| 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 CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ | 6 #define CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "chrome/browser/ui/status_bubble.h" | 15 #include "chrome/browser/ui/status_bubble.h" |
| 16 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "ui/base/animation/animation_delegate.h" | |
| 19 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 20 #include "ui/base/gtk/owned_widget_gtk.h" | 19 #include "ui/base/gtk/owned_widget_gtk.h" |
| 20 #include "ui/gfx/animation/animation_delegate.h" |
| 21 #include "ui/gfx/point.h" | 21 #include "ui/gfx/point.h" |
| 22 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 23 | 23 |
| 24 class GtkThemeService; | 24 class GtkThemeService; |
| 25 class Profile; | 25 class Profile; |
| 26 | 26 |
| 27 namespace ui { | 27 namespace gfx { |
| 28 class SlideAnimation; | 28 class SlideAnimation; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // GTK implementation of StatusBubble. Unlike Windows, our status bubble | 31 // GTK implementation of StatusBubble. Unlike Windows, our status bubble |
| 32 // 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 |
| 33 // 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. |
| 34 // 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. |
| 35 class StatusBubbleGtk : public StatusBubble, | 35 class StatusBubbleGtk : public StatusBubble, |
| 36 public content::NotificationObserver, | 36 public content::NotificationObserver, |
| 37 public ui::AnimationDelegate { | 37 public gfx::AnimationDelegate { |
| 38 public: | 38 public: |
| 39 explicit StatusBubbleGtk(Profile* profile); | 39 explicit StatusBubbleGtk(Profile* profile); |
| 40 virtual ~StatusBubbleGtk(); | 40 virtual ~StatusBubbleGtk(); |
| 41 | 41 |
| 42 bool flip_horizontally() const { return flip_horizontally_; } | 42 bool flip_horizontally() const { return flip_horizontally_; } |
| 43 int y_offset() const { return y_offset_; } | 43 int y_offset() const { return y_offset_; } |
| 44 | 44 |
| 45 // StatusBubble implementation. | 45 // StatusBubble implementation. |
| 46 virtual void SetStatus(const string16& status) OVERRIDE; | 46 virtual void SetStatus(const string16& status) OVERRIDE; |
| 47 virtual void SetURL(const GURL& url, const std::string& languages) OVERRIDE; | 47 virtual void SetURL(const GURL& url, const std::string& languages) OVERRIDE; |
| 48 virtual void Hide() OVERRIDE; | 48 virtual void Hide() OVERRIDE; |
| 49 virtual void MouseMoved(const gfx::Point& location, | 49 virtual void MouseMoved(const gfx::Point& location, |
| 50 bool left_content) OVERRIDE; | 50 bool left_content) OVERRIDE; |
| 51 | 51 |
| 52 // ui::AnimationDelegate implementation. | 52 // gfx::AnimationDelegate implementation. |
| 53 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 53 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE; |
| 54 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 54 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 55 | 55 |
| 56 // Called when the download shelf becomes visible or invisible. | 56 // Called when the download shelf becomes visible or invisible. |
| 57 // This is used by to ensure that the status bubble does not obscure | 57 // This is used by to ensure that the status bubble does not obscure |
| 58 // the download shelf, when it is visible. | 58 // the download shelf, when it is visible. |
| 59 virtual void UpdateDownloadShelfVisibility(bool visible) OVERRIDE; | 59 virtual void UpdateDownloadShelfVisibility(bool visible) OVERRIDE; |
| 60 | 60 |
| 61 // Overridden from content::NotificationObserver: | 61 // Overridden from content::NotificationObserver: |
| 62 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| 63 const content::NotificationSource& source, | 63 const content::NotificationSource& source, |
| 64 const content::NotificationDetails& details) OVERRIDE; | 64 const content::NotificationDetails& details) OVERRIDE; |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // the url text). | 139 // the url text). |
| 140 std::string languages_; | 140 std::string languages_; |
| 141 | 141 |
| 142 // A timer that hides our window after a delay. | 142 // A timer that hides our window after a delay. |
| 143 base::OneShotTimer<StatusBubbleGtk> hide_timer_; | 143 base::OneShotTimer<StatusBubbleGtk> hide_timer_; |
| 144 | 144 |
| 145 // A timer that expands our window after a delay. | 145 // A timer that expands our window after a delay. |
| 146 base::OneShotTimer<StatusBubbleGtk> expand_timer_; | 146 base::OneShotTimer<StatusBubbleGtk> expand_timer_; |
| 147 | 147 |
| 148 // The animation for resizing the status bubble on long hovers. | 148 // The animation for resizing the status bubble on long hovers. |
| 149 scoped_ptr<ui::SlideAnimation> expand_animation_; | 149 scoped_ptr<gfx::SlideAnimation> expand_animation_; |
| 150 | 150 |
| 151 // The start and end width of the current resize animation. | 151 // The start and end width of the current resize animation. |
| 152 int start_width_; | 152 int start_width_; |
| 153 int desired_width_; | 153 int desired_width_; |
| 154 | 154 |
| 155 // Should the bubble be flipped horizontally (e.g. displayed on the right for | 155 // Should the bubble be flipped horizontally (e.g. displayed on the right for |
| 156 // an LTR language)? We move the bubble to the other side of the tab contents | 156 // an LTR language)? We move the bubble to the other side of the tab contents |
| 157 // rather than sliding it down when the download shelf is visible. | 157 // rather than sliding it down when the download shelf is visible. |
| 158 bool flip_horizontally_; | 158 bool flip_horizontally_; |
| 159 | 159 |
| 160 // Vertical offset used to hide the status bubble as the pointer nears it. | 160 // Vertical offset used to hide the status bubble as the pointer nears it. |
| 161 int y_offset_; | 161 int y_offset_; |
| 162 | 162 |
| 163 // If the download shelf is visible, do not obscure it. | 163 // If the download shelf is visible, do not obscure it. |
| 164 bool download_shelf_is_visible_; | 164 bool download_shelf_is_visible_; |
| 165 | 165 |
| 166 // 'location' and 'left_content' values from the last invocation of | 166 // 'location' and 'left_content' values from the last invocation of |
| 167 // MouseMoved(). We hang onto these so we can move the bubble if necessary | 167 // MouseMoved(). We hang onto these so we can move the bubble if necessary |
| 168 // when its text changes, triggering a size change. | 168 // when its text changes, triggering a size change. |
| 169 gfx::Point last_mouse_location_; | 169 gfx::Point last_mouse_location_; |
| 170 bool last_mouse_left_content_; | 170 bool last_mouse_left_content_; |
| 171 | 171 |
| 172 // Shortly after the cursor enters the status bubble, we'll get a message | 172 // Shortly after the cursor enters the status bubble, we'll get a message |
| 173 // that the cursor left the content area. This lets us ignore that. | 173 // that the cursor left the content area. This lets us ignore that. |
| 174 bool ignore_next_left_content_; | 174 bool ignore_next_left_content_; |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 #endif // CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ | 177 #endif // CHROME_BROWSER_UI_GTK_STATUS_BUBBLE_GTK_H_ |
| OLD | NEW |