OLD | NEW |
---|---|
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 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_VIEWS_H_ |
6 #define UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_VIEWS_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/gfx/geometry/point.h" | 10 #include "ui/gfx/geometry/point.h" |
11 #include "ui/native_theme/native_theme.h" | 11 #include "ui/native_theme/native_theme.h" |
12 #include "ui/views/controls/button/button.h" | 12 #include "ui/views/controls/button/button.h" |
13 #include "ui/views/controls/scrollbar/base_scroll_bar.h" | 13 #include "ui/views/controls/scrollbar/base_scroll_bar.h" |
14 #include "ui/views/controls/scrollbar/native_scroll_bar_wrapper.h" | |
15 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
16 | 15 |
17 namespace gfx { | 16 namespace gfx { |
18 class Canvas; | 17 class Canvas; |
19 } | 18 } |
20 | 19 |
21 namespace views { | 20 namespace views { |
22 | 21 |
23 class NativeScrollBar; | |
24 | |
25 // Views implementation for the scrollbar. | 22 // Views implementation for the scrollbar. |
26 class VIEWS_EXPORT NativeScrollBarViews : public BaseScrollBar, | 23 class VIEWS_EXPORT ScrollBarViews : public BaseScrollBar, |
sky
2016/11/07 16:22:55
optional: name this ScrollBar (the Views name is n
Evan Stade
2016/11/07 17:10:00
yea, this name isn't great, but ScrollBar is alrea
| |
27 public ButtonListener, | 24 public ButtonListener { |
28 public NativeScrollBarWrapper { | |
29 public: | 25 public: |
30 static const char kViewClassName[]; | 26 static const char kViewClassName[]; |
31 | 27 |
32 // Creates new scrollbar, either horizontal or vertical. | 28 // Creates new scrollbar, either horizontal or vertical. |
33 explicit NativeScrollBarViews(NativeScrollBar* native_scroll_bar); | 29 explicit ScrollBarViews(bool horizontal); |
34 ~NativeScrollBarViews() override; | 30 ~ScrollBarViews() override; |
35 | 31 |
36 private: | 32 static int GetVerticalScrollBarWidth(const ui::NativeTheme* theme); |
33 | |
34 protected: | |
37 // View overrides: | 35 // View overrides: |
38 void Layout() override; | 36 void Layout() override; |
39 void OnPaint(gfx::Canvas* canvas) override; | 37 void OnPaint(gfx::Canvas* canvas) override; |
40 gfx::Size GetPreferredSize() const override; | 38 gfx::Size GetPreferredSize() const override; |
41 const char* GetClassName() const override; | 39 const char* GetClassName() const override; |
42 | 40 |
43 // ScrollBar overrides: | 41 // ScrollBar overrides: |
44 int GetLayoutSize() const override; | 42 int GetLayoutSize() const override; |
45 | 43 |
46 // BaseScrollBar overrides: | |
47 void ScrollToPosition(int position) override; | |
48 int GetScrollIncrement(bool is_page, bool is_positive) override; | |
49 | |
50 // BaseButton::ButtonListener overrides: | 44 // BaseButton::ButtonListener overrides: |
51 void ButtonPressed(Button* sender, const ui::Event& event) override; | 45 void ButtonPressed(Button* sender, const ui::Event& event) override; |
52 | 46 |
53 // NativeScrollBarWrapper overrides: | |
54 int GetPosition() const override; | |
55 View* GetView() override; | |
56 void Update(int viewport_size, int content_size, int current_pos) override; | |
57 | |
58 // Returns the area for the track. This is the area of the scrollbar minus | 47 // Returns the area for the track. This is the area of the scrollbar minus |
59 // the size of the arrow buttons. | 48 // the size of the arrow buttons. |
60 gfx::Rect GetTrackBounds() const override; | 49 gfx::Rect GetTrackBounds() const override; |
61 | 50 |
62 // The NativeScrollBar we are bound to. | 51 private: |
63 NativeScrollBar* native_scroll_bar_; | |
64 | |
65 // The scroll bar buttons (Up/Down, Left/Right). | 52 // The scroll bar buttons (Up/Down, Left/Right). |
66 Button* prev_button_; | 53 Button* prev_button_; |
67 Button* next_button_; | 54 Button* next_button_; |
68 | 55 |
69 ui::NativeTheme::ExtraParams params_; | 56 ui::NativeTheme::ExtraParams params_; |
70 ui::NativeTheme::Part part_; | 57 ui::NativeTheme::Part part_; |
71 ui::NativeTheme::State state_; | 58 ui::NativeTheme::State state_; |
72 | 59 |
73 DISALLOW_COPY_AND_ASSIGN(NativeScrollBarViews); | 60 DISALLOW_COPY_AND_ASSIGN(ScrollBarViews); |
74 }; | 61 }; |
75 | 62 |
76 } // namespace views | 63 } // namespace views |
77 | 64 |
78 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_NATIVE_SCROLL_BAR_VIEWS_H_ | 65 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_SCROLL_BAR_VIEWS_H_ |
OLD | NEW |