cleanup element classes

This commit is contained in:
MihailRis 2026-08-07 22:39:48 +03:00
parent 660bd0a5d3
commit 8c5a549773
11 changed files with 141 additions and 141 deletions

View file

@ -6,7 +6,7 @@
#include "Panel.hpp"
namespace gui {
class CheckBox : public UINode {
class CheckBox final : public UINode {
protected:
glm::vec4 checkColor {1.0f, 1.0f, 1.0f, 0.4f};
boolsupplier supplier = nullptr;
@ -15,23 +15,22 @@ namespace gui {
public:
explicit CheckBox(GUI& gui, bool checked = false);
virtual void draw(const DrawContext& pctx, const Assets& assets)
override;
void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void mouseRelease(int x, int y) override;
void mouseRelease(int x, int y) override;
virtual void setSupplier(boolsupplier supplier);
virtual void setConsumer(boolconsumer consumer);
void setSupplier(boolsupplier supplier);
void setConsumer(boolconsumer consumer);
virtual CheckBox* setChecked(bool flag);
CheckBox* setChecked(bool flag);
virtual bool isChecked() const {
bool isChecked() const {
if (supplier) return supplier();
return checked;
}
};
class FullCheckBox : public Panel {
class FullCheckBox final : public Panel {
protected:
std::shared_ptr<CheckBox> checkbox;
std::shared_ptr<Label> label;
@ -43,28 +42,28 @@ namespace gui {
bool checked = false
);
virtual void setSupplier(boolsupplier supplier) {
void setSupplier(boolsupplier supplier) {
checkbox->setSupplier(std::move(supplier));
}
virtual void setConsumer(boolconsumer consumer) {
void setConsumer(boolconsumer consumer) {
checkbox->setConsumer(std::move(consumer));
}
virtual void setChecked(bool flag) {
void setChecked(bool flag) {
checkbox->setChecked(flag);
}
virtual bool isChecked() const {
bool isChecked() const {
return checkbox->isChecked();
}
virtual void setTooltip(const std::wstring& text) override {
void setTooltip(const std::wstring& text) override {
Panel::setTooltip(text);
checkbox->setTooltip(text);
}
virtual void setSize(const glm::vec2& new_size) override {
void setSize(const glm::vec2& new_size) override {
Panel::setSize(new_size);
checkbox->setSize(glm::vec2(size.y, size.y));
}