Stephen Torri wrote:

I believe I have a good understanding of the first pass. Right now the
second pass that stumps me. So I have a few questions, which I will
research myself tomorrow, are:

1. Where is the function execute() called on my
FingeringInsertionCommand?
In MultiViewCommandHistory::addCommand()

2. How does the Event object passed to SegmentNotationHelper for
insertText, for example, get displayed?
Executing any command will trigger a refresh of the view.

The design behind this stems from two needs :
- an unlimited undo/redo stack
- abstracting the graphic representation of the data (notation, matrix, event list...) from the data itself (events in segments), that is, changes are performed on the data itself, and the view takes care of updating itself.

(Note that this 2nd need isn't as well implemented as it should, in part due to the QCanvas model, and in part due to my ignorance of the Model/View/Controller (or at least Model/View) pattern when I first laid this out back in 2000 - shame, which is one of the reaons behind my infamous rewrite of the segment canvas).

Anyway, the 2nd need explains why your commands should alter the Composition directly and ignore the existence of EditView. The 1st need explains why you need to have commands in the first place. This is a straightforward implementation of the Command design pattern : http://www.dofactory.com/Patterns/PatternCommand.aspx#_self1

(btw, if you don't have it yet, "Design Patterns" by the "gang of four", Gamma, Helm, Johnson & Vlissides is an absolute must-have)

This pattern is very simple : all user commands are represented by instances of an abstract Command class, which has only two methods : execute() and, obviously, unexecute(). The undo/redo stack is simply a stack of these objects. When the user performs a new action, the corresponding command is created, added on the stack, its execute() method is called, and the stack pointer is moved to this command. When the user calls 'undo', the 'unexecute()' method of the command pointed by the stack pointer is called, and the stack pointer is moved back one step.

--
Guillaume
http://telegraph-road.org



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to