Replace Old Widgets
This commit is contained in:
parent
03da5e41d6
commit
c41dc20132
81 changed files with 388 additions and 278 deletions
|
|
@ -1,46 +0,0 @@
|
|||
|
||||
#include "ButtonWidget.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
ButtonWidget::ButtonWidget() {
|
||||
this->setArea({ 0, 0, 100, 30 });
|
||||
this->mChildWidgets.pushBack(&mLabel);
|
||||
}
|
||||
|
||||
ButtonWidget::ButtonWidget(const std::string& label, const tp::RectF& aArea) {
|
||||
this->setArea(aArea);
|
||||
mLabel.mLabel = label;
|
||||
this->mChildWidgets.pushBack(&mLabel);
|
||||
}
|
||||
|
||||
bool ButtonWidget::isFired() { return this->isReleased(); }
|
||||
|
||||
void ButtonWidget::eventProcess(const Events&) {
|
||||
mLabel.setArea(this->mArea);
|
||||
|
||||
if (isFired()) {
|
||||
mCallback();
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonWidget::eventDraw(Canvas& canvas) {
|
||||
if (this->isHolding()) {
|
||||
canvas.rect(this->mArea, pressedColor, rounding);
|
||||
} else if (this->isFocus()) {
|
||||
canvas.rect(this->mArea, hoveredColor, rounding);
|
||||
} else {
|
||||
canvas.rect(this->mArea, accentColor, rounding);
|
||||
}
|
||||
}
|
||||
|
||||
void ButtonWidget::setLabel(const std::string& string) { mLabel.mLabel = string; }
|
||||
|
||||
void ButtonWidget::eventUpdateConfiguration(WidgetManager& wm) {
|
||||
wm.setActiveId("Button");
|
||||
|
||||
pressedColor = wm.getColor("Pressed", "Action");
|
||||
hoveredColor = wm.getColor("Hovered", "Interaction");
|
||||
accentColor = wm.getColor("Default", "Accent");
|
||||
rounding = wm.getNumber("Rounding", "Rounding");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue