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

Add "plugin" system for widgets to interact generically #235

Open
ecton opened this issue Jan 5, 2025 · 1 comment
Open

Add "plugin" system for widgets to interact generically #235

ecton opened this issue Jan 5, 2025 · 1 comment

Comments

@ecton
Copy link
Member

ecton commented Jan 5, 2025

Part of the discussion around the Data widget being "hard" to access (see #230) the contained data really stems from how interfaces in Cushy are built by composing many widgets and there being no way to find a specific instance of a widget in the hierarchy without having a reference to it.

Ultimately I think that it's a mistake for application data to be stored and queried this way. However, in designing widgets that are supposed to work with other widgets, it is very beneficial to be able to generically interact with a widget. To me, the Rust way to do this is with traits.

I want to design a system where dyn SomeTrait downcast can be done via a plugin id. Widgets would need to implement a function that would resolve self to a specific trait implementation based on the plugin id. The Any type would be used to ensure that the downcast is a valid downcast.

The main case where Cushy might use this is with how the Stack widget hardcodes several types to handle the layout operations directly (#127). While that could be solved another way, it might be a good opportunity for a system like this.

@saturn77
Copy link

saturn77 commented Jan 19, 2025

A related idea to the the plugin system --- The concept of a port on a widget would be a great help when attempting to connect widgets, say like in a 2d drawing application where one wanted to connect multiple widgets and the have a variable amount of input ports and output ports. A generic connector widget that would have straight line, orthogonal, and bezier options would be extremely awesome too. The generic Widget trait could perhaps be modified to include a Vec of Ports, where the Ports Type is a HaspMap of Input, Port or Output, Port.

The above functionality could also be a plugin.

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

No branches or pull requests

2 participants