elements icon indicating copy to clipboard operation
elements copied to clipboard

Refresh Question

Open bizehao opened this issue 2 years ago • 8 comments

When I look at the code, I find that view:: refresh (...) is not a local refresh, and all refreshes are brushed as a whole.

bizehao avatar Mar 23 '22 00:03 bizehao

refresh, like all view functions, has to traverse the element tree. The probably not obvious reason is because each element does not really know it's location. That said, it's not entirely true that "refreshes are brushed as a whole". It just walks the tree to see which elements need to be refreshed, including parts that may overlap.

djowel avatar Mar 23 '22 01:03 djowel

But I wrote a test, a custom control and a button. When I click the button, the custom control will also refresh and view the code. refresh will send a paint signal, on_paint will call the draw function of view, and the remaining elements will be drawn in turn

bizehao avatar Mar 23 '22 01:03 bizehao

But I wrote a test, a custom control and a button. When I click the button, the custom control will also refresh and view the code. refresh will send a paint signal, on_paint will call the draw function of view, and the remaining elements will be drawn in turn

Can you share the code? How are you calling refresh? Are you passing in the element_ptr parameter?

djowel avatar Mar 23 '22 02:03 djowel

Without calling any refresh, just click the mouse button

bizehao avatar Mar 23 '22 02:03 bizehao

Without calling any refresh, just click the mouse button

Hmmm... So what's the relevance of refresh? click is calling refresh? Maybe you can trace what is calling refresh.

djowel avatar Mar 23 '22 03:03 djowel

https://github.com/cycfi/elements/blob/master/lib/src/view.cpp#L65-L65

the dirty_, view::dirty() unused

bizehao avatar Mar 23 '22 05:03 bizehao

That view dirty flag is just for convenience. It will probably be removed, IDK yet...

The actual clip rectangle can be obtained from the canvas::clip_extent(). Some composites, and some potentially expensive to draw elements query the clip_extent to determine what needs to be drawn.

That said, scanning the code, there's a lot of room for optimization because the clip_extent is not very well used. It's only used in text and dynamic_list.

djowel avatar Mar 23 '22 08:03 djowel

@bizehao is this still an issue for you? If yes, please provide an MCVE (M)inimal (C)omplete (V)erifiable (E)xample.

djowel avatar Nov 24 '23 00:11 djowel