OLD | NEW |
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/tab_strip.h" | 5 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windowsx.h> | 8 #include <windowsx.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 // so that if they call back we aren't in a weird state. | 611 // so that if they call back we aren't in a weird state. |
612 RemoveAllChildViews(true); | 612 RemoveAllChildViews(true); |
613 } | 613 } |
614 | 614 |
615 void TabStrip::SetLayoutType(TabStripLayoutType layout_type, | 615 void TabStrip::SetLayoutType(TabStripLayoutType layout_type, |
616 bool adjust_layout) { | 616 bool adjust_layout) { |
617 adjust_layout_ = adjust_layout; | 617 adjust_layout_ = adjust_layout; |
618 if (layout_type == layout_type_) | 618 if (layout_type == layout_type_) |
619 return; | 619 return; |
620 | 620 |
| 621 const int active_index = controller_->GetActiveIndex(); |
| 622 int active_center = 0; |
| 623 if (active_index != -1) { |
| 624 active_center = ideal_bounds(active_index).x() + |
| 625 ideal_bounds(active_index).width() / 2; |
| 626 } |
621 layout_type_ = layout_type; | 627 layout_type_ = layout_type; |
622 SetResetToShrinkOnExit(false); | 628 SetResetToShrinkOnExit(false); |
623 SwapLayoutIfNecessary(); | 629 SwapLayoutIfNecessary(); |
| 630 // When transitioning to stacked try to keep the active tab centered. |
| 631 if (touch_layout_.get() && active_index != -1) { |
| 632 touch_layout_->SetActiveTabLocation( |
| 633 active_center - ideal_bounds(active_index).width() / 2); |
| 634 AnimateToIdealBounds(); |
| 635 } |
624 } | 636 } |
625 | 637 |
626 gfx::Rect TabStrip::GetNewTabButtonBounds() { | 638 gfx::Rect TabStrip::GetNewTabButtonBounds() { |
627 return newtab_button_->bounds(); | 639 return newtab_button_->bounds(); |
628 } | 640 } |
629 | 641 |
630 bool TabStrip::SizeTabButtonToTopOfTabStrip() { | 642 bool TabStrip::SizeTabButtonToTopOfTabStrip() { |
631 return browser_defaults::kSizeTabButtonToTopOfTabStrip || | 643 return browser_defaults::kSizeTabButtonToTopOfTabStrip || |
632 (GetWidget() && GetWidget()->IsMaximized()); | 644 (GetWidget() && GetWidget()->IsMaximized()); |
633 } | 645 } |
(...skipping 1787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2421 if (!adjust_layout_) | 2433 if (!adjust_layout_) |
2422 return false; | 2434 return false; |
2423 | 2435 |
2424 #if !defined(OS_CHROMEOS) | 2436 #if !defined(OS_CHROMEOS) |
2425 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) | 2437 if (ui::GetDisplayLayout() != ui::LAYOUT_TOUCH) |
2426 return false; | 2438 return false; |
2427 #endif | 2439 #endif |
2428 | 2440 |
2429 return true; | 2441 return true; |
2430 } | 2442 } |
OLD | NEW |