3 ms·
Indeed! I'm writing an app that resizes and moves shapes on a canvas (among other things) and I'm amazed at how many trivial little things I had to write that e
by airstrike 2y ago
Indeed! I'm writing an app that resizes and moves shapes on a canvas (among other things) and I'm amazed at how many trivial little things I had to write that everyone including me would take for granted, including copying and pasting, drawing the little handles to resize the shape, changing the cursor based on what's below it (the handles or the shapes), drawing a translucent version of the shape when it's being moved/resized, changing the position of the shape when it is resized from _some_ of the handles but not all (top left vs. bottom right)...
- escapecharacter 2y agojust wait until you get to the undo/redo stack! That's one of my favourite parts of a UI to program.
- mark-r 2y agoMy experience is that undo/redo isn't something you tack on at the end of the project, it has to be baked into the infrastructure. Every action you take has to be delegated to an object that has all the information it needs to both do the action and undo it. Then you can just keep a stack of those objects and call them as necessary.
- airstrike 2y agoFortunately I'm using iced which is an implementation of The Elm Architecture so undo/redo is just a matter of keeping track of which messages were sent and reversing them as needed.