Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: ui/views/controls/scrollbar/native_scroll_bar_views.cc

Issue 1671313002: MacViews: Overlay Scrollbars with Show/Hide Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/native_scroll_bar_views.h" 5 #include "ui/views/controls/scrollbar/native_scroll_bar_views.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/events/keycodes/keyboard_codes.h" 8 #include "ui/events/keycodes/keyboard_codes.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/path.h" 10 #include "ui/gfx/path.h"
(...skipping 11 matching lines...) Expand all
22 // Wrapper for the scroll buttons. 22 // Wrapper for the scroll buttons.
23 class ScrollBarButton : public BaseScrollBarButton { 23 class ScrollBarButton : public BaseScrollBarButton {
24 public: 24 public:
25 enum Type { 25 enum Type {
26 UP, 26 UP,
27 DOWN, 27 DOWN,
28 LEFT, 28 LEFT,
29 RIGHT, 29 RIGHT,
30 }; 30 };
31 31
32 ScrollBarButton(ButtonListener* listener, Type type); 32 explicit ScrollBarButton(ButtonListener* listener, Type type);
tapted 2016/02/11 08:46:18 oops - I think we can revert all the diffs in this
spqchan 2016/02/13 01:39:23 I removed all the diffs involving NativeScrollBar
33 ~ScrollBarButton() override; 33 ~ScrollBarButton() override;
34 34
35 gfx::Size GetPreferredSize() const override; 35 gfx::Size GetPreferredSize() const override;
36 const char* GetClassName() const override { return "ScrollBarButton"; } 36 const char* GetClassName() const override { return "ScrollBarButton"; }
37 37
38 protected: 38 protected:
39 void OnPaint(gfx::Canvas* canvas) override; 39 void OnPaint(gfx::Canvas* canvas) override;
40 40
41 private: 41 private:
42 ui::NativeTheme::ExtraParams GetNativeThemeParams() const; 42 ui::NativeTheme::ExtraParams GetNativeThemeParams() const;
43 ui::NativeTheme::Part GetNativeThemePart() const; 43 ui::NativeTheme::Part GetNativeThemePart() const;
44 ui::NativeTheme::State GetNativeThemeState() const; 44 ui::NativeTheme::State GetNativeThemeState() const;
45 45
46 Type type_; 46 Type type_;
47 }; 47 };
48 48
49 // Wrapper for the scroll thumb 49 // Wrapper for the scroll thumb
50 class ScrollBarThumb : public BaseScrollBarThumb { 50 class ScrollBarThumb : public BaseScrollBarThumb {
51 public: 51 public:
52 explicit ScrollBarThumb(BaseScrollBar* scroll_bar); 52 ScrollBarThumb(BaseScrollBar* scroll_bar);
53 ~ScrollBarThumb() override; 53 ~ScrollBarThumb() override;
54 54
55 gfx::Size GetPreferredSize() const override; 55 gfx::Size GetPreferredSize() const override;
56 const char* GetClassName() const override { return "ScrollBarThumb"; } 56 const char* GetClassName() const override { return "ScrollBarThumb"; }
57 57
58 protected: 58 protected:
59 void OnPaint(gfx::Canvas* canvas) override; 59 void OnPaint(gfx::Canvas* canvas) override;
60 60
61 private: 61 private:
62 ui::NativeTheme::ExtraParams GetNativeThemeParams() const; 62 ui::NativeTheme::ExtraParams GetNativeThemeParams() const;
63 ui::NativeTheme::Part GetNativeThemePart() const; 63 ui::NativeTheme::Part GetNativeThemePart() const;
64 ui::NativeTheme::State GetNativeThemeState() const; 64 ui::NativeTheme::State GetNativeThemeState() const;
65 65
66 ScrollBar* scroll_bar_; 66 ScrollBar* scroll_bar_;
67 }; 67 };
68 68
69 ///////////////////////////////////////////////////////////////////////////// 69 /////////////////////////////////////////////////////////////////////////////
70 // ScrollBarButton 70 // ScrollBarButton
71 71
72 ScrollBarButton::ScrollBarButton(ButtonListener* listener, Type type) 72 ScrollBarButton::ScrollBarButton(ButtonListener* listener, Type type)
73 : BaseScrollBarButton(listener), 73 : BaseScrollBarButton(listener), type_(type) {
74 type_(type) {
75 SetFocusable(false); 74 SetFocusable(false);
76 SetAccessibilityFocusable(false); 75 SetAccessibilityFocusable(false);
77 } 76 }
78 77
79 ScrollBarButton::~ScrollBarButton() { 78 ScrollBarButton::~ScrollBarButton() {
80 } 79 }
81 80
82 gfx::Size ScrollBarButton::GetPreferredSize() const { 81 gfx::Size ScrollBarButton::GetPreferredSize() const {
83 return GetNativeTheme()->GetPartSize(GetNativeThemePart(), 82 return GetNativeTheme()->GetPartSize(GetNativeThemePart(),
84 GetNativeThemeState(), 83 GetNativeThemeState(),
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 211 }
213 212
214 } // namespace 213 } // namespace
215 214
216 //////////////////////////////////////////////////////////////////////////////// 215 ////////////////////////////////////////////////////////////////////////////////
217 // NativeScrollBarViews, public: 216 // NativeScrollBarViews, public:
218 217
219 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews"; 218 const char NativeScrollBarViews::kViewClassName[] = "NativeScrollBarViews";
220 219
221 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar) 220 NativeScrollBarViews::NativeScrollBarViews(NativeScrollBar* scroll_bar)
222 : BaseScrollBar(scroll_bar->IsHorizontal(), 221 : BaseScrollBar(scroll_bar->IsHorizontal(), new ScrollBarThumb(this)),
223 new ScrollBarThumb(this)),
224 native_scroll_bar_(scroll_bar) { 222 native_scroll_bar_(scroll_bar) {
225 set_controller(native_scroll_bar_->controller()); 223 set_controller(native_scroll_bar_->controller());
226 224
227 if (native_scroll_bar_->IsHorizontal()) { 225 if (native_scroll_bar_->IsHorizontal()) {
228 prev_button_ = new ScrollBarButton(this, ScrollBarButton::LEFT); 226 prev_button_ = new ScrollBarButton(this, ScrollBarButton::LEFT);
229 next_button_ = new ScrollBarButton(this, ScrollBarButton::RIGHT); 227 next_button_ = new ScrollBarButton(this, ScrollBarButton::RIGHT);
230 228
231 part_ = ui::NativeTheme::kScrollbarHorizontalTrack; 229 part_ = ui::NativeTheme::kScrollbarHorizontalTrack;
232 } else { 230 } else {
233 prev_button_ = new ScrollBarButton(this, ScrollBarButton::UP); 231 prev_button_ = new ScrollBarButton(this, ScrollBarButton::UP);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 thumb_params.scrollbar_thumb.is_hovering = false; 398 thumb_params.scrollbar_thumb.is_hovering = false;
401 gfx::Size track_size = theme->GetPartSize( 399 gfx::Size track_size = theme->GetPartSize(
402 ui::NativeTheme::kScrollbarVerticalThumb, 400 ui::NativeTheme::kScrollbarVerticalThumb,
403 ui::NativeTheme::kNormal, 401 ui::NativeTheme::kNormal,
404 thumb_params); 402 thumb_params);
405 403
406 return std::max(track_size.width(), button_size.width()); 404 return std::max(track_size.width(), button_size.width());
407 } 405 }
408 406
409 } // namespace views 407 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698