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 if (button.has_border) { |
| 506 skrect.set(rect.x() + 1, rect.y() + 1, kRight - 1, kBottom - 1); |
| 507 } else { |
| 508 skrect.set(rect.x(), rect.y(), kRight, kBottom); |
| 509 } |
504 canvas->drawRect(skrect, paint); | 510 canvas->drawRect(skrect, paint); |
| 511 paint.setShader(NULL); |
505 | 512 |
506 paint.setShader(NULL); | 513 if (button.has_border) { |
507 paint.setColor(BrightenColor(base_hsl, SkColorGetA(base_color), -0.0588)); | 514 paint.setColor(BrightenColor(base_hsl, SkColorGetA(base_color), -0.0588)); |
508 canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint); | 515 canvas->drawPoint(rect.x() + 1, rect.y() + 1, paint); |
509 canvas->drawPoint(kRight - 2, rect.y() + 1, paint); | 516 canvas->drawPoint(kRight - 2, rect.y() + 1, paint); |
510 canvas->drawPoint(rect.x() + 1, kBottom - 2, paint); | 517 canvas->drawPoint(rect.x() + 1, kBottom - 2, paint); |
511 canvas->drawPoint(kRight - 2, kBottom - 2, paint); | 518 canvas->drawPoint(kRight - 2, kBottom - 2, paint); |
| 519 } |
512 } | 520 } |
513 | 521 |
514 void NativeThemeLinux::PaintTextField(skia::PlatformCanvas* canvas, | 522 void NativeThemeLinux::PaintTextField(skia::PlatformCanvas* canvas, |
515 State state, | 523 State state, |
516 const gfx::Rect& rect, | 524 const gfx::Rect& rect, |
517 const TextFieldExtraParams& text) { | 525 const TextFieldExtraParams& text) { |
518 // The following drawing code simulates the user-agent css border for | 526 // The following drawing code simulates the user-agent css border for |
519 // text area and text input so that we do not break layout tests. Once we | 527 // text area and text input so that we do not break layout tests. Once we |
520 // have decided the desired looks, we should update the code here and | 528 // have decided the desired looks, we should update the code here and |
521 // the layout test expectations. | 529 // the layout test expectations. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 path.lineTo(SkIntToScalar(right), SkIntToScalar(bottom)); | 606 path.lineTo(SkIntToScalar(right), SkIntToScalar(bottom)); |
599 path.lineTo(SkIntToScalar(right), SkIntToScalar(top)); | 607 path.lineTo(SkIntToScalar(right), SkIntToScalar(top)); |
600 canvas->drawPath(path, light_paint); | 608 canvas->drawPath(path, light_paint); |
601 } | 609 } |
602 } | 610 } |
603 | 611 |
604 void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas, | 612 void NativeThemeLinux::PaintMenuList(skia::PlatformCanvas* canvas, |
605 State state, | 613 State state, |
606 const gfx::Rect& rect, | 614 const gfx::Rect& rect, |
607 const MenuListExtraParams& menu_list) { | 615 const MenuListExtraParams& menu_list) { |
608 ButtonExtraParams button = { 0 }; | 616 // If a border radius is specified, we let the WebCore paint the background |
609 button.background_color = menu_list.background_color; | 617 // and the border of the control. |
610 PaintButton(canvas, state, rect, button); | 618 if (!menu_list.has_border_radius) { |
| 619 ButtonExtraParams button = { 0 }; |
| 620 button.background_color = menu_list.background_color; |
| 621 button.has_border = menu_list.has_border; |
| 622 PaintButton(canvas, state, rect, button); |
| 623 } |
611 | 624 |
612 SkPaint paint; | 625 SkPaint paint; |
613 paint.setColor(SK_ColorBLACK); | 626 paint.setColor(SK_ColorBLACK); |
614 paint.setAntiAlias(true); | 627 paint.setAntiAlias(true); |
615 paint.setStyle(SkPaint::kFill_Style); | 628 paint.setStyle(SkPaint::kFill_Style); |
616 | 629 |
617 SkPath path; | 630 SkPath path; |
618 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); | 631 path.moveTo(menu_list.arrow_x, menu_list.arrow_y - 3); |
619 path.rLineTo(6, 0); | 632 path.rLineTo(6, 0); |
620 path.rLineTo(-3, 6); | 633 path.rLineTo(-3, 6); |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 | 945 |
933 void NativeThemeLinux::SetScrollbarColors(unsigned inactive_color, | 946 void NativeThemeLinux::SetScrollbarColors(unsigned inactive_color, |
934 unsigned active_color, | 947 unsigned active_color, |
935 unsigned track_color) const { | 948 unsigned track_color) const { |
936 thumb_inactive_color_ = inactive_color; | 949 thumb_inactive_color_ = inactive_color; |
937 thumb_active_color_ = active_color; | 950 thumb_active_color_ = active_color; |
938 track_color_ = track_color; | 951 track_color_ = track_color; |
939 } | 952 } |
940 | 953 |
941 } // namespace gfx | 954 } // namespace gfx |
OLD | NEW |