浏览代码

Made drag source tooltip display at the same position as a regular tooltip to avoid discontinuity where dynamically swapping tooltip at the target site. Made drag source tooltip override previous tooltip if any. (#1739, #143).

omar 7 年之前
父节点
当前提交
3218666fb9
共有 1 个文件被更改,包括 2 次插入14 次删除
  1. 2 14
      imgui.cpp

+ 2 - 14
imgui.cpp

@@ -13230,16 +13230,8 @@ bool ImGui::BeginDragDropSource(ImGuiDragDropFlags flags)
 
 
         if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
         if (!(flags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
         {
         {
-            // FIXME-DRAG
-            //SetNextWindowPos(g.IO.MousePos - g.ActiveIdClickOffset - g.Style.WindowPadding);
-            //PushStyleVar(ImGuiStyleVar_Alpha, g.Style.Alpha * 0.60f); // This is better but e.g ColorButton with checkboard has issue with transparent colors :(
-
-            // The default tooltip position is a little offset to give space to see the context menu (it's also clamped within the current viewport/monitor)
-            // In the context of a dragging tooltip we try to reduce that offset and we enforce following the cursor.
-            ImVec2 tooltip_pos = g.IO.MousePos + ImVec2(16 * g.Style.MouseCursorScale, 8 * g.Style.MouseCursorScale);
-            SetNextWindowPos(tooltip_pos);
-            PushStyleColor(ImGuiCol_PopupBg, GetStyleColorVec4(ImGuiCol_PopupBg) * ImVec4(1.0f, 1.0f, 1.0f, 0.6f));
-            BeginTooltip();
+            SetNextWindowBgAlpha(g.Style.Colors[ImGuiCol_PopupBg].w * 0.60f);
+            BeginTooltipEx(0, true);
 
 
             // Target can request the Source to not display its tooltip (we use a dedicated flag to make this request explicit)
             // 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. 
             // We unfortunately can't just modify the source flags and skip the call to BeginTooltip, as caller may be emitting contents. 
@@ -13265,11 +13257,7 @@ void ImGui::EndDragDropSource()
     IM_ASSERT(g.DragDropActive);
     IM_ASSERT(g.DragDropActive);
 
 
     if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
     if (!(g.DragDropSourceFlags & ImGuiDragDropFlags_SourceNoPreviewTooltip))
-    {
         EndTooltip();
         EndTooltip();
-        PopStyleColor();
-        //PopStyleVar();
-    }
 
 
     // Discard the drag if have not called SetDragDropPayload()
     // Discard the drag if have not called SetDragDropPayload()
     if (g.DragDropPayload.DataFrameCount == -1)
     if (g.DragDropPayload.DataFrameCount == -1)