OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ |
| 6 #define VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "ui/gfx/size.h" |
| 10 #include "views/controls/button/custom_button.h" |
| 11 #include "views/controls/scrollbar/scroll_bar.h" |
| 12 #include "views/view.h" |
| 13 |
| 14 namespace gfx { |
| 15 class Canvas; |
| 16 } |
| 17 |
| 18 namespace views { |
| 19 |
| 20 class BaseScrollBar; |
| 21 |
| 22 /////////////////////////////////////////////////////////////////////////////// |
| 23 // |
| 24 // BaseScrollBarThumb |
| 25 // |
| 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. |
| 28 // |
| 29 /////////////////////////////////////////////////////////////////////////////// |
| 30 class VIEWS_EXPORT BaseScrollBarThumb : public View { |
| 31 public: |
| 32 explicit BaseScrollBarThumb(BaseScrollBar* scroll_bar); |
| 33 virtual ~BaseScrollBarThumb(); |
| 34 |
| 35 // Sets the size (width or height) of the thumb to the specified value. |
| 36 void SetSize(int size); |
| 37 |
| 38 // Retrieves the size (width or height) of the thumb. |
| 39 int GetSize() const; |
| 40 |
| 41 // Sets the position of the thumb on the x or y axis. |
| 42 void SetPosition(int position); |
| 43 |
| 44 // Gets the position of the thumb on the x or y axis. |
| 45 int GetPosition() const; |
| 46 |
| 47 // View overrides: |
| 48 virtual gfx::Size GetPreferredSize() OVERRIDE = 0; |
| 49 |
| 50 protected: |
| 51 // View overrides: |
| 52 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE = 0; |
| 53 virtual void OnMouseEntered(const MouseEvent& event) OVERRIDE; |
| 54 virtual void OnMouseExited(const MouseEvent& event) OVERRIDE; |
| 55 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; |
| 56 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; |
| 57 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; |
| 58 virtual void OnMouseCaptureLost() OVERRIDE; |
| 59 |
| 60 CustomButton::ButtonState GetState() const; |
| 61 // Update our state and schedule a repaint when the mouse moves over us. |
| 62 void SetState(CustomButton::ButtonState state); |
| 63 |
| 64 private: |
| 65 // The BaseScrollBar that owns us. |
| 66 BaseScrollBar* scroll_bar_; |
| 67 |
| 68 int drag_start_position_; |
| 69 |
| 70 // The position of the mouse on the scroll axis relative to the top of this |
| 71 // View when the drag started. |
| 72 int mouse_offset_; |
| 73 |
| 74 // The current state of the thumb button. |
| 75 CustomButton::ButtonState state_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(BaseScrollBarThumb); |
| 78 }; |
| 79 |
| 80 } // namespace views |
| 81 |
| 82 #endif // VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_THUMB_H_ |
OLD | NEW |