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/font_list.h" | |
11 #include "ui/gfx/geometry/insets.h" | 12 #include "ui/gfx/geometry/insets.h" |
12 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
14 #include "ui/views/controls/label.h" | |
13 #include "ui/views/window/non_client_view.h" | 15 #include "ui/views/window/non_client_view.h" |
14 | 16 |
15 namespace gfx { | |
16 class FontList; | |
17 } | |
18 | |
19 namespace views { | 17 namespace views { |
20 | 18 |
21 class Label; | |
22 class BubbleBorder; | 19 class BubbleBorder; |
23 class ImageView; | 20 class ImageView; |
24 | 21 |
25 // The non-client frame view of bubble-styled widgets. | 22 // The non-client frame view of bubble-styled widgets. |
26 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView, | 23 class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView, |
27 public ButtonListener { | 24 public ButtonListener { |
28 public: | 25 public: |
29 // Internal class name. | 26 // Internal class name. |
30 static const char kViewClassName[]; | 27 static const char kViewClassName[]; |
31 | 28 |
32 BubbleFrameView(const gfx::Insets& title_margins, | 29 BubbleFrameView(const gfx::Insets& title_margins, |
33 const gfx::Insets& content_margins); | 30 const gfx::Insets& content_margins); |
34 ~BubbleFrameView() override; | 31 ~BubbleFrameView() override; |
35 | 32 |
33 static Label* CreateDefaultTitleLabel(const base::string16& title_text); | |
34 | |
36 // Creates a close button used in the corner of the dialog. | 35 // Creates a close button used in the corner of the dialog. |
37 static Button* CreateCloseButton(ButtonListener* listener); | 36 static Button* CreateCloseButton(ButtonListener* listener); |
38 | 37 |
39 // NonClientFrameView: | 38 // NonClientFrameView: |
40 gfx::Rect GetBoundsForClientView() const override; | 39 gfx::Rect GetBoundsForClientView() const override; |
41 gfx::Rect GetWindowBoundsForClientBounds( | 40 gfx::Rect GetWindowBoundsForClientBounds( |
42 const gfx::Rect& client_bounds) const override; | 41 const gfx::Rect& client_bounds) const override; |
43 bool GetClientMask(const gfx::Size& size, gfx::Path* path) const override; | 42 bool GetClientMask(const gfx::Size& size, gfx::Path* path) const override; |
44 int NonClientHitTest(const gfx::Point& point) override; | 43 int NonClientHitTest(const gfx::Point& point) override; |
45 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; | 44 void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask) override; |
46 void ResetWindowControls() override; | 45 void ResetWindowControls() override; |
47 void UpdateWindowIcon() override; | 46 void UpdateWindowIcon() override; |
48 void UpdateWindowTitle() override; | 47 void UpdateWindowTitle() override; |
49 void SizeConstraintsChanged() override; | 48 void SizeConstraintsChanged() override; |
50 | 49 |
51 // Set the FontList to be used for the title of the bubble. | 50 // Sets a custom view to be the dialog title instead of the |default_title_| |
52 // Caller must arrange to update the layout to have the call take effect. | 51 // label. The title view is owned by this BubbleFrameView. If there is an |
53 void SetTitleFontList(const gfx::FontList& font_list); | 52 // existing title view it will be deleted. |
53 void SetTitleView(View* title_view); | |
54 | 54 |
55 // View: | 55 // View: |
56 const char* GetClassName() const override; | 56 const char* GetClassName() const override; |
57 gfx::Insets GetInsets() const override; | 57 gfx::Insets GetInsets() const override; |
58 gfx::Size CalculatePreferredSize() const override; | 58 gfx::Size CalculatePreferredSize() const override; |
59 gfx::Size GetMinimumSize() const override; | 59 gfx::Size GetMinimumSize() const override; |
60 gfx::Size GetMaximumSize() const override; | 60 gfx::Size GetMaximumSize() const override; |
61 void Layout() override; | 61 void Layout() override; |
62 void OnPaint(gfx::Canvas* canvas) override; | 62 void OnPaint(gfx::Canvas* canvas) override; |
63 void PaintChildren(const ui::PaintContext& context) override; | 63 void PaintChildren(const ui::PaintContext& context) override; |
(...skipping 30 matching lines...) Expand all Loading... | |
94 | 94 |
95 bool IsCloseButtonVisible() const; | 95 bool IsCloseButtonVisible() const; |
96 gfx::Rect GetCloseButtonMirroredBounds() const; | 96 gfx::Rect GetCloseButtonMirroredBounds() const; |
97 | 97 |
98 private: | 98 private: |
99 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); | 99 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView); |
100 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, RemoveFootnoteView); | 100 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, RemoveFootnoteView); |
101 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CloseReasons); | 101 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CloseReasons); |
102 FRIEND_TEST_ALL_PREFIXES(BubbleDialogDelegateTest, CloseMethods); | 102 FRIEND_TEST_ALL_PREFIXES(BubbleDialogDelegateTest, CloseMethods); |
103 | 103 |
104 View* title() const { | |
Peter Kasting
2017/06/17 01:16:20
Const member functions shouldn't return non-const
Bret
2017/06/21 22:37:55
Done, made const and non-const getters.
| |
105 return delegate_title_ ? delegate_title_ : default_title_; | |
106 } | |
107 | |
104 // Mirrors the bubble's arrow location on the |vertical| or horizontal axis, | 108 // Mirrors the bubble's arrow location on the |vertical| or horizontal axis, |
105 // if the generated window bounds don't fit in the monitor bounds. | 109 // if the generated window bounds don't fit in the monitor bounds. |
106 void MirrorArrowIfOffScreen(bool vertical, | 110 void MirrorArrowIfOffScreen(bool vertical, |
107 const gfx::Rect& anchor_rect, | 111 const gfx::Rect& anchor_rect, |
108 const gfx::Size& client_size); | 112 const gfx::Size& client_size); |
109 | 113 |
110 // Adjust the bubble's arrow offsets if the generated window bounds don't fit | 114 // Adjust the bubble's arrow offsets if the generated window bounds don't fit |
111 // in the monitor bounds. | 115 // in the monitor bounds. |
112 void OffsetArrowIfOffScreen(const gfx::Rect& anchor_rect, | 116 void OffsetArrowIfOffScreen(const gfx::Rect& anchor_rect, |
113 const gfx::Size& client_size); | 117 const gfx::Size& client_size); |
114 | 118 |
115 // Calculates the size needed to accommodate the given client area. | 119 // Calculates the size needed to accommodate the given client area. |
116 gfx::Size GetSizeForClientSize(const gfx::Size& client_size) const; | 120 gfx::Size GetSizeForClientSize(const gfx::Size& client_size) const; |
117 | 121 |
118 // The bubble border. | 122 // The bubble border. |
119 BubbleBorder* bubble_border_; | 123 BubbleBorder* bubble_border_; |
120 | 124 |
121 // Margins around the title label. | 125 // Margins around the title label. |
122 gfx::Insets title_margins_; | 126 gfx::Insets title_margins_; |
123 | 127 |
124 // Margins between the content and the inside of the border, in pixels. | 128 // Margins between the content and the inside of the border, in pixels. |
125 gfx::Insets content_margins_; | 129 gfx::Insets content_margins_; |
126 | 130 |
127 // The optional title icon, title, and (x) close button. | 131 // The optional title icon, title, and (x) close button. |
128 views::ImageView* title_icon_; | 132 views::ImageView* title_icon_; |
129 Label* title_; | 133 Label* default_title_; |
134 View* delegate_title_; | |
130 Button* close_; | 135 Button* close_; |
131 | 136 |
132 // A view to contain the footnote view, if it exists. | 137 // A view to contain the footnote view, if it exists. |
133 View* footnote_container_; | 138 View* footnote_container_; |
134 | 139 |
135 // Whether the close button was clicked. | 140 // Whether the close button was clicked. |
136 bool close_button_clicked_; | 141 bool close_button_clicked_; |
137 | 142 |
138 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); | 143 DISALLOW_COPY_AND_ASSIGN(BubbleFrameView); |
139 }; | 144 }; |
140 | 145 |
141 } // namespace views | 146 } // namespace views |
142 | 147 |
143 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ | 148 #endif // UI_VIEWS_BUBBLE_BUBBLE_FRAME_VIEW_H_ |
OLD | NEW |