3 ms·
Musescore (open-source music notation software) uses this pattern, for those interested... but not in a particularly DRY or stable way (so much duplicated logic
by btown 9y ago
Musescore (open-source music notation software) uses this pattern, for those interested... but not in a particularly DRY or stable way (so much duplicated logic!). I'm sure other open-source examples exist, but this should give you an idea:
https://github.com/musescore/MuseScore/blob/master/libmscore/undo.cpp#L245 https://github.com/musescore/MuseScore/blob/master/libmscore...
https://github.com/musescore/MuseScore/blob/master/libmscore/undo.cpp#L953 https://github.com/musescore/MuseScore/blob/master/libmscore...
https://github.com/musescore/MuseScore/blob/c4af0c22bc90a6ba180f8596fad8e4000c64a028/libmscore/measure.cpp#L1086 https://github.com/musescore/MuseScore/blob/c4af0c22bc90a6ba...
- aaron-lebo 9y agohttp://gameprogrammingpatterns.com/command.html http://gameprogrammingpatterns.com/command.html
- jcelerier 9y agoHere's how I do it (interestingly, on a Qt-based art software too :p ) https://github.com/OSSIA/score/blob/master/base/lib/core/command/CommandStack.cpp#L147 https://github.com/OSSIA/score/blob/master/base/lib/core/com... https://github.com/OSSIA/score/blob/master/base/plugins/score-plugin-media/Media/Commands/ChangeAudioFile.cpp https://github.com/OSSIA/score/blob/master/base/plugins/scor... https://github.com/OSSIA/score/blob/master/base/plugins/score-plugin-midi/Midi/Commands/AddNote.cpp https://github.com/OSSIA/score/blob/master/base/plugins/scor... https://github.com/OSSIA/score/blob/master/base/plugins/score-plugin-automation/Automation/Commands/SetAutomationMin.hpp https://github.com/OSSIA/score/blob/master/base/plugins/scor... Also once your commands are serialized you can send them over the network for distributed edition