OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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 ATHENA_UTIL_DRAG_HANDLE_H_ |
| 6 #define ATHENA_UTIL_DRAG_HANDLE_H_ |
| 7 |
| 8 #include "athena/athena_export.h" |
| 9 |
| 10 namespace views { |
| 11 class View; |
| 12 } |
| 13 |
| 14 namespace athena { |
| 15 // DragHandle will notify it's delegate of the scroll gestures it receives |
| 16 // through the ScrollDelegate interface. |
| 17 class DragHandle { |
| 18 public: |
| 19 class ScrollDelegate { |
| 20 public: |
| 21 virtual ~ScrollDelegate() {} |
| 22 |
| 23 // Beginning of a scroll gesture. |
| 24 virtual void HandleScrollBegin(float delta) = 0; |
| 25 |
| 26 // End of the current scroll gesture. |
| 27 virtual void HandleScrollEnd() = 0; |
| 28 |
| 29 // Update of the scroll position for the currently active scroll gesture. |
| 30 virtual void HandleScrollUpdate(float delta) = 0; |
| 31 |
| 32 // Should return false if the delegate isn't going to react to the scroll |
| 33 // events. |
| 34 // As long as this returns false, the handle won't start scrolling. However |
| 35 // if the scroll starts while HandleCanScroll() returns true and then the |
| 36 // delegate's state changes mid-scrol and HandleCanScroll() starts to return |
| 37 // false, the handle will continue scrolling and HandleScrollUpdate / |
| 38 // HandleScrollEnd callbacks will be called on the delegate. |
| 39 virtual bool HandleCanScroll() = 0; |
| 40 }; |
| 41 |
| 42 virtual ~DragHandle(); |
| 43 |
| 44 enum ScrollDirection { VERTICAL, HORIZONTAL }; |
| 45 }; |
| 46 |
| 47 // The handle view occupies the entire space given to it, showing a rectangular |
| 48 // handle in the center of the view on a black background. Preferred width and |
| 49 // height define the preferred visual extents of the rectangular handle. |
| 50 // |margin| defines the minimum margins between the visual handle and the |
| 51 // borders of the entire handle view. |
| 52 ATHENA_EXPORT views::View* CreateDragHandleView( |
| 53 DragHandle::ScrollDirection scroll_direction, |
| 54 DragHandle::ScrollDelegate* delegate, |
| 55 int preferred_width, |
| 56 int preferred_height, |
| 57 int margin); |
| 58 |
| 59 } // namespace athena |
| 60 |
| 61 #endif // ATHENA_UTIL_DRAG_HANDLE_H_ |
OLD | NEW |