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

How to disable resizing via imgui and hide grips on secondary viewports? #4534

Closed
aiekick opened this issue Sep 12, 2021 · 4 comments
Closed

Comments

@aiekick
Copy link
Contributor

aiekick commented Sep 12, 2021

Hello,

Version/Branch of Dear ImGui:

Version: 1.84.2
Branch: docking / viewport

Back-end/Renderer/Compiler/OS

Back-ends: glfw and opengl3
Compiler: msvc
Operating System: win10 64

My Issue/Question:

I have always the crash same issue (#3321) when i try to resize a chid windows
I tested in GLFW3 and SDL2 and i have the same issues.
There is many similar report for this issue in the forums of GLFW3 and SDL2.
So its not the fault of ImGui

I can avoid this crash by using the window resizing (if the decoration is enabled) instead of via imgui

But If i disable the decorations with that line

io.ConfigViewportsNoDecoration = false;

I always have the grip who is displayed on child windows.

The crash happen via this grip, but not via the windows.
because when i resize via the windows borders, the fbo is re created after the end of the resizing,
afaik i not see any crash issue.
if i resize with the grip, the fbo is constantly recreated during the resizing and the crash happen.

so i would like to disable the grip and the resizing feature (via grip or edges) of imgui for the child windows. (not for internal windows of a child windows, just for the child windows himself)

Is there a easy way for doing that without breaking ImGui ?

@aiekick aiekick changed the title How to disable resizing via grip and hide grips on ChildWIndows (Viewport/Docking) ? How to disable resizing via imgui and hide grips on ChildWIndows (Viewport/Docking) ? Sep 12, 2021
@aiekick aiekick changed the title How to disable resizing via imgui and hide grips on ChildWIndows (Viewport/Docking) ? How to disable resizing via imgui and hide grips on External WIndows (Viewport/Docking) ? Sep 13, 2021
@aiekick
Copy link
Contributor Author

aiekick commented Sep 13, 2021

Im embarassed because i found the solution jsut after writing this question :) sorry :)

here my solution :

static ImGuiWindowFlags flags = ImGuiWindowFlags_NoCollapse; // by ex
if (ImGui::Begin(windows_name, &opened, flags ))
{
	auto win = ImGui::GetCurrentWindowRead();
// test is the window is in another viewport than the default 
// and so disable titlebar and resizing (the grip will be hidden, and the resizing feature via imgui will be disabled)
	if (win->Viewport->Idx != 0)
		flags |= ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar;
	else
		flags = ImGuiWindowFlags_NoCollapse; //return to default, when merged in main viewport

and not forgot to disable decoration with that code :

io.ConfigViewportsNoDecoration = false;

the result :

bRtef9TsTu

it working like a charm but could be better to have a option for that in imgui, like that can be applied for every child windows
for me it make sense to have the posssiility to disable imgui resizing feature when we have decoration of windows.
if we want to use decoration it make sense to use also resizing feature of the windows.

@aiekick aiekick closed this as completed Sep 13, 2021
@aiekick aiekick reopened this Sep 13, 2021
@aiekick
Copy link
Contributor Author

aiekick commented Sep 13, 2021

btw when im using BeginPopupModal

ImGui::OpenPopup(name.c_str());
bool beg = ImGui::BeginPopupModal(name.c_str(), (bool*)nullptr,
	flags | ImGuiWindowFlags_NoScrollbar);

with this flag :

io.ConfigViewportsNoDecoration = false;

the decoration is not appearing :

AXFyNtNR9H

@ocornut ocornut changed the title How to disable resizing via imgui and hide grips on External WIndows (Viewport/Docking) ? How to disable resizing via imgui and hide grips on secondary viewports? Sep 13, 2021
@ocornut
Copy link
Owner

ocornut commented Sep 13, 2021

Decorations are off on popups and transient windows such as tooltips.
You can force it via:

ImGuiWindowClass window_class;
window_class.ViewportFlagsOverrideClear = ImGuiViewportFlags_NoDecoration;
ImGui::SetNextWindowClass(&window_class);

The viewport configuration flags are a little bit of a mess, will refactor at some point.
Enabling OS decoration isn't even very well supported right now:

  • dear imgui decorations should generally be hidden (the resize grips but also title bar)
  • on Windows, OS decorations are enforcing a minimum sizes that is impossible to override (well it is possible by it creates visual glitches in the window manager of Windows) so they are not suitable in all use cases.

It sucks but I think if you are affected by this issue you should consider using DX11 on Windows.

@aiekick
Copy link
Contributor Author

aiekick commented Sep 13, 2021

Ok thank for the trick :)

If the bug is on GLFW / SDL side, not sure if Directx will not have the issue. ?

By the way my app is a cross platform Opengl Shader editor, so i cant use directx, or use directx for app and opengl for rendering but not sure after to display GL texture on a Directx ui. too much complex if possible i guess.
And i have this bug also on linux. (less often time, but i had)

By the way the decoration is interesting too, for have split feature (magnetic splitting way) of windows on screen, like we have on win and linux. (i guess also on macos)
Not sure if the window spliting can be made without decoration.

so for the moment, its the best trick i found.

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

2 participants