Fix colors

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-10 03:56:03 +03:00
parent acf480832a
commit cabf8b23df
5 changed files with 15 additions and 8 deletions

View File

@@ -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);
}
}

View File

@@ -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 {

View File

@@ -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<Theme, ColorScheme> const
enum_array<Theme, ColorScheme> 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<Theme, ColorScheme> const
};
array[Theme::Dark] = {
.foreground = { 255, 255, 255, 255 },
.foreground_preedit = { 255, 255, 255, 255 },
.window =
{
.background = { 0, 0, 0, 100 },

View File

@@ -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<float>(GetScreenWidth()),
static_cast<float>(GetScreenHeight()),
0.0f,
0.0f,
static_cast<float>(GetScreenWidth()),
static_cast<float>(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;

View File

@@ -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