Keep the lister text field's right side in view

master
Allen Webster 2020-05-03 06:07:27 -07:00
parent b9b44f481a
commit 25d07a750c
1 changed files with 18 additions and 2 deletions

View File

@ -219,14 +219,30 @@ lister_render(Application_Links *app, Frame_Info frame_info, View_ID view){
}
{
Vec2_f32 p = V2f32(text_field_rect.x0 + 3.f, text_field_rect.y0);
Fancy_Line text_field = {};
push_fancy_string(scratch, &text_field, fcolor_id(defcolor_pop1),
lister->query.string);
push_fancy_stringf(scratch, &text_field, " ");
p = draw_fancy_line(app, face_id, fcolor_zero(), &text_field, p);
// TODO(allen): This is a bit of a hack. Maybe an upgrade to fancy to focus
// more on being good at this and less on overriding everything 10 ways to sunday
// would be good.
block_zero_struct(&text_field);
push_fancy_string(scratch, &text_field, fcolor_id(defcolor_text_default),
lister->text_field.string);
draw_fancy_line(app, face_id, fcolor_zero(), &text_field,
V2f32(text_field_rect.x0 + 3.f, text_field_rect.y0));
f32 width = get_fancy_line_width(app, face_id, &text_field);
f32 cap_width = text_field_rect.x1 - p.x - 6.f;
if (cap_width < width){
Rect_f32 prect = draw_set_clip(app, Rf32(p.x, text_field_rect.y0, p.x + cap_width, text_field_rect.y1));
p.x += cap_width - width;
draw_fancy_line(app, face_id, fcolor_zero(), &text_field, p);
draw_set_clip(app, prect);
}
else{
draw_fancy_line(app, face_id, fcolor_zero(), &text_field, p);
}
}