mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-31 13:11:05 +01:00 
			
		
		
		
	Disabled: disabled items set HoveredId, allowing e.g. HoveredIdTimer to function. (#211, #3419) + Menus: fix hovering a disabled menu or menu item not closing other menus.
Rework of https://github.com/rokups/imgui/commit/c24b470
Note that the declared intent of that commit "Prevents window from being dragged if mouse hovers a disabled item." was already fullfilled by a876ad87.
Changes in ButtonBehavior() not needed anymore since ImGuiButtonFlags_Disabled is gone
			
			
This commit is contained in:
		| @@ -1445,7 +1445,7 @@ bool ImGui::SplitterBehavior(const ImRect& bb, ImGuiID id, ImGuiAxis axis, float | ||||
|     if (g.ActiveId != id) | ||||
|         SetItemAllowOverlap(); | ||||
|  | ||||
|     if (held || (g.HoveredId == id && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) | ||||
|     if (held || (hovered && g.HoveredIdPreviousFrame == id && g.HoveredIdTimer >= hover_visibility_delay)) | ||||
|         SetMouseCursor(axis == ImGuiAxis_Y ? ImGuiMouseCursor_ResizeNS : ImGuiMouseCursor_ResizeEW); | ||||
|  | ||||
|     ImRect bb_render = bb; | ||||
| @@ -2431,7 +2431,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data, | ||||
|     } | ||||
|  | ||||
|     // Draw frame | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     RenderNavHighlight(frame_bb, id); | ||||
|     RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, style.FrameRounding); | ||||
|  | ||||
| @@ -3037,7 +3037,7 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat | ||||
|     } | ||||
|  | ||||
|     // Draw frame | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     RenderNavHighlight(frame_bb, id); | ||||
|     RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); | ||||
|  | ||||
| @@ -3185,7 +3185,7 @@ bool ImGui::VSliderScalar(const char* label, const ImVec2& size, ImGuiDataType d | ||||
|     } | ||||
|  | ||||
|     // Draw frame | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : g.HoveredId == id ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     const ImU32 frame_col = GetColorU32(g.ActiveId == id ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg); | ||||
|     RenderNavHighlight(frame_bb, id); | ||||
|     RenderFrame(frame_bb.Min, frame_bb.Max, frame_col, true, g.Style.FrameRounding); | ||||
|  | ||||
| @@ -7964,7 +7964,6 @@ bool    ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, | ||||
|     bool pressed = ButtonBehavior(bb, id, &hovered, &held, button_flags); | ||||
|     if (pressed && !is_tab_button) | ||||
|         tab_bar->NextSelectedTabId = id; | ||||
|     hovered |= (g.HoveredId == id); | ||||
|  | ||||
|     // Allow the close button to overlap unless we are dragging (in which case we don't want any overlapping tabs to be hovered) | ||||
|     if (g.ActiveId != id) | ||||
| @@ -8028,8 +8027,11 @@ bool    ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, | ||||
|         PopClipRect(); | ||||
|     window->DC.CursorPos = backup_main_cursor_pos; | ||||
|  | ||||
|     // Tooltip (FIXME: Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer) | ||||
|     // We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar (which g.HoveredId ignores) | ||||
|     // Tooltip | ||||
|     // (Won't work over the close button because ItemOverlap systems messes up with HoveredIdTimer-> seems ok) | ||||
|     // (We test IsItemHovered() to discard e.g. when another item is active or drag and drop over the tab bar, which g.HoveredId ignores) | ||||
|     // FIXME: This is a mess. | ||||
|     // FIXME: We may want disabled tab to still display the tooltip? | ||||
|     if (text_clipped && g.HoveredId == id && !held && g.HoveredIdNotActiveTimer > g.TooltipSlowDelay && IsItemHovered()) | ||||
|         if (!(tab_bar->Flags & ImGuiTabBarFlags_NoTooltip) && !(tab->Flags & ImGuiTabItemFlags_NoTooltip)) | ||||
|             SetTooltip("%.*s", (int)(FindRenderedTextEnd(label) - label), label); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user