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, rec.x + HORIZONTAL_PADDING - state.scroll_offset.x,
baseline_y, 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 left_view(str.data(), caret_byte);
std::string_view const right_view( std::string_view const right_view(
str.data() + caret_byte, str.size() - caret_byte); 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 }; Color const highlight { 120, 160, 255, 100 };
DrawRectangleRec(sel_rect, highlight); 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, m_text_renderer->draw_text(*m_font,
std::string_view( std::string_view(
state.preedit_text.data(), state.preedit_text.size()), 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) { if (m_focused_id == id && state.caret_visible) {
Rectangle caret_rect = state.caret_rect; Rectangle caret_rect = state.caret_rect;
caret_rect.x = std::round(caret_rect.x); 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); DrawRectangleRec(caret_rect, caret_color);
} }
} }

View File

@@ -15,6 +15,8 @@ constexpr float DEFAULT_FONT_SIZE { 24 };
struct TextInputOptions { struct TextInputOptions {
bool multiline { false }; bool multiline { false };
float font_size { DEFAULT_FONT_SIZE }; float font_size { DEFAULT_FONT_SIZE };
Color text_color { BLACK };
Color preedit_color { BLACK };
}; };
struct ImGui { struct ImGui {

View File

@@ -6,6 +6,7 @@
struct ColorScheme { struct ColorScheme {
Color foreground; Color foreground;
Color foreground_preedit;
struct { struct {
Color background; Color background;
} window; } window;
@@ -23,6 +24,7 @@ constexpr auto make_default_themes() -> enum_array<Theme, ColorScheme> const
enum_array<Theme, ColorScheme> array; enum_array<Theme, ColorScheme> array;
array[Theme::Light] = { array[Theme::Light] = {
.foreground = { 0, 0, 0, 255 }, .foreground = { 0, 0, 0, 255 },
.foreground_preedit = { 0, 0, 0, 255 },
.window = .window =
{ {
.background = { 255, 255, 255, 100 }, .background = { 255, 255, 255, 100 },
@@ -30,6 +32,7 @@ constexpr auto make_default_themes() -> enum_array<Theme, ColorScheme> const
}; };
array[Theme::Dark] = { array[Theme::Dark] = {
.foreground = { 255, 255, 255, 255 }, .foreground = { 255, 255, 255, 255 },
.foreground_preedit = { 255, 255, 255, 255 },
.window = .window =
{ {
.background = { 0, 0, 0, 100 }, .background = { 0, 0, 0, 100 },

View File

@@ -47,7 +47,8 @@ auto App::tick() -> void
static_cast<float>(GetScreenWidth()), static_cast<float>(GetScreenWidth()),
static_cast<float>(GetScreenHeight()), 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)) if (result.test(1))
m_ime.surrounding_dirty = true; 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 - [ ] Integrate IME directly into ImGui
- [ ] Implement selection in ImGui::text_edit - [ ] Implement selection in ImGui::text_edit
- [ ] Implement clipboard copy/paste - [ ] Implement clipboard copy/paste