diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-03 21:26:41 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-03 21:26:41 +0000 |
commit | dda9db85dfd14a0424d1da962ee2fd88e6de4e8b (patch) | |
tree | 0d127171a0f9382e5844087d81b2302b9bb0674a /chrome/browser/gtk/tabs/tab_gtk.cc | |
parent | 781a29f287deb3a2df33885e061e780ce0086504 (diff) | |
download | chromium_src-dda9db85dfd14a0424d1da962ee2fd88e6de4e8b.zip chromium_src-dda9db85dfd14a0424d1da962ee2fd88e6de4e8b.tar.gz chromium_src-dda9db85dfd14a0424d1da962ee2fd88e6de4e8b.tar.bz2 |
Create a well-defined region that closely matches the shape of the tab to use for hit testing in the Linux tabstrip.
Review URL: http://codereview.chromium.org/62013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tabs/tab_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/tabs/tab_gtk.cc | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc index bd555f4..3cd6869 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_gtk.cc @@ -26,6 +26,13 @@ TabGtk::TabGtk(TabDelegate* delegate) TabGtk::~TabGtk() { } +bool TabGtk::IsPointInBounds(const gfx::Point& point) { + GdkRegion* region = MakeRegionForTab(); + bool in_bounds = (gdk_region_point_in(region, point.x(), point.y()) == TRUE); + gdk_region_destroy(region); + return in_bounds; +} + /////////////////////////////////////////////////////////////////////////////// // TabGtk, TabRendererGtk overrides: @@ -36,28 +43,25 @@ bool TabGtk::IsSelected() const { /////////////////////////////////////////////////////////////////////////////// // TabGtk, private: -void TabGtk::MakePathForTab(gfx::Path* path) const { - DCHECK(path); - - SkScalar h = SkIntToScalar(height()); - SkScalar w = SkIntToScalar(width()); - - path->moveTo(0, h); - - // Left end cap. - path->lineTo(kTabBottomCurveWidth, h - kTabBottomCurveWidth); - path->lineTo(kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth); - path->lineTo(kTabCapWidth, 0); - - // Connect to the right cap. - path->lineTo(w - kTabCapWidth, 0); - - // Right end cap. - path->lineTo(w - kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth); - path->lineTo(w - kTabBottomCurveWidth, h - kTabBottomCurveWidth); - path->lineTo(w, h); - - // Close out the path. - path->lineTo(0, h); - path->close(); +GdkRegion* TabGtk::MakeRegionForTab()const { + int w = width(); + int h = height(); + static const int kNumRegionPoints = 9; + + GdkPoint polygon[kNumRegionPoints] = { + { 0, h }, + { kTabBottomCurveWidth, h - kTabBottomCurveWidth }, + { kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth }, + { kTabCapWidth, 0 }, + { w - kTabCapWidth, 0 }, + { w - kTabCapWidth - kTabTopCurveWidth, kTabTopCurveWidth }, + { w - kTabBottomCurveWidth, h - kTabBottomCurveWidth }, + { w, h }, + { 0, h }, + }; + + GdkRegion* region = gdk_region_polygon(polygon, kNumRegionPoints, + GDK_WINDING_RULE); + gdk_region_offset(region, x(), y()); + return region; } |