diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 23:39:07 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-01 23:39:07 +0000 |
commit | 1c737dc5879775cf70753eefc1f3482aeb460db1 (patch) | |
tree | 8fe3389197fa5bbbe54e87279d90d6eae47317cf | |
parent | a32c2e289456b10490cae921bfe8ba504719c9e0 (diff) | |
download | chromium_src-1c737dc5879775cf70753eefc1f3482aeb460db1.zip chromium_src-1c737dc5879775cf70753eefc1f3482aeb460db1.tar.gz chromium_src-1c737dc5879775cf70753eefc1f3482aeb460db1.tar.bz2 |
Minor tweaks to how pin tabs look:
. Increases the width by 8 pixels.
. Animates the position of the favicon when the tab changes from
pinned to unpinned. Without this the favicon jumps noticably.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/183040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25118 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.cc | 22 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_renderer_gtk.h | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/tabs/tab_strip_gtk.cc | 8 |
3 files changed, 31 insertions, 3 deletions
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc index c2580c7..e6381d6 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc @@ -37,7 +37,7 @@ const int kStandardTitleWidth = 175; const int kDropShadowOffset = 2; const int kInactiveTabBackgroundOffsetY = 20; // Preferred width of pinned tabs. -const int kPinnedTabWidth = 56; +const int kPinnedTabWidth = 64; // 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 @@ -241,6 +241,7 @@ TabRendererGtk::TabRendererGtk(ThemeProvider* theme_provider) InitResources(); data_.pinned = false; + data_.animating_pinned_change = false; tab_.Own(gtk_fixed_new()); gtk_widget_set_app_paintable(tab_.get(), TRUE); @@ -313,6 +314,10 @@ bool TabRendererGtk::is_pinned() const { return data_.pinned; } +void TabRendererGtk::set_animating_pinned_change(bool value) { + data_.animating_pinned_change = value; +} + bool TabRendererGtk::IsSelected() const { return true; } @@ -591,8 +596,19 @@ void TabRendererGtk::Layout() { int favicon_top = kTopPadding + (content_height - kFavIconSize) / 2; favicon_bounds_.SetRect(local_bounds.x(), favicon_top, kFavIconSize, kFavIconSize); - if (is_pinned() && bounds_.width() < kPinnedTabRendererAsTabWidth) - favicon_bounds_.set_x((bounds_.width() - kFavIconSize) / 2); + if ((is_pinned() || data_.animating_pinned_change) && + bounds_.width() < kPinnedTabRendererAsTabWidth) { + int pin_delta = kPinnedTabRendererAsTabWidth - kPinnedTabWidth; + int ideal_delta = bounds_.width() - kPinnedTabWidth; + if (ideal_delta < pin_delta) { + int ideal_x = (kPinnedTabWidth - kFavIconSize) / 2; + int x = favicon_bounds_.x() + static_cast<int>( + (1 - static_cast<float>(ideal_delta) / + static_cast<float>(pin_delta)) * + (ideal_x - favicon_bounds_.x())); + favicon_bounds_.set_x(x); + } + } } else { favicon_bounds_.SetRect(local_bounds.x(), local_bounds.y(), 0, 0); } diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h index ff85410..d994be2 100644 --- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h +++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h @@ -106,6 +106,9 @@ class TabRendererGtk : public AnimationDelegate { void set_pinned(bool pinned); bool is_pinned() const; + // Are we in the process of animating a pinned state change on this tab? + void set_animating_pinned_change(bool value); + // Updates the display to reflect the contents of this TabRenderer's model. void UpdateFromModel(); @@ -223,6 +226,7 @@ class TabRendererGtk : public AnimationDelegate { bool off_the_record; bool show_icon; bool pinned; + bool animating_pinned_change; }; // TODO(jhawkins): Move into TabResources class. diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index 01be3db..aaea60f 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -524,6 +524,7 @@ class PinnedTabAnimation : public TabStripGtk::TabAnimation { start_pinned_count--; else start_pinned_count++; + tabstrip_->GetTabAt(index)->set_animating_pinned_change(true); GenerateStartAndEndWidths(tab_count, tab_count, start_pinned_count, end_pinned_count); } @@ -588,6 +589,7 @@ class PinAndMoveAnimation : public TabStripGtk::TabAnimation { GenerateStartAndEndWidths(tab_count, tab_count, start_pinned_count, end_pinned_count); target_bounds_ = tabstrip->GetIdealBounds(to_index); + tab_->set_animating_pinned_change(true); } // Overridden from AnimationDelegate: @@ -767,6 +769,7 @@ void TabStripGtk::Layout() { for (int i = 0; i < tab_count; ++i) { const gfx::Rect& bounds = tab_data_.at(i).ideal_bounds; TabGtk* tab = GetTabAt(i); + tab->set_animating_pinned_change(false); SetTabBounds(tab, bounds); tab_right = bounds.right(); tab_right += GetTabHOffset(i + 1); @@ -1769,6 +1772,11 @@ bool TabStripGtk::CanUpdateDisplay() { void TabStripGtk::FinishAnimation(TabStripGtk::TabAnimation* animation, bool layout) { active_animation_.reset(NULL); + + // Reset the animation state of each tab. + for (int i = 0, count = GetTabCount(); i < count; ++i) + GetTabAt(i)->set_animating_pinned_change(false); + if (layout) Layout(); } |