Dynamic composition of application parts #959
Replies: 5 comments 7 replies
-
|
Currently this is a bit awkward and we're open to find out what kind of syntax this could have. Several options are available.
property <[ImageInfo]> images;
property <[SvgInfo]> svgs;
property <[TextInfo]> texts;
//...
for it in images : Image { ... }
for it in svgs : Svg { ... }
for it in texts : Text { ... }
for it in items : Rectangle {
// this could clearly benefit to have some C-style `enum` in the language
if (it.type == 0) : Image { ... }
if (it.type == 1) : Svg { ... }
if (it.type == 2) : Text { ... }
}the I was thinking maybe there should be some kind of a But what would be the ideal solution that would work for you? What kind of syntax would you use for it. |
Beta Was this translation helpful? Give feedback.
-
|
I was more thinking of a solution via code, e.g. by providing some way to create a "child control" via code and then add it to the main control. I am not sure if the current approach to generate the item_tree could be adapted to make item nodes dynamically. The second place where this would be really helpful is for composing whole applications. In my case, I am having 10-30 different screens, where the user can navigate to. Now I would need to add all those screens to the main window and use the "if approach". But additionally this would also require to bind all the properties via the main window (see example code below). export MainWindowViewModel := {
property <int> activeScreen;
property <Screen1ViewModel> screen1Model;
property <Screen2ViewModel> screen2Model;
property <Screen3ViewModel> screen3Model;
...
}
MyWindow := MainWindow {
property <MainWindowViewModel> model;
if (model.activeScreen == 0): Screen1 {
model: model.screen1Model
}
if (model.activeScreen == 1): Screen2 {
model: model.screen2Model
}
if (model.activeScreen == 2): Screen3 {
model: model.screen3Model
}
}Or is there a different way to do that? |
Beta Was this translation helpful? Give feedback.
-
|
I trying to find a UI framework for implementing an INDIGO application in Rust. INDIGO is highly dynamic and the number of devices and their properties are not known at design time. Also a device might be added or removed at any point in runtime, and the same goes for their properties. At first blush, Slint looks like a very good candidate but given that I cannot change the UI programmatically as discussed here and indicated in #4620, Slint is unfortunately a no-go for my project. :-( I am not in a position to say exactly how that support should work, but suffice it to say that I need to be able to react to INDIGO events and add/remove device and property components/widgets from closures registered on the INDIGO model that I am developing. |
Beta Was this translation helpful? Give feedback.
-
|
Hii and yep if we want to make basicaly a "mutiple documents interface" with dynamic layouts each document as a "component" with a backend / controller this can only be acheve properly from code i guess do we have an "api" to walk and edit the "dom" ? |
Beta Was this translation helpful? Give feedback.
-
|
I'll second the idea that ideally, there would be a way to manually alter the control hierarchy without properties, callbacks and models. Properties, callbacks and models are great... 95% of the time. In my application, context menus are a particular pain. The logic to generate them is almost completely on the application side, and I have to create very basic models and properties to carry things over to Slint land. This works, but is awkward and sometimes necessitates obnoxious hacks (e.g. - certain items being duplicated because in certain conditions they can be submenus) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In all the examples I have so far only seen that the UI for the whole application is defined upfront statically. The only dynamic aspects are conditionals and repetition like documented at https://slint-ui.com/releases/0.2.0/docs/cpp/markdown/langref.html#repetition
Is there a way to achieve some truly dynamic composition (other than including all possible widget types and binding the visibility of those).
One of my use cases for this is a kind of "report representation" consisting of multiple elements that are put one after the other. But there are 5-10 different element types (e.g. image, SVG, text, table, chart, etc.). Ideally I can create the widget via code and then attach it in some way in the "main page".
Beta Was this translation helpful? Give feedback.
All reactions