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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 // If the active tab is being dragged, it goes last. | 1305 // If the active tab is being dragged, it goes last. |
1306 if (active_tab && is_dragging) | 1306 if (active_tab && is_dragging) |
1307 active_tab->Paint(canvas, cull_set); | 1307 active_tab->Paint(canvas, cull_set); |
1308 } | 1308 } |
1309 | 1309 |
1310 const char* TabStrip::GetClassName() const { | 1310 const char* TabStrip::GetClassName() const { |
1311 return kViewClassName; | 1311 return kViewClassName; |
1312 } | 1312 } |
1313 | 1313 |
1314 gfx::Size TabStrip::GetPreferredSize() const { | 1314 gfx::Size TabStrip::GetPreferredSize() const { |
1315 // For stacked tabs the minimum size is calculated as the size needed to | 1315 int needed_tab_width; |
1316 // handle showing any number of tabs. Otherwise report the minimum width as | 1316 if (touch_layout_ || adjust_layout_) { |
1317 // the size required for a single selected tab plus the new tab button. Don't | 1317 // For stacked tabs the minimum size is calculated as the size needed to |
1318 // base it on the actual number of tabs because it's undesirable to have the | 1318 // handle showing any number of tabs. |
1319 // minimum window size change when a new tab is opened. | 1319 needed_tab_width = |
1320 const int needed_tab_width = (touch_layout_ || adjust_layout_) ? | 1320 Tab::GetTouchWidth() + (2 * kStackedPadding * kMaxStackedCount); |
1321 (Tab::GetTouchWidth() + (2 * kStackedPadding * kMaxStackedCount)) : | 1321 } else { |
1322 Tab::GetMinimumSelectedSize().width(); | 1322 // Otherwise the minimum width is based on the actual number of tabs. |
1323 return gfx::Size(needed_tab_width + new_tab_button_width(), immersive_style_ ? | 1323 const int mini_tab_count = GetMiniTabCount(); |
1324 Tab::GetImmersiveHeight() : Tab::GetMinimumUnselectedSize().height()); | 1324 needed_tab_width = mini_tab_count * Tab::GetMiniWidth(); |
| 1325 const int remaining_tab_count = tab_count() - mini_tab_count; |
| 1326 const int min_selected_width = Tab::GetMinimumSelectedSize().width(); |
| 1327 const int min_unselected_width = Tab::GetMinimumUnselectedSize().width(); |
| 1328 if (remaining_tab_count > 0) { |
| 1329 needed_tab_width += kMiniToNonMiniGap + min_selected_width + |
| 1330 ((remaining_tab_count - 1) * min_unselected_width); |
| 1331 } |
| 1332 if (tab_count() > 1) |
| 1333 needed_tab_width += (tab_count() - 1) * kTabHorizontalOffset; |
| 1334 |
| 1335 // Don't let the tabstrip shrink smaller than is necessary to show one tab, |
| 1336 // and don't force it to be larger than is necessary to show 20 tabs. |
| 1337 const int largest_min_tab_width = |
| 1338 min_selected_width + 19 * (min_unselected_width + kTabHorizontalOffset); |
| 1339 needed_tab_width = std::min( |
| 1340 std::max(needed_tab_width, min_selected_width), largest_min_tab_width); |
| 1341 } |
| 1342 return gfx::Size( |
| 1343 needed_tab_width + new_tab_button_width(), |
| 1344 immersive_style_ ? |
| 1345 Tab::GetImmersiveHeight() : Tab::GetMinimumUnselectedSize().height()); |
1325 } | 1346 } |
1326 | 1347 |
1327 void TabStrip::OnDragEntered(const DropTargetEvent& event) { | 1348 void TabStrip::OnDragEntered(const DropTargetEvent& event) { |
1328 // Force animations to stop, otherwise it makes the index calculation tricky. | 1349 // Force animations to stop, otherwise it makes the index calculation tricky. |
1329 StopAnimating(true); | 1350 StopAnimating(true); |
1330 | 1351 |
1331 UpdateDropIndex(event); | 1352 UpdateDropIndex(event); |
1332 | 1353 |
1333 GURL url; | 1354 GURL url; |
1334 base::string16 title; | 1355 base::string16 title; |
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2691 action = TouchUMA::GESTURE_TABSWITCH_TAP; | 2712 action = TouchUMA::GESTURE_TABSWITCH_TAP; |
2692 TouchUMA::RecordGestureAction(action); | 2713 TouchUMA::RecordGestureAction(action); |
2693 break; | 2714 break; |
2694 } | 2715 } |
2695 | 2716 |
2696 default: | 2717 default: |
2697 break; | 2718 break; |
2698 } | 2719 } |
2699 event->SetHandled(); | 2720 event->SetHandled(); |
2700 } | 2721 } |
OLD | NEW |