gui: added UINode.zindex
This commit is contained in:
parent
e1b2d8f7e4
commit
b6f675a540
@ -143,6 +143,14 @@ glm::vec4 UINode::getMargin() const {
|
||||
return margin;
|
||||
}
|
||||
|
||||
void UINode::setZIndex(int zindex) {
|
||||
this->zindex = zindex;
|
||||
}
|
||||
|
||||
int UINode::getZIndex() const {
|
||||
return zindex;
|
||||
}
|
||||
|
||||
void UINode::lock() {
|
||||
}
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ namespace gui {
|
||||
bool focused = false;
|
||||
bool interactive = true;
|
||||
bool resizing = true;
|
||||
int zindex = 0;
|
||||
Align align = Align::left;
|
||||
UINode* parent = nullptr;
|
||||
UINode(glm::vec2 coord, glm::vec2 size);
|
||||
@ -68,6 +69,9 @@ namespace gui {
|
||||
virtual void setMargin(glm::vec4 margin);
|
||||
glm::vec4 getMargin() const;
|
||||
|
||||
virtual void setZIndex(int idx);
|
||||
int getZIndex() const;
|
||||
|
||||
virtual void focus(GUI*) {focused = true;}
|
||||
virtual void click(GUI*, int x, int y);
|
||||
virtual void clicked(GUI*, int button) {}
|
||||
|
||||
@ -37,6 +37,9 @@ static void _readUINode(xml::xmlelement element, UINode& node) {
|
||||
if (element->has("margin")) {
|
||||
node.setMargin(element->attr("margin").asVec4());
|
||||
}
|
||||
if (element->has("z-index")) {
|
||||
node.setZIndex(element->attr("z-index").asInt());
|
||||
}
|
||||
std::string alignName = element->attr("align", "").getText();
|
||||
node.setAlign(align_from_string(alignName, node.getAlign()));
|
||||
}
|
||||
|
||||
@ -144,6 +144,12 @@ void Container::setSize(glm::vec2 size) {
|
||||
refresh();
|
||||
}
|
||||
|
||||
void Container::refresh() {
|
||||
std::stable_sort(nodes.begin(), nodes.end(), [](const auto& a, const auto& b) {
|
||||
return a->getZIndex() < b->getZIndex();
|
||||
});
|
||||
}
|
||||
|
||||
const std::vector<std::shared_ptr<UINode>>& Container::getNodes() const {
|
||||
return nodes;
|
||||
}
|
||||
@ -190,6 +196,7 @@ void Panel::add(std::shared_ptr<UINode> node) {
|
||||
}
|
||||
|
||||
void Panel::refresh() {
|
||||
UINode::refresh();
|
||||
float x = padding.x;
|
||||
float y = padding.y;
|
||||
vec2 size = getSize();
|
||||
|
||||
@ -47,6 +47,7 @@ namespace gui {
|
||||
void listenInterval(float interval, ontimeout callback, int repeat=-1);
|
||||
virtual glm::vec2 contentOffset() override {return glm::vec2(0.0f, scroll);};
|
||||
virtual void setSize(glm::vec2 size) override;
|
||||
virtual void refresh() override;
|
||||
|
||||
const std::vector<std::shared_ptr<UINode>>& getNodes() const;
|
||||
};
|
||||
|
||||
@ -250,6 +250,8 @@ HudRenderer::HudRenderer(Engine* engine, LevelFrontend* frontend)
|
||||
|
||||
debugPanel = createDebugPanel(engine);
|
||||
menu->reset();
|
||||
|
||||
debugPanel->setZIndex(1);
|
||||
|
||||
gui->addBack(darkOverlay);
|
||||
gui->addBack(hotbarView);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user