This commit is contained in:
MihailRis 2025-06-28 02:16:53 +03:00
parent c8f8f66a07
commit 0042dbfb3d
2 changed files with 14 additions and 5 deletions

View File

@ -89,6 +89,8 @@ namespace gui {
void updateTooltip(float delta);
void resetTooltip();
public:
static constexpr int CONTEXT_MENU_ZINDEX = 999;
GUI(Engine& engine);
~GUI();

View File

@ -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
);
}