@@ -143,11 +143,14 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
143143 cursor_color .w *= box -> parent -> parent -> focus_active_t ;
144144 Vec4F32 select_color = ui_color_from_tags_key_name (box -> tags_key , str8_lit ("selection" ));
145145 select_color .w *= (box -> parent -> parent -> focus_active_t * 0.2f + 0.8f );
146+ Vec4F32 trail_color = cursor_color ;
147+ trail_color .w *= 0.25f ;
146148 Vec2F32 text_position = ui_box_text_position (box );
147149 String8 edited_string = draw_data -> edited_string ;
148150 TxtPt cursor = draw_data -> cursor ;
149151 TxtPt mark = draw_data -> mark ;
150152 F32 cursor_pixel_off = fnt_dim_from_tag_size_string (font , font_size , 0 , tab_size , str8_prefix (edited_string , cursor .column - 1 )).x ;
153+ F32 cursor_pixel_off__animated = ui_anim (ui_key_from_stringf (box -> key , "cursor_off_px" ), cursor_pixel_off );
151154 F32 mark_pixel_off = fnt_dim_from_tag_size_string (font , font_size , 0 , tab_size , str8_prefix (edited_string , mark .column - 1 )).x ;
152155 F32 cursor_thickness = ClampBot (1.f , floor_f32 (font_size /10.f ));
153156 Rng2F32 cursor_rect =
@@ -157,6 +160,14 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
157160 text_position .x + cursor_pixel_off + cursor_thickness ,
158161 box -> parent -> parent -> rect .y1 - ui_top_font_size ()* 0.5f ,
159162 };
163+ Rng1F32 trail_off_span = r1f32 (cursor_pixel_off , cursor_pixel_off__animated );
164+ Rng2F32 trail_rect =
165+ {
166+ text_position .x + trail_off_span .min ,
167+ cursor_rect .y0 ,
168+ text_position .x + trail_off_span .max ,
169+ cursor_rect .y1 ,
170+ };
160171 Rng2F32 mark_rect =
161172 {
162173 text_position .x + mark_pixel_off - cursor_thickness ,
@@ -167,6 +178,17 @@ internal UI_BOX_CUSTOM_DRAW(ui_line_edit_draw)
167178 Rng2F32 select_rect = union_2f32 (cursor_rect , mark_rect );
168179 dr_rect (select_rect , select_color , font_size /2.f , 0 , 1.f );
169180 dr_rect (cursor_rect , cursor_color , 0.f , 0 , 0.f );
181+ R_Rect2DInst * trail_inst = dr_rect (trail_rect , trail_color , ui_top_font_size ()* 0.2f , 0 , 1.f );
182+ if (cursor_pixel_off > cursor_pixel_off__animated )
183+ {
184+ trail_inst -> colors [Corner_00 ].w *= 0.1f ;
185+ trail_inst -> colors [Corner_01 ].w *= 0.1f ;
186+ }
187+ else
188+ {
189+ trail_inst -> colors [Corner_10 ].w *= 0.1f ;
190+ trail_inst -> colors [Corner_11 ].w *= 0.1f ;
191+ }
170192}
171193
172194internal UI_Signal
0 commit comments