Skip to content

Improve highlighting of repainted areas #180

Closed
@lc-soft

Description

@lc-soft

Issuehunt badges

Is your feature request related to a problem? Please describe.

LCUI/src/display.c

Lines 173 to 184 in 4a9516e

/**
* FIXME: Improve highlighting of repainted areas
* Let the highlighted areas disappear after a short
* period of time, just like flashing
*/
if (display.show_rect_border) {
DrawBorder(paint);
}
if (display.mode != LCUI_DMODE_SEAMLESS) {
LCUICursor_Paint(paint);
}
Surface_EndPaint(s, paint);

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() function
    • Compute 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:

highlights-areas

Describe alternatives you've considered
None.

Additional context
None.


IssueHunt Summary

vbalyasnyy vbalyasnyy has been rewarded.

Backers (Total: $10.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions