forked from acaudwell/Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
slider.h
89 lines (64 loc) · 1.82 KB
/
slider.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
#ifndef UI_SLIDER_H
#define UI_SLIDER_H
#include "element.h"
#include "label.h"
#include "layout.h"
class UISlider : public UIElement {
protected:
TextureResource* slidertex;
float slider_width;
bool background;
UIAction* action;
void drawSlider(float position);
public:
UISlider(const std::string& slider_texure, float width, UIAction* action = 0);
bool keyPress(SDL_KeyboardEvent *e, char c);
virtual void scroll(bool up) {};
virtual void scale(bool up) {};
void idle();
int getType() const { return UI_SLIDER; };
};
class UIFloatSlider : public UISlider {
public:
float* value;
float min;
float max;
UIFloatSlider(float* value, float min, float max, UIAction* action = 0);
void scale(bool up, float value_scale = 0.25f);
void scroll(bool up);
void click(const vec2& pos);
void drag(const vec2& pos);
void setFloat(float* f);
void setValue(float v);
void drawContent();
};
class UIIntSlider : public UISlider {
public:
int* value;
int min;
int max;
UIIntSlider(int* value, int min, int max, UIAction* action = 0);
void scroll(bool up);
void click(const vec2& pos);
void drag(const vec2& pos);
void setValue(int v);
void drawContent();
};
class UILabelFloatSlider : public UILayout {
UIFloatSlider* slider;
UIFloatLabel* flabel;
public:
UILabelFloatSlider(const std::string& label, float* value, float min, float max, UIAction* action = 0);
void setFloat(float* f);
void scale(bool up);
void scale(bool up, float value_scale);
void scroll(bool up);
};
class UILabelIntSlider : public UILayout {
UIIntSlider* slider;
public:
UILabelIntSlider(const std::string& label, int* value, int min, int max, UIAction* action = 0);
void scale(bool up);
void scroll(bool up);
};
#endif