mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-03 22:51:06 +01:00 
			
		
		
		
	Begin: WIP consistent Begin/End behavior, BeginTooltip API (one issue with BeginDragDropSource)
This commit is contained in:
		
							
								
								
									
										34
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								imgui.cpp
									
									
									
									
									
								
							@@ -4153,11 +4153,13 @@ void ImGui::UpdateDebugToolItemPicker()
 | 
			
		||||
            g.DebugItemPickerActive = false;
 | 
			
		||||
        }
 | 
			
		||||
        ImGui::SetNextWindowBgAlpha(0.60f);
 | 
			
		||||
        ImGui::BeginTooltip();
 | 
			
		||||
        ImGui::Text("HoveredId: 0x%08X", hovered_id);
 | 
			
		||||
        ImGui::Text("Press ESC to abort picking.");
 | 
			
		||||
        ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
 | 
			
		||||
        ImGui::EndTooltip();
 | 
			
		||||
        if (ImGui::BeginTooltip())
 | 
			
		||||
        {
 | 
			
		||||
            ImGui::Text("HoveredId: 0x%08X", hovered_id);
 | 
			
		||||
            ImGui::Text("Press ESC to abort picking.");
 | 
			
		||||
            ImGui::TextColored(GetStyleColorVec4(hovered_id ? ImGuiCol_Text : ImGuiCol_TextDisabled), "Click to break in debugger!");
 | 
			
		||||
            ImGui::EndTooltip();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -8540,12 +8542,12 @@ void ImGui::SetScrollHereY(float center_y_ratio)
 | 
			
		||||
// [SECTION] TOOLTIPS
 | 
			
		||||
//-----------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
void ImGui::BeginTooltip()
 | 
			
		||||
bool ImGui::BeginTooltip()
 | 
			
		||||
{
 | 
			
		||||
    BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
 | 
			
		||||
    return BeginTooltipEx(ImGuiWindowFlags_None, ImGuiTooltipFlags_None);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
 | 
			
		||||
bool ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags tooltip_flags)
 | 
			
		||||
{
 | 
			
		||||
    ImGuiContext& g = *GImGui;
 | 
			
		||||
 | 
			
		||||
@@ -8575,8 +8577,10 @@ void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, ImGuiTooltipFlags toolt
 | 
			
		||||
            }
 | 
			
		||||
    ImGuiWindowFlags flags = ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking;
 | 
			
		||||
    bool ret = Begin(window_name, NULL, flags | extra_flags);
 | 
			
		||||
    // FIXME-NEWBEGIN
 | 
			
		||||
    IM_ASSERT(ret);
 | 
			
		||||
    // FIXME-NEWBEGIN: adding a bool to API...
 | 
			
		||||
    //IM_UNUSED(ret);
 | 
			
		||||
    //IM_ASSERT(ret);
 | 
			
		||||
    return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ImGui::EndTooltip()
 | 
			
		||||
@@ -8587,7 +8591,8 @@ void ImGui::EndTooltip()
 | 
			
		||||
 | 
			
		||||
void ImGui::SetTooltipV(const char* fmt, va_list args)
 | 
			
		||||
{
 | 
			
		||||
    BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip);
 | 
			
		||||
    if (!BeginTooltipEx(0, ImGuiTooltipFlags_OverridePreviousTooltip))
 | 
			
		||||
        return;
 | 
			
		||||
    TextV(fmt, args);
 | 
			
		||||
    EndTooltip();
 | 
			
		||||
}
 | 
			
		||||
@@ -10381,7 +10386,9 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
 | 
			
		||||
        {
 | 
			
		||||
            // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
 | 
			
		||||
            // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents.
 | 
			
		||||
            BeginTooltip();
 | 
			
		||||
            bool ret = BeginTooltip(); // FIXME-NEWBEGIN: problematic
 | 
			
		||||
            IM_UNUSED(ret);
 | 
			
		||||
            IM_ASSERT(ret);
 | 
			
		||||
            if (g.DragDropAcceptIdPrev && (g.DragDropAcceptFlags & ImGuiDragDropFlags_AcceptNoPreviewTooltip))
 | 
			
		||||
            {
 | 
			
		||||
                ImGuiWindow* tooltip_window = g.CurrentWindow;
 | 
			
		||||
@@ -15745,9 +15752,8 @@ static void RenderViewportsThumbnails()
 | 
			
		||||
static void MetricsHelpMarker(const char* desc)
 | 
			
		||||
{
 | 
			
		||||
    ImGui::TextDisabled("(?)");
 | 
			
		||||
    if (ImGui::IsItemHovered())
 | 
			
		||||
    if (ImGui::IsItemHovered() && ImGui::BeginTooltip())
 | 
			
		||||
    {
 | 
			
		||||
        ImGui::BeginTooltip();
 | 
			
		||||
        ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
 | 
			
		||||
        ImGui::TextUnformatted(desc);
 | 
			
		||||
        ImGui::PopTextWrapPos();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user