mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	Merge various minor things (supposedly harmless) from Navigation branch into Master to reduce differences. (#787)
This commit is contained in:
		
							
								
								
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -1803,9 +1803,9 @@ ImGuiWindow::ImGuiWindow(const char* name) | |||||||
|     DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList)); |     DrawList = (ImDrawList*)ImGui::MemAlloc(sizeof(ImDrawList)); | ||||||
|     IM_PLACEMENT_NEW(DrawList) ImDrawList(); |     IM_PLACEMENT_NEW(DrawList) ImDrawList(); | ||||||
|     DrawList->_OwnerName = Name; |     DrawList->_OwnerName = Name; | ||||||
|  |     ParentWindow = NULL; | ||||||
|     RootWindow = NULL; |     RootWindow = NULL; | ||||||
|     RootNonPopupWindow = NULL; |     RootNonPopupWindow = NULL; | ||||||
|     ParentWindow = NULL; |  | ||||||
|  |  | ||||||
|     FocusIdxAllCounter = FocusIdxTabCounter = -1; |     FocusIdxAllCounter = FocusIdxTabCounter = -1; | ||||||
|     FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX; |     FocusIdxAllRequestCurrent = FocusIdxTabRequestCurrent = INT_MAX; | ||||||
| @@ -1925,7 +1925,8 @@ void ImGui::ItemSize(const ImRect& bb, float text_offset_y) | |||||||
| // declares their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd(). | // declares their minimum size requirement to ItemSize() and then use a larger region for drawing/interaction, which is passed to ItemAdd(). | ||||||
| bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id) | bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id) | ||||||
| { | { | ||||||
|     ImGuiWindow* window = GetCurrentWindow(); |     ImGuiContext& g = *GImGui; | ||||||
|  |     ImGuiWindow* window = g.CurrentWindow; | ||||||
|     window->DC.LastItemId = id ? *id : 0; |     window->DC.LastItemId = id ? *id : 0; | ||||||
|     window->DC.LastItemRect = bb; |     window->DC.LastItemRect = bb; | ||||||
|     window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = false; |     window->DC.LastItemHoveredAndUsable = window->DC.LastItemHoveredRect = false; | ||||||
| @@ -1933,7 +1934,6 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id) | |||||||
|         return false; |         return false; | ||||||
|  |  | ||||||
|     // This is a sensible default, but widgets are free to override it after calling ItemAdd() |     // This is a sensible default, but widgets are free to override it after calling ItemAdd() | ||||||
|     ImGuiContext& g = *GImGui; |  | ||||||
|     if (IsMouseHoveringRect(bb.Min, bb.Max)) |     if (IsMouseHoveringRect(bb.Min, bb.Max)) | ||||||
|     { |     { | ||||||
|         // Matching the behavior of IsHovered() but allow if ActiveId==window->MoveID (we clicked on the window background) |         // Matching the behavior of IsHovered() but allow if ActiveId==window->MoveID (we clicked on the window background) | ||||||
| @@ -2210,7 +2210,7 @@ void ImGui::NewFrame() | |||||||
|     g.ActiveIdIsAlive = false; |     g.ActiveIdIsAlive = false; | ||||||
|     g.ActiveIdIsJustActivated = false; |     g.ActiveIdIsJustActivated = false; | ||||||
|  |  | ||||||
|     // Handle user moving window (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows. |     // Handle user moving window with mouse (at the beginning of the frame to avoid input lag or sheering). Only valid for root windows. | ||||||
|     if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId) |     if (g.MovedWindowMoveId && g.MovedWindowMoveId == g.ActiveId) | ||||||
|     { |     { | ||||||
|         KeepAliveID(g.MovedWindowMoveId); |         KeepAliveID(g.MovedWindowMoveId); | ||||||
| @@ -2221,7 +2221,7 @@ void ImGui::NewFrame() | |||||||
|             if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove)) |             if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoMove)) | ||||||
|             { |             { | ||||||
|                 g.MovedWindow->PosFloat += g.IO.MouseDelta; |                 g.MovedWindow->PosFloat += g.IO.MouseDelta; | ||||||
|                 if (!(g.MovedWindow->Flags & ImGuiWindowFlags_NoSavedSettings) && (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f)) |                 if (g.IO.MouseDelta.x != 0.0f || g.IO.MouseDelta.y != 0.0f) | ||||||
|                     MarkIniSettingsDirty(g.MovedWindow); |                     MarkIniSettingsDirty(g.MovedWindow); | ||||||
|             } |             } | ||||||
|             FocusWindow(g.MovedWindow); |             FocusWindow(g.MovedWindow); | ||||||
| @@ -3705,7 +3705,6 @@ void ImGui::EndChild() | |||||||
|             sz.x = ImMax(4.0f, sz.x); |             sz.x = ImMax(4.0f, sz.x); | ||||||
|         if (window->AutoFitChildAxises & 0x02) |         if (window->AutoFitChildAxises & 0x02) | ||||||
|             sz.y = ImMax(4.0f, sz.y); |             sz.y = ImMax(4.0f, sz.y); | ||||||
|  |  | ||||||
|         ImGui::End(); |         ImGui::End(); | ||||||
|  |  | ||||||
|         ImGuiWindow* parent_window = GetCurrentWindow(); |         ImGuiWindow* parent_window = GetCurrentWindow(); | ||||||
| @@ -4159,10 +4158,11 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us | |||||||
|         // Position tooltip (always follows mouse) |         // Position tooltip (always follows mouse) | ||||||
|         if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api) |         if ((flags & ImGuiWindowFlags_Tooltip) != 0 && !window_pos_set_by_api) | ||||||
|         { |         { | ||||||
|             ImRect rect_to_avoid(g.IO.MousePos.x - 16, g.IO.MousePos.y - 8, g.IO.MousePos.x + 24, g.IO.MousePos.y + 24); // FIXME: Completely hard-coded. Perhaps center on cursor hit-point instead? |             ImVec2 ref_pos = g.IO.MousePos; | ||||||
|             window->PosFloat = FindBestPopupWindowPos(g.IO.MousePos, window->Size, &window->AutoPosLastDirection, rect_to_avoid); |             ImRect rect_to_avoid(ref_pos.x - 16, ref_pos.y - 8, ref_pos.x + 24, ref_pos.y + 24); // FIXME: Completely hard-coded. Perhaps center on cursor hit-point instead? | ||||||
|  |             window->PosFloat = FindBestPopupWindowPos(ref_pos, window->Size, &window->AutoPosLastDirection, rect_to_avoid); | ||||||
|             if (window->AutoPosLastDirection == -1) |             if (window->AutoPosLastDirection == -1) | ||||||
|                 window->PosFloat = g.IO.MousePos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. |                 window->PosFloat = ref_pos + ImVec2(2,2); // If there's not enough room, for tooltip we prefer avoiding the cursor at all cost even if it means that part of the tooltip won't be visible. | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Clamp position so it stays visible |         // Clamp position so it stays visible | ||||||
| @@ -4217,7 +4217,7 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_on_first_us | |||||||
|         const float window_rounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding; |         const float window_rounding = (flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding; | ||||||
|         if (window->Collapsed) |         if (window->Collapsed) | ||||||
|         { |         { | ||||||
|             // Draw title bar only |             // Title bar only | ||||||
|             RenderFrame(title_bar_rect.GetTL(), title_bar_rect.GetBR(),  GetColorU32(ImGuiCol_TitleBgCollapsed), true, window_rounding); |             RenderFrame(title_bar_rect.GetTL(), title_bar_rect.GetBR(),  GetColorU32(ImGuiCol_TitleBgCollapsed), true, window_rounding); | ||||||
|         } |         } | ||||||
|         else |         else | ||||||
|   | |||||||
							
								
								
									
										14
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -412,11 +412,11 @@ namespace ImGui | |||||||
|     IMGUI_API void          PopClipRect(); |     IMGUI_API void          PopClipRect(); | ||||||
|  |  | ||||||
|     // Utilities |     // Utilities | ||||||
|     IMGUI_API bool          IsItemHovered();                                                    // was the last item hovered by mouse? |     IMGUI_API bool          IsItemHovered();                                                    // is the last item hovered by mouse (and usable)? | ||||||
|     IMGUI_API bool          IsItemRectHovered();                                                // was the last item hovered by mouse? even if another item is active or window is blocked by popup while we are hovering this |     IMGUI_API bool          IsItemRectHovered();                                                // is the last item hovered by mouse? even if another item is active or window is blocked by popup while we are hovering this | ||||||
|     IMGUI_API bool          IsItemActive();                                                     // was the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) |     IMGUI_API bool          IsItemActive();                                                     // is the last item active? (e.g. button being held, text field being edited- items that don't interact will always return false) | ||||||
|     IMGUI_API bool          IsItemClicked(int mouse_button = 0);                                // was the last item clicked? (e.g. button/node just clicked on) |     IMGUI_API bool          IsItemClicked(int mouse_button = 0);                                // is the last item clicked? (e.g. button/node just clicked on) | ||||||
|     IMGUI_API bool          IsItemVisible();                                                    // was the last item visible? (aka not out of sight due to clipping/scrolling.) |     IMGUI_API bool          IsItemVisible();                                                    // is the last item visible? (aka not out of sight due to clipping/scrolling.) | ||||||
|     IMGUI_API bool          IsAnyItemHovered(); |     IMGUI_API bool          IsAnyItemHovered(); | ||||||
|     IMGUI_API bool          IsAnyItemActive(); |     IMGUI_API bool          IsAnyItemActive(); | ||||||
|     IMGUI_API ImVec2        GetItemRectMin();                                                   // get bounding rect of last item in screen space |     IMGUI_API ImVec2        GetItemRectMin();                                                   // get bounding rect of last item in screen space | ||||||
| @@ -425,7 +425,7 @@ namespace ImGui | |||||||
|     IMGUI_API void          SetItemAllowOverlap();                                              // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. |     IMGUI_API void          SetItemAllowOverlap();                                              // allow last item to be overlapped by a subsequent item. sometimes useful with invisible buttons, selectables, etc. to catch unused area. | ||||||
|     IMGUI_API bool          IsWindowFocused();                                                  // is current window focused |     IMGUI_API bool          IsWindowFocused();                                                  // is current window focused | ||||||
|     IMGUI_API bool          IsWindowHovered();                                                  // is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others) |     IMGUI_API bool          IsWindowHovered();                                                  // is current window hovered and hoverable (not blocked by a popup) (differentiate child windows from each others) | ||||||
|     IMGUI_API bool          IsWindowRectHovered();                                              // is current window rectnagle hovered, disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup) |     IMGUI_API bool          IsWindowRectHovered();                                              // is current window rectangle hovered, disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup) | ||||||
|     IMGUI_API bool          IsRootWindowFocused();                                              // is current root window focused (root = top-most parent of a child, otherwise self) |     IMGUI_API bool          IsRootWindowFocused();                                              // is current root window focused (root = top-most parent of a child, otherwise self) | ||||||
|     IMGUI_API bool          IsRootWindowOrAnyChildFocused();                                    // is current root window or any of its child (including current window) focused |     IMGUI_API bool          IsRootWindowOrAnyChildFocused();                                    // is current root window or any of its child (including current window) focused | ||||||
|     IMGUI_API bool          IsRootWindowOrAnyChildHovered();                                    // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup) |     IMGUI_API bool          IsRootWindowOrAnyChildHovered();                                    // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup) | ||||||
| @@ -786,7 +786,7 @@ struct ImGuiIO | |||||||
|     float         MouseDragThreshold;       // = 6.0f               // Distance threshold before considering we are dragging |     float         MouseDragThreshold;       // = 6.0f               // Distance threshold before considering we are dragging | ||||||
|     int           KeyMap[ImGuiKey_COUNT];   // <unset>              // Map of indices into the KeysDown[512] entries array |     int           KeyMap[ImGuiKey_COUNT];   // <unset>              // Map of indices into the KeysDown[512] entries array | ||||||
|     float         KeyRepeatDelay;           // = 0.250f             // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). |     float         KeyRepeatDelay;           // = 0.250f             // When holding a key/button, time before it starts repeating, in seconds (for buttons in Repeat mode, etc.). | ||||||
|     float         KeyRepeatRate;            // = 0.020f             // When holding a key/button, rate at which it repeats, in seconds. |     float         KeyRepeatRate;            // = 0.050f             // When holding a key/button, rate at which it repeats, in seconds. | ||||||
|     void*         UserData;                 // = NULL               // Store your own data for retrieval by callbacks. |     void*         UserData;                 // = NULL               // Store your own data for retrieval by callbacks. | ||||||
|  |  | ||||||
|     ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. |     ImFontAtlas*  Fonts;                    // <auto>               // Load and assemble one or more fonts into a single tightly packed texture. Output to Fonts array. | ||||||
|   | |||||||
| @@ -538,7 +538,7 @@ struct ImGuiContext | |||||||
|         DragCurrentValue = 0.0f; |         DragCurrentValue = 0.0f; | ||||||
|         DragLastMouseDelta = ImVec2(0.0f, 0.0f); |         DragLastMouseDelta = ImVec2(0.0f, 0.0f); | ||||||
|         DragSpeedDefaultRatio = 1.0f / 100.0f; |         DragSpeedDefaultRatio = 1.0f / 100.0f; | ||||||
|         DragSpeedScaleSlow = 0.01f; |         DragSpeedScaleSlow = 1.0f / 100.0f; | ||||||
|         DragSpeedScaleFast = 10.0f; |         DragSpeedScaleFast = 10.0f; | ||||||
|         ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f); |         ScrollbarClickDeltaToGrabCenter = ImVec2(0.0f, 0.0f); | ||||||
|         TooltipOverrideCount = 0; |         TooltipOverrideCount = 0; | ||||||
| @@ -697,9 +697,10 @@ struct IMGUI_API ImGuiWindow | |||||||
|     ImGuiStorage            StateStorage; |     ImGuiStorage            StateStorage; | ||||||
|     float                   FontWindowScale;                    // Scale multiplier per-window |     float                   FontWindowScale;                    // Scale multiplier per-window | ||||||
|     ImDrawList*             DrawList; |     ImDrawList*             DrawList; | ||||||
|     ImGuiWindow*            RootWindow;                         // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself. |     ImGuiWindow*            ParentWindow;                       // Immediate parent in the window stack *regardless* of whether this window is a child window or not) | ||||||
|     ImGuiWindow*            RootNonPopupWindow;                 // If we are a child window, this is pointing to the first non-child non-popup parent window. Else point to ourself. |     ImGuiWindow*            RootWindow;                         // Generally point to ourself. If we are a child window, this is pointing to the first non-child parent window. | ||||||
|     ImGuiWindow*            ParentWindow;                       // If we are a child window, this is pointing to our parent window. Else point to NULL. |     ImGuiWindow*            RootNonPopupWindow;                 // Generally point to ourself. Used to display TitleBgActive color and for selecting which window to use for NavWindowing | ||||||
|  |  | ||||||
|  |  | ||||||
|     // Navigation / Focus |     // Navigation / Focus | ||||||
|     int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister() |     int                     FocusIdxAllCounter;                 // Start at -1 and increase as assigned via FocusItemRegister() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user