| 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_BASE_SCROLL_BAR_H_ | 5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_ |
| 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_ | 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "ui/views/animation/scroll_animator.h" | 9 #include "ui/views/animation/scroll_animator.h" |
| 10 #include "ui/views/context_menu_controller.h" | 10 #include "ui/views/context_menu_controller.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 // | 22 // |
| 23 // BaseScrollBar | 23 // BaseScrollBar |
| 24 // | 24 // |
| 25 /////////////////////////////////////////////////////////////////////////////// | 25 /////////////////////////////////////////////////////////////////////////////// |
| 26 class VIEWS_EXPORT BaseScrollBar : public ScrollBar, | 26 class VIEWS_EXPORT BaseScrollBar : public ScrollBar, |
| 27 public ScrollDelegate, | 27 public ScrollDelegate, |
| 28 public ContextMenuController, | 28 public ContextMenuController, |
| 29 public MenuDelegate { | 29 public MenuDelegate { |
| 30 public: | 30 public: |
| 31 BaseScrollBar(bool horizontal, BaseScrollBarThumb* thumb); | 31 BaseScrollBar(bool horizontal, BaseScrollBarThumb* thumb); |
| 32 virtual ~BaseScrollBar(); | 32 ~BaseScrollBar() override; |
| 33 | 33 |
| 34 // Get the bounds of the "track" area that the thumb is free to slide within. | 34 // Get the bounds of the "track" area that the thumb is free to slide within. |
| 35 virtual gfx::Rect GetTrackBounds() const = 0; | 35 virtual gfx::Rect GetTrackBounds() const = 0; |
| 36 | 36 |
| 37 // An enumeration of different amounts of incremental scroll, representing | 37 // An enumeration of different amounts of incremental scroll, representing |
| 38 // events sent from different parts of the UI/keyboard. | 38 // events sent from different parts of the UI/keyboard. |
| 39 enum ScrollAmount { | 39 enum ScrollAmount { |
| 40 SCROLL_NONE = 0, | 40 SCROLL_NONE = 0, |
| 41 SCROLL_START, | 41 SCROLL_START, |
| 42 SCROLL_END, | 42 SCROLL_END, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 59 bool ScrollByContentsOffset(int contents_offset); | 59 bool ScrollByContentsOffset(int contents_offset); |
| 60 | 60 |
| 61 // Called when the thumb state has been changed from |old_state| to | 61 // Called when the thumb state has been changed from |old_state| to |
| 62 // |new_state|. | 62 // |new_state|. |
| 63 void OnThumbStateChanged(CustomButton::ButtonState old_state, | 63 void OnThumbStateChanged(CustomButton::ButtonState old_state, |
| 64 CustomButton::ButtonState new_state); | 64 CustomButton::ButtonState new_state); |
| 65 | 65 |
| 66 // View overrides: | 66 // View overrides: |
| 67 virtual gfx::Size GetPreferredSize() const override = 0; | 67 virtual gfx::Size GetPreferredSize() const override = 0; |
| 68 virtual void Layout() override = 0; | 68 virtual void Layout() override = 0; |
| 69 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 69 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 70 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 70 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 71 virtual void OnMouseCaptureLost() override; | 71 void OnMouseCaptureLost() override; |
| 72 virtual void OnMouseEntered(const ui::MouseEvent& event) override; | 72 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 73 virtual void OnMouseExited(const ui::MouseEvent& event) override; | 73 void OnMouseExited(const ui::MouseEvent& event) override; |
| 74 virtual bool OnKeyPressed(const ui::KeyEvent& event) override; | 74 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 75 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) override; | 75 bool OnMouseWheel(const ui::MouseWheelEvent& event) override; |
| 76 | 76 |
| 77 // ui::EventHandler overrides: | 77 // ui::EventHandler overrides: |
| 78 virtual void OnGestureEvent(ui::GestureEvent* event) override; | 78 void OnGestureEvent(ui::GestureEvent* event) override; |
| 79 | 79 |
| 80 // ScrollBar overrides: | 80 // ScrollBar overrides: |
| 81 virtual void Update(int viewport_size, | 81 void Update(int viewport_size, |
| 82 int content_size, | 82 int content_size, |
| 83 int contents_scroll_offset) override; | 83 int contents_scroll_offset) override; |
| 84 virtual int GetLayoutSize() const override = 0; | 84 virtual int GetLayoutSize() const override = 0; |
| 85 virtual int GetPosition() const override; | 85 int GetPosition() const override; |
| 86 | 86 |
| 87 // ScrollDelegate overrides: | 87 // ScrollDelegate overrides: |
| 88 virtual bool OnScroll(float dx, float dy) override; | 88 bool OnScroll(float dx, float dy) override; |
| 89 | 89 |
| 90 // ContextMenuController overrides: | 90 // ContextMenuController overrides: |
| 91 virtual void ShowContextMenuForView(View* source, | 91 void ShowContextMenuForView(View* source, |
| 92 const gfx::Point& point, | 92 const gfx::Point& point, |
| 93 ui::MenuSourceType source_type) override; | 93 ui::MenuSourceType source_type) override; |
| 94 | 94 |
| 95 // Menu::Delegate overrides: | 95 // Menu::Delegate overrides: |
| 96 virtual base::string16 GetLabel(int id) const override; | 96 base::string16 GetLabel(int id) const override; |
| 97 virtual bool IsCommandEnabled(int id) const override; | 97 bool IsCommandEnabled(int id) const override; |
| 98 virtual void ExecuteCommand(int id) override; | 98 void ExecuteCommand(int id) override; |
| 99 | 99 |
| 100 protected: | 100 protected: |
| 101 // View overrides: | 101 // View overrides: |
| 102 virtual void OnPaint(gfx::Canvas* canvas) override = 0; | 102 virtual void OnPaint(gfx::Canvas* canvas) override = 0; |
| 103 | 103 |
| 104 BaseScrollBarThumb* GetThumb() const; | 104 BaseScrollBarThumb* GetThumb() const; |
| 105 CustomButton::ButtonState GetThumbTrackState() const; | 105 CustomButton::ButtonState GetThumbTrackState() const; |
| 106 | 106 |
| 107 // Wrapper functions that calls the controller. We need this since native | 107 // Wrapper functions that calls the controller. We need this since native |
| 108 // scrollbars wrap around a different scrollbar. When calling the controller | 108 // scrollbars wrap around a different scrollbar. When calling the controller |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // TODO(tdresser): This should be removed when raw pixel scrolling for views | 183 // TODO(tdresser): This should be removed when raw pixel scrolling for views |
| 184 // is enabled. See crbug.com/329354. | 184 // is enabled. See crbug.com/329354. |
| 185 gfx::Vector2dF roundoff_error_; | 185 gfx::Vector2dF roundoff_error_; |
| 186 | 186 |
| 187 DISALLOW_COPY_AND_ASSIGN(BaseScrollBar); | 187 DISALLOW_COPY_AND_ASSIGN(BaseScrollBar); |
| 188 }; | 188 }; |
| 189 | 189 |
| 190 } // namespace views | 190 } // namespace views |
| 191 | 191 |
| 192 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_ | 192 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_BASE_SCROLL_BAR_H_ |
| OLD | NEW |