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

Side by Side Diff: ui/native_theme/common_theme.cc

Issue 1797053002: Move theme part drawing functions only used on Windows to NativeThemeWin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile Created 4 years, 9 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
« no previous file with comments | « ui/native_theme/common_theme.h ('k') | ui/native_theme/native_theme_aura.cc » ('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/native_theme/common_theme.h" 5 #include "ui/native_theme/common_theme.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 8 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "ui/base/material_design/material_design_controller.h" 9 #include "ui/base/material_design/material_design_controller.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 430
431 return size; 431 return size;
432 } 432 }
433 433
434 void CommonThemePaintComboboxArrow(SkCanvas* canvas, const gfx::Rect& rect) { 434 void CommonThemePaintComboboxArrow(SkCanvas* canvas, const gfx::Rect& rect) {
435 gfx::ImageSkia* arrow = ui::ResourceBundle::GetSharedInstance(). 435 gfx::ImageSkia* arrow = ui::ResourceBundle::GetSharedInstance().
436 GetImageSkiaNamed(IDR_MENU_DROPARROW); 436 GetImageSkiaNamed(IDR_MENU_DROPARROW);
437 CommonThemeCreateCanvas(canvas)->DrawImageInt(*arrow, rect.x(), rect.y()); 437 CommonThemeCreateCanvas(canvas)->DrawImageInt(*arrow, rect.x(), rect.y());
438 } 438 }
439 439
440 void CommonThemePaintMenuSeparator(SkCanvas* canvas, const gfx::Rect& rect) {
441 SkPaint paint;
442 paint.setColor(
443 GetAuraColor(NativeTheme::kColorId_MenuSeparatorColor, nullptr));
444 int position_y = rect.y() + rect.height() / 2;
445 canvas->drawLine(rect.x(), position_y, rect.right(), position_y, paint);
446 }
447
448 void CommonThemePaintMenuGutter(SkCanvas* canvas, const gfx::Rect& rect) {
449 SkPaint paint;
450 paint.setColor(
451 GetAuraColor(NativeTheme::kColorId_MenuSeparatorColor, nullptr));
452 int position_x = rect.x() + rect.width() / 2;
453 canvas->drawLine(position_x, rect.y(), position_x, rect.bottom(), paint);
454 }
455
456 void CommonThemePaintMenuBackground(SkCanvas* canvas, const gfx::Rect& rect) {
457 SkPaint paint;
458 paint.setColor(
459 GetAuraColor(NativeTheme::kColorId_MenuBackgroundColor, nullptr));
460 canvas->drawRect(gfx::RectToSkRect(rect), paint);
461 }
462
463 void CommonThemePaintMenuItemBackground( 440 void CommonThemePaintMenuItemBackground(
441 const NativeTheme* theme,
464 SkCanvas* canvas, 442 SkCanvas* canvas,
465 NativeTheme::State state, 443 NativeTheme::State state,
466 const gfx::Rect& rect, 444 const gfx::Rect& rect,
467 const NativeTheme::MenuItemExtraParams& menu_item) { 445 const NativeTheme::MenuItemExtraParams& menu_item) {
468 SkPaint paint; 446 SkPaint paint;
469 switch (state) { 447 switch (state) {
470 case NativeTheme::kNormal: 448 case NativeTheme::kNormal:
471 case NativeTheme::kDisabled: 449 case NativeTheme::kDisabled:
472 paint.setColor( 450 paint.setColor(
473 GetAuraColor(NativeTheme::kColorId_MenuBackgroundColor, nullptr)); 451 theme->GetSystemColor(NativeTheme::kColorId_MenuBackgroundColor));
474 break; 452 break;
475 case NativeTheme::kHovered: 453 case NativeTheme::kHovered:
476 paint.setColor(GetAuraColor( 454 paint.setColor(theme->GetSystemColor(
477 NativeTheme::kColorId_FocusedMenuItemBackgroundColor, nullptr)); 455 NativeTheme::kColorId_FocusedMenuItemBackgroundColor));
478 break; 456 break;
479 default: 457 default:
480 NOTREACHED() << "Invalid state " << state; 458 NOTREACHED() << "Invalid state " << state;
481 break; 459 break;
482 } 460 }
483 if (menu_item.corner_radius > 0) { 461 if (menu_item.corner_radius > 0) {
484 const SkScalar radius = SkIntToScalar(menu_item.corner_radius); 462 const SkScalar radius = SkIntToScalar(menu_item.corner_radius);
485 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint); 463 canvas->drawRoundRect(gfx::RectToSkRect(rect), radius, radius, paint);
486 return; 464 return;
487 } 465 }
488 canvas->drawRect(gfx::RectToSkRect(rect), paint); 466 canvas->drawRect(gfx::RectToSkRect(rect), paint);
489 } 467 }
490 468
491 // static 469 // static
492 scoped_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) { 470 scoped_ptr<gfx::Canvas> CommonThemeCreateCanvas(SkCanvas* sk_canvas) {
493 // TODO(pkotwicz): Do something better and don't infer device 471 // TODO(pkotwicz): Do something better and don't infer device
494 // scale factor from canvas scale. 472 // scale factor from canvas scale.
495 SkMatrix m = sk_canvas->getTotalMatrix(); 473 SkMatrix m = sk_canvas->getTotalMatrix();
496 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX())); 474 float device_scale = static_cast<float>(SkScalarAbs(m.getScaleX()));
497 return make_scoped_ptr(new gfx::Canvas(skia::SharePtr(sk_canvas), 475 return make_scoped_ptr(new gfx::Canvas(skia::SharePtr(sk_canvas),
498 device_scale)); 476 device_scale));
499 } 477 }
500 478
501 } // namespace ui 479 } // namespace ui
OLDNEW
« no previous file with comments | « ui/native_theme/common_theme.h ('k') | ui/native_theme/native_theme_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698