Skip to content
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

Remove need to explicitly call SetNeedsLayout -> Have Pos/Dim use events #3485

Open
tig opened this issue May 19, 2024 · 0 comments
Open

Remove need to explicitly call SetNeedsLayout -> Have Pos/Dim use events #3485

tig opened this issue May 19, 2024 · 0 comments
Labels
Milestone

Comments

@tig
Copy link
Collaborator

tig commented May 19, 2024

Pos.Align pushes the envelope on being the most sophisticated Pos/Dim object. The fact that it has multiple configuration properties and the use-cases mean there are interesting cases where a dev will want to modify a PosAlign object.

For example, if X is Pos.Align, a dev may want to posAlign.AlignmentModes &= ^AlignmentMode.AddSpaces without creating a new instance an assinging it to X. If they do that, there's no way for View to know it the state was changed to force a layout.

View.LayoutSubviews is (rightly, IMO) internal so a dev has really no way to indicate a layout is needed other than forcing View.X to be set with a new instance of PosAlign.

This is actually not a common case, so I'm not going to fix it now. However, thinking through how it would work made me realize that if Pos and Dim supported IPropertyNotify (or similar), and on set_X we subscribed, View would always just know layout was needed. There would be no need to ever explicitly call SetLayoutNeeded and would radically remove the times where calling LayoutSubviews was need.

This could be a big perf win (I have not measured the # of times layout happens unnecessarily in a long time, but I did it ages ago and it's an issue). It could also be a correctness win.

Not high pri by any means, but something to noodle on.

@tig tig added the bug label May 19, 2024
@tig tig added this to the V2 Beta milestone May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🆕 Not Triaged
Status: 🆕 Not Triaged
Development

No branches or pull requests

1 participant