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

Side by Side Diff: ui/views/controls/tabbed_pane/native_tabbed_pane_views.cc

Issue 10823229: (Views only) Add a gradient background to the tabstrip of the view tabbed pane implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unnecessary curly braces Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/background.cc ('k') | ui/views/painter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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
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 // The gradient colors are derived from the tabbed panes used for the
129 // WebUI.
130 SkColor colors[] = {
131 SkColorSetRGB(0xff, 0xff, 0xff),
132 SkColorSetRGB(0xff, 0xff, 0xff),
133 SkColorSetRGB(0xfa, 0xfa, 0xfa),
134 SkColorSetRGB(0xf2, 0xf2, 0xf2)
135 };
136 // The relative positions of the gradient colors are derived from the
137 // tabbed panes used for the WebUI.
138 SkScalar pos[4] = {0.0f, 0.6f, 0.8f, 1.0f};
139 set_background(Background::CreateVerticalMultiColorGradientBackground(
140 colors, pos, kCount));
127 } 141 }
128 virtual ~TabStrip() {} 142 virtual ~TabStrip() {}
129 143
130 void SelectTab(View* tab) { 144 void SelectTab(View* tab) {
131 if (tab == selected_tab_) 145 if (tab == selected_tab_)
132 return; 146 return;
133 if (selected_tab_) 147 if (selected_tab_)
134 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(false); 148 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(false);
135 selected_tab_ = tab; 149 selected_tab_ = tab;
136 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(true); 150 static_cast<Tab*>(selected_tab_)->OnSelectedStateChanged(true);
(...skipping 23 matching lines...) Expand all
160 virtual void Layout() OVERRIDE { 174 virtual void Layout() OVERRIDE {
161 const int kTabOffset = 18; 175 const int kTabOffset = 18;
162 int x = kTabOffset; // Layout tabs with an offset to the tabstrip border. 176 int x = kTabOffset; // Layout tabs with an offset to the tabstrip border.
163 for (int i = 0; i < child_count(); ++i) { 177 for (int i = 0; i < child_count(); ++i) {
164 gfx::Size ps = child_at(i)->GetPreferredSize(); 178 gfx::Size ps = child_at(i)->GetPreferredSize();
165 child_at(i)->SetBounds(x, 0, ps.width(), ps.height()); 179 child_at(i)->SetBounds(x, 0, ps.width(), ps.height());
166 x = child_at(i)->bounds().right(); 180 x = child_at(i)->bounds().right();
167 } 181 }
168 } 182 }
169 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 183 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
184 OnPaintBackground(canvas);
185
186 // Draw the TabStrip border.
170 SkPaint paint; 187 SkPaint paint;
171 paint.setColor(kTabBorderColor); 188 paint.setColor(kTabBorderColor);
172 paint.setStrokeWidth(kTabBorderThickness); 189 paint.setStrokeWidth(kTabBorderThickness);
173 SkScalar line_y = SkIntToScalar(height()) - kTabBorderThickness; 190 SkScalar line_y = SkIntToScalar(height()) - kTabBorderThickness;
174 SkScalar line_width = SkIntToScalar(width()); 191 SkScalar line_width = SkIntToScalar(width());
175 canvas->sk_canvas()->drawLine(0, line_y, line_width, line_y, paint); 192 canvas->sk_canvas()->drawLine(0, line_y, line_width, line_y, paint);
176 } 193 }
177 194
178 private: 195 private:
179 NativeTabbedPaneViews* owner_; 196 NativeTabbedPaneViews* owner_;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 if (tab_strip_->has_children()) 419 if (tab_strip_->has_children())
403 InitializeTabs(); 420 InitializeTabs();
404 } 421 }
405 422
406 void NativeTabbedPaneViews::InitializeTabs() { 423 void NativeTabbedPaneViews::InitializeTabs() {
407 for (int i = 0; i < tab_strip_->child_count(); ++i) 424 for (int i = 0; i < tab_strip_->child_count(); ++i)
408 content_view_->AddChildView(Tab::GetContents(tab_strip_->child_at(i))); 425 content_view_->AddChildView(Tab::GetContents(tab_strip_->child_at(i)));
409 } 426 }
410 427
411 } // namespace views 428 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/background.cc ('k') | ui/views/painter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698