OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/controls/scrollbar/kennedy_scroll_bar.h" | 5 #include "ui/views/controls/scrollbar/kennedy_scroll_bar.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkColor.h" | 7 #include "third_party/skia/include/core/SkColor.h" |
8 #include "third_party/skia/include/core/SkXfermode.h" | 8 #include "third_party/skia/include/core/SkXfermode.h" |
9 #include "ui/gfx/canvas.h" | 9 #include "ui/gfx/canvas.h" |
10 #include "ui/views/background.h" | 10 #include "ui/views/background.h" |
11 #include "ui/views/border.h" | 11 #include "ui/views/border.h" |
12 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" | 12 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 namespace { | 15 namespace { |
16 | 16 |
17 const int kScrollbarWidth = 10; | 17 const int kScrollbarWidth = 10; |
18 const int kThumbMinimumSize = kScrollbarWidth * 2; | 18 const int kThumbMinimumSize = kScrollbarWidth * 2; |
19 const SkColor kBorderColor = SkColorSetARGB(32, 0, 0, 0); | 19 const SkColor kBorderColor = SkColorSetARGB(32, 0, 0, 0); |
20 const SkColor kThumbHoverColor = SkColorSetARGB(128, 0, 0, 0); | 20 const SkColor kThumbHoverColor = SkColorSetARGB(128, 0, 0, 0); |
21 const SkColor kThumbDefaultColor = SkColorSetARGB(64, 0, 0, 0); | 21 const SkColor kThumbDefaultColor = SkColorSetARGB(64, 0, 0, 0); |
22 const SkColor kTrackHoverColor = SkColorSetARGB(32, 0, 0, 0); | 22 const SkColor kTrackHoverColor = SkColorSetARGB(32, 0, 0, 0); |
23 | 23 |
24 class KennedyScrollBarThumb : public BaseScrollBarThumb { | 24 class KennedyScrollBarThumb : public BaseScrollBarThumb { |
25 public: | 25 public: |
26 explicit KennedyScrollBarThumb(BaseScrollBar* scroll_bar); | 26 explicit KennedyScrollBarThumb(BaseScrollBar* scroll_bar); |
27 virtual ~KennedyScrollBarThumb(); | 27 ~KennedyScrollBarThumb() override; |
28 | 28 |
29 protected: | 29 protected: |
30 // View overrides: | 30 // View overrides: |
31 virtual gfx::Size GetPreferredSize() const override; | 31 gfx::Size GetPreferredSize() const override; |
32 virtual void OnPaint(gfx::Canvas* canvas) override; | 32 void OnPaint(gfx::Canvas* canvas) override; |
33 | 33 |
34 private: | 34 private: |
35 DISALLOW_COPY_AND_ASSIGN(KennedyScrollBarThumb); | 35 DISALLOW_COPY_AND_ASSIGN(KennedyScrollBarThumb); |
36 }; | 36 }; |
37 | 37 |
38 KennedyScrollBarThumb::KennedyScrollBarThumb(BaseScrollBar* scroll_bar) | 38 KennedyScrollBarThumb::KennedyScrollBarThumb(BaseScrollBar* scroll_bar) |
39 : BaseScrollBarThumb(scroll_bar) { | 39 : BaseScrollBarThumb(scroll_bar) { |
40 } | 40 } |
41 | 41 |
42 KennedyScrollBarThumb::~KennedyScrollBarThumb() { | 42 KennedyScrollBarThumb::~KennedyScrollBarThumb() { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 CustomButton::ButtonState state = GetThumbTrackState(); | 98 CustomButton::ButtonState state = GetThumbTrackState(); |
99 if ((state == CustomButton::STATE_HOVERED) || | 99 if ((state == CustomButton::STATE_HOVERED) || |
100 (state == CustomButton::STATE_PRESSED)) { | 100 (state == CustomButton::STATE_PRESSED)) { |
101 gfx::Rect local_bounds(GetLocalBounds()); | 101 gfx::Rect local_bounds(GetLocalBounds()); |
102 canvas->FillRect(local_bounds, kTrackHoverColor); | 102 canvas->FillRect(local_bounds, kTrackHoverColor); |
103 canvas->DrawRect(local_bounds, kBorderColor); | 103 canvas->DrawRect(local_bounds, kBorderColor); |
104 } | 104 } |
105 } | 105 } |
106 | 106 |
107 } // namespace views | 107 } // namespace views |
OLD | NEW |