Fixed world name label behaviour
This commit is contained in:
@@ -78,9 +78,20 @@ bool UINode::isInside(glm::vec2 pos) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<UINode> UINode::getAt(vec2 pos, shared_ptr<UINode> self) {
|
shared_ptr<UINode> UINode::getAt(vec2 pos, shared_ptr<UINode> self) {
|
||||||
|
if (!interactive) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return isInside(pos) ? self : nullptr;
|
return isInside(pos) ? self : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UINode::isInteractive() const {
|
||||||
|
return interactive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UINode::setInteractive(bool flag) {
|
||||||
|
interactive = flag;
|
||||||
|
}
|
||||||
|
|
||||||
vec2 UINode::calcCoord() const {
|
vec2 UINode::calcCoord() const {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
return coord + parent->calcCoord() + parent->contentOffset();
|
return coord + parent->calcCoord() + parent->contentOffset();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace gui {
|
|||||||
bool hover_ = false;
|
bool hover_ = false;
|
||||||
bool pressed_ = false;
|
bool pressed_ = false;
|
||||||
bool focused_ = false;
|
bool focused_ = false;
|
||||||
|
bool interactive = true;
|
||||||
Align align_ = Align::left;
|
Align align_ = Align::left;
|
||||||
UINode* parent = nullptr;
|
UINode* parent = nullptr;
|
||||||
UINode(glm::vec2 coord, glm::vec2 size);
|
UINode(glm::vec2 coord, glm::vec2 size);
|
||||||
@@ -74,9 +75,12 @@ namespace gui {
|
|||||||
virtual bool isInside(glm::vec2 pos);
|
virtual bool isInside(glm::vec2 pos);
|
||||||
virtual std::shared_ptr<UINode> getAt(glm::vec2 pos, std::shared_ptr<UINode> self);
|
virtual std::shared_ptr<UINode> getAt(glm::vec2 pos, std::shared_ptr<UINode> self);
|
||||||
|
|
||||||
|
virtual bool isInteractive() const;
|
||||||
|
virtual void setInteractive(bool flag);
|
||||||
|
|
||||||
virtual glm::vec2 contentOffset() {return glm::vec2(0.0f);};
|
virtual glm::vec2 contentOffset() {return glm::vec2(0.0f);};
|
||||||
glm::vec2 calcCoord() const;
|
glm::vec2 calcCoord() const;
|
||||||
void setCoord(glm::vec2 coord);
|
virtual void setCoord(glm::vec2 coord);
|
||||||
glm::vec2 size() const;
|
glm::vec2 size() const;
|
||||||
virtual void size(glm::vec2 size);
|
virtual void size(glm::vec2 size);
|
||||||
void _size(glm::vec2 size);
|
void _size(glm::vec2 size);
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ Container::Container(vec2 coord, vec2 size) : UINode(coord, size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shared_ptr<UINode> Container::getAt(vec2 pos, shared_ptr<UINode> self) {
|
shared_ptr<UINode> Container::getAt(vec2 pos, shared_ptr<UINode> self) {
|
||||||
|
if (!interactive) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
if (!isInside(pos)) return nullptr;
|
if (!isInside(pos)) return nullptr;
|
||||||
for (auto node : nodes) {
|
for (auto node : nodes) {
|
||||||
if (!node->visible())
|
if (!node->visible())
|
||||||
|
|||||||
@@ -201,7 +201,10 @@ Panel* create_worlds_panel(Engine* engine) {
|
|||||||
auto btn = std::make_shared<RichButton>(vec2(390, 46));
|
auto btn = std::make_shared<RichButton>(vec2(390, 46));
|
||||||
btn->color(vec4(1.0f, 1.0f, 1.0f, 0.1f));
|
btn->color(vec4(1.0f, 1.0f, 1.0f, 0.1f));
|
||||||
btn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
btn->setHoverColor(vec4(1.0f, 1.0f, 1.0f, 0.17f));
|
||||||
btn->add(std::make_shared<Label>(namews), vec2(8, 8));
|
|
||||||
|
auto label = std::make_shared<Label>(namews);
|
||||||
|
label->setInteractive(false);
|
||||||
|
btn->add(label, vec2(8, 8));
|
||||||
btn->listenAction([=](GUI*) {
|
btn->listenAction([=](GUI*) {
|
||||||
open_world(name, engine);
|
open_world(name, engine);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user