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

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: nits 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
« no previous file with comments | « ui/views/controls/scroll_view_unittest.cc ('k') | ui/views/controls/scrollbar/cocoa_scroll_bar.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d3c9ba5fa021937787ce7734d51f6b24ace25403
--- /dev/null
+++ b/ui/views/controls/scrollbar/cocoa_scroll_bar.h
@@ -0,0 +1,70 @@
+// 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);
+
+ // ScrollDelegate:
+ bool OnScroll(float dx, float dy) override;
+
+ // ViewsScrollbarBridgeDelegate:
+ void OnScrollerStyleChanged() override;
+
+ // Returns the scroller style.
+ NSScrollerStyle GetScrollerStyle() const { return scroller_style_; }
+
+ protected:
+ // BaseScrollBar:
+ gfx::Rect GetTrackBounds() const override;
+
+ // ScrollBar:
+ int GetLayoutSize() const override;
+ int GetContentOverlapSize() const override;
+
+ // View:
+ void Layout() override;
+ gfx::Size GetPreferredSize() const override;
+ void OnPaint(gfx::Canvas* canvas) override;
+
+ private:
+ // Methods to change the visibility of the scrollbar.
+ void ShowScrollbar();
+ void HideScrollbar();
+
+ // Scroller style the scrollbar is using.
+ NSScrollerStyle scroller_style_;
+
+ // Timer that will start the scrollbar's hiding animation when it reaches 0.
+ base::Timer hide_scrollbar_timer_;
+
+ // True when the scrolltrack should be drawn.
+ bool has_scrolltrack_;
+
+ // 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_
« no previous file with comments | « ui/views/controls/scroll_view_unittest.cc ('k') | ui/views/controls/scrollbar/cocoa_scroll_bar.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698