mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 13:08:47 +02:00
Merge branch 'master' into docking
# Conflicts: # examples/imgui_impl_glfw.cpp # examples/imgui_impl_opengl2.cpp # imgui.cpp # imgui_internal.h
This commit is contained in:
126
imgui.cpp
126
imgui.cpp
@ -373,6 +373,7 @@ CODE
|
||||
- 2019/XX/XX (1.XX) - Moved IME support functions from io.ImeSetInputScreenPosFn, io.ImeWindowHandle to the PlatformIO api.
|
||||
|
||||
|
||||
- 2020/01/22 (1.75) - ImDrawList::AddCircle()/AddCircleFilled() functions don't accept negative radius any more.
|
||||
- 2019/12/17 (1.75) - made Columns() limited to 64 columns by asserting above that limit. While the current code technically supports it, future code may not so we're putting the restriction ahead.
|
||||
- 2019/12/13 (1.75) - [imgui_internal.h] changed ImRect() default constructor initializes all fields to 0.0f instead of (FLT_MAX,FLT_MAX,-FLT_MAX,-FLT_MAX). If you used ImRect::Add() to create bounding boxes by adding multiple points into it, you may need to fix your initial value.
|
||||
- 2019/12/08 (1.75) - removed redirecting functions/enums that were marked obsolete in 1.53 (December 2017):
|
||||
@ -824,6 +825,9 @@ CODE
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning (disable: 4127) // condition expression is constant
|
||||
#pragma warning (disable: 4996) // 'This function or variable may be unsafe': strcpy, strdup, sprintf, vsnprintf, sscanf, fopen
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1922 // MSVC 2019 16.2 or later
|
||||
#pragma warning (disable: 5054) // operator '|': deprecated between enumerations of different types
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Clang/GCC warnings with -Weverything
|
||||
@ -1013,6 +1017,7 @@ ImGuiStyle::ImGuiStyle()
|
||||
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.)
|
||||
CurveTessellationTol = 1.25f; // Tessellation tolerance when using PathBezierCurveTo() without a specific number of segments. Decrease for highly tessellated curves (higher quality, more polygons), increase to reduce quality.
|
||||
CircleSegmentMaxError = 1.60f; // Maximum error (in pixels) allowed when using AddCircle()/AddCircleFilled() or drawing rounded corner rectangles with no explicit segment count specified. Decrease for higher quality but more geometry.
|
||||
|
||||
// Default theme
|
||||
ImGui::StyleColorsDark(this);
|
||||
@ -1392,7 +1397,6 @@ const char* ImStrSkipBlank(const char* str)
|
||||
// You may set IMGUI_USE_STB_SPRINTF to use our default wrapper, or set IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS
|
||||
// and setup the wrapper yourself. (FIXME-OPT: Some of our high-level operations such as ImGuiTextBuffer::appendfv() are
|
||||
// designed using two-passes worst case, which probably could be improved using the stbsp_vsprintfcb() function.)
|
||||
//#define IMGUI_USE_STB_SPRINTF
|
||||
#ifdef IMGUI_USE_STB_SPRINTF
|
||||
#define STB_SPRINTF_IMPLEMENTATION
|
||||
#include "stb_sprintf.h"
|
||||
@ -2804,27 +2808,6 @@ void ImGui::GcAwakeTransientWindowBuffers(ImGuiWindow* window)
|
||||
window->MemoryDrawListIdxCapacity = window->MemoryDrawListVtxCapacity = 0;
|
||||
}
|
||||
|
||||
// FIXME-NAV: Refactor those functions into a single, more explicit one.
|
||||
void ImGui::SetNavID(ImGuiID id, int nav_layer, int focus_scope_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindow);
|
||||
IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
||||
g.NavId = id;
|
||||
g.NavFocusScopeId = focus_scope_id;
|
||||
g.NavWindow->NavLastIds[nav_layer] = id;
|
||||
}
|
||||
|
||||
void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, int focus_scope_id, const ImRect& rect_rel)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetNavID(id, nav_layer, focus_scope_id);
|
||||
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
||||
g.NavMousePosDirty = true;
|
||||
g.NavDisableHighlight = false;
|
||||
g.NavDisableMouseHover = true;
|
||||
}
|
||||
|
||||
void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -2857,31 +2840,6 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
|
||||
g.ActiveIdUsingKeyInputMask = 0x00;
|
||||
}
|
||||
|
||||
// FIXME-NAV: The existence of SetNavID/SetNavIDWithRectRel/SetFocusID is incredibly messy and confusing and needs some explanation or refactoring.
|
||||
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(id != 0);
|
||||
|
||||
// Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
|
||||
// Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
|
||||
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
||||
if (g.NavWindow != window)
|
||||
g.NavInitRequest = false;
|
||||
g.NavWindow = window;
|
||||
g.NavId = id;
|
||||
g.NavLayer = nav_layer;
|
||||
g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
window->NavLastIds[nav_layer] = id;
|
||||
if (window->DC.LastItemId == id)
|
||||
window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
||||
|
||||
if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
||||
g.NavDisableMouseHover = true;
|
||||
else
|
||||
g.NavDisableHighlight = true;
|
||||
}
|
||||
|
||||
void ImGui::ClearActiveID()
|
||||
{
|
||||
SetActiveID(0, NULL);
|
||||
@ -3015,10 +2973,10 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
|
||||
|
||||
// [DEBUG] Item Picker tool, when enabling the "extended" version we perform the check in ItemAdd()
|
||||
#ifdef IMGUI_DEBUG_TOOL_ITEM_PICKER_EX
|
||||
if (id == g.DebugItemPickerBreakID)
|
||||
if (id == g.DebugItemPickerBreakId)
|
||||
{
|
||||
IM_DEBUG_BREAK();
|
||||
g.DebugItemPickerBreakID = 0;
|
||||
g.DebugItemPickerBreakId = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -3117,7 +3075,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
||||
// #define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX in imconfig.h if you want this check to also be performed in ItemAdd().
|
||||
if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id)
|
||||
GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255));
|
||||
if (g.DebugItemPickerBreakID == id)
|
||||
if (g.DebugItemPickerBreakId == id)
|
||||
IM_DEBUG_BREAK();
|
||||
|
||||
return true;
|
||||
@ -3778,6 +3736,7 @@ static void NewFrameSanityChecks()
|
||||
IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?");
|
||||
IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!");
|
||||
IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!");
|
||||
IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting.");
|
||||
IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right);
|
||||
@ -3891,6 +3850,7 @@ void ImGui::NewFrame()
|
||||
virtual_space.Add(g.Viewports[n]->GetRect());
|
||||
g.DrawListSharedData.ClipRectFullscreen = ImVec4(virtual_space.Min.x, virtual_space.Min.y, virtual_space.Max.x, virtual_space.Max.y);
|
||||
g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol;
|
||||
g.DrawListSharedData.SetCircleSegmentMaxError(g.Style.CircleSegmentMaxError);
|
||||
g.DrawListSharedData.InitialFlags = ImDrawListFlags_None;
|
||||
if (g.Style.AntiAliasedLines)
|
||||
g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AntiAliasedLines;
|
||||
@ -4071,7 +4031,7 @@ void ImGui::NewFrame()
|
||||
void ImGui::UpdateDebugToolItemPicker()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.DebugItemPickerBreakID = 0;
|
||||
g.DebugItemPickerBreakId = 0;
|
||||
if (g.DebugItemPickerActive)
|
||||
{
|
||||
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
|
||||
@ -4080,7 +4040,7 @@ void ImGui::UpdateDebugToolItemPicker()
|
||||
g.DebugItemPickerActive = false;
|
||||
if (ImGui::IsMouseClicked(0) && hovered_id)
|
||||
{
|
||||
g.DebugItemPickerBreakID = hovered_id;
|
||||
g.DebugItemPickerBreakId = hovered_id;
|
||||
g.DebugItemPickerActive = false;
|
||||
}
|
||||
ImGui::SetNextWindowBgAlpha(0.60f);
|
||||
@ -7644,6 +7604,22 @@ void ImGui::ActivateItem(ImGuiID id)
|
||||
g.NavNextActivateId = id;
|
||||
}
|
||||
|
||||
void ImGui::PushFocusScope(ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->IDStack.push_back(window->DC.NavFocusScopeIdCurrent);
|
||||
window->DC.NavFocusScopeIdCurrent = id;
|
||||
}
|
||||
|
||||
void ImGui::PopFocusScope()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
window->DC.NavFocusScopeIdCurrent = window->IDStack.back();
|
||||
window->IDStack.pop_back();
|
||||
}
|
||||
|
||||
void ImGui::SetKeyboardFocusHere(int offset)
|
||||
{
|
||||
IM_ASSERT(offset >= -1); // -1 is allowed but not below
|
||||
@ -8596,6 +8572,52 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
|
||||
// [SECTION] KEYBOARD/GAMEPAD NAVIGATION
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// FIXME-NAV: The existance of SetNavID vs SetNavIDWithRectRel vs SetFocusID is incredibly messy and confusing,
|
||||
// and needs some explanation or serious refactoring.
|
||||
void ImGui::SetNavID(ImGuiID id, int nav_layer, ImGuiID focus_scope_id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindow);
|
||||
IM_ASSERT(nav_layer == 0 || nav_layer == 1);
|
||||
g.NavId = id;
|
||||
g.NavFocusScopeId = focus_scope_id;
|
||||
g.NavWindow->NavLastIds[nav_layer] = id;
|
||||
}
|
||||
|
||||
void ImGui::SetNavIDWithRectRel(ImGuiID id, int nav_layer, ImGuiID focus_scope_id, const ImRect& rect_rel)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
SetNavID(id, nav_layer, focus_scope_id);
|
||||
g.NavWindow->NavRectRel[nav_layer] = rect_rel;
|
||||
g.NavMousePosDirty = true;
|
||||
g.NavDisableHighlight = false;
|
||||
g.NavDisableMouseHover = true;
|
||||
}
|
||||
|
||||
void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(id != 0);
|
||||
|
||||
// Assume that SetFocusID() is called in the context where its window->DC.NavLayerCurrent and window->DC.NavFocusScopeIdCurrent are valid.
|
||||
// Note that window may be != g.CurrentWindow (e.g. SetFocusID call in InputTextEx for multi-line text)
|
||||
const ImGuiNavLayer nav_layer = window->DC.NavLayerCurrent;
|
||||
if (g.NavWindow != window)
|
||||
g.NavInitRequest = false;
|
||||
g.NavWindow = window;
|
||||
g.NavId = id;
|
||||
g.NavLayer = nav_layer;
|
||||
g.NavFocusScopeId = window->DC.NavFocusScopeIdCurrent;
|
||||
window->NavLastIds[nav_layer] = id;
|
||||
if (window->DC.LastItemId == id)
|
||||
window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos);
|
||||
|
||||
if (g.ActiveIdSource == ImGuiInputSource_Nav)
|
||||
g.NavDisableMouseHover = true;
|
||||
else
|
||||
g.NavDisableHighlight = true;
|
||||
}
|
||||
|
||||
ImGuiDir ImGetDirQuadrantFromDelta(float dx, float dy)
|
||||
{
|
||||
if (ImFabs(dx) > ImFabs(dy))
|
||||
|
Reference in New Issue
Block a user