How to query properties and attributes of components? #1900
-
5fca344 When traversing the element tree this way, I could query the "x,y" (origin) and "w,h" (size) of each widget, but how to get more information, the properties and attributes? The code in process_key_input in windows.rs:
Sample slint:
My goal is to get the following output: |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 1 reply
-
907b581 Maybe I could use this "init" callback to save properties of all components. |
Beta Was this translation helpful? Give feedback.
-
What you're doing sounds quite interesting and I wonder what exactly you are trying to achieve. Unfortunately, this is not really possible to do what you're asking. It would be nice to have an understanding of what you really want to achieve with that information so we could find a solution that works for you. |
Beta Was this translation helpful? Give feedback.
-
In simple terms, we need to find out the exact position (x,y,w,h) and type and text of all components. I almost get it done:
The only problem is that x,y are relative position, not absolute position, and the code is a little bit messy. |
Beta Was this translation helpful? Give feedback.
-
Our goal is to generate many UI screenshot with annotations, then we can use them to train deep learning models. That's why we need information of widgets, only these properties: type, x,y, w,h, text. I haven't read the code of slint.internal.core, but the concept of compilation process is clear to me. The .slint file is a specification, not exactly the same as runtime. For example, some components can switch between visible and invisible state, the position will change accordingly. The task is a little bit difficult, but I guess it's still doable. In the compilation stage (internal/compiler/load_builtins.rs), each built-in widget is registered with their properties, so the widget name and properties are stored somewhere. If the runtime item could be connected with widgets by UUID or something similar, then the runtime item can attach back to the original widgets, thus get all the information. Actually, not all the information, just the above six properties. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
Our goal is to generate many UI screenshot with annotations, then we can use them to train deep learning models. That's why we need information of widgets, only these properties: type, x,y, w,h, text.
I haven't read the code of slint.internal.core, but the concept of compilation process is clear to me. The .slint file is a specification, not exactly the same as runtime. For example, some components can switch between visible and invisible state, the position will change accordingly. The task is a little bit difficult, but I guess it's still doable.
In the compilation stage (internal/compiler/load_builtins.rs), each built-in widget is registered with their properties, so the widget name an…