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

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

Issue 7054052: Move more from Window onto Widget. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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/view_ids.h" 8 #include "chrome/browser/ui/view_ids.h"
9 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h" 9 #include "chrome/browser/ui/views/tabs/dragged_tab_controller.h"
10 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h" 10 #include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 BaseTab* tab = CreateTab(); 129 BaseTab* tab = CreateTab();
130 tab->SetData(data); 130 tab->SetData(data);
131 131
132 TabData d = { tab, gfx::Rect() }; 132 TabData d = { tab, gfx::Rect() };
133 tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d); 133 tab_data_.insert(tab_data_.begin() + ModelIndexToTabIndex(model_index), d);
134 134
135 AddChildView(tab); 135 AddChildView(tab);
136 136
137 // Don't animate the first tab, it looks weird, and don't animate anything 137 // Don't animate the first tab, it looks weird, and don't animate anything
138 // if the containing window isn't visible yet. 138 // if the containing window isn't visible yet.
139 if (tab_count() > 1 && GetWindow() && GetWindow()->IsVisible()) 139 if (tab_count() > 1 && GetWidget() && GetWidget()->IsVisible())
140 StartInsertTabAnimation(model_index); 140 StartInsertTabAnimation(model_index);
141 else 141 else
142 DoLayout(); 142 DoLayout();
143 } 143 }
144 144
145 void BaseTabStrip::MoveTab(int from_model_index, int to_model_index) { 145 void BaseTabStrip::MoveTab(int from_model_index, int to_model_index) {
146 int from_tab_data_index = ModelIndexToTabIndex(from_model_index); 146 int from_tab_data_index = ModelIndexToTabIndex(from_model_index);
147 BaseTab* tab = tab_data_[from_tab_data_index].tab; 147 BaseTab* tab = tab_data_[from_tab_data_index].tab;
148 tab_data_.erase(tab_data_.begin() + from_tab_data_index); 148 tab_data_.erase(tab_data_.begin() + from_tab_data_index);
149 149
150 TabData data = {tab, gfx::Rect()}; 150 TabData data = {tab, gfx::Rect()};
151 int to_tab_data_index = ModelIndexToTabIndex(to_model_index); 151 int to_tab_data_index = ModelIndexToTabIndex(to_model_index);
152 tab_data_.insert(tab_data_.begin() + to_tab_data_index, data); 152 tab_data_.insert(tab_data_.begin() + to_tab_data_index, data);
153 153
154 StartMoveTabAnimation(); 154 StartMoveTabAnimation();
155 } 155 }
156 156
157 void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) { 157 void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) {
158 BaseTab* tab = GetBaseTabAtModelIndex(model_index); 158 BaseTab* tab = GetBaseTabAtModelIndex(model_index);
159 bool mini_state_changed = tab->data().mini != data.mini; 159 bool mini_state_changed = tab->data().mini != data.mini;
160 tab->SetData(data); 160 tab->SetData(data);
161 161
162 if (mini_state_changed) { 162 if (mini_state_changed) {
163 if (GetWindow() && GetWindow()->IsVisible()) 163 if (GetWidget() && GetWidget()->IsVisible())
164 StartMiniTabAnimation(); 164 StartMiniTabAnimation();
165 else 165 else
166 DoLayout(); 166 DoLayout();
167 } 167 }
168 } 168 }
169 169
170 BaseTab* BaseTabStrip::GetBaseTabAtModelIndex(int model_index) const { 170 BaseTab* BaseTabStrip::GetBaseTabAtModelIndex(int model_index) const {
171 return base_tab_at_tab_index(ModelIndexToTabIndex(model_index)); 171 return base_tab_at_tab_index(ModelIndexToTabIndex(model_index));
172 } 172 }
173 173
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 // Animate the view back to its correct position. 579 // Animate the view back to its correct position.
580 GenerateIdealBounds(); 580 GenerateIdealBounds();
581 AnimateToIdealBounds(); 581 AnimateToIdealBounds();
582 } 582 }
583 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab))); 583 bounds_animator_.AnimateViewTo(tab, ideal_bounds(TabIndexOfTab(tab)));
584 // Install a delegate to reset the dragging state when done. We have to leave 584 // Install a delegate to reset the dragging state when done. We have to leave
585 // dragging true for the tab otherwise it'll draw beneath the new tab button. 585 // dragging true for the tab otherwise it'll draw beneath the new tab button.
586 bounds_animator_.SetAnimationDelegate( 586 bounds_animator_.SetAnimationDelegate(
587 tab, new ResetDraggingStateDelegate(tab), true); 587 tab, new ResetDraggingStateDelegate(tab), true);
588 } 588 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profile_menu_button.cc ('k') | chrome/browser/ui/views/tabs/dragged_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698