Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_discrete_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_DISCRETE_SLIDER_H
8#define _DS_DISCRETE_SLIDER_H
9
10
11#include <ds_view.h>
12#include <ds_selection_base.h>
13
23{
24public:
34 DsDiscreteSlider(DsView* parent, const DsPoint &pos, const DsSize &size, uint32_t stops, bool inverted = false);
35
36
41
47
48
53 void setTrackBorderThickness(uint8_t thickness);
54
55
60 void setTrackProportion(float proportion);
61
62
68
69
74 void setKnobBorderThickness(uint8_t thickness);
75
76
82 void setTrackColors(DsColor color, DsColor color_active);
83
84
89 void setKnobColor(DsColor color);
90
91
100 void setTrackSurfaces(DsSurface* surface, DsSurface* surface_active);
101
102
111 void setKnobSurface(DsSurface* surface, uint32_t diameter);
112
113
114private:
115 float mTrackProportion;
116 DsRect mTrackRegion;
117
118 int32_t mKnobPos; //this is the top left corner of the knob surface
119 int32_t mKnobPosMin;
120 int32_t mKnobPosMax;
121
122 DsSurface* mTrackSurface;
123 DsSurface* mActiveTrackSurface;
124 DsSurface* mKnobSurface;
125
126 uint16_t mTrackWidth;
127 uint16_t mKnobDiameter;
128
129 DsColor mTrackBorderColor;
130 DsColor mTrackColor;
131 DsColor mActiveTrackColor;
132 DsColor mKnobBorderColor;
133 DsColor mKnobColor;
134
135 uint32_t mTouchTimestamp;
136 int32_t mTouchPos;
137
138 struct
139 {
140 uint8_t mIsInverted: 1;
141 uint8_t mIsTouchActive: 1;
142 };
143
144 uint8_t mTrackBorderThickness;
145 uint8_t mKnobBorderThickness;
146
147
148 void onPaint(DsRenderer &renderer) override final;
149 bool onTouch(const DsTouchEvent &event) override final;
150 void onSizeChange(void) override final;
151
152 int32_t onSelectionChange(int32_t selection) override final;
153
154 bool isPosInsideKnob(const DsPoint &pos);
155 DsRect updateKnobPosition(int32_t new_knob_pos);
156};
157
158
159#endif
DsColor is a class that represents a 4 channel color (Alpha, Red, Green, Blue).
Definition ds_color.h:53
DsDiscreteSlider is a class that represents a slider that can be used to adjust a value in discrete s...
Definition ds_discrete_slider.h:23
void setTrackBorderColor(DsColor color)
Sets the track border color.
void setKnobColor(DsColor color)
Sets the knob color.
void setKnobBorderColor(DsColor color)
Sets the knob border color.
void setTrackProportion(float proportion)
Sets proportion of the track width versus the knob diameter.
~DsDiscreteSlider()
Destructor.
void setKnobSurface(DsSurface *surface, uint32_t diameter)
Sets the surfaces used for drawing the knob.
void setTrackSurfaces(DsSurface *surface, DsSurface *surface_active)
Sets the surfaces used for drawing the track.
void setTrackColors(DsColor color, DsColor color_active)
Sets the track color.
DsDiscreteSlider(DsView *parent, const DsPoint &pos, const DsSize &size, uint32_t stops, bool inverted=false)
Creates a DsSlider object.
void setKnobBorderThickness(uint8_t thickness)
Sets the knob border thickness.
void setTrackBorderThickness(uint8_t thickness)
Sets the track border thickness.
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
DsSelectionBase is a base class that contains a selection value.
Definition ds_selection_base.h:19
DsSize is class that represents the 2D size of a graphic object (width, height) as integer values.
Definition ds_geometry.h:780
DsSurface is a class that represents a drawing surface.
Definition ds_surface.h:30
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