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 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1226 // If the active tab is being dragged, it goes last. | 1226 // If the active tab is being dragged, it goes last. |
1227 if (active_tab && is_dragging) | 1227 if (active_tab && is_dragging) |
1228 active_tab->Paint(canvas); | 1228 active_tab->Paint(canvas); |
1229 } | 1229 } |
1230 | 1230 |
1231 std::string TabStrip::GetClassName() const { | 1231 std::string TabStrip::GetClassName() const { |
1232 return kViewClassName; | 1232 return kViewClassName; |
1233 } | 1233 } |
1234 | 1234 |
1235 gfx::Size TabStrip::GetPreferredSize() { | 1235 gfx::Size TabStrip::GetPreferredSize() { |
1236 // Report the minimum width as the size required for a single selected tab | 1236 // For stacked tabs the minimum size is calculated as the size needed to |
1237 // plus the new tab button. Don't base it on the actual number of tabs because | 1237 // handle showing any number of tabs. Otherwise report the minimum width as |
1238 // it's undesirable to have the minimum window size change when a new tab is | 1238 // the size required for a single selected tab plus the new tab button. Don't |
1239 // opened. | 1239 // base it on the actual number of tabs because it's undesirable to have the |
1240 int needed_width = Tab::GetMinimumSelectedSize().width() - | 1240 // minimum window size change when a new tab is opened. |
1241 tab_h_offset() + new_tab_button_width(); | 1241 int needed_width; |
| 1242 if (touch_layout_.get() || adjust_layout_) { |
| 1243 needed_width = Tab::GetTouchWidth() + |
| 1244 (2 * kStackedPadding * kMaxStackedCount); |
| 1245 } else { |
| 1246 needed_width = Tab::GetMinimumSelectedSize().width(); |
| 1247 } |
| 1248 needed_width += new_tab_button_width(); |
1242 return gfx::Size(needed_width, Tab::GetMinimumUnselectedSize().height()); | 1249 return gfx::Size(needed_width, Tab::GetMinimumUnselectedSize().height()); |
1243 } | 1250 } |
1244 | 1251 |
1245 void TabStrip::OnDragEntered(const DropTargetEvent& event) { | 1252 void TabStrip::OnDragEntered(const DropTargetEvent& event) { |
1246 // Force animations to stop, otherwise it makes the index calculation tricky. | 1253 // Force animations to stop, otherwise it makes the index calculation tricky. |
1247 StopAnimating(true); | 1254 StopAnimating(true); |
1248 | 1255 |
1249 UpdateDropIndex(event); | 1256 UpdateDropIndex(event); |
1250 } | 1257 } |
1251 | 1258 |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2334 GenerateIdealBounds(); | 2341 GenerateIdealBounds(); |
2335 AnimateToIdealBounds(); | 2342 AnimateToIdealBounds(); |
2336 } | 2343 } |
2337 | 2344 |
2338 bool TabStrip::NeedsTouchLayout() const { | 2345 bool TabStrip::NeedsTouchLayout() const { |
2339 if (layout_type_ == TAB_STRIP_LAYOUT_SHRINK) | 2346 if (layout_type_ == TAB_STRIP_LAYOUT_SHRINK) |
2340 return false; | 2347 return false; |
2341 | 2348 |
2342 int mini_tab_count = GetMiniTabCount(); | 2349 int mini_tab_count = GetMiniTabCount(); |
2343 int normal_count = tab_count() - mini_tab_count; | 2350 int normal_count = tab_count() - mini_tab_count; |
2344 if (normal_count == 0 || normal_count == mini_tab_count) | 2351 if (normal_count <= 1 || normal_count == mini_tab_count) |
2345 return false; | 2352 return false; |
2346 int x = GetStartXForNormalTabs(); | 2353 int x = GetStartXForNormalTabs(); |
2347 int available_width = width() - x - new_tab_button_width(); | 2354 int available_width = width() - x - new_tab_button_width(); |
2348 return (Tab::GetTouchWidth() * normal_count + | 2355 return (Tab::GetTouchWidth() * normal_count + |
2349 tab_h_offset() * (normal_count - 1)) > available_width; | 2356 tab_h_offset() * (normal_count - 1)) > available_width; |
2350 } | 2357 } |
OLD | NEW |