Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ pub fn build(b: *std.Build) void {
"use_32bit_draw_idx",
"Use 32-bit draw index",
) orelse false,
.disable_obsolete = b.option(
bool,
"disable_obsolete",
"Disable obsolete imgui functions",
) orelse true,
};

const options_step = b.addOptions();
Expand Down Expand Up @@ -107,7 +112,11 @@ pub fn build(b: *std.Build) void {
}),
});

imgui.root_module.addCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS", "");
imgui.root_module.addCMacro("IMGUI_IMPL_API", "extern \"C\"");

if (options.disable_obsolete) {
imgui.root_module.addCMacro("IMGUI_DISABLE_OBSOLETE_FUNCTIONS", "");
}

if (options.shared) {
if (target.result.os.tag == .windows) {
Expand Down Expand Up @@ -437,6 +446,10 @@ pub fn build(b: *std.Build) void {
imgui.addSystemIncludePath(system_sdk.path("macos12/usr/include"));
imgui.addFrameworkPath(system_sdk.path("macos12/System/Library/Frameworks"));
}
} else if (target.result.os.tag == .linux) {
if (b.lazyDependency("system_sdk", .{})) |system_sdk| {
imgui.addSystemIncludePath(system_sdk.path("linux/include"));
}
}

const test_step = b.step("test", "Run zgui tests");
Expand Down
5 changes: 5 additions & 0 deletions libs/imgui_test_engine/imgui_capture_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (screen/video capture tool)
// This is usable as a standalone applet or controlled by the test engine.

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

// Two mode of operation:
// - Interactive: call ImGuiCaptureToolUI::ShowCaptureToolWindow()
// - Programmatic: generally via ImGuiTestContext::CaptureXXX functions
Expand Down Expand Up @@ -203,6 +206,7 @@ void ImGuiCaptureContext::PreRender()
if (IsCapturing())
{
const ImGuiCaptureArgs* args = _CaptureArgs;
IM_ASSERT(args != NULL);
g.IO.MouseDrawCursor = !(args->InFlags & ImGuiCaptureFlags_HideMouseCursor);
}
}
Expand Down Expand Up @@ -615,6 +619,7 @@ void ImGuiCaptureContext::EndVideoCapture()
IM_ASSERT(_VideoRecording == true);

_VideoRecording = false;
_CaptureArgs = nullptr;
}

bool ImGuiCaptureContext::IsCapturingVideo()
Expand Down
3 changes: 3 additions & 0 deletions libs/imgui_test_engine/imgui_capture_tool.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (screen/video capture tool)
// This is usable as a standalone applet or controlled by the test engine.

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

#pragma once

