mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
Internals: tidying up and stripping more of focus scope code.
This commit is contained in:
parent
9f66a3a9ed
commit
7109f32f96
22
imgui.cpp
22
imgui.cpp
@ -6329,8 +6329,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
window->ParentWindowInBeginStack = parent_window_in_stack;
|
||||
}
|
||||
|
||||
// Add to focus scope stack - inherited by default by child windows from parent, reset by regular window
|
||||
//if (window == window->RootWindow && (window->Flags & ImGuiWindowFlags_ChildMenu) == 0)
|
||||
// Add to focus scope stack
|
||||
PushFocusScope(window->ID);
|
||||
window->NavRootFocusScopeId = g.CurrentFocusScopeId;
|
||||
g.CurrentWindow = NULL;
|
||||
@ -6942,7 +6941,6 @@ void ImGui::End()
|
||||
if (window->DC.CurrentColumns)
|
||||
EndColumns();
|
||||
PopClipRect(); // Inner window clip rectangle
|
||||
//if (window == window->RootWindow && (window->Flags & ImGuiWindowFlags_ChildMenu) == 0)
|
||||
PopFocusScope();
|
||||
|
||||
// Stop logging
|
||||
@ -7624,24 +7622,16 @@ void ImGui::ActivateItem(ImGuiID id)
|
||||
void ImGui::PushFocusScope(ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.FocusScopeStackLocked > 0)
|
||||
return;
|
||||
ImGuiFocusScope scope;
|
||||
scope.FocusScopeId = id;
|
||||
scope.Window = g.CurrentWindow;
|
||||
g.FocusScopeStack.push_back(scope);
|
||||
g.CurrentFocusScopeId = scope.FocusScopeId;
|
||||
g.FocusScopeStack.push_back(id);
|
||||
g.CurrentFocusScopeId = id;
|
||||
}
|
||||
|
||||
void ImGui::PopFocusScope()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.FocusScopeStackLocked > 0)
|
||||
return;
|
||||
IM_ASSERT(g.FocusScopeStack.Size > 0); // Too many PopFocusScope() ?
|
||||
IM_ASSERT(g.FocusScopeStack.back().Window == g.CurrentWindow); // Mismatched pop location?
|
||||
g.FocusScopeStack.pop_back();
|
||||
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back().FocusScopeId : 0;
|
||||
g.CurrentFocusScopeId = g.FocusScopeStack.Size ? g.FocusScopeStack.back() : 0;
|
||||
}
|
||||
|
||||
// Note: this will likely be called ActivateItem() once we rework our Focus/Activation system!
|
||||
@ -10750,7 +10740,7 @@ void ImGui::NavUpdateCreateMoveRequest()
|
||||
inner_rect_rel.Min.y = clamp_y ? (inner_rect_rel.Min.y + pad_y) : -FLT_MAX;
|
||||
inner_rect_rel.Max.y = clamp_y ? (inner_rect_rel.Max.y - pad_y) : +FLT_MAX;
|
||||
window->NavRectRel[g.NavLayer].ClipWithFull(inner_rect_rel);
|
||||
g.NavId = /*g.NavFocusScopeId =*/ 0;
|
||||
g.NavId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -10933,7 +10923,7 @@ static void ImGui::NavUpdateCancelRequest()
|
||||
// Clear NavLastId for popups but keep it for regular child window so we can leave one and come back where we were
|
||||
if (g.NavWindow && ((g.NavWindow->Flags & ImGuiWindowFlags_Popup) || !(g.NavWindow->Flags & ImGuiWindowFlags_ChildWindow)))
|
||||
g.NavWindow->NavLastIds[0] = 0;
|
||||
g.NavId = /*g.NavFocusScopeId =*/ 0;
|
||||
g.NavId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1388,14 +1388,6 @@ struct ImGuiNavItemData
|
||||
void Clear() { Window = NULL; ID = FocusScopeId = 0; InFlags = 0; DistBox = DistCenter = DistAxial = FLT_MAX; }
|
||||
};
|
||||
|
||||
struct ImGuiFocusScope
|
||||
{
|
||||
ImGuiID FocusScopeId;
|
||||
ImGuiWindow* Window;
|
||||
|
||||
ImGuiFocusScope() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] Columns support
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1696,7 +1688,7 @@ struct ImGuiContext
|
||||
#endif
|
||||
|
||||
// Next window/item data
|
||||
ImGuiID CurrentFocusScopeId; // == g.FocusScopeStack.back().FocusScopeId
|
||||
ImGuiID CurrentFocusScopeId; // == g.FocusScopeStack.back()
|
||||
ImGuiItemFlags CurrentItemFlags; // == g.ItemFlagsStack.back()
|
||||
ImGuiNextItemData NextItemData; // Storage for SetNextItem** functions
|
||||
ImGuiLastItemData LastItemData; // Storage for last submitted item (setup by ItemAdd)
|
||||
@ -1706,13 +1698,12 @@ struct ImGuiContext
|
||||
ImVector<ImGuiColorMod> ColorStack; // Stack for PushStyleColor()/PopStyleColor() - inherited by Begin()
|
||||
ImVector<ImGuiStyleMod> StyleVarStack; // Stack for PushStyleVar()/PopStyleVar() - inherited by Begin()
|
||||
ImVector<ImFont*> FontStack; // Stack for PushFont()/PopFont() - inherited by Begin()
|
||||
ImVector<ImGuiFocusScope> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
|
||||
ImVector<ImGuiID> FocusScopeStack; // Stack for PushFocusScope()/PopFocusScope() - inherited by BeginChild(), pushed into by Begin()
|
||||
ImVector<ImGuiItemFlags>ItemFlagsStack; // Stack for PushItemFlag()/PopItemFlag() - inherited by Begin()
|
||||
ImVector<ImGuiGroupData>GroupStack; // Stack for BeginGroup()/EndGroup() - not inherited by Begin()
|
||||
ImVector<ImGuiPopupData>OpenPopupStack; // Which popups are open (persistent)
|
||||
ImVector<ImGuiPopupData>BeginPopupStack; // Which level of BeginPopup() we are in (reset every frame)
|
||||
int BeginMenuCount;
|
||||
int FocusScopeStackLocked; // Prevent PushFocusScope()/PopFocusScope()
|
||||
|
||||
// Viewports
|
||||
ImVector<ImGuiViewportP*> Viewports; // Active viewports (Size==1 in 'master' branch). Each viewports hold their copy of ImDrawData.
|
||||
@ -1950,7 +1941,6 @@ struct ImGuiContext
|
||||
CurrentFocusScopeId = 0;
|
||||
CurrentItemFlags = ImGuiItemFlags_None;
|
||||
BeginMenuCount = 0;
|
||||
FocusScopeStackLocked = 0;
|
||||
|
||||
NavWindow = NULL;
|
||||
NavId = NavFocusScopeId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavActivateInputId = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user