-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIScrollView.h
104 lines (73 loc) · 2.41 KB
/
GUIScrollView.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// ScrollView.h
// Deep
//
// Created by Nathan Daly on 1/2/13.
// Copyright (c) 2013 Lions Entertainment. All rights reserved.
//
#ifndef Deep_ScrollView_h
#define Deep_ScrollView_h
#include "GUIView.h"
#include "GUIImageView.h"
namespace GUI {
struct GUITimer_command;
class ScrollView : public View {
public:
ScrollView(int w_, int h_, View *display_view_);
~ScrollView();
void update();
virtual bool handle_mouse_scroll_start(bool up_down);
virtual bool handle_mouse_scroll_stop(bool up_down);
// Overrided to add or remove the scrollbars.
virtual void did_resize(int w_, int h_);
private:
GUITimer_command *repeater;
class ScrollBarBg : public View {
public:
ScrollBarBg(int w_, int h_, ScrollView *view_)
: View(w_,h_), view(view_) { }
void display();
virtual bool handle_mouse_down(DispPoint coord);
private:
ScrollView *view;
};
class ScrollBar : public View {
public:
ScrollBar(int w_, int h_, ScrollView *view_)
: View(w_,h_), view(view_), clicked(false) { }
void display();
virtual bool handle_mouse_down(DispPoint coord);
virtual bool handle_mouse_up(DispPoint coord);
virtual bool handle_mouse_motion(DispPoint coord, DispPoint rel_motion);
private:
ScrollView *view;
bool clicked;
DispPoint click;
};
class ScrollArrow : public ImageView {
public:
ScrollArrow(bool up_down_, const GUIImage& image)
: ImageView(image), up_down(up_down_) { }
virtual bool handle_mouse_down(DispPoint coord);
virtual bool handle_mouse_up(DispPoint coord);
private:
bool up_down;
};
void move_display_to(DispPoint pos);
void move_scroll_bar_to(DispPoint pos);
ScrollBar scroll_bar;
ScrollBarBg scroll_bar_bg;
ScrollArrow arrow_up, arrow_down;
View *display_view;
int w_init, h_init;
double scroll_y;
double scroll_y_vel;
bool scrollable; // false if this view is larger than display_view
bool scrolling; // true if currently holding down scroll wheel/gesture
int scroll_bar_x;
// Where the scroll bar should stop (set after sizes are determined)
int scroll_bar_top;
int scroll_bar_bottom;
};
} // namespace GUI
#endif