From c06a465f518628a05466b3ba59e63473f7133e78 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Fri, 8 Apr 2022 12:37:16 +0300 Subject: [PATCH] Make ui::edit clip renderered text by text box using stencil --- libs/ui/source/edit.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/ui/source/edit.cpp b/libs/ui/source/edit.cpp index ea37bf7d..20eed6de 100644 --- a/libs/ui/source/edit.cpp +++ b/libs/ui/source/edit.cpp @@ -309,6 +309,10 @@ namespace psemek::ui 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) { auto shoffset = offset + geom::cast(*st->text_shadow_offset); @@ -319,6 +323,8 @@ namespace psemek::ui for (auto const & g : cached_state_->glyphs) p.draw_glyph(*cached_state_->font, g.character, g.position + offset, *st->text_color); + p.end_stencil(); + if (caret_visible_) { float x;