Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 virtual void SetState(CustomButton::ButtonState state); |
|
sadrul
2016/11/12 03:01:10
Can you introduce a separate OnStateChanged() or s
| |
| 63 | |
| 64 bool IsHorizontal() const; | |
| 63 | 65 |
| 64 BaseScrollBar* scroll_bar() { return scroll_bar_; } | 66 BaseScrollBar* scroll_bar() { return scroll_bar_; } |
| 65 | 67 |
| 66 private: | 68 private: |
| 67 // The BaseScrollBar that owns us. | 69 // The BaseScrollBar that owns us. |
| 68 BaseScrollBar* scroll_bar_; | 70 BaseScrollBar* scroll_bar_; |
| 69 | 71 |
| 70 int drag_start_position_; | 72 int drag_start_position_; |
| 71 | 73 |
| 72 // The position of the mouse on the scroll axis relative to the top of this | 74 // The position of the mouse on the scroll axis relative to the top of this |
| 73 // View when the drag started. | 75 // View when the drag started. |
| 74 int mouse_offset_; | 76 int mouse_offset_; |
| 75 | 77 |
| 76 // The current state of the thumb button. | 78 // The current state of the thumb button. |
| 77 CustomButton::ButtonState state_; | 79 CustomButton::ButtonState state_; |
| 78 | 80 |
| 79 DISALLOW_COPY_AND_ASSIGN(BaseScrollBarThumb); | 81 DISALLOW_COPY_AND_ASSIGN(BaseScrollBarThumb); |
| 80 }; | 82 }; |
| 81 | 83 |
| 82 } // namespace views | 84 } // namespace views |
| 83 | 85 |
| 84 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ | 86 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ |
| OLD | NEW |