| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #import "base/mac/scoped_nsobject.h" |
| 10 #import "ui/views/cocoa/views_scrollbar_bridge.h" |
| 11 #include "ui/views/controls/scrollbar/base_scroll_bar.h" |
| 12 #include "ui/views/views_export.h" |
| 13 |
| 14 namespace views { |
| 15 |
| 16 // The transparent scrollbar for Mac which overlays its contents. |
| 17 class VIEWS_EXPORT CocoaScrollBar : public BaseScrollBar, |
| 18 public ViewsScrollbarBridgeDelegate { |
| 19 public: |
| 20 explicit CocoaScrollBar(bool horizontal); |
| 21 ~CocoaScrollBar() override; |
| 22 |
| 23 // Called by CocoaScrollBarThumb when the mouse enters or exits the view. |
| 24 void OnMouseEnteredScrollbarThumb(const ui::MouseEvent& event); |
| 25 void OnMouseExitedScrollbarThumb(const ui::MouseEvent& event); |
| 26 |
| 27 // ScrollDelegate: |
| 28 bool OnScroll(float dx, float dy) override; |
| 29 |
| 30 // ViewsScrollbarBridgeDelegate: |
| 31 void OnScrollerStyleChanged() override; |
| 32 |
| 33 protected: |
| 34 // BaseScrollBar: |
| 35 gfx::Rect GetTrackBounds() const override; |
| 36 |
| 37 // ScrollBar: |
| 38 int GetLayoutSize() const override; |
| 39 int GetContentOverlapSize() const override; |
| 40 |
| 41 // View: |
| 42 gfx::Size GetPreferredSize() const override; |
| 43 void OnPaint(gfx::Canvas* canvas) override; |
| 44 |
| 45 private: |
| 46 // Methods to change the visibility of the scrollbar. |
| 47 void ShowScrollbar(); |
| 48 void HideScrollbar(); |
| 49 |
| 50 // Resets hide_scrollbar_timer_ if the timer is running. Otherwise, this |
| 51 // method will just start the timer. |
| 52 void ResetTimer(); |
| 53 |
| 54 // Scroller style the scrollbar is using. |
| 55 NSScrollerStyle scroller_style_; |
| 56 |
| 57 // Timer that will start the scrollbar's hiding animation when it reaches 0. |
| 58 base::OneShotTimer hide_scrollbar_timer_; |
| 59 |
| 60 // True when the scrolltrack should be drawn. |
| 61 bool has_scrolltrack_; |
| 62 |
| 63 // True if the scrollbar is in its hover state. |
| 64 bool is_hovering_; |
| 65 |
| 66 // The bridge for NSScroller. |
| 67 base::scoped_nsobject<ViewsScrollbarBridge> bridge_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar); |
| 70 }; |
| 71 |
| 72 } // namespace views |
| 73 |
| 74 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ |
| OLD | NEW |