mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 05:21:49 +00:00
UiXmlReader added (WIP)
This commit is contained in:
parent
e9efdb0e7b
commit
86412a28ec
6 changed files with 269 additions and 13 deletions
|
|
@ -97,6 +97,7 @@ Button::Button(std::shared_ptr<UINode> content, glm::vec4 padding)
|
|||
add(content);
|
||||
setScrollable(false);
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||
content->setInteractive(false);
|
||||
}
|
||||
|
||||
Button::Button(
|
||||
|
|
@ -122,6 +123,7 @@ Button::Button(
|
|||
label = std::make_shared<Label>(text);
|
||||
label->setAlign(Align::center);
|
||||
label->setSize(size-vec2(padding.z+padding.x, padding.w+padding.y));
|
||||
label->setInteractive(false);
|
||||
add(label);
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.15f, 0.75f));
|
||||
}
|
||||
|
|
@ -161,10 +163,6 @@ void Button::drawBackground(const GfxContext* pctx, Assets* assets) {
|
|||
batch->rect(coord.x, coord.y, size.x, size.y);
|
||||
}
|
||||
|
||||
std::shared_ptr<UINode> Button::getAt(vec2 pos, std::shared_ptr<UINode> self) {
|
||||
return UINode::getAt(pos, self);
|
||||
}
|
||||
|
||||
void Button::mouseRelease(GUI* gui, int x, int y) {
|
||||
UINode::mouseRelease(gui, x, y);
|
||||
if (isInside(vec2(x, y))) {
|
||||
|
|
@ -219,6 +217,7 @@ TextBox::TextBox(std::wstring placeholder, vec4 padding)
|
|||
input(L""),
|
||||
placeholder(placeholder) {
|
||||
label = std::make_shared<Label>(L"");
|
||||
label->setSize(size-vec2(padding.z+padding.x, padding.w+padding.y));
|
||||
add(label);
|
||||
setHoverColor(glm::vec4(0.05f, 0.1f, 0.2f, 0.75f));
|
||||
}
|
||||
|
|
@ -289,6 +288,11 @@ void TextBox::focus(GUI* gui) {
|
|||
}
|
||||
}
|
||||
|
||||
void TextBox::refresh() {
|
||||
Panel::refresh();
|
||||
label->setSize(size-vec2(padding.z+padding.x, padding.w+padding.y));
|
||||
}
|
||||
|
||||
void TextBox::keyPressed(int key) {
|
||||
if (key == keycode::BACKSPACE) {
|
||||
if (!input.empty()){
|
||||
|
|
@ -327,13 +331,13 @@ void TextBox::textValidator(wstringchecker validator) {
|
|||
this->validator = validator;
|
||||
}
|
||||
|
||||
std::wstring TextBox::text() const {
|
||||
std::wstring TextBox::getText() const {
|
||||
if (input.empty())
|
||||
return placeholder;
|
||||
return input;
|
||||
}
|
||||
|
||||
void TextBox::text(std::wstring value) {
|
||||
void TextBox::setText(std::wstring value) {
|
||||
this->input = value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue