Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_slider.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_SLIDER_H
8#define _DS_SLIDER_H
9
10
11#include <ds_view.h>
12#include <ds_value_base.h>
13
22class DsSlider: public DsView, public DsValueBase
23{
24public:
33 DsSlider(DsView* parent, const DsPoint &pos, const DsSize &size, bool inverted = false);
34
35
40
41
48
49
55 void drawKnobSurface(void);
56
57
63
64
69 void setTrackBorderThickness(uint8_t thickness);
70
71
76 void setTrackProportion(float proportion);
77
78
84
85
90 void setKnobBorderThickness(uint8_t thickness);
91
92
98 void setTrackColors(DsColor color, DsColor color_active);
99
100
106
107
116 void setTrackSurfaces(DsSurface* surface, DsSurface* surface_active);
117
118
127 void setKnobSurface(DsSurface* surface, uint32_t diameter);
128
129
130private:
131 float mTrackProportion;
132 DsRect mTrackRegion;
133
134 int32_t mKnobPos; //this is the top left corner of the knob surface
135 int32_t mKnobPosMin;
136 int32_t mKnobPosMax;
137
138 DsSurface* mTrackSurface;
139 DsSurface* mActiveTrackSurface;
140 DsSurface* mKnobSurface;
141
142 uint16_t mTrackWidth;
143 uint16_t mKnobDiameter;
144
145 DsColor mTrackBorderColor;
146 DsColor mTrackColor;
147 DsColor mActiveTrackColor;
148 DsColor mKnobBorderColor;
149 DsColor mKnobColor;
150
151 uint32_t mTouchTimestamp;
152 int32_t mTouchPos;
153
154 struct
155 {
156 uint8_t mCreatedTrackSurface: 1;
157 uint8_t mCreatedActiveTrackSurface: 1;
158 uint8_t mCreatedKnobSurface: 1;
159 uint8_t mIsInverted: 1;
160 uint8_t mIsTouchActive: 1;
161 };
162
163 uint8_t mTrackBorderThickness;
164 uint8_t mKnobBorderThickness;
165
166
167 void onPaint(DsRenderer &renderer) override final;
168 bool onTouch(const DsTouchEvent &event) override final;
169 void onSizeChange(void) override final;
170
171 float onValueChange(float value) override final;
172
173 bool isPosInsideKnob(const DsPoint &pos);
174 DsRect updateKnobPosition(int32_t new_knob_pos);
175};
176
177
178#endif
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
DsPoint is a class that represents the X and Y 2D coordinates of a point as integer numbers.
Definition ds_geometry.h:24
DsRect is a class that represents a 2D rectangle (X, Y, W, H)
Definition ds_geometry.h:1507
DsRenderer is a class that implements all the drawing operations.
Definition ds_renderer.h:42
DsSize is class that represents the 2D size of a graphic object (width, height) as integer values.
Definition ds_geometry.h:780
DsSlider is a class that represents a slider that can be used to adjust a value.
Definition ds_slider.h:23
void drawKnobSurface(void)
Creates a surface and pre-draws the knob.
void setKnobSurface(DsSurface *surface, uint32_t diameter)
Sets the surfaces used for drawing the knob.
void setTrackBorderThickness(uint8_t thickness)
Sets the track border thickness.
void setTrackBorderColor(DsColor color)
Sets the track border color.
void setKnobBorderColor(DsColor color)
Sets the knob border color.
void setKnobBorderThickness(uint8_t thickness)
Sets the knob border thickness.
void setTrackProportion(float proportion)
Sets proportion of the track width versus the knob diameter.
DsSlider(DsView *parent, const DsPoint &pos, const DsSize &size, bool inverted=false)
Creates a DsSlider object.
void setTrackColors(DsColor color, DsColor color_active)
Sets the track color.
void setTrackSurfaces(DsSurface *surface, DsSurface *surface_active)
Sets the surfaces used for drawing the track.
~DsSlider()
Destructor.
void setKnobColor(DsColor color)
Sets the knob color.
void drawTrackSurfaces(void)
Creates a surface and pre-draws the track.
DsSurface is a class that represents a drawing surface.
Definition ds_surface.h:30
DsValueBase is a base class that contains a float value.
Definition ds_value_base.h:19
DsView is a base class that represents any view on the screen.
Definition ds_view.h:40
This structure implements a touch event.
Definition ds_event.h:25