Bind
C++ UI toolkit 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!
28class BindTextLabel : public BindView
29{
30
31public:
40 BindTextLabel(const char *cstr);
41
48 BindTextLabel() :BindTextLabel("TextLabel"){}
49
58 void setlabel(const char *cstr)
59 {
60 str = cstr;
61 }
62
63 int16_t x;
64 int16_t y;
65 uint8_t cmdId = 0;
66 int16_t fontSize;
67 int32_t color;
68
77 uint16_t getBytes(uint8_t *out) override
78 {
79 offset = 0;
80 strLength = strlen(str);
81 if (strLength > MAX_STRING_LENGTH_TERMINAL)
82 {
83 strLength = MAX_STRING_LENGTH_TERMINAL;
84 }
85 copyAndOffset(out, &offset, &objID, sizeof(objID));
86 copyAndOffset(out, &offset, &x, sizeof(x));
87 copyAndOffset(out, &offset, &y, sizeof(y));
88 copyAndOffset(out, &offset, &tag, sizeof(tag));
89 copyAndOffset(out, &offset, &cmdId, sizeof(cmdId));
90 copyAndOffset(out, &offset, &fontSize, sizeof(fontSize));
91 copyAndOffset(out, &offset, &color, sizeof(color));
92 copyAndOffset(out, &offset, str, strLength);
93 return offset;
94 }
95
96private:
97 uint8_t objID = BIND_ID_LABEL;
98 uint16_t offset = 0;
99 int strLength = 0;
100 const char *str;
101 static int16_t tagIndex;
102};
103
104#endif /* __BINDTEXTLABEL_H */
The BindTextLabel class represents a text label UI element for use with BindCanvas.
Definition BindTextLabel.hpp:29
int32_t color
Text color for the text label.
Definition BindTextLabel.hpp:67
uint16_t getBytes(uint8_t *out) override
Retrieves the bytes representing the text label for synchronization.
Definition BindTextLabel.hpp:77
int16_t y
Y-coordinate position of the text label.
Definition BindTextLabel.hpp:64
int16_t fontSize
Font size for the text label.
Definition BindTextLabel.hpp:66
uint8_t cmdId
Command ID for the text label. See the notes for possible cmdId values.
Definition BindTextLabel.hpp:65
BindTextLabel()
Constructs a BindTextLabel with a default label.
Definition BindTextLabel.hpp:48
void setlabel(const char *cstr)
Sets the label text for the text label.
Definition BindTextLabel.hpp:58
int16_t x
X-coordinate position of the text label.
Definition BindTextLabel.hpp:63
Definition BindView.hpp:22