Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: ui/views/controls/scrollbar/overlay_scroll_bar.h

Issue 2496643002: Implement Sebastien's overlay scrollbars for native UI (Views). (Closed)
Patch Set: self review Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_OVERLAY_SCROLL_BAR_H_ 5 #ifndef UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_
6 #define UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_ 6 #define UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "ui/gfx/animation/slide_animation.h" 9 #include "ui/gfx/animation/slide_animation.h"
10 #include "ui/views/controls/scrollbar/base_scroll_bar.h" 10 #include "ui/views/controls/scrollbar/base_scroll_bar.h"
11 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h"
11 12
12 namespace views { 13 namespace views {
13 14
14 // The transparent scrollbar which overlays its contents. 15 // The transparent scrollbar which overlays its contents.
15 class VIEWS_EXPORT OverlayScrollBar : public BaseScrollBar { 16 class VIEWS_EXPORT OverlayScrollBar : public BaseScrollBar {
16 public: 17 public:
17 explicit OverlayScrollBar(bool horizontal); 18 explicit OverlayScrollBar(bool horizontal);
18 ~OverlayScrollBar() override; 19 ~OverlayScrollBar() override;
19 20
20 protected: 21 protected:
21 // BaseScrollBar overrides: 22 // BaseScrollBar overrides:
22 gfx::Rect GetTrackBounds() const override; 23 gfx::Rect GetTrackBounds() const override;
23 void OnGestureEvent(ui::GestureEvent* event) override;
24 24
25 // ScrollBar overrides: 25 // ScrollBar overrides:
26 int GetLayoutSize() const override; 26 int GetLayoutSize() const override;
27 int GetContentOverlapSize() const override; 27 int GetContentOverlapSize() const override;
28 void OnMouseEnteredScrollView(const ui::MouseEvent& event) override;
29 void OnMouseExitedScrollView(const ui::MouseEvent& event) override;
30 28
31 // View overrides: 29 // View overrides:
32 void Layout() override; 30 void Layout() override;
31 void OnMouseEntered(const ui::MouseEvent& event) override;
32 void OnMouseExited(const ui::MouseEvent& event) override;
33 33
34 private: 34 private:
35 gfx::SlideAnimation animation_; 35 class Thumb : public BaseScrollBarThumb, public gfx::AnimationDelegate {
36 public:
37 explicit Thumb(OverlayScrollBar* scroll_bar);
38 ~Thumb() override;
39
40 protected:
41 // BaseScrollBarThumb:
42 gfx::Size GetPreferredSize() const override;
43 void OnPaint(gfx::Canvas* canvas) override;
44 void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
45 void SetState(CustomButton::ButtonState state) override;
46
47 // gfx::AnimationDelegate overrides:
tdanderson 2016/11/10 20:50:21 nit: just gfx::AnimationDelegate:
Evan Stade 2016/11/11 02:46:46 guess I don't really care one way or another, but
48 void AnimationProgressed(const gfx::Animation* animation) override;
49
50 private:
51 OverlayScrollBar* scroll_bar_;
52 gfx::SlideAnimation hover_animation_;
53
54 DISALLOW_COPY_AND_ASSIGN(Thumb);
55 };
56 friend class Thumb;
57
58 // Shows the thumb without delay.
59 void ShowThumb();
60 // Hides the thumb with a delay.
61 void HideThumb();
62 // Starts a countdown that hides the thumb when it fires.
63 void StartThumbHideCountdown();
64
65 base::Timer thumb_hide_timer_;
66
36 DISALLOW_COPY_AND_ASSIGN(OverlayScrollBar); 67 DISALLOW_COPY_AND_ASSIGN(OverlayScrollBar);
37 }; 68 };
38 69
39 } // namespace views 70 } // namespace views
40 71
41 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_ 72 #endif // UI_VIEWS_CONTROLS_SCROLLBAR_OVERLAY_SCROLL_BAR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698