| 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_GTK_CUSTOM_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/public/browser/notification_observer.h" | 13 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
| 15 #include "third_party/skia/include/core/SkColor.h" | 15 #include "third_party/skia/include/core/SkColor.h" |
| 16 #include "ui/base/animation/animation_delegate.h" | 16 #include "ui/base/animation/animation_delegate.h" |
| 17 #include "ui/base/animation/slide_animation.h" | 17 #include "ui/base/animation/slide_animation.h" |
| 18 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 19 #include "ui/base/gtk/owned_widget_gtk.h" | 19 #include "ui/base/gtk/owned_widget_gtk.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 | 21 |
| 22 class CairoCachedSurface; | |
| 23 class GtkThemeService; | 22 class GtkThemeService; |
| 24 class SkBitmap; | 23 class SkBitmap; |
| 25 | 24 |
| 25 namespace gfx { |
| 26 class CairoCachedSurface; |
| 27 } |
| 28 |
| 26 // These classes implement two kinds of custom-drawn buttons. They're | 29 // These classes implement two kinds of custom-drawn buttons. They're |
| 27 // used on the toolbar and the bookmarks bar. | 30 // used on the toolbar and the bookmarks bar. |
| 28 | 31 |
| 29 // CustomDrawButtonBase provides the base for building a custom drawn button. | 32 // CustomDrawButtonBase provides the base for building a custom drawn button. |
| 30 // It handles managing the pixbufs containing all the static images used to draw | 33 // It handles managing the pixbufs containing all the static images used to draw |
| 31 // the button. It also manages painting these pixbufs. | 34 // the button. It also manages painting these pixbufs. |
| 32 class CustomDrawButtonBase : public content::NotificationObserver { | 35 class CustomDrawButtonBase : public content::NotificationObserver { |
| 33 public: | 36 public: |
| 34 // If the images come from ResourceBundle rather than the theme provider, | 37 // If the images come from ResourceBundle rather than the theme provider, |
| 35 // pass in NULL for |theme_provider|. | 38 // pass in NULL for |theme_provider|. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 // Set the background details. | 60 // Set the background details. |
| 58 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); | 61 void SetBackground(SkColor color, SkBitmap* image, SkBitmap* mask); |
| 59 | 62 |
| 60 // Provide content::NotificationObserver implementation. | 63 // Provide content::NotificationObserver implementation. |
| 61 virtual void Observe(int type, | 64 virtual void Observe(int type, |
| 62 const content::NotificationSource& source, | 65 const content::NotificationSource& source, |
| 63 const content::NotificationDetails& details) OVERRIDE; | 66 const content::NotificationDetails& details) OVERRIDE; |
| 64 | 67 |
| 65 private: | 68 private: |
| 66 // Get the CairoCachedSurface from |surfaces_| for |state|. | 69 // Get the CairoCachedSurface from |surfaces_| for |state|. |
| 67 CairoCachedSurface* PixbufForState(int state); | 70 gfx::CairoCachedSurface* PixbufForState(int state); |
| 68 | 71 |
| 69 // We store one surface for each possible state of the button; | 72 // We store one surface for each possible state of the button; |
| 70 // INSENSITIVE is the last available state; | 73 // INSENSITIVE is the last available state; |
| 71 scoped_ptr<CairoCachedSurface> surfaces_[GTK_STATE_INSENSITIVE + 1]; | 74 scoped_ptr<gfx::CairoCachedSurface> surfaces_[GTK_STATE_INSENSITIVE + 1]; |
| 72 | 75 |
| 73 // The background image. | 76 // The background image. |
| 74 scoped_ptr<CairoCachedSurface> background_image_; | 77 scoped_ptr<gfx::CairoCachedSurface> background_image_; |
| 75 | 78 |
| 76 // If non-negative, the state to paint the button. | 79 // If non-negative, the state to paint the button. |
| 77 int paint_override_; | 80 int paint_override_; |
| 78 | 81 |
| 79 // We need to remember the image ids that the user passes in and the theme | 82 // We need to remember the image ids that the user passes in and the theme |
| 80 // provider so we can reload images if the user changes theme. | 83 // provider so we can reload images if the user changes theme. |
| 81 int normal_id_; | 84 int normal_id_; |
| 82 int pressed_id_; | 85 int pressed_id_; |
| 83 int hover_id_; | 86 int hover_id_; |
| 84 int disabled_id_; | 87 int disabled_id_; |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 // True if we should never do gtk rendering. | 226 // True if we should never do gtk rendering. |
| 224 bool forcing_chrome_theme_; | 227 bool forcing_chrome_theme_; |
| 225 | 228 |
| 226 // Used to listen for theme change notifications. | 229 // Used to listen for theme change notifications. |
| 227 content::NotificationRegistrar registrar_; | 230 content::NotificationRegistrar registrar_; |
| 228 | 231 |
| 229 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); | 232 DISALLOW_COPY_AND_ASSIGN(CustomDrawButton); |
| 230 }; | 233 }; |
| 231 | 234 |
| 232 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ | 235 #endif // CHROME_BROWSER_UI_GTK_CUSTOM_BUTTON_H_ |
| OLD | NEW |