mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Added ImGuiWindowFlags_UnsavedDocument flags.
This commit is contained in:
		
							
								
								
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -5004,8 +5004,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|             window->DC.NavLayerCurrentMask >>= 1; | ||||
|             window->DC.ItemFlags = item_flags_backup; | ||||
|  | ||||
|             // Title text (FIXME: refactor text alignment facilities along with RenderText helpers, this is too much code for what it does.) | ||||
|             ImVec2 text_size = CalcTextSize(name, NULL, true); | ||||
|             // Title bar text (with: horizontal alignment, avoiding collapse/close button, optional "unsaved document" marker) | ||||
|             // FIXME: Refactor text alignment facilities along with RenderText helpers, this is too much code.. | ||||
|             const char* UNSAVED_DOCUMENT_MARKER = "*"; | ||||
|             float marker_size_x = (flags & ImGuiWindowFlags_UnsavedDocument) ? CalcTextSize(UNSAVED_DOCUMENT_MARKER, NULL, false).x : 0.0f; | ||||
|             ImVec2 text_size = CalcTextSize(name, NULL, true) + ImVec2(marker_size_x, 0.0f); | ||||
|             ImRect text_r = title_bar_rect; | ||||
|             float pad_left = (flags & ImGuiWindowFlags_NoCollapse) ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x); | ||||
|             float pad_right = (p_open == NULL)                     ? style.FramePadding.x : (style.FramePadding.x + g.FontSize + style.ItemInnerSpacing.x); | ||||
| @@ -5016,6 +5019,12 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|             ImRect clip_rect = text_r; | ||||
|             clip_rect.Max.x = window->Pos.x + window->Size.x - (p_open ? title_bar_rect.GetHeight() - 3 : style.FramePadding.x); // Match the size of CloseButton() | ||||
|             RenderTextClipped(text_r.Min, text_r.Max, name, NULL, &text_size, style.WindowTitleAlign, &clip_rect); | ||||
|             if (flags & ImGuiWindowFlags_UnsavedDocument) | ||||
|             { | ||||
|                 ImVec2 marker_pos = ImVec2(ImMax(text_r.Min.x, text_r.Min.x + (text_r.GetWidth() - text_size.x) * style.WindowTitleAlign.x) + text_size.x, text_r.Min.y) + ImVec2(2 - marker_size_x, 0.0f); | ||||
|                 ImVec2 off = ImVec2(0.0f, (float)(int)(-g.FontSize * 0.25f)); | ||||
|                 RenderTextClipped(marker_pos + off, text_r.Max + off, UNSAVED_DOCUMENT_MARKER, NULL, NULL, ImVec2(0, style.WindowTitleAlign.y), &clip_rect); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         // Save clipped aabb so we can access it in constant-time in FindHoveredWindow() | ||||
|   | ||||
							
								
								
									
										1
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -623,6 +623,7 @@ enum ImGuiWindowFlags_ | ||||
|     ImGuiWindowFlags_NoNavInputs            = 1 << 18,  // No gamepad/keyboard navigation within the window | ||||
|     ImGuiWindowFlags_NoNavFocus             = 1 << 19,  // No focusing toward this window with gamepad/keyboard navigation (e.g. skipped by CTRL+TAB) | ||||
|     ImGuiWindowFlags_NoNav                  = ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoNavFocus, | ||||
|     ImGuiWindowFlags_UnsavedDocument        = 1 << 20,  // Append '*' to title without affecting the ID, as a convenience to avoid using the ### operator. When used in a tab/docking context, tab is selected on closure and closure is deferred by one frame to allow code to cancel the closure (with a confirmation popup, etc.) without flicker. | ||||
|  | ||||
|     // [Internal] | ||||
|     ImGuiWindowFlags_NavFlattened           = 1 << 23,  // [BETA] Allow gamepad/keyboard navigation to cross over parent border to this child (only use on child that have no scrolling!) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user