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

Side by Side Diff: chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h

Issue 598013003: Added views::ViewModelT<T>, a type-safe template version of ViewModel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@appsgridview-static-casts
Patch Set: Fix browser_test compile on ChromeOS (missing include). Created 6 years, 2 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
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 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_
6 #define CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_ 6 #define CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_
7 7
8 #include <algorithm> 8 #include <algorithm>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "ui/gfx/size.h" 11 #include "ui/gfx/size.h"
12 #include "ui/views/view_model.h" 12 #include "ui/views/view_model.h"
13 13
14 namespace views { 14 class Tab;
15 class ViewModel;
16 }
17 15
18 // StackedTabStripLayout is used by TabStrip in touch 16 // StackedTabStripLayout is used by TabStrip in touch
19 // mode. StackedTabStripLayout is responsible for managing the bounds of the 17 // mode. StackedTabStripLayout is responsible for managing the bounds of the
20 // tabs. StackedTabStripLayout differs from the normal layout in that it stacks 18 // tabs. StackedTabStripLayout differs from the normal layout in that it stacks
21 // tabs. Stacked tabs are tabs placed nearly on top of each other, and if enough 19 // tabs. Stacked tabs are tabs placed nearly on top of each other, and if enough
22 // consecutive stacked tabs exist they are placed on top of each other. Normally 20 // consecutive stacked tabs exist they are placed on top of each other. Normally
23 // stacked tabs are placed after mini-tabs, or at the end of the tabstrip, but 21 // stacked tabs are placed after mini-tabs, or at the end of the tabstrip, but
24 // during dragging tabs may be stacked before or after the active tab. 22 // during dragging tabs may be stacked before or after the active tab.
25 class StackedTabStripLayout { 23 class StackedTabStripLayout {
26 public: 24 public:
27 static const int kAddTypeMini = 1 << 0; 25 static const int kAddTypeMini = 1 << 0;
28 static const int kAddTypeActive = 1 << 1; 26 static const int kAddTypeActive = 1 << 1;
29 27
30 // |size| is the size for tabs, |padding| the padding between consecutive 28 // |size| is the size for tabs, |padding| the padding between consecutive
31 // tabs, |stacked_padding| the padding between stacked tabs, 29 // tabs, |stacked_padding| the padding between stacked tabs,
32 // |max_stacked_count| the maximum number of consecutive tabs that can be 30 // |max_stacked_count| the maximum number of consecutive tabs that can be
33 // stacked before they are placed on top of each other, |view_model| is the 31 // stacked before they are placed on top of each other, |view_model| is the
34 // ViewModel the bounds of the tabs are placed in. 32 // ViewModel the bounds of the tabs are placed in.
35 StackedTabStripLayout(const gfx::Size& size, 33 StackedTabStripLayout(const gfx::Size& size,
36 int padding, 34 int padding,
37 int stacked_padding, 35 int stacked_padding,
38 int max_stacked_count, 36 int max_stacked_count,
39 views::ViewModel* view_model); 37 views::ViewModelBase* view_model);
40 ~StackedTabStripLayout(); 38 ~StackedTabStripLayout();
41 39
42 // Sets the x-coordinate the normal tabs start at as well as the mini-tab 40 // Sets the x-coordinate the normal tabs start at as well as the mini-tab
43 // count. This is only useful if the mini-tab count or x-coordinate change. 41 // count. This is only useful if the mini-tab count or x-coordinate change.
44 void SetXAndMiniCount(int x, int mini_tab_count); 42 void SetXAndMiniCount(int x, int mini_tab_count);
45 43
46 // Sets the width available for sizing the tabs to. 44 // Sets the width available for sizing the tabs to.
47 void SetWidth(int width); 45 void SetWidth(int width);
48 46
49 int width() const { return width_; } 47 int width() const { return width_; }
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // Padding between tabs. 208 // Padding between tabs.
211 const int padding_; 209 const int padding_;
212 210
213 // Padding between stacked tabs. 211 // Padding between stacked tabs.
214 const int stacked_padding_; 212 const int stacked_padding_;
215 213
216 // Max number of stacked tabs. 214 // Max number of stacked tabs.
217 const int max_stacked_count_; 215 const int max_stacked_count_;
218 216
219 // Where bounds are placed. This is owned by TabStrip. 217 // Where bounds are placed. This is owned by TabStrip.
220 views::ViewModel* view_model_; 218 // (Note: This is a ViewModelBase, not a ViewModelT<Tab>, because the tests do
219 // not populate the model with Tab views.)
220 views::ViewModelBase* view_model_;
221 221
222 // x-coordinate normal tabs start at. 222 // x-coordinate normal tabs start at.
223 int x_; 223 int x_;
224 224
225 // Available width. 225 // Available width.
226 int width_; 226 int width_;
227 227
228 // Number of mini-tabs. 228 // Number of mini-tabs.
229 int mini_tab_count_; 229 int mini_tab_count_;
230 230
231 // Distance from the last mini-tab to the first non-mini-tab. 231 // Distance from the last mini-tab to the first non-mini-tab.
232 int mini_tab_to_non_mini_tab_; 232 int mini_tab_to_non_mini_tab_;
233 233
234 // Index of the active tab. 234 // Index of the active tab.
235 int active_index_; 235 int active_index_;
236 236
237 // X-coordinate of the first tab. This is either |x_| if there are no 237 // X-coordinate of the first tab. This is either |x_| if there are no
238 // mini-tabs, or the x-coordinate of the first mini-tab. 238 // mini-tabs, or the x-coordinate of the first mini-tab.
239 int first_tab_x_; 239 int first_tab_x_;
240 240
241 DISALLOW_COPY_AND_ASSIGN(StackedTabStripLayout); 241 DISALLOW_COPY_AND_ASSIGN(StackedTabStripLayout);
242 }; 242 };
243 243
244 #endif // CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_ 244 #endif // CHROME_BROWSER_UI_VIEWS_TABS_STACKED_TAB_STRIP_LAYOUT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698