ocornut/imgui

How to Create a Window that fills the OS window?

Closed this issue · 4 comments

I would like to treat the main window(as in the OS level window) as the window I'm drawing to instead of creating a windows within a window. Kind of like the web browser you are using right now has multiple rows of info at the top and tabs and the website you are viewing now takes up the full window.

Have tried a few things and none of them seem to be working.. is it possible to do this? How would I accomplish it? All the examples I'm seeing maybe have a menubar attached to main window, as I've figured out how to do, but otherwise all free floating windows.

Perhaps I need to use ImGuiWindowFlags_NoTitleBar as well as ImGuiWindowFlags_NoResize and ImGuiWindowFlags_NoMove plus somehow setting the size of the window to be the size of the full screen?

Thanks

frink commented

You need the window with the flags you mentioned... Then use io = ImGui::GetIO() to get the IO object and use io->DisplaySize.x and io->DisplaySize.y with ImGui:: SetNextWindowSize(). You may also need to use ImGui::SetNextWindowPos() to put the window at the top left corner. (0, 0)

Thanks frink, that worked perfectly.

If anyone else stumbles across this, in order to get the corners to look right, you probably also want to set:
ImGui::GetStyle().WindowRounding = 0.0f;
Link: #1797

One other question, is it possible to repaint the window when I resize the main window? That might be a glfw thing, but it freezes while resizing until I let go. Not a huge issue but long term I definitely want this.

Interesting coincidence frink, I've been creating a cryptocurrency on the side called Frink: www.frink.global :)

frink commented

One other question, is it possible to repaint the window when I resize the main window? That might be a glfw thing...

I use Sokol as my app container. It updates the canvas size as windows change. See this example... Super easy to make things work that way. Otherwise, you've got to deal with it yourself. You can see how floooh deals with it in his library if you don't want to use Sokol. He's a nice guy anyway and pretty knowledgeable on the GLDL code.

Interesting coincidence frink, I've been creating a cryptocurrency on the side called Frink...

That IS an interesting coincidence. I'd love to here more. Are you ready to go? What kind of help you need. Etc...

I just registered so that we can email back and forth more on that topic!

Basically you need

#ifdef IMGUI_HAS_VIEWPORT
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGui::SetNextWindowPos(viewport->GetWorkPos());
ImGui::SetNextWindowSize(viewport->GetWorkSize());
ImGui::SetNextWindowViewport(viewport->ID);
#else 
ImGui::SetNextWindowPos(ImVec2(0.0f, 0.0f));
ImGui::SetNextWindowSize(ImGui::GetIO().DisplaySize);
#endif
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::Begin(..., ..., ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize);
[...]
ImGui::End();
ImGui::PopStyleVar(2);