| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #import "ui/views/controls/scrollbar/cocoa_scroll_bar.h" | 5 #import "ui/views/controls/scrollbar/cocoa_scroll_bar.h" |
| 6 | 6 |
| 7 #import "base/mac/sdk_forward_declarations.h" | 7 #import "base/mac/sdk_forward_declarations.h" |
| 8 #include "third_party/skia/include/core/SkColor.h" | 8 #include "third_party/skia/include/core/SkColor.h" |
| 9 #include "third_party/skia/include/effects/SkGradientShader.h" | 9 #include "third_party/skia/include/effects/SkGradientShader.h" |
| 10 #include "ui/compositor/layer.h" | 10 #include "ui/compositor/layer.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 void CocoaScrollBarThumb::OnPaint(gfx::Canvas* canvas) { | 116 void CocoaScrollBarThumb::OnPaint(gfx::Canvas* canvas) { |
| 117 SkColor thumb_color = kScrollerDefaultThumbColor; | 117 SkColor thumb_color = kScrollerDefaultThumbColor; |
| 118 if (cocoa_scroll_bar()->GetScrollerStyle() == NSScrollerStyleOverlay || | 118 if (cocoa_scroll_bar()->GetScrollerStyle() == NSScrollerStyleOverlay || |
| 119 IsStateHovered() || | 119 IsStateHovered() || |
| 120 IsStatePressed()) { | 120 IsStatePressed()) { |
| 121 thumb_color = kScrollerHoverThumbColor; | 121 thumb_color = kScrollerHoverThumbColor; |
| 122 } | 122 } |
| 123 | 123 |
| 124 gfx::Rect local_bounds(GetLocalBounds()); | 124 gfx::Rect local_bounds(GetLocalBounds()); |
| 125 SkPaint paint; | 125 CdlPaint paint; |
| 126 paint.setAntiAlias(true); | 126 paint.setAntiAlias(true); |
| 127 paint.setStyle(SkPaint::kFill_Style); | 127 paint.setStyle(CdlPaint::kFill_Style); |
| 128 paint.setColor(thumb_color); | 128 paint.setColor(thumb_color); |
| 129 const SkScalar radius = | 129 const SkScalar radius = |
| 130 std::min(local_bounds.width(), local_bounds.height()); | 130 std::min(local_bounds.width(), local_bounds.height()); |
| 131 canvas->DrawRoundRect(local_bounds, radius, paint); | 131 canvas->DrawRoundRect(local_bounds, radius, paint); |
| 132 } | 132 } |
| 133 | 133 |
| 134 bool CocoaScrollBarThumb::OnMousePressed(const ui::MouseEvent& event) { | 134 bool CocoaScrollBarThumb::OnMousePressed(const ui::MouseEvent& event) { |
| 135 // Ignore the mouse press if the scrollbar is hidden. | 135 // Ignore the mouse press if the scrollbar is hidden. |
| 136 if (cocoa_scroll_bar()->IsScrollbarFullyHidden()) | 136 if (cocoa_scroll_bar()->IsScrollbarFullyHidden()) |
| 137 return false; | 137 return false; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 gfx::Rect track_rect = GetLocalBounds(); | 249 gfx::Rect track_rect = GetLocalBounds(); |
| 250 | 250 |
| 251 SkPoint gradient_bounds[2]; | 251 SkPoint gradient_bounds[2]; |
| 252 if (IsHorizontal()) { | 252 if (IsHorizontal()) { |
| 253 gradient_bounds[0].set(track_rect.x(), track_rect.y()); | 253 gradient_bounds[0].set(track_rect.x(), track_rect.y()); |
| 254 gradient_bounds[1].set(track_rect.x(), track_rect.bottom()); | 254 gradient_bounds[1].set(track_rect.x(), track_rect.bottom()); |
| 255 } else { | 255 } else { |
| 256 gradient_bounds[0].set(track_rect.x(), track_rect.y()); | 256 gradient_bounds[0].set(track_rect.x(), track_rect.y()); |
| 257 gradient_bounds[1].set(track_rect.right(), track_rect.y()); | 257 gradient_bounds[1].set(track_rect.right(), track_rect.y()); |
| 258 } | 258 } |
| 259 SkPaint gradient; | 259 CdlPaint gradient; |
| 260 gradient.setShader(SkGradientShader::MakeLinear( | 260 gradient.setShader(CdlShader::WrapSkShader(SkGradientShader::MakeLinear( |
| 261 gradient_bounds, kScrollerTrackGradientColors, nullptr, | 261 gradient_bounds, kScrollerTrackGradientColors, nullptr, |
| 262 arraysize(kScrollerTrackGradientColors), SkShader::kClamp_TileMode)); | 262 arraysize(kScrollerTrackGradientColors), SkShader::kClamp_TileMode))); |
| 263 canvas->DrawRect(track_rect, gradient); | 263 canvas->DrawRect(track_rect, gradient); |
| 264 | 264 |
| 265 // Draw the inner border: top if horizontal, left if vertical. | 265 // Draw the inner border: top if horizontal, left if vertical. |
| 266 SkPaint paint; | 266 CdlPaint paint; |
| 267 paint.setColor(kScrollerTrackInnerBorderColor); | 267 paint.setColor(kScrollerTrackInnerBorderColor); |
| 268 gfx::Rect inner_border(track_rect); | 268 gfx::Rect inner_border(track_rect); |
| 269 if (IsHorizontal()) | 269 if (IsHorizontal()) |
| 270 inner_border.set_height(kScrollerTrackBorderWidth); | 270 inner_border.set_height(kScrollerTrackBorderWidth); |
| 271 else | 271 else |
| 272 inner_border.set_width(kScrollerTrackBorderWidth); | 272 inner_border.set_width(kScrollerTrackBorderWidth); |
| 273 canvas->DrawRect(inner_border, paint); | 273 canvas->DrawRect(inner_border, paint); |
| 274 | 274 |
| 275 // Draw the outer border: bottom if horizontal, right if veritcal. | 275 // Draw the outer border: bottom if horizontal, right if veritcal. |
| 276 paint.setColor(kScrollerTrackOuterBorderColor); | 276 paint.setColor(kScrollerTrackOuterBorderColor); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { | 536 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { |
| 537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); | 537 return static_cast<CocoaScrollBarThumb*>(GetThumb()); |
| 538 } | 538 } |
| 539 | 539 |
| 540 // static | 540 // static |
| 541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { | 541 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) { |
| 542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; | 542 return &static_cast<CocoaScrollBar*>(scroll_bar)->hide_scrollbar_timer_; |
| 543 } | 543 } |
| 544 | 544 |
| 545 } // namespace views | 545 } // namespace views |
| OLD | NEW |