diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 04:00:18 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-07 04:00:18 +0000 |
commit | 3f7af10d3e7d931500433326908d261333710b31 (patch) | |
tree | e0e69f211a9c89b5625e0ba1380fd13462bbca14 /chrome/browser/ui/tabs | |
parent | 431814ea3763a71f55729c1e8c0c3d1095481bc9 (diff) | |
download | chromium_src-3f7af10d3e7d931500433326908d261333710b31.zip chromium_src-3f7af10d3e7d931500433326908d261333710b31.tar.gz chromium_src-3f7af10d3e7d931500433326908d261333710b31.tar.bz2 |
Trying again: Gtk: Make click target of tabs match their appearance.
BUG=87856
TEST=See bug
Review URL: http://codereview.chromium.org/7740043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99911 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/tabs')
-rw-r--r-- | chrome/browser/ui/tabs/tab_resources.cc | 44 | ||||
-rw-r--r-- | chrome/browser/ui/tabs/tab_resources.h | 22 |
2 files changed, 66 insertions, 0 deletions
diff --git a/chrome/browser/ui/tabs/tab_resources.cc b/chrome/browser/ui/tabs/tab_resources.cc new file mode 100644 index 0000000..45f06c3 --- /dev/null +++ b/chrome/browser/ui/tabs/tab_resources.cc @@ -0,0 +1,44 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/tabs/tab_resources.h" + +#include "base/logging.h" +#include "ui/gfx/path.h" + +namespace { + +// Hit mask constants. +const SkScalar kTabCapWidth = 15; +const SkScalar kTabTopCurveWidth = 4; +const SkScalar kTabBottomCurveWidth = 3; + +} // namespace + +// static +void TabResources::GetHitTestMask(int width, int height, gfx::Path* path) { + 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(); +} diff --git a/chrome/browser/ui/tabs/tab_resources.h b/chrome/browser/ui/tabs/tab_resources.h new file mode 100644 index 0000000..975ccd0 --- /dev/null +++ b/chrome/browser/ui/tabs/tab_resources.h @@ -0,0 +1,22 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_TABS_TAB_RESOURCES_H_ +#define CHROME_BROWSER_UI_TABS_TAB_RESOURCES_H_ +#pragma once + +namespace gfx { +class Path; +} + +// Common resources for tab widgets. Currently this is used on Views and Gtk, +// but not on Cocoa. +class TabResources { + public: + // Return a |path| containing the region that matches the bitmap display of + // a tab of the given |width| and |height|, for input event hit testing. + static void GetHitTestMask(int width, int height, gfx::Path* path); +}; + +#endif // CHROME_BROWSER_UI_TABS_TAB_RESOURCES_H_ |