-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Layers #30
Comments
How would the depth of the widgets be determined? Maybe with something like this? enum Depth {
Above,
Below,
Topmost,
}
fn view(&mut self) -> Element<Message> {
// ...
Layer(SomeWidget::new(), Depth::Above)
// ...
} Then the current depth would have to be kept in the layouting state. Given a combobox for example, would it be best for the choice list to be part of the drawing code and the widget set to be on top (and |
I do not have a particular approach in mind yet. There is definitely an interesting amount of exploration ahead of us here. I do know using something like absolute indices (like A relative
I think layers (or at least event layers) will need to exist as a first-class concept in I am not yet sure about how we will end up implementing this. I do have the feeling that the different methods in the I think the problem is telling us something here: we should define layout, update, and draw in a unified, declarative way. The runtime will then figure out how to process events and draw widgets. How could this API look like? I am not sure yet! 😅 This is where we should explore! I think the way |
I would like to add my 2 cents. In other GUI libraries like GTK under X11, such overlays are actually separate windows, and can therefore extend outside the actual application window. In my opinion, this is very useful for dropdowns and menus. I collected a couple of screenshots to illustrate my point. In such cases or in cases of very small windows, it looks like it would be desirable to have a similar effect in Iced, too. I'm absolutely not sure how difficult something like that is to achieve... |
Isn't it better to achieve single instance window widget support @hecrj ? |
Separate windows would be the ideal way to go, but aren't really supported by winit yet (rust-windowing/winit#403), and even if it were I don't know if it would be portable to all platforms (e.g. Android). FYI, for KAS I solved the event handling via specific support for "pop-ups" (still a bit hacky, but required to support closing menus when clicking under them and things like accelerator key bindings on the menus). For drawing it uses the depth buffer with some specific offsets (not the only option, but otherwise you'd need indirect drawing for each layer I believe). |
@hecrj isn't this already achieved through overlays? Could you explain the difference between a overlays and what you're suggesting? I'm a bit new to Iced, and I don't have a lot of experience with the API as yet. |
@AshfordN overlays do somewhat work but the issue become when you have a lot of overlays which ones should be rendered above the others. So in this case a lot of GUI libraries even Microsoft's UI stuff uses Z List rendering/ordering. All this means is they have a Arc connection point to a list and the list is just used for the rendering order. A list works the best for this method since you can Add children quickly above it and additions don't normally matter as much. To use a faster method for rendering like a Array/Vec you would need to pull in the top most first and then everything else starting from its children and then back in reverse. so the children or top most object is last/first in the array. and moving them around should be OK to do as well. In C we would use memmove() but if you use Vec or an actual list should be good enough since both support those methods safely. This would be
@dhardy: separate windows would need to be an enabled feature and would also require a separate list of widgets per window. this also means a different sandbox etc per window. for it to work optimally. I did some work a while back with GLFW and multiple window support is nice but they function as their own individual programs just with shared memory. |
Regarding child windows, there is now this PR for winit (X11 only): rust-windowing/winit#2246 As @genusistimelord notes, having an application spawn multiple windows isn't exactly hard (KAS has had a "synchronised counter" example since very early on), but tying together event handling across windows for uses like menus is harder. |
Is there any kind of requirement list?
These are just some ideas I gathered and a complete list would be helpful / would need to be discussed (maybe already exists and I just missed it). |
Currently hector has kindof made layering possible with the ability to create more layering structs which is helpful for fixing the overlay issues. |
Solved by #1719. |
Currently, Iced assumes widgets cannot be laid out on top of each other. We should implement support for multiple layers of widgets.
This is a necessary feature to implement many kind of interactables, like dropdown menus, select fields, etc.
iced_native
will need to group widgets to perform layouting and process some events first for widgets positioned on top.iced_wgpu
will also need to process the scene graph and sort draw calls based on the different layers.The text was updated successfully, but these errors were encountered: