Skip to content
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

Some flag such as ImGuiWindowFlags_ViewportDisable to disable some windows from being external viewports #2544

Closed
zzzyap opened this issue May 8, 2019 · 12 comments

Comments

@zzzyap
Copy link

zzzyap commented May 8, 2019

Regarding viewports (using v1.69 docking), is there a flag to disable some windows from becoming viewports.
In our use case, we have notifications (that generate a lot of windows) and was wondering if we could flag these as non-viewports. Such that notifications can be animated and rendered within the main viewport and not create windows/swap chains.

@ocornut
Copy link
Owner

ocornut commented May 8, 2019

As we are aiming to generalize the concept of owned/hosting viewports to allow zero or more than one of them, I think what we are looking for isn't so much of a _NoViewport flag but rather to make this works:

ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
ImGui::Begin("Hello, world!");

Right now I noticed this doesn't work but it is an easy fix.
Would that work for you if I pushed a fix?

(PS: Some of the viewport/platform windows api are a little bit of a mess, here consider the use of viewport pointers vs viewport id. Will have a general small-breaking pass at them once the feature dust has settled)

@ocornut
Copy link
Owner

ocornut commented May 8, 2019

Addenum: I am also curious if you are using io.ConfigViewportsNoAutoMerge=true or not. It is false by default, and any notification window covering the main viewport would therefore not use a new swap chain.

EDIT However mixing io.ConfigViewportsNoAutoMerge=true and SetNextWindowViewport is likely to create z-ordering issue.

@zzzyap
Copy link
Author

zzzyap commented May 8, 2019

We use the default for ConfigViewportsNoAutoMerge = false.
The issue derived from the fact that we animate in (reposition) the notifications. They basically start offscreen and move onscreen, then upwards as other notifications pop out.

Personally I do see ImGui::Begin("Hello, world!", nullptr, ImGuiWindowFlags_ViewportDisable); being more useful beyond this case. The flag would be easier to check later on like other window flags. Then the user could (if needed) add behaviors for these type windows.
Side side note: I do believe there is already a flag for no docking, so a no viewport would be familiar for users.

ImGui::SetNextWindowViewport(...); does sound like it would achieve the same effect.
Edit: trying ^ this out right now.

@ocornut
Copy link
Owner

ocornut commented May 8, 2019

But what I am trying to say is an hypothetical "ViewportDisable" flag is ambiguous:

  • windows are always associated to a viewport.
  • it will be possible to have multiple user-owned host viewports: which one should the window pick?
  • what if you decide to have notifications on the side of some content which is not on your "main" viewport?

Edit: trying ^ this out right now.

It doesn't work now because of a bug (I have a local fix).

@zzzyap
Copy link
Author

zzzyap commented May 8, 2019

Ok got it, these would be a deal breaker.
Constrain to viewport via SetNextWindowViewport would make more sense.

ocornut added a commit that referenced this issue May 8, 2019
@ocornut
Copy link
Owner

ocornut commented May 8, 2019

I pushed a fix for SetNextWindowViewport for now.

I think we'll somehow have to come back to this from another angle at some point, maybe after we've done #2471.

@zzzyap
Copy link
Author

zzzyap commented May 8, 2019

Tested it out locally SetNextWindowViewport works great :)
#2471 looks awesome, will keep my eye on it.
Closing this issue.

@zzzyap zzzyap closed this as completed May 8, 2019
@smilediver
Copy link

I've also spent half an hour trying to figure out how to disable log overlay from popping out to a separate window. A flag like ImGuiWindowFlags_ViewportDisable was the first thing I've looked for. Something like that, or maybe ImGuiWindowFlags_AlwaysInMainViewport would be awesome.

@ocornut
Copy link
Owner

ocornut commented May 30, 2019

I understand the problem and need here, but as stated here this would be misleading when it comes to supporting multiple main viewport?

@smilediver
Copy link

Unless I don't understand something, or there are plans to change it, there is a single main viewport for imgui context. So I would expect that a flag like ImGuiWindowFlags_AlwaysInMainViewport would work in that context, and it doesn't seem misleading to me. However I do see that a meaning of ImGuiWindowFlags_ViewportDisable flag may be misleading.

@ocornut
Copy link
Owner

ocornut commented May 30, 2019

The post above state that there is an attention for the user to have zero or more than one host viewport.
Even the "main viewport" terminology is misleading.

I however understand this would be convenient mid-term and going to come up with an idea for a flag, maybe there will be a concept of a "default" viewport which can be modified during the frame.

(Please all remember multi-viewport are in beta and some of those flags/api are going to change before it all gets merged in master.)

@zzzyap
Copy link
Author

zzzyap commented May 30, 2019

The case of multiple main viewports (which could be multiple contexts etc... depending on impl.).
Flags such as ImGuiWindowFlags_AlwaysInMainViewport and ImGuiWindowFlags_ViewportDisable conflicts when dealing with multiple main viewports.
ImGui::Begin(...) etc... does not have user specification for which main viewport or context it is created or exists within (and it shouldn't).
SetNextWindowViewport(...) is an approach that would scale better, context and "main" viewport does not matter for this generalized approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants