Drag-drop behavior from child to parent is wrong

Drag-drop behavior from child to parent is wrong

Postby X512 » Mon Jul 11, 2016 4:31 pm

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: 37
Joined: Sat Feb 07, 2015 2:51 pm

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

Postby X512 » Mon Jul 11, 2016 4:50 pm

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
X512
 
Posts: 37
Joined: Sat Feb 07, 2015 2:51 pm

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

Postby Josef Templ » Fri Jul 15, 2016 7:18 am

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
Josef Templ
 
Posts: 212
Joined: Tue Sep 17, 2013 6:50 am

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

Postby X512 » Fri Jul 15, 2016 3:47 pm

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.
X512
 
Posts: 37
Joined: Sat Feb 07, 2015 2:51 pm

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

Postby Josef Templ » Sun Jul 17, 2016 10:59 am

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.
Josef Templ
 
Posts: 212
Joined: Tue Sep 17, 2013 6:50 am

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

Postby X512 » Mon Jul 18, 2016 7:45 am

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)
X512
 
Posts: 37
Joined: Sat Feb 07, 2015 2:51 pm

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

Postby Josef Templ » Tue Jul 19, 2016 6:16 am

excellent analysis. I guess it will go into 1.7.

- Josef
Josef Templ
 
Posts: 212
Joined: Tue Sep 17, 2013 6:50 am

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

Postby Ivan Denisov » Sun Jul 24, 2016 10:01 am

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

Thanks for you contribution!
User avatar
Ivan Denisov
 
Posts: 232
Joined: Tue Sep 17, 2013 12:21 am
Location: Krasnoyarsk, Russia


Return to Bug

Who is online

Users browsing this forum: No registered users and 1 guest

cron