Sketching and Scribbling at the Same Time

Previous pageNext page

"Keeping the above window open, create an Etch-a-Sketch window that draws in parallel with the Scribble pad. Use the sliders as drawing controls. This is another tutorial example"

EtchASketch showOn: scribble model.

 


Now this is cool. Evaluate the above and you will get an EtchASketch window that displays the same ink as your original Scribble pad (EtchASketch is another Dolphin sample application). What's even better is that, if you draw in either of the two windows, the other updates. This is because both windows are sharing the same underlying ink data. This data is known as the model data. Hint: in the Etch-a-Sketch window use the sliders at the sides to do the drawing; it's meant to be a bit like the child's toy.

Once, you've done enough doodling just close the Scribble and Etch-a-Sketch windows.

Both the Scribble and EtchASketch classes are examples that demonstrate Dolphin's user interface framework, which is called Model, View, Presenter (or MVP). Now is not the time to go into full details, but the key point is that the model data (the ink objects in this case) are held separately from the window that views them. Not only does this make it easier to program the model because you don't have to worry about how it is going to be displayed but it also allows you to connect several views onto the same data and have each view update automatically as the model changes.

Remember, to get back to these experiments just choose Help/First Splash in any Dolphin tool window.