summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views/tabs
diff options
context:
space:
mode:
authorglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 20:02:07 +0000
committerglen@chromium.org <glen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-04 20:02:07 +0000
commite296bed56a43c1aac9204e86976fcfc91c8e9631 (patch)
tree4f8f97fb074693b475ae145d8f337b9369969bf5 /chrome/browser/views/tabs
parent98d8f5ca944a12014f930165f403d56aa39cd39b (diff)
downloadchromium_src-e296bed56a43c1aac9204e86976fcfc91c8e9631.zip
chromium_src-e296bed56a43c1aac9204e86976fcfc91c8e9631.tar.gz
chromium_src-e296bed56a43c1aac9204e86976fcfc91c8e9631.tar.bz2
Make the inactive tab background line up with the parent without using magic numbers.
BUG=12761 TEST=Verify that the inactive tab background lines up with the frame image in maximized and unmaximized mode - you will need a heavily patterned theme to test with. Review URL: http://codereview.chromium.org/118221 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc15
-rw-r--r--chrome/browser/views/tabs/tab_renderer.h10
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc7
-rw-r--r--chrome/browser/views/tabs/tab_strip.h3
4 files changed, 27 insertions, 8 deletions
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index fefae85..a65662f 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -584,10 +584,8 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) {
// The tab image needs to be lined up with the background image
// so that it feels partially transparent. These offsets represent the tab
// position within the frame background image.
- int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1;
- // TODO(glen): http://crbug.com/12761 This should use
- // BrowserView::GetTabstripBounds() instead of a hardcoded constant.
- int offset_y = 20;
+ int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
+ background_offset_.x();
int tab_id;
if (GetWidget() &&
@@ -603,7 +601,7 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) {
// Draw left edge. Don't draw over the toolbar, as we're not the foreground
// tab.
SkBitmap tab_l = skia::ImageOperations::CreateTiledBitmap(
- *tab_bg, offset, offset_y,
+ *tab_bg, offset, background_offset_.y(),
tab_active.l_width, height());
SkBitmap theme_l = skia::ImageOperations::CreateMaskedBitmap(
tab_l, *tab_alpha.image_l);
@@ -615,7 +613,7 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) {
// Draw right edge. Again, don't draw over the toolbar.
SkBitmap tab_r = skia::ImageOperations::CreateTiledBitmap(
*tab_bg,
- offset + width() - tab_active.r_width, offset_y,
+ offset + width() - tab_active.r_width, background_offset_.y(),
tab_active.r_width, height());
SkBitmap theme_r = skia::ImageOperations::CreateMaskedBitmap(
tab_r, *tab_alpha.image_r);
@@ -628,7 +626,7 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) {
// by incrementing by kDropShadowHeight, since it's a simple rectangle. And
// again, don't draw over the toolbar.
canvas->TileImageInt(*tab_bg,
- offset + tab_active.l_width, offset_y + kDropShadowHeight,
+ offset + tab_active.l_width, background_offset_.y() + kDropShadowHeight,
tab_active.l_width, kDropShadowHeight,
width() - tab_active.l_width - tab_active.r_width,
height() - kDropShadowHeight - kToolbarOverlap);
@@ -644,7 +642,8 @@ void TabRenderer::PaintInactiveTabBackground(gfx::Canvas* canvas) {
}
void TabRenderer::PaintActiveTabBackground(gfx::Canvas* canvas) {
- int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) + 1;
+ int offset = GetX(views::View::APPLY_MIRRORING_TRANSFORMATION) +
+ background_offset_.x();
ThemeProvider* tp = GetThemeProvider();
if (!tp)
NOTREACHED() << "Unable to get theme provider";
diff --git a/chrome/browser/views/tabs/tab_renderer.h b/chrome/browser/views/tabs/tab_renderer.h
index f0785ab..e68308c 100644
--- a/chrome/browser/views/tabs/tab_renderer.h
+++ b/chrome/browser/views/tabs/tab_renderer.h
@@ -60,6 +60,12 @@ class TabRenderer : public views::View,
void StartPulse();
void StopPulse();
+ // Set the background offset used to match the image in the inactive tab
+ // to the frame image.
+ void SetBackgroundOffset(gfx::Point offset) {
+ background_offset_ = offset;
+ }
+
// Set the theme provider - because we get detached, we are frequently
// outside of a hierarchy with a theme provider at the top. This should be
// called whenever we're detached or attached to a hierarchy.
@@ -137,6 +143,9 @@ class TabRenderer : public views::View,
gfx::Rect favicon_bounds_;
gfx::Rect title_bounds_;
+ // The offset used to paint the inactive background image.
+ gfx::Point background_offset_;
+
// Current state of the animation.
AnimationState animation_state_;
@@ -162,6 +171,7 @@ class TabRenderer : public views::View,
bool crashed;
bool off_the_record;
bool show_icon;
+ int background_vertical_offset;
};
TabData data_;
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 84b1ca3..2db2c86 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -588,6 +588,12 @@ void TabStrip::UpdateLoadingAnimations() {
}
}
+void TabStrip::SetBackgroundOffset(gfx::Point offset) {
+ int tab_count = GetTabCount();
+ for (int i = 0; i < tab_count; ++i)
+ GetTabAt(i)->SetBackgroundOffset(offset);
+}
+
///////////////////////////////////////////////////////////////////////////////
// TabStrip, views::View overrides:
@@ -653,6 +659,7 @@ void TabStrip::Layout() {
GenerateIdealBounds();
int tab_count = GetTabCount();
int tab_right = 0;
+
for (int i = 0; i < tab_count; ++i) {
const gfx::Rect& bounds = tab_data_.at(i).ideal_bounds;
GetTabAt(i)->SetBounds(bounds.x(), bounds.y(), bounds.width(),
diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h
index fb85d20..013f9d1 100644
--- a/chrome/browser/views/tabs/tab_strip.h
+++ b/chrome/browser/views/tabs/tab_strip.h
@@ -87,6 +87,9 @@ class TabStrip : public views::View,
// Updates loading animations for the TabStrip.
void UpdateLoadingAnimations();
+ // Set the background offset used by inactive tabs to match the frame image.
+ void SetBackgroundOffset(gfx::Point offset);
+
// views::View overrides:
virtual void PaintChildren(gfx::Canvas* canvas);
virtual views::View* GetViewByID(int id) const;