This is a guide on how to insert multiple Snappers during an insert animation. Useful if you want to insert a group of Snappers like a connected group of worksurfaces.
Example
Fika worksurface will be used as an example to demonstrate how to achieve this functionality. In this example, a Worksurface
will be connected to the back of another Worksurface
when adding it into the drawing
Create your own group InsertAnimation:
/** * Fo straight front worksurface insert animation */ public class FoGroupInsertAnimationG2 extends WorksurfaceInsertAnimationG2 { /** * The other worksurface that you are trying to connect */ private FOStraightFrontWorksurface _otherWs; /** * Constructor */ public constructor(StartInsertAnimationEnv env) { super(..); if (!_otherWs) _otherWs = FOStraightFrontWorksurface(); if (selection) selection.snappers << _otherWs; connectOtherWorksurfaces(); } /** * Connect other worksurfaces */ extend public void connectOtherWorksurfaces() { if (!isConnectedTo(_otherWs, surface())) { if (WorksurfaceConnectLine mainWsBackCl = surface.connectLine("b")) { if (WorksurfaceConnectLine otherWsBackCl = _otherWs.connectLine("b")) { if (!(mainWsBackCl.isConnected() and otherWsBackCl.isConnected())) { _otherWs.setRot(_otherWs.rotationIfConnected(otherWsBackCl, mainWsBackCl)); _otherWs.setPos(_otherWs.positionIfConnected(otherWsBackCl, mainWsBackCl)); if (isActive()) { surface.connect(mainWsBackCl, otherWsBackCl); } } } } } } }
And then just use that Animation in the insert animation of FOFSRectWorksurface
:
/** * Return desired insert animation. */ public Animation insertAnimation(StartInsertAnimationEnv env) { return FoGroupInsertAnimationG2(env); }
Result:
This guide gloss over a lot of stuff like changing property that propagates to other connected Snappers when animation properties are changed. To keep it simple the guide focuses on how to connect Snappers during the Animation of another Snapper.
Comments
0 comments
Please sign in to leave a comment.