mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Internals: Popup: Explicitely setting up ImGuiPopupRef reduces confusion.
This commit is contained in:
		
							
								
								
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3725,9 +3725,13 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) | |||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     ImGuiWindow* parent_window = g.CurrentWindow; |     ImGuiWindow* parent_window = g.CurrentWindow; | ||||||
|     int current_stack_size = g.CurrentPopupStack.Size; |     int current_stack_size = g.CurrentPopupStack.Size; | ||||||
|     ImVec2 mouse_pos = g.IO.MousePos; |     ImGuiPopupRef popup_ref; // Tagged as new ref as Window will be set back to NULL if we write this into OpenPopupStack. | ||||||
|     ImVec2 popup_pos = mouse_pos; // NB: In the Navigation branch popup_pos may not use mouse_pos. |     popup_ref.PopupId = id; | ||||||
|     ImGuiPopupRef popup_ref = ImGuiPopupRef(id, parent_window, parent_window->GetID("##Menus"), popup_pos, mouse_pos); // Tagged as new ref because constructor sets Window to NULL. |     popup_ref.Window = NULL; | ||||||
|  |     popup_ref.ParentWindow = parent_window; | ||||||
|  |     popup_ref.ParentMenuSet = parent_window->GetID("##Menus"); | ||||||
|  |     popup_ref.MousePosOnOpen = g.IO.MousePos; | ||||||
|  |     popup_ref.PopupPosOnOpen = g.IO.MousePos; // NB: In the Navigation branch popup_pos may not use mouse_pos. | ||||||
|     if (g.OpenPopupStack.Size < current_stack_size + 1) |     if (g.OpenPopupStack.Size < current_stack_size + 1) | ||||||
|         g.OpenPopupStack.push_back(popup_ref); |         g.OpenPopupStack.push_back(popup_ref); | ||||||
|     else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) |     else if (reopen_existing || g.OpenPopupStack[current_stack_size].PopupId != id) | ||||||
|   | |||||||
| @@ -403,8 +403,6 @@ struct ImGuiPopupRef | |||||||
|     ImGuiID             ParentMenuSet;  // Set on OpenPopup() |     ImGuiID             ParentMenuSet;  // Set on OpenPopup() | ||||||
|     ImVec2              PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) |     ImVec2              PopupPosOnOpen; // Preferred popup position (typically == MousePosOnOpen when using mouse) | ||||||
|     ImVec2              MousePosOnOpen; // Copy of mouse position at the time of opening popup |     ImVec2              MousePosOnOpen; // Copy of mouse position at the time of opening popup | ||||||
|  |  | ||||||
|     ImGuiPopupRef(ImGuiID id, ImGuiWindow* parent_window, ImGuiID parent_menu_set, const ImVec2& popup_pos, const ImVec2& mouse_pos) { PopupId = id; Window = NULL; ParentWindow = parent_window; ParentMenuSet = parent_menu_set; PopupPosOnOpen = popup_pos; MousePosOnOpen = mouse_pos; } |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct ImGuiColumnData | struct ImGuiColumnData | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user