| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_DIALOG_DELEGATE_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_ |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_ | 6 #define UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 // BubbleDialogDelegateView is a special DialogDelegateView for bubbles. | 24 // BubbleDialogDelegateView is a special DialogDelegateView for bubbles. |
| 25 class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView, | 25 class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView, |
| 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 { | 31 enum class CloseReason { |
| 32 DEACTIVATION, | 32 DEACTIVATION, |
| 33 ESCAPE, | |
| 34 CLOSE_BUTTON, | 33 CLOSE_BUTTON, |
| 35 UNKNOWN, | 34 UNKNOWN, |
| 36 }; | 35 }; |
| 37 | 36 |
| 38 ~BubbleDialogDelegateView() override; | 37 ~BubbleDialogDelegateView() override; |
| 39 | 38 |
| 40 // Create and initialize the bubble Widget(s) with proper bounds. | 39 // Create and initialize the bubble Widget(s) with proper bounds. |
| 41 static Widget* CreateBubble(BubbleDialogDelegateView* bubble_delegate); | 40 static Widget* CreateBubble(BubbleDialogDelegateView* bubble_delegate); |
| 42 | 41 |
| 43 // WidgetDelegateView overrides: | 42 // WidgetDelegateView overrides: |
| 43 BubbleDialogDelegateView* AsBubbleDialogDelegate() override; |
| 44 bool ShouldShowCloseButton() const override; | 44 bool ShouldShowCloseButton() const override; |
| 45 ClientView* CreateClientView(Widget* widget) override; | 45 ClientView* CreateClientView(Widget* widget) override; |
| 46 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; | 46 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
| 47 void GetAccessibleState(ui::AXViewState* state) override; | 47 void GetAccessibleState(ui::AXViewState* state) override; |
| 48 const char* GetClassName() const override; | 48 const char* GetClassName() const override; |
| 49 | 49 |
| 50 // WidgetObserver overrides: | 50 // WidgetObserver overrides: |
| 51 void OnWidgetClosing(Widget* widget) override; | 51 void OnWidgetClosing(Widget* widget) override; |
| 52 void OnWidgetDestroying(Widget* widget) override; | 52 void OnWidgetDestroying(Widget* widget) override; |
| 53 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; | 53 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; |
| 54 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; | 54 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; |
| 55 void OnWidgetActivationChanged(Widget* widget, bool active) override; | 55 void OnWidgetActivationChanged(Widget* widget, bool active) override; |
| 56 void OnWidgetBoundsChanged(Widget* widget, | 56 void OnWidgetBoundsChanged(Widget* widget, |
| 57 const gfx::Rect& new_bounds) override; | 57 const gfx::Rect& new_bounds) override; |
| 58 | 58 |
| 59 bool close_on_esc() const { return close_on_esc_; } | |
| 60 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | |
| 61 | |
| 62 bool close_on_deactivate() const { return close_on_deactivate_; } | 59 bool close_on_deactivate() const { return close_on_deactivate_; } |
| 63 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } | 60 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } |
| 64 | 61 |
| 65 View* GetAnchorView() const; | 62 View* GetAnchorView() const; |
| 66 Widget* anchor_widget() const { return anchor_widget_; } | 63 Widget* anchor_widget() const { return anchor_widget_; } |
| 67 | 64 |
| 68 // The anchor rect is used in the absence of an assigned anchor view. | 65 // The anchor rect is used in the absence of an assigned anchor view. |
| 69 const gfx::Rect& anchor_rect() const { return anchor_rect_; } | 66 const gfx::Rect& anchor_rect() const { return anchor_rect_; } |
| 70 | 67 |
| 71 BubbleBorder::Arrow arrow() const { return arrow_; } | 68 BubbleBorder::Arrow arrow() const { return arrow_; } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | 124 BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); |
| 128 | 125 |
| 129 // Get bubble bounds from the anchor rect and client view's preferred size. | 126 // Get bubble bounds from the anchor rect and client view's preferred size. |
| 130 virtual gfx::Rect GetBubbleBounds(); | 127 virtual gfx::Rect GetBubbleBounds(); |
| 131 | 128 |
| 132 // Return a FontList to use for the title of the bubble. | 129 // Return a FontList to use for the title of the bubble. |
| 133 // (The default is MediumFont). | 130 // (The default is MediumFont). |
| 134 virtual const gfx::FontList& GetTitleFontList() const; | 131 virtual const gfx::FontList& GetTitleFontList() const; |
| 135 | 132 |
| 136 // View overrides: | 133 // View overrides: |
| 137 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | |
| 138 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 134 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| 139 | 135 |
| 140 // Perform view initialization on the contents for bubble sizing. | 136 // Perform view initialization on the contents for bubble sizing. |
| 141 virtual void Init(); | 137 virtual void Init(); |
| 142 | 138 |
| 143 // Sets the anchor view or rect and repositions the bubble. Note that if a | 139 // Sets the anchor view or rect and repositions the bubble. Note that if a |
| 144 // valid view gets passed, the anchor rect will get ignored. If the view gets | 140 // valid view gets passed, the anchor rect will get ignored. If the view gets |
| 145 // deleted, but no new view gets set, the last known anchor postion will get | 141 // deleted, but no new view gets set, the last known anchor postion will get |
| 146 // returned. | 142 // returned. |
| 147 void SetAnchorView(View* anchor_view); | 143 void SetAnchorView(View* anchor_view); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 158 | 154 |
| 159 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); | 155 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); |
| 160 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); | 156 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); |
| 161 | 157 |
| 162 // Update the bubble color from |theme|, unless it was explicitly set. | 158 // Update the bubble color from |theme|, unless it was explicitly set. |
| 163 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 159 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
| 164 | 160 |
| 165 // Handles widget visibility changes. | 161 // Handles widget visibility changes. |
| 166 void HandleVisibilityChanged(Widget* widget, bool visible); | 162 void HandleVisibilityChanged(Widget* widget, bool visible); |
| 167 | 163 |
| 168 // Flags controlling bubble closure on the escape key and deactivation. | 164 // A flag controlling bubble closure on deactivation. |
| 169 bool close_on_esc_; | |
| 170 bool close_on_deactivate_; | 165 bool close_on_deactivate_; |
| 171 | 166 |
| 172 // The view and widget to which this bubble is anchored. Since an anchor view | 167 // The view and widget to which this bubble is anchored. Since an anchor view |
| 173 // can be deleted without notice, we store it in the ViewStorage and retrieve | 168 // can be deleted without notice, we store it in the ViewStorage and retrieve |
| 174 // it from there. It will make sure that the view is still valid. | 169 // it from there. It will make sure that the view is still valid. |
| 175 const int anchor_view_storage_id_; | 170 const int anchor_view_storage_id_; |
| 176 Widget* anchor_widget_; | 171 Widget* anchor_widget_; |
| 177 | 172 |
| 178 // The anchor rect used in the absence of an anchor view. | 173 // The anchor rect used in the absence of an anchor view. |
| 179 mutable gfx::Rect anchor_rect_; | 174 mutable gfx::Rect anchor_rect_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 206 gfx::NativeView parent_window_; | 201 gfx::NativeView parent_window_; |
| 207 | 202 |
| 208 CloseReason close_reason_; | 203 CloseReason close_reason_; |
| 209 | 204 |
| 210 DISALLOW_COPY_AND_ASSIGN(BubbleDialogDelegateView); | 205 DISALLOW_COPY_AND_ASSIGN(BubbleDialogDelegateView); |
| 211 }; | 206 }; |
| 212 | 207 |
| 213 } // namespace views | 208 } // namespace views |
| 214 | 209 |
| 215 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE2_H_ | 210 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE2_H_ |
| OLD | NEW |