Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gfx/native_theme_linux.h" | 5 #include "ui/gfx/native_theme_linux.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "grit/gfx_resources.h" | 10 #include "grit/gfx_resources.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 SkColor light_color(BrightenColor(base_hsl, SkColorGetA(base_color), 0.105)); | 468 SkColor light_color(BrightenColor(base_hsl, SkColorGetA(base_color), 0.105)); |
| 469 | 469 |
| 470 // If the button is too small, fallback to drawing a single, solid color | 470 // If the button is too small, fallback to drawing a single, solid color |
| 471 if (rect.width() < 5 || rect.height() < 5) { | 471 if (rect.width() < 5 || rect.height() < 5) { |
| 472 paint.setColor(base_color); | 472 paint.setColor(base_color); |
| 473 skrect.set(rect.x(), rect.y(), kRight, kBottom); | 473 skrect.set(rect.x(), rect.y(), kRight, kBottom); |
| 474 canvas->drawRect(skrect, paint); | 474 canvas->drawRect(skrect, paint); |
| 475 return; | 475 return; |
| 476 } | 476 } |
| 477 | 477 |
| 478 const int kBorderAlpha = state == kHovered ? 0x80 : 0x55; | 478 if (button.has_border) { |
| 479 paint.setARGB(kBorderAlpha, 0, 0, 0); | 479 const int kBorderAlpha = state == kHovered ? 0x80 : 0x55; |
| 480 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); | 480 paint.setARGB(kBorderAlpha, 0, 0, 0); |
| 481 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); | 481 canvas->drawLine(rect.x() + 1, rect.y(), kRight - 1, rect.y(), paint); |
| 482 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); | 482 canvas->drawLine(kRight - 1, rect.y() + 1, kRight - 1, kBottom - 1, paint); |
| 483 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); | 483 canvas->drawLine(rect.x() + 1, kBottom - 1, kRight - 1, kBottom - 1, paint); |
| 484 canvas->drawLine(rect.x(), rect.y() + 1, rect.x(), kBottom - 1, paint); | |
| 485 } | |
| 484 | 486 |
| 485 paint.setColor(SK_ColorBLACK); | 487 paint.setColor(SK_ColorBLACK); |
| 486 const int kLightEnd = state == kPressed ? 1 : 0; | 488 const int kLightEnd = state == kPressed ? 1 : 0; |
| 487 const int kDarkEnd = !kLightEnd; | 489 const int kDarkEnd = !kLightEnd; |
| 488 SkPoint gradient_bounds[2]; | 490 SkPoint gradient_bounds[2]; |
| 489 gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()), | 491 gradient_bounds[kLightEnd].set(SkIntToScalar(rect.x()), |
| 490 SkIntToScalar(rect.y())); | 492 SkIntToScalar(rect.y())); |
| 491 gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()), | 493 gradient_bounds[kDarkEnd].set(SkIntToScalar(rect.x()), |
| 492 SkIntToScalar(kBottom - 1)); | 494 SkIntToScalar(kBottom - 1)); |
| 493 SkColor colors[2]; | 495 SkColor colors[2]; |
| 494 colors[0] = light_color; | 496 colors[0] = light_color; |
| 495 colors[1] = base_color; | 497 colors[1] = base_color; |
| 496 | 498 |
| 497 SkShader* shader = SkGradientShader::CreateLinear( | 499 SkShader* shader = SkGradientShader::CreateLinear( |
| 498 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); | 500 gradient_bounds, colors, NULL, 2, SkShader::kClamp_TileMode, NULL); |
| 499 paint.setStyle(SkPaint::kFill_Style); | 501 paint.setStyle(SkPaint::kFill_Style); |
| 500 paint.setShader(shader); | 502 paint.setShader(shader); |
| 501 shader->unref(); | 503 shader->unref(); |
| 502 | 504 |
| 503 skrect.set(rect.x() + 1, rect.y() + 1, kRight - 1, kBottom - 1); | 505 skrect.set(rect.x() + 1, rect.y() + 1, kRight - 1, kBottom - 1); |
|
xiyuan
2011/02/11 01:06:21
Should you set proper size for no border case so t
| |
| 504 canvas->drawRect(skrect, paint); | 506 canvas->drawRect(skrect, paint); |
| 505 | 507 |
| 506 paint.setShader(NULL); | 508 paint.setShader(NULL); |
| 507 paint.setColor(BrightenColor(base_hsl, SkColorGetA(base_color), -0.0588)); | 509 paint.setColor(BrightenColor(base_hsl, SkColorGetA(base_color), -0.0588)); |
| 508 canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint); | 510 canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint); |
| 509 canvas->drawPoint(kRight - 2, rect.y() + 1, paint); | 511 canvas->drawPoint(kRight - 2, rect.y() + 1, paint); |
| 510 canvas->drawPoint(rect.x() + 1, kBottom - 2, paint); | 512 canvas->drawPoint(rect.x() + 1, kBottom - 2, paint); |
| 511 canvas->drawPoint(kRight - 2, kBottom - 2, paint); | 513 canvas->drawPoint(kRight - 2, kBottom - 2, paint); |
| 512 } | 514 } |
| 513 | 515 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 600 canvas->drawPath(path, light_paint); | 602 canvas->drawPath(path, light_paint); |
| 601 } | 603 } |
| 602 } | 604 } |
| 603 | 605 |
| 604 void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas, | 606 void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas, |
| 605 State state, | 607 State state, |
| 606 const gfx::Rect& rect, | 608 const gfx::Rect& rect, |
| 607 const MenuListExtraParams& menu_list) { | 609 const MenuListExtraParams& menu_list) { |
| 608 ButtonExtraParams button = { 0 }; | 610 ButtonExtraParams button = { 0 }; |
| 609 button.background_color = menu_list.background_color; | 611 button.background_color = menu_list.background_color; |
| 612 button.has_border = menu_list.has_border; | |
| 610 PaintButton(canvas, state, rect, button); | 613 PaintButton(canvas, state, rect, button); |
| 611 | 614 |
| 612 SkPaint paint; | 615 SkPaint paint; |
| 613 paint.setColor(SK_ColorBLACK); | 616 paint.setColor(SK_ColorBLACK); |
| 614 paint.setAntiAlias(true); | 617 paint.setAntiAlias(true); |
| 615 paint.setStyle(SkPaint::kFill_Style); | 618 paint.setStyle(SkPaint::kFill_Style); |
| 616 | 619 |
| 617 SkPath path; | 620 SkPath path; |
| 618 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); | 621 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); |
| 619 path.rLineTo(6, 0); | 622 path.rLineTo(6, 0); |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 932 | 935 |
| 933 void NativeThemeLinux::SetScrollbarColors(unsigned inactive_color, | 936 void NativeThemeLinux::SetScrollbarColors(unsigned inactive_color, |
| 934 unsigned active_color, | 937 unsigned active_color, |
| 935 unsigned track_color) const { | 938 unsigned track_color) const { |
| 936 thumb_inactive_color_ = inactive_color; | 939 thumb_inactive_color_ = inactive_color; |
| 937 thumb_active_color_ = active_color; | 940 thumb_active_color_ = active_color; |
| 938 track_color_ = track_color; | 941 track_color_ = track_color; |
| 939 } | 942 } |
| 940 | 943 |
| 941 } // namespace gfx | 944 } // namespace gfx |
| OLD | NEW |