| 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" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 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 // Internal class name. | 28 // Internal class name. |
| 29 static const char kViewClassName[]; | 29 static const char kViewClassName[]; |
| 30 | 30 |
| 31 enum class CloseReason { |
| 32 DEACTIVATION, |
| 33 ESCAPE, |
| 34 CLOSE_BUTTON, |
| 35 UNKNOWN, |
| 36 }; |
| 37 |
| 31 BubbleDelegateView(); | 38 BubbleDelegateView(); |
| 32 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | 39 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); |
| 33 ~BubbleDelegateView() override; | 40 ~BubbleDelegateView() override; |
| 34 | 41 |
| 35 // Create and initialize the bubble Widget(s) with proper bounds. | 42 // Create and initialize the bubble Widget(s) with proper bounds. |
| 36 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 43 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
| 37 | 44 |
| 38 // WidgetDelegateView overrides: | 45 // WidgetDelegateView overrides: |
| 39 BubbleDelegateView* AsBubbleDelegate() override; | 46 BubbleDelegateView* AsBubbleDelegate() override; |
| 40 bool ShouldShowCloseButton() const override; | 47 bool ShouldShowCloseButton() const override; |
| 41 View* GetContentsView() override; | 48 View* GetContentsView() override; |
| 42 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; | 49 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
| 43 void GetAccessibleState(ui::AXViewState* state) override; | 50 void GetAccessibleState(ui::AXViewState* state) override; |
| 44 const char* GetClassName() const override; | 51 const char* GetClassName() const override; |
| 45 | 52 |
| 46 // WidgetObserver overrides: | 53 // WidgetObserver overrides: |
| 54 void OnWidgetClosing(Widget* widget) override; |
| 47 void OnWidgetDestroying(Widget* widget) override; | 55 void OnWidgetDestroying(Widget* widget) override; |
| 48 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; | 56 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; |
| 49 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; | 57 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; |
| 50 void OnWidgetActivationChanged(Widget* widget, bool active) override; | 58 void OnWidgetActivationChanged(Widget* widget, bool active) override; |
| 51 void OnWidgetBoundsChanged(Widget* widget, | 59 void OnWidgetBoundsChanged(Widget* widget, |
| 52 const gfx::Rect& new_bounds) override; | 60 const gfx::Rect& new_bounds) override; |
| 53 | 61 |
| 54 bool close_on_esc() const { return close_on_esc_; } | 62 bool close_on_esc() const { return close_on_esc_; } |
| 55 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 63 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
| 56 | 64 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 86 | 94 |
| 87 bool accept_events() const { return accept_events_; } | 95 bool accept_events() const { return accept_events_; } |
| 88 void set_accept_events(bool accept_events) { accept_events_ = accept_events; } | 96 void set_accept_events(bool accept_events) { accept_events_ = accept_events; } |
| 89 | 97 |
| 90 bool border_accepts_events() const { return border_accepts_events_; } | 98 bool border_accepts_events() const { return border_accepts_events_; } |
| 91 void set_border_accepts_events(bool event) { border_accepts_events_ = event; } | 99 void set_border_accepts_events(bool event) { border_accepts_events_ = event; } |
| 92 | 100 |
| 93 bool adjust_if_offscreen() const { return adjust_if_offscreen_; } | 101 bool adjust_if_offscreen() const { return adjust_if_offscreen_; } |
| 94 void set_adjust_if_offscreen(bool adjust) { adjust_if_offscreen_ = adjust; } | 102 void set_adjust_if_offscreen(bool adjust) { adjust_if_offscreen_ = adjust; } |
| 95 | 103 |
| 104 CloseReason close_reason() const { return close_reason_; } |
| 105 |
| 96 // Get the arrow's anchor rect in screen space. | 106 // Get the arrow's anchor rect in screen space. |
| 97 virtual gfx::Rect GetAnchorRect() const; | 107 virtual gfx::Rect GetAnchorRect() const; |
| 98 | 108 |
| 99 // Allows delegates to provide custom parameters before widget initialization. | 109 // Allows delegates to provide custom parameters before widget initialization. |
| 100 virtual void OnBeforeBubbleWidgetInit(Widget::InitParams* params, | 110 virtual void OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
| 101 Widget* widget) const; | 111 Widget* widget) const; |
| 102 | 112 |
| 103 // Sets the bubble alignment relative to the anchor. This may only be called | 113 // Sets the bubble alignment relative to the anchor. This may only be called |
| 104 // after calling CreateBubble. | 114 // after calling CreateBubble. |
| 105 void SetAlignment(BubbleBorder::BubbleAlignment alignment); | 115 void SetAlignment(BubbleBorder::BubbleAlignment alignment); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 bool accept_events_; | 195 bool accept_events_; |
| 186 bool border_accepts_events_; | 196 bool border_accepts_events_; |
| 187 | 197 |
| 188 // If true (defaults to true), the arrow may be mirrored and moved to fit the | 198 // If true (defaults to true), the arrow may be mirrored and moved to fit the |
| 189 // bubble on screen better. It would be a no-op if the bubble has no arrow. | 199 // bubble on screen better. It would be a no-op if the bubble has no arrow. |
| 190 bool adjust_if_offscreen_; | 200 bool adjust_if_offscreen_; |
| 191 | 201 |
| 192 // Parent native window of the bubble. | 202 // Parent native window of the bubble. |
| 193 gfx::NativeView parent_window_; | 203 gfx::NativeView parent_window_; |
| 194 | 204 |
| 205 CloseReason close_reason_; |
| 206 |
| 195 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 207 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 196 }; | 208 }; |
| 197 | 209 |
| 198 } // namespace views | 210 } // namespace views |
| 199 | 211 |
| 200 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 212 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |