@ -3132,7 +3132,7 @@ void ImGui::MarkItemEdited(ImGuiID id)
//IM_ASSERT(g.CurrentWindow->DC.LastItemId == id);
g . ActiveIdHasBeenEditedThisFrame = true ;
g . ActiveIdHasBeenEditedBefore = true ;
g . CurrentWindow - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_Edited ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_Edited ;
}
static inline bool IsWindowContentHoverable ( ImGuiWindow * window , ImGuiHoveredFlags flags )
@ -3163,13 +3163,13 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
ImGuiWindow * window = g . CurrentWindow ;
if ( g . NavDisableMouseHover & & ! g . NavDisableHighlight )
{
if ( ( window - > DC . LastItem InFlags & ImGuiItemFlags_Disabled ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenDisabled ) )
if ( ( g . LastItemData . InFlags & ImGuiItemFlags_Disabled ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenDisabled ) )
return false ;
return IsItemFocused ( ) ;
}
// Test for bounding box overlap, as updated as ItemAdd()
ImGuiItemStatusFlags status_flags = window - > DC . LastItem StatusFlags;
ImGuiItemStatusFlags status_flags = g . LastItemData . StatusFlags ;
if ( ! ( status_flags & ImGuiItemStatusFlags_HoveredRect ) )
return false ;
IM_ASSERT ( ( flags & ( ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows ) ) = = 0 ) ; // Flags not supported by this function
@ -3185,7 +3185,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
// Test if another item is active (e.g. being dragged)
if ( ( flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem ) = = 0 )
if ( g . ActiveId ! = 0 & & g . ActiveId ! = window - > DC . LastItemId & & ! g . ActiveIdAllowOverlap & & g . ActiveId ! = window - > MoveId )
if ( g . ActiveId ! = 0 & & g . ActiveId ! = g . LastItemData . ID & & ! g . ActiveIdAllowOverlap & & g . ActiveId ! = window - > MoveId )
return false ;
// Test if interactions on this window are blocked by an active popup or modal.
@ -3194,12 +3194,12 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
return false ;
// Test if the item is disabled
if ( ( window - > DC . LastItem InFlags & ImGuiItemFlags_Disabled ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenDisabled ) )
if ( ( g . LastItemData . InFlags & ImGuiItemFlags_Disabled ) & & ! ( flags & ImGuiHoveredFlags_AllowWhenDisabled ) )
return false ;
// Special handling for calling after Begin() which represent the title bar or tab.
// When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect the case.
if ( window - > DC . LastItemId = = window - > MoveId & & window - > WriteAccessed )
if ( g . LastItemData . ID = = window - > MoveId & & window - > WriteAccessed )
return false ;
return true ;
}
@ -3268,22 +3268,12 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged
return false ;
}
// This is also inlined in ItemAdd()
// Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect!
void ImGui : : SetLastItemData ( ImGuiWindow * window , ImGuiID item_id , ImGuiItemFlags item_flags , ImGuiItemStatusFlags item_status_flags , const ImRect & item_rect )
{
window - > DC . LastItemId = item_id ;
window - > DC . LastItemInFlags = item_flags ;
window - > DC . LastItemStatusFlags = item_status_flags ;
window - > DC . LastItemRect = item_rect ;
}
// Called by ItemAdd()
// Process TAB/Shift+TAB. Be mindful that this function may _clear_ the ActiveID when tabbing out.
void ImGui : : ItemFocusable ( ImGuiWindow * window , ImGuiID id )
{
ImGuiContext & g = * GImGui ;
IM_ASSERT ( id ! = 0 & & id = = window - > DC . LastItemId ) ;
IM_ASSERT ( id ! = 0 & & id = = g . LastItemData . ID ) ;
// Increment counters
// FIXME: ImGuiItemFlags_Disabled should disable more.
@ -3309,13 +3299,13 @@ void ImGui::ItemFocusable(ImGuiWindow* window, ImGuiID id)
{
if ( window - > DC . FocusCounterRegular = = g . TabFocusRequestCurrCounterRegular )
{
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_FocusedByCode ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_FocusedByCode ;
return ;
}
if ( is_tab_stop & & window - > DC . FocusCounterTabStop = = g . TabFocusRequestCurrCounterTabStop )
{
g . NavJustTabbedId = id ;
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_FocusedByTabbing ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_FocusedByTabbing ;
return ;
}
@ -4858,10 +4848,7 @@ bool ImGui::IsItemActive()
{
ImGuiContext & g = * GImGui ;
if ( g . ActiveId )
{
ImGuiWindow * window = g . CurrentWindow ;
return g . ActiveId = = window - > DC . LastItemId ;
}
return g . ActiveId = = g . LastItemData . ID ;
return false ;
}
@ -4869,21 +4856,17 @@ bool ImGui::IsItemActivated()
{
ImGuiContext & g = * GImGui ;
if ( g . ActiveId )
{
ImGuiWindow * window = g . CurrentWindow ;
if ( g . ActiveId = = window - > DC . LastItemId & & g . ActiveIdPreviousFrame ! = window - > DC . LastItemId )
if ( g . ActiveId = = g . LastItemData . ID & & g . ActiveIdPreviousFrame ! = g . LastItemData . ID )
return true ;
}
return false ;
}
bool ImGui : : IsItemDeactivated ( )
{
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
if ( window - > DC . LastItemStatusFlags & ImGuiItemStatusFlags_HasDeactivated )
return ( window - > DC . LastItemStatusFlags & ImGuiItemStatusFlags_Deactivated ) ! = 0 ;
return ( g . ActiveIdPreviousFrame = = window - > DC . LastItemId & & g . ActiveIdPreviousFrame ! = 0 & & g . ActiveId ! = window - > DC . LastItemId ) ;
if ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_HasDeactivated )
return ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_Deactivated ) ! = 0 ;
return ( g . ActiveIdPreviousFrame = = g . LastItemData . ID & & g . ActiveIdPreviousFrame ! = 0 & & g . ActiveId ! = g . LastItemData . ID ) ;
}
bool ImGui : : IsItemDeactivatedAfterEdit ( )
@ -4896,9 +4879,7 @@ bool ImGui::IsItemDeactivatedAfterEdit()
bool ImGui : : IsItemFocused ( )
{
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
if ( g . NavId ! = window - > DC . LastItemId | | g . NavId = = 0 )
if ( g . NavId ! = g . LastItemData . ID | | g . NavId = = 0 )
return false ;
return true ;
}
@ -4913,13 +4894,13 @@ bool ImGui::IsItemClicked(ImGuiMouseButton mouse_button)
bool ImGui : : IsItemToggledOpen ( )
{
ImGuiContext & g = * GImGui ;
return ( g . CurrentWindow - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_ToggledOpen ) ? true : false ;
return ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_ToggledOpen ) ? true : false ;
}
bool ImGui : : IsItemToggledSelection ( )
{
ImGuiContext & g = * GImGui ;
return ( g . CurrentWindow - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_ToggledSelection ) ? true : false ;
return ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_ToggledSelection ) ? true : false ;
}
bool ImGui : : IsAnyItemHovered ( )
@ -4942,14 +4923,14 @@ bool ImGui::IsAnyItemFocused()
bool ImGui : : IsItemVisible ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return w indow- > ClipRect . Overlaps ( window - > DC . LastItem Rect) ;
ImGuiContext & g = * GImGui ;
return g . CurrentW indow- > ClipRect . Overlaps ( g . LastItemData . Rect ) ;
}
bool ImGui : : IsItemEdited ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return ( window - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_Edited ) ! = 0 ;
ImGuiContext & g = * GImGui ;
return ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_Edited ) ! = 0 ;
}
// Allow last item to be overlapped by a subsequent item. Both may be activated during the same frame before the later one takes priority.
@ -4957,7 +4938,7 @@ bool ImGui::IsItemEdited()
void ImGui : : SetItemAllowOverlap ( )
{
ImGuiContext & g = * GImGui ;
ImGuiID id = g . CurrentWindow - > DC . LastItemId ;
ImGuiID id = g . LastItemData . ID ;
if ( g . HoveredId = = id )
g . HoveredIdAllowOverlap = true ;
if ( g . ActiveId = = id )
@ -4967,7 +4948,7 @@ void ImGui::SetItemAllowOverlap()
void ImGui : : SetItemUsingMouseWheel ( )
{
ImGuiContext & g = * GImGui ;
ImGuiID id = g . CurrentWindow - > DC . LastItemId ;
ImGuiID id = g . LastItemData . ID ;
if ( g . HoveredId = = id )
g . HoveredIdUsingMouseWheel = true ;
if ( g . ActiveId = = id )
@ -4986,20 +4967,20 @@ void ImGui::SetActiveIdUsingNavAndKeys()
ImVec2 ImGui : : GetItemRectMin ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return window - > DC . LastItem Rect. Min ;
ImGuiContext & g = * GImGui ;
return g . LastItemData . Rect . Min ;
}
ImVec2 ImGui : : GetItemRectMax ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return window - > DC . LastItem Rect. Max ;
ImGuiContext & g = * GImGui ;
return g . LastItemData . Rect . Max ;
}
ImVec2 ImGui : : GetItemRectSize ( )
{
ImGuiWindow * window = GetCurrentWindowRead ( ) ;
return window - > DC . LastItem Rect. GetSize ( ) ;
ImGuiContext & g = * GImGui ;
return g . LastItemData . Rect . GetSize ( ) ;
}
bool ImGui : : BeginChildEx ( const char * name , ImGuiID id , const ImVec2 & size_arg , bool border , ImGuiWindowFlags flags )
@ -5104,7 +5085,7 @@ void ImGui::EndChild()
ItemAdd ( bb , 0 ) ;
}
if ( g . HoveredWindow = = window )
parent_window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_HoveredWindow ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_HoveredWindow ;
}
g . WithinEndChild = false ;
g . LogLinePosY = - FLT_MAX ; // To enforce a carriage return
@ -5811,7 +5792,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
}
// Parent window is latched only on the first call to Begin() of the frame, so further append-calls can be done from a different window stack
ImGuiWindow * parent_window_in_stack = g . CurrentWindowStack . empty ( ) ? NULL : g . CurrentWindowStack . back ( ) ;
ImGuiWindow * parent_window_in_stack = g . CurrentWindowStack . empty ( ) ? NULL : g . CurrentWindowStack . back ( ) . Window ;
ImGuiWindow * parent_window = first_begin_of_the_frame ? ( ( flags & ( ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup ) ) ? parent_window_in_stack : NULL ) : window - > ParentWindow ;
IM_ASSERT ( parent_window ! = NULL | | ! ( flags & ImGuiWindowFlags_ChildWindow ) ) ;
@ -5821,7 +5802,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// Add to stack
// We intentionally set g.CurrentWindow to NULL to prevent usage until when the viewport is set, then will call SetCurrentWindow()
g . CurrentWindowStack . push_back ( window ) ;
ImGuiWindowStackData window_stack_data ;
window_stack_data . Window = window ;
window_stack_data . ParentLastItemDataBackup = g . LastItemData ;
g . CurrentWindowStack . push_back ( window_stack_data ) ;
g . CurrentWindow = window ;
window - > DC . StackSizesOnBegin . SetToCurrentState ( ) ;
g . CurrentWindow = NULL ;
@ -6334,11 +6318,14 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
// This is useful to allow creating context menus on title bar only, etc.
SetLastItemData ( window , window - > MoveId , g . CurrentItemFlags , IsMouseHoveringRect ( title_bar_rect . Min , title_bar_rect . Max , false ) ? ImGuiItemStatusFlags_HoveredRect : 0 , title_bar_rect ) ;
g . LastItemData . ID = window - > MoveId ;
g . LastItemData . InFlags = g . CurrentItemFlags ;
g . LastItemData . StatusFlags = IsMouseHoveringRect ( title_bar_rect . Min , title_bar_rect . Max , false ) ? ImGuiItemStatusFlags_HoveredRect : 0 ;
g . LastItemData . Rect = title_bar_rect ;
# ifdef IMGUI_ENABLE_TEST_ENGINE
if ( ! ( window - > Flags & ImGuiWindowFlags_NoTitleBar ) )
IMGUI_TEST_ENGINE_ITEM_ADD ( window - > DC . LastItemRect , window - > DC . LastItemId ) ;
IMGUI_TEST_ENGINE_ITEM_ADD ( g . LastItemData . Rect , g . LastItemData . ID ) ;
# endif
}
else
@ -6430,11 +6417,12 @@ void ImGui::End()
LogFinish ( ) ;
// Pop from window stack
g . LastItemData = g . CurrentWindowStack . back ( ) . ParentLastItemDataBackup ;
g . CurrentWindowStack . pop_back ( ) ;
if ( window - > Flags & ImGuiWindowFlags_Popup )
g . BeginPopupStack . pop_back ( ) ;
window - > DC . StackSizesOnBegin . CompareWithCurrentState ( ) ;
SetCurrentWindow ( g . CurrentWindowStack . empty ( ) ? NULL : g . CurrentWindowStack . back ( ) ) ;
SetCurrentWindow ( g . CurrentWindowStack . Size = = 0 ? NULL : g . CurrentWindowStack . back ( ) . Window ) ;
}
void ImGui : : BringWindowToFocusFront ( ImGuiWindow * window )
@ -7060,8 +7048,8 @@ void ImGui::SetItemDefaultFocus()
if ( g . NavWindow = = window - > RootWindowForNav & & ( g . NavInitRequest | | g . NavInitResultId ! = 0 ) & & g . NavLayer = = window - > DC . NavLayerCurrent )
{
g . NavInitRequest = false ;
g . NavInitResultId = window - > DC . LastItemId ;
g . NavInitResultRectRel = ImRect ( window - > DC . LastItem Rect. Min - window - > Pos , window - > DC . LastItem Rect. Max - window - > Pos ) ;
g . NavInitResultId = g . LastItemData . ID ;
g . NavInitResultRectRel = ImRect ( g . LastItemData . Rect . Min - window - > Pos , g . LastItemData . Rect . Max - window - > Pos ) ;
NavUpdateAnyRequestFlag ( ) ;
if ( ! IsItemVisible ( ) )
SetScrollHereY ( ) ;
@ -7456,11 +7444,11 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
// Equivalent to calling SetLastItemData()
window - > DC . LastItemId = id ;
window - > DC . LastItem Rect = bb ;
window - > DC . LastItem InFlags = g . CurrentItemFlags ;
window - > DC . LastItem StatusFlags = ImGuiItemStatusFlags_None ;
// Set item data
g . LastItemData . ID = id ;
g . LastItemData . Rect = bb ;
g . LastItemData . InFlags = g . CurrentItemFlags ;
g . LastItemData . StatusFlags = ImGuiItemStatusFlags_None ;
g . NextItemData . Flags = ImGuiNextItemDataFlags_None ;
// Directional navigation processing
@ -7509,7 +7497,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
if ( IsMouseHoveringRect ( bb . Min , bb . Max ) )
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_HoveredRect ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_HoveredRect ;
return true ;
}
@ -7841,24 +7829,24 @@ void ImGui::EndGroup()
const bool group_contains_curr_active_id = ( group_data . BackupActiveIdIsAlive ! = g . ActiveId ) & & ( g . ActiveIdIsAlive = = g . ActiveId ) & & g . ActiveId ;
const bool group_contains_prev_active_id = ( group_data . BackupActiveIdPreviousFrameIsAlive = = false ) & & ( g . ActiveIdPreviousFrameIsAlive = = true ) ;
if ( group_contains_curr_active_id )
window - > DC . LastItemId = g . ActiveId ;
g . LastItemData . ID = g . ActiveId ;
else if ( group_contains_prev_active_id )
window - > DC . LastItemId = g . ActiveIdPreviousFrame ;
window - > DC . LastItem Rect = group_bb ;
g . LastItemData . ID = g . ActiveIdPreviousFrame ;
g . LastItemData . Rect = group_bb ;
// Forward Hovered flag
const bool group_contains_curr_hovered_id = ( group_data . BackupHoveredIdIsAlive = = false ) & & g . HoveredId ! = 0 ;
if ( group_contains_curr_hovered_id )
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_HoveredWindow ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_HoveredWindow ;
// Forward Edited flag
if ( group_contains_curr_active_id & & g . ActiveIdHasBeenEditedThisFrame )
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_Edited ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_Edited ;
// Forward Deactivated flag
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_HasDeactivated ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_HasDeactivated ;
if ( group_contains_prev_active_id & & g . ActiveId ! = g . ActiveIdPreviousFrame )
window - > DC . LastItem StatusFlags | = ImGuiItemStatusFlags_Deactivated ;
g . LastItemData . StatusFlags | = ImGuiItemStatusFlags_Deactivated ;
g . GroupStack . pop_back ( ) ;
//window->DrawList->AddRect(group_bb.Min, group_bb.Max, IM_COL32(255,0,255,255)); // [Debug]
@ -8047,7 +8035,7 @@ void ImGui::SetScrollHereX(float center_x_ratio)
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
float spacing_x = ImMax ( window - > WindowPadding . x , g . Style . ItemSpacing . x ) ;
float target_pos_x = ImLerp ( window - > DC . LastItem Rect. Min . x - spacing_x , window - > DC . LastItem Rect. Max . x + spacing_x , center_x_ratio ) ;
float target_pos_x = ImLerp ( g . LastItemData . Rect . Min . x - spacing_x , g . LastItemData . Rect . Max . x + spacing_x , center_x_ratio ) ;
SetScrollFromPosX ( window , target_pos_x - window - > Pos . x , center_x_ratio ) ; // Convert from absolute to local pos
// Tweak: snap on edges when aiming at an item very close to the edge
@ -8443,12 +8431,13 @@ void ImGui::EndPopup()
// - This is essentially the same as BeginPopupContextItem() but without the trailing BeginPopup()
void ImGui : : OpenPopupOnItemClick ( const char * str_id , ImGuiPopupFlags popup_flags )
{
ImGuiWindow * window = GImGui - > CurrentWindow ;
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
int mouse_button = ( popup_flags & ImGuiPopupFlags_MouseButtonMask_ ) ;
if ( IsMouseReleased ( mouse_button ) & & IsItemHovered ( ImGuiHoveredFlags_AllowWhenBlockedByPopup ) )
{
ImGuiID id = str_id ? window - > GetID ( str_id ) : window - > DC . LastItemId ; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT ( id ! = 0 ) ; // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
ImGuiID id = str_id ? window - > GetID ( str_id ) : g . LastItemData . ID ; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT ( id ! = 0 ) ; // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
OpenPopupEx ( id , popup_flags ) ;
}
}
@ -8471,11 +8460,12 @@ void ImGui::OpenPopupOnItemClick(const char* str_id, ImGuiPopupFlags popup_flags
// The main difference being that this is tweaked to avoid computing the ID twice.
bool ImGui : : BeginPopupContextItem ( const char * str_id , ImGuiPopupFlags popup_flags )
{
ImGuiWindow * window = GImGui - > CurrentWindow ;
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
if ( window - > SkipItems )
return false ;
ImGuiID id = str_id ? window - > GetID ( str_id ) : window - > DC . LastItemId ; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT ( id ! = 0 ) ; // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
ImGuiID id = str_id ? window - > GetID ( str_id ) : g . LastItemData . ID ; // If user hasn't passed an ID, we can use the LastItemID. Using LastItemID as a Popup ID won't conflict!
IM_ASSERT ( id ! = 0 ) ; // You cannot pass a NULL str_id if the last item has no identifier (e.g. a Text() item)
int mouse_button = ( popup_flags & ImGuiPopupFlags_MouseButtonMask_ ) ;
if ( IsMouseReleased ( mouse_button ) & & IsItemHovered ( ImGuiHoveredFlags_AllowWhenBlockedByPopup ) )
OpenPopupEx ( id , popup_flags ) ;
@ -8484,7 +8474,8 @@ bool ImGui::BeginPopupContextItem(const char* str_id, ImGuiPopupFlags popup_flag
bool ImGui : : BeginPopupContextWindow ( const char * str_id , ImGuiPopupFlags popup_flags )
{
ImGuiWindow * window = GImGui - > CurrentWindow ;
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
if ( ! str_id )
str_id = " window_context " ;
ImGuiID id = window - > GetID ( str_id ) ;
@ -8497,7 +8488,8 @@ bool ImGui::BeginPopupContextWindow(const char* str_id, ImGuiPopupFlags popup_fl
bool ImGui : : BeginPopupContextVoid ( const char * str_id , ImGuiPopupFlags popup_flags )
{
ImGuiWindow * window = GImGui - > CurrentWindow ;
ImGuiContext & g = * GImGui ;
ImGuiWindow * window = g . CurrentWindow ;
if ( ! str_id )
str_id = " void_context " ;
ImGuiID id = window - > GetID ( str_id ) ;
@ -8608,7 +8600,7 @@ ImVec2 ImGui::FindBestWindowPosForPopup(ImGuiWindow* window)
// Child menus typically request _any_ position within the parent menu item, and then we move the new menu outside the parent bounds.
// This is how we end up with child menus appearing (most-commonly) on the right of the parent menu.
IM_ASSERT ( g . CurrentWindow = = window ) ;
ImGuiWindow * parent_window = g . CurrentWindowStack [ g . CurrentWindowStack . Size - 2 ] ;
ImGuiWindow * parent_window = g . CurrentWindowStack [ g . CurrentWindowStack . Size - 2 ] . Window ;
float horizontal_overlap = g . Style . ItemInnerSpacing . x ; // We want some overlap to convey the relative depth of each menu (currently the amount of overlap is hard-coded to style.ItemSpacing.x).
ImRect r_avoid ;
if ( parent_window - > DC . MenuBarAppending )
@ -8672,8 +8664,8 @@ void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window)
g . NavLayer = nav_layer ;
g . NavFocusScopeId = window - > DC . NavFocusScopeIdCurrent ;
window - > NavLastIds [ nav_layer ] = id ;
if ( window - > DC . LastItemId = = id )
window - > NavRectRel [ nav_layer ] = ImRect ( window - > DC . LastItem Rect. Min - window - > Pos , window - > DC . LastItem Rect. Max - window - > Pos ) ;
if ( g . LastItemData . ID = = id )
window - > NavRectRel [ nav_layer ] = ImRect ( g . LastItemData . Rect . Min - window - > Pos , g . LastItemData . Rect . Max - window - > Pos ) ;
if ( g . ActiveIdSource = = ImGuiInputSource_Nav )
g . NavDisableMouseHover = true ;
@ -8770,7 +8762,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result, ImRect cand)
else
{
// Degenerate case: two overlapping buttons with same center, break ties arbitrarily (note that LastItemId here is really the _previous_ item order, but it doesn't matter)
quadrant = ( window - > DC . LastItemId < g . NavId ) ? ImGuiDir_Left : ImGuiDir_Right ;
quadrant = ( g . LastItemData . ID < g . NavId ) ? ImGuiDir_Left : ImGuiDir_Right ;
}
# if IMGUI_DEBUG_NAV_SCORING
@ -8858,7 +8850,7 @@ static void ImGui::NavProcessItem(ImGuiWindow* window, const ImRect& nav_bb, con
//if (!g.IO.NavActive) // [2017/10/06] Removed this possibly redundant test but I am not sure of all the side-effects yet. Some of the feature here will need to work regardless of using a _NoNavInputs flag.
// return;
const ImGuiItemFlags item_flags = window - > DC . LastItem InFlags;
const ImGuiItemFlags item_flags = g . LastItemData . InFlags ;
const ImRect nav_bb_rel ( nav_bb . Min - window - > Pos , nav_bb . Max - window - > Pos ) ;
// Process Init Request
@ -9853,7 +9845,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
ImGuiID source_parent_id = 0 ;
if ( ! ( flags & ImGuiDragDropFlags_SourceExtern ) )
{
source_id = window - > DC . LastItemId ;
source_id = g . LastItemData . ID ;
if ( source_id ! = 0 )
{
// Common path: items with ID
@ -9880,7 +9872,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
}
// Early out
if ( ( window - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_HoveredRect ) = = 0 & & ( g . ActiveId = = 0 | | g . ActiveIdWindow ! = window ) )
if ( ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_HoveredRect ) = = 0 & & ( g . ActiveId = = 0 | | g . ActiveIdWindow ! = window ) )
return false ;
// Magic fallback (=somehow reprehensible) to handle items with no assigned ID, e.g. Text(), Image()
@ -9888,8 +9880,8 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
// THE IDENTIFIER WON'T SURVIVE ANY REPOSITIONING OF THE WIDGET, so if your widget moves your dragging operation will be canceled.
// We don't need to maintain/call ClearActiveID() as releasing the button will early out this function and trigger !ActiveIdIsAlive.
// Rely on keeping other window->LastItemXXX fields intact.
source_id = window - > DC . LastItemId = window - > GetIDFromRectangle ( window - > DC . LastItem Rect) ;
bool is_hovered = ItemHoverable ( window - > DC . LastItem Rect, source_id ) ;
source_id = g . LastItemData . ID = window - > GetIDFromRectangle ( g . LastItemData . Rect ) ;
bool is_hovered = ItemHoverable ( g . LastItemData . Rect , source_id ) ;
if ( is_hovered & & g . IO . MouseClicked [ mouse_button ] )
{
SetActiveID ( source_id , window ) ;
@ -9945,7 +9937,7 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
}
if ( ! ( flags & ImGuiDragDropFlags_SourceNoDisableHover ) & & ! ( flags & ImGuiDragDropFlags_SourceExtern ) )
window - > DC . LastItem StatusFlags & = ~ ImGuiItemStatusFlags_HoveredRect ;
g . LastItemData . StatusFlags & = ~ ImGuiItemStatusFlags_HoveredRect ;
return true ;
}
@ -10045,14 +10037,14 @@ bool ImGui::BeginDragDropTarget()
return false ;
ImGuiWindow * window = g . CurrentWindow ;
if ( ! ( window - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_HoveredRect ) )
if ( ! ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_HoveredRect ) )
return false ;
ImGuiWindow * hovered_window = g . HoveredWindowUnderMovingWindow ;
if ( hovered_window = = NULL | | window - > RootWindow ! = hovered_window - > RootWindow )
return false ;
const ImRect & display_rect = ( window - > DC . LastItem StatusFlags & ImGuiItemStatusFlags_HasDisplayRect ) ? window - > DC . LastItemDisplayRect : window - > DC . LastItem Rect;
ImGuiID id = window - > DC . LastItemId ;
const ImRect & display_rect = ( g . LastItemData . StatusFlags & ImGuiItemStatusFlags_HasDisplayRect ) ? g . LastItemData . DisplayRect : g . LastItemData . Rect ;
ImGuiID id = g . LastItemData . ID ;
if ( id = = 0 )
id = window - > GetIDFromRectangle ( display_rect ) ;
if ( g . DragDropPayload . SourceId = = id )