Bind
C++ UI framework for Arduino
 
Loading...
Searching...
No Matches
BindTextLabel.hpp
1#ifndef __BINDTEXTLABEL_H
2#define __BINDTEXTLABEL_H
3#include "BindView.hpp"
4#include "BindUtils.hpp"
5// TODO: Extract the class to a serprate .h and .c file! Now!
29class BindTextLabel : public BindView
30{
31
32public:
41 BindTextLabel(const char *cstr);
42
49 BindTextLabel() :BindTextLabel("TextLabel"){}
50
51 [[deprecated("Use setLabel instead")]]
52 void setlabel(const char *cstr)
53 {
54 setLabel(cstr);
55 }
56
65 void setLabel(const char *cstr)
66 {
67 str = cstr;
68 }
69
70 int16_t x;
71 int16_t y;
72 uint8_t cmdId = 0;
73 int16_t fontSize;
74 int32_t color;
75
84 uint16_t getBytes(uint8_t *out) override
85 {
86 offset = 0;
87 strLength = strlen(str);
88 if (strLength > MAX_STRING_LENGTH_TERMINAL)
89 {
90 strLength = MAX_STRING_LENGTH_TERMINAL;
91 }
92 copyAndOffset(out, &offset, &objID, sizeof(objID));
93 copyAndOffset(out, &offset, &x, sizeof(x));
94 copyAndOffset(out, &offset, &y, sizeof(y));
95 copyAndOffset(out, &offset, &tag, sizeof(tag));
96 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
97 copyAndOffset(out, &offset, &fontSize, sizeof(fontSize));
98 copyAndOffset(out, &offset, &color, sizeof(color));
99 copyAndOffset(out, &offset, str, strLength);
100 return offset;
101 }
102
103private:
104 uint8_t objID = BIND_ID_LABEL;
105 uint16_t offset = 0;
106 int strLength = 0;
107 const char *str;
108 static int16_t tagIndex;
109};
110
111#endif /* __BINDTEXTLABEL_H */
The BindTextLabel class represents a text label UI element for use with BindCanvas.
Definition BindTextLabel.hpp:30
int32_t color
Text color for the text label.
Definition BindTextLabel.hpp:74
uint16_t getBytes(uint8_t *out) override
Retrieves the bytes representing the text label for synchronization.
Definition BindTextLabel.hpp:84
int16_t y
Y-coordinate position of the text label.
Definition BindTextLabel.hpp:71
int16_t fontSize
Font size for the text label.
Definition BindTextLabel.hpp:73
uint8_t cmdId
Command ID for the text label. See the notes for possible cmdId values.
Definition BindTextLabel.hpp:72
BindTextLabel()
Constructs a BindTextLabel with a default label.
Definition BindTextLabel.hpp:49
int16_t x
X-coordinate position of the text label.
Definition BindTextLabel.hpp:70
void setLabel(const char *cstr)
Sets the label text for the text label.
Definition BindTextLabel.hpp:65
Definition BindView.hpp:26