From 63c39bc108e41f2b75cf9c0a374dc75d0ffb3d9b Mon Sep 17 00:00:00 2001 From: "markusheintz@chromium.org" Date: Mon, 23 Jul 2012 09:10:35 +0000 Subject: Layout the tabs in the TabStrip of views implementation of the tabbed pane with an offset. So tabs will be painted with small offset/inset to the vertical border of the tabbed pane. Draw the active (selected) tab with a solid background BUG=138063 TEST=none Review URL: https://chromiumcodereview.appspot.com/10810005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147838 0039d316-1c4b-4281-b951-d872f2087c98 --- .../controls/tabbed_pane/native_tabbed_pane_views.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ui/views/controls') diff --git a/ui/views/controls/tabbed_pane/native_tabbed_pane_views.cc b/ui/views/controls/tabbed_pane/native_tabbed_pane_views.cc index 570b7a9..6e37c8b 100644 --- a/ui/views/controls/tabbed_pane/native_tabbed_pane_views.cc +++ b/ui/views/controls/tabbed_pane/native_tabbed_pane_views.cc @@ -20,6 +20,9 @@ const SkColor kTabTitleColor_Inactive = SkColorSetRGB(0x66, 0x66, 0x66); const SkColor kTabTitleColor_Active = SkColorSetRGB(0x20, 0x20, 0x20); const SkColor kTabTitleColor_Pressed = SkColorSetRGB(0x33, 0x33, 0x33); const SkColor kTabTitleColor_Hovered = SkColorSetRGB(0x22, 0x22, 0x22); +// TODO(markusheintz): The tab background color should be provided by the +// NativeTheme. +const SkColor kTabBackgroundColor_Active = SK_ColorWHITE; const SkColor kTabBorderColor = SkColorSetRGB(0xCC, 0xCC, 0xCC); const SkScalar kTabBorderThickness = 1.0f; const SkScalar kTabBorderRadius = 2.0f; @@ -63,6 +66,12 @@ class Tab : public View { } private: + void PaintTabBackground(gfx::Canvas* canvas) { + // Fill the background. Note that we don't constrain to the bounds as + // canvas is already clipped for us. + canvas->DrawColor(kTabBackgroundColor_Active); + } + void PaintTabBorder(gfx::Canvas* canvas) { SkPath path; SkRect bounds = { 0, 0, SkIntToScalar(width()), SkIntToScalar(height()) }; @@ -149,7 +158,8 @@ class TabStrip : public View { return gfx::Size(50, Tab::GetMinimumTabHeight()); } virtual void Layout() OVERRIDE { - int x = 0; + const int kTabOffset = 18; + int x = kTabOffset; // Layout tabs with an offset to the tabstrip border. for (int i = 0; i < child_count(); ++i) { gfx::Size ps = child_at(i)->GetPreferredSize(); child_at(i)->SetBounds(x, 0, ps.width(), ps.height()); @@ -178,8 +188,10 @@ void Tab::OnSelectedStateChanged(bool selected) { void Tab::OnPaint(gfx::Canvas* canvas) { bool selected = tab_strip_->IsTabSelected(this); - if (selected) + if (selected) { + PaintTabBackground(canvas); PaintTabBorder(canvas); + } PaintTabTitle(canvas, selected); } -- cgit v1.1