| 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* GetAnchorView() const; |
| 63 Widget* anchor_widget() const { return anchor_widget_; } | 63 Widget* anchor_widget() const { return anchor_widget_; } |
| 64 | 64 |
| 65 // The anchor rect is used in the absence of an anchor view. | 65 // The anchor rect is used in the absence of an assigned anchor view. |
| 66 const gfx::Rect& anchor_rect() const { return anchor_rect_; } | 66 const gfx::Rect& anchor_rect() const { return anchor_rect_; } |
| 67 | 67 |
| 68 BubbleBorder::Arrow arrow() const { return arrow_; } | 68 BubbleBorder::Arrow arrow() const { return arrow_; } |
| 69 void set_arrow(BubbleBorder::Arrow arrow) { arrow_ = arrow; } | 69 void set_arrow(BubbleBorder::Arrow arrow) { arrow_ = arrow; } |
| 70 | 70 |
| 71 BubbleBorder::Shadow shadow() const { return shadow_; } | 71 BubbleBorder::Shadow shadow() const { return shadow_; } |
| 72 void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; } | 72 void set_shadow(BubbleBorder::Shadow shadow) { shadow_ = shadow; } |
| 73 | 73 |
| 74 SkColor color() const { return color_; } | 74 SkColor color() const { return color_; } |
| 75 void set_color(SkColor color) { | 75 void set_color(SkColor color) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 134 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 135 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 135 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
| 136 | 136 |
| 137 // gfx::AnimationDelegate overrides: | 137 // gfx::AnimationDelegate overrides: |
| 138 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; | 138 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 139 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 139 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 140 | 140 |
| 141 // Perform view initialization on the contents for bubble sizing. | 141 // Perform view initialization on the contents for bubble sizing. |
| 142 virtual void Init(); | 142 virtual void Init(); |
| 143 | 143 |
| 144 // Set the anchor view or rect; set these before CreateBubble or Show. | 144 // 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; } | 145 // that if a valid view gets passed, the anchor rect will get ignored. If the |
| 146 // view gets deleted, but no new view gets set, the last known anchor postion |
| 147 // will get returned. |
| 148 void SetAnchorView(View* anchor_view); |
| 146 void set_anchor_rect(const gfx::Rect& rect) { anchor_rect_ = rect; } | 149 void set_anchor_rect(const gfx::Rect& rect) { anchor_rect_ = rect; } |
| 147 | 150 |
| 148 // Resize and potentially move the bubble to fit the content's preferred size. | 151 // Resize and potentially move the bubble to fit the content's preferred size. |
| 149 void SizeToContents(); | 152 void SizeToContents(); |
| 150 | 153 |
| 151 BubbleFrameView* GetBubbleFrameView() const; | 154 BubbleFrameView* GetBubbleFrameView() const; |
| 152 | 155 |
| 153 private: | 156 private: |
| 154 friend class BubbleBorderDelegate; | 157 friend class BubbleBorderDelegate; |
| 155 | 158 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 167 // Handles widget visibility changes. | 170 // Handles widget visibility changes. |
| 168 void HandleVisibilityChanged(Widget* widget, bool visible); | 171 void HandleVisibilityChanged(Widget* widget, bool visible); |
| 169 | 172 |
| 170 // Fade animation for bubble. | 173 // Fade animation for bubble. |
| 171 scoped_ptr<gfx::SlideAnimation> fade_animation_; | 174 scoped_ptr<gfx::SlideAnimation> fade_animation_; |
| 172 | 175 |
| 173 // Flags controlling bubble closure on the escape key and deactivation. | 176 // Flags controlling bubble closure on the escape key and deactivation. |
| 174 bool close_on_esc_; | 177 bool close_on_esc_; |
| 175 bool close_on_deactivate_; | 178 bool close_on_deactivate_; |
| 176 | 179 |
| 177 // The view and widget to which this bubble is anchored. | 180 // The view and widget to which this bubble is anchored. Since an anchor view |
| 178 View* anchor_view_; | 181 // can be deleted without notice, we store it in the ViewStorage and retrieve |
| 182 // it from there. It will make sure that the view is still valid. |
| 183 int anchor_view_storage_id_; |
| 179 Widget* anchor_widget_; | 184 Widget* anchor_widget_; |
| 180 | 185 |
| 181 // The anchor rect used in the absence of an anchor view. | 186 // The anchor rect used in the absence of an anchor view. |
| 182 gfx::Rect anchor_rect_; | 187 gfx::Rect anchor_rect_; |
| 183 | 188 |
| 184 // If true, the bubble will re-anchor (and may resize) with |anchor_widget_|. | 189 // If true, the bubble will re-anchor (and may resize) with |anchor_widget_|. |
| 185 bool move_with_anchor_; | 190 bool move_with_anchor_; |
| 186 | 191 |
| 187 // The arrow's location on the bubble. | 192 // The arrow's location on the bubble. |
| 188 BubbleBorder::Arrow arrow_; | 193 BubbleBorder::Arrow arrow_; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 219 | 224 |
| 220 // Parent native window of the bubble. | 225 // Parent native window of the bubble. |
| 221 gfx::NativeView parent_window_; | 226 gfx::NativeView parent_window_; |
| 222 | 227 |
| 223 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 228 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 224 }; | 229 }; |
| 225 | 230 |
| 226 } // namespace views | 231 } // namespace views |
| 227 | 232 |
| 228 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 233 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |