Index: ui/native_theme/native_theme_mac.mm |
diff --git a/ui/native_theme/native_theme_mac.mm b/ui/native_theme/native_theme_mac.mm |
index 2477af8ea0b3b20754a2e138685c892134c67f06..e33749ba11079364840ffa0fa7f55c4b1dfe1e3b 100644 |
--- a/ui/native_theme/native_theme_mac.mm |
+++ b/ui/native_theme/native_theme_mac.mm |
@@ -12,10 +12,18 @@ |
#include "base/mac/sdk_forward_declarations.h" |
#include "ui/native_theme/common_theme.h" |
#import "skia/ext/skia_utils_mac.h" |
+#include "ui/gfx/geometry/rect.h" |
#include "ui/gfx/skia_util.h" |
namespace { |
+const SkColor kScrollerTrackColor = SkColorSetRGB(0xF8, 0xF8, 0xF8); |
tapted
2014/08/11 01:00:58
Can we make this a horizontal 3-stage gradient, to
Andre
2014/08/12 21:42:38
Done.
|
+const SkColor kScrollerTrackBorderColor = SkColorSetRGB(0xE4, 0xE4, 0xE4); |
+const SkColor kScrollerThumbColor = SkColorSetRGB(0xC3, 0xC3, 0xC3); |
tapted
2014/08/11 01:00:58
These should have an alpha component, so the track
Andre
2014/08/12 21:42:37
Added alpha component, although the effect is very
|
+const SkColor kScrollerThumbHoverColor = SkColorSetRGB(0x7E, 0x7E, 0x7E); |
+const int kScrollerTrackBorderWidth = 1; |
+const int kScrollerThumbInset = 3; |
+ |
// Values calculated by reading pixels and solving simultaneous equations |
// derived from "A over B" alpha compositing. Steps: Sample the semi-transparent |
// pixel over two backgrounds; P1, P2 over backgrounds B1, B2. Use the color |
@@ -216,7 +224,61 @@ void NativeThemeMac::PaintMenuItemBackground( |
} |
} |
+void NativeThemeMac::PaintScrollbarTrack( |
tapted
2014/08/11 01:00:58
(nit: move up in the .mm file too)
Andre
2014/08/12 21:42:37
Done.
|
+ SkCanvas* canvas, |
+ Part part, |
+ State state, |
+ const ScrollbarTrackExtraParams& extra_params, |
+ const gfx::Rect& rect) const { |
+ SkPaint paint; |
+ paint.setColor(track_color_); |
tapted
2014/08/11 01:00:58
probably something like paint.setShader(SkGradient
Andre
2014/08/12 21:42:38
Done.
|
+ SkIRect track_rect; |
+ track_rect.set(rect.x(), rect.y(), rect.right(), rect.bottom()); |
+ canvas->drawIRect(track_rect, paint); |
+ |
+ // Draw line border next to content area. |
+ paint.setColor(kScrollerTrackBorderColor); |
+ if (part == kScrollbarVerticalTrack) { |
+ canvas->drawRectCoords(track_rect.left(), |
+ track_rect.top(), |
+ track_rect.left() + kScrollerTrackBorderWidth, |
+ track_rect.bottom(), |
+ paint); |
+ } else { |
+ canvas->drawRectCoords(track_rect.left(), |
+ track_rect.top(), |
+ track_rect.right(), |
+ track_rect.top() + kScrollerTrackBorderWidth, |
+ paint); |
+ } |
+} |
+ |
+void NativeThemeMac::PaintScrollbarThumb(SkCanvas* canvas, |
+ Part part, |
+ State state, |
+ const gfx::Rect& rect) const { |
+ gfx::Rect thumb_rect(rect); |
+ if (part == kScrollbarVerticalThumb) |
tapted
2014/08/11 01:00:58
Maybe a switch statement here, with NOTREACHED().
Andre
2014/08/12 21:42:38
Done.
|
+ thumb_rect.Inset(kScrollerTrackBorderWidth, 0, 0, 0); |
+ else |
+ thumb_rect.Inset(0, kScrollerTrackBorderWidth, 0, 0); |
+ |
+ thumb_rect.Inset(kScrollerThumbInset, kScrollerThumbInset); |
+ |
+ SkPaint paint; |
+ paint.setColor(state == kHovered ? thumb_active_color_ |
+ : thumb_inactive_color_); |
+ SkRect skrect; |
+ skrect.set( |
+ thumb_rect.x(), thumb_rect.y(), thumb_rect.right(), thumb_rect.bottom()); |
+ const SkScalar radius = std::min(skrect.width(), skrect.height()); |
+ canvas->drawRoundRect(skrect, radius, radius, paint); |
+} |
+ |
NativeThemeMac::NativeThemeMac() { |
+ set_scrollbar_button_length(0); |
tapted
2014/08/11 01:00:58
Perhaps also override PaintArrowButton to be a no-
Andre
2014/08/12 21:42:38
I've added a scrollbar_button_length_ check in Nat
tapted
2014/08/13 01:13:29
lg
|
+ SetScrollbarColors( |
+ kScrollerThumbColor, kScrollerThumbHoverColor, kScrollerTrackColor); |
} |
NativeThemeMac::~NativeThemeMac() { |