How to rotate dropped objects in the GLSP editor #789
-
Can we provide feature of rotatation to objects that are dragged and dropped in glsp editor. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, You would need to implement an operation (e.g. RotateOperation) to modify the state of your diagram, and trigger this operation when the user interacts with the Rotate handle. The server needs to store the current rotation, and update it when it receives the RotateOperation. On the client, this can be implemented using an SVG Transform property on the rotated node (You need to provide and customize your own RectangularNodeView for this - or any other similar view that you use to render your node). If your node contains children, the children will be rotated as well. Note that this will likely cause issues with existing user-actions, such as Move (ChangeBounds), because the coordinate system will be modified by the Rotation, and GLSP won't expect that. It won't know how to properly deal with it (Dragging/Change Bounds will still kind of work, but with some unexpected results). If the rotated node doesn't contain any child, or the children can't be moved, this shouldn't be an issue. If you need to keep children and you want to move them around, I would advise against the rotation approach. If you only rotate your nodes by multiples of 90°, then similar behavior can be achieved by simply swapping the Width and Height property of the rotated node, and updating the children positions accordingly. This way, the rotation is handled exclusively on the Server, and the client tools won't break (You can still drag child nodes to move them, without any specific issue). However, this simplified approach only works when rotating by 90, 180 or 270°. |
Beta Was this translation helpful? Give feedback.
Hi,
You would need to implement an operation (e.g. RotateOperation) to modify the state of your diagram, and trigger this operation when the user interacts with the Rotate handle. The server needs to store the current rotation, and update it when it receives the RotateOperation.
On the client, this can be implemented using an SVG Transform property on the rotated node (You need to provide and customize your own RectangularNodeView for this - or any other similar view that you use to render your node). If your node contains children, the children will be rotated as well. Note that this will likely cause issues with existing user-actions, such as Move (ChangeBounds), because the coordinate …