mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
BeginMainMenuBar(): remove expectation that we don't know menu bar height ahead, allowing up to generalize placement in any direction (will be done in master)
Amend 75de34e281
This commit is contained in:
parent
085cff2fe5
commit
ca34c81ce9
@ -943,7 +943,6 @@ static void UpdateViewportsEndFrame();
|
||||
static void UpdateSelectWindowViewport(ImGuiWindow* window);
|
||||
static bool UpdateTryMergeWindowIntoHostViewport(ImGuiWindow* window, ImGuiViewportP* host_viewport);
|
||||
static bool UpdateTryMergeWindowIntoHostViewports(ImGuiWindow* window);
|
||||
static void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||
static bool GetWindowAlwaysWantOwnViewport(ImGuiWindow* window);
|
||||
static int FindPlatformMonitorForPos(const ImVec2& pos);
|
||||
static int FindPlatformMonitorForRect(const ImRect& r);
|
||||
|
@ -2462,6 +2462,7 @@ namespace ImGui
|
||||
IMGUI_API void TranslateWindowsInViewport(ImGuiViewportP* viewport, const ImVec2& old_pos, const ImVec2& new_pos);
|
||||
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
|
||||
IMGUI_API void DestroyPlatformWindow(ImGuiViewportP* viewport);
|
||||
IMGUI_API void SetCurrentViewport(ImGuiWindow* window, ImGuiViewportP* viewport);
|
||||
const ImGuiPlatformMonitor* GetViewportPlatformMonitor(ImGuiViewport* viewport);
|
||||
|
||||
// Settings
|
||||
|
@ -6625,12 +6625,15 @@ bool ImGui::BeginMainMenuBar()
|
||||
if (menu_bar_window == NULL || menu_bar_window->BeginCount == 0)
|
||||
{
|
||||
// Set window position
|
||||
// We don't attempt to calculate our height ahead, as it depends on the per-viewport font size.
|
||||
// However menu-bar will affect the minimum window size so we'll get the right height.
|
||||
SetCurrentViewport(NULL, viewport);
|
||||
float height = GetFrameHeight();
|
||||
ImVec2 menu_bar_pos = viewport->Pos + viewport->CurrWorkOffsetMin;
|
||||
ImVec2 menu_bar_size = ImVec2(viewport->Size.x - viewport->CurrWorkOffsetMin.x + viewport->CurrWorkOffsetMax.x, 1.0f);
|
||||
ImVec2 menu_bar_size = ImVec2(viewport->Size.x - viewport->CurrWorkOffsetMin.x + viewport->CurrWorkOffsetMax.x, height);
|
||||
SetNextWindowPos(menu_bar_pos);
|
||||
SetNextWindowSize(menu_bar_size);
|
||||
|
||||
// Report our size into work area
|
||||
viewport->CurrWorkOffsetMin.y += height;
|
||||
}
|
||||
|
||||
// Create window
|
||||
@ -6641,11 +6644,6 @@ bool ImGui::BeginMainMenuBar()
|
||||
bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
|
||||
PopStyleVar(2);
|
||||
|
||||
// Report our size into work area (for next frame) using actual window size
|
||||
menu_bar_window = GetCurrentWindow();
|
||||
if (menu_bar_window->BeginCount == 1)
|
||||
viewport->CurrWorkOffsetMin.y += menu_bar_window->Size.y;
|
||||
|
||||
g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
||||
if (!is_open)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user