mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 05:01:05 +01:00 
			
		
		
		
	Disabled: fixed IsItemHovered() if popped disabled state after item, or when using Selectable_Disabled. (#211)
This commit is contained in:
		| @@ -64,6 +64,7 @@ Other Changes: | |||||||
| - Disabled: disabled mode more consistently release active id if the active item got disabled. (#211) | - Disabled: disabled mode more consistently release active id if the active item got disabled. (#211) | ||||||
| - Disabled: disabled mode doesn't prevent Selectable() from looking selected. (#211) | - Disabled: disabled mode doesn't prevent Selectable() from looking selected. (#211) | ||||||
| - Disabled: fixed IsItemHovered() returning true on disabled item when navigated to. (#211) | - Disabled: fixed IsItemHovered() returning true on disabled item when navigated to. (#211) | ||||||
|  | - Disabled: fixed IsItemHovered() if popped disabled state after item, or when using Selectable_Disabled. (#211) | ||||||
| - Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592) | - Fixed printf-style format checks on non-MinGW flavors. (#4183, #3592) | ||||||
| - Fonts: Functions with a 'float size_pixels' parameter can accept zero if it is set in ImFontSize::SizePixels. | - Fonts: Functions with a 'float size_pixels' parameter can accept zero if it is set in ImFontSize::SizePixels. | ||||||
| - Fonts: Prefer using U+FFFD character for fallback instead of '?', if available. (#4269) | - Fonts: Prefer using U+FFFD character for fallback instead of '?', if available. (#4269) | ||||||
|   | |||||||
							
								
								
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -3163,7 +3163,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) | |||||||
|     ImGuiWindow* window = g.CurrentWindow; |     ImGuiWindow* window = g.CurrentWindow; | ||||||
|     if (g.NavDisableMouseHover && !g.NavDisableHighlight) |     if (g.NavDisableMouseHover && !g.NavDisableHighlight) | ||||||
|     { |     { | ||||||
|         if ((g.CurrentItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) |         if ((window->DC.LastItemInFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) | ||||||
|             return false; |             return false; | ||||||
|         return IsItemFocused(); |         return IsItemFocused(); | ||||||
|     } |     } | ||||||
| @@ -3194,7 +3194,7 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) | |||||||
|         return false; |         return false; | ||||||
|  |  | ||||||
|     // Test if the item is disabled |     // Test if the item is disabled | ||||||
|     if ((g.CurrentItemFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) |     if ((window->DC.LastItemInFlags & ImGuiItemFlags_Disabled) && !(flags & ImGuiHoveredFlags_AllowWhenDisabled)) | ||||||
|         return false; |         return false; | ||||||
|  |  | ||||||
|     // Special handling for calling after Begin() which represent the title bar or tab. |     // Special handling for calling after Begin() which represent the title bar or tab. | ||||||
| @@ -3270,10 +3270,11 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged | |||||||
|  |  | ||||||
| // This is also inlined in ItemAdd() | // This is also inlined in ItemAdd() | ||||||
| // Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect! | // Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect! | ||||||
| void ImGui::SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags item_flags, const ImRect& item_rect) | void ImGui::SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemFlags item_flags, ImGuiItemStatusFlags item_status_flags, const ImRect& item_rect) | ||||||
| { | { | ||||||
|     window->DC.LastItemId = item_id; |     window->DC.LastItemId = item_id; | ||||||
|     window->DC.LastItemStatusFlags = item_flags; |     window->DC.LastItemInFlags = item_flags; | ||||||
|  |     window->DC.LastItemStatusFlags = item_status_flags; | ||||||
|     window->DC.LastItemRect = item_rect; |     window->DC.LastItemRect = item_rect; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -6332,7 +6333,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | |||||||
|  |  | ||||||
|         // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin(). |         // We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin(). | ||||||
|         // This is useful to allow creating context menus on title bar only, etc. |         // This is useful to allow creating context menus on title bar only, etc. | ||||||
|         SetLastItemData(window, window->MoveId, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect); |         SetLastItemData(window, window->MoveId, g.CurrentItemFlags, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect); | ||||||
|  |  | ||||||
| #ifdef IMGUI_ENABLE_TEST_ENGINE | #ifdef IMGUI_ENABLE_TEST_ENGINE | ||||||
|         if (!(window->Flags & ImGuiWindowFlags_NoTitleBar)) |         if (!(window->Flags & ImGuiWindowFlags_NoTitleBar)) | ||||||
| @@ -7484,6 +7485,7 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu | |||||||
|     // Equivalent to calling SetLastItemData() |     // Equivalent to calling SetLastItemData() | ||||||
|     window->DC.LastItemId = id; |     window->DC.LastItemId = id; | ||||||
|     window->DC.LastItemRect = bb; |     window->DC.LastItemRect = bb; | ||||||
|  |     window->DC.LastItemInFlags = g.CurrentItemFlags; | ||||||
|     window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; |     window->DC.LastItemStatusFlags = ImGuiItemStatusFlags_None; | ||||||
|     g.NextItemData.Flags = ImGuiNextItemDataFlags_None; |     g.NextItemData.Flags = ImGuiNextItemDataFlags_None; | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -61,7 +61,7 @@ Index of this file: | |||||||
| // Version | // Version | ||||||
| // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) | // (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens) | ||||||
| #define IMGUI_VERSION               "1.84 WIP" | #define IMGUI_VERSION               "1.84 WIP" | ||||||
| #define IMGUI_VERSION_NUM           18309 | #define IMGUI_VERSION_NUM           18310 | ||||||
| #define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) | #define IMGUI_CHECKVERSION()        ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx)) | ||||||
| #define IMGUI_HAS_TABLE | #define IMGUI_HAS_TABLE | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1808,6 +1808,7 @@ struct IMGUI_API ImGuiWindowTempData | |||||||
|  |  | ||||||
|     // Last item status |     // Last item status | ||||||
|     ImGuiID                 LastItemId;             // ID for last item |     ImGuiID                 LastItemId;             // ID for last item | ||||||
|  |     ImGuiItemFlags          LastItemInFlags;        // Copy of flags for last item (see ImGuiItemflags_), named "In" to avoid probably confusion with status flags | ||||||
|     ImGuiItemStatusFlags    LastItemStatusFlags;    // Status flags for last item (see ImGuiItemStatusFlags_) |     ImGuiItemStatusFlags    LastItemStatusFlags;    // Status flags for last item (see ImGuiItemStatusFlags_) | ||||||
|     ImRect                  LastItemRect;           // Interaction rect for last item |     ImRect                  LastItemRect;           // Interaction rect for last item | ||||||
|     ImRect                  LastItemDisplayRect;    // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) |     ImRect                  LastItemDisplayRect;    // End-user display rect for last item (only valid if LastItemStatusFlags & ImGuiItemStatusFlags_HasDisplayRect) | ||||||
| @@ -1962,13 +1963,14 @@ public: | |||||||
| struct ImGuiLastItemDataBackup | struct ImGuiLastItemDataBackup | ||||||
| { | { | ||||||
|     ImGuiID                 LastItemId; |     ImGuiID                 LastItemId; | ||||||
|  |     ImGuiItemFlags          LastItemInFlags; | ||||||
|     ImGuiItemStatusFlags    LastItemStatusFlags; |     ImGuiItemStatusFlags    LastItemStatusFlags; | ||||||
|     ImRect                  LastItemRect; |     ImRect                  LastItemRect; | ||||||
|     ImRect                  LastItemDisplayRect; |     ImRect                  LastItemDisplayRect; | ||||||
|  |  | ||||||
|     ImGuiLastItemDataBackup() { Backup(); } |     ImGuiLastItemDataBackup() { Backup(); } | ||||||
|     void Backup()           { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; } |     void Backup()           { ImGuiWindow* window = GImGui->CurrentWindow; LastItemId = window->DC.LastItemId; LastItemInFlags = window->DC.LastItemInFlags; LastItemStatusFlags = window->DC.LastItemStatusFlags; LastItemRect = window->DC.LastItemRect; LastItemDisplayRect = window->DC.LastItemDisplayRect; } | ||||||
|     void Restore() const    { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; } |     void Restore() const    { ImGuiWindow* window = GImGui->CurrentWindow; window->DC.LastItemId = LastItemId; window->DC.LastItemInFlags = LastItemInFlags; window->DC.LastItemStatusFlags = LastItemStatusFlags; window->DC.LastItemRect = LastItemRect; window->DC.LastItemDisplayRect = LastItemDisplayRect; } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| //----------------------------------------------------------------------------- | //----------------------------------------------------------------------------- | ||||||
| @@ -2401,7 +2403,7 @@ namespace ImGui | |||||||
|     IMGUI_API bool          ItemHoverable(const ImRect& bb, ImGuiID id); |     IMGUI_API bool          ItemHoverable(const ImRect& bb, ImGuiID id); | ||||||
|     IMGUI_API void          ItemFocusable(ImGuiWindow* window, ImGuiID id); |     IMGUI_API void          ItemFocusable(ImGuiWindow* window, ImGuiID id); | ||||||
|     IMGUI_API bool          IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); |     IMGUI_API bool          IsClippedEx(const ImRect& bb, ImGuiID id, bool clip_even_when_logged); | ||||||
|     IMGUI_API void          SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemStatusFlags status_flags, const ImRect& item_rect); |     IMGUI_API void          SetLastItemData(ImGuiWindow* window, ImGuiID item_id, ImGuiItemFlags item_flags, ImGuiItemStatusFlags status_flags, const ImRect& item_rect); | ||||||
|     IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_w, float default_h); |     IMGUI_API ImVec2        CalcItemSize(ImVec2 size, float default_w, float default_h); | ||||||
|     IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); |     IMGUI_API float         CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x); | ||||||
|     IMGUI_API void          PushMultiItemsWidths(int components, float width_full); |     IMGUI_API void          PushMultiItemsWidths(int components, float width_full); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user