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

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

Issue 10910005: Makes the tabstrip center the active tab when transitioning from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/touch_tab_strip_layout.h" 5 #include "chrome/browser/ui/views/tabs/touch_tab_strip_layout.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 bool TouchTabStripLayout::IsStacked(int index) const { 158 bool TouchTabStripLayout::IsStacked(int index) const {
159 if (index == active_index() || tab_count() == mini_tab_count_ || 159 if (index == active_index() || tab_count() == mini_tab_count_ ||
160 index < mini_tab_count_) 160 index < mini_tab_count_)
161 return false; 161 return false;
162 if (index > active_index()) 162 if (index > active_index())
163 return ideal_x(index) != ideal_x(index - 1) + tab_offset(); 163 return ideal_x(index) != ideal_x(index - 1) + tab_offset();
164 return ideal_x(index + 1) != ideal_x(index) + tab_offset(); 164 return ideal_x(index + 1) != ideal_x(index) + tab_offset();
165 } 165 }
166 166
167 void TouchTabStripLayout::SetActiveTabLocation(int x) {
168 if (!requires_stacking())
169 return;
170
171 const int index = active_index();
172 if (index <= mini_tab_count_)
173 return;
174
175 x = std::min(GetMaxX(index), std::max(x, GetMinX(index)));
176 if (x == ideal_x(index))
177 return;
178
179 SetIdealBoundsAt(index, x);
180 LayoutByTabOffsetBefore(index);
181 LayoutByTabOffsetAfter(index);
182 }
183
167 #if !defined(NDEBUG) 184 #if !defined(NDEBUG)
168 std::string TouchTabStripLayout::BoundsString() const { 185 std::string TouchTabStripLayout::BoundsString() const {
169 std::string result; 186 std::string result;
170 for (int i = 0; i < view_model_->view_size(); ++i) { 187 for (int i = 0; i < view_model_->view_size(); ++i) {
171 if (!result.empty()) 188 if (!result.empty())
172 result += " "; 189 result += " ";
173 if (i == active_index()) 190 if (i == active_index())
174 result += "["; 191 result += "[";
175 result += base::IntToString(view_model_->ideal_bounds(i).x()); 192 result += base::IntToString(view_model_->ideal_bounds(i).x());
176 if (i == active_index()) 193 if (i == active_index())
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 } 451 }
435 452
436 int TouchTabStripLayout::GetMinXCompressed(int index) const { 453 int TouchTabStripLayout::GetMinXCompressed(int index) const {
437 DCHECK_GT(index, active_index()); 454 DCHECK_GT(index, active_index());
438 return std::max( 455 return std::max(
439 width_ - width_for_count(tab_count() - index), 456 width_ - width_for_count(tab_count() - index),
440 ideal_x(active_index()) + 457 ideal_x(active_index()) +
441 stacked_padding_for_count(index - active_index())); 458 stacked_padding_for_count(index - active_index()));
442 459
443 } 460 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/touch_tab_strip_layout.h ('k') | chrome/browser/ui/views/tabs/touch_tab_strip_layout_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698