Make ui::edit clip renderered text by text box using stencil

This commit is contained in:
Nikita Lisitsa 2022-04-08 12:37:16 +03:00
parent 5066dd6494
commit c06a465f51

View file

@ -309,6 +309,10 @@ namespace psemek::ui
break; break;
} }
p.begin_stencil();
p.draw_rect(text_box_, {0, 0, 0, 255});
p.commit_stencil();
if (*st->text_shadow_offset != geom::vector{0, 0} && (*st->shadow_color)[3] != 0) if (*st->text_shadow_offset != geom::vector{0, 0} && (*st->shadow_color)[3] != 0)
{ {
auto shoffset = offset + geom::cast<float>(*st->text_shadow_offset); auto shoffset = offset + geom::cast<float>(*st->text_shadow_offset);
@ -319,6 +323,8 @@ namespace psemek::ui
for (auto const & g : cached_state_->glyphs) for (auto const & g : cached_state_->glyphs)
p.draw_glyph(*cached_state_->font, g.character, g.position + offset, *st->text_color); p.draw_glyph(*cached_state_->font, g.character, g.position + offset, *st->text_color);
p.end_stencil();
if (caret_visible_) if (caret_visible_)
{ {
float x; float x;