Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 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_DELEGATE_H_ | 5 #ifndef UI_VIEWS_BUBBLE_BUBBLE_DIALOG_DELEGATE_H_ |
| 6 #define UI_VIEWS_BUBBLE_BUBBLE_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" |
| 11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
| 12 #include "ui/views/widget/widget_delegate.h" | |
| 13 #include "ui/views/widget/widget_observer.h" | 12 #include "ui/views/widget/widget_observer.h" |
| 13 #include "ui/views/window/dialog_delegate.h" | |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 class FontList; | 16 class FontList; |
| 17 class Rect; | 17 class Rect; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace views { | 20 namespace views { |
| 21 | 21 |
| 22 class BubbleFrameView; | 22 class BubbleFrameView; |
| 23 | 23 |
| 24 // BubbleDelegateView creates frame and client views for bubble Widgets. | 24 // BubbleDialogDelegateView is a special DialogDelegateView for bubbles. It |
| 25 // BubbleDelegateView itself is the client's contents view. | 25 // should be used in place of BubbleDelegateView as it shares more code with |
|
msw
2016/02/22 21:43:56
Can you rephrase this sentence? Why does the code
Evan Stade
2016/02/22 22:58:23
Done.
| |
| 26 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 26 // DialogDelegateView. |
| 27 public WidgetObserver { | 27 class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView, |
| 28 public WidgetObserver { | |
| 28 public: | 29 public: |
| 29 // Internal class name. | 30 // Internal class name. |
| 30 static const char kViewClassName[]; | 31 static const char kViewClassName[]; |
| 31 | 32 |
| 32 enum class CloseReason { | 33 enum class CloseReason { |
| 33 DEACTIVATION, | 34 DEACTIVATION, |
| 34 ESCAPE, | 35 ESCAPE, |
| 35 CLOSE_BUTTON, | 36 CLOSE_BUTTON, |
| 36 UNKNOWN, | 37 UNKNOWN, |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 BubbleDelegateView(); | 40 ~BubbleDialogDelegateView() override; |
| 40 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | |
| 41 ~BubbleDelegateView() override; | |
| 42 | 41 |
| 43 // Create and initialize the bubble Widget(s) with proper bounds. | 42 // Create and initialize the bubble Widget(s) with proper bounds. |
| 44 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 43 static Widget* CreateBubble(BubbleDialogDelegateView* bubble_delegate); |
| 45 | 44 |
| 46 // WidgetDelegateView overrides: | 45 // WidgetDelegateView overrides: |
| 47 BubbleDelegateView* AsBubbleDelegate() override; | |
| 48 bool ShouldShowCloseButton() const override; | 46 bool ShouldShowCloseButton() const override; |
| 49 View* GetContentsView() override; | 47 ClientView* CreateClientView(Widget* widget) override; |
| 50 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; | 48 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
| 51 void GetAccessibleState(ui::AXViewState* state) override; | 49 void GetAccessibleState(ui::AXViewState* state) override; |
| 52 const char* GetClassName() const override; | 50 const char* GetClassName() const override; |
| 53 | 51 |
| 54 // WidgetObserver overrides: | 52 // WidgetObserver overrides: |
| 55 void OnWidgetClosing(Widget* widget) override; | 53 void OnWidgetClosing(Widget* widget) override; |
| 56 void OnWidgetDestroying(Widget* widget) override; | 54 void OnWidgetDestroying(Widget* widget) override; |
| 57 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; | 55 void OnWidgetVisibilityChanging(Widget* widget, bool visible) override; |
| 58 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; | 56 void OnWidgetVisibilityChanged(Widget* widget, bool visible) override; |
| 59 void OnWidgetActivationChanged(Widget* widget, bool active) override; | 57 void OnWidgetActivationChanged(Widget* widget, bool active) override; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 | 102 |
| 105 CloseReason close_reason() const { return close_reason_; } | 103 CloseReason close_reason() const { return close_reason_; } |
| 106 | 104 |
| 107 // Get the arrow's anchor rect in screen space. | 105 // Get the arrow's anchor rect in screen space. |
| 108 virtual gfx::Rect GetAnchorRect() const; | 106 virtual gfx::Rect GetAnchorRect() const; |
| 109 | 107 |
| 110 // Allows delegates to provide custom parameters before widget initialization. | 108 // Allows delegates to provide custom parameters before widget initialization. |
| 111 virtual void OnBeforeBubbleWidgetInit(Widget::InitParams* params, | 109 virtual void OnBeforeBubbleWidgetInit(Widget::InitParams* params, |
| 112 Widget* widget) const; | 110 Widget* widget) const; |
| 113 | 111 |
| 114 // Creates and returns a view to be displayed at the bottom of the bubble. | |
| 115 virtual scoped_ptr<View> CreateFootnoteView(); | |
| 116 | |
| 117 // Sets |margins_| to a default picked for smaller bubbles. | 112 // Sets |margins_| to a default picked for smaller bubbles. |
| 118 void UseCompactMargins(); | 113 void UseCompactMargins(); |
| 119 | 114 |
| 120 // Sets the bubble alignment relative to the anchor. This may only be called | 115 // Sets the bubble alignment relative to the anchor. This may only be called |
| 121 // after calling CreateBubble. | 116 // after calling CreateBubble. |
| 122 void SetAlignment(BubbleBorder::BubbleAlignment alignment); | 117 void SetAlignment(BubbleBorder::BubbleAlignment alignment); |
| 123 | 118 |
| 124 // Sets the bubble arrow paint type. | 119 // Sets the bubble arrow paint type. |
| 125 void SetArrowPaintType(BubbleBorder::ArrowPaintType paint_type); | 120 void SetArrowPaintType(BubbleBorder::ArrowPaintType paint_type); |
| 126 | 121 |
| 127 // Call this method when the anchor bounds have changed to reposition the | 122 // Call this method when the anchor bounds have changed to reposition the |
| 128 // bubble. The bubble is automatically repositioned when the anchor view | 123 // bubble. The bubble is automatically repositioned when the anchor view |
| 129 // bounds change as a result of the widget's bounds changing. | 124 // bounds change as a result of the widget's bounds changing. |
| 130 void OnAnchorBoundsChanged(); | 125 void OnAnchorBoundsChanged(); |
| 131 | 126 |
| 132 protected: | 127 protected: |
| 128 BubbleDialogDelegateView(); | |
| 129 BubbleDialogDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | |
| 130 | |
| 133 // Get bubble bounds from the anchor rect and client view's preferred size. | 131 // Get bubble bounds from the anchor rect and client view's preferred size. |
| 134 virtual gfx::Rect GetBubbleBounds(); | 132 virtual gfx::Rect GetBubbleBounds(); |
| 135 | 133 |
| 136 // Return a FontList to use for the title of the bubble. | 134 // Return a FontList to use for the title of the bubble. |
| 137 // (The default is MediumFont). | 135 // (The default is MediumFont). |
| 138 virtual const gfx::FontList& GetTitleFontList() const; | 136 virtual const gfx::FontList& GetTitleFontList() const; |
| 139 | 137 |
| 140 // View overrides: | 138 // View overrides: |
| 141 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 139 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 142 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 140 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 | 202 |
| 205 // If true (defaults to true), the arrow may be mirrored and moved to fit the | 203 // If true (defaults to true), the arrow may be mirrored and moved to fit the |
| 206 // bubble on screen better. It would be a no-op if the bubble has no arrow. | 204 // bubble on screen better. It would be a no-op if the bubble has no arrow. |
| 207 bool adjust_if_offscreen_; | 205 bool adjust_if_offscreen_; |
| 208 | 206 |
| 209 // Parent native window of the bubble. | 207 // Parent native window of the bubble. |
| 210 gfx::NativeView parent_window_; | 208 gfx::NativeView parent_window_; |
| 211 | 209 |
| 212 CloseReason close_reason_; | 210 CloseReason close_reason_; |
| 213 | 211 |
| 214 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 212 DISALLOW_COPY_AND_ASSIGN(BubbleDialogDelegateView); |
| 215 }; | 213 }; |
| 216 | 214 |
| 217 } // namespace views | 215 } // namespace views |
| 218 | 216 |
| 219 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 217 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE2_H_ |
| OLD | NEW |