ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
59.76k stars 10.17k forks source link

Suggestion: Extend demo with full screen window / docking examples #7955

Closed Andersama closed 3 weeks ago

Andersama commented 3 weeks ago

Version/Branch of Dear ImGui:

Any

Back-ends:

Any

Compiler, OS:

Any

Full config/build information:

No response

Details:

I just figured I'd point out that while:

ImGui::ShowDemoWindow(&show_demo_window);

is an excellent resource for the basics, this function doesn't show off how to make a window "maximized" or fit to the screen, which is one of the first things a person would like to do.

I figure there's probably a good place to add a toggle button in the demo to do just that, and similarly, for builds with the dock enabled there should probably maybe there's there's a variation of "ShowDemoWindow" called "ShowDemoDock" that allows shuffling around some child windows.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

ocornut commented 3 weeks ago

The DockSpace demo already has a fullscreen demo but because it does quite more things it may be a little unobvious.

You basically need to do:

const ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->WorkPos);
ImGui::SetNextWindowSize(viewport->WorkSize);
ImGui::SetNextWindowViewport(viewport->ID); // in docking branch
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus;
ImGui::Begin(...., ..., flags);
ImGui::PopStyleVar();
ocornut commented 3 weeks ago

Err, I just realized there IS such demo. Demo->Examples->Fullscreen Window. Leading to the ShowExampleAppFullscreen() function.

But if you mean adding a "Maximize" button to every window, that's another topic. I presume we might support it at some point. Linking to #2104 and #3486.

called "ShowDemoDock" that allows shuffling around some child windows.

There is a Dockspace demo but that's more advanced. You can already dock and drag anything into anything by default.

Andersama commented 3 weeks ago

Ah, well, I didn't find that example, despite it being under the examples drop down. Yeah it might be better if it's related to minimizing/maximizing/restoring type buttons, or just better placement. I'd almost suggest putting it underneath the dropdowns.

I'm realizing now why it's strange, that demo opens another window, where you might expect it to impact the demo window.

ocornut commented 3 weeks ago

Yeah it might be better if it's related to minimizing/maximizing/restoring type buttons,

The existing open issues are here to track when this will be implemented.

I'm realizing now why it's strange, that demo opens another window, where you might expect it to impact the demo window.

We have many many features to demo they cannot all be packed at the beginning of the main demo window.

Andersama commented 3 weeks ago

Call me crazy, would it not be possible to add it to the front/main window?

I mean it seems like you're referencing static variables to do similar things for other features.

ocornut commented 3 weeks ago

I don't understand what you are saying. Please be more explicit. Maybe https://github.com/ocornut/imgui/wiki/Glossary can help.

Andersama commented 3 weeks ago

I thought you were referring to adding code to demonstrate the feature on the demo window itself, it seems like it'd be doable towards the start of the demo window function.

Andersama commented 3 weeks ago

@ocornut I'm not sure because it seems like from the links you referenced that someone started on this project quite a while ago, is there a commit already being considered?

I took a couple minutes and I've got a minimize/maximize/restore button in the title bar using flags. The only remaining part is what the behavior exactly is.

Edit: Maximize/Restores fairly clear, I'm not 100% on how "minimize" should act. A thought I had was that it could "collapse" and move the collapsed window handle to a particular position. There's also the idea like w/ OS's where minimizing is associated w/ a button-like icon somewhere else.

image

ocornut commented 3 weeks ago

I think this discussion may be moved to #2104. If that issue is open it means that the work hasn't been done.