Improve highlighting of repainted areas #180
lc-soft posted onGitHub
Is your feature request related to a problem? Please describe. https://github.com/lc-soft/LCUI/blob/4a9516e8eb3bc23b681575653ac31468093d8a2c/src/display.c#L173-L184
Describe the solution you'd like
Remove DrawBorder() function and use FlashPaintArea()
instead, this function should do the following:
Save the repainting area and its paint time into a list.
record.rect = paint_rect; record.paint_time = clock(); LinkedList_Append(&list, &record);
Create a timer to repaint each highlighted area of the list every 10 milliseconds.
int timer = LCUI_SetInterval(10, OnUpdateHighlightArea, NULL);
Check the paint time of the highlighted area:
if (clock() - record.paint_time >= duration) { // remove record and get next area. }
Fill the repainted area with the corresponding transparency color based on the current time:
Create a bitmap named
mask
:LCUI_Graph mask; Graph_Init(&mask); mask.color_type = LCUI_COLOR_TYPE_ARGB; Graph_Create(&mask, record.rect.width, record.rect.height);
Fill color into
mask
:Graph_FillRect(&mask, NULL, RGBA(255, 0, 0, 200), TRUE);
Paint a border to the
mask
. Refer the DrawBorder() functionCompute
mask
opacity:mask.opactiy = 1.0 * (record.paint_time + duration - clock()) / duration;
Render the original content of the painting area and blend
mask
into the canvas:paint = Surface_BeginPaint(s, paint_rect); Widget_Render(record->widget, paint); Graph_Mix(&paint->canvas, &mask); Surface_EndPaint(s, paint);
The final effect should be the same as the paint flashing of Google Chrome:
Describe alternatives you've considered None.
Additional context None.