mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Standardizing the casing/format of internal window names + Misc comments.
This commit is contained in:
		
							
								
								
									
										18
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3640,14 +3640,14 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_ | |||||||
| { | { | ||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     char window_name[16]; |     char window_name[16]; | ||||||
|     ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip%02d", g.TooltipOverrideCount); |     ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", g.TooltipOverrideCount); | ||||||
|     if (override_previous_tooltip) |     if (override_previous_tooltip) | ||||||
|         if (ImGuiWindow* window = FindWindowByName(window_name)) |         if (ImGuiWindow* window = FindWindowByName(window_name)) | ||||||
|             if (window->Active) |             if (window->Active) | ||||||
|             { |             { | ||||||
|                 // Hide previous tooltips. We can't easily "reset" the content of a window so we create a new one. |                 // Hide previous tooltips. We can't easily "reset" the content of a window so we create a new one. | ||||||
|                 window->HiddenFrames = 1; |                 window->HiddenFrames = 1; | ||||||
|                 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip%02d", ++g.TooltipOverrideCount); |                 ImFormatString(window_name, IM_ARRAYSIZE(window_name), "##Tooltip_%02d", ++g.TooltipOverrideCount); | ||||||
|             } |             } | ||||||
|     ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize; |     ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip|ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_AlwaysAutoResize; | ||||||
|     Begin(window_name, NULL, flags | extra_flags); |     Begin(window_name, NULL, flags | extra_flags); | ||||||
| @@ -3688,7 +3688,7 @@ void ImGui::OpenPopupEx(ImGuiID id, bool reopen_existing) | |||||||
|     ImGuiContext& g = *GImGui; |     ImGuiContext& g = *GImGui; | ||||||
|     ImGuiWindow* window = g.CurrentWindow; |     ImGuiWindow* window = g.CurrentWindow; | ||||||
|     int current_stack_size = g.CurrentPopupStack.Size; |     int current_stack_size = g.CurrentPopupStack.Size; | ||||||
|     ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here) |     ImGuiPopupRef popup_ref = ImGuiPopupRef(id, window, window->GetID("##Menus"), g.IO.MousePos); // Tagged as new ref because constructor sets Window to NULL (we are passing the ParentWindow info here) | ||||||
|     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) | ||||||
| @@ -3802,9 +3802,9 @@ bool ImGui::BeginPopupEx(ImGuiID id, ImGuiWindowFlags extra_flags) | |||||||
|  |  | ||||||
|     char name[20]; |     char name[20]; | ||||||
|     if (flags & ImGuiWindowFlags_ChildMenu) |     if (flags & ImGuiWindowFlags_ChildMenu) | ||||||
|         ImFormatString(name, IM_ARRAYSIZE(name), "##menu_%d", g.CurrentPopupStack.Size);    // Recycle windows based on depth |         ImFormatString(name, IM_ARRAYSIZE(name), "##Menu_%02d", g.CurrentPopupStack.Size);    // Recycle windows based on depth | ||||||
|     else |     else | ||||||
|         ImFormatString(name, IM_ARRAYSIZE(name), "##popup_%08x", id); // Not recycling, so we can close/open during the same frame |         ImFormatString(name, IM_ARRAYSIZE(name), "##Popup_%08x", id); // Not recycling, so we can close/open during the same frame | ||||||
|  |  | ||||||
|     bool is_open = Begin(name, NULL, flags); |     bool is_open = Begin(name, NULL, flags); | ||||||
|     if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) |     if (!is_open) // NB: Begin can return false when the popup is completely clipped (e.g. zero size display) | ||||||
| @@ -4202,7 +4202,7 @@ static ImVec2 CalcSizeAutoFit(ImGuiWindow* window, const ImVec2& size_contents) | |||||||
|     } |     } | ||||||
|     else |     else | ||||||
|     { |     { | ||||||
|         // Handling case of auto fit window not fitting on the screen (on either axis): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding. |         // When the window cannot fit all contents (either because of constraints, either because screen is too small): we are growing the size on the other axis to compensate for expected scrollbar. FIXME: Might turn bigger than DisplaySize-WindowPadding. | ||||||
|         size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding)); |         size_auto_fit = ImClamp(size_contents, style.WindowMinSize, ImMax(style.WindowMinSize, g.IO.DisplaySize - g.Style.DisplaySafeAreaPadding)); | ||||||
|         ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit); |         ImVec2 size_auto_fit_after_constraint = CalcSizeAfterConstraint(window, size_auto_fit); | ||||||
|         if (size_auto_fit_after_constraint.x < size_contents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)) |         if (size_auto_fit_after_constraint.x < size_contents.x && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)) | ||||||
| @@ -4499,7 +4499,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|         else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) |         else if (window->AutoFitFramesX > 0 || window->AutoFitFramesY > 0) | ||||||
|         { |         { | ||||||
|             // Auto-fit only grows during the first few frames |             // Auto-fit only grows during the first few frames | ||||||
|             // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize ImGuiWindowFlags_AlwaysAutoResize. |             // We still process initial auto-fit on collapsed windows to get a window width, but otherwise don't honor ImGuiWindowFlags_AlwaysAutoResize when collapsed. | ||||||
|             if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) |             if (!window_size_x_set_by_api && window->AutoFitFramesX > 0) | ||||||
|                 window->SizeFull.x = size_full_modified.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; |                 window->SizeFull.x = size_full_modified.x = window->AutoFitOnlyGrows ? ImMax(window->SizeFull.x, size_auto_fit.x) : size_auto_fit.x; | ||||||
|             if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) |             if (!window_size_y_set_by_api && window->AutoFitFramesY > 0) | ||||||
| @@ -9136,7 +9136,7 @@ bool ImGui::BeginCombo(const char* label, const char* preview_value, ImGuiComboF | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     char name[16]; |     char name[16]; | ||||||
|     ImFormatString(name, IM_ARRAYSIZE(name), "##combo_%d", g.CurrentPopupStack.Size); // Recycle windows based on depth |     ImFormatString(name, IM_ARRAYSIZE(name), "##Combo_%02d", g.CurrentPopupStack.Size); // Recycle windows based on depth | ||||||
|  |  | ||||||
|     // Peak into expected window size so we can position it |     // Peak into expected window size so we can position it | ||||||
|     if (ImGuiWindow* popup_window = FindWindowByName(name)) |     if (ImGuiWindow* popup_window = FindWindowByName(name)) | ||||||
| @@ -9580,7 +9580,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled) | |||||||
|  |  | ||||||
|     bool pressed; |     bool pressed; | ||||||
|     bool menu_is_open = IsPopupOpen(id); |     bool menu_is_open = IsPopupOpen(id); | ||||||
|     bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##menus")); |     bool menuset_is_open = !(window->Flags & ImGuiWindowFlags_Popup) && (g.OpenPopupStack.Size > g.CurrentPopupStack.Size && g.OpenPopupStack[g.CurrentPopupStack.Size].ParentMenuSet == window->GetID("##Menus")); | ||||||
|     ImGuiWindow* backed_nav_window = g.NavWindow; |     ImGuiWindow* backed_nav_window = g.NavWindow; | ||||||
|     if (menuset_is_open) |     if (menuset_is_open) | ||||||
|         g.NavWindow = window;  // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) |         g.NavWindow = window;  // Odd hack to allow hovering across menus of a same menu-set (otherwise we wouldn't be able to hover parent) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user