diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 21:20:54 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-02 21:20:54 +0000 |
commit | 1a242c311da93e0458808816d5212805e7b93464 (patch) | |
tree | 6cecde28259a1ae051436f44f1f23e9a69be276d /chrome/browser/views/tabs | |
parent | 12d1d395df66090ce37a8719040bf9c096636330 (diff) | |
download | chromium_src-1a242c311da93e0458808816d5212805e7b93464.zip chromium_src-1a242c311da93e0458808816d5212805e7b93464.tar.gz chromium_src-1a242c311da93e0458808816d5212805e7b93464.tar.bz2 |
Adjusts tab strip model to deal with app tabs. There were a couple of
places where I left them using the variable with pinned when it should
be app because those places need to be radically whacked. I'll do that
next.
BUG=32845
TEST=none yet
Review URL: http://codereview.chromium.org/555173
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/tabs')
-rw-r--r-- | chrome/browser/views/tabs/dragged_tab_controller.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_overview_controller.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_overview_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 190 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 10 |
5 files changed, 11 insertions, 206 deletions
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index e354e56..04c0a1b 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -681,8 +681,7 @@ void DraggedTabController::MoveTab(const gfx::Point& screen_point) { if (!view_->pinned()) { // If the dragged tab isn't pinned, don't allow the drag to a pinned // tab. - to_index = - std::max(to_index, attached_model->IndexOfFirstNonPinnedTab()); + to_index = std::max(to_index, attached_model->IndexOfFirstNonAppTab()); } if (from_index != to_index) { last_move_screen_x_ = screen_point.x(); @@ -745,8 +744,8 @@ void DraggedTabController::StartPinTimerIfNecessary( return; TabStripModel* attached_model = attached_tabstrip_->model(); - int pinned_count = attached_model->IndexOfFirstNonPinnedTab(); - if (pinned_count > 0) + int app_count = attached_model->IndexOfFirstNonAppTab(); + if (app_count > 0) return; int index = attached_model->GetIndexOfTabContents(dragged_contents_); @@ -768,7 +767,7 @@ void DraggedTabController::AdjustDragPointForPinnedTabs( int* from_index, gfx::Point* dragged_tab_point) { TabStripModel* attached_model = attached_tabstrip_->model(); - int pinned_count = attached_model->IndexOfFirstNonPinnedTab(); + int pinned_count = attached_model->IndexOfFirstNonAppTab(); if (pinned_count == 0) return; @@ -982,7 +981,7 @@ void DraggedTabController::Detach() { } int DraggedTabController::GetPinnedThreshold() { - int pinned_count = attached_tabstrip_->model()->IndexOfFirstNonPinnedTab(); + int pinned_count = attached_tabstrip_->model()->IndexOfFirstNonAppTab(); if (pinned_count == 0) return 0; if (!view_->pinned()) { diff --git a/chrome/browser/views/tabs/tab_overview_controller.cc b/chrome/browser/views/tabs/tab_overview_controller.cc index 3e791d6..4422d85 100644 --- a/chrome/browser/views/tabs/tab_overview_controller.cc +++ b/chrome/browser/views/tabs/tab_overview_controller.cc @@ -253,8 +253,7 @@ void TabOverviewController::TabDetachedAt(TabContents* contents, int index) { void TabOverviewController::TabMoved(TabContents* contents, int from_index, - int to_index, - bool pinned_state_changed) { + int to_index) { if (!grid_->modifying_model()) grid_->CancelDrag(); diff --git a/chrome/browser/views/tabs/tab_overview_controller.h b/chrome/browser/views/tabs/tab_overview_controller.h index 4fc2cf8..3110f7d 100644 --- a/chrome/browser/views/tabs/tab_overview_controller.h +++ b/chrome/browser/views/tabs/tab_overview_controller.h @@ -90,8 +90,7 @@ class TabOverviewController : public TabStripModelObserver { virtual void TabDetachedAt(TabContents* contents, int index); virtual void TabMoved(TabContents* contents, int from_index, - int to_index, - bool pinned_state_changed); + int to_index); virtual void TabChangedAt(TabContents* contents, int index, TabChangeType change_type); virtual void TabStripEmpty(); diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 5dc8a49..69af0895 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -52,7 +52,6 @@ using views::DropTargetEvent; static const int kDefaultAnimationDurationMs = 200; static const int kResizeLayoutAnimationDurationMs = 200; static const int kReorderAnimationDurationMs = 200; -static const int kPinnedTabAnimationDurationMs = 200; static const int kNewTabButtonHOffset = -5; static const int kNewTabButtonVOffset = 5; @@ -129,8 +128,6 @@ class TabStrip::TabAnimation : public AnimationDelegate { REMOVE, MOVE, RESIZE, - PIN, - PIN_MOVE }; TabAnimation(TabStrip* tabstrip, Type type) @@ -558,164 +555,6 @@ class TabStrip::ResizeLayoutAnimation : public TabStrip::TabAnimation { DISALLOW_COPY_AND_ASSIGN(ResizeLayoutAnimation); }; -//////////////////////////////////////////////////////////////////////////////// - -// Handles a tabs pinned state changing while the tab does not change position -// in the model. -class TabStrip::PinnedTabAnimation : public TabStrip::TabAnimation { - public: - explicit PinnedTabAnimation(TabStrip* tabstrip, int index) - : TabAnimation(tabstrip, PIN), - index_(index) { - int tab_count = tabstrip->GetTabCount(); - int start_pinned_count = tabstrip->GetPinnedTabCount(); - int end_pinned_count = start_pinned_count; - if (tabstrip->GetTabAt(index)->pinned()) - 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); - } - - protected: - // Overridden from TabStrip::TabAnimation: - virtual int GetDuration() const { - return kPinnedTabAnimationDurationMs; - } - - virtual double GetWidthForTab(int index) const { - Tab* tab = tabstrip_->GetTabAt(index); - - if (index == index_) { - if (tab->pinned()) { - return AnimationPosition( - start_selected_width_, - static_cast<double>(Tab::GetPinnedWidth())); - } else { - return AnimationPosition(static_cast<double>(Tab::GetPinnedWidth()), - end_selected_width_); - } - } else if (tab->pinned()) { - return Tab::GetPinnedWidth(); - } - - if (tab->IsSelected()) - return AnimationPosition(start_selected_width_, end_selected_width_); - - return AnimationPosition(start_unselected_width_, end_unselected_width_); - } - - private: - // Index of the tab whose pinned state changed. - int index_; - - DISALLOW_COPY_AND_ASSIGN(PinnedTabAnimation); -}; - -//////////////////////////////////////////////////////////////////////////////// - -// Handles the animation when a tabs pinned state changes and the tab moves as a -// result. -class TabStrip::PinAndMoveAnimation : public TabStrip::TabAnimation { - public: - explicit PinAndMoveAnimation(TabStrip* tabstrip, - int from_index, - int to_index, - const gfx::Rect& start_bounds) - : TabAnimation(tabstrip, PIN_MOVE), - tab_(tabstrip->GetTabAt(to_index)), - start_bounds_(start_bounds), - from_index_(from_index), - to_index_(to_index) { - int tab_count = tabstrip->GetTabCount(); - int start_pinned_count = tabstrip->GetPinnedTabCount(); - int end_pinned_count = start_pinned_count; - if (tabstrip->GetTabAt(to_index)->pinned()) - start_pinned_count--; - else - start_pinned_count++; - 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: - virtual void AnimationProgressed(const Animation* animation) { - // Do the normal layout. - TabAnimation::AnimationProgressed(animation); - - // Then special case the position of the tab being moved. - int x = AnimationPosition(start_bounds_.x(), target_bounds_.x()); - int width = AnimationPosition(start_bounds_.width(), - target_bounds_.width()); - gfx::Rect tab_bounds(x, start_bounds_.y(), width, - start_bounds_.height()); - tab_->SetBounds(tab_bounds); - } - - virtual void AnimationEnded(const Animation* animation) { - tabstrip_->needs_resize_layout_ = false; - TabStrip::TabAnimation::AnimationEnded(animation); - } - - virtual double GetGapWidth(int index) { - if (to_index_ < from_index_) { - // The tab was pinned. - if (index == to_index_) { - double current_size = AnimationPosition(0, target_bounds_.width()); - if (current_size < -kTabHOffset) - return -(current_size + kTabHOffset); - } else if (index == from_index_ + 1) { - return AnimationPosition(start_bounds_.width(), 0); - } - } else { - // The tab was unpinned. - if (index == from_index_) { - return AnimationPosition(Tab::GetPinnedWidth() + kTabHOffset, 0); - } - } - return 0; - } - - protected: - // Overridden from TabStrip::TabAnimation: - virtual int GetDuration() const { return kReorderAnimationDurationMs; } - - virtual double GetWidthForTab(int index) const { - Tab* tab = tabstrip_->GetTabAt(index); - - if (index == to_index_) - return AnimationPosition(0, target_bounds_.width()); - - if (tab->pinned()) - return Tab::GetPinnedWidth(); - - if (tab->IsSelected()) - return AnimationPosition(start_selected_width_, end_selected_width_); - - return AnimationPosition(start_unselected_width_, end_unselected_width_); - } - - private: - // The tab being moved. - Tab* tab_; - - // Initial bounds of tab_. - gfx::Rect start_bounds_; - - // Target bounds. - gfx::Rect target_bounds_; - - // Start and end indices of the tab. - int from_index_; - int to_index_; - - DISALLOW_COPY_AND_ASSIGN(PinAndMoveAnimation); -}; - /////////////////////////////////////////////////////////////////////////////// // TabStrip, public: @@ -1158,8 +997,7 @@ void TabStrip::TabSelectedAt(TabContents* old_contents, GetTabAt(old_index)->StopPinnedTabTitleAnimation(); } -void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index, - bool pinned_state_changed) { +void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index) { gfx::Rect start_bounds = GetIdealBounds(from_index); Tab* tab = GetTabAt(from_index); tab_data_.erase(tab_data_.begin() + from_index); @@ -1169,12 +1007,8 @@ void TabStrip::TabMoved(TabContents* contents, int from_index, int to_index, tab_data_.insert(tab_data_.begin() + to_index, data); if (tab->phantom() != model_->IsPhantomTab(to_index)) tab->set_phantom(!tab->phantom()); - if (pinned_state_changed) { - StartPinAndMoveTabAnimation(from_index, to_index, start_bounds); - } else { - GenerateIdealBounds(); - StartMoveTabAnimation(from_index, to_index); - } + GenerateIdealBounds(); + StartMoveTabAnimation(from_index, to_index); } void TabStrip::TabChangedAt(TabContents* contents, int index, @@ -1201,7 +1035,6 @@ void TabStrip::TabReplacedAt(TabContents* old_contents, void TabStrip::TabPinnedStateChanged(TabContents* contents, int index) { GetTabAt(index)->set_pinned(model_->IsTabPinned(index)); - StartPinnedTabAnimation(index); } void TabStrip::TabBlockedStateChanged(TabContents* contents, int index) { @@ -1894,23 +1727,6 @@ void TabStrip::StartMoveTabAnimation(int from_index, int to_index) { active_animation_->Start(); } -void TabStrip::StartPinnedTabAnimation(int index) { - if (active_animation_.get()) - active_animation_->Stop(); - active_animation_.reset(new PinnedTabAnimation(this, index)); - active_animation_->Start(); -} - -void TabStrip::StartPinAndMoveTabAnimation(int from_index, - int to_index, - const gfx::Rect& start_bounds) { - if (active_animation_.get()) - active_animation_->Stop(); - active_animation_.reset( - new PinAndMoveAnimation(this, from_index, to_index, start_bounds)); - active_animation_->Start(); -} - void TabStrip::FinishAnimation(TabStrip::TabAnimation* animation, bool layout) { active_animation_.reset(NULL); diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 309a9f3..e24cc43 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -135,8 +135,7 @@ class TabStrip : public views::View, TabContents* contents, int index, bool user_gesture); - virtual void TabMoved(TabContents* contents, int from_index, int to_index, - bool pinned_state_changed); + virtual void TabMoved(TabContents* contents, int from_index, int to_index); virtual void TabChangedAt(TabContents* contents, int index, TabChangeType change_type); virtual void TabReplacedAt(TabContents* old_contents, @@ -181,8 +180,6 @@ class TabStrip : public views::View, private: class InsertTabAnimation; class MoveTabAnimation; - class PinAndMoveAnimation; - class PinnedTabAnimation; class RemoveTabAnimation; class ResizeLayoutAnimation; class TabAnimation; @@ -190,8 +187,6 @@ class TabStrip : public views::View, friend class DraggedTabController; friend class InsertTabAnimation; friend class MoveTabAnimation; - friend class PinAndMoveAnimation; - friend class PinnedTabAnimation; friend class RemoveTabAnimation; friend class ResizeLayoutAnimation; friend class TabAnimation; @@ -295,9 +290,6 @@ class TabStrip : public views::View, void StartInsertTabAnimation(int index); void StartRemoveTabAnimation(int index, TabContents* contents); void StartMoveTabAnimation(int from_index, int to_index); - void StartPinnedTabAnimation(int index); - void StartPinAndMoveTabAnimation(int from_index, int to_index, - const gfx::Rect& start_bounds); // Notifies the TabStrip that the specified TabAnimation has completed. // Optionally a full Layout will be performed, specified by |layout|. |