96 |
* @author Grigor Iliev |
* @author Grigor Iliev |
97 |
*/ |
*/ |
98 |
public class MainFrame extends StdMainFrame { |
public class MainFrame extends StdMainFrame { |
99 |
|
public final static int MAX_CHANNEL_LANE_NUMBER = 8; |
100 |
|
|
101 |
private final StandardBar standardBar = new StandardBar(); |
private final StandardBar standardBar = new StandardBar(); |
102 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
103 |
private final JPanel rootPane = new RootPane(); |
private final JPanel rootPane = new RootPane(); |
167 |
addChannelsPane(mainPane.getChannelsPane(i)); |
addChannelsPane(mainPane.getChannelsPane(i)); |
168 |
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
169 |
} |
} |
170 |
|
|
171 |
|
PropertyChangeListener l = new PropertyChangeListener() { |
172 |
|
public void |
173 |
|
propertyChange(PropertyChangeEvent e) { |
174 |
|
onChangeChannelLaneCount(); |
175 |
|
} |
176 |
|
}; |
177 |
|
|
178 |
|
preferences().addPropertyChangeListener("channelLanes.count", l); |
179 |
|
|
180 |
int h = preferences().getIntProperty("midiKeyboard.height"); |
int h = preferences().getIntProperty("midiKeyboard.height"); |
181 |
setMidiKeyboardHeight(h); |
setMidiKeyboardHeight(h); |
182 |
|
|
183 |
PropertyChangeListener l = new PropertyChangeListener() { |
l = new PropertyChangeListener() { |
184 |
public void |
public void |
185 |
propertyChange(PropertyChangeEvent e) { |
propertyChange(PropertyChangeEvent e) { |
186 |
int h = preferences().getIntProperty("midiKeyboard.height"); |
int h = preferences().getIntProperty("midiKeyboard.height"); |
312 |
|
|
313 |
super.onWindowClose(); |
super.onWindowClose(); |
314 |
} |
} |
315 |
|
|
316 |
|
private void |
317 |
|
onChangeChannelLaneCount() { |
318 |
|
int newCount = preferences().getIntProperty("channelLanes.count"); |
319 |
|
if(newCount < 1 || newCount > MAX_CHANNEL_LANE_NUMBER) return; |
320 |
|
if(newCount == getChannelsPaneCount()) return; |
321 |
|
int current = getChannelsPaneIndex(getSelectedChannelsPane()); |
322 |
|
|
323 |
|
if(newCount > getChannelsPaneCount()) { |
324 |
|
int d = newCount - getChannelsPaneCount(); |
325 |
|
for(int i = 0; i < d; i++) { |
326 |
|
JSChannelsPane p = mainPane.addChannelsPane(); |
327 |
|
addChannelsPane(p); |
328 |
|
p.addListSelectionListener(pianoKeyboardPane); |
329 |
|
} |
330 |
|
} else { |
331 |
|
int d = getChannelsPaneCount() - newCount; |
332 |
|
for(int i = 0; i < d; i++) { |
333 |
|
int idx = getChannelsPaneCount() - 1 - i; |
334 |
|
if(getChannelsPane(idx).getChannelCount() > 0) { |
335 |
|
String s; |
336 |
|
s = i18n.getError("MainFrame.notEmptyChannelLane!", idx + 1); |
337 |
|
HF.showErrorMessage(s); |
338 |
|
return; |
339 |
|
} |
340 |
|
} |
341 |
|
|
342 |
|
for(int i = 0; i < d; i++) { |
343 |
|
int idx = getChannelsPaneCount() - 1; |
344 |
|
JSChannelsPane p = getChannelsPane(idx); |
345 |
|
removeChannelsPane(p); |
346 |
|
p.removeListSelectionListener(pianoKeyboardPane); |
347 |
|
mainPane.removeChannelsPane(idx); |
348 |
|
} |
349 |
|
} |
350 |
|
|
351 |
|
if(newCount == 1) { |
352 |
|
mainPane.getButtonsPanel().setVisible(false); |
353 |
|
} else if(!mainPane.getButtonsPanel().isVisible()) { |
354 |
|
mainPane.getButtonsPanel().setVisible(true); |
355 |
|
} |
356 |
|
mainPane.getButtonsPanel().setButtonNumber(newCount); |
357 |
|
if(current < 0 || current >= getChannelsPaneCount()) current = 0; |
358 |
|
setSelectedChannelsPane(getChannelsPane(current)); |
359 |
|
} |
360 |
|
|
361 |
@Override |
@Override |
362 |
public void |
public void |