diff options
author | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 00:37:27 +0000 |
---|---|---|
committer | erg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-23 00:37:27 +0000 |
commit | 8ee2adfed1b3c34d1031b1a0e4f8e0380f4e1707 (patch) | |
tree | d6f3616b6af66ea8c4aacff2df304a12d670bd4b /chrome/browser/gtk/tabs | |
parent | 811430d640be417604665d1f73a4d02e9eb50f56 (diff) | |
download | chromium_src-8ee2adfed1b3c34d1031b1a0e4f8e0380f4e1707.zip chromium_src-8ee2adfed1b3c34d1031b1a0e4f8e0380f4e1707.tar.gz chromium_src-8ee2adfed1b3c34d1031b1a0e4f8e0380f4e1707.tar.bz2 |
GTK: Change the vertical offsets in non-custom tab background images depending on how the window is configured.
This fixes the vertical positioning of transparent tabs when no tab background image was specified.
BUG=34815
TEST=none
Review URL: http://codereview.chromium.org/650076
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/tabs')
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.h | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 7 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.h | 9 |
4 files changed, 28 insertions, 3 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index 861ff04..151e13a 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -37,7 +37,8 @@ const int kFavIconTitleSpacing = 4; const int kTitleCloseButtonSpacing = 5; const int kStandardTitleWidth = 175; const int kDropShadowOffset = 2; -const int kInactiveTabBackgroundOffsetY = 20; +const int kInactiveTabBackgroundOffsetY = 15; + // When a non-pinned tab is pinned the width of the tab animates. If the width // of a pinned tab is >= kPinnedTabRendererAsTabWidth then the tab is rendered // as a normal tab. This is done to avoid having the title immediately @@ -244,6 +245,7 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider) should_display_crashed_favicon_(false), loading_animation_(theme_provider), background_offset_x_(0), + background_offset_y_(kInactiveTabBackgroundOffsetY), close_button_color_(NULL) { InitResources(); @@ -390,7 +392,7 @@ void TabRendererGtk::PaintFavIconArea(GdkEventExpose* event) { theme_id = IDR_THEME_TAB_BACKGROUND_INCOGNITO; } if (!theme_provider_->HasCustomImage(theme_id)) - offset_y = kInactiveTabBackgroundOffsetY; + offset_y = background_offset_y_; } SkBitmap* tab_bg = theme_provider_->GetBitmapNamed(theme_id); canvas.TileImageInt(*tab_bg, @@ -877,7 +879,7 @@ void TabRendererGtk::PaintInactiveTabBackground(gfx::Canvas* canvas) { // should be at the top of the tab. Otherwise, we assume that the background // image is a composited foreground + frame image. int offset_y = theme_provider_->HasCustomImage(tab_id) ? - 0 : kInactiveTabBackgroundOffsetY; + 0 : background_offset_y_; // Draw left edge. SkBitmap* theme_l = GetMaskedBitmap(tab_alpha_.image_l, tab_bg, offset_x, diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h index 440a0d7..227322b 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h @@ -204,6 +204,8 @@ class TabRendererGtk : public AnimationDelegate, void StartPinnedTabTitleAnimation(); void StopPinnedTabTitleAnimation(); + void set_vertical_offset(int offset) { background_offset_y_ = offset; } + protected: const gfx::Rect& title_bounds() const { return title_bounds_; } const gfx::Rect& close_button_bounds() const { return close_button_bounds_; } @@ -405,6 +407,11 @@ class TabRendererGtk : public AnimationDelegate, // The offset used to paint the tab theme images. int background_offset_x_; + // The vertical offset used to paint the tab theme images. Controlled by the + // tabstrip and plumbed here to offset the theme image by the size of the + // alignment in the BrowserTitlebar. + int background_offset_y_; + GtkThemeProvider* theme_provider_; // The close button. diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index cb63413..858b88b 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -514,6 +514,7 @@ TabStripGtk::TabStripGtk(TabStripModel* model, BrowserWindowGtk* window) current_selected_width_(TabGtk::GetStandardSize().width()), available_width_for_tabs_(-1), needs_resize_layout_(false), + tab_vertical_offset_(0), model_(model), window_(window), theme_provider_(GtkThemeProvider::GetFrom(model->profile())), @@ -612,6 +613,7 @@ void TabStripGtk::Layout() { const gfx::Rect& bounds = tab_data_.at(i).ideal_bounds; TabGtk* tab = GetTabAt(i); tab->set_animating_pinned_change(false); + tab->set_vertical_offset(tab_vertical_offset_); SetTabBounds(tab, bounds); tab_right = bounds.right(); tab_right += GetTabHOffset(i + 1); @@ -702,6 +704,11 @@ gfx::Rect TabStripGtk::GetIdealBounds(int index) { return tab_data_.at(index).ideal_bounds; } +void TabStripGtk::SetVerticalOffset(int offset) { + tab_vertical_offset_ = offset; + Layout(); +} + gfx::Point TabStripGtk::GetTabStripOriginForWidget(GtkWidget* target) { int x, y; if (!gtk_widget_translate_coordinates(widget(), target, diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.h b/chrome/browser/gtk/tabs/tab_strip_gtk.h index 048f661..1c4a5b7 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.h +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.h @@ -84,6 +84,11 @@ class TabStripGtk : public TabStripModelObserver, // Retrieve the ideal bounds for the Tab at the specified index. gfx::Rect GetIdealBounds(int index); + // Sets the vertical offset that each tab will use to offset against the + // background image. Passed in from the titlebar and based on the size of the + // alignment that sits above the tabstrip. + void SetVerticalOffset(int offset); + // TabstripOriginProvider implementation ------------------------------------- virtual gfx::Point GetTabStripOriginForWidget(GtkWidget* widget); @@ -415,6 +420,10 @@ class TabStripGtk : public TabStripModelObserver, // The bounds of the tabstrip. gfx::Rect bounds_; + // The amount to offset tab backgrounds when we are using an autogenerated + // tab background image. + int tab_vertical_offset_; + // Our model. TabStripModel* model_; |