Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_switch.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_SWITCH_H
8#define _DS_SWITCH_H
9
10
11#include <ds_view.h>
12#include <ds_selection_base.h>
13
14
23class DsSwitch: public DsView, public DsSelectionBase
24{
25public:
26
35 DsSwitch(DsView* parent, const DsPoint &pos, const DsSize &size, bool inverted = false);
36
37
47 void setText(const char* text_on, DsColor color_on, const char* text_off, DsColor color_off, const ds_bitmap_font_t* font);
48
49
54 void setTrackBorderThickness(uint8_t thickness);
55
56
61 void setTrackProportion(float proportion);
62
63
68 void setKnobBorderThickness(uint8_t thickness);
69
70
79 void setSwitchTrackColors(DsColor track_border_on_color, DsColor track_on_color, DsColor track_border_off_color, DsColor track_off_color);
80
81
90 void setSwitchKnobColors(DsColor knob_border_on_color, DsColor knob_on_color, DsColor knob_border_off_color, DsColor knob_off_color);
91
92
93private:
94 float mTrackProportion;
95 DsRect mTrackRegion;
96
97 uint32_t mKnobDiameter;
98 uint32_t mTrackWidth;
99
100 const ds_bitmap_font_t* mFont;
101
102 const char* mTextOn;
103 DsColor mTextOnColor;
104
105 const char* mTextOff;
106 DsColor mTextOffColor;
107
108 DsColor mTrackBorderOnColor;
109 DsColor mTrackBorderOffColor;
110
111 DsColor mTrackOnColor;
112 DsColor mTrackOffColor;
113
114 DsColor mKnobBorderOnColor;
115 DsColor mKnobBorderOffColor;
116
117 DsColor mKnobOnColor;
118 DsColor mKnobOffColor;
119
120 uint32_t mTouchTimestamp;
121
122 struct
123 {
124 uint8_t mIsInverted: 1;
125 uint8_t mIsTouchActive: 1;
126 };
127
128 uint8_t mTrackBorderThickness;
129 uint8_t mKnobBorderThickness;
130
131
132 void onSizeChange(void) override final;
133 void onPaint(DsRenderer &renderer) override final;
134 bool onTouch(const DsTouchEvent &event) override final;
135
136 int32_t onSelectionChange(int32_t selection) override final;
137};
138
139
140#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
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
DsSwitch is a class that represents an ON/OFF switch view.
Definition ds_switch.h:24
void setKnobBorderThickness(uint8_t thickness)
Sets the knob border thickness.
DsSwitch(DsView *parent, const DsPoint &pos, const DsSize &size, bool inverted=false)
Creates a DsSwitch object.
void setText(const char *text_on, DsColor color_on, const char *text_off, DsColor color_off, const ds_bitmap_font_t *font)
Sets the text for both ON/OFF states.
void setSwitchKnobColors(DsColor knob_border_on_color, DsColor knob_on_color, DsColor knob_border_off_color, DsColor knob_off_color)
Sets the switch knob colors.
void setTrackBorderThickness(uint8_t thickness)
Sets the track border thickness.
void setTrackProportion(float proportion)
Sets proportion of the track width versus the knob diameter.
void setSwitchTrackColors(DsColor track_border_on_color, DsColor track_on_color, DsColor track_border_off_color, DsColor track_off_color)
Sets the switch track colors.
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
Definition ds_font.h:45