-
-
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
Multi-window support #27
Comments
Is there an ETA for multiple windows or someone already working on it? |
@Songtronix Not really. I know some folks were experimenting with running two Iced applications in different processes and communicating them using a I will most likely tackle this after #32. It always helps me to know more about different use cases, so feel free to share your own! |
Well Airshipper will need to soon display a new window for (profile) settings so multi-window support might come in handy! Maybe even showing the game output in a different window might be interesting to experiment with. |
I was thinking about this concept the other day. I wondered if it is really necessary to have multiple windows for a single "app". Especially since it's not clear what this means for web. What do you guys think the use cases are for needing multiple windows that cant be achieved with inter-process comms? |
Well, inter-process communication is usually quite a PITA to make work, so I'd say it's usually possible but not the first choice. I could imagine a lot of application with multiple windows that make sense. A CAD application with multiple different views to the same drawing so you can spread them onto multiple screens (where you don't want to synchronize the content of the one drawing between processes), GIMP handles multiple documents + shared tool bars (I'm not saying GIMP is the best GUI design, but if iced aims to be general purpose, it should be possible to do too). These probably would lose some abilities on the web ‒ eg. the CAD application would support only one view on the web, while could do multiple in desktop version. Another thing that's common to desktop is pop-up dialogs. I can imagine the „Menu -> Edit -> Settings“ being a separate process, but it does seem inconvenient to do. |
@krooq In regards to the web: If the proposed |
I have 2 thoughts/concerns here:
|
|
|
@maxjoehnk I was thinking that maybe multiple windows could be emulated inside a single window that spans multiple desktops with transparent areas. But I'm not sure if all of the native APIs allow for areas of event pass through on different windows. Pretty sure it's possible on X. All that a native window gives you is a rendering context, events and some native window manager stuff like resize and decoration. This is why I'm not convinced that multiple windows per application is an ideal solution. Another advantage to being single window is that when you switch focus, your entire application is brought to front by the window manager. It's like the OS is giving you a box to put your application in and we want to rip a hole in the box and duct tape on another one. That could certainly be fun but I'm not sure it's advisable. |
@krooq I'm not sure how portable that would be, e.g. whether OSX and Windows allow for such a use case. Also iced would need to handle all edge cases with weird screen layouts. The focus switch sounds quite nice but I would not want this kind of behavior for every application. I like to have multiple browser windows open on multiple workspaces on multiple screens and do not want my wm to bring all the different windows to the front when I focus the window with some documentation for the code I'm working on. |
This is all true. I don't think the transparent window idea is the right solution.
But the question is why is another window needed for the tools?
Yes true. However the job of the OS is to let you do whatever you want safely and securely. Don't get me wrong, I still want multi window. I think the concept of multiple windows has great merit and has stood the test of time. I just know how much of a pain they can be across platforms. |
That sounds like a giant pita. Maybe we can add some kind of extension system where you have traits for specific non cross platform features (e.g. multiple windows or maybe something like dialogs). This could allow native multi window support as well as "emulated" multi window support with the same implementation. |
I believe applications should act in a way consistent with the platform they run on. For desktop, that means asking questions as separate modal windows (which you can still drag outside of their parent window to uncover what's below it) or configuration dialog. That certainly is different on non-desktop platforms ‒ modal windows on eg. Android just aren't a thing. Having multiple top-level windows is also kind of power-feature of desktop that can't really be expected in other contexts (I don't know if single application could open multiple browser tabs and/or windows and act as one application; it certainly doesn't make sense in mobile devices where the surface is severely limited). So there are two possible ways. One way is somehow trying to find a common ground ‒ which might be good enough for some applications, but not for everything. Once you start drawing modal windows inside the top level windows on desktop, users will get the not-quite-native almost-but-not-really-great feeling. The other one is somehow mapping the UX intentions to the native expressive means. So I could imagine having some kind of modal question flow expressed in code that gets mapped to a separate window on desktop, replaces the application window in android and draws a window-inside-a-window on the web. I could imagine having some kind of top-level window/viewport thing that you can have multiple ones on desktop and only one on other platforms (and get a panic if you try to create a second) or only one visible at a time on other platforms (and you get some kind of tabs or have to manually switch them). I also think that you could have almost the same code for the platforms in the end application. So you'd conditionally not show the button to create another top-level window, or conditionally have code for the tabs, but all the bulk of code for drawing into the multiple (same) windows or computations, etc, could stay the same. Of course the hard part would be actually finding all the conceptual flows and their mappings to native tools. I think at least these three are there:
|
This is all really good discussion.
I like this idea. It should be very clear that to the user how certain features will behave on certain platforms. I'd love to see Iced being used for simple small desktop applications over basic WinAPI or other toolkits, many of these tools are little desktop widgets which may want multi window.
I agree, I think this will be very difficult. I believe we should guide users to think about alternatives to multi-window for their functional use cases as currently multi-window is quite strongly tied to the desktop platform and behavior is generally ambiguous on web and mobile. |
I would personally prefer an API with e.g. enum DialogStrategy {
Auto, // e.g. `Emulated` in web and `Float` in native platform.
Float, // multi-window one
Emulated // inside-window one
} that can be passed to Actually, I don't think it is a good choice to have the "emulated window" implementation for non-native platforms (esp. the web). In the web, a "dialog" can be as simple as a |
Obligatory link to the mutli-viewports branch of imgui: ocornut/imgui#1542 |
How would multi-window play along with integrating However, that goes against the model of other use cases for traditional desktop application where every "window" is a top-level native window, except for maybe dockable tool windows, but those are still different because they either stay as a top-level native window or get docked inside the main window, and there is almost never the need to become a virtual window. |
I think that makers of custom engines should worry themselves about window managing and iced only needs to support handling of events and rendering of multiple viewports. I mean, iced should not even care if window is virtual or native, it only needs to support some abstract window and let engine makers handle the rest. |
Just a comment on a usecase for this, I would like to wrap |
My use case is kind of weird, so bear with me. I want to create something like a magnifying glass or X-ray window that can be dragged over the main window to display additional information. There are several components to this though:
So, what am I using this capability for? Quite a number of potential use cases, some of which are below:
I'm sure others can think of additional uses, but those are the ones that I'm thinking about. |
I'd like to maybe use iced possibly, but this would stop me before even trying. My entire application is based off multiple windows. It's a presentation app so it needs another window to house slides and videos while the main window controls it on the projector |
Is anyone aware of the rough ideas one would need to implement this? |
Implemented in #1964. |
Open and control multiple windows at runtime.
I think this could be achieved by implementing an additional trait in
iced_winit
similar toApplication
but with a slightly differentview
method, allowing users to control what is shown in each window.This approach should also allow us to perform custom optimizations for this particular use case.
The text was updated successfully, but these errors were encountered: