OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef UI_VIEWS_BUBBLE_IMAGELESS_BUBBLE_BORDER_H_ | |
6 #define UI_VIEWS_BUBBLE_IMAGELESS_BUBBLE_BORDER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "ui/gfx/shadow_value.h" | |
11 #include "ui/views/bubble/bubble_border.h" | |
12 | |
13 namespace views { | |
14 | |
15 // Renders a border, similar to the BubbleBorder completely using skia (as | |
msw
2012/08/03 06:32:21
Consider: "A BubbleBorder rendered with Skia drawi
varunjain
2012/08/03 15:17:43
Done.
| |
16 // opposed to BubbleBorder which is composed of images; hence, "Imageless"). | |
17 class VIEWS_EXPORT ImagelessBubbleBorder : public BubbleBorder { | |
msw
2012/08/03 06:32:21
I dislike the name, but lack a good suggestion, ma
varunjain
2012/08/03 15:17:43
Done.
| |
18 public: | |
19 | |
msw
2012/08/03 06:32:21
nit: remove blank line.
varunjain
2012/08/03 15:17:43
Done.
| |
20 explicit ImagelessBubbleBorder(ArrowLocation arrow_location); | |
21 virtual ~ImagelessBubbleBorder(); | |
22 | |
23 // Given the |bubble_rect| that this border encloses, and the bounds of the | |
24 // anchor view |anchor_view_rect|, compute the right offset to place the | |
25 // arrow at shifting the |bubble_rect| to fit inside the display area if | |
26 // needed. Returns the shifted |bubble_rect|. | |
27 gfx::Rect ComputeOffsetAndUpdateBubbleRect(gfx::Rect bubble_rect, | |
28 const gfx::Rect& anchor_view_rect); | |
29 | |
30 // Returns the path in |mask| that would be created if this border were to be | |
31 // applied to the rect specified by |bounds|. | |
32 void GetMask(const gfx::Rect& bounds, gfx::Path* mask) const; | |
33 | |
34 void set_offset(const gfx::Point& offset) { offset_ = offset; } | |
35 const gfx::Point& offset() const { return offset_; } | |
36 | |
37 void set_corner_radius(int corner_radius) { corner_radius_ = corner_radius; } | |
38 int corner_radius() { return corner_radius_; } | |
39 | |
40 void set_border_size(int border_size) { border_size_ = border_size; } | |
41 int border_size() { return border_size_; } | |
42 | |
43 void set_arrow_height(int arrow_height) { arrow_height_ = arrow_height; } | |
44 int arrow_height() { return arrow_height_; } | |
45 | |
46 void set_arrow_width(int arrow_width) { arrow_width_ = arrow_width; } | |
47 int arrow_width() { return arrow_width_; } | |
48 | |
49 void SetShadow(gfx::ShadowValue shadow); | |
50 | |
51 // views::BubbleBorder overrides: | |
52 int border_thickness() const OVERRIDE; | |
53 | |
54 protected: | |
55 void PaintBackground(gfx::Canvas* canvas, | |
56 const gfx::Rect& bounds) const; | |
57 | |
58 private: | |
59 // Returns true if arrow location is at the top or the bottom of the border. | |
60 bool ArrowAtTopOrBottom() const; | |
61 | |
62 // Returns true if arrow location is at the left or the right of the border. | |
63 bool ArrowOnLeftOrRight() const; | |
64 | |
65 // Gets arrow offset based on arrow location and |offset_|. | |
66 int GetArrowOffset() const; | |
67 | |
68 // views::BubbleBorder overrides: | |
69 virtual void GetInsets(gfx::Insets* insets) const OVERRIDE; | |
70 virtual gfx::Rect GetBounds(const gfx::Rect& position_relative_to, | |
71 const gfx::Size& contents_size) const OVERRIDE; | |
72 void GetInsetsForArrowLocation(gfx::Insets* insets, | |
73 ArrowLocation arrow_loc) const OVERRIDE; | |
74 | |
75 // Overridden from Border: | |
msw
2012/08/03 06:32:21
nit: match override comment style from above.
varunjain
2012/08/03 15:17:43
Done.
| |
76 virtual void Paint(const View& view, | |
77 gfx::Canvas* canvas) const OVERRIDE; | |
78 | |
79 int corner_radius_; | |
80 int border_size_; | |
81 int arrow_height_; | |
82 int arrow_width_; | |
83 SkColor background_color_; | |
84 SkColor border_color_; | |
85 | |
86 // Offset in pixels relative the default middle position. | |
msw
2012/08/03 06:32:21
nit: offset of what? Please clarify comment and/or
varunjain
2012/08/03 15:17:43
Done.
| |
87 gfx::Point offset_; | |
88 | |
89 gfx::ShadowValues shadows_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(ImagelessBubbleBorder); | |
92 }; | |
93 | |
94 } // namespace views | |
95 | |
96 #endif // UI_VIEWS_BUBBLE_IMAGELESS_BUBBLE_BORDER_H_ | |
OLD | NEW |