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

Unified Diff: ui/views/controls/scrollbar/cocoa_scroll_bar.h

Issue 1671313002: MacViews: Overlay Scrollbars with Show/Hide Animations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update layout according to scroller style Created 4 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/scrollbar/cocoa_scroll_bar.h
diff --git a/ui/views/controls/scrollbar/cocoa_scroll_bar.h b/ui/views/controls/scrollbar/cocoa_scroll_bar.h
new file mode 100644
index 0000000000000000000000000000000000000000..aafb4bc880d247125355c78540800814ef6bb04c
--- /dev/null
+++ b/ui/views/controls/scrollbar/cocoa_scroll_bar.h
@@ -0,0 +1,74 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_
+#define UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_
+
+#include "base/macros.h"
+#import "base/mac/scoped_nsobject.h"
+#import "ui/views/cocoa/views_scrollbar_bridge.h"
+#include "ui/views/controls/scrollbar/base_scroll_bar.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+// The transparent scrollbar for Mac which overlays its contents.
+class VIEWS_EXPORT CocoaScrollBar : public BaseScrollBar,
+ public ViewsScrollbarBridgeDelegate {
+ public:
+ explicit CocoaScrollBar(bool horizontal);
+ ~CocoaScrollBar() override;
+
+ // Called by CocoaScrollBarThumb when the mouse enters or exits the view.
+ void OnMouseEnteredScrollbarThumb(const ui::MouseEvent& event);
+ void OnMouseExitedScrollbarThumb(const ui::MouseEvent& event);
+
+ // ScrollDelegate:
+ bool OnScroll(float dx, float dy) override;
+
+ // ViewsScrollbarBridgeDelegate:
+ void OnScrollerStyleChanged() override;
+
+ protected:
+ // BaseScrollBar:
+ gfx::Rect GetTrackBounds() const override;
+
+ // ScrollBar:
+ int GetLayoutSize() const override;
+ int GetContentOverlapSize() const override;
+
+ // View:
+ gfx::Size GetPreferredSize() const override;
+ void OnPaint(gfx::Canvas* canvas) override;
+
+ private:
+ // Methods to change the visibility of the scrollbar.
+ void ShowScrollbar();
+ void HideScrollbar();
+
+ // Resets hide_scrollbar_timer_ if the timer is running. Otherwise, this
+ // method will just start the timer.
+ void ResetTimer();
+
+ // Scroller style the scrollbar is using.
+ NSScrollerStyle scroller_style_;
+
+ // Timer that will start the scrollbar's hiding animation when it reaches 0.
+ base::OneShotTimer hide_scrollbar_timer_;
tapted 2016/02/17 08:46:20 I think it might be nicer just to use a base::Time
spqchan 2016/02/19 00:14:02 Done
+
+ // True when the scrolltrack should be drawn.
+ bool has_scrolltrack_;
+
+ // True if the scrollbar is in its hover state.
+ bool is_hovering_;
+
+ // The bridge for NSScroller.
+ base::scoped_nsobject<ViewsScrollbarBridge> bridge_;
+
+ DISALLOW_COPY_AND_ASSIGN(CocoaScrollBar);
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_CONTROLS_SCROLLBAR_COCOA_SCROLL_BAR_H_

Powered by Google App Engine
This is Rietveld 408576698