From: Brian <br...@ov...> - 2005-03-15 14:52:37
|
Joe Emenaker wrote: > Looking at various synth editors for ideas, I'm seeing many bits of > code that look like: > > addWidget(leftPane, new CheckBoxWidget("Midi Pitch Bend", patch, > new MKSBitModel(patch, 16, 5), new MKSBitSender(patch, 16, 5, > 9)), 0, 10, 1, 1, -3); > > or... > > addWidget(panel, new ComboBoxWidget("Footswitch Mode", patch, > new DM5SysInfoModel(patch, > headerSize + 0, 32, false), > new DM5SysInfoSender(patch, 1),.... > > Notice that "patch" is used 3 times in these method calls. This seems > like it could be made a little more streamlined to me. > > As usual, I'm willing to do the work to fix it, but I don't want to if > everyone else feels that the current system is optimal. > > However, if anyone else would like to see this cleaned up, then I'd > like to discuss ideas for it. I think this should be pretty easy to clean up if you are willing. . The reason patch appears three times is that the Widget itself wants to see the patch, the sender wants to see it, and the model wants to see it. My gut reaction to how to fix it would be to create a method in the base class for models and senders that does nothing called setPatch (Patch p). This would be called automatically by addWidget on the Model and Sender sent to it. Models / Senders could override this to get at the Patch rather than having to take the Patch in their constructor. Existing drivers could remain unchanged but new ones could then get away without having to pass patch three times. We could always go back and upgrade older drivers later. Brian |