refactor: add GUI instance reference to UI nodes
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user