diff --git a/src/graphics/ui/GUI.hpp b/src/graphics/ui/GUI.hpp index c8bb20e2..92e58db5 100644 --- a/src/graphics/ui/GUI.hpp +++ b/src/graphics/ui/GUI.hpp @@ -89,6 +89,8 @@ namespace gui { void updateTooltip(float delta); void resetTooltip(); public: + static constexpr int CONTEXT_MENU_ZINDEX = 999; + GUI(Engine& engine); ~GUI(); diff --git a/src/graphics/ui/elements/SelectBox.cpp b/src/graphics/ui/elements/SelectBox.cpp index 828a5a8a..608eb6c5 100644 --- a/src/graphics/ui/elements/SelectBox.cpp +++ b/src/graphics/ui/elements/SelectBox.cpp @@ -31,7 +31,7 @@ SelectBox::SelectBox( }); panel->add(button); } - panel->setZIndex(999); + panel->setZIndex(GUI::CONTEXT_MENU_ZINDEX); gui.setFocus(panel); panel->listenDefocus([panel=panel.get()](GUI& gui) { gui.remove(panel); @@ -48,13 +48,20 @@ void SelectBox::setSelected(const Element& selected) { void SelectBox::drawBackground(const DrawContext& pctx, const Assets&) { glm::vec2 pos = calcPos(); auto batch = pctx.getBatch2D(); - batch->texture(nullptr); + batch->untexture(); batch->setColor(calcColor()); batch->rect(pos.x, pos.y, size.x, size.y); batch->setColor({1.0f, 1.0f, 1.0f, 0.333f}); + + int paddingRight = padding.w; + int widthHalf = 8; + int heightHalf = 4; batch->triangle( - pos.x + size.x - 32, pos.y + size.y / 2.0f - 4, - pos.x + size.x - 32 + 16, pos.y + size.y / 2.0f - 4, - pos.x + size.x - 32 + 8, pos.y + size.y / 2.0f + 4 + pos.x + size.x - paddingRight - widthHalf * 2, + pos.y + size.y / 2.0f - heightHalf, + pos.x + size.x - paddingRight, + pos.y + size.y / 2.0f - heightHalf, + pos.x + size.x - paddingRight - widthHalf, + pos.y + size.y / 2.0f + heightHalf ); }