mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-12 02:00:58 +01:00
parent
0dd756bceb
commit
085ed7bfbe
@ -87,6 +87,8 @@ Other changes:
|
|||||||
- Mostly legacy behavior when used inside old Columns(), as we favored that idiom back then,
|
- Mostly legacy behavior when used inside old Columns(), as we favored that idiom back then,
|
||||||
only different is left position follows indentation level, to match calling a Separator()
|
only different is left position follows indentation level, to match calling a Separator()
|
||||||
inside or outside Columns().
|
inside or outside Columns().
|
||||||
|
- Drag and Drop: Rework drop target highlight: reduce rectangle to its visible portion, and
|
||||||
|
then expand slightly. A full rectangle is always visible and it may protrude slightly. (#4281, #3272)
|
||||||
- Drag and Drop: Fixed submitting a tooltip from drop target location when using AcceptDragDropPayload()
|
- Drag and Drop: Fixed submitting a tooltip from drop target location when using AcceptDragDropPayload()
|
||||||
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
with ImGuiDragDropFlags_AcceptNoPreviewTooltip and submitting a tooltip manually.
|
||||||
- Tables: Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
- Tables: Fixed an edge-case when no columns are visible + table scrollbar is visible + user
|
||||||
|
17
imgui.cpp
17
imgui.cpp
@ -12656,7 +12656,6 @@ bool ImGui::IsDragDropPayloadBeingAccepted()
|
|||||||
const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
|
const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDropFlags flags)
|
||||||
{
|
{
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
ImGuiWindow* window = g.CurrentWindow;
|
|
||||||
ImGuiPayload& payload = g.DragDropPayload;
|
ImGuiPayload& payload = g.DragDropPayload;
|
||||||
IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
|
IM_ASSERT(g.DragDropActive); // Not called between BeginDragDropTarget() and EndDragDropTarget() ?
|
||||||
IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
|
IM_ASSERT(payload.DataFrameCount != -1); // Forgot to call EndDragDropTarget() ?
|
||||||
@ -12680,7 +12679,7 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
|||||||
payload.Preview = was_accepted_previously;
|
payload.Preview = was_accepted_previously;
|
||||||
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that live for 1 frame)
|
flags |= (g.DragDropSourceFlags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect); // Source can also inhibit the preview (useful for external sources that live for 1 frame)
|
||||||
if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
|
if (!(flags & ImGuiDragDropFlags_AcceptNoDrawDefaultRect) && payload.Preview)
|
||||||
window->DrawList->AddRect(r.Min - ImVec2(3.5f,3.5f), r.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f);
|
RenderDragDropTargetRect(r);
|
||||||
|
|
||||||
g.DragDropAcceptFrameCount = g.FrameCount;
|
g.DragDropAcceptFrameCount = g.FrameCount;
|
||||||
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
|
payload.Delivery = was_accepted_previously && !IsMouseDown(g.DragDropMouseButton); // For extern drag sources affecting OS window focus, it's easier to just test !IsMouseDown() instead of IsMouseReleased()
|
||||||
@ -12691,10 +12690,20 @@ const ImGuiPayload* ImGui::AcceptDragDropPayload(const char* type, ImGuiDragDrop
|
|||||||
return &payload;
|
return &payload;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME-DRAGDROP: Settle on a proper default visuals for drop target.
|
// FIXME-STYLE FIXME-DRAGDROP: Settle on a proper default visuals for drop target.
|
||||||
void ImGui::RenderDragDropTargetRect(const ImRect& bb)
|
void ImGui::RenderDragDropTargetRect(const ImRect& bb)
|
||||||
{
|
{
|
||||||
GetWindowDrawList()->AddRect(bb.Min - ImVec2(3.5f, 3.5f), bb.Max + ImVec2(3.5f, 3.5f), GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f);
|
ImGuiContext& g = *GImGui;
|
||||||
|
ImGuiWindow* window = g.CurrentWindow;
|
||||||
|
ImRect bb_display = bb;
|
||||||
|
bb_display.ClipWith(window->ClipRect); // Clip THEN expand so we have a way to visualize that target is not entirely visible.
|
||||||
|
bb_display.Expand(3.5f);
|
||||||
|
bool push_clip_rect = !window->ClipRect.Contains(bb_display);
|
||||||
|
if (push_clip_rect)
|
||||||
|
window->DrawList->PushClipRectFullScreen();
|
||||||
|
window->DrawList->AddRect(bb_display.Min, bb_display.Max, GetColorU32(ImGuiCol_DragDropTarget), 0.0f, 0, 2.0f);
|
||||||
|
if (push_clip_rect)
|
||||||
|
window->DrawList->PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
const ImGuiPayload* ImGui::GetDragDropPayload()
|
const ImGuiPayload* ImGui::GetDragDropPayload()
|
||||||
|
@ -2437,6 +2437,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
ImGuiDragDropFlags drop_target_flags = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoPreviewTooltip;
|
ImGuiDragDropFlags drop_target_flags = ImGuiDragDropFlags_AcceptBeforeDelivery | ImGuiDragDropFlags_AcceptNoPreviewTooltip;
|
||||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, drop_target_flags))
|
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F, drop_target_flags))
|
||||||
{
|
{
|
||||||
|
IM_UNUSED(payload);
|
||||||
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
|
ImGui::SetMouseCursor(ImGuiMouseCursor_NotAllowed);
|
||||||
ImGui::BeginTooltip();
|
ImGui::BeginTooltip();
|
||||||
ImGui::Text("Cannot drop here!");
|
ImGui::Text("Cannot drop here!");
|
||||||
|
Loading…
Reference in New Issue
Block a user