2
2
// (context when a running test + end user automation API)
3
3
// This is the main (if not only) interface that your Tests will be using.
4
4
5
+ // This file is governed by the "Dear ImGui Test Engine License".
6
+ // Details of the license are provided in the LICENSE.txt file in the same directory.
7
+
5
8
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
6
9
#define _CRT_SECURE_NO_WARNINGS
7
10
#endif
@@ -1622,7 +1625,13 @@ void ImGuiTestContext::_MakeAimingSpaceOverPos(ImGuiViewport* viewport, ImGuiWin
1622
1625
LogDebug (" _MakeAimingSpaceOverPos(over_window = '%s', over_pos = %.2f,%.2f)" , over_window ? over_window->Name : " N/A" , over_pos.x , over_pos.y );
1623
1626
1624
1627
const int over_window_n = (over_window != nullptr ) ? ImGui::FindWindowDisplayIndex (over_window) : -1 ;
1625
- const ImVec2 window_min_pos = over_pos + g.WindowsHoverPadding + ImVec2 (1 .0f , 1 .0f );
1628
+ #if IMGUI_VERSION_NUM < 19183
1629
+ const ImVec2 hover_padding = g.WindowsHoverPadding ;
1630
+ #else
1631
+ const ImVec2 hover_padding = ImVec2 (g.WindowsBorderHoverPadding , g.WindowsBorderHoverPadding );
1632
+ #endif
1633
+
1634
+ const ImVec2 window_min_pos = over_pos + hover_padding + ImVec2 (1 .0f , 1 .0f );
1626
1635
for (int window_n = g.Windows .Size - 1 ; window_n > over_window_n; window_n--)
1627
1636
{
1628
1637
ImGuiWindow* window = g.Windows [window_n];
@@ -1732,11 +1741,16 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)
1732
1741
1733
1742
// Check visibility and scroll if necessary
1734
1743
{
1744
+ #if IMGUI_VERSION_NUM < 19183
1745
+ const ImVec2 hover_padding = g.WindowsHoverPadding ;
1746
+ #else
1747
+ const ImVec2 hover_padding = ImVec2 (g.WindowsBorderHoverPadding , g.WindowsBorderHoverPadding );
1748
+ #endif
1735
1749
if (item.NavLayer == ImGuiNavLayer_Main)
1736
1750
{
1737
1751
float min_visible_size = 10 .0f ;
1738
- float min_window_size_x = window->DecoInnerSizeX1 + window->DecoOuterSizeX1 + window->DecoOuterSizeX2 + min_visible_size + g. WindowsHoverPadding .x * 2 .0f ;
1739
- float min_window_size_y = window->DecoInnerSizeY1 + window->DecoOuterSizeY1 + window->DecoOuterSizeY2 + min_visible_size + g. WindowsHoverPadding .y * 2 .0f ;
1752
+ float min_window_size_x = window->DecoInnerSizeX1 + window->DecoOuterSizeX1 + window->DecoOuterSizeX2 + min_visible_size + hover_padding .x * 2 .0f ;
1753
+ float min_window_size_y = window->DecoInnerSizeY1 + window->DecoOuterSizeY1 + window->DecoOuterSizeY2 + min_visible_size + hover_padding .y * 2 .0f ;
1740
1754
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 )
1741
1755
{
1742
1756
LogDebug (" MouseMove: Will attempt to resize window to make item in main scrolling layer visible." );
@@ -1749,7 +1763,7 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)
1749
1763
}
1750
1764
1751
1765
ImRect window_r = window->InnerClipRect ;
1752
- window_r.Expand (ImVec2 (-g. WindowsHoverPadding . x , -g. WindowsHoverPadding .y ));
1766
+ window_r.Expand (ImVec2 (-hover_padding. x , -hover_padding .y ));
1753
1767
1754
1768
ImRect item_r_clipped;
1755
1769
item_r_clipped.Min .x = ImClamp (item.RectFull .Min .x , window_r.Min .x , window_r.Max .x );
@@ -1862,7 +1876,11 @@ void ImGuiTestContext::MouseMove(ImGuiTestRef ref, ImGuiTestOpFlags flags)
1862
1876
if (is_hovering_resize_corner)
1863
1877
{
1864
1878
LogDebug (" MouseMove: Child obstructed by parent's ResizeGrip, trying to resize window and trying again.." );
1879
+ #if IMGUI_VERSION_NUM < 19172
1865
1880
float extra_size = window->CalcFontSize () * 3 .0f ;
1881
+ #else
1882
+ float extra_size = window->FontRefSize * 3 .0f ;
1883
+ #endif
1866
1884
WindowResize (window->ID , window->Size + ImVec2 (extra_size, extra_size));
1867
1885
MouseMove (ref, flags | ImGuiTestOpFlags_IsSecondAttempt);
1868
1886
return ;
@@ -1985,14 +2003,19 @@ void ImGuiTestContext::_ForeignWindowsHideOverPos(const ImVec2& pos, ImGuiWindow
1985
2003
for (int i = 0 ; ignore_list[i]; i++)
1986
2004
min_window_index = ImMin (min_window_index, ImGui::FindWindowDisplayIndex (ignore_list[i]));
1987
2005
2006
+ #if IMGUI_VERSION_NUM < 19183
2007
+ const ImVec2 hover_padding = g.WindowsHoverPadding ;
2008
+ #else
2009
+ const ImVec2 hover_padding = ImVec2 (g.WindowsBorderHoverPadding , g.WindowsBorderHoverPadding );
2010
+ #endif
1988
2011
bool hidden_windows = false ;
1989
2012
for (int i = 0 ; i < g.Windows .Size ; i++)
1990
2013
{
1991
2014
ImGuiWindow* other_window = g.Windows [i];
1992
2015
if (other_window->RootWindow == other_window && other_window->WasActive )
1993
2016
{
1994
2017
ImRect r = other_window->Rect ();
1995
- r.Expand (g. WindowsHoverPadding );
2018
+ r.Expand (hover_padding );
1996
2019
if (r.Contains (pos))
1997
2020
{
1998
2021
for (int j = 0 ; ignore_list[j]; j++)
@@ -2293,6 +2316,11 @@ ImGuiWindow* ImGuiTestContext::FindHoveredWindowAtPos(const ImVec2& pos)
2293
2316
2294
2317
static bool IsPosOnVoid (ImGuiContext& g, const ImVec2& pos)
2295
2318
{
2319
+ #if IMGUI_VERSION_NUM < 19183
2320
+ const ImVec2 hover_padding = g.WindowsHoverPadding ;
2321
+ #else
2322
+ const ImVec2 hover_padding = ImVec2 (g.WindowsBorderHoverPadding , g.WindowsBorderHoverPadding );
2323
+ #endif
2296
2324
for (ImGuiWindow* window : g.Windows )
2297
2325
#ifdef IMGUI_HAS_DOCK
2298
2326
if (window->RootWindowDockTree == window && window->WasActive )
@@ -2301,7 +2329,7 @@ static bool IsPosOnVoid(ImGuiContext& g, const ImVec2& pos)
2301
2329
#endif
2302
2330
{
2303
2331
ImRect r = window->Rect ();
2304
- r.Expand (g. WindowsHoverPadding );
2332
+ r.Expand (hover_padding );
2305
2333
if (r.Contains (pos))
2306
2334
return false ;
2307
2335
}
@@ -3497,7 +3525,11 @@ void ImGuiTestContext::MenuAction(ImGuiTestAction action, ImGuiTestRef ref)
3497
3525
ItemAction (Inputs->MouseButtonsValue ? ImGuiTestAction_Hover : ImGuiTestAction_Click, buf.c_str ());
3498
3526
}
3499
3527
}
3528
+ #if IMGUI_VERSION_NUM < 19187
3500
3529
current_window = GetWindowByRef (Str16f (" //##Menu_%02d" , depth).c_str ());
3530
+ #else
3531
+ current_window = GetWindowByRef (Str16f (" //###Menu_%02d" , depth).c_str ());
3532
+ #endif
3501
3533
IM_CHECK_SILENT (current_window != nullptr );
3502
3534
3503
3535
path = p + 1 ;
0 commit comments