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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar_thumb.h

Issue 2496643002: Implement Sebastien's overlay scrollbars for native UI (Views). (Closed)
Patch Set: fix test failure Created 4 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BASE_SCROLL_BAR_THUMB_H_ 5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_
6 #define UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/gfx/geometry/size.h" 9 #include "ui/gfx/geometry/size.h"
10 #include "ui/views/controls/button/custom_button.h" 10 #include "ui/views/controls/button/custom_button.h"
(...skipping 14 matching lines...) Expand all
25 // 25 //
26 // A view that acts as the thumb in the scroll bar track that the user can 26 // A view that acts as the thumb in the scroll bar track that the user can
27 // drag to scroll the associated contents view within the viewport. 27 // drag to scroll the associated contents view within the viewport.
28 // 28 //
29 /////////////////////////////////////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////////////
30 class VIEWS_EXPORT BaseScrollBarThumb : public View { 30 class VIEWS_EXPORT BaseScrollBarThumb : public View {
31 public: 31 public:
32 explicit BaseScrollBarThumb(BaseScrollBar* scroll_bar); 32 explicit BaseScrollBarThumb(BaseScrollBar* scroll_bar);
33 ~BaseScrollBarThumb() override; 33 ~BaseScrollBarThumb() override;
34 34
35 // Sets the size (width or height) of the thumb to the specified value. 35 // Sets the length (width or height) of the thumb to the specified value.
36 void SetSize(int size); 36 void SetLength(int length);
37 37
38 // Retrieves the size (width or height) of the thumb. 38 // Retrieves the size (width or height) of the thumb.
39 int GetSize() const; 39 int GetSize() const;
40 40
41 // Sets the position of the thumb on the x or y axis. 41 // Sets the position of the thumb on the x or y axis.
42 void SetPosition(int position); 42 void SetPosition(int position);
43 43
44 // Gets the position of the thumb on the x or y axis. 44 // Gets the position of the thumb on the x or y axis.
45 int GetPosition() const; 45 int GetPosition() const;
46 46
47 // View overrides: 47 // View overrides:
48 gfx::Size GetPreferredSize() const override = 0; 48 gfx::Size GetPreferredSize() const override = 0;
49 49
50 protected: 50 protected:
51 // View overrides: 51 // View overrides:
52 void OnPaint(gfx::Canvas* canvas) override = 0; 52 void OnPaint(gfx::Canvas* canvas) override = 0;
53 void OnMouseEntered(const ui::MouseEvent& event) override; 53 void OnMouseEntered(const ui::MouseEvent& event) override;
54 void OnMouseExited(const ui::MouseEvent& event) override; 54 void OnMouseExited(const ui::MouseEvent& event) override;
55 bool OnMousePressed(const ui::MouseEvent& event) override; 55 bool OnMousePressed(const ui::MouseEvent& event) override;
56 bool OnMouseDragged(const ui::MouseEvent& event) override; 56 bool OnMouseDragged(const ui::MouseEvent& event) override;
57 void OnMouseReleased(const ui::MouseEvent& event) override; 57 void OnMouseReleased(const ui::MouseEvent& event) override;
58 void OnMouseCaptureLost() override; 58 void OnMouseCaptureLost() override;
59 59
60 CustomButton::ButtonState GetState() const; 60 CustomButton::ButtonState GetState() const;
61 // Update our state and schedule a repaint when the mouse moves over us. 61 // Update our state and schedule a repaint when the mouse moves over us.
62 void SetState(CustomButton::ButtonState state); 62 void SetState(CustomButton::ButtonState state);
63 virtual void OnStateChanged();
64
65 bool IsHorizontal() const;
63 66
64 BaseScrollBar* scroll_bar() { return scroll_bar_; } 67 BaseScrollBar* scroll_bar() { return scroll_bar_; }
65 68
66 private: 69 private:
67 // The BaseScrollBar that owns us. 70 // The BaseScrollBar that owns us.
68 BaseScrollBar* scroll_bar_; 71 BaseScrollBar* scroll_bar_;
69 72
70 int drag_start_position_; 73 int drag_start_position_;
71 74
72 // The position of the mouse on the scroll axis relative to the top of this 75 // The position of the mouse on the scroll axis relative to the top of this
73 // View when the drag started. 76 // View when the drag started.
74 int mouse_offset_; 77 int mouse_offset_;
75 78
76 // The current state of the thumb button. 79 // The current state of the thumb button.
77 CustomButton::ButtonState state_; 80 CustomButton::ButtonState state_;
78 81
79 DISALLOW_COPY_AND_ASSIGN(BaseScrollBarThumb); 82 DISALLOW_COPY_AND_ASSIGN(BaseScrollBarThumb);
80 }; 83 };
81 84
82 } // namespace views 85 } // namespace views
83 86
84 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ 87 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.cc ('k') | ui/views/controls/scrollbar/base_scroll_bar_thumb.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698