|
|
@@ -834,7 +834,7 @@ ImGuiStyle::ImGuiStyle()
|
|
|
GrabRounding = 0.0f; // Radius of grabs corners rounding. Set to 0.0f to have rectangular slider grabs.
|
|
|
ButtonTextAlign = ImVec2(0.5f,0.5f);// Alignment of button text when button is larger than text.
|
|
|
DisplayWindowPadding = ImVec2(22,22); // Window positions are clamped to be visible within the display area by at least this amount. Only covers regular windows.
|
|
|
- DisplaySafeAreaPadding = ImVec2(4,4); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
|
|
+ DisplaySafeAreaPadding = ImVec2(3,3); // If you cannot see the edge of your screen (e.g. on a TV) increase the safe area padding. Covers popups/tooltips as well regular windows.
|
|
|
MouseCursorScale = 1.0f; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
|
|
AntiAliasedLines = true; // Enable anti-aliasing on lines/borders. Disable if you are really short on CPU/GPU.
|
|
|
AntiAliasedFill = true; // Enable anti-aliasing on filled shapes (rounded rectangles, circles, etc.)
|
|
|
@@ -4160,13 +4160,9 @@ void ImGui::LogText(const char* fmt, ...)
|
|
|
va_list args;
|
|
|
va_start(args, fmt);
|
|
|
if (g.LogFile)
|
|
|
- {
|
|
|
vfprintf(g.LogFile, fmt, args);
|
|
|
- }
|
|
|
else
|
|
|
- {
|
|
|
g.LogClipboard->appendfv(fmt, args);
|
|
|
- }
|
|
|
va_end(args);
|
|
|
}
|
|
|
|
|
|
@@ -4242,8 +4238,7 @@ void ImGui::RenderText(ImVec2 pos, const char* text, const char* text_end, bool
|
|
|
text_display_end = text_end;
|
|
|
}
|
|
|
|
|
|
- const int text_len = (int)(text_display_end - text);
|
|
|
- if (text_len > 0)
|
|
|
+ if (text != text_display_end)
|
|
|
{
|
|
|
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_display_end);
|
|
|
if (g.LogEnabled)
|
|
|
@@ -4259,8 +4254,7 @@ void ImGui::RenderTextWrapped(ImVec2 pos, const char* text, const char* text_end
|
|
|
if (!text_end)
|
|
|
text_end = text + strlen(text); // FIXME-OPT
|
|
|
|
|
|
- const int text_len = (int)(text_end - text);
|
|
|
- if (text_len > 0)
|
|
|
+ if (text != text_end)
|
|
|
{
|
|
|
window->DrawList->AddText(g.Font, g.FontSize, pos, GetColorU32(ImGuiCol_Text), text, text_end, wrap_width);
|
|
|
if (g.LogEnabled)
|
|
|
@@ -5243,11 +5237,11 @@ enum ImGuiPopupPositionPolicy
|
|
|
ImGuiPopupPositionPolicy_ComboBox
|
|
|
};
|
|
|
|
|
|
-static ImRect FindScreenRectForWindow(ImGuiWindow* window)
|
|
|
+static ImRect FindScreenRectForWindow(ImGuiWindow*)
|
|
|
{
|
|
|
ImVec2 padding = GImGui->Style.DisplaySafeAreaPadding;
|
|
|
ImRect r_screen = GetViewportRect();
|
|
|
- r_screen.Expand(ImVec2((window->Size.x - r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (window->Size.y - r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
|
|
|
+ r_screen.Expand(ImVec2((r_screen.GetWidth() > padding.x * 2) ? -padding.x : 0.0f, (r_screen.GetHeight() > padding.y * 2) ? -padding.y : 0.0f));
|
|
|
return r_screen;
|
|
|
}
|
|
|
|
|
|
@@ -5313,7 +5307,7 @@ static ImVec2 FindBestWindowPosForPopup(ImGuiWindow* window)
|
|
|
ImRect r_screen = FindScreenRectForWindow(window);
|
|
|
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
|
|
{
|
|
|
- // Child menus typically request _any_ position within the parent menu item, and then our FindBestPopupWindowPos() function will move the new menu outside the parent bounds.
|
|
|
+ // Child menus typically request _any_ position within the parent menu item, and then our FindBestWindowPosForPopup() function will move the new menu outside the parent bounds.
|
|
|
// This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
|
|
|
IM_ASSERT(g.CurrentWindow == window);
|
|
|
ImGuiWindow* parent_menu = g.CurrentWindowStack[g.CurrentWindowStack.Size - 2];
|
|
|
@@ -5464,7 +5458,7 @@ static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents)
|
|
|
else
|
|
|
{
|
|
|
// When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding.
|
|
|
- size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding));
|
|
|
+ size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding * 2.0f));
|
|
|
ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit);
|
|
|
if (size_auto_fit_after_constraint.x < size_contents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar))
|
|
|
size_auto_fit.y += style.ScrollbarSize;
|
|
|
@@ -5811,6 +5805,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->WindowPadding = style.WindowPadding;
|
|
|
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
|
|
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
|
|
+ window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
|
|
+ window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
|
|
|
|
|
// Collapse window by double-clicking on title bar
|
|
|
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
|
|
@@ -5927,7 +5923,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->PosFloat = FindBestWindowPosForPopup(window);
|
|
|
|
|
|
// Clamp position so it stays visible
|
|
|
- if (!(flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Tooltip))
|
|
|
+ if (!(flags & ImGuiWindowFlags_ChildWindow))
|
|
|
{
|
|
|
if (!window_pos_set_by_api && window->AutoFitFramesX <= 0 && window->AutoFitFramesY <= 0 && g.IO.DisplaySize.x > 0.0f && g.IO.DisplaySize.y > 0.0f) // Ignore zero-sized display explicitly to avoid losing positions if a window manager reports zero-sized window when initializing or minimizing.
|
|
|
{
|
|
|
@@ -5938,12 +5934,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
}
|
|
|
window->Pos = ImFloor(window->PosFloat);
|
|
|
|
|
|
- // Default item width. Make it proportional to window size if window manually resizes
|
|
|
- if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
|
|
|
- window->ItemWidthDefault = (float)(int)(window->Size.x * 0.65f);
|
|
|
- else
|
|
|
- window->ItemWidthDefault = (float)(int)(g.FontSize * 16.0f);
|
|
|
-
|
|
|
// Prepare for focus requests
|
|
|
window->FocusIdxAllRequestCurrent = (window->FocusIdxAllRequestNext == INT_MAX || window->FocusIdxAllCounter == -1) ? INT_MAX : (window->FocusIdxAllRequestNext + (window->FocusIdxAllCounter+1)) % (window->FocusIdxAllCounter+1);
|
|
|
window->FocusIdxTabRequestCurrent = (window->FocusIdxTabRequestNext == INT_MAX || window->FocusIdxTabCounter == -1) ? INT_MAX : (window->FocusIdxTabRequestNext + (window->FocusIdxTabCounter+1)) % (window->FocusIdxTabCounter+1);
|
|
|
@@ -5968,6 +5958,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
if (!window->Collapsed)
|
|
|
UpdateManualResize(window, size_auto_fit, &border_held, resize_grip_count, &resize_grip_col[0]);
|
|
|
|
|
|
+ // Default item width. Make it proportional to window size if window manually resizes
|
|
|
+ if (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize))
|
|
|
+ window->ItemWidthDefault = (float)(int)(window->Size.x * 0.65f);
|
|
|
+ else
|
|
|
+ window->ItemWidthDefault = (float)(int)(g.FontSize * 16.0f);
|
|
|
+
|
|
|
// DRAWING
|
|
|
|
|
|
// Setup draw list and outer clipping rectangle
|
|
|
@@ -6104,7 +6100,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|
|
window->DC.NavLayerActiveMask = window->DC.NavLayerActiveMaskNext;
|
|
|
window->DC.NavLayerActiveMaskNext = 0x00;
|
|
|
window->DC.MenuBarAppending = false;
|
|
|
- window->DC.MenuBarOffsetX = ImMax(window->WindowPadding.x, style.ItemSpacing.x);
|
|
|
window->DC.LogLinePosY = window->DC.CursorPos.y - 9999.0f;
|
|
|
window->DC.ChildWindows.resize(0);
|
|
|
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
|
|
@@ -11148,21 +11143,24 @@ bool ImGui::MenuItem(const char* label, const char* shortcut, bool* p_selected,
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+// For the main menu bar, which cannot be moved, we honor g.Style.DisplaySafeAreaPadding to ensure text can be visible on a TV set.
|
|
|
bool ImGui::BeginMainMenuBar()
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(g.Style.DisplaySafeAreaPadding.x, ImMax(g.Style.DisplaySafeAreaPadding.y - g.Style.FramePadding.y, 0.0f));
|
|
|
SetNextWindowPos(ImVec2(0.0f, 0.0f));
|
|
|
- SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.FontBaseSize + g.Style.FramePadding.y * 2.0f));
|
|
|
+ SetNextWindowSize(ImVec2(g.IO.DisplaySize.x, g.NextWindowData.MenuBarOffsetMinVal.y + g.FontBaseSize + g.Style.FramePadding.y));
|
|
|
PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
|
|
PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(0,0));
|
|
|
- if (!Begin("##MainMenuBar", NULL, ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollbar|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_MenuBar)
|
|
|
- || !BeginMenuBar())
|
|
|
+ ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_MenuBar;
|
|
|
+ bool is_open = Begin("##MainMenuBar", NULL, window_flags) && BeginMenuBar();
|
|
|
+ g.NextWindowData.MenuBarOffsetMinVal = ImVec2(0.0f, 0.0f);
|
|
|
+ if (!is_open)
|
|
|
{
|
|
|
End();
|
|
|
PopStyleVar(2);
|
|
|
return false;
|
|
|
}
|
|
|
- g.CurrentWindow->DC.MenuBarOffsetX += g.Style.DisplaySafeAreaPadding.x;
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -11191,14 +11189,14 @@ bool ImGui::BeginMenuBar()
|
|
|
BeginGroup(); // Save position
|
|
|
PushID("##menubar");
|
|
|
|
|
|
- // We don't clip with regular window clipping rectangle as it is already set to the area below. However we clip with window full rect.
|
|
|
- // We remove 1 worth of rounding to Max.x to that text in long menus don't tend to display over the lower-right rounded area, which looks particularly glitchy.
|
|
|
+ // We don't clip with current window clipping rectangle as it is already set to the area below. However we clip with window full rect.
|
|
|
+ // We remove 1 worth of rounding to Max.x to that text in long menus and small windows don't tend to display over the lower-right rounded area, which looks particularly glitchy.
|
|
|
ImRect bar_rect = window->MenuBarRect();
|
|
|
ImRect clip_rect(ImFloor(bar_rect.Min.x + 0.5f), ImFloor(bar_rect.Min.y + window->WindowBorderSize + 0.5f), ImFloor(ImMax(bar_rect.Min.x, bar_rect.Max.x - window->WindowRounding) + 0.5f), ImFloor(bar_rect.Max.y + 0.5f));
|
|
|
clip_rect.ClipWith(window->WindowRectClipped);
|
|
|
PushClipRect(clip_rect.Min, clip_rect.Max, false);
|
|
|
|
|
|
- window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffsetX, bar_rect.Min.y);// + g.Style.FramePadding.y);
|
|
|
+ window->DC.CursorPos = ImVec2(bar_rect.Min.x + window->DC.MenuBarOffset.x, bar_rect.Min.y + window->DC.MenuBarOffset.y);
|
|
|
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
|
|
|
window->DC.NavLayerCurrent++;
|
|
|
window->DC.NavLayerCurrentMask <<= 1;
|
|
|
@@ -11238,7 +11236,7 @@ void ImGui::EndMenuBar()
|
|
|
IM_ASSERT(window->DC.MenuBarAppending);
|
|
|
PopClipRect();
|
|
|
PopID();
|
|
|
- window->DC.MenuBarOffsetX = window->DC.CursorPos.x - window->MenuBarRect().Min.x;
|
|
|
+ window->DC.MenuBarOffset.x = window->DC.CursorPos.x - window->MenuBarRect().Min.x; // Save horizontal position so next append can reuse it. This is kinda equivalent to a per-layer CursorPos.
|
|
|
window->DC.GroupStack.back().AdvanceCursor = false;
|
|
|
EndGroup();
|
|
|
window->DC.LayoutType = ImGuiLayoutType_Vertical;
|
|
|
@@ -11266,13 +11264,13 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|
|
if (menuset_is_open)
|
|
|
g.NavWindow = window; // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent)
|
|
|
|
|
|
- // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu (using FindBestPopupWindowPos).
|
|
|
+ // The reference position stored in popup_pos will be used by Begin() to find a suitable position for the child menu (using FindBestWindowPosForPopup).
|
|
|
ImVec2 popup_pos, pos = window->DC.CursorPos;
|
|
|
if (window->DC.LayoutType == ImGuiLayoutType_Horizontal)
|
|
|
{
|
|
|
// Menu inside an horizontal menu bar
|
|
|
// Selectable extend their highlight by half ItemSpacing in each direction.
|
|
|
- // For ChildMenu, the popup position will be overwritten by the call to FindBestPopupWindowPos() in Begin()
|
|
|
+ // For ChildMenu, the popup position will be overwritten by the call to FindBestWindowPosForPopup() in Begin()
|
|
|
popup_pos = ImVec2(pos.x - window->WindowPadding.x, pos.y - style.FramePadding.y + window->MenuBarHeight());
|
|
|
window->DC.CursorPos.x += (float)(int)(style.ItemSpacing.x * 0.5f);
|
|
|
PushStyleVar(ImGuiStyleVar_ItemSpacing, style.ItemSpacing * 2.0f);
|