mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Internals: Updating condition/allow flags with a function.
This commit is contained in:
		
							
								
								
									
										25
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3918,6 +3918,13 @@ static ImVec2 FindBestPopupWindowPos(const ImVec2& base_pos, const ImVec2& size, | ||||
|     return pos; | ||||
| } | ||||
|  | ||||
| static void SetWindowConditionAllowFlags(ImGuiWindow* window, ImGuiCond flags, bool enabled) | ||||
| { | ||||
|     window->SetWindowPosAllowFlags       = enabled ? (window->SetWindowPosAllowFlags       | flags) : (window->SetWindowPosAllowFlags       & ~flags); | ||||
|     window->SetWindowSizeAllowFlags      = enabled ? (window->SetWindowSizeAllowFlags      | flags) : (window->SetWindowSizeAllowFlags      & ~flags); | ||||
|     window->SetWindowCollapsedAllowFlags = enabled ? (window->SetWindowCollapsedAllowFlags | flags) : (window->SetWindowCollapsedAllowFlags & ~flags); | ||||
| } | ||||
|  | ||||
| ImGuiWindow* ImGui::FindWindowByName(const char* name) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
| @@ -3949,15 +3956,9 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl | ||||
|  | ||||
|         ImGuiIniData* settings = FindWindowSettings(name); | ||||
|         if (!settings) | ||||
|         { | ||||
|             settings = AddWindowSettings(name); | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             window->SetWindowPosAllowFlags &= ~ImGuiCond_FirstUseEver; | ||||
|             window->SetWindowSizeAllowFlags &= ~ImGuiCond_FirstUseEver; | ||||
|             window->SetWindowCollapsedAllowFlags &= ~ImGuiCond_FirstUseEver; | ||||
|         } | ||||
|             SetWindowConditionAllowFlags(window, ImGuiCond_FirstUseEver, false); | ||||
|  | ||||
|         if (settings->Pos.x != FLT_MAX) | ||||
|         { | ||||
| @@ -4134,11 +4135,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|     window->CloseButton = (p_open != NULL); | ||||
|  | ||||
|     // Process SetNextWindow***() calls | ||||
|     if (window->Appearing) | ||||
|         SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); | ||||
|     bool window_pos_set_by_api = false, window_size_set_by_api = false; | ||||
|     if (g.SetNextWindowPosCond) | ||||
|     { | ||||
|         if (window->Appearing)  | ||||
|             window->SetWindowPosAllowFlags |= ImGuiCond_Appearing; | ||||
|         window_pos_set_by_api = (window->SetWindowPosAllowFlags & g.SetNextWindowPosCond) != 0; | ||||
|         if (window_pos_set_by_api && ImLengthSqr(g.SetNextWindowPosPivot) > 0.00001f) | ||||
|         { | ||||
| @@ -4156,8 +4157,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|     } | ||||
|     if (g.SetNextWindowSizeCond) | ||||
|     { | ||||
|         if (window->Appearing)  | ||||
|             window->SetWindowSizeAllowFlags |= ImGuiCond_Appearing; | ||||
|         window_size_set_by_api = (window->SetWindowSizeAllowFlags & g.SetNextWindowSizeCond) != 0; | ||||
|         SetWindowSize(window, g.SetNextWindowSizeVal, g.SetNextWindowSizeCond); | ||||
|         g.SetNextWindowSizeCond = 0; | ||||
| @@ -4173,8 +4172,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|     } | ||||
|     if (g.SetNextWindowCollapsedCond) | ||||
|     { | ||||
|         if (window->Appearing) | ||||
|             window->SetWindowCollapsedAllowFlags |= ImGuiCond_Appearing; | ||||
|         SetWindowCollapsed(window, g.SetNextWindowCollapsedVal, g.SetNextWindowCollapsedCond); | ||||
|         g.SetNextWindowCollapsedCond = 0; | ||||
|     } | ||||
| @@ -4183,6 +4180,8 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|         SetWindowFocus(); | ||||
|         g.SetNextWindowFocus = false; | ||||
|     } | ||||
|     if (window->Appearing) | ||||
|         SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, false); | ||||
|  | ||||
|     // When reusing window again multiple times a frame, just append content (don't need to setup again) | ||||
|     if (first_begin_of_the_frame) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user