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 CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "views/bubble/bubble_border.h" | 9 #include "views/bubble/bubble_border.h" |
10 #include "ui/base/animation/animation_delegate.h" | 10 #include "ui/base/animation/animation_delegate.h" |
11 #include "views/accelerator.h" | 11 #include "views/accelerator.h" |
12 #include "views/view.h" | 12 #include "views/view.h" |
13 | 13 |
14 #if defined(OS_WIN) | 14 #if defined(USE_AURA) |
| 15 #include "views/widget/native_widget_aura.h" |
| 16 #elif defined(OS_WIN) |
15 #include "views/widget/native_widget_win.h" | 17 #include "views/widget/native_widget_win.h" |
16 #elif defined(TOOLKIT_USES_GTK) | 18 #elif defined(TOOLKIT_USES_GTK) |
17 #include "views/widget/native_widget_gtk.h" | 19 #include "views/widget/native_widget_gtk.h" |
18 #endif | 20 #endif |
19 | 21 |
20 // Bubble is used to display an arbitrary view above all other windows. | 22 // Bubble is used to display an arbitrary view above all other windows. |
21 // Think of Bubble as a tooltip that allows you to embed an arbitrary view | 23 // Think of Bubble as a tooltip that allows you to embed an arbitrary view |
22 // in the tooltip. Additionally the Bubble renders an arrow pointing at | 24 // in the tooltip. Additionally the Bubble renders an arrow pointing at |
23 // the region the info bubble is providing the information about. | 25 // the region the info bubble is providing the information about. |
24 // | 26 // |
25 // To use an Bubble, invoke Show() and it'll take care of the rest. The Bubble | 27 // To use an Bubble, invoke Show() and it'll take care of the rest. The Bubble |
26 // insets the contents for you, so the contents typically shouldn't have any | 28 // insets the contents for you, so the contents typically shouldn't have any |
27 // additional margins. | 29 // additional margins. |
28 | 30 |
29 class BorderContents; | 31 class BorderContents; |
30 #if defined(OS_WIN) | 32 #if defined(OS_WIN) && !defined(USE_AURA) |
31 class BorderWidgetWin; | 33 class BorderWidgetWin; |
32 #endif | 34 #endif |
33 class Bubble; | 35 class Bubble; |
34 | 36 |
35 namespace gfx { | 37 namespace gfx { |
36 class Path; | 38 class Path; |
37 } | 39 } |
38 | 40 |
39 namespace ui { | 41 namespace ui { |
40 class SlideAnimation; | 42 class SlideAnimation; |
(...skipping 22 matching lines...) Expand all Loading... |
63 virtual bool FadeInOnShow() = 0; | 65 virtual bool FadeInOnShow() = 0; |
64 | 66 |
65 // The name of the window to which this delegate belongs. | 67 // The name of the window to which this delegate belongs. |
66 virtual std::wstring accessible_name(); | 68 virtual std::wstring accessible_name(); |
67 }; | 69 }; |
68 | 70 |
69 // TODO(sky): this code is ifdef-tastic. It might be cleaner to refactor the | 71 // TODO(sky): this code is ifdef-tastic. It might be cleaner to refactor the |
70 // WidgetFoo subclass into a separate class that calls into Bubble. | 72 // WidgetFoo subclass into a separate class that calls into Bubble. |
71 // That way Bubble has no (or very few) ifdefs. | 73 // That way Bubble has no (or very few) ifdefs. |
72 class Bubble | 74 class Bubble |
73 #if defined(OS_WIN) | 75 #if defined(USE_AURA) |
| 76 : public views::NativeWidgetAura, |
| 77 #elif defined(OS_WIN) |
74 : public views::NativeWidgetWin, | 78 : public views::NativeWidgetWin, |
75 #elif defined(TOOLKIT_USES_GTK) | 79 #elif defined(TOOLKIT_USES_GTK) |
76 : public views::NativeWidgetGtk, | 80 : public views::NativeWidgetGtk, |
77 #endif | 81 #endif |
78 public views::AcceleratorTarget, | 82 public views::AcceleratorTarget, |
79 public ui::AnimationDelegate { | 83 public ui::AnimationDelegate { |
80 public: | 84 public: |
81 // Shows the Bubble. | 85 // Shows the Bubble. |
82 // |parent| is set as the parent window. | 86 // |parent| is set as the parent window. |
83 // |contents| are the contents shown in the bubble. | 87 // |contents| are the contents shown in the bubble. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void SizeToContents(); | 122 void SizeToContents(); |
119 | 123 |
120 // Whether the Bubble should fade away when it closes. Generally speaking, | 124 // Whether the Bubble should fade away when it closes. Generally speaking, |
121 // we use FadeOut when the user selects something within the bubble that | 125 // we use FadeOut when the user selects something within the bubble that |
122 // causes the bubble to dismiss. We don't use it when the bubble gets | 126 // causes the bubble to dismiss. We don't use it when the bubble gets |
123 // deactivated as a result of clicking outside the bubble. | 127 // deactivated as a result of clicking outside the bubble. |
124 void set_fade_away_on_close(bool fade_away_on_close) { | 128 void set_fade_away_on_close(bool fade_away_on_close) { |
125 fade_away_on_close_ = fade_away_on_close; | 129 fade_away_on_close_ = fade_away_on_close; |
126 } | 130 } |
127 | 131 |
128 // Overridden from NativeWidgetWin: | 132 // Overridden from NativeWidget: |
129 virtual void Close(); | 133 virtual void Close(); |
130 | 134 |
131 // Overridden from ui::AnimationDelegate: | 135 // Overridden from ui::AnimationDelegate: |
132 virtual void AnimationEnded(const ui::Animation* animation); | 136 virtual void AnimationEnded(const ui::Animation* animation); |
133 virtual void AnimationProgressed(const ui::Animation* animation); | 137 virtual void AnimationProgressed(const ui::Animation* animation); |
134 | 138 |
135 #ifdef UNIT_TEST | 139 #ifdef UNIT_TEST |
136 views::View* contents() const { return contents_; } | 140 views::View* contents() const { return contents_; } |
137 #endif | 141 #endif |
138 | 142 |
(...skipping 11 matching lines...) Expand all Loading... |
150 virtual void InitBubble(views::Widget* parent, | 154 virtual void InitBubble(views::Widget* parent, |
151 const gfx::Rect& position_relative_to, | 155 const gfx::Rect& position_relative_to, |
152 views::BubbleBorder::ArrowLocation arrow_location, | 156 views::BubbleBorder::ArrowLocation arrow_location, |
153 views::View* contents, | 157 views::View* contents, |
154 BubbleDelegate* delegate); | 158 BubbleDelegate* delegate); |
155 | 159 |
156 // Instantiates and returns the BorderContents this Bubble should use. | 160 // Instantiates and returns the BorderContents this Bubble should use. |
157 // Subclasses can return their own BorderContents implementation. | 161 // Subclasses can return their own BorderContents implementation. |
158 virtual BorderContents* CreateBorderContents(); | 162 virtual BorderContents* CreateBorderContents(); |
159 | 163 |
160 #if defined(OS_WIN) | 164 #if defined(USE_AURA) |
| 165 // Overridden from NativeWidgetAura: |
| 166 // TODO(beng): OnActivate(); |
| 167 #elif defined(OS_WIN) |
161 // Overridden from NativeWidgetWin: | 168 // Overridden from NativeWidgetWin: |
162 virtual void OnActivate(UINT action, BOOL minimized, HWND window); | 169 virtual void OnActivate(UINT action, BOOL minimized, HWND window); |
163 #elif defined(TOOLKIT_USES_GTK) | 170 #elif defined(TOOLKIT_USES_GTK) |
164 // Overridden from NativeWidgetGtk: | 171 // Overridden from NativeWidgetGtk: |
165 virtual void OnActiveChanged() OVERRIDE; | 172 virtual void OnActiveChanged() OVERRIDE; |
166 #endif | 173 #endif |
167 | 174 |
168 #if defined(OS_WIN) | 175 #if defined(USE_AURA) |
| 176 // TODO(beng): |
| 177 #elif defined(OS_WIN) |
169 // The window used to render the padding, border and arrow. | 178 // The window used to render the padding, border and arrow. |
170 BorderWidgetWin* border_; | 179 BorderWidgetWin* border_; |
171 #elif defined(TOOLKIT_USES_GTK) | 180 #elif defined(TOOLKIT_USES_GTK) |
172 // The view displaying the border. | 181 // The view displaying the border. |
173 BorderContents* border_contents_; | 182 BorderContents* border_contents_; |
174 #endif | 183 #endif |
175 | 184 |
176 private: | 185 private: |
177 enum ShowStatus { | 186 enum ShowStatus { |
178 kOpen, | 187 kOpen, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 views::BubbleBorder::ArrowLocation arrow_location_; | 233 views::BubbleBorder::ArrowLocation arrow_location_; |
225 | 234 |
226 views::View* contents_; | 235 views::View* contents_; |
227 | 236 |
228 bool accelerator_registered_; | 237 bool accelerator_registered_; |
229 | 238 |
230 DISALLOW_COPY_AND_ASSIGN(Bubble); | 239 DISALLOW_COPY_AND_ASSIGN(Bubble); |
231 }; | 240 }; |
232 | 241 |
233 #endif // CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ | 242 #endif // CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_ |
OLD | NEW |