| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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_TABS_TAB_RENDERER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "app/animation.h" | 11 #include "app/animation.h" |
| 12 #include "app/gtk_signal.h" |
| 12 #include "app/slide_animation.h" | 13 #include "app/slide_animation.h" |
| 13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 14 #include "base/string16.h" | 15 #include "base/string16.h" |
| 15 #include "chrome/common/notification_observer.h" | 16 #include "chrome/common/notification_observer.h" |
| 16 #include "chrome/common/notification_registrar.h" | 17 #include "chrome/common/notification_registrar.h" |
| 17 #include "chrome/common/owned_widget_gtk.h" | 18 #include "chrome/common/owned_widget_gtk.h" |
| 18 #include "gfx/canvas.h" | 19 #include "gfx/canvas.h" |
| 19 #include "gfx/font.h" | 20 #include "gfx/font.h" |
| 20 #include "gfx/rect.h" | 21 #include "gfx/rect.h" |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 22 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 void set_vertical_offset(int offset) { background_offset_y_ = offset; } | 216 void set_vertical_offset(int offset) { background_offset_y_ = offset; } |
| 216 | 217 |
| 217 protected: | 218 protected: |
| 218 const gfx::Rect& title_bounds() const { return title_bounds_; } | 219 const gfx::Rect& title_bounds() const { return title_bounds_; } |
| 219 const gfx::Rect& close_button_bounds() const { return close_button_bounds_; } | 220 const gfx::Rect& close_button_bounds() const { return close_button_bounds_; } |
| 220 | 221 |
| 221 // Returns the title of the Tab. | 222 // Returns the title of the Tab. |
| 222 std::wstring GetTitle() const; | 223 std::wstring GetTitle() const; |
| 223 | 224 |
| 224 // enter-notify-event handler that signals when the mouse enters the tab. | 225 // enter-notify-event handler that signals when the mouse enters the tab. |
| 225 static gboolean OnEnterNotifyEvent(GtkWidget* widget, GdkEventCrossing* event, | 226 CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnEnterNotifyEvent, |
| 226 TabRendererGtk* tab); | 227 GdkEventCrossing*); |
| 227 | 228 |
| 228 // leave-notify-event handler that signals when the mouse enters the tab. | 229 // leave-notify-event handler that signals when the mouse enters the tab. |
| 229 static gboolean OnLeaveNotifyEvent(GtkWidget* widget, GdkEventCrossing* event, | 230 CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnLeaveNotifyEvent, |
| 230 TabRendererGtk* tab); | 231 GdkEventCrossing*); |
| 231 | 232 |
| 232 private: | 233 private: |
| 233 class FavIconCrashAnimation; | 234 class FavIconCrashAnimation; |
| 234 | 235 |
| 235 // The data structure used to hold cached bitmaps. We need to manually free | 236 // The data structure used to hold cached bitmaps. We need to manually free |
| 236 // the bitmap in CachedBitmap when we remove it from |cached_bitmaps_|. We | 237 // the bitmap in CachedBitmap when we remove it from |cached_bitmaps_|. We |
| 237 // handle this when we replace images in the map and in the destructor. | 238 // handle this when we replace images in the map and in the destructor. |
| 238 struct CachedBitmap { | 239 struct CachedBitmap { |
| 239 int bg_offset_x; | 240 int bg_offset_x; |
| 240 int bg_offset_y; | 241 int bg_offset_y; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 bool ShouldShowCloseBox() const; | 344 bool ShouldShowCloseBox() const; |
| 344 | 345 |
| 345 CustomDrawButton* MakeCloseButton(); | 346 CustomDrawButton* MakeCloseButton(); |
| 346 | 347 |
| 347 // Gets the throb value for the tab. When a tab is not selected the | 348 // Gets the throb value for the tab. When a tab is not selected the |
| 348 // active background is drawn at |GetThrobValue()|%. This is used for hover | 349 // active background is drawn at |GetThrobValue()|%. This is used for hover |
| 349 // and mini-tab title change effects. | 350 // and mini-tab title change effects. |
| 350 double GetThrobValue(); | 351 double GetThrobValue(); |
| 351 | 352 |
| 352 // Handles the clicked signal for the close button. | 353 // Handles the clicked signal for the close button. |
| 353 static void OnCloseButtonClicked(GtkWidget* widget, TabRendererGtk* tab); | 354 CHROMEGTK_CALLBACK_0(TabRendererGtk, void, OnCloseButtonClicked); |
| 354 | 355 |
| 355 // Handles middle clicking the close button. | 356 // Handles middle clicking the close button. |
| 356 static gboolean OnCloseButtonMouseRelease(GtkWidget* widget, | 357 CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnCloseButtonMouseRelease, |
| 357 GdkEventButton* event, | 358 GdkEventButton*); |
| 358 TabRendererGtk* tab); | |
| 359 | 359 |
| 360 // expose-event handler that redraws the tab. | 360 // expose-event handler that redraws the tab. |
| 361 static gboolean OnExposeEvent(GtkWidget* widget, GdkEventExpose* event, | 361 CHROMEGTK_CALLBACK_1(TabRendererGtk, gboolean, OnExposeEvent, |
| 362 TabRendererGtk* tab); | 362 GdkEventExpose*); |
| 363 | 363 |
| 364 // size-allocate handler used to update the current bounds of the tab. | 364 // size-allocate handler used to update the current bounds of the tab. |
| 365 static void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation, | 365 CHROMEGTK_CALLBACK_1(TabRendererGtk, void, OnSizeAllocate, GtkAllocation*); |
| 366 TabRendererGtk* tab); | |
| 367 | 366 |
| 368 // TODO(jhawkins): Move to TabResources. | 367 // TODO(jhawkins): Move to TabResources. |
| 369 static void InitResources(); | 368 static void InitResources(); |
| 370 static bool initialized_; | 369 static bool initialized_; |
| 371 | 370 |
| 372 // The bounds of various sections of the display. | 371 // The bounds of various sections of the display. |
| 373 gfx::Rect favicon_bounds_; | 372 gfx::Rect favicon_bounds_; |
| 374 gfx::Rect title_bounds_; | 373 gfx::Rect title_bounds_; |
| 375 gfx::Rect close_button_bounds_; | 374 gfx::Rect close_button_bounds_; |
| 376 | 375 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 // The current color of the close button. | 440 // The current color of the close button. |
| 442 SkColor close_button_color_; | 441 SkColor close_button_color_; |
| 443 | 442 |
| 444 // Used to listen for theme change notifications. | 443 // Used to listen for theme change notifications. |
| 445 NotificationRegistrar registrar_; | 444 NotificationRegistrar registrar_; |
| 446 | 445 |
| 447 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); | 446 DISALLOW_COPY_AND_ASSIGN(TabRendererGtk); |
| 448 }; | 447 }; |
| 449 | 448 |
| 450 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ | 449 #endif // CHROME_BROWSER_GTK_TABS_TAB_RENDERER_GTK_H_ |
| OLD | NEW |