@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 },
|
||||
|
||||
11
src/Tick.cpp
11
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<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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user