@@ -116,6 +116,7 @@ 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;
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -409,13 +410,24 @@ auto ImGui::text_input(std::size_t id, std::pmr::string &str, Rectangle rec,
|
||||
|
||||
float const text_top = rec.y + VERTICAL_PADDING;
|
||||
float const baseline_y = text_top + options.font_size;
|
||||
float caret_height = std::min(options.font_size,
|
||||
std::max(0.0f, rec.height - 2.0f * VERTICAL_PADDING));
|
||||
float const max_caret_height
|
||||
= std::max(0.0f, rec.height - 2.0f * VERTICAL_PADDING);
|
||||
float caret_height = options.font_size * (1.0f + CARET_DESCENT_FRACTION);
|
||||
caret_height = std::min(caret_height,
|
||||
max_caret_height > 0.0f ? max_caret_height : caret_height);
|
||||
if (caret_height <= 0.0f)
|
||||
caret_height = options.font_size;
|
||||
float caret_top = baseline_y - caret_height;
|
||||
caret_top = std::clamp(caret_top, rec.y + VERTICAL_PADDING,
|
||||
rec.y + rec.height - VERTICAL_PADDING - caret_height);
|
||||
float caret_top = baseline_y - options.font_size;
|
||||
float const min_top = rec.y + VERTICAL_PADDING;
|
||||
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;
|
||||
if (caret_bottom < desired_bottom) {
|
||||
float const adjust = desired_bottom - caret_bottom;
|
||||
caret_top = std::min(caret_top + adjust, max_top);
|
||||
caret_bottom = caret_top + caret_height;
|
||||
}
|
||||
state.cursor_position.y = caret_top;
|
||||
|
||||
BeginScissorMode(rec.x, rec.y, rec.width, rec.height);
|
||||
|
||||
@@ -29,7 +29,6 @@ auto App::tick() -> void
|
||||
|
||||
ClearBackground(theme().window.background);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
{
|
||||
assert(m_gui);
|
||||
u32 rune { 0 };
|
||||
|
||||
Reference in New Issue
Block a user