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/stacked_tab_strip_layout.h" | 5 #include "chrome/browser/ui/views/tabs/stacked_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/metrics/user_metrics.h" |
10 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
11 #include "content/public/browser/user_metrics.h" | |
12 | 12 |
13 using base::UserMetricsAction; | 13 using base::UserMetricsAction; |
14 | 14 |
15 StackedTabStripLayout::StackedTabStripLayout(const gfx::Size& size, | 15 StackedTabStripLayout::StackedTabStripLayout(const gfx::Size& size, |
16 int overlap, | 16 int overlap, |
17 int stacked_padding, | 17 int stacked_padding, |
18 int max_stacked_count, | 18 int max_stacked_count, |
19 views::ViewModelBase* view_model) | 19 views::ViewModelBase* view_model) |
20 : size_(size), | 20 : size_(size), |
21 overlap_(overlap), | 21 overlap_(overlap), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 SetIdealBoundsAt(active_index(), ConstrainActiveX(ideal_x(active_index()))); | 71 SetIdealBoundsAt(active_index(), ConstrainActiveX(ideal_x(active_index()))); |
72 LayoutByTabOffsetBefore(active_index()); | 72 LayoutByTabOffsetBefore(active_index()); |
73 LayoutByTabOffsetAfter(active_index()); | 73 LayoutByTabOffsetAfter(active_index()); |
74 AdjustStackedTabs(); | 74 AdjustStackedTabs(); |
75 } | 75 } |
76 | 76 |
77 void StackedTabStripLayout::DragActiveTab(int delta) { | 77 void StackedTabStripLayout::DragActiveTab(int delta) { |
78 if (delta == 0 || !requires_stacking()) | 78 if (delta == 0 || !requires_stacking()) |
79 return; | 79 return; |
80 | 80 |
81 content::RecordAction(UserMetricsAction("StackedTab_DragActiveTab")); | 81 base::RecordAction(UserMetricsAction("StackedTab_DragActiveTab")); |
82 int initial_x = ideal_x(active_index()); | 82 int initial_x = ideal_x(active_index()); |
83 // If we're at a particular edge and start dragging, expose all the tabs after | 83 // If we're at a particular edge and start dragging, expose all the tabs after |
84 // the tab (or before when dragging to the left). | 84 // the tab (or before when dragging to the left). |
85 if (delta > 0 && initial_x == GetMinX(active_index())) { | 85 if (delta > 0 && initial_x == GetMinX(active_index())) { |
86 LayoutByTabOffsetAfter(active_index()); | 86 LayoutByTabOffsetAfter(active_index()); |
87 AdjustStackedTabs(); | 87 AdjustStackedTabs(); |
88 } else if (delta < 0 && initial_x == GetMaxX(active_index())) { | 88 } else if (delta < 0 && initial_x == GetMaxX(active_index())) { |
89 LayoutByTabOffsetBefore(active_index()); | 89 LayoutByTabOffsetBefore(active_index()); |
90 ResetToIdealState(); | 90 ResetToIdealState(); |
91 } | 91 } |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 return width_ - trailing_offset - size_.width(); | 565 return width_ - trailing_offset - size_.width(); |
566 } | 566 } |
567 | 567 |
568 int StackedTabStripLayout::GetMinXCompressed(int index) const { | 568 int StackedTabStripLayout::GetMinXCompressed(int index) const { |
569 DCHECK_GT(index, active_index()); | 569 DCHECK_GT(index, active_index()); |
570 return std::max( | 570 return std::max( |
571 width_ - width_for_count(tab_count() - index), | 571 width_ - width_for_count(tab_count() - index), |
572 ideal_x(active_index()) + | 572 ideal_x(active_index()) + |
573 stacked_padding_for_count(index - active_index())); | 573 stacked_padding_for_count(index - active_index())); |
574 } | 574 } |
OLD | NEW |