| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 gfx::Rect track_rect = GetLocalBounds(); | 247 gfx::Rect track_rect = GetLocalBounds(); |
| 248 | 248 |
| 249 SkPoint gradient_bounds[2]; | 249 SkPoint gradient_bounds[2]; |
| 250 if (IsHorizontal()) { | 250 if (IsHorizontal()) { |
| 251 gradient_bounds[0].set(track_rect.x(), track_rect.y()); | 251 gradient_bounds[0].set(track_rect.x(), track_rect.y()); |
| 252 gradient_bounds[1].set(track_rect.x(), track_rect.bottom()); | 252 gradient_bounds[1].set(track_rect.x(), track_rect.bottom()); |
| 253 } else { | 253 } else { |
| 254 gradient_bounds[0].set(track_rect.x(), track_rect.y()); | 254 gradient_bounds[0].set(track_rect.x(), track_rect.y()); |
| 255 gradient_bounds[1].set(track_rect.right(), track_rect.y()); | 255 gradient_bounds[1].set(track_rect.right(), track_rect.y()); |
| 256 } | 256 } |
| 257 skia::RefPtr<SkShader> shader = skia::AdoptRef(SkGradientShader::CreateLinear( | 257 SkPaint gradient; |
| 258 gradient.setShader(SkGradientShader::MakeLinear( |
| 258 gradient_bounds, kScrollerTrackGradientColors, nullptr, | 259 gradient_bounds, kScrollerTrackGradientColors, nullptr, |
| 259 arraysize(kScrollerTrackGradientColors), SkShader::kClamp_TileMode)); | 260 arraysize(kScrollerTrackGradientColors), SkShader::kClamp_TileMode)); |
| 260 SkPaint gradient; | |
| 261 gradient.setShader(shader.get()); | |
| 262 canvas->DrawRect(track_rect, gradient); | 261 canvas->DrawRect(track_rect, gradient); |
| 263 | 262 |
| 264 // Draw the inner border: top if horizontal, left if vertical. | 263 // Draw the inner border: top if horizontal, left if vertical. |
| 265 SkPaint paint; | 264 SkPaint paint; |
| 266 paint.setColor(kScrollerTrackInnerBorderColor); | 265 paint.setColor(kScrollerTrackInnerBorderColor); |
| 267 gfx::Rect inner_border(track_rect); | 266 gfx::Rect inner_border(track_rect); |
| 268 if (IsHorizontal()) | 267 if (IsHorizontal()) |
| 269 inner_border.set_height(kScrollerTrackBorderWidth); | 268 inner_border.set_height(kScrollerTrackBorderWidth); |
| 270 else | 269 else |
| 271 inner_border.set_width(kScrollerTrackBorderWidth); | 270 inner_border.set_width(kScrollerTrackBorderWidth); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 void CocoaScrollBar::SetScrolltrackVisible(bool visible) { | 478 void CocoaScrollBar::SetScrolltrackVisible(bool visible) { |
| 480 has_scrolltrack_ = visible; | 479 has_scrolltrack_ = visible; |
| 481 SchedulePaint(); | 480 SchedulePaint(); |
| 482 } | 481 } |
| 483 | 482 |
| 484 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { | 483 CocoaScrollBarThumb* CocoaScrollBar::GetCocoaScrollBarThumb() const { |
| 485 return static_cast<CocoaScrollBarThumb*>(GetThumb()); | 484 return static_cast<CocoaScrollBarThumb*>(GetThumb()); |
| 486 } | 485 } |
| 487 | 486 |
| 488 } // namespace views | 487 } // namespace views |
| OLD | NEW |