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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "ui/gfx/image/image_skia.h" | 12 #include "ui/gfx/image/image_skia.h" |
13 #include "ui/views/background.h" | 13 #include "ui/views/background.h" |
14 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Rect; | 17 class Rect; |
18 class Path; | |
tapted
2016/02/05 04:51:07
nit: alphabetise
karandeepb
2016/02/08 07:47:09
Done. Didn't knew this was a word!
| |
18 } | 19 } |
19 | 20 |
21 class SkPath; | |
22 | |
20 namespace views { | 23 namespace views { |
21 class Painter; | 24 class Painter; |
22 | 25 |
23 namespace internal { | 26 namespace internal { |
24 | 27 |
25 // A helper that combines each border image-set painter with arrows and metrics. | 28 // A helper that combines each border image-set painter with arrows and metrics. |
26 struct BorderImages { | 29 struct BorderImages { |
27 BorderImages(const int border_image_ids[], | 30 BorderImages(const int border_image_ids[], |
28 const int arrow_image_ids[], | 31 const int arrow_image_ids[], |
29 int border_interior_thickness, | 32 int border_interior_thickness, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 | 200 |
198 // Get the border exterior thickness, including stroke and shadow, in pixels. | 201 // Get the border exterior thickness, including stroke and shadow, in pixels. |
199 int GetBorderThickness() const; | 202 int GetBorderThickness() const; |
200 | 203 |
201 // Returns the corner radius of the current image set. | 204 // Returns the corner radius of the current image set. |
202 int GetBorderCornerRadius() const; | 205 int GetBorderCornerRadius() const; |
203 | 206 |
204 // Gets the arrow offset to use. | 207 // Gets the arrow offset to use. |
205 int GetArrowOffset(const gfx::Size& border_size) const; | 208 int GetArrowOffset(const gfx::Size& border_size) const; |
206 | 209 |
210 // Retreives the arrow path given |view_bounds|. |view_bounds| should be in | |
211 // its own coordinates (origin at (0,0)). | |
212 // Returns false if |path| is unchanged, which is the case when there is no | |
213 // painted arrow. | |
214 // The returned path does not account for arrow stroke and shadow. | |
215 bool GetArrowPath(const gfx::Rect& view_bounds, gfx::Path* path) const; | |
216 | |
207 // Overridden from Border: | 217 // Overridden from Border: |
208 void Paint(const View& view, gfx::Canvas* canvas) override; | 218 void Paint(const View& view, gfx::Canvas* canvas) override; |
209 gfx::Insets GetInsets() const override; | 219 gfx::Insets GetInsets() const override; |
210 gfx::Size GetMinimumSize() const override; | 220 gfx::Size GetMinimumSize() const override; |
211 | 221 |
212 private: | 222 private: |
213 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest); | 223 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetSizeForContentsSizeTest); |
214 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest); | 224 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, GetBoundsOriginTest); |
215 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, ShadowTypes); | 225 FRIEND_TEST_ALL_PREFIXES(BubbleBorderTest, ShadowTypes); |
216 | 226 |
217 // The border and arrow stroke size used in image assets, in pixels. | 227 // The border and arrow stroke size used in image assets, in pixels. |
218 static const int kStroke; | 228 static const int kStroke; |
219 | 229 |
220 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; | 230 gfx::Size GetSizeForContentsSize(const gfx::Size& contents_size) const; |
221 gfx::ImageSkia* GetArrowImage() const; | 231 gfx::ImageSkia* GetArrowImage() const; |
222 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const; | 232 gfx::Rect GetArrowRect(const gfx::Rect& bounds) const; |
233 void GetArrowPathFromArrowBounds(const gfx::Rect& arrow_bounds, | |
234 SkPath* mask) const; | |
tapted
2016/02/05 04:51:07
nit: mask -> path
karandeepb
2016/02/08 07:47:09
Done.
| |
223 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const; | 235 void DrawArrow(gfx::Canvas* canvas, const gfx::Rect& arrow_bounds) const; |
224 | 236 |
225 internal::BorderImages* GetImagesForTest() const; | 237 internal::BorderImages* GetImagesForTest() const; |
226 | 238 |
227 Arrow arrow_; | 239 Arrow arrow_; |
228 int arrow_offset_; | 240 int arrow_offset_; |
229 ArrowPaintType arrow_paint_type_; | 241 ArrowPaintType arrow_paint_type_; |
230 BubbleAlignment alignment_; | 242 BubbleAlignment alignment_; |
231 Shadow shadow_; | 243 Shadow shadow_; |
232 internal::BorderImages* images_; | 244 internal::BorderImages* images_; |
(...skipping 14 matching lines...) Expand all Loading... | |
247 | 259 |
248 private: | 260 private: |
249 BubbleBorder* border_; | 261 BubbleBorder* border_; |
250 | 262 |
251 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); | 263 DISALLOW_COPY_AND_ASSIGN(BubbleBackground); |
252 }; | 264 }; |
253 | 265 |
254 } // namespace views | 266 } // namespace views |
255 | 267 |
256 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ | 268 #endif // UI_VIEWS_BUBBLE_BUBBLE_BORDER_H_ |
OLD | NEW |