Skip to content

Commit 07e09c1

Browse files
committed
- Proxy should adjust the drop info point to local space
- 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).
1 parent 04f16b3 commit 07e09c1

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lib/include/elements/base_view.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ namespace cycfi { namespace elements
284284
struct drop_info
285285
{
286286
payload data;
287-
point where;
287+
mutable point where;
288288
};
289289

290290
////////////////////////////////////////////////////////////////////////////

lib/src/element/drag_and_drop.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ namespace cycfi { namespace elements
411411
{
412412
payload pl;
413413
pl[address_to_string(di)] = {};
414-
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::entering);
414+
auto where = ctx.canvas.user_to_device(track_info.current);
415+
ctx.view.track_drop({pl, where}, cursor_tracking::entering);
415416
}
416417
track_info.processed = true;
417418
}
@@ -432,9 +433,10 @@ namespace cycfi { namespace elements
432433

433434
if (auto* di = find_parent<drop_inserter_element *>(ctx))
434435
{
436+
auto where = ctx.canvas.user_to_device(track_info.current);
435437
payload pl;
436438
pl[address_to_string(di)] = {};
437-
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::hovering);
439+
ctx.view.track_drop({pl, where}, cursor_tracking::hovering);
438440
track_info.processed = true;
439441
}
440442
ctx.view.refresh(); // $$$ Don't be lazy $$$
@@ -458,12 +460,13 @@ namespace cycfi { namespace elements
458460
_drag_image.reset();
459461
ctx.view.refresh();
460462

461-
auto* di = find_parent<drop_inserter_element *>(ctx);
463+
auto* di = find_parent<drop_inserter_element*>(ctx);
462464
if (di)
463465
{
464466
payload pl;
465467
pl[address_to_string(di)] = {};
466-
ctx.view.track_drop({pl, track_info.current}, cursor_tracking::leaving);
468+
auto where = ctx.canvas.user_to_device(track_info.current);
469+
ctx.view.track_drop({pl, where}, cursor_tracking::leaving);
467470
}
468471

469472
// Did we actually do a drag?

lib/src/element/proxy.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,17 +194,21 @@ namespace cycfi { namespace elements
194194
void proxy_base::track_drop(context const& ctx, drop_info const& info, cursor_tracking status)
195195
{
196196
context sctx {ctx, &subject(), ctx.bounds};
197-
prepare_subject(sctx);
197+
auto save = info.where;
198+
prepare_subject(sctx, info.where);
198199
subject().track_drop(sctx, info, status);
199200
restore_subject(sctx);
201+
info.where = save;
200202
}
201203

202204
bool proxy_base::drop(context const& ctx, drop_info const& info)
203205
{
204206
context sctx {ctx, &subject(), ctx.bounds};
205-
prepare_subject(sctx);
207+
auto save = info.where;
208+
prepare_subject(sctx, info.where);
206209
auto r = subject().drop(sctx, info);
207210
restore_subject(sctx);
211+
info.where = save;
208212
return r;
209213
}
210214
}}

0 commit comments

Comments
 (0)