Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(308)

Side by Side Diff: chrome/browser/ui/views/tabs/base_tab_strip.cc

Issue 6822006: Adds scroll buttons to side tabs so that you can get to all the tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/base_tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/base_tab_strip.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/ui/title_prefix_matcher.h" 8 #include "chrome/browser/ui/title_prefix_matcher.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" 10 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 BaseTabStrip::BaseTabStrip(TabStripController* controller, Type type) 119 BaseTabStrip::BaseTabStrip(TabStripController* controller, Type type)
120 : controller_(controller), 120 : controller_(controller),
121 type_(type), 121 type_(type),
122 attaching_dragged_tab_(false), 122 attaching_dragged_tab_(false),
123 ALLOW_THIS_IN_INITIALIZER_LIST(bounds_animator_(this)) { 123 ALLOW_THIS_IN_INITIALIZER_LIST(bounds_animator_(this)) {
124 } 124 }
125 125
126 BaseTabStrip::~BaseTabStrip() { 126 BaseTabStrip::~BaseTabStrip() {
127 } 127 }
128 128
129 bool BaseTabStrip::IsAnimating() const {
130 return bounds_animator_.IsAnimating();
131 }
132
133 void BaseTabStrip::AddTabAt(int model_index, const TabRendererData& data) { 129 void BaseTabStrip::AddTabAt(int model_index, const TabRendererData& data) {
134 BaseTab* tab = CreateTab(); 130 BaseTab* tab = CreateTab();
135 tab->SetData(data); 131 tab->SetData(data);
136 132
137 TabData d = { tab, gfx::Rect() }; 133 TabData d = { tab, gfx::Rect() };
138 tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d); 134 tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d);
139 UpdateCommonTitlePrefix(); 135 UpdateCommonTitlePrefix();
140 136
141 AddChildView(tab); 137 AddChildView(tab);
142 138
143 // Don't animate the first tab, it looks weird, and don't animate anything 139 // Don't animate the first tab, it looks weird, and don't animate anything
144 // if the containing window isn't visible yet. 140 // if the containing window isn't visible yet.
145 if (tab_count() > 1 && GetWindow() && GetWindow()->IsVisible()) 141 if (tab_count() > 1 && GetWindow() && GetWindow()->IsVisible())
146 StartInsertTabAnimation(model_index); 142 StartInsertTabAnimation(model_index);
147 else 143 else
148 DoLayout(); 144 DoLayout();
149 } 145 }
150 146
151 void BaseTabStrip::MoveTab(int from_model_index, int to_model_index) { 147 void BaseTabStrip::MoveTab(int from_model_index, int to_model_index) {
152 int from_tab_data_index = ModelIndexToTabIndex(from_model_index); 148 int from_tab_data_index = ModelIndexToTabIndex(from_model_index);
153
154 BaseTab* tab = tab_data_[from_tab_data_index].tab; 149 BaseTab* tab = tab_data_[from_tab_data_index].tab;
155 tab_data_.erase(tab_data_.begin() + from_tab_data_index); 150 tab_data_.erase(tab_data_.begin() + from_tab_data_index);
156 151
157 TabData data = {tab, gfx::Rect()}; 152 TabData data = {tab, gfx::Rect()};
158
159 int to_tab_data_index = ModelIndexToTabIndex(to_model_index); 153 int to_tab_data_index = ModelIndexToTabIndex(to_model_index);
160
161 tab_data_.insert(tab_data_.begin() + to_tab_data_index, data); 154 tab_data_.insert(tab_data_.begin() + to_tab_data_index, data);
162 155
163 StartMoveTabAnimation(); 156 StartMoveTabAnimation();
164 } 157 }
165 158
166 void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) { 159 void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) {
167 BaseTab* tab = GetBaseTabAtModelIndex(model_index); 160 BaseTab* tab = GetBaseTabAtModelIndex(model_index);
168 bool mini_state_changed = tab->data().mini != data.mini; 161 bool mini_state_changed = tab->data().mini != data.mini;
169 tab->SetData(data); 162 tab->SetData(data);
170 UpdateCommonTitlePrefix(); 163 UpdateCommonTitlePrefix();
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 StopAnimating(false); 548 StopAnimating(false);
556 549
557 GenerateIdealBounds(); 550 GenerateIdealBounds();
558 551
559 for (int i = 0; i < tab_count(); ++i) 552 for (int i = 0; i < tab_count(); ++i)
560 tab_data_[i].tab->SetBoundsRect(tab_data_[i].ideal_bounds); 553 tab_data_[i].tab->SetBoundsRect(tab_data_[i].ideal_bounds);
561 554
562 SchedulePaint(); 555 SchedulePaint();
563 } 556 }
564 557
565 BaseTab* BaseTabStrip::GetTabAtLocal( 558 bool BaseTabStrip::IsAnimating() const {
566 const gfx::Point& local_point) { 559 return bounds_animator_.IsAnimating();
560 }
561
562 BaseTab* BaseTabStrip::GetTabAtLocal(const gfx::Point& local_point) {
567 views::View* view = GetEventHandlerForPoint(local_point); 563 views::View* view = GetEventHandlerForPoint(local_point);
568 if (!view) 564 if (!view)
569 return NULL; // No tab contains the point. 565 return NULL; // No tab contains the point.
570 566
571 // Walk up the view hierarchy until we find a tab, or the TabStrip. 567 // Walk up the view hierarchy until we find a tab, or the TabStrip.
572 while (view && view != this && view->GetID() != VIEW_ID_TAB) 568 while (view && view != this && view->GetID() != VIEW_ID_TAB)
573 view = view->parent(); 569 view = view->parent();
574 570
575 return view && view->GetID() == VIEW_ID_TAB ? 571 return view && view->GetID() == VIEW_ID_TAB ?
576 static_cast<BaseTab*>(view) : NULL; 572 static_cast<BaseTab*>(view) : NULL;
(...skipping 13 matching lines...) Expand all
590 // Animate the view back to its correct position. 586 // Animate the view back to its correct position.
591 GenerateIdealBounds(); 587 GenerateIdealBounds();
592 AnimateToIdealBounds(); 588 AnimateToIdealBounds();
593 } 589 }
594 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab))); 590 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab)));
595 // Install a delegate to reset the dragging state when done. We have to leave 591 // Install a delegate to reset the dragging state when done. We have to leave
596 // dragging true for the tab otherwise it'll draw beneath the new tab button. 592 // dragging true for the tab otherwise it'll draw beneath the new tab button.
597 bounds_animator_.SetAnimationDelegate( 593 bounds_animator_.SetAnimationDelegate(
598 tab, new ResetDraggingStateDelegate(tab), true); 594 tab, new ResetDraggingStateDelegate(tab), true);
599 } 595 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/base_tab_strip.h ('k') | chrome/browser/ui/views/tabs/side_tab_strip.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698