diff --git a/src/ImGui.cpp b/src/ImGui.cpp index ef82a0f..cf818a1 100644 --- a/src/ImGui.cpp +++ b/src/ImGui.cpp @@ -655,7 +655,7 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, rec.x + HORIZONTAL_PADDING - state.scroll_offset.x, baseline_y, }; - Color const text_color { 255, 255, 255, 255 }; + Color const &text_color = options.text_color; std::string_view const left_view(str.data(), caret_byte); std::string_view const right_view( str.data() + caret_byte, str.size() - caret_byte); @@ -682,7 +682,7 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, Color const highlight { 120, 160, 255, 100 }; DrawRectangleRec(sel_rect, highlight); } - Color const preedit_color { 200, 220, 255, 255 }; + Color const &preedit_color { options.preedit_color }; m_text_renderer->draw_text(*m_font, std::string_view( state.preedit_text.data(), state.preedit_text.size()), @@ -700,7 +700,7 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec, if (m_focused_id == id && state.caret_visible) { Rectangle caret_rect = state.caret_rect; caret_rect.x = std::round(caret_rect.x); - Color const caret_color { 255, 255, 255, 200 }; + Color const caret_color { text_color }; DrawRectangleRec(caret_rect, caret_color); } } diff --git a/src/ImGui.hpp b/src/ImGui.hpp index 70e3cee..2de4226 100644 --- a/src/ImGui.hpp +++ b/src/ImGui.hpp @@ -15,6 +15,8 @@ constexpr float DEFAULT_FONT_SIZE { 24 }; struct TextInputOptions { bool multiline { false }; float font_size { DEFAULT_FONT_SIZE }; + Color text_color { BLACK }; + Color preedit_color { BLACK }; }; struct ImGui { diff --git a/src/Theme.hpp b/src/Theme.hpp index 10f26a0..4b87ac3 100644 --- a/src/Theme.hpp +++ b/src/Theme.hpp @@ -6,6 +6,7 @@ struct ColorScheme { Color foreground; + Color foreground_preedit; struct { Color background; } window; @@ -23,6 +24,7 @@ constexpr auto make_default_themes() -> enum_array const enum_array array; array[Theme::Light] = { .foreground = { 0, 0, 0, 255 }, + .foreground_preedit = { 0, 0, 0, 255 }, .window = { .background = { 255, 255, 255, 100 }, @@ -30,6 +32,7 @@ constexpr auto make_default_themes() -> enum_array const }; array[Theme::Dark] = { .foreground = { 255, 255, 255, 255 }, + .foreground_preedit = { 255, 255, 255, 255 }, .window = { .background = { 0, 0, 0, 100 }, diff --git a/src/Tick.cpp b/src/Tick.cpp index 91dd3d6..51538b1 100644 --- a/src/Tick.cpp +++ b/src/Tick.cpp @@ -42,12 +42,13 @@ auto App::tick() -> void ImGuiGuard gui_scope(m_gui, rune, m_kbd.ctrl(), m_kbd.shift()); Rectangle const input_rect { - 0.0f, - 0.0f, - static_cast(GetScreenWidth()), - static_cast(GetScreenHeight()), + 0.0f, + 0.0f, + static_cast(GetScreenWidth()), + static_cast(GetScreenHeight()), }; - auto result = m_gui->text_input(1, text_input_data, input_rect); + auto result = m_gui->text_input(1, text_input_data, input_rect, + { .text_color = theme().foreground }); if (result.test(1)) m_ime.surrounding_dirty = true; diff --git a/todo.txt b/todo.txt index 0af30e1..a1e3d6f 100644 --- a/todo.txt +++ b/todo.txt @@ -1,3 +1,4 @@ +- [ ] Fix text moving left and right based on cursor position (right side of cursor is too left) - [ ] Integrate IME directly into ImGui - [ ] Implement selection in ImGui::text_edit - [ ] Implement clipboard copy/paste