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" |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 // BubbleDelegateView creates frame and client views for bubble Widgets. | 23 // BubbleDelegateView creates frame and client views for bubble Widgets. |
24 // BubbleDelegateView itself is the client's contents view. | 24 // BubbleDelegateView itself is the client's contents view. |
25 // | 25 // |
26 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, | 27 class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView, |
28 public ui::AnimationDelegate, | 28 public ui::AnimationDelegate, |
29 public Widget::Observer { | 29 public Widget::Observer { |
30 public: | 30 public: |
31 BubbleDelegateView(); | 31 BubbleDelegateView(); |
32 BubbleDelegateView(View* anchor_view, | 32 BubbleDelegateView(const View* anchor_view, |
33 BubbleBorder::ArrowLocation arrow_location, | 33 BubbleBorder::ArrowLocation arrow_location, |
34 const SkColor& color); | 34 const SkColor& color); |
35 virtual ~BubbleDelegateView(); | 35 virtual ~BubbleDelegateView(); |
36 | 36 |
37 // Create and initialize the bubble Widget(s) with proper bounds. | 37 // Create and initialize the bubble Widget(s) with proper bounds. |
38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); | 38 static Widget* CreateBubble(BubbleDelegateView* bubble_delegate); |
39 | 39 |
40 // WidgetDelegate overrides: | 40 // WidgetDelegate overrides: |
41 virtual View* GetInitiallyFocusedView() OVERRIDE; | 41 virtual View* GetInitiallyFocusedView() OVERRIDE; |
42 virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE; | 42 virtual BubbleDelegateView* AsBubbleDelegate() OVERRIDE; |
43 virtual View* GetContentsView() OVERRIDE; | 43 virtual View* GetContentsView() OVERRIDE; |
44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; | 44 virtual NonClientFrameView* CreateNonClientFrameView() OVERRIDE; |
45 | 45 |
46 // Widget::Observer overrides: | 46 // Widget::Observer overrides: |
47 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; | 47 virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; |
48 | 48 |
49 bool close_on_esc() const { return close_on_esc_; } | 49 bool close_on_esc() const { return close_on_esc_; } |
50 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; } |
51 | 51 |
52 bool close_on_deactivate() const { return close_on_deactivate_; } | 52 bool close_on_deactivate() const { return close_on_deactivate_; } |
53 void set_close_on_deactivate(bool close_on_deactivate) { | 53 void set_close_on_deactivate(bool close_on_deactivate) { |
54 close_on_deactivate_ = close_on_deactivate; | 54 close_on_deactivate_ = close_on_deactivate; |
55 } | 55 } |
56 | 56 |
57 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } | 57 bool allow_bubble_offscreen() const { return allow_bubble_offscreen_; } |
58 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { | 58 void set_allow_bubble_offscreen(bool allow_bubble_offscreen) { |
59 allow_bubble_offscreen_ = allow_bubble_offscreen; | 59 allow_bubble_offscreen_ = allow_bubble_offscreen; |
60 } | 60 } |
61 | 61 |
62 View* anchor_view() const { return anchor_view_; } | 62 const View* anchor_view() const { return anchor_view_; } |
63 | 63 |
64 bool use_focusless() const { return use_focusless_; } | 64 bool use_focusless() const { return use_focusless_; } |
65 void set_use_focusless(bool use_focusless) { | 65 void set_use_focusless(bool use_focusless) { |
66 use_focusless_ = use_focusless; | 66 use_focusless_ = use_focusless; |
67 } | 67 } |
68 | 68 |
69 // Get the arrow's anchor point in screen space. | 69 // Get the arrow's anchor point in screen space. |
70 virtual gfx::Point GetAnchorPoint(); | 70 virtual gfx::Point GetAnchorPoint(); |
71 | 71 |
72 // Get the arrow's location on the bubble. | 72 // Get the arrow's location on the bubble. |
(...skipping 10 matching lines...) Expand all Loading... | |
83 void StartFade(bool fade_in); | 83 void StartFade(bool fade_in); |
84 | 84 |
85 // Reset fade and opacity of bubble. Restore the opacity of the | 85 // Reset fade and opacity of bubble. Restore the opacity of the |
86 // bubble to the setting before StartFade() was called. | 86 // bubble to the setting before StartFade() was called. |
87 void ResetFade(); | 87 void ResetFade(); |
88 | 88 |
89 protected: | 89 protected: |
90 // View overrides: | 90 // View overrides: |
91 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; | 91 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; |
92 | 92 |
93 // ui::AnimationDelegate overrides: | |
94 virtual void AnimationEnded(const ui::Animation* animation); | |
95 virtual void AnimationProgressed(const ui::Animation* animation); | |
Finnur
2011/11/15 10:05:01
Why not OVERRIDE?
msw
2011/11/15 20:16:57
Done.
| |
96 | |
93 // Perform view initialization on the contents for bubble sizing. | 97 // Perform view initialization on the contents for bubble sizing. |
94 virtual void Init(); | 98 virtual void Init(); |
95 | 99 |
100 // Resizes and potentially moves the Bubble to best accommodate the | |
101 // contents preferred size. | |
102 void SizeToContents(); | |
103 | |
96 private: | 104 private: |
97 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, NonClientHitTest); | 105 FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewBasicTest, NonClientHitTest); |
98 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); | 106 FRIEND_TEST_ALL_PREFIXES(BubbleDelegateTest, CreateDelegate); |
99 | 107 |
100 // ui::AnimationDelegate overrides: | |
101 virtual void AnimationEnded(const ui::Animation* animation); | |
102 virtual void AnimationProgressed(const ui::Animation* animation); | |
103 | |
104 BubbleFrameView* GetBubbleFrameView() const; | 108 BubbleFrameView* GetBubbleFrameView() const; |
105 | 109 |
106 // Get bubble bounds from the anchor point and client view's preferred size. | 110 // Get bubble bounds from the anchor point and client view's preferred size. |
107 gfx::Rect GetBubbleBounds(); | 111 gfx::Rect GetBubbleBounds(); |
108 | 112 |
109 #if defined(OS_WIN) && !defined(USE_AURA) | 113 #if defined(OS_WIN) && !defined(USE_AURA) |
110 // Initialize the border widget needed for Windows native control hosting. | |
111 void InitializeBorderWidget(Widget* parent_widget); | |
112 | |
113 // Get bounds for the Windows-only widget that hosts the bubble's contents. | 114 // Get bounds for the Windows-only widget that hosts the bubble's contents. |
114 gfx::Rect GetBubbleClientBounds() const; | 115 gfx::Rect GetBubbleClientBounds() const; |
115 #endif | 116 #endif |
116 | 117 |
117 // Fade animation for bubble. | 118 // Fade animation for bubble. |
118 scoped_ptr<ui::SlideAnimation> fade_animation_; | 119 scoped_ptr<ui::SlideAnimation> fade_animation_; |
119 | 120 |
120 // Flags controlling bubble closure on the escape key and deactivation. | 121 // Flags controlling bubble closure on the escape key and deactivation. |
121 bool close_on_esc_; | 122 bool close_on_esc_; |
122 bool close_on_deactivate_; | 123 bool close_on_deactivate_; |
123 | 124 |
124 // Whether the bubble is allowed to be displayed offscreen, or if auto | 125 // Whether the bubble is allowed to be displayed offscreen, or if auto |
125 // re-positioning should be performed. | 126 // re-positioning should be performed. |
126 bool allow_bubble_offscreen_; | 127 bool allow_bubble_offscreen_; |
127 | 128 |
128 // The view hosting this bubble; the arrow is anchored to this view. | 129 // The view hosting this bubble; the arrow is anchored to this view. |
129 View* anchor_view_; | 130 const View* anchor_view_; |
130 | 131 |
131 // The arrow's location on the bubble. | 132 // The arrow's location on the bubble. |
132 BubbleBorder::ArrowLocation arrow_location_; | 133 BubbleBorder::ArrowLocation arrow_location_; |
133 | 134 |
134 // The background color of the bubble. | 135 // The background color of the bubble. |
135 SkColor color_; | 136 SkColor color_; |
136 | 137 |
137 // Original opacity of the bubble. | 138 // Original opacity of the bubble. |
138 int original_opacity_; | 139 int original_opacity_; |
139 | 140 |
140 // The widget hosting the border for this bubble (non-Aura Windows only). | 141 // The widget hosting the border for this bubble (non-Aura Windows only). |
141 Widget* border_widget_; | 142 Widget* border_widget_; |
142 | 143 |
143 // Create a popup window for focusless bubbles on Linux/ChromeOS. | 144 // Create a popup window for focusless bubbles on Linux/ChromeOS. |
144 // These bubbles are not interactive and should not gain focus. | 145 // These bubbles are not interactive and should not gain focus. |
145 bool use_focusless_; | 146 bool use_focusless_; |
146 | 147 |
147 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); | 148 DISALLOW_COPY_AND_ASSIGN(BubbleDelegateView); |
148 }; | 149 }; |
149 | 150 |
150 } // namespace views | 151 } // namespace views |
151 | 152 |
152 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ | 153 #endif // VIEWS_BUBBLE_BUBBLE_DELEGATE_H_ |
OLD | NEW |