summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk/tabs/tab_renderer_gtk.cc')
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc40
1 files changed, 38 insertions, 2 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 7331c14..b6e9464 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -10,6 +10,7 @@
#include "chrome/common/resource_bundle.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+#include "skia/ext/image_operations.h"
namespace {
@@ -29,6 +30,9 @@ const int kUnselectedTitleColor = SkColorSetRGB(64, 64, 64);
const int kCloseButtonVertFuzz = 0;
const int kCloseButtonHorzFuzz = 5;
+// How opaque to make the hover state (out of 1).
+const double kHoverOpacity = 0.33;
+
// TODO(jhawkins): Move this code into ChromeFont and allow pulling out a
// GdkFont*.
GdkFont* load_default_font() {
@@ -70,7 +74,8 @@ TabRendererGtk::TabRendererGtk()
showing_download_icon_(false),
showing_close_button_(false),
fav_icon_hiding_offset_(0),
- should_display_crashed_favicon_(false) {
+ should_display_crashed_favicon_(false),
+ hovering_(false) {
InitResources();
}
@@ -180,6 +185,11 @@ void TabRendererGtk::SetBounds(const gfx::Rect& bounds) {
Layout();
}
+bool TabRendererGtk::IsPointInBounds(const gfx::Point& coord) {
+ // TODO(jhawkins): Use a GdkRegion that better maps to the shape of the tab.
+ return bounds_.Contains(coord);
+}
+
////////////////////////////////////////////////////////////////////////////////
// TabRendererGtk, protected:
@@ -315,7 +325,13 @@ void TabRendererGtk::PaintTabBackground(ChromeCanvasPaint* canvas) {
// the active representation for the dragged tab.
PaintActiveTabBackground(canvas);
} else {
- PaintInactiveTabBackground(canvas);
+ // Draw our hover state.
+ // TODO(jhawkins): Hover animations.
+ if (hovering_) {
+ PaintHoverTabBackground(canvas, kHoverOpacity);
+ } else {
+ PaintInactiveTabBackground(canvas);
+ }
}
}
@@ -333,6 +349,26 @@ void TabRendererGtk::PaintInactiveTabBackground(ChromeCanvasPaint* canvas) {
bounds_.y());
}
+void TabRendererGtk::PaintHoverTabBackground(ChromeCanvasPaint* canvas,
+ double opacity) {
+ bool is_otr = data_.off_the_record;
+ const TabImage& image = is_otr ? tab_inactive_otr_ : tab_inactive_;
+
+ SkBitmap left = skia::ImageOperations::CreateBlendedBitmap(
+ *image.image_l, *tab_hover_.image_l, opacity);
+ SkBitmap center = skia::ImageOperations::CreateBlendedBitmap(
+ *image.image_c, *tab_hover_.image_c, opacity);
+ SkBitmap right = skia::ImageOperations::CreateBlendedBitmap(
+ *image.image_r, *tab_hover_.image_r, opacity);
+
+ canvas->DrawBitmapInt(left, bounds_.x(), bounds_.y());
+ canvas->TileImageInt(center, bounds_.x() + tab_active_.l_width, bounds_.y(),
+ bounds_.width() - tab_active_.l_width - tab_active_.r_width,
+ bounds_.height());
+ canvas->DrawBitmapInt(right,
+ bounds_.x() + bounds_.width() - tab_active_.r_width, bounds_.y());
+}
+
void TabRendererGtk::PaintActiveTabBackground(ChromeCanvasPaint* canvas) {
canvas->DrawBitmapInt(*tab_active_.image_l, bounds_.x(), bounds_.y());
canvas->TileImageInt(*tab_active_.image_c,