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_DELEGATE_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
6 #define UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "ui/views/bubble/bubble_border.h" | 9 #include "ui/views/bubble/bubble_border.h" |
10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
11 #include "ui/views/widget/widget_delegate.h" | 11 #include "ui/views/widget/widget_delegate.h" |
12 #include "ui/views/widget/widget_observer.h" | 12 #include "ui/views/widget/widget_observer.h" |
13 | 13 |
14 namespace gfx { | 14 namespace gfx { |
15 class FontList; | 15 class FontList; |
16 class Rect; | 16 class Rect; |
17 } | 17 } |
18 | 18 |
19 namespace views { | 19 namespace views { |
20 | 20 |
21 class BubbleFrameView; | 21 class BubbleFrameView; |
22 | 22 |
23 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
24 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
25 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 25 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
26 public WidgetObserver { | 26 public WidgetObserver { |
27 public: | 27 public: |
28 BubbleDelegateView(); | 28 BubbleDelegateView(); |
29 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | 29 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); |
30 virtual ~BubbleDelegateView(); | 30 ~BubbleDelegateView() override; |
31 | 31 |
32 // Create and initialize the bubble Widget(s) with proper bounds. | 32 // Create and initialize the bubble Widget(s) with proper bounds. |
33 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 33 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
34 | 34 |
35 // WidgetDelegateView overrides: | 35 // WidgetDelegateView overrides: |
36 virtual BubbleDelegateView* AsBubbleDelegate() override; | 36 BubbleDelegateView* AsBubbleDelegate() override; |
37 virtual bool ShouldShowCloseButton() const override; | 37 bool ShouldShowCloseButton() const override; |
38 virtual View* GetContentsView() override; | 38 View* GetContentsView() override; |
39 virtual NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; | 39 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
40 virtual void GetAccessibleState(ui::AXViewState* state) override; | 40 void GetAccessibleState(ui::AXViewState* state) override; |
41 | 41 |
42 // WidgetObserver overrides: | 42 // WidgetObserver overrides: |
43 virtual void OnWidgetDestroying(Widget* widget) override; | 43 void OnWidgetDestroying(Widget* widget) override; |
44 virtual void OnWidgetVisibilityChanging(Widget* widget, bool visible) | 44 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; |
45 override; | 45 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; |
46 virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) | 46 void OnWidgetActivationChanged(Widget* widget, bool active) override; |
47 override; | 47 void OnWidgetBoundsChanged(Widget* widget, |
48 virtual void OnWidgetActivationChanged(Widget* widget, bool active) override; | 48 const gfx::Rect& new_bounds) override; |
49 virtual void OnWidgetBoundsChanged(Widget* widget, | |
50 const gfx::Rect& new_bounds) override; | |
51 | 49 |
52 bool close_on_esc() const { return close_on_esc_; } | 50 bool close_on_esc() const { return close_on_esc_; } |
53 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 51 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
54 | 52 |
55 bool close_on_deactivate() const { return close_on_deactivate_; } | 53 bool close_on_deactivate() const { return close_on_deactivate_; } |
56 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } | 54 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } |
57 | 55 |
58 View* GetAnchorView() const; | 56 View* GetAnchorView() const; |
59 Widget* anchor_widget() const { return anchor_widget_; } | 57 Widget* anchor_widget() const { return anchor_widget_; } |
60 | 58 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 110 |
113 protected: | 111 protected: |
114 // Get bubble bounds from the anchor rect and client view's preferred size. | 112 // Get bubble bounds from the anchor rect and client view's preferred size. |
115 virtual gfx::Rect GetBubbleBounds(); | 113 virtual gfx::Rect GetBubbleBounds(); |
116 | 114 |
117 // Return a FontList to use for the title of the bubble. | 115 // Return a FontList to use for the title of the bubble. |
118 // (The default is MediumFont). | 116 // (The default is MediumFont). |
119 virtual const gfx::FontList& GetTitleFontList() const; | 117 virtual const gfx::FontList& GetTitleFontList() const; |
120 | 118 |
121 // View overrides: | 119 // View overrides: |
122 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 120 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
123 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 121 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
124 | 122 |
125 // Perform view initialization on the contents for bubble sizing. | 123 // Perform view initialization on the contents for bubble sizing. |
126 virtual void Init(); | 124 virtual void Init(); |
127 | 125 |
128 // Sets the anchor view or rect and repositions the bubble. Note that if a | 126 // Sets the anchor view or rect and repositions the bubble. Note that if a |
129 // valid view gets passed, the anchor rect will get ignored. If the view gets | 127 // valid view gets passed, the anchor rect will get ignored. If the view gets |
130 // deleted, but no new view gets set, the last known anchor postion will get | 128 // deleted, but no new view gets set, the last known anchor postion will get |
131 // returned. | 129 // returned. |
132 void SetAnchorView(View* anchor_view); | 130 void SetAnchorView(View* anchor_view); |
133 void SetAnchorRect(const gfx::Rect& rect); | 131 void SetAnchorRect(const gfx::Rect& rect); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 187 |
190 // Parent native window of the bubble. | 188 // Parent native window of the bubble. |
191 gfx::NativeView parent_window_; | 189 gfx::NativeView parent_window_; |
192 | 190 |
193 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 191 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
194 }; | 192 }; |
195 | 193 |
196 } // namespace views | 194 } // namespace views |
197 | 195 |
198 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 196 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |