mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 04:51:49 +00:00
refactor: add GUI instance reference to UI nodes
This commit is contained in:
parent
74a94f869c
commit
4c48afbb90
70 changed files with 1133 additions and 832 deletions
|
|
@ -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));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue