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
Provide a way to store AUI layouts in any custom format #24235
base: master
Are you sure you want to change the base?
Conversation
3d713a3
to
63030e0
Compare
@craftyjon @marekr @imciner2 Sorry for mass-tagging but would you have any feedback about this? I'd like to go ahead and finish this, but it would be nice to check that it is fit for purpose, i.e. can be used in KiCad instead of the current serialization system, first. TIA! |
Looks good to me! Thanks! |
LGTM |
This was done in the sample bakefile, apparently unnecessarily, but not in CMakeLists.txt, so add the library there too now that it will be really needed because the sample will use wxXmlDocument after the next commit.
Add wxAuiSerializer and wxAuiDeserializer classes and SaveLayout() and LoadLayout() functions in wxAuiManager using them. Show how these classes can be used to use XML for storing AUI layout in the sample. See wxWidgets#24225.
Although this is unusual in wxWidgets API, it really makes sense to let wxAuiManager perform the scaling, if necessary, instead of asking every implementation of wxAuiSerializer and wxAuiDeserializer to do it on their own, so pass the values as DIPs to the former and assume the values returned by the latter are in DIPs too to make things just work even on the platforms where DIPs are not natively used (i.e. wxMSW).
I've implemented automatic support for saving (and restoring) all coordinates as DIPs as this is the only thing which really makes sense and it seems better to do it, even if this is inconsistent with the rest of wx API, than keep doing the wrong thing for consistency. Please let me know if anybody has objections to this, but personally I'd rather try to find some way to use DIPs in Any other comments are also welcome, of course! |
It is really great to have this support of saving and restoring AUI layouts in wxWidgets. And IMHO using DIPs is exactly the right thing to do. 👍
I'm fully in favor of using DIPs, even if it were not backwards-compatible. |
Using DIPs sounds good to me.
Does it need to be backwards-compatible? If a client application is working around the current behavior by doing DPI-scaling themselves, it seems fine to me for the client just gate that on checking the wxWidgets version. In general I would prefer wx made breaking changes (in major versions) where necessary to improve things, rather than try to avoid any breakage and preserve old/potentially-broken behavior. |
Thanks, I count two votes in favour as sufficient, so let's do it like this.
It would be nicer if it did because it's going to be hard to find all the places that you need to update because if you just change And I think it should be possible to keep compatibility relatively easily. I just hesitate between:
|
Funny how testing can be useful. After checking the current behaviour under wxMSW, I've realized that we already use DIPs there even though we don't do anything for this in our code: |
Also, while testing this, I've realized that saving/restoring layout doesn't actually restore the window sizes. I think this should be done but it doesn't seem to be trivial to implement it, at least just saving/restoring |
Wouldn't it be possible to re-apply the saved size after the initial size is computed? This is what we end up doing as a client application if wx doesn't support save/restore of size internally. |
I wanted to reapply the saved size even before/instead of computing the new size to avoid wasting time doing it, but I guess we can indeed do it later too, as you're probably not going to restore AUI layouts thousands time per second...
If you agree to relicense this code under wx licence, I could just copy it instead of rewriting it, please let me know if I can do it (and where this code is). TIA! |
Sorry I was not clear, I just mean that we would do such a thing in the future if wxWidgets doesn't do it. We have various places that do something like this, but not for wxAUI in particular (well, we have some hacks that do some of it, but I think it's not a good universal solution) To be honest I'm not sure our code should be copied, there are a number of places where we have added "hacks" that seem to work around differences in behavior between different wx platforms that maybe aren't relevant anymore in 3.2, etc. It all needs a rewrite on our side too. |
Add wxAuiSerializer and wxAuiDeserializer classes and SaveLayout() and LoadLayout() functions in wxAuiManager using them.
Show how these classes can be used to use XML for storing AUI layout in the sample.
See #24225.
This still needs to be documented and the example serializer might be moved to the library itself if we think it can be useful. It also should use DIPs as discussed in #24225.
TODO: