| 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/base/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" |
| 11 #include "ui/views/widget/widget_delegate.h" | 11 #include "ui/views/widget/widget_delegate.h" |
| 12 #include "ui/views/widget/widget_observer.h" | 12 #include "ui/views/widget/widget_observer.h" |
| 13 | 13 |
| 14 namespace gfx { | 14 namespace gfx { |
| 15 class Rect; | 15 class Rect; |
| 16 } | |
| 17 | |
| 18 namespace ui { | |
| 19 class SlideAnimation; | 16 class SlideAnimation; |
| 20 } | 17 } |
| 21 | 18 |
| 22 namespace views { | 19 namespace views { |
| 23 | 20 |
| 24 class BubbleFrameView; | 21 class BubbleFrameView; |
| 25 | 22 |
| 26 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
| 27 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
| 28 // | 25 // |
| 29 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 30 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
| 31 public ui::AnimationDelegate, | 28 public gfx::AnimationDelegate, |
| 32 public WidgetObserver { | 29 public WidgetObserver { |
| 33 public: | 30 public: |
| 34 BubbleDelegateView(); | 31 BubbleDelegateView(); |
| 35 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); | 32 BubbleDelegateView(View* anchor_view, BubbleBorder::Arrow arrow); |
| 36 virtual ~BubbleDelegateView(); | 33 virtual ~BubbleDelegateView(); |
| 37 | 34 |
| 38 // Create and initialize the bubble Widget(s) with proper bounds. | 35 // Create and initialize the bubble Widget(s) with proper bounds. |
| 39 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 36 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
| 40 | 37 |
| 41 // WidgetDelegate overrides: | 38 // WidgetDelegate overrides: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // Returns the duration in milliseconds for the fade animation. | 129 // Returns the duration in milliseconds for the fade animation. |
| 133 virtual int GetFadeDuration(); | 130 virtual int GetFadeDuration(); |
| 134 | 131 |
| 135 // View overrides: | 132 // View overrides: |
| 136 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | 133 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; |
| 137 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; | 134 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) OVERRIDE; |
| 138 | 135 |
| 139 // ui::AnimationDelegate overrides: | 136 // gfx::AnimationDelegate overrides: |
| 140 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 137 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 141 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 138 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 142 | 139 |
| 143 // Perform view initialization on the contents for bubble sizing. | 140 // Perform view initialization on the contents for bubble sizing. |
| 144 virtual void Init(); | 141 virtual void Init(); |
| 145 | 142 |
| 146 // Set the anchor view or rect; set these before CreateBubble or Show. | 143 // Set the anchor view or rect; set these before CreateBubble or Show. |
| 147 void set_anchor_view(View* anchor_view) { anchor_view_ = anchor_view; } | 144 void set_anchor_view(View* anchor_view) { anchor_view_ = anchor_view; } |
| 148 void set_anchor_rect(const gfx::Rect& rect) { anchor_rect_ = rect; } | 145 void set_anchor_rect(const gfx::Rect& rect) { anchor_rect_ = rect; } |
| 149 | 146 |
| 150 // Resize and potentially move the bubble to fit the content's preferred size. | 147 // Resize and potentially move the bubble to fit the content's preferred size. |
| 151 void SizeToContents(); | 148 void SizeToContents(); |
| 152 | 149 |
| 153 BubbleFrameView* GetBubbleFrameView() const; | 150 BubbleFrameView* GetBubbleFrameView() const; |
| 154 | 151 |
| 155 private: | 152 private: |
| 156 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); | 153 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); |
| 157 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); | 154 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, NonClientHitTest); |
| 158 | 155 |
| 159 // Update the bubble color from |theme|, unless it was explicitly set. | 156 // Update the bubble color from |theme|, unless it was explicitly set. |
| 160 void UpdateColorsFromTheme(const ui::NativeTheme* theme); | 157 void UpdateColorsFromTheme(const ui::NativeTheme* theme); |
| 161 | 158 |
| 162 #if defined(OS_WIN) && !defined(USE_AURA) | 159 #if defined(OS_WIN) && !defined(USE_AURA) |
| 163 // Get bounds for the Windows-only widget that hosts the bubble's contents. | 160 // Get bounds for the Windows-only widget that hosts the bubble's contents. |
| 164 gfx::Rect GetBubbleClientBounds() const; | 161 gfx::Rect GetBubbleClientBounds() const; |
| 165 #endif | 162 #endif |
| 166 | 163 |
| 167 // Handles widget visibility changes. | 164 // Handles widget visibility changes. |
| 168 void HandleVisibilityChanged(Widget* widget, bool visible); | 165 void HandleVisibilityChanged(Widget* widget, bool visible); |
| 169 | 166 |
| 170 // Fade animation for bubble. | 167 // Fade animation for bubble. |
| 171 scoped_ptr<ui::SlideAnimation> fade_animation_; | 168 scoped_ptr<gfx::SlideAnimation> fade_animation_; |
| 172 | 169 |
| 173 // Flags controlling bubble closure on the escape key and deactivation. | 170 // Flags controlling bubble closure on the escape key and deactivation. |
| 174 bool close_on_esc_; | 171 bool close_on_esc_; |
| 175 bool close_on_deactivate_; | 172 bool close_on_deactivate_; |
| 176 | 173 |
| 177 // The view and widget to which this bubble is anchored. | 174 // The view and widget to which this bubble is anchored. |
| 178 View* anchor_view_; | 175 View* anchor_view_; |
| 179 Widget* anchor_widget_; | 176 Widget* anchor_widget_; |
| 180 | 177 |
| 181 // The anchor rect used in the absence of an anchor view. | 178 // The anchor rect used in the absence of an anchor view. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 | 216 |
| 220 // Parent native window of the bubble. | 217 // Parent native window of the bubble. |
| 221 gfx::NativeView parent_window_; | 218 gfx::NativeView parent_window_; |
| 222 | 219 |
| 223 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 220 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 224 }; | 221 }; |
| 225 | 222 |
| 226 } // namespace views | 223 } // namespace views |
| 227 | 224 |
| 228 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 225 #endif // UI_VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |