New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RefreshArea() member function to wxGrid #22826
Conversation
This will make refreshing frozen grid windows much easier and a lot of functions much more clear an concise
This is more neat and less error prone
The affected functions already accept NULL as a valid argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I find the new function very confusing. Maybe it's just me, but it also looks like it's only used in 2 cases:
- Refresh several areas completely.
- Refresh part of a single area.
And this seems to indicate to me that we need 2 different functions here and not one doing everything. Am I missing some reason we need to do all in a single function?
First, thanks for the review. In the above image, the nine (09) child windows are all there: Suppose now that the selection rectangle In addition, if the labels need to be refreshed to reflect the selected state, the following For me i find this feature extremely useful, i.e. no need to test for any frozen part at all. |
One that refreshes part of one area of the grid and takes a wxRect as parameter. the other one can refresh one or more areas entirely. This makes sense and less confusing because a rectangle cannot be shared with two separate/unrelated areas. Notice that this commit undoes this 3bb8613 (Move wxGridArea enum to private header)
… windows Also, don't do anything if the corresponding label window is hidden
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes, they make things clearer, but now it seems even more obvious that we don't actually need a special function for a single area refresh: it's basically only used once and it's more clear to just do it there.
The other overload is, of course, nice and useful to have.
Also make wxGA_Corner part of wxGA_Labels so it will be refreshed when the row and col labels are refreshed
This function expects the rectangle to be calculated relative to the wxGrid window itself (with the origin (0, 0) in the top left corner of the window) which is the caller's responsibility to make sure. Additionally, wxScrolledCanvas::Refresh() will properly refresh the intersection of subwindows with the rectangle rect. so no need to do anything special inside the function which is at best an unnecessary complication.
return true; | ||
} | ||
|
||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! we can just return labelArea != -1;
ddd8725
to
2b848f6
Compare
No need to worry about frozen windows anymore as wxGrid::Refresh() will do the right job for them anyhow.
Do not refresh the unaffected label window unnecessarily due to the last call to Refresh(). In fact, we can do even better by refreshing the grid window the same way wxGrid::DoSet{Row,Col}Size() do that. but for now let's continue with the simple and straightforward way to refresh the grid.
2b848f6
to
a2f039e
Compare
No need to do any refresh inside AutoSizeColOrRow() as it is already done inside DoSet{Row,Col}Size() when Set{Row,Col}Size() is called.
Calling Refresh() with no explicit rectangle will refresh the entire window anyhow.
FYI in this function wxGrid::DoSetRowSize() (also true for wxGrid::DoSetColSize()) IMHO this is not a problem (i.e. to execute the refresh code resulting in another refresh request to be queued) because GTK 3 is optimized in such a way the drawing is done only once. but the problem is in the user not expecting a refresh if Personally, I haven't had any issues with this, and just wanted to let you know so it can be documented. Thank you. |
So should we just move |
What I was thinking is to apply something like this:
What do you think ? |
I'd rather avoid having platform checks in the generic code. I also have to wonder how important is it to try to refresh just parts of the window here. If we're using double buffering (and we do), is it really any better than just refreshing everything? And if we do this, we could do it unconditionally and it shouldn't do any harm in wxGTK as 2 refreshes should be coalesced anyhow. |
I hate platform checks in the generic code too.
I did some measurments on
and guess what ? So if you (or someone else) don't object to apply the patch above I'll do that ? |
I think partial refreshing is just generally not that useful when using double buffering as the entire window is going to be blitted to the screen anyhow. I guess there could be some exceptions when drawing itself takes a relatively long time and we want to optimize away redrawing of the unchanged parts even off screen, but normally this shouldn't be the case. So yes, let's simplify the code here by just refreshing everything. |
Will be replaced with another one soon! |
The idea here is to issue a refresh request on the
wxGrid
object itself and rely on the underlying toolkit to dispatch the request to the child windows intersecting the refreshed rectangle. Notice that there is no performance penalty here because the paint handler of the grid itself is trivial (does nothing in fact) and the number of its children is nine (09) at most, and this is not a problem at all (in practice) to know which part needs to be refreshed from the request.Tested and works correctly under Windows 10 and Linux. but i have no Mac machine to test this on, sorry