Chromium Code Reviews| 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 which overlays its contents. | |
|
tapted
2016/02/16 06:47:58
nit: mention Mac?
spqchan
2016/02/16 23:18:18
Done.
| |
| 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 override | |
|
tapted
2016/02/16 06:47:58
nit: `// ScrollDelegate:`
(i.e. since we've been
spqchan
2016/02/16 23:18:18
Done.
| |
| 28 bool OnScroll(float dx, float dy) override; | |
| 29 | |
| 30 // ViewsScrollbarBridgeDelegate override | |
|
tapted
2016/02/16 06:47:58
// ViewsScrollbarBridgeDelegate:
spqchan
2016/02/16 23:18:18
Done.
| |
| 31 void OnScrollerStyleChanged() override; | |
| 32 | |
| 33 protected: | |
| 34 // BaseScrollBar override: | |
|
tapted
2016/02/16 06:47:58
// BaseScrollBar:
spqchan
2016/02/16 23:18:18
Done.
| |
| 35 gfx::Rect GetTrackBounds() const override; | |
| 36 | |
| 37 // ScrollBar overrides: | |
|
tapted
2016/02/16 06:47:58
// ScrollBar:
spqchan
2016/02/16 23:18:18
Done.
| |
| 38 int GetLayoutSize() const override; | |
| 39 int GetContentOverlapSize() const override; | |
| 40 | |
| 41 // View overrides: | |
|
tapted
2016/02/16 06:47:58
// View:
spqchan
2016/02/16 23:18:18
Done.
| |
| 42 gfx::Size GetPreferredSize() const override; | |
| 43 void Layout() override; | |
| 44 void OnPaint(gfx::Canvas* canvas) override; | |
| 45 | |
| 46 private: | |
| 47 // Methods to change the visibility of the scrollbar. | |
| 48 void ShowScrollbar(); | |
| 49 void HideScrollbar(); | |
| 50 | |
| 51 // Resets hide_scrollbar_timer_ if the timer is running. Otherwise, this | |
| 52 // method will just start the timer. | |
| 53 void ResetTimer(); | |
| 54 | |
| 55 // Scroller style the scrollbar is using. | |
| 56 NSScrollerStyle scroller_style_; | |
| 57 | |
| 58 // Timer that will start the scrollbar's hiding animation when it reaches 0. | |
| 59 base::OneShotTimer hide_scrollbar_timer_; | |
| 60 | |
| 61 // True when the scrolltrack should be drawn. | |
| 62 bool has_scrolltrack_; | |
| 63 | |
| 64 // True if the scrollbar is in its hover state. | |
| 65 bool is_hovering_; | |
| 66 | |
| 67 // The bridge for NSScroller. | |
| 68 base::scoped_nsobject<ViewsScrollbarBridge> bridge_; | |
| 69 DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar); | |
|
tapted
2016/02/16 06:47:58
nit: blank line before
spqchan
2016/02/16 23:18:18
Done.
| |
| 70 }; | |
| 71 | |
| 72 } // namespace views | |
| 73 | |
| 74 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_ | |
| OLD | NEW |