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/gfx/animation/animation_delegate.h" | 9 #include "ui/gfx/animation/animation_delegate.h" |
10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; | 52 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; |
53 virtual void OnWidgetBoundsChanged(Widget* widget, | 53 virtual void OnWidgetBoundsChanged(Widget* widget, |
54 const gfx::Rect& new_bounds) OVERRIDE; | 54 const gfx::Rect& new_bounds) OVERRIDE; |
55 | 55 |
56 bool close_on_esc() const { return close_on_esc_; } | 56 bool close_on_esc() const { return close_on_esc_; } |
57 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 57 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
58 | 58 |
59 bool close_on_deactivate() const { return close_on_deactivate_; } | 59 bool close_on_deactivate() const { return close_on_deactivate_; } |
60 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } | 60 void set_close_on_deactivate(bool close) { close_on_deactivate_ = close; } |
61 | 61 |
62 View* anchor_view() const { return anchor_view_; } | 62 View* AnchorView() const; |
msw
2013/09/27 18:20:31
nit: GetAnchorView.
Mr4D (OOO till 08-26)
2013/09/27 20:29:35
Done.
| |
63 Widget* anchor_widget() const { return anchor_widget_; } | 63 Widget* anchor_widget() const { return anchor_widget_; } |
64 // Even though AnchorView might return NULL, the bubble might have an | |
msw
2013/09/27 18:20:31
Why is this important? I think it can be removed.
Mr4D (OOO till 08-26)
2013/09/27 20:29:35
Because the bubble might have been created with an
msw
2013/09/27 21:21:52
I understand how that works, but why would anyone
| |
65 // anchor_view attached to it upon creation. | |
66 bool has_anchor_view() const { return has_anchor_view_; } | |
64 | 67 |
65 // The anchor rect is used in the absence of an anchor view. | 68 // The anchor rect is used in the absence of an assigned anchor view. |
66 const gfx::Rect& anchor_rect() const { return anchor_rect_; } | 69 const gfx::Rect& AnchorRect() const; |
msw
2013/09/27 18:20:31
nit: GetAnchorRect.
Mr4D (OOO till 08-26)
2013/09/27 20:29:35
Done.
| |
67 | 70 |
68 BubbleBorder::Arrow arrow() const { return arrow_; } | 71 BubbleBorder::Arrow arrow() const { return arrow_; } |
69 void set_arrow(BubbleBorder::Arrow arrow) { arrow_ = arrow; } | 72 void set_arrow(BubbleBorder::Arrow arrow) { arrow_ = arrow; } |
70 | 73 |
71 BubbleBorder::Shadow shadow() const { return shadow_; } | 74 BubbleBorder::Shadow shadow() const { return shadow_; } |
72 void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; } | 75 void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; } |
73 | 76 |
74 SkColor color() const { return color_; } | 77 SkColor color() const { return color_; } |
75 void set_color(SkColor color) { | 78 void set_color(SkColor color) { |
76 color_ = color; | 79 color_ = color; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
134 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 137 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
135 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 138 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
136 | 139 |
137 // gfx::AnimationDelegate overrides: | 140 // gfx::AnimationDelegate overrides: |
138 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 141 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
139 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 142 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
140 | 143 |
141 // Perform view initialization on the contents for bubble sizing. | 144 // Perform view initialization on the contents for bubble sizing. |
142 virtual void Init(); | 145 virtual void Init(); |
143 | 146 |
144 // Set the anchor view or rect; set these before CreateBubble or Show. | 147 // Set the anchor view or rect; set these before CreateBubble or Show. Note |
145 void set_anchor_view(View* anchor_view) { anchor_view_ = anchor_view; } | 148 // that if a valid view gets passed, the anchor rect will get ignored. If the |
146 void set_anchor_rect(const gfx::Rect& rect) { anchor_rect_ = rect; } | 149 // view gets deleted, but no new view gets set, the last known anchor postion |
150 // will get returned. | |
151 void SetAnchorView(View* anchor_view); | |
152 void SetAnchorRect(const gfx::Rect& rect); | |
147 | 153 |
148 // Resize and potentially move the bubble to fit the content's preferred size. | 154 // Resize and potentially move the bubble to fit the content's preferred size. |
149 void SizeToContents(); | 155 void SizeToContents(); |
150 | 156 |
151 BubbleFrameView* GetBubbleFrameView() const; | 157 BubbleFrameView* GetBubbleFrameView() const; |
152 | 158 |
153 private: | 159 private: |
154 friend class BubbleBorderDelegate; | 160 friend class BubbleBorderDelegate; |
155 | 161 |
156 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); | 162 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); |
157 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); | 163 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); |
158 | 164 |
159 // Update the bubble color from |theme|, unless it was explicitly set. | 165 // Update the bubble color from |theme|, unless it was explicitly set. |
160 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 166 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
161 | 167 |
162 #if defined(OS_WIN) && !defined(USE_AURA) | 168 #if defined(OS_WIN) && !defined(USE_AURA) |
163 // Get bounds for the Windows-only widget that hosts the bubble's contents. | 169 // Get bounds for the Windows-only widget that hosts the bubble's contents. |
164 gfx::Rect GetBubbleClientBounds() const; | 170 gfx::Rect GetBubbleClientBounds() const; |
165 #endif | 171 #endif |
166 | 172 |
167 // Handles widget visibility changes. | 173 // Handles widget visibility changes. |
168 void HandleVisibilityChanged(Widget* widget, bool visible); | 174 void HandleVisibilityChanged(Widget* widget, bool visible); |
169 | 175 |
176 // Detach the bubble from the anchor (has no effect if there is no anchor). | |
177 void DetachFromAnchor(); | |
178 | |
170 // Fade animation for bubble. | 179 // Fade animation for bubble. |
171 scoped_ptr<gfx::SlideAnimation> fade_animation_; | 180 scoped_ptr<gfx::SlideAnimation> fade_animation_; |
172 | 181 |
173 // Flags controlling bubble closure on the escape key and deactivation. | 182 // Flags controlling bubble closure on the escape key and deactivation. |
174 bool close_on_esc_; | 183 bool close_on_esc_; |
175 bool close_on_deactivate_; | 184 bool close_on_deactivate_; |
176 | 185 |
177 // The view and widget to which this bubble is anchored. | 186 // The view and widget to which this bubble is anchored. Since an anchor view |
178 View* anchor_view_; | 187 // can be deleted without notice, we store it in the ViewStorage and retrieve |
188 // it from there. It will make sure that the view is still valid. | |
189 // To avoid the bubble to jump upon early anchor destruction, we remember the | |
msw
2013/09/27 18:20:31
nit: I think the complex behavior and the rest of
Mr4D (OOO till 08-26)
2013/09/27 20:29:35
Done.
| |
190 // last known anchor bounds in |last_known_anchor_view_rect_|. The originally | |
191 // set |anchor_rect_| will only be passed back when the anchor_view got | |
192 // explicitly cleared. | |
193 bool has_anchor_view_; | |
194 gfx::Rect last_known_anchor_view_rect_; | |
195 int anchor_view_storage_id_; | |
179 Widget* anchor_widget_; | 196 Widget* anchor_widget_; |
180 | 197 |
181 // The anchor rect used in the absence of an anchor view. | 198 // The anchor rect used in the absence of an anchor view. |
182 gfx::Rect anchor_rect_; | 199 gfx::Rect anchor_rect_; |
183 | 200 |
184 // If true, the bubble will re-anchor (and may resize) with |anchor_widget_|. | 201 // If true, the bubble will re-anchor (and may resize) with |anchor_widget_|. |
185 bool move_with_anchor_; | 202 bool move_with_anchor_; |
186 | 203 |
187 // The arrow's location on the bubble. | 204 // The arrow's location on the bubble. |
188 BubbleBorder::Arrow arrow_; | 205 BubbleBorder::Arrow arrow_; |
(...skipping 30 matching lines...) Expand all Loading... | |
219 | 236 |
220 // Parent native window of the bubble. | 237 // Parent native window of the bubble. |
221 gfx::NativeView parent_window_; | 238 gfx::NativeView parent_window_; |
222 | 239 |
223 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 240 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
224 }; | 241 }; |
225 | 242 |
226 } // namespace views | 243 } // namespace views |
227 | 244 |
228 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 245 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |