mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui.h
This commit is contained in:
		| @@ -77,6 +77,7 @@ Frameworks: | |||||||
| - Cinder: https://github.com/simongeilfus/Cinder-ImGui | - Cinder: https://github.com/simongeilfus/Cinder-ImGui | ||||||
| - cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551 | - cocos2d-x: https://github.com/c0i/imguix https://github.com/ocornut/imgui/issues/551 | ||||||
| - Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI | - Flexium/SFML (FlexGUI): https://github.com/DXsmiley/FlexGUI | ||||||
|  | - GML/GameMakerStudio2 (ImGuiGML): https://marketplace.yoyogames.com/assets/6221/imguigml | ||||||
| - Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI | - Irrlicht (IrrIMGUI): https://github.com/ZahlGraf/IrrIMGUI | ||||||
| - Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src | - Ogre: https://bitbucket.org/LMCrashy/ogreimgui/src | ||||||
| - openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui | - openFrameworks (ofxImGui): https://github.com/jvcleave/ofxImGui | ||||||
|   | |||||||
							
								
								
									
										51
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										51
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -4970,12 +4970,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl | |||||||
|     window->Flags = flags; |     window->Flags = flags; | ||||||
|     g.WindowsById.SetVoidPtr(window->ID, window); |     g.WindowsById.SetVoidPtr(window->ID, window); | ||||||
|  |  | ||||||
|     if (flags & ImGuiWindowFlags_NoSavedSettings) |     // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. | ||||||
|     { |     if (!(flags & ImGuiWindowFlags_NoSavedSettings)) | ||||||
|         // User can disable loading and saving of settings. Tooltip and child windows also don't store settings. |  | ||||||
|         window->Size = window->SizeFull = size; |  | ||||||
|     } |  | ||||||
|     else |  | ||||||
|     { |     { | ||||||
|         // Retrieve settings from .ini file |         // Retrieve settings from .ini file | ||||||
|         // Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. |         // Use SetWindowPos() or SetNextWindowPos() with the appropriate condition flag to change the initial position of a window. | ||||||
| @@ -4991,8 +4987,8 @@ static ImGuiWindow* CreateNewWindow(const char* name, ImVec2 size, ImGuiWindowFl | |||||||
|             if (ImLengthSqr(settings->Size) > 0.00001f) |             if (ImLengthSqr(settings->Size) > 0.00001f) | ||||||
|                 size = settings->Size; |                 size = settings->Size; | ||||||
|         } |         } | ||||||
|         window->Size = window->SizeFull = size; |  | ||||||
|     } |     } | ||||||
|  |     window->Size = window->SizeFull = window->SizeFullAtLastBegin = size; | ||||||
|  |  | ||||||
|     if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) |     if ((flags & ImGuiWindowFlags_AlwaysAutoResize) != 0) | ||||||
|     { |     { | ||||||
| @@ -5183,6 +5179,20 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|     else |     else | ||||||
|         flags = window->Flags; |         flags = window->Flags; | ||||||
|  |  | ||||||
|  |     // Update the Appearing flag | ||||||
|  |     bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1);   // Not using !WasActive because the implicit "Debug" window would always toggle off->on | ||||||
|  |     const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFrames == 1); | ||||||
|  |     if (flags & ImGuiWindowFlags_Popup) | ||||||
|  |     { | ||||||
|  |         ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size]; | ||||||
|  |         window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed | ||||||
|  |         window_just_activated_by_user |= (window != popup_ref.Window); | ||||||
|  |     } | ||||||
|  |     window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize); | ||||||
|  |     window->CloseButton = (p_open != NULL); | ||||||
|  |     if (window->Appearing) | ||||||
|  |         SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); | ||||||
|  |  | ||||||
|     // 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 |     // 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 = first_begin_of_the_frame ? (!g.CurrentWindowStack.empty() ? g.CurrentWindowStack.back() : NULL) : window->ParentWindow; |     ImGuiWindow* parent_window = first_begin_of_the_frame ? (!g.CurrentWindowStack.empty() ? g.CurrentWindowStack.back() : NULL) : window->ParentWindow; | ||||||
|     IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); |     IM_ASSERT(parent_window != NULL || !(flags & ImGuiWindowFlags_ChildWindow)); | ||||||
| @@ -5191,27 +5201,18 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|     g.CurrentWindowStack.push_back(window); |     g.CurrentWindowStack.push_back(window); | ||||||
|     SetCurrentWindow(window); |     SetCurrentWindow(window); | ||||||
|     CheckStacksSize(window, true); |     CheckStacksSize(window, true); | ||||||
|  |  | ||||||
|     bool window_just_activated_by_user = (window->LastFrameActive < current_frame - 1);   // Not using !WasActive because the implicit "Debug" window would always toggle off->on |  | ||||||
|     if (flags & ImGuiWindowFlags_Popup) |     if (flags & ImGuiWindowFlags_Popup) | ||||||
|     { |     { | ||||||
|         ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size]; |         ImGuiPopupRef& popup_ref = g.OpenPopupStack[g.CurrentPopupStack.Size]; | ||||||
|         window_just_activated_by_user |= (window->PopupId != popup_ref.PopupId); // We recycle popups so treat window as activated if popup id changed |  | ||||||
|         window_just_activated_by_user |= (window != popup_ref.Window); |  | ||||||
|         popup_ref.Window = window; |         popup_ref.Window = window; | ||||||
|         g.CurrentPopupStack.push_back(popup_ref); |         g.CurrentPopupStack.push_back(popup_ref); | ||||||
|         window->PopupId = popup_ref.PopupId; |         window->PopupId = popup_ref.PopupId; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const bool window_just_appearing_after_hidden_for_resize = (window->HiddenFrames == 1); |  | ||||||
|     if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow)) |     if (window_just_appearing_after_hidden_for_resize && !(flags & ImGuiWindowFlags_ChildWindow)) | ||||||
|         window->NavLastIds[0] = 0; |         window->NavLastIds[0] = 0; | ||||||
|     window->Appearing = (window_just_activated_by_user || window_just_appearing_after_hidden_for_resize); |  | ||||||
|     window->CloseButton = (p_open != NULL); |  | ||||||
|  |  | ||||||
|     // Process SetNextWindow***() calls |     // Process SetNextWindow***() calls | ||||||
|     if (window->Appearing) |  | ||||||
|         SetWindowConditionAllowFlags(window, ImGuiCond_Appearing, true); |  | ||||||
|     bool window_pos_set_by_api = false, window_size_set_by_api = false; |     bool window_pos_set_by_api = false, window_size_set_by_api = false; | ||||||
|     if (g.SetNextWindowPosCond) |     if (g.SetNextWindowPosCond) | ||||||
|     { |     { | ||||||
| @@ -5380,13 +5381,13 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|  |  | ||||||
|         // SCROLLBAR STATUS |         // SCROLLBAR STATUS | ||||||
|  |  | ||||||
|         // Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size). We need to do this before manual resize (below) is effective. |         // Update scrollbar status (based on the Size that was effective during last frame or the auto-resized Size).  | ||||||
|         if (!window->Collapsed) |         if (!window->Collapsed) | ||||||
|         { |         { | ||||||
|             window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFull.y) && !(flags & ImGuiWindowFlags_NoScrollbar)); |             window->ScrollbarY = (flags & ImGuiWindowFlags_AlwaysVerticalScrollbar) || ((window->SizeContents.y > window->SizeFullAtLastBegin.y) && !(flags & ImGuiWindowFlags_NoScrollbar)); | ||||||
|             window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFull.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); |             window->ScrollbarX = (flags & ImGuiWindowFlags_AlwaysHorizontalScrollbar) || ((window->SizeContents.x > window->SizeFullAtLastBegin.x - (window->ScrollbarY ? style.ScrollbarSize : 0.0f) - window->WindowPadding.x) && !(flags & ImGuiWindowFlags_NoScrollbar) && (flags & ImGuiWindowFlags_HorizontalScrollbar)); | ||||||
|             if (window->ScrollbarX && !window->ScrollbarY) |             if (window->ScrollbarX && !window->ScrollbarY) | ||||||
|                 window->ScrollbarY = (window->SizeContents.y > window->SizeFull.y + style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar); |                 window->ScrollbarY = (window->SizeContents.y > window->SizeFullAtLastBegin.y + style.ScrollbarSize) && !(flags & ImGuiWindowFlags_NoScrollbar); | ||||||
|             window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); |             window->ScrollbarSizes = ImVec2(window->ScrollbarY ? style.ScrollbarSize : 0.0f, window->ScrollbarX ? style.ScrollbarSize : 0.0f); | ||||||
|         } |         } | ||||||
|  |  | ||||||
| @@ -5520,11 +5521,11 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|                     ImRect resize_rect(corner, corner + grip.InnerDir * grip_hover_size); |                     ImRect resize_rect(corner, corner + grip.InnerDir * grip_hover_size); | ||||||
|                     resize_rect.FixInverted(); |                     resize_rect.FixInverted(); | ||||||
|                     bool hovered, held; |                     bool hovered, held; | ||||||
|                     ButtonBehavior(resize_rect, window->GetID((void*)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChilds|ImGuiButtonFlags_NoNavFocus); |                     ButtonBehavior(resize_rect, window->GetID((void*)resize_grip_n), &hovered, &held, ImGuiButtonFlags_FlattenChilds); | ||||||
|                     if (hovered || held) |                     if (hovered || held) | ||||||
|                         g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; |                         g.MouseCursor = (resize_grip_n & 1) ? ImGuiMouseCursor_ResizeNESW : ImGuiMouseCursor_ResizeNWSE; | ||||||
|  |  | ||||||
|                     if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0]) |                     if (g.HoveredWindow == window && held && g.IO.MouseDoubleClicked[0] && resize_grip_n == 0) | ||||||
|                     { |                     { | ||||||
|                         // Manual auto-fit when double-clicking |                         // Manual auto-fit when double-clicking | ||||||
|                         size_target = CalcSizeFullWithConstraint(window, size_auto_fit); |                         size_target = CalcSizeFullWithConstraint(window, size_auto_fit); | ||||||
| @@ -5537,6 +5538,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|                         ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + resize_rect.GetSize() * grip.CornerPos; // Corner of the window corresponding to our corner grip |                         ImVec2 corner_target = g.IO.MousePos - g.ActiveIdClickOffset + resize_rect.GetSize() * grip.CornerPos; // Corner of the window corresponding to our corner grip | ||||||
|                         CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPos, &pos_target, &size_target); |                         CalcResizePosSizeFromAnyCorner(window, corner_target, grip.CornerPos, &pos_target, &size_target); | ||||||
|                     } |                     } | ||||||
|  |                 if (resize_grip_n == 0 || held || hovered) | ||||||
|                     resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); |                     resize_grip_col[resize_grip_n] = GetColorU32(held ? ImGuiCol_ResizeGripActive : hovered ? ImGuiCol_ResizeGripHovered : ImGuiCol_ResizeGrip); | ||||||
|                 } |                 } | ||||||
|                 for (int border_n = 0; border_n < resize_border_count; border_n++) |                 for (int border_n = 0; border_n < resize_border_count; border_n++) | ||||||
| @@ -5582,6 +5584,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |                 PopID(); | ||||||
|  |  | ||||||
|                 // Apply back modified position/size to window |                 // Apply back modified position/size to window | ||||||
|                 if (size_target.x != FLT_MAX) |                 if (size_target.x != FLT_MAX) | ||||||
| @@ -5594,6 +5597,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|                     window->Pos = window->PosFloat = ImVec2((float)(int)pos_target.x, (float)(int)pos_target.y); |                     window->Pos = window->PosFloat = ImVec2((float)(int)pos_target.x, (float)(int)pos_target.y); | ||||||
|                     MarkIniSettingsDirty(window); |                     MarkIniSettingsDirty(window); | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 window->Size = window->SizeFull; |                 window->Size = window->SizeFull; | ||||||
|                 title_bar_rect = window->TitleBarRect(); |                 title_bar_rect = window->TitleBarRect(); | ||||||
|             } |             } | ||||||
| @@ -5648,6 +5652,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|                 window->DrawList->AddLine(title_bar_rect.GetBL()+ImVec2(1,-1), title_bar_rect.GetBR()+ImVec2(-1,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); |                 window->DrawList->AddLine(title_bar_rect.GetBL()+ImVec2(1,-1), title_bar_rect.GetBR()+ImVec2(-1,-1), GetColorU32(ImGuiCol_Border), style.FrameBorderSize); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         // Store a backup of SizeFull which we will use next frame to decide if we need scrollbars.  | ||||||
|  |         window->SizeFullAtLastBegin = window->SizeFull; | ||||||
|  |  | ||||||
|         // Update ContentsRegionMax. All the variable it depends on are set above in this function. |         // Update ContentsRegionMax. All the variable it depends on are set above in this function. | ||||||
|         window->ContentsRegionRect.Min.x = -window->Scroll.x + window->WindowPadding.x; |         window->ContentsRegionRect.Min.x = -window->Scroll.x + window->WindowPadding.x; | ||||||
|         window->ContentsRegionRect.Min.y = -window->Scroll.y + window->WindowPadding.y + window->TitleBarHeight() + window->MenuBarHeight(); |         window->ContentsRegionRect.Min.y = -window->Scroll.y + window->WindowPadding.y + window->TitleBarHeight() + window->MenuBarHeight(); | ||||||
|   | |||||||
| @@ -794,6 +794,7 @@ struct IMGUI_API ImGuiWindow | |||||||
|     ImVec2                  Pos;                                // Position rounded-up to nearest pixel |     ImVec2                  Pos;                                // Position rounded-up to nearest pixel | ||||||
|     ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size) |     ImVec2                  Size;                               // Current size (==SizeFull or collapsed title bar size) | ||||||
|     ImVec2                  SizeFull;                           // Size when non collapsed |     ImVec2                  SizeFull;                           // Size when non collapsed | ||||||
|  |     ImVec2                  SizeFullAtLastBegin;                // Copy of SizeFull at the end of Begin. This is the reference value we'll use on the next frame to decide if we need scrollbars. | ||||||
|     ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame |     ImVec2                  SizeContents;                       // Size of contents (== extents reach of the drawing cursor) from previous frame | ||||||
|     ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize() |     ImVec2                  SizeContentsExplicit;               // Size of contents explicitly set by the user via SetNextWindowContentSize() | ||||||
|     ImRect                  ContentsRegionRect;                 // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis |     ImRect                  ContentsRegionRect;                 // Maximum visible content position in window coordinates. ~~ (SizeContentsExplicit ? SizeContentsExplicit : Size - ScrollbarSizes) - CursorStartPos, per axis | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 omar
					omar