Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: ui/views/bubble/tray_bubble_view.h

Issue 2948223002: Revert of Do not activate TrayBubbleView by default (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/message_center/views/message_bubble_base.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_TRAY_BUBBLE_VIEW_H_ 5 #ifndef UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 6 #define UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/optional.h" 11 #include "base/optional.h"
12 #include "ui/base/accelerators/accelerator.h"
13 #include "ui/events/event.h"
14 #include "ui/gfx/native_widget_types.h" 12 #include "ui/gfx/native_widget_types.h"
15 #include "ui/views/bubble/bubble_dialog_delegate.h" 13 #include "ui/views/bubble/bubble_dialog_delegate.h"
16 #include "ui/views/mouse_watcher.h" 14 #include "ui/views/mouse_watcher.h"
17 #include "ui/views/views_export.h" 15 #include "ui/views/views_export.h"
18 16
19 namespace views { 17 namespace views {
20 class BoxLayout; 18 class BoxLayout;
21 class View; 19 class View;
22 class Widget; 20 class Widget;
23 } 21 }
(...skipping 29 matching lines...) Expand all
53 // Called when the view is destroyed. Any pointers to the view should be 51 // Called when the view is destroyed. Any pointers to the view should be
54 // cleared when this gets called. 52 // cleared when this gets called.
55 virtual void BubbleViewDestroyed() = 0; 53 virtual void BubbleViewDestroyed() = 0;
56 54
57 // Called when the mouse enters/exits the view. 55 // Called when the mouse enters/exits the view.
58 // Note: This event will only be called if the mouse gets actively moved by 56 // Note: This event will only be called if the mouse gets actively moved by
59 // the user to enter the view. 57 // the user to enter the view.
60 virtual void OnMouseEnteredView() = 0; 58 virtual void OnMouseEnteredView() = 0;
61 virtual void OnMouseExitedView() = 0; 59 virtual void OnMouseExitedView() = 0;
62 60
63 // Called to register/unregister accelerators for TrayBubbleView.
64 // TrayBubbleView wants to register those accelerators at the global level.
65 // Those accelerators are used to activate TrayBubbleView, i.e. those
66 // accelerators need to be processed even if TrayBubbleView is not active.
67 // UnregisterAllAccelerators can be called even if RegisterAccelerators is
68 // not called.
69 virtual void RegisterAccelerators(
70 const std::vector<ui::Accelerator>& accelerators,
71 TrayBubbleView* tray_bubble_view) = 0;
72 virtual void UnregisterAllAccelerators(
73 TrayBubbleView* tray_bubble_view) = 0;
74
75 // Called from GetAccessibleNodeData(); should return the appropriate 61 // Called from GetAccessibleNodeData(); should return the appropriate
76 // accessible name for the bubble. 62 // accessible name for the bubble.
77 virtual base::string16 GetAccessibleNameForBubble() = 0; 63 virtual base::string16 GetAccessibleNameForBubble() = 0;
78 64
79 // Should return true if extra keyboard accessibility is enabled.
80 // TrayBubbleView will put focus on the default item if extra keyboard
81 // accessibility is enabled.
82 virtual bool ShouldEnableExtraKeyboardAccessibility() = 0;
83
84 // Called when a bubble wants to hide/destroy itself (e.g. last visible 65 // Called when a bubble wants to hide/destroy itself (e.g. last visible
85 // child view was closed). 66 // child view was closed).
86 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0; 67 virtual void HideBubble(const TrayBubbleView* bubble_view) = 0;
87 68
88 private: 69 private:
89 DISALLOW_COPY_AND_ASSIGN(Delegate); 70 DISALLOW_COPY_AND_ASSIGN(Delegate);
90 }; 71 };
91 72
92 struct VIEWS_EXPORT InitParams { 73 struct VIEWS_EXPORT InitParams {
93 InitParams(); 74 InitParams();
94 InitParams(const InitParams& other); 75 InitParams(const InitParams& other);
95 Delegate* delegate = nullptr; 76 Delegate* delegate = nullptr;
96 gfx::NativeWindow parent_window = nullptr; 77 gfx::NativeWindow parent_window = nullptr;
97 View* anchor_view = nullptr; 78 View* anchor_view = nullptr;
98 AnchorAlignment anchor_alignment = ANCHOR_ALIGNMENT_BOTTOM; 79 AnchorAlignment anchor_alignment = ANCHOR_ALIGNMENT_BOTTOM;
99 int min_width = 0; 80 int min_width = 0;
100 int max_width = 0; 81 int max_width = 0;
101 int max_height = 0; 82 int max_height = 0;
83 bool can_activate = false;
102 bool close_on_deactivate = true; 84 bool close_on_deactivate = true;
103 // If not provided, the bg color will be derived from the NativeTheme. 85 // If not provided, the bg color will be derived from the NativeTheme.
104 base::Optional<SkColor> bg_color; 86 base::Optional<SkColor> bg_color;
105 }; 87 };
106 88
107 explicit TrayBubbleView(const InitParams& init_params); 89 explicit TrayBubbleView(const InitParams& init_params);
108 ~TrayBubbleView() override; 90 ~TrayBubbleView() override;
109 91
110 // Returns whether a tray bubble is active. 92 // Returns whether a tray bubble is active.
111 static bool IsATrayBubbleOpen(); 93 static bool IsATrayBubbleOpen();
(...skipping 10 matching lines...) Expand all
122 104
123 // Sets the bottom padding that child views will be laid out within. 105 // Sets the bottom padding that child views will be laid out within.
124 void SetBottomPadding(int padding); 106 void SetBottomPadding(int padding);
125 107
126 // Sets the bubble width. 108 // Sets the bubble width.
127 void SetWidth(int width); 109 void SetWidth(int width);
128 110
129 // Returns the border insets. Called by TrayEventFilter. 111 // Returns the border insets. Called by TrayEventFilter.
130 gfx::Insets GetBorderInsets() const; 112 gfx::Insets GetBorderInsets() const;
131 113
132 // Called when the delegate is destroyed. This must be called before the 114 // Called when the delegate is destroyed.
133 // delegate is actually destroyed. TrayBubbleView will do clean up in 115 void reset_delegate() { delegate_ = NULL; }
134 // ResetDelegate.
135 void ResetDelegate();
136 116
137 Delegate* delegate() { return delegate_; } 117 Delegate* delegate() { return delegate_; }
138 118
139 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; } 119 void set_gesture_dragging(bool dragging) { is_gesture_dragging_ = dragging; }
140 bool is_gesture_dragging() const { return is_gesture_dragging_; } 120 bool is_gesture_dragging() const { return is_gesture_dragging_; }
141 121
142 // Overridden from views::WidgetDelegate. 122 // Overridden from views::WidgetDelegate.
143 views::NonClientFrameView* CreateNonClientFrameView( 123 views::NonClientFrameView* CreateNonClientFrameView(
144 views::Widget* widget) override; 124 views::Widget* widget) override;
145 bool WidgetHasHitTestMask() const override; 125 bool WidgetHasHitTestMask() const override;
146 void GetWidgetHitTestMask(gfx::Path* mask) const override; 126 void GetWidgetHitTestMask(gfx::Path* mask) const override;
147 base::string16 GetAccessibleWindowTitle() const override; 127 base::string16 GetAccessibleWindowTitle() const override;
148 128
149 // Overridden from views::BubbleDialogDelegateView. 129 // Overridden from views::BubbleDialogDelegateView.
150 void OnBeforeBubbleWidgetInit(Widget::InitParams* params, 130 void OnBeforeBubbleWidgetInit(Widget::InitParams* params,
151 Widget* bubble_widget) const override; 131 Widget* bubble_widget) const override;
152 void OnWidgetClosing(Widget* widget) override; 132 void OnWidgetClosing(Widget* widget) override;
153 133
154 // Overridden from views::View. 134 // Overridden from views::View.
155 gfx::Size CalculatePreferredSize() const override; 135 gfx::Size CalculatePreferredSize() const override;
156 gfx::Size GetMaximumSize() const override; 136 gfx::Size GetMaximumSize() const override;
157 int GetHeightForWidth(int width) const override; 137 int GetHeightForWidth(int width) const override;
158 void OnMouseEntered(const ui::MouseEvent& event) override; 138 void OnMouseEntered(const ui::MouseEvent& event) override;
159 void OnMouseExited(const ui::MouseEvent& event) override; 139 void OnMouseExited(const ui::MouseEvent& event) override;
160 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; 140 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
161 141
162 // Overridden from MouseWatcherListener 142 // Overridden from MouseWatcherListener
163 void MouseMovedOutOfHost() override; 143 void MouseMovedOutOfHost() override;
164 144
165 // Overridden from ui::AcceleratorTarget
166 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
167
168 protected: 145 protected:
169 // Overridden from views::BubbleDialogDelegateView. 146 // Overridden from views::BubbleDialogDelegateView.
170 int GetDialogButtons() const override; 147 int GetDialogButtons() const override;
171 148
172 // Overridden from views::View. 149 // Overridden from views::View.
173 void ChildPreferredSizeChanged(View* child) override; 150 void ChildPreferredSizeChanged(View* child) override;
174 void ViewHierarchyChanged( 151 void ViewHierarchyChanged(
175 const ViewHierarchyChangedDetails& details) override; 152 const ViewHierarchyChangedDetails& details) override;
176 153
177 private: 154 private:
178 void CloseBubbleView();
179 void ActivateAndStartNavigation(const ui::KeyEvent& key_event);
180
181 // Focus the default item if no item is focused.
182 void FocusDefaultIfNeeded();
183
184 InitParams params_; 155 InitParams params_;
185 BoxLayout* layout_; 156 BoxLayout* layout_;
186 Delegate* delegate_; 157 Delegate* delegate_;
187 int preferred_width_; 158 int preferred_width_;
188 // |bubble_border_| and |owned_bubble_border_| point to the same thing, but 159 // |bubble_border_| and |owned_bubble_border_| point to the same thing, but
189 // the latter ensures we don't leak it before passing off ownership. 160 // the latter ensures we don't leak it before passing off ownership.
190 BubbleBorder* bubble_border_; 161 BubbleBorder* bubble_border_;
191 std::unique_ptr<views::BubbleBorder> owned_bubble_border_; 162 std::unique_ptr<views::BubbleBorder> owned_bubble_border_;
192 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_; 163 std::unique_ptr<internal::TrayBubbleContentMask> bubble_content_mask_;
193 bool is_gesture_dragging_; 164 bool is_gesture_dragging_;
194 165
195 // True once the mouse cursor was actively moved by the user over the bubble. 166 // True once the mouse cursor was actively moved by the user over the bubble.
196 // Only then the OnMouseExitedView() event will get passed on to listeners. 167 // Only then the OnMouseExitedView() event will get passed on to listeners.
197 bool mouse_actively_entered_; 168 bool mouse_actively_entered_;
198 169
199 // Used to find any mouse movements. 170 // Used to find any mouse movements.
200 std::unique_ptr<MouseWatcher> mouse_watcher_; 171 std::unique_ptr<MouseWatcher> mouse_watcher_;
201 172
202 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView); 173 DISALLOW_COPY_AND_ASSIGN(TrayBubbleView);
203 }; 174 };
204 175
205 } // namespace views 176 } // namespace views
206 177
207 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_ 178 #endif // UI_VIEWS_BUBBLE_TRAY_BUBBLE_VIEW_H_
OLDNEW
« no previous file with comments | « ui/message_center/views/message_bubble_base.cc ('k') | ui/views/bubble/tray_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698