mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-26 02:34:23 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_dx10.cpp # backends/imgui_impl_dx11.cpp # backends/imgui_impl_dx12.cpp # backends/imgui_impl_sdl2.cpp # backends/imgui_impl_sdl3.cpp # examples/example_glfw_metal/main.mm # examples/example_glfw_opengl2/main.cpp # examples/example_glfw_opengl3/main.cpp # examples/example_glfw_vulkan/main.cpp # examples/example_sdl2_directx11/main.cpp # examples/example_sdl2_opengl2/main.cpp # examples/example_sdl2_opengl3/main.cpp # examples/example_sdl2_sdlrenderer2/main.cpp # examples/example_sdl2_vulkan/main.cpp # examples/example_sdl3_directx11/main.cpp # examples/example_sdl3_opengl3/main.cpp # examples/example_sdl3_sdlgpu3/main.cpp # examples/example_sdl3_sdlrenderer3/main.cpp # examples/example_sdl3_vulkan/main.cpp # examples/example_win32_directx10/main.cpp # examples/example_win32_directx11/main.cpp # examples/example_win32_directx12/main.cpp # examples/example_win32_directx9/main.cpp # examples/example_win32_opengl3/main.cpp # examples/example_win32_vulkan/main.cpp # imgui_internal.h
This commit is contained in:
commit
2a08c87b8c
66 changed files with 308 additions and 310 deletions
102
imgui.cpp
102
imgui.cpp
|
|
@ -3708,11 +3708,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, float val)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->DataType != ImGuiDataType_Float || var_info->Count != 1)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(var_info->DataType == ImGuiDataType_Float && var_info->Count == 1, "Calling PushStyleVar() variant with wrong type!");
|
||||
float* pvar = (float*)var_info->GetVarPtr(&g.Style);
|
||||
g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar));
|
||||
*pvar = val;
|
||||
|
|
@ -3722,11 +3718,7 @@ void ImGui::PushStyleVarX(ImGuiStyleVar idx, float val_x)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->DataType != ImGuiDataType_Float || var_info->Count != 2)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(var_info->DataType == ImGuiDataType_Float && var_info->Count == 2, "Calling PushStyleVar() variant with wrong type!");
|
||||
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
|
||||
g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar));
|
||||
pvar->x = val_x;
|
||||
|
|
@ -3736,11 +3728,7 @@ void ImGui::PushStyleVarY(ImGuiStyleVar idx, float val_y)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->DataType != ImGuiDataType_Float || var_info->Count != 2)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(var_info->DataType == ImGuiDataType_Float && var_info->Count == 2, "Calling PushStyleVar() variant with wrong type!");
|
||||
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
|
||||
g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar));
|
||||
pvar->y = val_y;
|
||||
|
|
@ -3750,11 +3738,7 @@ void ImGui::PushStyleVar(ImGuiStyleVar idx, const ImVec2& val)
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
const ImGuiStyleVarInfo* var_info = GetStyleVarInfo(idx);
|
||||
if (var_info->DataType != ImGuiDataType_Float || var_info->Count != 2)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PushStyleVar() variant with wrong type!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(var_info->DataType == ImGuiDataType_Float && var_info->Count == 2, "Calling PushStyleVar() variant with wrong type!");
|
||||
ImVec2* pvar = (ImVec2*)var_info->GetVarPtr(&g.Style);
|
||||
g.StyleVarStack.push_back(ImGuiStyleMod(idx, *pvar));
|
||||
*pvar = val;
|
||||
|
|
@ -5212,10 +5196,11 @@ void ImGui::DebugAllocHook(ImGuiDebugAllocInfo* info, int frame_count, void* ptr
|
|||
}
|
||||
}
|
||||
|
||||
// A conformant backend should return NULL on failure (e.g. clipboard data is not text).
|
||||
const char* ImGui::GetClipboardText()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : "";
|
||||
return g.PlatformIO.Platform_GetClipboardTextFn ? g.PlatformIO.Platform_GetClipboardTextFn(&g) : NULL;
|
||||
}
|
||||
|
||||
void ImGui::SetClipboardText(const char* text)
|
||||
|
|
@ -6195,11 +6180,7 @@ void ImGui::EndFrame()
|
|||
// Don't process EndFrame() multiple times.
|
||||
if (g.FrameCountEnded == g.FrameCount)
|
||||
return;
|
||||
if (!g.WithinFrameScope)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(g.WithinFrameScope, "Forgot to call ImGui::NewFrame()?");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(g.WithinFrameScope, "Forgot to call ImGui::NewFrame()?");
|
||||
|
||||
CallContextHooks(&g, ImGuiContextHookType_EndFramePre);
|
||||
|
||||
|
|
@ -8504,13 +8485,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||
window->DC.ParentLayoutType = parent_window ? parent_window->DC.LayoutType : ImGuiLayoutType_Vertical;
|
||||
|
||||
// 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 = ImTrunc(window->Size.x * 0.65f);
|
||||
const bool is_resizable_window = (window->Size.x > 0.0f && !(flags & ImGuiWindowFlags_Tooltip) && !(flags & ImGuiWindowFlags_AlwaysAutoResize));
|
||||
if (is_resizable_window)
|
||||
window->DC.ItemWidthDefault = ImTrunc(window->Size.x * 0.65f);
|
||||
else
|
||||
window->ItemWidthDefault = ImTrunc(g.FontSize * 16.0f);
|
||||
window->DC.ItemWidth = window->ItemWidthDefault;
|
||||
window->DC.TextWrapPos = -1.0f; // disabled
|
||||
window->DC.ItemWidthDefault = ImTrunc(g.FontSize * 16.0f);
|
||||
window->DC.ItemWidth = window->DC.ItemWidthDefault;
|
||||
window->DC.ItemWidthStack.resize(0);
|
||||
window->DC.TextWrapPos = -1.0f; // Disabled
|
||||
window->DC.TextWrapPosStack.resize(0);
|
||||
if (flags & ImGuiWindowFlags_Modal)
|
||||
window->DC.ModalDimBgColor = ColorConvertFloat4ToU32(GetStyleColorVec4(ImGuiCol_ModalWindowDimBg));
|
||||
|
|
@ -8789,11 +8771,7 @@ void ImGui::PushItemFlag(ImGuiItemFlags option, bool enabled)
|
|||
void ImGui::PopItemFlag()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.ItemFlagsStack.Size <= 1)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PopItemFlag() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(g.ItemFlagsStack.Size > 1, "Calling PopItemFlag() too many times!");
|
||||
g.ItemFlagsStack.pop_back();
|
||||
g.CurrentItemFlags = g.ItemFlagsStack.back();
|
||||
}
|
||||
|
|
@ -8823,11 +8801,7 @@ void ImGui::BeginDisabled(bool disabled)
|
|||
void ImGui::EndDisabled()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.DisabledStackSize <= 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndDisabled() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(g.DisabledStackSize > 0, "Calling EndDisabled() too many times!");
|
||||
g.DisabledStackSize--;
|
||||
bool was_disabled = (g.CurrentItemFlags & ImGuiItemFlags_Disabled) != 0;
|
||||
//PopItemFlag();
|
||||
|
|
@ -8854,8 +8828,8 @@ void ImGui::BeginDisabledOverrideReenable()
|
|||
void ImGui::EndDisabledOverrideReenable()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.DisabledStackSize--;
|
||||
IM_ASSERT(g.DisabledStackSize > 0);
|
||||
g.DisabledStackSize--;
|
||||
g.ItemFlagsStack.pop_back();
|
||||
g.CurrentItemFlags = g.ItemFlagsStack.back();
|
||||
g.Style.Alpha = g.CurrentWindowStack.back().DisabledOverrideReenableAlphaBackup;
|
||||
|
|
@ -8874,11 +8848,7 @@ void ImGui::PopTextWrapPos()
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (window->DC.TextWrapPosStack.Size <= 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PopTextWrapPos() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(window->DC.TextWrapPosStack.Size > 0, "Calling PopTextWrapPos() too many times!");
|
||||
window->DC.TextWrapPos = window->DC.TextWrapPosStack.back();
|
||||
window->DC.TextWrapPosStack.pop_back();
|
||||
}
|
||||
|
|
@ -9330,11 +9300,7 @@ void ImGui::PushFocusScope(ImGuiID id)
|
|||
void ImGui::PopFocusScope()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.FocusScopeStack.Size <= g.StackSizesInBeginForCurrentWindow->SizeOfFocusScopeStack)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PopFocusScope() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(g.FocusScopeStack.Size > g.StackSizesInBeginForCurrentWindow->SizeOfFocusScopeStack, "Calling PopFocusScope() too many times!");
|
||||
g.FocusScopeStack.pop_back();
|
||||
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back().ID : 0;
|
||||
}
|
||||
|
|
@ -9667,7 +9633,7 @@ void ImGui::UpdateCurrentFontSize(float restore_font_size_after_scaling)
|
|||
|
||||
// Global scale factors
|
||||
final_size *= g.Style.FontScaleMain; // Main global scale factor
|
||||
final_size *= g.Style.FontScaleDpi; // Per-monitor/viewport DPI scale factor, automatically updated when io.ConfigDpiScaleFonts is enabled.
|
||||
final_size *= g.Style.FontScaleDpi; // Per-monitor/viewport DPI scale factor (in docking branch: automatically updated when io.ConfigDpiScaleFonts is enabled).
|
||||
|
||||
// Window scale (mostly obsolete now)
|
||||
if (window != NULL)
|
||||
|
|
@ -9725,11 +9691,7 @@ void ImGui::PushFont(ImFont* font, float font_size_base)
|
|||
void ImGui::PopFont()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.FontStack.Size <= 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PopFont() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(g.FontStack.Size > 0, "Calling PopFont() too many times!");
|
||||
ImFontStackData* font_stack_data = &g.FontStack.back();
|
||||
SetCurrentFont(font_stack_data->Font, font_stack_data->FontSizeBeforeScaling, font_stack_data->FontSizeAfterScaling);
|
||||
g.FontStack.pop_back();
|
||||
|
|
@ -9869,11 +9831,7 @@ ImGuiID ImGui::GetIDWithSeed(int n, ImGuiID seed)
|
|||
void ImGui::PopID()
|
||||
{
|
||||
ImGuiWindow* window = GImGui->CurrentWindow;
|
||||
if (window->IDStack.Size <= 1)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling PopID() too many times!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET(window->IDStack.Size > 1, "Calling PopID() too many times!");
|
||||
window->IDStack.pop_back();
|
||||
}
|
||||
|
||||
|
|
@ -12172,7 +12130,7 @@ void ImGui::PushItemWidth(float item_width)
|
|||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->DC.ItemWidthStack.push_back(window->DC.ItemWidth); // Backup current width
|
||||
window->DC.ItemWidth = (item_width == 0.0f ? window->ItemWidthDefault : item_width);
|
||||
window->DC.ItemWidth = (item_width == 0.0f ? window->DC.ItemWidthDefault : item_width);
|
||||
g.NextItemData.HasFlags &= ~ImGuiNextItemDataFlags_HasWidth;
|
||||
}
|
||||
|
||||
|
|
@ -13138,11 +13096,7 @@ void ImGui::EndPopup()
|
|||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if ((window->Flags & ImGuiWindowFlags_Popup) == 0 || g.BeginPopupStack.Size == 0)
|
||||
{
|
||||
IM_ASSERT_USER_ERROR(0, "Calling EndPopup() in wrong window!");
|
||||
return;
|
||||
}
|
||||
IM_ASSERT_USER_ERROR_RET((window->Flags & ImGuiWindowFlags_Popup) != 0 && g.BeginPopupStack.Size > 0, "Calling EndPopup() in wrong window!");
|
||||
|
||||
// Make all menus and popups wrap around for now, may need to expose that policy (e.g. focus scope could include wrap/loop policy flags used by new move requests)
|
||||
if (g.NavWindow == window)
|
||||
|
|
@ -14191,7 +14145,7 @@ void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags wra
|
|||
|
||||
// In theory we should test for NavMoveRequestButNoResultYet() but there's no point doing it:
|
||||
// as NavEndFrame() will do the same test. It will end up calling NavUpdateCreateWrappingRequest().
|
||||
if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == ImGuiNavLayer_Main)
|
||||
if (g.NavWindow == window && g.NavMoveScoringItems && g.NavLayer == window->DC.NavLayerCurrent)
|
||||
g.NavMoveFlags = (g.NavMoveFlags & ~ImGuiNavMoveFlags_WrapMask_) | wrap_flags;
|
||||
}
|
||||
|
||||
|
|
@ -15012,9 +14966,13 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
|||
|
||||
const ImGuiNavMoveFlags move_flags = g.NavMoveFlags;
|
||||
//const ImGuiAxis move_axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
|
||||
|
||||
// Menu layer does not maintain scrolling / content size (#9178)
|
||||
ImVec2 wrap_size = (g.NavLayer == ImGuiNavLayer_Menu) ? window->Size : window->ContentSize + window->WindowPadding;
|
||||
|
||||
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
|
||||
{
|
||||
bb_rel.Min.x = bb_rel.Max.x = window->ContentSize.x + window->WindowPadding.x;
|
||||
bb_rel.Min.x = bb_rel.Max.x = wrap_size.x;
|
||||
if (move_flags & ImGuiNavMoveFlags_WrapX)
|
||||
{
|
||||
bb_rel.TranslateY(-bb_rel.GetHeight()); // Previous row
|
||||
|
|
@ -15034,7 +14992,7 @@ static void ImGui::NavUpdateCreateWrappingRequest()
|
|||
}
|
||||
if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
|
||||
{
|
||||
bb_rel.Min.y = bb_rel.Max.y = window->ContentSize.y + window->WindowPadding.y;
|
||||
bb_rel.Min.y = bb_rel.Max.y = wrap_size.y;
|
||||
if (move_flags & ImGuiNavMoveFlags_WrapY)
|
||||
{
|
||||
bb_rel.TranslateX(-bb_rel.GetWidth()); // Previous column
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue