afonsolage / bevy_ecss

Bevy crate which uses a subset of CSS to update Bevy ECS components
Apache License 2.0
98 stars 11 forks source link

Allow entities to ignore change listeners for certain properties #52

Open TheDudeFromCI opened 8 months ago

TheDudeFromCI commented 8 months ago

Due to the nature of interactive elements in a user interface, some properties of an entity must be overwritten dynamically. An example of this might be a scroll pane overwriting the top field of it's Style component to shift the content panel within up and down.

As the current change listener for bevy_ecss listens for all component changes, it will always trigger a change when this this field within the Style component and thus triggering the CSS to be reapplied. (See #53)

A possible solution to this would be to allow for a new component that can be added to an entity that would contain a list of properties to blacklist the change listener for. Any changes to these properties would be ignored.

This is just a performance enhancement, but is something worth considering with entities that needed to be updated extremely frequently.

afonsolage commented 8 months ago

Interesting point. You mean skip entirely a descendant component, like add SkipStyling (temp name), or partial skip, like SkipProperties(Vec<String>), which contains a list of properties to not react to changes?

There are three levels of skipping that I can think of:

  1. Skip the entity as a whole and all its children;
  2. Skip only the entity, but not its children;
  3. Skip only some properties on the entity;
TheDudeFromCI commented 8 months ago

I would imagine the third option to be most useful in the case of directly editing properties, as one would know which properties they plan on overwriting. Although, I can see the practicality of all three.