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 "ui/views/controls/tabbed_pane/native_tabbed_pane_views.h" | 5 #include "ui/views/controls/tabbed_pane/native_tabbed_pane_views.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/canvas.h" | 10 #include "ui/gfx/canvas.h" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 SkColor title_color_; | 117 SkColor title_color_; |
118 | 118 |
119 DISALLOW_COPY_AND_ASSIGN(Tab); | 119 DISALLOW_COPY_AND_ASSIGN(Tab); |
120 }; | 120 }; |
121 | 121 |
122 class TabStrip : public View { | 122 class TabStrip : public View { |
123 public: | 123 public: |
124 explicit TabStrip(NativeTabbedPaneViews* owner) | 124 explicit TabStrip(NativeTabbedPaneViews* owner) |
125 : owner_(owner), | 125 : owner_(owner), |
126 selected_tab_(NULL) { | 126 selected_tab_(NULL) { |
127 const int kCount = 4; | |
128 SkColor colors[] = { | |
msw
2012/08/08 23:13:53
nit: mention where these values were derived from?
markusheintz_
2012/08/09 01:00:15
Done.
| |
129 SkColorSetRGB(0xff, 0xff, 0xff), | |
130 SkColorSetRGB(0xff, 0xff, 0xff), | |
131 SkColorSetRGB(0xfa, 0xfa, 0xfa), | |
132 SkColorSetRGB(0xf2, 0xf2, 0xf2) | |
133 }; | |
134 | |
135 SkScalar pos[4] = {0.0f, 0.6f, 0.8f, 1.0f}; | |
136 set_background(Background::CreateVerticalMultiColorGradientBackground( | |
137 colors, pos, kCount)); | |
127 } | 138 } |
128 virtual ~TabStrip() {} | 139 virtual ~TabStrip() {} |
129 | 140 |
130 void SelectTab(View* tab) { | 141 void SelectTab(View* tab) { |
131 if (tab == selected_tab_) | 142 if (tab == selected_tab_) |
132 return; | 143 return; |
133 if (selected_tab_) | 144 if (selected_tab_) |
134 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(false); | 145 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(false); |
135 selected_tab_ = tab; | 146 selected_tab_ = tab; |
136 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(true); | 147 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(true); |
(...skipping 23 matching lines...) Expand all Loading... | |
160 virtual void Layout() OVERRIDE { | 171 virtual void Layout() OVERRIDE { |
161 const int kTabOffset = 18; | 172 const int kTabOffset = 18; |
162 int x = kTabOffset; // Layout tabs with an offset to the tabstrip border. | 173 int x = kTabOffset; // Layout tabs with an offset to the tabstrip border. |
163 for (int i = 0; i < child_count(); ++i) { | 174 for (int i = 0; i < child_count(); ++i) { |
164 gfx::Size ps = child_at(i)->GetPreferredSize(); | 175 gfx::Size ps = child_at(i)->GetPreferredSize(); |
165 child_at(i)->SetBounds(x, 0, ps.width(), ps.height()); | 176 child_at(i)->SetBounds(x, 0, ps.width(), ps.height()); |
166 x = child_at(i)->bounds().right(); | 177 x = child_at(i)->bounds().right(); |
167 } | 178 } |
168 } | 179 } |
169 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 180 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
181 OnPaintBackground(canvas); | |
182 // Draw the TabStrip border. | |
msw
2012/08/08 23:13:53
nit: blank line above (separate bg / border).
markusheintz_
2012/08/09 01:00:15
Done.
| |
170 SkPaint paint; | 183 SkPaint paint; |
171 paint.setColor(kTabBorderColor); | 184 paint.setColor(kTabBorderColor); |
172 paint.setStrokeWidth(kTabBorderThickness); | 185 paint.setStrokeWidth(kTabBorderThickness); |
173 SkScalar line_y = SkIntToScalar(height()) - kTabBorderThickness; | 186 SkScalar line_y = SkIntToScalar(height()) - kTabBorderThickness; |
174 SkScalar line_width = SkIntToScalar(width()); | 187 SkScalar line_width = SkIntToScalar(width()); |
175 canvas->sk_canvas()->drawLine(0, line_y, line_width, line_y, paint); | 188 canvas->sk_canvas()->drawLine(0, line_y, line_width, line_y, paint); |
176 } | 189 } |
177 | 190 |
178 private: | 191 private: |
179 NativeTabbedPaneViews* owner_; | 192 NativeTabbedPaneViews* owner_; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 if (tab_strip_->has_children()) | 415 if (tab_strip_->has_children()) |
403 InitializeTabs(); | 416 InitializeTabs(); |
404 } | 417 } |
405 | 418 |
406 void NativeTabbedPaneViews::InitializeTabs() { | 419 void NativeTabbedPaneViews::InitializeTabs() { |
407 for (int i = 0; i < tab_strip_->child_count(); ++i) | 420 for (int i = 0; i < tab_strip_->child_count(); ++i) |
408 content_view_->AddChildView(Tab::GetContents(tab_strip_->child_at(i))); | 421 content_view_->AddChildView(Tab::GetContents(tab_strip_->child_at(i))); |
409 } | 422 } |
410 | 423 |
411 } // namespace views | 424 } // namespace views |
OLD | NEW |