mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-22 07:36:35 +00:00
Internals: Backport one ->WasActive test in NavRestoreLastChildNavWindow() from 9bf6509c6
+ minor/shallow bits from docking branch.
This commit is contained in:
parent
c7f5876f8a
commit
218ff3a2a5
42
imgui.cpp
42
imgui.cpp
@ -2467,6 +2467,7 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] RENDER HELPERS
|
||||
// Some of those (internal) functions are currently quite a legacy mess - their signature and behavior will change,
|
||||
@ -5590,6 +5591,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & (ImGuiWindowFlags_AlwaysUseWindowPadding | ImGuiWindowFlags_Popup)) && window->WindowBorderSize == 0.0f)
|
||||
window->WindowPadding = ImVec2(0.0f, (flags & ImGuiWindowFlags_MenuBar) ? style.WindowPadding.y : 0.0f);
|
||||
|
||||
// Lock menu offset so size calculation can use it as menu-bar windows need a minimum size.
|
||||
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
||||
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
||||
|
||||
// Collapse window by double-clicking on title bar
|
||||
// At this point we don't have a clipping rectangle setup yet, so we can use the title bar area for hit detection and drawing
|
||||
if (!(flags & ImGuiWindowFlags_NoTitleBar) && !(flags & ImGuiWindowFlags_NoCollapse))
|
||||
@ -5912,8 +5917,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->DC.NavHasScroll = (window->ScrollMax.y > 0.0f);
|
||||
|
||||
window->DC.MenuBarAppending = false;
|
||||
window->DC.MenuBarOffset.x = ImMax(ImMax(window->WindowPadding.x, style.ItemSpacing.x), g.NextWindowData.MenuBarOffsetMinVal.x);
|
||||
window->DC.MenuBarOffset.y = g.NextWindowData.MenuBarOffsetMinVal.y;
|
||||
window->DC.MenuColumns.Update(3, style.ItemSpacing.x, window_just_activated_by_user);
|
||||
window->DC.TreeDepth = 0;
|
||||
window->DC.TreeJumpToParentOnPopMask = 0x00;
|
||||
@ -7624,7 +7627,7 @@ void ImGui::OpenPopupEx(ImGuiID id, ImGuiPopupFlags popup_flags)
|
||||
popup_ref.OpenPopupPos = NavCalcPreferredRefPos();
|
||||
popup_ref.OpenMousePos = IsMousePosValid(&g.IO.MousePos) ? g.IO.MousePos : popup_ref.OpenPopupPos;
|
||||
|
||||
//IMGUI_DEBUG_LOG("OpenPopupEx(0x%08X)\n", g.FrameCount, id);
|
||||
IMGUI_DEBUG_LOG_POPUP("OpenPopupEx(0x%08X)\n", id);
|
||||
if (g.OpenPopupStack.Size < current_stack_size + 1)
|
||||
{
|
||||
g.OpenPopupStack.push_back(popup_ref);
|
||||
@ -7685,7 +7688,7 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
|
||||
}
|
||||
if (popup_count_to_keep < g.OpenPopupStack.Size) // This test is not required but it allows to set a convenient breakpoint on the statement below
|
||||
{
|
||||
//IMGUI_DEBUG_LOG("ClosePopupsOverWindow(%s) -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
|
||||
IMGUI_DEBUG_LOG_POPUP("ClosePopupsOverWindow(\"%s\") -> ClosePopupToLevel(%d)\n", ref_window->Name, popup_count_to_keep);
|
||||
ClosePopupToLevel(popup_count_to_keep, restore_focus_to_window_under_popup);
|
||||
}
|
||||
}
|
||||
@ -7693,6 +7696,7 @@ void ImGui::ClosePopupsOverWindow(ImGuiWindow* ref_window, bool restore_focus_to
|
||||
void ImGui::ClosePopupToLevel(int remaining, bool restore_focus_to_window_under_popup)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IMGUI_DEBUG_LOG_POPUP("ClosePopupToLevel(%d), restore_focus_to_window_under_popup=%d\n", remaining, restore_focus_to_window_under_popup);
|
||||
IM_ASSERT(remaining >= 0 && remaining < g.OpenPopupStack.Size);
|
||||
|
||||
// Trim open popup stack
|
||||
@ -7737,7 +7741,7 @@ void ImGui::CloseCurrentPopup()
|
||||
break;
|
||||
popup_idx--;
|
||||
}
|
||||
//IMGUI_DEBUG_LOG("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
|
||||
IMGUI_DEBUG_LOG_POPUP("CloseCurrentPopup %d -> %d\n", g.BeginPopupStack.Size - 1, popup_idx);
|
||||
ClosePopupToLevel(popup_idx, true);
|
||||
|
||||
// A common pattern is to close a popup when selecting a menu item/selectable that will open another window.
|
||||
@ -8322,18 +8326,20 @@ void ImGui::NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags mov
|
||||
// This way we could find the last focused window among our children. It would be much less confusing this way?
|
||||
static void ImGui::NavSaveLastChildNavWindowIntoParent(ImGuiWindow* nav_window)
|
||||
{
|
||||
ImGuiWindow* parent_window = nav_window;
|
||||
while (parent_window && (parent_window->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent_window->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
|
||||
parent_window = parent_window->ParentWindow;
|
||||
if (parent_window && parent_window != nav_window)
|
||||
parent_window->NavLastChildNavWindow = nav_window;
|
||||
ImGuiWindow* parent = nav_window;
|
||||
while (parent && (parent->Flags & ImGuiWindowFlags_ChildWindow) != 0 && (parent->Flags & (ImGuiWindowFlags_Popup | ImGuiWindowFlags_ChildMenu)) == 0)
|
||||
parent = parent->ParentWindow;
|
||||
if (parent && parent != nav_window)
|
||||
parent->NavLastChildNavWindow = nav_window;
|
||||
}
|
||||
|
||||
// Restore the last focused child.
|
||||
// Call when we are expected to land on the Main Layer (0) after FocusWindow()
|
||||
static ImGuiWindow* ImGui::NavRestoreLastChildNavWindow(ImGuiWindow* window)
|
||||
{
|
||||
return window->NavLastChildNavWindow ? window->NavLastChildNavWindow : window;
|
||||
if (window->NavLastChildNavWindow && window->NavLastChildNavWindow->WasActive)
|
||||
return window->NavLastChildNavWindow;
|
||||
return window;
|
||||
}
|
||||
|
||||
static void NavRestoreLayer(ImGuiNavLayer layer)
|
||||
@ -9651,6 +9657,7 @@ void ImGui::LogButtons()
|
||||
LogToClipboard();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] SETTINGS
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -9905,9 +9912,9 @@ static void WindowSettingsHandler_ReadLine(ImGuiContext*, ImGuiSettingsHandler*,
|
||||
ImGuiWindowSettings* settings = (ImGuiWindowSettings*)entry;
|
||||
int x, y;
|
||||
int i;
|
||||
if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) settings->Pos = ImVec2ih((short)x, (short)y);
|
||||
else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) settings->Size = ImVec2ih((short)x, (short)y);
|
||||
else if (sscanf(line, "Collapsed=%d", &i) == 1) settings->Collapsed = (i != 0);
|
||||
if (sscanf(line, "Pos=%i,%i", &x, &y) == 2) { settings->Pos = ImVec2ih((short)x, (short)y); }
|
||||
else if (sscanf(line, "Size=%i,%i", &x, &y) == 2) { settings->Size = ImVec2ih((short)x, (short)y); }
|
||||
else if (sscanf(line, "Collapsed=%d", &i) == 1) { settings->Collapsed = (i != 0); }
|
||||
}
|
||||
|
||||
// Apply to existing windows (if any)
|
||||
@ -10514,7 +10521,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
|
||||
// Details for Docking
|
||||
#ifdef IMGUI_HAS_DOCK
|
||||
if (ImGui::TreeNode("Docking"))
|
||||
if (ImGui::TreeNode("Dock nodes"))
|
||||
{
|
||||
ImGui::TreePop();
|
||||
}
|
||||
@ -10526,6 +10533,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
if (ImGui::SmallButton("Clear"))
|
||||
ImGui::ClearIniSettings();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Save to memory"))
|
||||
ImGui::SaveIniSettingsToMemory();
|
||||
ImGui::SameLine();
|
||||
if (ImGui::SmallButton("Save to disk"))
|
||||
ImGui::SaveIniSettingsToDisk(g.IO.IniFilename);
|
||||
ImGui::SameLine();
|
||||
@ -10537,7 +10547,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
if (ImGui::TreeNode("SettingsHandlers", "Settings handlers: (%d)", g.SettingsHandlers.Size))
|
||||
{
|
||||
for (int n = 0; n < g.SettingsHandlers.Size; n++)
|
||||
ImGui::TextUnformatted(g.SettingsHandlers[n].TypeName);
|
||||
ImGui::BulletText("%s", g.SettingsHandlers[n].TypeName);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
if (ImGui::TreeNode("SettingsWindows", "Settings packed data: Windows: %d bytes", g.SettingsWindows.size()))
|
||||
|
4
imgui.h
4
imgui.h
@ -723,7 +723,7 @@ namespace ImGui
|
||||
IMGUI_API void ColorConvertHSVtoRGB(float h, float s, float v, float& out_r, float& out_g, float& out_b);
|
||||
|
||||
// Inputs Utilities: Keyboard
|
||||
// - For 'int user_key_index' you can use your own indices/enums according to how your backend/engine stored them in io.KeysDown[].
|
||||
// - For 'int user_key_index' you can use your own indices/enums according to how your back-end/engine stored them in io.KeysDown[].
|
||||
// - We don't know the meaning of those value. You can use GetKeyIndex() to map a ImGuiKey_ value into the user index.
|
||||
IMGUI_API int GetKeyIndex(ImGuiKey imgui_key); // map ImGuiKey_* values into user's key index. == io.KeyMap[key]
|
||||
IMGUI_API bool IsKeyDown(int user_key_index); // is key being held. == io.KeysDown[user_key_index].
|
||||
@ -1434,7 +1434,7 @@ struct ImGuiStyle
|
||||
ImGuiDir ColorButtonPosition; // Side of the color button in the ColorEdit4 widget (left/right). Defaults to ImGuiDir_Right.
|
||||
ImVec2 ButtonTextAlign; // Alignment of button text when button is larger than text. Defaults to (0.5f, 0.5f) (centered).
|
||||
ImVec2 SelectableTextAlign; // Alignment of selectable text. Defaults to (0.0f, 0.0f) (top-left aligned). It's generally important to keep this left-aligned if you want to lay multiple items on a same line.
|
||||
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area by at least this amount. Only applies to regular windows.
|
||||
ImVec2 DisplayWindowPadding; // Window position are clamped to be visible within the display area or monitors by at least this amount. Only applies to regular windows.
|
||||
ImVec2 DisplaySafeAreaPadding; // If you cannot see the edges of your screen (e.g. on a TV) increase the safe area padding. Apply to popups/tooltips as well regular windows. NB: Prefer configuring your TV sets correctly!
|
||||
float MouseCursorScale; // Scale software rendered mouse cursor (when io.MouseDrawCursor is enabled). May be removed later.
|
||||
bool AntiAliasedLines; // Enable anti-aliased lines/borders. Disable if you are really tight on CPU/GPU. Latched at the beginning of the frame (copied to ImDrawList).
|
||||
|
@ -228,8 +228,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
IM_ASSERT(ImGui::GetCurrentContext() != NULL && "Missing dear imgui context. Refer to examples app!");
|
||||
|
||||
// Examples Apps (accessible from the "Examples" menu)
|
||||
static bool show_app_documents = false;
|
||||
static bool show_app_main_menu_bar = false;
|
||||
static bool show_app_documents = false;
|
||||
static bool show_app_console = false;
|
||||
static bool show_app_log = false;
|
||||
static bool show_app_layout = false;
|
||||
@ -241,8 +241,9 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
static bool show_app_window_titles = false;
|
||||
static bool show_app_custom_rendering = false;
|
||||
|
||||
if (show_app_documents) ShowExampleAppDocuments(&show_app_documents);
|
||||
if (show_app_main_menu_bar) ShowExampleAppMainMenuBar();
|
||||
if (show_app_documents) ShowExampleAppDocuments(&show_app_documents);
|
||||
|
||||
if (show_app_console) ShowExampleAppConsole(&show_app_console);
|
||||
if (show_app_log) ShowExampleAppLog(&show_app_log);
|
||||
if (show_app_layout) ShowExampleAppLayout(&show_app_layout);
|
||||
|
@ -163,6 +163,10 @@ namespace ImStb
|
||||
#define IMGUI_DEBUG_LOG(_FMT,...) printf("[%05d] " _FMT, GImGui->FrameCount, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
// Debug Logging for selected systems. Remove the '((void)0) //' to enable.
|
||||
//#define IMGUI_DEBUG_LOG_POPUP IMGUI_DEBUG_LOG // Enable log
|
||||
#define IMGUI_DEBUG_LOG_POPUP(...) ((void)0) // Disable log
|
||||
|
||||
// Static Asserts
|
||||
#if (__cplusplus >= 201100)
|
||||
#define IM_STATIC_ASSERT(_COND) static_assert(_COND, "")
|
||||
|
Loading…
Reference in New Issue
Block a user