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

Side by Side Diff: views/controls/menu/menu_scroll_view_container.cc

Issue 8122013: Allow CanvasSkia to bind to an existing SkCanvas. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: 1 more fix Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/menu/menu_scroll_view_container.h" 5 #include "views/controls/menu/menu_scroll_view_container.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <uxtheme.h> 9 #include <uxtheme.h>
10 #include <Vssym32.h> 10 #include <Vssym32.h>
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 80
81 virtual void OnPaint(gfx::Canvas* canvas) { 81 virtual void OnPaint(gfx::Canvas* canvas) {
82 const MenuConfig& config = MenuConfig::instance(); 82 const MenuConfig& config = MenuConfig::instance();
83 83
84 #if defined(OS_WIN) 84 #if defined(OS_WIN)
85 // The background. 85 // The background.
86 gfx::Rect item_bounds(0, 0, width(), height()); 86 gfx::Rect item_bounds(0, 0, width(), height());
87 NativeTheme::ExtraParams extra; 87 NativeTheme::ExtraParams extra;
88 extra.menu_item.is_selected = false; 88 extra.menu_item.is_selected = false;
89 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 89 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
90 NativeTheme::kMenuItemBackground, 90 NativeTheme::kMenuItemBackground,
91 NativeTheme::kNormal, item_bounds, extra); 91 NativeTheme::kNormal, item_bounds, extra);
92 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT); 92 SkColor arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT);
93 #else 93 #else
94 SkColor arrow_color = SK_ColorBLACK; 94 SkColor arrow_color = SK_ColorBLACK;
95 #endif 95 #endif
96 96
97 // Then the arrow. 97 // Then the arrow.
98 int x = width() / 2; 98 int x = width() / 2;
99 int y = (height() - config.scroll_arrow_height) / 2; 99 int y = (height() - config.scroll_arrow_height) / 2;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) { 179 void MenuScrollViewContainer::OnPaintBackground(gfx::Canvas* canvas) {
180 if (background()) { 180 if (background()) {
181 View::OnPaintBackground(canvas); 181 View::OnPaintBackground(canvas);
182 return; 182 return;
183 } 183 }
184 184
185 #if defined(OS_WIN) 185 #if defined(OS_WIN)
186 HDC dc = canvas->BeginPlatformPaint(); 186 HDC dc = canvas->BeginPlatformPaint();
187 gfx::Rect bounds(0, 0, width(), height()); 187 gfx::Rect bounds(0, 0, width(), height());
188 NativeTheme::ExtraParams extra; 188 NativeTheme::ExtraParams extra;
189 NativeTheme::instance()->Paint(canvas->AsCanvasSkia(), 189 NativeTheme::instance()->Paint(canvas->GetSkCanvas(),
190 NativeTheme::kMenuPopupBackground, NativeTheme::kNormal, bounds, extra); 190 NativeTheme::kMenuPopupBackground, NativeTheme::kNormal, bounds, extra);
191 canvas->EndPlatformPaint(); 191 canvas->EndPlatformPaint();
192 #elif defined(OS_CHROMEOS) 192 #elif defined(OS_CHROMEOS)
193 static const SkColor kGradientColors[2] = { 193 static const SkColor kGradientColors[2] = {
194 SK_ColorWHITE, 194 SK_ColorWHITE,
195 SkColorSetRGB(0xF0, 0xF0, 0xF0) 195 SkColorSetRGB(0xF0, 0xF0, 0xF0)
196 }; 196 };
197 197
198 static const SkScalar kGradientPoints[2] = { 198 static const SkScalar kGradientPoints[2] = {
199 SkIntToScalar(0), 199 SkIntToScalar(0),
(...skipping 12 matching lines...) Expand all
212 SkPaint paint; 212 SkPaint paint;
213 paint.setShader(shader); 213 paint.setShader(shader);
214 shader->unref(); 214 shader->unref();
215 215
216 paint.setStyle(SkPaint::kFill_Style); 216 paint.setStyle(SkPaint::kFill_Style);
217 paint.setXfermodeMode(SkXfermode::kSrc_Mode); 217 paint.setXfermodeMode(SkXfermode::kSrc_Mode);
218 218
219 canvas->DrawRectInt(0, 0, width(), height(), paint); 219 canvas->DrawRectInt(0, 0, width(), height(), paint);
220 #else 220 #else
221 // This is the same as COLOR_TOOLBAR. 221 // This is the same as COLOR_TOOLBAR.
222 canvas->AsCanvasSkia()->drawColor(SkColorSetRGB(210, 225, 246), 222 canvas->GetSkCanvas()->drawColor(SkColorSetRGB(210, 225, 246),
223 SkXfermode::kSrc_Mode); 223 SkXfermode::kSrc_Mode);
224 #endif 224 #endif
225 } 225 }
226 226
227 void MenuScrollViewContainer::Layout() { 227 void MenuScrollViewContainer::Layout() {
228 gfx::Insets insets = GetInsets(); 228 gfx::Insets insets = GetInsets();
229 int x = insets.left(); 229 int x = insets.left();
230 int y = insets.top(); 230 int y = insets.top();
231 int width = View::width() - insets.width(); 231 int width = View::width() - insets.width();
232 int content_height = height() - insets.height(); 232 int content_height = height() - insets.height();
233 if (!scroll_up_button_->IsVisible()) { 233 if (!scroll_up_button_->IsVisible()) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 void MenuScrollViewContainer::OnBoundsChanged( 273 void MenuScrollViewContainer::OnBoundsChanged(
274 const gfx::Rect& previous_bounds) { 274 const gfx::Rect& previous_bounds) {
275 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize(); 275 gfx::Size content_pref = scroll_view_->GetContents()->GetPreferredSize();
276 scroll_up_button_->SetVisible(content_pref.height() > height()); 276 scroll_up_button_->SetVisible(content_pref.height() > height());
277 scroll_down_button_->SetVisible(content_pref.height() > height()); 277 scroll_down_button_->SetVisible(content_pref.height() > height());
278 Layout(); 278 Layout();
279 } 279 }
280 280
281 } // namespace views 281 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698