elements
elements copied to clipboard
Refresh Question
When I look at the code, I find that view:: refresh (...) is not a local refresh, and all refreshes are brushed as a whole.
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.
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
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?
Without calling any refresh, just click the mouse button
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
.
https://github.com/cycfi/elements/blob/master/lib/src/view.cpp#L65-L65
the dirty_, view::dirty() unused
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
.
@bizehao is this still an issue for you? If yes, please provide an MCVE (M)inimal (C)omplete (V)erifiable (E)xample.