refactor: add GUI instance reference to UI nodes

This commit is contained in:
MihailRis
2025-04-02 14:55:53 +03:00
parent 74a94f869c
commit 4c48afbb90
70 changed files with 1133 additions and 832 deletions
+12 -7
View File
@@ -2,8 +2,8 @@
#include <utility>
#include "Panel.hpp"
#include "Label.hpp"
#include "Panel.hpp"
namespace gui {
class CheckBox : public UINode {
@@ -13,11 +13,12 @@ namespace gui {
boolconsumer consumer = nullptr;
bool checked = false;
public:
CheckBox(bool checked=false);
explicit CheckBox(GUI& gui, bool checked = false);
virtual void draw(const DrawContext& pctx, const Assets& assets) override;
virtual void draw(const DrawContext& pctx, const Assets& assets)
override;
virtual void mouseRelease(GUI*, int x, int y) override;
virtual void mouseRelease(int x, int y) override;
virtual void setSupplier(boolsupplier supplier);
virtual void setConsumer(boolconsumer consumer);
@@ -25,8 +26,7 @@ namespace gui {
virtual CheckBox* setChecked(bool flag);
virtual bool isChecked() const {
if (supplier)
return supplier();
if (supplier) return supplier();
return checked;
}
};
@@ -36,7 +36,12 @@ namespace gui {
std::shared_ptr<CheckBox> checkbox;
std::shared_ptr<Label> label;
public:
FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked=false);
explicit FullCheckBox(
GUI& gui,
const std::wstring& text,
glm::vec2 size,
bool checked = false
);
virtual void setSupplier(boolsupplier supplier) {
checkbox->setSupplier(std::move(supplier));