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

ECS #432

Merged
merged 25 commits into from
May 8, 2024
Merged

ECS #432

merged 25 commits into from
May 8, 2024

Conversation

dzhou121
Copy link
Contributor

This PR adds VIEW_STORAGE which stores all the View, ViewState, parent/child relationship between views, and TaffyTree. The benefits:

  • No need for ViewData any more. ViewData was introduced so that it can store the initial Style, EventListener without go through the UpdateMessages. Now we have "direct" access to ViewState so this is not needed.
  • Lots of other updates don't need to go through the UpdateMessages
  • update_state doesn't need to go through the view tree by id_path dispatch, since we have "direct" access to View
  • The taffy layout of an view can be accessed anywhere without the need of AppState

@jrmoulton
Copy link
Collaborator

For what I care about this looks great to me. Removes the boilerplate for view creation and no longer has duplicated locations for events/styles. 👍

@dzhou121
Copy link
Contributor Author

dzhou121 commented May 1, 2024

Some exciting updates.

IntoView is re-purposed to no need for a view id, which means we can impl it for &str, (), etc. And it will work like a normal View so can directly apply Decorators on it. E.g. you can do

(
    "some button",
   (    
        ().style(|s| s.width(100).height(20).background(Color::GRAY),
        "another button".style(|s| s.color(Color::RED)),
   )
).style(|s| s.flex_col())

@jrmoulton
Copy link
Collaborator

I definite like Into view for stacks. I'm on the fence though whether we should implement it for the empty tuple and&str.

I feel like text/empty make it significantly more clear what is going on.

I'd be fine with it though / maybe would come to love it

@dzhou121
Copy link
Contributor Author

dzhou121 commented May 1, 2024

Yeah I'm a bit worried about () as well, because then if you do something like

fn your_view() -> impl IntoView {
    (
        "some button",
       (    
            ().style(|s| s.width(100).height(20).background(Color::GRAY),
            "another button".style(|s| s.color(Color::RED)),
       )
    ).style(|s| s.flex_col());
}

This compiles, but then you would be surprised why it doesn't show anything.

@dzhou121
Copy link
Contributor Author

dzhou121 commented May 7, 2024

Added impl IntoView for Box<dyn Fn() -> IntoView> and RwSignal<IntoView>

Simplified dyn_container to only take impl Fn() -> IntoView as parameter.

@dzhou121 dzhou121 merged commit 8f5a9c5 into main May 8, 2024
3 of 4 checks passed
@dzhou121 dzhou121 deleted the ecs branch May 8, 2024 21:36
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