2
* Copyright (C) 2012 - Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License, as
6
* published by the Free Software Foundation; either version 2.1 or 3.0
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranties of
11
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
12
* PURPOSE. See the applicable version of the GNU Lesser General Public
13
* License for more details.
15
* You should have received a copy of both the GNU Lesser General Public
16
* License along with this program. If not, see <http://www.gnu.org/licenses/>
18
* Authored by: Daniel d'Andrada <daniel.dandrada@canonical.com>
21
#ifndef NUX_KINETIC_SCROLL_VIEW_H
22
#define NUX_KINETIC_SCROLL_VIEW_H
25
#include <Nux/KineticScrolling/KineticScroller.h>
26
#include <Nux/KineticScrolling/KineticScrollingEnums.h>
32
Used to scroll content that is bigger than the available space to display it.
34
Unlike ScrollView, where scroll bars are used to move the content, here you directly
35
drag the content with a mouse pointer or finger (in case of a touchscreen).
37
Items inside a KineticScrollView should properly handle events of type
38
EVENT_MOUSE_CANCEL. If an item inside a kinetic scroll view is pressed, it gets
39
a EVENT_MOUSE_DOWN as usual. But if the user starts dragging it (instead of
40
releasing it to generete a "click"), the KineticScrollView will get ownership of the
41
mouse and that item will receive an EVENT_MOUSE_CANCEL signalling that it no
42
longer has the mouse and won't get any further events from it. The mouse will
43
then be used for scrolling or flicking the KineticScrollView contents until it's
48
VLayout *layout = new Layout;
52
layout->AddView(item ...);
54
KineticScrollView *kinetic_scroll_view = new KineticScrollView;
55
kinetic_scroll_view->SetLayout(layout);
58
class KineticScrollView : public View
60
NUX_DECLARE_OBJECT_TYPE(KineticScrollView, View);
62
KineticScrollView(NUX_FILE_LINE_PROTO);
63
virtual ~KineticScrollView();
65
void SetScrollableDirections(ScrollableDirections scrollable_directions);
68
Defines what happens when the viewport is about to go beyond content boundaries
70
The default value is DragAndOvershootBounds.
72
void SetBoundsBehavior(BoundsBehavior bounds_behavior);
75
virtual bool ChildMouseEvent(const Event& event);
78
virtual void Draw(GraphicsEngine &graphics_engine, bool force_draw);
79
virtual void DrawContent(GraphicsEngine &graphics_engine, bool force_draw);
80
virtual long PostLayoutManagement(long LayoutResult);
81
virtual void PostResizeGeometry();
84
void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
85
void OnMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags);
86
void OnMouseDrag(int x, int y, int dx, int dy,
87
unsigned long button_flags, unsigned long key_flags);
88
void SetLayoutTranslation(int x, int y);
90
KineticScroller scroller_;
92
/* Variables used to process events from ChildMouseEven() */
93
bool mouse_pressed_on_child_;
94
int last_child_mouse_position_x_;
95
int last_child_mouse_position_y_;
100
#endif // NUX_KINETIC_SCROLL_VIEW_H