Skip to content

Commit

Permalink
- Proxy should adjust the drop info point to local space
Browse files Browse the repository at this point in the history
- Drag and drop should convert to global space when tracking a drag and drop operation
- Temporarily make drop_info::where mutable (we need a better solution).
  • Loading branch information
djowel committed Feb 17, 2024
1 parent 04f16b3 commit ad1c670
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/include/elements/base_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace cycfi { namespace elements
struct drop_info
{
payload data;
point where;
mutable point where;
};

////////////////////////////////////////////////////////////////////////////
Expand Down
9 changes: 6 additions & 3 deletions lib/src/element/drag_and_drop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ namespace cycfi { namespace elements
{
payload pl;
pl[address_to_string(di)] = {};
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::entering);
auto where = ctx.canvas.user_to_device(track_info.current);
ctx.view.track_drop({pl, where}, cursor_tracking::entering);
}
track_info.processed = true;
}
Expand All @@ -432,9 +433,10 @@ namespace cycfi { namespace elements

if (auto* di = find_parent<drop_inserter_element *>(ctx))
{
auto where = ctx.canvas.user_to_device(track_info.current);
payload pl;
pl[address_to_string(di)] = {};
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::hovering);
ctx.view.track_drop({pl, where}, cursor_tracking::hovering);
track_info.processed = true;
}
ctx.view.refresh(); // $$$ Don't be lazy $$$
Expand Down Expand Up @@ -463,7 +465,8 @@ namespace cycfi { namespace elements
{
payload pl;
pl[address_to_string(di)] = {};
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::leaving);
auto where = ctx.canvas.user_to_device(track_info.current);
ctx.view.track_drop({pl, where}, cursor_tracking::leaving);
}

// Did we actually do a drag?
Expand Down
8 changes: 6 additions & 2 deletions lib/src/element/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,21 @@ namespace cycfi { namespace elements
void proxy_base::track_drop(context const& ctx, drop_info const& info, cursor_tracking status)
{
context sctx {ctx, &subject(), ctx.bounds};
prepare_subject(sctx);
auto save = info.where;
prepare_subject(sctx, info.where);
subject().track_drop(sctx, info, status);
restore_subject(sctx);
info.where = save;
}

bool proxy_base::drop(context const& ctx, drop_info const& info)
{
context sctx {ctx, &subject(), ctx.bounds};
prepare_subject(sctx);
auto save = info.where;
prepare_subject(sctx, info.where);
auto r = subject().drop(sctx, info);
restore_subject(sctx);
info.where = save;
return r;
}
}}

0 comments on commit ad1c670

Please sign in to comment.