From 18614ccee9bee1dcd47018dd9371f32deff8c6ba Mon Sep 17 00:00:00 2001 From: Slendi Date: Fri, 10 Oct 2025 03:25:29 +0300 Subject: [PATCH] Remove caret inset Signed-off-by: Slendi --- src/ImGui.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ImGui.cpp b/src/ImGui.cpp index fa3f5b7..1a24ee5 100644 --- a/src/ImGui.cpp +++ b/src/ImGui.cpp @@ -114,7 +114,6 @@ auto encode_utf8(u32 cp) -> std::string constexpr float HORIZONTAL_PADDING = 6.0f; constexpr float VERTICAL_PADDING = 4.0f; constexpr float CARET_WIDTH = 2.0f; -constexpr float CARET_INSET = 1.0f; constexpr double CARET_BLINK_INTERVAL = 0.5; constexpr float CARET_DESCENT_FRACTION = 0.25f; @@ -362,7 +361,8 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, state.caret_visible = true; state.caret_timer += dt; if (state.caret_timer >= CARET_BLINK_INTERVAL) { - int toggles = static_cast(state.caret_timer / CARET_BLINK_INTERVAL); + int toggles = static_cast( + state.caret_timer / CARET_BLINK_INTERVAL); state.caret_timer = std::fmod(state.caret_timer, CARET_BLINK_INTERVAL); if (toggles % 2 == 1) @@ -422,7 +422,8 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, float const max_top = rec.y + rec.height - VERTICAL_PADDING - caret_height; caret_top = std::clamp(caret_top, min_top, max_top); float caret_bottom = caret_top + caret_height; - float const desired_bottom = baseline_y + options.font_size * CARET_DESCENT_FRACTION; + float const desired_bottom + = baseline_y + options.font_size * CARET_DESCENT_FRACTION; if (caret_bottom < desired_bottom) { float const adjust = desired_bottom - caret_bottom; caret_top = std::min(caret_top + adjust, max_top); @@ -443,8 +444,7 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, if (m_focused_id == id && state.caret_visible) { float const caret_x = std::round(rec.x + HORIZONTAL_PADDING - + state.cursor_position.x - state.scroll_offset.x - + CARET_INSET); + + state.cursor_position.x - state.scroll_offset.x); Rectangle caret_rect { caret_x, caret_top,