mirror of
https://github.com/ocornut/imgui.git
synced 2025-12-21 22:05:57 +00:00
Merge branch 'master' into docking
# Conflicts: # backends/imgui_impl_sdlgpu3.cpp # backends/imgui_impl_win32.cpp
This commit is contained in:
36
imgui.cpp
36
imgui.cpp
@@ -2096,7 +2096,7 @@ bool ImTriangleContainsPoint(const ImVec2& a, const ImVec2& b, const ImVec2& c,
|
||||
bool b1 = ((p.x - b.x) * (a.y - b.y) - (p.y - b.y) * (a.x - b.x)) < 0.0f;
|
||||
bool b2 = ((p.x - c.x) * (b.y - c.y) - (p.y - c.y) * (b.x - c.x)) < 0.0f;
|
||||
bool b3 = ((p.x - a.x) * (c.y - a.y) - (p.y - a.y) * (c.x - a.x)) < 0.0f;
|
||||
return ((b1 == b2) && (b2 == b3));
|
||||
return (b1 == b2) && (b2 == b3);
|
||||
}
|
||||
|
||||
void ImTriangleBarycentricCoords(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& p, float& out_u, float& out_v, float& out_w)
|
||||
@@ -3196,7 +3196,7 @@ IM_MSVC_RUNTIME_CHECKS_RESTORE
|
||||
static bool GetSkipItemForListClipping()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return (g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems);
|
||||
return g.CurrentTable ? g.CurrentTable->HostSkipItems : g.CurrentWindow->SkipItems;
|
||||
}
|
||||
|
||||
static void ImGuiListClipper_SortAndFuseRanges(ImVector<ImGuiListClipperRange>& ranges, int offset = 0)
|
||||
@@ -4421,7 +4421,7 @@ void ImGui::Initialize()
|
||||
g.ViewportCreatedCount++;
|
||||
g.PlatformIO.Viewports.push_back(g.Viewports[0]);
|
||||
|
||||
// Build KeysMayBeCharInput[] lookup table (1 bool per named key)
|
||||
// Build KeysMayBeCharInput[] lookup table (1 bit per named key)
|
||||
for (ImGuiKey key = ImGuiKey_NamedKey_BEGIN; key < ImGuiKey_NamedKey_END; key = (ImGuiKey)(key + 1))
|
||||
if ((key >= ImGuiKey_0 && key <= ImGuiKey_9) || (key >= ImGuiKey_A && key <= ImGuiKey_Z) || (key >= ImGuiKey_Keypad0 && key <= ImGuiKey_Keypad9)
|
||||
|| key == ImGuiKey_Tab || key == ImGuiKey_Space || key == ImGuiKey_Apostrophe || key == ImGuiKey_Comma || key == ImGuiKey_Minus || key == ImGuiKey_Period
|
||||
@@ -4547,6 +4547,13 @@ void ImGui::Shutdown()
|
||||
g.Initialized = false;
|
||||
}
|
||||
|
||||
// When using multiple context it can be helpful to give name a name.
|
||||
// (A) Will be visible in debugger, (B) Will be included in all IMGUI_DEBUG_LOG() calls, (C) Should be <= 15 characters long.
|
||||
void ImGui::SetContextName(ImGuiContext* ctx, const char* name)
|
||||
{
|
||||
ImStrncpy(ctx->ContextName, name, IM_ARRAYSIZE(ctx->ContextName));
|
||||
}
|
||||
|
||||
// No specific ordering/dependency support, will see as needed
|
||||
ImGuiID ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook)
|
||||
{
|
||||
@@ -5472,7 +5479,7 @@ static void ScaleWindow(ImGuiWindow* window, float scale)
|
||||
|
||||
static bool IsWindowActiveAndVisible(ImGuiWindow* window)
|
||||
{
|
||||
return (window->Active) && (!window->Hidden);
|
||||
return window->Active && !window->Hidden;
|
||||
}
|
||||
|
||||
// The reason this is exposed in imgui_internal.h is: on touch-based system that don't have hovering, we want to dispatch inputs to the right target (imgui vs imgui+app)
|
||||
@@ -5887,7 +5894,7 @@ static int IMGUI_CDECL ChildWindowComparer(const void* lhs, const void* rhs)
|
||||
return d;
|
||||
if (int d = (a->Flags & ImGuiWindowFlags_Tooltip) - (b->Flags & ImGuiWindowFlags_Tooltip))
|
||||
return d;
|
||||
return (a->BeginOrderWithinParent - b->BeginOrderWithinParent);
|
||||
return a->BeginOrderWithinParent - b->BeginOrderWithinParent;
|
||||
}
|
||||
|
||||
static void AddWindowToSortBuffer(ImVector<ImGuiWindow*>* out_sorted_windows, ImGuiWindow* window)
|
||||
@@ -6434,7 +6441,7 @@ bool ImGui::IsItemDeactivated()
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_HasDeactivated)
|
||||
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Deactivated) != 0;
|
||||
return (g.DeactivatedItemData.ID == g.LastItemData.ID && g.LastItemData.ID != 0 && g.DeactivatedItemData.ElapseFrame >= g.FrameCount);
|
||||
return g.DeactivatedItemData.ID == g.LastItemData.ID && g.LastItemData.ID != 0 && g.DeactivatedItemData.ElapseFrame >= g.FrameCount;
|
||||
}
|
||||
|
||||
bool ImGui::IsItemDeactivatedAfterEdit()
|
||||
@@ -6880,13 +6887,13 @@ static inline ImVec2 CalcWindowMinSize(ImGuiWindow* window)
|
||||
ImVec2 size_min;
|
||||
if ((window->Flags & ImGuiWindowFlags_ChildWindow) && !(window->Flags & ImGuiWindowFlags_Popup))
|
||||
{
|
||||
size_min.x = (window->ChildFlags & ImGuiChildFlags_ResizeX) ? g.Style.WindowMinSize.x : 4.0f;
|
||||
size_min.y = (window->ChildFlags & ImGuiChildFlags_ResizeY) ? g.Style.WindowMinSize.y : 4.0f;
|
||||
size_min.x = (window->ChildFlags & ImGuiChildFlags_ResizeX) ? g.Style.WindowMinSize.x : IMGUI_WINDOW_HARD_MIN_SIZE;
|
||||
size_min.y = (window->ChildFlags & ImGuiChildFlags_ResizeY) ? g.Style.WindowMinSize.y : IMGUI_WINDOW_HARD_MIN_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : 4.0f;
|
||||
size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.y : 4.0f;
|
||||
size_min.x = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.x : IMGUI_WINDOW_HARD_MIN_SIZE;
|
||||
size_min.y = ((window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0) ? g.Style.WindowMinSize.y : IMGUI_WINDOW_HARD_MIN_SIZE;
|
||||
}
|
||||
|
||||
// Reduce artifacts with very small windows
|
||||
@@ -10008,7 +10015,7 @@ int ImGui::CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, flo
|
||||
if (t0 >= t1)
|
||||
return 0;
|
||||
if (repeat_rate <= 0.0f)
|
||||
return (t0 < repeat_delay) && (t1 >= repeat_delay);
|
||||
return t0 < repeat_delay && t1 >= repeat_delay;
|
||||
const int count_t0 = (t0 < repeat_delay) ? -1 : (int)((t0 - repeat_delay) / repeat_rate);
|
||||
const int count_t1 = (t1 < repeat_delay) ? -1 : (int)((t1 - repeat_delay) / repeat_rate);
|
||||
const int count = count_t1 - count_t0;
|
||||
@@ -10951,12 +10958,13 @@ static const char* GetMouseSourceName(ImGuiMouseSource source)
|
||||
static void DebugPrintInputEvent(const char* prefix, const ImGuiInputEvent* e)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
char buf[5];
|
||||
if (e->Type == ImGuiInputEventType_MousePos) { if (e->MousePos.PosX == -FLT_MAX && e->MousePos.PosY == -FLT_MAX) IMGUI_DEBUG_LOG_IO("[io] %s: MousePos (-FLT_MAX, -FLT_MAX)\n", prefix); else IMGUI_DEBUG_LOG_IO("[io] %s: MousePos (%.1f, %.1f) (%s)\n", prefix, e->MousePos.PosX, e->MousePos.PosY, GetMouseSourceName(e->MousePos.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseButton) { IMGUI_DEBUG_LOG_IO("[io] %s: MouseButton %d %s (%s)\n", prefix, e->MouseButton.Button, e->MouseButton.Down ? "Down" : "Up", GetMouseSourceName(e->MouseButton.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseWheel) { IMGUI_DEBUG_LOG_IO("[io] %s: MouseWheel (%.3f, %.3f) (%s)\n", prefix, e->MouseWheel.WheelX, e->MouseWheel.WheelY, GetMouseSourceName(e->MouseWheel.MouseSource)); return; }
|
||||
if (e->Type == ImGuiInputEventType_MouseViewport){IMGUI_DEBUG_LOG_IO("[io] %s: MouseViewport (0x%08X)\n", prefix, e->MouseViewport.HoveredViewportID); return; }
|
||||
if (e->Type == ImGuiInputEventType_Key) { IMGUI_DEBUG_LOG_IO("[io] %s: Key \"%s\" %s\n", prefix, ImGui::GetKeyName(e->Key.Key), e->Key.Down ? "Down" : "Up"); return; }
|
||||
if (e->Type == ImGuiInputEventType_Text) { IMGUI_DEBUG_LOG_IO("[io] %s: Text: %c (U+%08X)\n", prefix, e->Text.Char, e->Text.Char); return; }
|
||||
if (e->Type == ImGuiInputEventType_Text) { ImTextCharToUtf8(buf, e->Text.Char); IMGUI_DEBUG_LOG_IO("[io] %s: Text: '%s' (U+%08X)\n", prefix, buf, e->Text.Char); return; }
|
||||
if (e->Type == ImGuiInputEventType_Focus) { IMGUI_DEBUG_LOG_IO("[io] %s: AppFocused %d\n", prefix, e->AppFocused.Focused); return; }
|
||||
}
|
||||
#endif
|
||||
@@ -11137,7 +11145,7 @@ bool ImGui::TestKeyOwner(ImGuiKey key, ImGuiID owner_id)
|
||||
|
||||
ImGuiKeyOwnerData* owner_data = GetKeyOwnerData(&g, key);
|
||||
if (owner_id == ImGuiKeyOwner_Any)
|
||||
return (owner_data->LockThisFrame == false);
|
||||
return owner_data->LockThisFrame == false;
|
||||
|
||||
// Note: SetKeyOwner() sets OwnerCurr. It is not strictly required for most mouse routing overlap (because of ActiveId/HoveredId
|
||||
// are acting as filter before this has a chance to filter), but sane as soon as user tries to look into things.
|
||||
@@ -13378,7 +13386,7 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
|
||||
if (flags & ImGuiFocusedFlags_ChildWindows)
|
||||
return IsWindowChildOf(ref_window, cur_window, popup_hierarchy, dock_hierarchy);
|
||||
else
|
||||
return (ref_window == cur_window);
|
||||
return ref_window == cur_window;
|
||||
}
|
||||
|
||||
static int ImGui::FindWindowFocusIndex(ImGuiWindow* window)
|
||||
|
||||
Reference in New Issue
Block a user