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

Split the View trait into View and Widget #288

Merged
merged 1 commit into from
Jan 28, 2024

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Jan 23, 2024

This splits the View trait into View and Widget. The Widget has all the functionality of the previous View trait while the new View trait has a method to build widgets and necessary access for view decorators. Widget::id is removed as there where common conflicts with View::id as most widgets implement both View and Widget.

AnyView is a new type equivalent to the old Box<dyn View> as the new View trait is no longer object safe so it can't have dynamic dispatch. The View trait has an any method to convert views into AnyView. That seems to be reasonably ergonomic.

DynStack and VirtualStack are changed to use dynamic dispatch for widgets to reduce generic parameters.

This provides a layer of separation between widgets and views which means you can create APIs in a builder pattern style making the final built widget a function of the configured view state. I have yet to look over and see if there's any problems with View::build being called in a different Scope.

@Zoxc Zoxc force-pushed the view-widget-split branch 2 times, most recently from 8f2e657 to 252dead Compare January 23, 2024 13:44
@Zoxc Zoxc marked this pull request as ready for review January 26, 2024 13:42
@dzhou121 dzhou121 merged commit 1c417d0 into lapce:main Jan 28, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants