Drag-drop behavior from child to parent is wrong

Post Reply
X512
Posts: 72
Joined: Sat Feb 07, 2015 2:51 pm

Drag-drop behavior from child to parent is wrong

Post by X512 »

Code: Select all

StdCoder.Decode ..,, ..sG....3Qw7uP5PRPPNR9Rbf9b8R79FTvMf1GomCrlAy2xhX,Cb2x
 hXhC6FU1xhiZiVBhihgmRiioedhgrZcZRiXFfaqmSrtuGfa4700zdGrr8rmCLLCJuyKtYcZRiX
 7.2.s,MD7.,k,5TWyql.bnayKmKKqGomC5XzET1.PuP.MHT9N9ntumaU2,CJuyKtQC98P9PP7O
 NbXmb.2.Ql1k2k,D.,6.,U0eFTfQPfJHPNCbHZiYpedhgrZ6MwBuPZ1QCh0708T,U..w.gZ1U.
 2U1Cy4xhmNHT9NQCbWBxhYhA704D.CbB,708T1U.ES9.J.dh.2U.2.IkmD,2U.kpl1kdF.0U1K
 y9.,ULU8UDU.2.6U2.E,5DQcjpBZvPN9P9fQbf9b8RCoruKu.GomCrl0ks,.sQRtETfPd16F6.
 C244.IC...Qii..70,cw7.,..A,6..8k.0LX7EnM.K.ivljj.pj36ExP,0Qx0V.LjEcUZ50E.M
 91U5UJA.0U.QE2.,6.QOI,QN2U..3gwU.ELl1E9F.0U100E.6Jc06H6.U0CyDJgs3eVZiohgmp
 hnpZK,C5C.2.a,2.4.2kmI.,gA3EU1v12sky.,Y..8Mtr.2..M0E..I...zzjzJUu5,0,4,4,Y
 ..866.,..a.2..3..kRVtj0,0,cwLFUSrBIklz78ouGLuyKrCLLO3..,UCV.2.O12.c8mLT5.0
 E.0t.k.yYW7SGZmNM0bi6Fy4G3U.2U.az8kwLV.X.xiP6U2.E,,,6..k22.0.U0..E.AUA2TmE
 w7HFfAmsq5W0Cy2,U1xB..y.2..600U.E0E.6RvuQ0mHCe.az86Utj0GTkWaUKZM0sB,...
 --- end of encoding ---
Steps to reproduce:
1. Open encoded document.
2. drag pattern view (view with nested color rectangles) to root form.
3. You get copy of pattern view, but view should be moved (original should be deleted).

Problem reason is wrong order of inserting and deletion in Containers.TrackToDrop.

Original:

Code: Select all

ELSIF op = Mechanisms.move THEN	(* drop copy and delete original *)
	Controllers.Drop(x, y, f, x0, y0, v, isSingle, w, h, rx, ry);
	c.DeleteSelection;
END
Fix:

Code: Select all

ELSIF op = Mechanisms.move THEN	(* drop copy and delete original *)
	c.DeleteSelection;
	Controllers.Drop(x, y, f, x0, y0, v, isSingle, w, h, rx, ry);
END
Also after drop 2 operations (insertion and deletion) are recorded. It will be good to group this operations to one move operation (BeginScript etc.).
Last edited by X512 on Fri Jul 15, 2016 3:52 pm, edited 1 time in total.
X512
Posts: 72
Joined: Sat Feb 07, 2015 2:51 pm

Re: Drag-drop behavior from child to pare is wrong

Post by X512 »

Also focus should be set to view where selection was dropped. Otherwise it will cause drawing glitches.

Containers.Transfer:

Code: Select all

| msg: Controllers.DropMsg DO
	inSelection := c.InSelection(f, msg.x, msg.y);
	dMsg.mode := c.opts; dMsg.okToDrop := FALSE;
	IF g # NIL THEN Views.HandlePropMsg(g.view, dMsg) END;
	IF (g # NIL) & ~inSelection & (dMsg.okToDrop OR ~(noFocus IN c.opts))THEN
		c.SetFocus(g.view); (* this line was added *)
		focus := g.view
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Drag-drop behavior from child to pare is wrong

Post by Josef Templ »

I think the grouping of the two operations (delete + insert) is only possible if
the drop source and target are in the same domain.

Can you try to work this out in detail?

The other fixes look good to me.

- Josef
X512
Posts: 72
Joined: Sat Feb 07, 2015 2:51 pm

Re: Drag-drop behavior from child to pare is wrong

Post by X512 »

Editing history is recorded separately for each domain (in Sequencer object, implemented in Windows module), so if selection was dropped to same domain as source it is possible to make copy and delete one operation. First argument for Models.BeginScript and Views.BeginScript is only used to get domain, so it can be any model/view from domain. So following change is possible:

Code: Select all

VAR script: Stores.Operation
...
Views.BeginScript(c.view, "#System:Moving", script);
c.DeleteSelection;
Controllers.Drop(x, y, f, x0, y0, v, isSingle, w, h, rx, ry);
Views.EndScript(c.view, script);
If selection was dropped to different domain or different process/application, only deletion will be recorded as moving script, no error happens. Making one operation for multiple domains is not possible, at least without tricks.
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Drag-drop behavior from child to parent is wrong

Post by Josef Templ »

When you have two domains, you cannot undo a Move, you can only undo an Insert or a Delete.
It should not be named 'Move' then but use the specialized names Insert and Delete.
X512
Posts: 72
Joined: Sat Feb 07, 2015 2:51 pm

Re: Drag-drop behavior from child to parent is wrong

Post by X512 »

In this case it is possible to check domains explicitly:

Code: Select all

IF (c.view.Domain() # NIL) & (c.view.Domain() = dest.view.Domain()) THEN
	Views.BeginScript(c.view, "#System:Moving", script);
END;
c.DeleteSelection;
Controllers.Drop(x, y, f, x0, y0, v, isSingle, w, h, rx, ry);
IF script # NIL THEN
	Views.EndScript(c.view, script);
END
Deleting operation is already generated by c.DeleteSelection.
Also it will be good to group insertion operations in form when selection containing many views are dropped.
FormControllers.StdController.Drop

Code: Select all

VAR
...
		script: Stores.Operation; (* this line was added *)
BEGIN	(* cf. MarkDropTarget *)
	DEC(dx, rx); DEC(dy, ry);
	IF ~isSingle & (v IS FormViews.View) THEN
		Models.BeginScript(c.form, "#System:Insertion", script); (* this line was added *)
		...
		Models.EndScript(c.form, script); (* this line was added *)
		c.SetSelection(p)
Josef Templ
Posts: 262
Joined: Tue Sep 17, 2013 6:50 am

Re: Drag-drop behavior from child to parent is wrong

Post by Josef Templ »

excellent analysis. I guess it will go into 1.7.

- Josef
User avatar
Ivan Denisov
Posts: 362
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia

Re: Drag-drop behavior from child to parent is wrong

Post by Ivan Denisov »

The bug fix was included in 1.7.
http://blackboxframework.org/unstable/m ... c1.589.zip

Thanks for you contribution!
Post Reply