OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "ui/gfx/image/image_skia.h" | |
10 #include "ui/views/background.h" | 11 #include "ui/views/background.h" |
11 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
12 | 13 |
13 namespace gfx { | 14 namespace gfx { |
14 class ImageSkia; | 15 class ImageSkia; |
msw
2014/08/22 20:54:44
nit: remove forward decl.
bruthig
2014/08/22 22:55:03
Done.
| |
15 class Rect; | 16 class Rect; |
16 } | 17 } |
17 | 18 |
18 namespace views { | 19 namespace views { |
20 class Painter; | |
19 | 21 |
20 namespace internal { | 22 namespace internal { |
21 struct BorderImages; | 23 |
22 } | 24 // A helper that combines each border image-set painter with arrows and metrics. |
25 struct BorderImages { | |
26 BorderImages(const int border_image_ids[], | |
27 const int arrow_image_ids[], | |
28 int border_interior_thickness, | |
29 int arrow_interior_thickness, | |
30 int corner_radius); | |
31 virtual ~BorderImages(); | |
32 | |
33 scoped_ptr<Painter> border_painter; | |
msw
2014/08/22 20:54:44
nit: add a base/memory/scoped_ptr.h include
bruthig
2014/08/22 22:55:03
Done.
| |
34 gfx::ImageSkia left_arrow; | |
35 gfx::ImageSkia top_arrow; | |
36 gfx::ImageSkia right_arrow; | |
37 gfx::ImageSkia bottom_arrow; | |
38 | |
39 // The thickness of border and arrow images and their interior areas. | |
40 // Thickness is the width of left/right and the height of top/bottom images. | |
41 // The interior is measured without including stroke or shadow pixels. | |
42 int border_thickness; | |
43 int border_interior_thickness; | |
44 int arrow_thickness; | |
45 int arrow_interior_thickness; | |
46 // The corner radius of the bubble's rounded-rect interior area. | |
47 int corner_radius; | |
48 }; | |
49 | |
50 } // namespace internal | |
23 | 51 |
24 // Renders a border, with optional arrow, and a custom dropshadow. | 52 // Renders a border, with optional arrow, and a custom dropshadow. |
25 // This can be used to produce floating "bubble" objects with rounded corners. | 53 // This can be used to produce floating "bubble" objects with rounded corners. |
26 class VIEWS_EXPORT BubbleBorder : public Border { | 54 class VIEWS_EXPORT BubbleBorder : public Border { |
27 public: | 55 public: |
28 // Possible locations for the (optional) arrow. | 56 // Possible locations for the (optional) arrow. |
29 // 0 bit specifies left or right. | 57 // 0 bit specifies left or right. |
30 // 1 bit specifies top or bottom. | 58 // 1 bit specifies top or bottom. |
31 // 2 bit specifies horizontal or vertical. | 59 // 2 bit specifies horizontal or vertical. |
32 // 3 bit specifies whether the arrow at the center of its residing edge. | 60 // 3 bit specifies whether the arrow at the center of its residing edge. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 194 |
167 // Gets the arrow offset to use. | 195 // Gets the arrow offset to use. |
168 int GetArrowOffset(const gfx::Size& border_size) const; | 196 int GetArrowOffset(const gfx::Size& border_size) const; |
169 | 197 |
170 // Overridden from Border: | 198 // Overridden from Border: |
171 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE; | 199 virtual void Paint(const View& view, gfx::Canvas* canvas) OVERRIDE; |
172 virtual gfx::Insets GetInsets() const OVERRIDE; | 200 virtual gfx::Insets GetInsets() const OVERRIDE; |
173 virtual gfx::Size GetMinimumSize() const OVERRIDE; | 201 virtual gfx::Size GetMinimumSize() const OVERRIDE; |
174 | 202 |
175 private: | 203 private: |
204 friend class BubbleBorderTest; | |
msw
2014/08/22 20:54:44
Remove this (as per typedefing and/or moving kStro
bruthig
2014/08/22 22:55:03
Done.
| |
205 | |
msw
2014/08/22 20:54:44
nit: remove blank line.
bruthig
2014/08/22 22:55:03
Done.
| |
206 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest); | |
207 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest); | |
208 | |
209 // The border and arrow stroke size used in image assets, in pixels. | |
210 static const int kStroke; | |
211 | |
176 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; | 212 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; |
177 gfx::ImageSkia* GetArrowImage() const; | 213 gfx::ImageSkia* GetArrowImage() const; |
178 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const; | 214 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const; |
179 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const; | 215 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const; |
180 | 216 |
217 internal::BorderImages* GetImagesForTest() const { | |
msw
2014/08/22 20:54:44
nit: define this in the .cc file (to match CamelCa
bruthig
2014/08/22 22:55:03
Done.
| |
218 return images_; | |
219 } | |
220 | |
181 Arrow arrow_; | 221 Arrow arrow_; |
182 int arrow_offset_; | 222 int arrow_offset_; |
183 ArrowPaintType arrow_paint_type_; | 223 ArrowPaintType arrow_paint_type_; |
184 BubbleAlignment alignment_; | 224 BubbleAlignment alignment_; |
185 Shadow shadow_; | 225 Shadow shadow_; |
186 internal::BorderImages* images_; | 226 internal::BorderImages* images_; |
187 SkColor background_color_; | 227 SkColor background_color_; |
188 bool use_theme_background_color_; | 228 bool use_theme_background_color_; |
189 | 229 |
190 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); | 230 DISALLOW_COPY_AND_ASSIGN(BubbleBorder); |
(...skipping 10 matching lines...) Expand all Loading... | |
201 | 241 |
202 private: | 242 private: |
203 BubbleBorder* border_; | 243 BubbleBorder* border_; |
204 | 244 |
205 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); | 245 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); |
206 }; | 246 }; |
207 | 247 |
208 } // namespace views | 248 } // namespace views |
209 | 249 |
210 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 250 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
OLD | NEW |