// Need "imgui_te_engine.h" included for ImFuncPtr
Expand Down
44 changes: 38 additions & 6 deletions libs/imgui_test_engine/imgui_te_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (context when a running test + end user automation API)
// This is the main (if not only) interface that your Tests will be using.

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS
#endif
Expand Down Expand Up @@ -1622,7 +1625,13 @@ void ImGuiTestContext::_MakeAimingSpaceOverPos(ImGuiViewport* viewport, ImGuiWin
LogDebug("_MakeAimingSpaceOverPos(over_window = '%s', over_pos = %.2f,%.2f)", over_window ? over_window->Name : "N/A", over_pos.x, over_pos.y);

const int over_window_n = (over_window != nullptr) ? ImGui::FindWindowDisplayIndex(over_window) : -1;
const ImVec2 window_min_pos = over_pos + g.WindowsHoverPadding + ImVec2(1.0f, 1.0f);
#if IMGUI_VERSION_NUM < 19183
const ImVec2 hover_padding = g.WindowsHoverPadding;
#else
const ImVec2 hover_padding = ImVec2(g.WindowsBorderHoverPadding, g.WindowsBorderHoverPadding);
#endif

const ImVec2 window_min_pos = over_pos + hover_padding + ImVec2(1.0f, 1.0f);
for (int window_n = g.Windows.Size - 1; window_n > over_window_n; window_n--)
{
ImGuiWindow* window = g.Windows[window_n];
Expand Down Expand Up @@ -1732,11 +1741,16 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)

// Check visibility and scroll if necessary
{
#if IMGUI_VERSION_NUM < 19183
const ImVec2 hover_padding = g.WindowsHoverPadding;
#else
const ImVec2 hover_padding = ImVec2(g.WindowsBorderHoverPadding, g.WindowsBorderHoverPadding);
#endif
if (item.NavLayer == ImGuiNavLayer_Main)
{
float min_visible_size = 10.0f;
float min_window_size_x = window->DecoInnerSizeX1 + window->DecoOuterSizeX1 + window->DecoOuterSizeX2 + min_visible_size + g.WindowsHoverPadding.x * 2.0f;
float min_window_size_y = window->DecoInnerSizeY1 + window->DecoOuterSizeY1 + window->DecoOuterSizeY2 + min_visible_size + g.WindowsHoverPadding.y * 2.0f;
float min_window_size_x = window->DecoInnerSizeX1 + window->DecoOuterSizeX1 + window->DecoOuterSizeX2 + min_visible_size + hover_padding.x * 2.0f;
float min_window_size_y = window->DecoInnerSizeY1 + window->DecoOuterSizeY1 + window->DecoOuterSizeY2 + min_visible_size + hover_padding.y * 2.0f;
if ((window->Size.x < min_window_size_x || window->Size.y < min_window_size_y) && (window->Flags & ImGuiWindowFlags_NoResize) == 0 && (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) == 0)
{
LogDebug("MouseMove: Will attempt to resize window to make item in main scrolling layer visible.");
Expand All @@ -1749,7 +1763,7 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)
}

ImRect window_r = window->InnerClipRect;
window_r.Expand(ImVec2(-g.WindowsHoverPadding.x, -g.WindowsHoverPadding.y));
window_r.Expand(ImVec2(-hover_padding.x, -hover_padding.y));

ImRect item_r_clipped;
item_r_clipped.Min.x = ImClamp(item.RectFull.Min.x, window_r.Min.x, window_r.Max.x);
Expand Down Expand Up @@ -1862,7 +1876,11 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)
if (is_hovering_resize_corner)
{
LogDebug("MouseMove: Child obstructed by parent's ResizeGrip, trying to resize window and trying again..");
#if IMGUI_VERSION_NUM < 19172
float extra_size = window->CalcFontSize() * 3.0f;
#else
float extra_size = window->FontRefSize * 3.0f;
#endif
WindowResize(window->ID, window->Size + ImVec2(extra_size, extra_size));
MouseMove(ref, flags | ImGuiTestOpFlags_IsSecondAttempt);
return;
Expand Down Expand Up @@ -1985,14 +2003,19 @@ void ImGuiTestContext::_ForeignWindowsHideOverPos(const ImVec2& pos, ImGuiWindow
for (int i = 0; ignore_list[i]; i++)
min_window_index = ImMin(min_window_index, ImGui::FindWindowDisplayIndex(ignore_list[i]));

#if IMGUI_VERSION_NUM < 19183
const ImVec2 hover_padding = g.WindowsHoverPadding;
#else
const ImVec2 hover_padding = ImVec2(g.WindowsBorderHoverPadding, g.WindowsBorderHoverPadding);
#endif
bool hidden_windows = false;
for (int i = 0; i < g.Windows.Size; i++)
{
ImGuiWindow* other_window = g.Windows[i];
if (other_window->RootWindow == other_window && other_window->WasActive)
{
ImRect r = other_window->Rect();
r.Expand(g.WindowsHoverPadding);
r.Expand(hover_padding);
if (r.Contains(pos))
{
for (int j = 0; ignore_list[j]; j++)
Expand Down Expand Up @@ -2293,6 +2316,11 @@ ImGuiWindow* ImGuiTestContext::FindHoveredWindowAtPos(const ImVec2& pos)

static bool IsPosOnVoid(ImGuiContext& g, const ImVec2& pos)
{
#if IMGUI_VERSION_NUM < 19183
const ImVec2 hover_padding = g.WindowsHoverPadding;
#else
const ImVec2 hover_padding = ImVec2(g.WindowsBorderHoverPadding, g.WindowsBorderHoverPadding);
#endif
for (ImGuiWindow* window : g.Windows)
#ifdef IMGUI_HAS_DOCK
if (window->RootWindowDockTree == window && window->WasActive)
Expand All @@ -2301,7 +2329,7 @@ static bool IsPosOnVoid(ImGuiContext& g, const ImVec2& pos)
#endif
{
ImRect r = window->Rect();
r.Expand(g.WindowsHoverPadding);
r.Expand(hover_padding);
if (r.Contains(pos))
return false;
}
Expand Down Expand Up @@ -3497,7 +3525,11 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
ItemAction(Inputs->MouseButtonsValue ? ImGuiTestAction_Hover : ImGuiTestAction_Click, buf.c_str());
}
}
#if IMGUI_VERSION_NUM < 19187
current_window = GetWindowByRef(Str16f("//##Menu_%02d", depth).c_str());
#else
current_window = GetWindowByRef(Str16f("//###Menu_%02d", depth).c_str());
#endif
IM_CHECK_SILENT(current_window != nullptr);

path = p + 1;
Expand Down
5 changes: 4 additions & 1 deletion libs/imgui_test_engine/imgui_te_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (context when a running test + end user automation API)
// This is the main (if not only) interface that your Tests will be using.

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

#pragma once

#include "imgui.h"
Expand Down Expand Up @@ -167,6 +170,7 @@ struct IMGUI_API ImGuiTestGenericItemStatus
void Clear() { memset(this, 0, sizeof(*this)); }
void QuerySet(bool ret_val = false) { Clear(); QueryInc(ret_val); }
void QueryInc(bool ret_val = false) { RetValue += ret_val; Hovered += ImGui::IsItemHovered(); Active += ImGui::IsItemActive(); Focused += ImGui::IsItemFocused(); Clicked += ImGui::IsItemClicked(); Visible += ImGui::IsItemVisible(); Edited += ImGui::IsItemEdited(); Activated += ImGui::IsItemActivated(); Deactivated += ImGui::IsItemDeactivated(); DeactivatedAfterEdit += ImGui::IsItemDeactivatedAfterEdit(); }
void Draw() { ImGui::Text("Ret: %d, Hovered: %d, Active: %d, Focused: %d\nClicked: %d, Visible: %d, Edited: %d\nActivated: %d, Deactivated: %d, DeactivatedAfterEdit: %d", RetValue, Hovered, Active, Focused, Clicked, Visible, Edited, Activated, Deactivated, DeactivatedAfterEdit); }
};

// Generic structure with various storage fields.
Expand Down Expand Up @@ -422,7 +426,6 @@ struct IMGUI_API ImGuiTestContext
void ItemClose(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0) { ItemAction(ImGuiTestAction_Close, ref, flags); }
void ItemInput(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0) { ItemAction(ImGuiTestAction_Input, ref, flags); }
void ItemNavActivate(ImGuiTestRef ref, ImGuiTestOpFlags flags = 0) { ItemAction(ImGuiTestAction_NavActivate, ref, flags); }
bool ItemOpenFullPath(ImGuiTestRef);

// Item/Widgets: Batch actions over an entire scope
void ItemActionAll(ImGuiTestAction action, ImGuiTestRef ref_parent, const ImGuiTestActionFilter* filter = nullptr);
Expand Down
3 changes: 3 additions & 0 deletions libs/imgui_test_engine/imgui_te_coroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (coroutine interface + optional implementation)
// Read https://github.com/ocornut/imgui_test_engine/wiki/Setting-Up

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

#include "imgui_te_coroutine.h"
#include "imgui.h"

Expand Down
3 changes: 3 additions & 0 deletions libs/imgui_test_engine/imgui_te_coroutine.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// (coroutine interface + optional implementation)
// Read https://github.com/ocornut/imgui_test_engine/wiki/Setting-Up

// This file is governed by the "Dear ImGui Test Engine License".
// Details of the license are provided in the LICENSE.txt file in the same directory.

#pragma once

#ifndef IMGUI_VERSION
Expand Down
Loading
Loading