slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.58k stars 604 forks source link

slint-viewer Feature Request (STDIN as a Stream) #2673

Open darkphase opened 1 year ago

darkphase commented 1 year ago

Hi, Is it possible to modify slint-viewer such a way that it can listen continuously from stdin, so data can be taken from backend into slint UI side...

ogoffart commented 1 year ago

Currently this is not implemented, but it would make a lot of sense to open the slint-viewer in a 'server' mode and it would use some command over stdin/stdout to to set properties and act on callbacks

darkphase commented 1 year ago

I suspect, some kind of protocol will be needed for that... While loading data from stdin (-) SSE like syntax would be awesome... It would also provide 2 way event mechanism

EVENT: [event name]\n\n DATA: [json string]\n\n DATA: [json string]\n\n

ogoffart commented 1 year ago

Yes exactly, we would need command like

> SET_PROPERTY foobar 42
> GET_PROPERTY foobar
< PROPERTY foobar 42
< CALLBACK button_clicked [5, 6]
> REPLY button_clicked 0
> INVOKE some_function
< REPLY some_function "hello"
> RESET_GUI "component Xxx { ... }"

(this is just a stawman protocol, not an actual suggestion)

darkphase commented 1 year ago

It is not my place to say if the protocol would be that generic or not but that would be cool... Because, as of now, at least it is possible to carry out events outside of slint-viewer with --on parameter. Is there any possibility to implement this feature (At least continuous stdin reading) any time soon?

ogoffart commented 1 year ago

While we don't currently have plans to implement this feature in the near future, we would be more than happy to help if you would like to contribute to the project. We would be happy to provide guidance. If you have any questions or need any help, just let us know.

darkphase commented 1 year ago

with --auto-reload parameter I managed to send progress data via data file into progressbar and re-render UI every time input data file changes... But the feature mentioned above would still be appreciated... Eventhough, it wouldn't seem much of a problem with a single widget UI when it becomes complex, loading all UI files would lead to glitches and performance issues I suspect. Instead it would be awesome to load data into a group of widgets or even a single widget.