Skip to content

Instantly share code, notes, and snippets.

@kudaba
Created October 22, 2020 23:09
Show Gist options
  • Save kudaba/645cb5e18746290460b633230342113a to your computer and use it in GitHub Desktop.
Save kudaba/645cb5e18746290460b633230342113a to your computer and use it in GitHub Desktop.
namespace ImGui
{
// Copy of BeginMenuBar except it's at the bottom
bool BeginMainStatusBar()
{
ImGuiContext& g = *GImGui;
ImGuiViewport* viewport = g.Viewports[0];
float height = g.NextWindowData.MenuBarOffsetMinVal.y + g.FontSize + g.Style.FramePadding.y * 2;
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
SetNextWindowPos(ImVec2(viewport->Pos.x, viewport->Pos.y + viewport->Size.y - height));
SetNextWindowSize(ImVec2(viewport->Size.x, height));
SetNextWindowViewport(viewport->ID); // Enforce viewport so we don't create our onw viewport when ImGuiConfigFlags_ViewportsNoMerge is set.
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
bool is_open = Begin("##MainStatusBar", NULL, window_flags) && BeginMenuBar();
PopStyleVar(2);
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
if (!is_open)
{
End();
return false;
}
return true;
}
void EndMainStatusBar()
{
EndMainMenuBar();
}
}
namespace ImGui
{
// Copy of BeginMenuBar except it's at the bottom
bool BeginMainStatusBar();
void EndMainStatusBar();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment