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!
29 class BindTextLabel : public BindView
30{
31
32 public:
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
103 private:
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 */
BindTextLabel
The BindTextLabel class represents a text label UI element for use with BindCanvas.
Definition BindTextLabel.hpp:30
BindTextLabel::color
int32_t color
Text color for the text label.
Definition BindTextLabel.hpp:74
BindTextLabel::getBytes
uint16_t getBytes(uint8_t *out) override
Retrieves the bytes representing the text label for synchronization.
Definition BindTextLabel.hpp:84
BindTextLabel::y
int16_t y
Y-coordinate position of the text label.
Definition BindTextLabel.hpp:71
BindTextLabel::fontSize
int16_t fontSize
Font size for the text label.
Definition BindTextLabel.hpp:73
BindTextLabel::cmdId
uint8_t cmdId
Command ID for the text label. See the notes for possible cmdId values.
Definition BindTextLabel.hpp:72
BindTextLabel::BindTextLabel
BindTextLabel()
Constructs a BindTextLabel with a default label.
Definition BindTextLabel.hpp:49
BindTextLabel::x
int16_t x
X-coordinate position of the text label.
Definition BindTextLabel.hpp:70
BindTextLabel::setLabel
void setLabel(const char *cstr)
Sets the label text for the text label.
Definition BindTextLabel.hpp:65
BindView
Definition BindView.hpp:22