mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +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,13 +2,14 @@
|
|||
|
||||
#include <utility>
|
||||
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "Label.hpp"
|
||||
#include "graphics/core/Batch2D.hpp"
|
||||
#include "graphics/core/DrawContext.hpp"
|
||||
|
||||
using namespace gui;
|
||||
|
||||
CheckBox::CheckBox(bool checked) : UINode(glm::vec2(32.0f)), checked(checked) {
|
||||
CheckBox::CheckBox(GUI& gui, bool checked)
|
||||
: UINode(gui, glm::vec2(32.0f)), checked(checked) {
|
||||
setColor({0.0f, 0.0f, 0.0f, 0.5f});
|
||||
setHoverColor({0.05f, 0.1f, 0.2f, 0.75f});
|
||||
}
|
||||
|
|
@ -24,7 +25,7 @@ void CheckBox::draw(const DrawContext& pctx, const Assets&) {
|
|||
batch->rect(pos.x, pos.y, size.x, size.y);
|
||||
}
|
||||
|
||||
void CheckBox::mouseRelease(GUI*, int, int) {
|
||||
void CheckBox::mouseRelease(int, int) {
|
||||
checked = !checked;
|
||||
if (consumer) {
|
||||
consumer(checked);
|
||||
|
|
@ -44,15 +45,17 @@ CheckBox* CheckBox::setChecked(bool flag) {
|
|||
return this;
|
||||
}
|
||||
|
||||
FullCheckBox::FullCheckBox(const std::wstring& text, glm::vec2 size, bool checked)
|
||||
: Panel(size),
|
||||
checkbox(std::make_shared<CheckBox>(checked)),
|
||||
label(std::make_shared<Label>(text)) {
|
||||
FullCheckBox::FullCheckBox(
|
||||
GUI& gui, const std::wstring& text, glm::vec2 size, bool checked
|
||||
)
|
||||
: Panel(gui, size),
|
||||
checkbox(std::make_shared<CheckBox>(gui, checked)),
|
||||
label(std::make_shared<Label>(gui, text)) {
|
||||
setColor(glm::vec4(0.0f));
|
||||
setOrientation(Orientation::horizontal);
|
||||
|
||||
add(checkbox);
|
||||
|
||||
|
||||
label->setMargin(glm::vec4(5.f, 5.f, 0.f, 0.f));
|
||||
add(label);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue