Add submenu arrows to default ui::selector

This commit is contained in:
Nikita Lisitsa 2022-12-22 16:33:46 +03:00
parent 72cbec959d
commit a63bc2eb01

View file

@ -816,10 +816,41 @@ namespace psemek::ui
p.draw_rect(bbox, *st->bg_color);
if (auto i = selected())
{
p.draw_rect(item_box(*i), *st->highlight_color);
for (int i = 0; i < size(); ++i)
{
if (submenu(i))
{
auto box = item_box(i);
auto c = box.corner(1.f, 0.5f);
c[0] -= (*st->inner_margin)[0];
int w = st->font->size()[1];
auto p0 = c;
p0[0] -= w / 2.f;
p0[1] -= w / 2.f;
auto p1 = c;
p1[0] -= w / 2.f;
p1[1] += w / 2.f;
auto sh = geom::cast<float>(*st->shadow_offset);
p.draw_triangle({p0 + sh, p1 + sh, c + sh}, *st->shadow_color);
p.draw_triangle({p0, p1, c}, *st->text_color);
}
}
}
protected:
int submenu_extra() const override
{
auto st = merged_own_style();
return 2 * (*st->inner_margin)[0] + st->font->size()[1] / 2;
}
};
struct edit_impl