| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 5 #ifndef VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| 6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 6 #define VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "ui/base/animation/animation_delegate.h" | 10 #include "ui/base/animation/animation_delegate.h" |
| 11 #include "views/bubble/bubble_border.h" | 11 #include "views/bubble/bubble_border.h" |
| 12 #include "views/widget/widget.h" |
| 12 #include "views/widget/widget_delegate.h" | 13 #include "views/widget/widget_delegate.h" |
| 13 | 14 |
| 14 namespace ui { | 15 namespace ui { |
| 15 class SlideAnimation; | 16 class SlideAnimation; |
| 16 } // namespace ui | 17 } // namespace ui |
| 17 | 18 |
| 18 namespace views { | 19 namespace views { |
| 19 | 20 |
| 20 class BubbleFrameView; | 21 class BubbleFrameView; |
| 21 | 22 |
| 22 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
| 23 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
| 24 // | 25 // |
| 25 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 26 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
| 27 public ui::AnimationDelegate { | 28 public ui::AnimationDelegate, |
| 29 public Widget::Observer { |
| 28 public: | 30 public: |
| 29 BubbleDelegateView(); | 31 BubbleDelegateView(); |
| 30 BubbleDelegateView(const gfx::Point& anchor_point, | 32 BubbleDelegateView(const gfx::Point& anchor_point, |
| 31 BubbleBorder::ArrowLocation arrow_location, | 33 BubbleBorder::ArrowLocation arrow_location, |
| 32 const SkColor& color); | 34 const SkColor& color); |
| 33 virtual ~BubbleDelegateView(); | 35 virtual ~BubbleDelegateView(); |
| 34 | 36 |
| 35 // Create and initialize the bubble Widget(s) with proper bounds. | 37 // Create and initialize the bubble Widget(s) with proper bounds. |
| 36 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate, | 38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate, |
| 37 Widget* parent_widget); | 39 Widget* parent_widget); |
| 38 | 40 |
| 39 // WidgetDelegate overrides: | 41 // WidgetDelegate overrides: |
| 40 virtual View* GetInitiallyFocusedView() OVERRIDE; | 42 virtual View* GetInitiallyFocusedView() OVERRIDE; |
| 41 virtual View* GetContentsView() OVERRIDE; | 43 virtual View* GetContentsView() OVERRIDE; |
| 42 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
| 43 | 45 |
| 46 // Widget::Observer overrides: |
| 47 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; |
| 48 |
| 44 bool close_on_esc() const { return close_on_esc_; } | 49 bool close_on_esc() const { return close_on_esc_; } |
| 45 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } | 50 void set_close_on_esc(bool close_on_esc) { close_on_esc_ = close_on_esc; } |
| 46 | 51 |
| 52 bool close_on_deactivate() const { return close_on_deactivate_; } |
| 53 void set_close_on_deactivate(bool close_on_deactivate) { |
| 54 close_on_deactivate_ = close_on_deactivate; |
| 55 } |
| 56 |
| 47 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } | 57 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } |
| 48 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { | 58 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { |
| 49 allow_bubble_offscreen_ = allow_bubble_offscreen; | 59 allow_bubble_offscreen_ = allow_bubble_offscreen; |
| 50 } | 60 } |
| 51 | 61 |
| 52 // Get the arrow's anchor point in screen space. | 62 // Get the arrow's anchor point in screen space. |
| 53 virtual gfx::Point GetAnchorPoint(); | 63 virtual gfx::Point GetAnchorPoint(); |
| 54 | 64 |
| 55 // Get the arrow's location on the bubble. | 65 // Get the arrow's location on the bubble. |
| 56 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; | 66 virtual BubbleBorder::ArrowLocation GetArrowLocation() const; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // Initialize the border widget needed for Windows native control hosting. | 103 // Initialize the border widget needed for Windows native control hosting. |
| 94 void InitializeBorderWidget(Widget* parent_widget); | 104 void InitializeBorderWidget(Widget* parent_widget); |
| 95 | 105 |
| 96 // Get bounds for the Windows-only widget that hosts the bubble's contents. | 106 // Get bounds for the Windows-only widget that hosts the bubble's contents. |
| 97 gfx::Rect GetBubbleClientBounds() const; | 107 gfx::Rect GetBubbleClientBounds() const; |
| 98 #endif | 108 #endif |
| 99 | 109 |
| 100 // Fade animation for bubble. | 110 // Fade animation for bubble. |
| 101 scoped_ptr<ui::SlideAnimation> fade_animation_; | 111 scoped_ptr<ui::SlideAnimation> fade_animation_; |
| 102 | 112 |
| 103 // Should this bubble close on the escape key? | 113 // Flags controlling bubble closure on the escape key and deactivation. |
| 104 bool close_on_esc_; | 114 bool close_on_esc_; |
| 115 bool close_on_deactivate_; |
| 105 | 116 |
| 106 // Whether the bubble is allowed to be displayed offscreen, or if auto | 117 // Whether the bubble is allowed to be displayed offscreen, or if auto |
| 107 // re-positioning should be performed. | 118 // re-positioning should be performed. |
| 108 bool allow_bubble_offscreen_; | 119 bool allow_bubble_offscreen_; |
| 109 | 120 |
| 110 // The screen point where this bubble's arrow is anchored. | 121 // The screen point where this bubble's arrow is anchored. |
| 111 gfx::Point anchor_point_; | 122 gfx::Point anchor_point_; |
| 112 | 123 |
| 113 // The arrow's location on the bubble. | 124 // The arrow's location on the bubble. |
| 114 BubbleBorder::ArrowLocation arrow_location_; | 125 BubbleBorder::ArrowLocation arrow_location_; |
| 115 | 126 |
| 116 // The background color of the bubble. | 127 // The background color of the bubble. |
| 117 SkColor color_; | 128 SkColor color_; |
| 118 | 129 |
| 119 // Original opacity of the bubble. | 130 // Original opacity of the bubble. |
| 120 int original_opacity_; | 131 int original_opacity_; |
| 121 | 132 |
| 122 // The widget hosting the border for this bubble (non-Aura Windows only). | 133 // The widget hosting the border for this bubble (non-Aura Windows only). |
| 123 Widget* border_widget_; | 134 Widget* border_widget_; |
| 124 | 135 |
| 125 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 136 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
| 126 }; | 137 }; |
| 127 | 138 |
| 128 } // namespace views | 139 } // namespace views |
| 129 | 140 |
| 130 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 141 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
| OLD | NEW |