46 lines
644 B
C++
46 lines
644 B
C++
#ifndef UI_LABEL_H
|
|
#define UI_LABEL_H
|
|
|
|
#include "UIElement.h"
|
|
#include "UIStructs.h"
|
|
|
|
#undef min
|
|
#undef max
|
|
#include <string>
|
|
|
|
class UILabel : public UIElement {
|
|
|
|
std::string txt;
|
|
|
|
Color cBackground = Color::fromRGB(255,255,255);
|
|
Color cText = Color::fromRGB(0,0,0);
|
|
|
|
public:
|
|
|
|
UILabel() {
|
|
;
|
|
}
|
|
|
|
void setText(const std::string& txt) {
|
|
this->txt = txt;
|
|
setNeedsRedraw();
|
|
}
|
|
|
|
void draw(UIPainter& p) {
|
|
|
|
p.setFG(cBackground);
|
|
p.fillRect(rect);
|
|
|
|
//const uint16_t txtW = fnt_f1.getWidth(txt);
|
|
//const uint16_t txtH = fnt_f1.getHeight();
|
|
|
|
p.setFG(cText);
|
|
p.drawText(rect.x, rect.y, txt.c_str());
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
#endif // UI_LABEL_H
|