OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_GTK_STATUS_BUBBLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ |
6 #define CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ | 6 #define CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "app/animation_delegate.h" | |
14 #include "app/gtk_signal.h" | 13 #include "app/gtk_signal.h" |
15 #include "base/scoped_ptr.h" | 14 #include "base/scoped_ptr.h" |
16 #include "base/timer.h" | 15 #include "base/timer.h" |
17 #include "chrome/browser/gtk/owned_widget_gtk.h" | 16 #include "chrome/browser/gtk/owned_widget_gtk.h" |
18 #include "chrome/browser/ui/status_bubble.h" | 17 #include "chrome/browser/ui/status_bubble.h" |
19 #include "chrome/common/notification_observer.h" | 18 #include "chrome/common/notification_observer.h" |
20 #include "chrome/common/notification_registrar.h" | 19 #include "chrome/common/notification_registrar.h" |
21 #include "gfx/point.h" | 20 #include "gfx/point.h" |
22 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
| 22 #include "ui/base/animation/animation_delegate.h" |
23 | 23 |
24 class GtkThemeProvider; | 24 class GtkThemeProvider; |
25 class Profile; | 25 class Profile; |
| 26 |
| 27 namespace ui { |
26 class SlideAnimation; | 28 class SlideAnimation; |
| 29 } |
27 | 30 |
28 // GTK implementation of StatusBubble. Unlike Windows, our status bubble | 31 // GTK implementation of StatusBubble. Unlike Windows, our status bubble |
29 // doesn't have the nice leave-the-window effect since we can't rely on the | 32 // doesn't have the nice leave-the-window effect since we can't rely on the |
30 // window manager to not try to be "helpful" and center our popups, etc. | 33 // window manager to not try to be "helpful" and center our popups, etc. |
31 // We therefore position it absolutely in a GtkFixed, that we don't own. | 34 // We therefore position it absolutely in a GtkFixed, that we don't own. |
32 class StatusBubbleGtk : public StatusBubble, | 35 class StatusBubbleGtk : public StatusBubble, |
33 public NotificationObserver, | 36 public NotificationObserver, |
34 public AnimationDelegate { | 37 public ui::AnimationDelegate { |
35 public: | 38 public: |
36 explicit StatusBubbleGtk(Profile* profile); | 39 explicit StatusBubbleGtk(Profile* profile); |
37 virtual ~StatusBubbleGtk(); | 40 virtual ~StatusBubbleGtk(); |
38 | 41 |
39 bool flip_horizontally() const { return flip_horizontally_; } | 42 bool flip_horizontally() const { return flip_horizontally_; } |
40 int y_offset() const { return y_offset_; } | 43 int y_offset() const { return y_offset_; } |
41 | 44 |
42 // StatusBubble implementation. | 45 // StatusBubble implementation. |
43 virtual void SetStatus(const string16& status); | 46 virtual void SetStatus(const string16& status); |
44 virtual void SetURL(const GURL& url, const string16& languages); | 47 virtual void SetURL(const GURL& url, const string16& languages); |
45 virtual void Hide(); | 48 virtual void Hide(); |
46 virtual void MouseMoved(const gfx::Point& location, bool left_content); | 49 virtual void MouseMoved(const gfx::Point& location, bool left_content); |
47 | 50 |
48 // AnimationDelegate implementation. | 51 // ui::AnimationDelegate implementation. |
49 virtual void AnimationEnded(const Animation* animation); | 52 virtual void AnimationEnded(const ui::Animation* animation); |
50 virtual void AnimationProgressed(const Animation* animation); | 53 virtual void AnimationProgressed(const ui::Animation* animation); |
51 | 54 |
52 // Called when the download shelf becomes visible or invisible. | 55 // Called when the download shelf becomes visible or invisible. |
53 // This is used by to ensure that the status bubble does not obscure | 56 // This is used by to ensure that the status bubble does not obscure |
54 // the download shelf, when it is visible. | 57 // the download shelf, when it is visible. |
55 virtual void UpdateDownloadShelfVisibility(bool visible); | 58 virtual void UpdateDownloadShelfVisibility(bool visible); |
56 | 59 |
57 // Overridden from NotificationObserver: | 60 // Overridden from NotificationObserver: |
58 virtual void Observe(NotificationType type, | 61 virtual void Observe(NotificationType type, |
59 const NotificationSource& source, | 62 const NotificationSource& source, |
60 const NotificationDetails& details); | 63 const NotificationDetails& details); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // the url text). | 135 // the url text). |
133 string16 languages_; | 136 string16 languages_; |
134 | 137 |
135 // A timer that hides our window after a delay. | 138 // A timer that hides our window after a delay. |
136 base::OneShotTimer<StatusBubbleGtk> hide_timer_; | 139 base::OneShotTimer<StatusBubbleGtk> hide_timer_; |
137 | 140 |
138 // A timer that expands our window after a delay. | 141 // A timer that expands our window after a delay. |
139 base::OneShotTimer<StatusBubbleGtk> expand_timer_; | 142 base::OneShotTimer<StatusBubbleGtk> expand_timer_; |
140 | 143 |
141 // The animation for resizing the status bubble on long hovers. | 144 // The animation for resizing the status bubble on long hovers. |
142 scoped_ptr<SlideAnimation> expand_animation_; | 145 scoped_ptr<ui::SlideAnimation> expand_animation_; |
143 | 146 |
144 // The start and end width of the current resize animation. | 147 // The start and end width of the current resize animation. |
145 int start_width_; | 148 int start_width_; |
146 int desired_width_; | 149 int desired_width_; |
147 | 150 |
148 // Should the bubble be flipped horizontally (e.g. displayed on the right for | 151 // Should the bubble be flipped horizontally (e.g. displayed on the right for |
149 // an LTR language)? We move the bubble to the other side of the tab contents | 152 // an LTR language)? We move the bubble to the other side of the tab contents |
150 // rather than sliding it down when the download shelf is visible. | 153 // rather than sliding it down when the download shelf is visible. |
151 bool flip_horizontally_; | 154 bool flip_horizontally_; |
152 | 155 |
153 // Vertical offset used to hide the status bubble as the pointer nears it. | 156 // Vertical offset used to hide the status bubble as the pointer nears it. |
154 int y_offset_; | 157 int y_offset_; |
155 | 158 |
156 // If the download shelf is visible, do not obscure it. | 159 // If the download shelf is visible, do not obscure it. |
157 bool download_shelf_is_visible_; | 160 bool download_shelf_is_visible_; |
158 | 161 |
159 // 'location' and 'left_content' values from the last invocation of | 162 // 'location' and 'left_content' values from the last invocation of |
160 // MouseMoved(). We hang onto these so we can move the bubble if necessary | 163 // MouseMoved(). We hang onto these so we can move the bubble if necessary |
161 // when its text changes, triggering a size change. | 164 // when its text changes, triggering a size change. |
162 gfx::Point last_mouse_location_; | 165 gfx::Point last_mouse_location_; |
163 bool last_mouse_left_content_; | 166 bool last_mouse_left_content_; |
164 }; | 167 }; |
165 | 168 |
166 #endif // CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ | 169 #endif // CHROME_BROWSER_GTK_STATUS_BUBBLE_GTK_H_ |
OLD | NEW |