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_FRAME_VIEW_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
6 #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_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 "ui/gfx/geometry/insets.h" | 11 #include "ui/gfx/geometry/insets.h" |
12 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
13 #include "ui/views/controls/button/image_button.h" | |
14 #include "ui/views/window/non_client_view.h" | 13 #include "ui/views/window/non_client_view.h" |
15 | 14 |
16 namespace gfx { | 15 namespace gfx { |
17 class FontList; | 16 class FontList; |
18 } | 17 } |
19 | 18 |
20 namespace views { | 19 namespace views { |
21 | 20 |
22 class Label; | 21 class Label; |
23 class LabelButton; | 22 class LabelButton; |
24 class BubbleBorder; | 23 class BubbleBorder; |
25 class ImageView; | 24 class ImageView; |
26 | 25 |
27 // The non-client frame view of bubble-styled widgets. | 26 // The non-client frame view of bubble-styled widgets. |
28 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView, | 27 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView, |
29 public ButtonListener { | 28 public ButtonListener { |
30 public: | 29 public: |
31 // Internal class name. | 30 // Internal class name. |
32 static const char kViewClassName[]; | 31 static const char kViewClassName[]; |
33 | 32 |
34 BubbleFrameView(const gfx::Insets& title_margins, | 33 BubbleFrameView(const gfx::Insets& title_margins, |
35 const gfx::Insets& content_margins); | 34 const gfx::Insets& content_margins); |
36 ~BubbleFrameView() override; | 35 ~BubbleFrameView() override; |
37 | 36 |
38 // Creates a close button used in the corner of the dialog. | 37 // Creates a close button used in the corner of the dialog. |
39 static ImageButton* CreateCloseButton(ButtonListener* listener); | 38 static LabelButton* CreateCloseButton(ButtonListener* listener); |
40 | 39 |
41 // NonClientFrameView overrides: | 40 // NonClientFrameView overrides: |
42 gfx::Rect GetBoundsForClientView() const override; | 41 gfx::Rect GetBoundsForClientView() const override; |
43 gfx::Rect GetWindowBoundsForClientBounds( | 42 gfx::Rect GetWindowBoundsForClientBounds( |
44 const gfx::Rect& client_bounds) const override; | 43 const gfx::Rect& client_bounds) const override; |
45 bool GetClientMask(const gfx::Size& size, gfx::Path* path) const override; | 44 bool GetClientMask(const gfx::Size& size, gfx::Path* path) const override; |
46 int NonClientHitTest(const gfx::Point& point) override; | 45 int NonClientHitTest(const gfx::Point& point) override; |
47 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; | 46 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; |
48 void ResetWindowControls() override; | 47 void ResetWindowControls() override; |
49 void UpdateWindowIcon() override; | 48 void UpdateWindowIcon() override; |
(...skipping 29 matching lines...) Expand all Loading... |
79 | 78 |
80 // Given the size of the contents and the rect to point at, returns the bounds | 79 // Given the size of the contents and the rect to point at, returns the bounds |
81 // of the bubble window. The bubble's arrow location may change if the bubble | 80 // of the bubble window. The bubble's arrow location may change if the bubble |
82 // does not fit on the monitor and |adjust_if_offscreen| is true. | 81 // does not fit on the monitor and |adjust_if_offscreen| is true. |
83 gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, | 82 gfx::Rect GetUpdatedWindowBounds(const gfx::Rect& anchor_rect, |
84 gfx::Size client_size, | 83 gfx::Size client_size, |
85 bool adjust_if_offscreen); | 84 bool adjust_if_offscreen); |
86 | 85 |
87 bool close_button_clicked() const { return close_button_clicked_; } | 86 bool close_button_clicked() const { return close_button_clicked_; } |
88 | 87 |
89 ImageButton* GetCloseButtonForTest() { return close_; } | 88 LabelButton* GetCloseButtonForTest() { return close_; } |
90 | 89 |
91 protected: | 90 protected: |
92 // Returns the available screen bounds if the frame were to show in |rect|. | 91 // Returns the available screen bounds if the frame were to show in |rect|. |
93 virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const; | 92 virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) const; |
94 | 93 |
95 bool IsCloseButtonVisible() const; | 94 bool IsCloseButtonVisible() const; |
96 gfx::Rect GetCloseButtonMirroredBounds() const; | 95 gfx::Rect GetCloseButtonMirroredBounds() const; |
97 | 96 |
98 private: | 97 private: |
99 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); | 98 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 118 |
120 // Margins around the title label. | 119 // Margins around the title label. |
121 gfx::Insets title_margins_; | 120 gfx::Insets title_margins_; |
122 | 121 |
123 // Margins between the content and the inside of the border, in pixels. | 122 // Margins between the content and the inside of the border, in pixels. |
124 gfx::Insets content_margins_; | 123 gfx::Insets content_margins_; |
125 | 124 |
126 // The optional title icon, title, and (x) close button. | 125 // The optional title icon, title, and (x) close button. |
127 views::ImageView* title_icon_; | 126 views::ImageView* title_icon_; |
128 Label* title_; | 127 Label* title_; |
129 ImageButton* close_; | 128 LabelButton* close_; |
130 | 129 |
131 // A view to contain the footnote view, if it exists. | 130 // A view to contain the footnote view, if it exists. |
132 View* footnote_container_; | 131 View* footnote_container_; |
133 | 132 |
134 // Whether the close button was clicked. | 133 // Whether the close button was clicked. |
135 bool close_button_clicked_; | 134 bool close_button_clicked_; |
136 | 135 |
137 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); | 136 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); |
138 }; | 137 }; |
139 | 138 |
140 } // namespace views | 139 } // namespace views |
141 | 140 |
142 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 141 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
OLD | NEW |