1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
23 |
package org.jsampler.view.fantasia; |
package org.jsampler.view.fantasia; |
24 |
|
|
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
26 |
|
import java.awt.Color; |
27 |
|
import java.awt.Composite; |
28 |
import java.awt.Dialog; |
import java.awt.Dialog; |
29 |
import java.awt.Dimension; |
import java.awt.Dimension; |
30 |
import java.awt.Frame; |
import java.awt.Frame; |
31 |
import java.awt.Graphics; |
import java.awt.Graphics; |
32 |
|
import java.awt.Graphics2D; |
33 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagConstraints; |
34 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
35 |
import java.awt.Insets; |
import java.awt.Insets; |
36 |
import java.awt.Point; |
import java.awt.Paint; |
37 |
|
import java.awt.Rectangle; |
38 |
|
|
39 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
40 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
41 |
import java.awt.event.KeyEvent; |
import java.awt.event.KeyEvent; |
42 |
import java.awt.event.MouseAdapter; |
|
43 |
import java.awt.event.MouseEvent; |
import java.beans.PropertyChangeEvent; |
44 |
|
import java.beans.PropertyChangeListener; |
45 |
|
|
46 |
import java.io.BufferedReader; |
import java.io.BufferedReader; |
47 |
import java.io.File; |
import java.io.File; |
49 |
import java.io.FileReader; |
import java.io.FileReader; |
50 |
|
|
51 |
import java.util.Vector; |
import java.util.Vector; |
|
import java.util.logging.Level; |
|
52 |
|
|
53 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
|
import javax.swing.Box; |
|
54 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
55 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
|
import javax.swing.JComponent; |
|
|
import javax.swing.JDialog; |
|
|
import javax.swing.JFileChooser; |
|
|
import javax.swing.JFrame; |
|
56 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
57 |
import javax.swing.JMenuBar; |
import javax.swing.JMenuBar; |
58 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
59 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
|
import javax.swing.JPopupMenu; |
|
|
import javax.swing.JScrollPane; |
|
60 |
import javax.swing.JSplitPane; |
import javax.swing.JSplitPane; |
|
import javax.swing.JToggleButton; |
|
61 |
import javax.swing.KeyStroke; |
import javax.swing.KeyStroke; |
62 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
63 |
import javax.swing.UIManager; |
import javax.swing.Timer; |
64 |
|
|
65 |
import net.sf.juife.TitleBar; |
import javax.swing.event.ListSelectionEvent; |
66 |
|
import javax.swing.event.ListSelectionListener; |
67 |
|
|
68 |
import org.jsampler.CC; |
import org.jsampler.CC; |
69 |
import org.jsampler.HF; |
import org.jsampler.HF; |
70 |
|
import org.jsampler.JSUtils; |
71 |
import org.jsampler.LSConsoleModel; |
import org.jsampler.LSConsoleModel; |
72 |
|
import org.jsampler.Server; |
73 |
|
|
|
import org.jsampler.view.JSChannel; |
|
74 |
import org.jsampler.view.JSChannelsPane; |
import org.jsampler.view.JSChannelsPane; |
75 |
import org.jsampler.view.JSMainFrame; |
import org.jsampler.view.SessionViewConfig; |
76 |
import org.jsampler.view.LscpFileFilter; |
|
77 |
|
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
78 |
|
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
79 |
|
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
80 |
|
|
81 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
82 |
|
import org.jsampler.view.std.JSConnectDlg; |
83 |
import org.jsampler.view.std.JSDetailedErrorDlg; |
import org.jsampler.view.std.JSDetailedErrorDlg; |
84 |
import org.jsampler.view.std.JSQuitDlg; |
import org.jsampler.view.std.JSQuitDlg; |
85 |
import org.jsampler.view.std.JSamplerHomeChooser; |
import org.jsampler.view.std.JSamplerHomeChooser; |
86 |
|
import org.jsampler.view.std.StdMainFrame; |
87 |
|
import org.jsampler.view.std.StdUtils; |
88 |
|
|
89 |
import static org.jsampler.view.fantasia.A4n.a4n; |
import static org.jsampler.view.fantasia.A4n.a4n; |
90 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
96 |
* |
* |
97 |
* @author Grigor Iliev |
* @author Grigor Iliev |
98 |
*/ |
*/ |
99 |
public class MainFrame extends JSMainFrame { |
public class MainFrame extends StdMainFrame { |
100 |
|
public final static int MAX_CHANNEL_LANE_NUMBER = 8; |
101 |
|
|
102 |
private final StandardBar standardBar = new StandardBar(); |
private final StandardBar standardBar = new StandardBar(); |
103 |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
104 |
private final JPanel rootPane = new JPanel(); |
private final JPanel rootPane = new RootPane(); |
105 |
private final MainPane mainPane = new MainPane(); |
private final BottomPane bottomPane; |
106 |
private final DevicesPane devicesPane = new DevicesPane(); |
private final MainPane mainPane; |
107 |
private final JScrollPane spDevicesPane = new JScrollPane(); |
private final PianoKeyboardPane pianoKeyboardPane; |
108 |
|
|
109 |
private final JMenu recentScriptsMenu = |
private final JMenu recentScriptsMenu = |
110 |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
111 |
|
|
112 |
private final JSplitPane hSplitPane; |
private final JSplitPane hSplitPane; |
113 |
|
|
114 |
private final SidePane sidePane = new SidePane(); |
private final LeftSidePane leftSidePane; |
115 |
|
private final RightSidePane rightSidePane; |
116 |
private final JPanel rightPane; |
private final JPanel rightPane; |
117 |
|
|
118 |
|
//private final StatusBar statusBar = new StatusBar(); |
119 |
|
|
120 |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
121 |
private final Vector<String> recentScripts = new Vector<String>(); |
private final Vector<String> recentScripts = new Vector<String>(); |
122 |
|
|
123 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
124 |
|
|
125 |
|
|
126 |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
127 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
128 |
|
|
129 |
private final JCheckBoxMenuItem cbmiSidePaneVisible = |
private final JCheckBoxMenuItem cbmiLeftSidePaneVisible = |
130 |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane")); |
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane")); |
131 |
|
|
132 |
|
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
133 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
134 |
|
|
135 |
|
private final JCheckBoxMenuItem cbmiMidiKeyboardVisible = |
136 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard")); |
137 |
|
|
138 |
private final JCheckBoxMenuItem cbmiDevicesPaneVisible = |
private final Timer guiTimer = new Timer(1000, null); |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane")); |
|
139 |
|
|
140 |
/** Creates a new instance of <code>MainFrame</code> */ |
/** Creates a new instance of <code>MainFrame</code> */ |
141 |
public |
public |
142 |
MainFrame() { |
MainFrame() { |
143 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
144 |
|
//setUndecorated(true); |
145 |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
146 |
|
|
147 |
|
CC.setMainFrame(this); // TODO: |
148 |
|
mainPane = new MainPane(); |
149 |
|
leftSidePane = new LeftSidePane(); |
150 |
|
rightSidePane = new RightSidePane(); |
151 |
|
|
152 |
|
setSelectedChannelsPane(mainPane.getChannelsPane(0)); |
153 |
|
|
154 |
getContentPane().add(standardBar, BorderLayout.NORTH); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
155 |
|
|
156 |
rightPane = createRightPane(); |
rightPane = createRightPane(); |
158 |
hSplitPane = new JSplitPane ( |
hSplitPane = new JSplitPane ( |
159 |
JSplitPane.HORIZONTAL_SPLIT, |
JSplitPane.HORIZONTAL_SPLIT, |
160 |
true, // continuousLayout |
true, // continuousLayout |
161 |
sidePane, rightPane |
leftSidePane, rightPane |
162 |
); |
); |
163 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
164 |
|
|
165 |
rootPane.setLayout(new BorderLayout()); |
pianoKeyboardPane = new PianoKeyboardPane(); |
166 |
rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0)); |
|
167 |
rootPane.setOpaque(false); |
for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) { |
168 |
|
addChannelsPane(mainPane.getChannelsPane(i)); |
169 |
|
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
170 |
|
} |
171 |
|
|
172 |
|
PropertyChangeListener l = new PropertyChangeListener() { |
173 |
|
public void |
174 |
|
propertyChange(PropertyChangeEvent e) { |
175 |
|
onChangeChannelLaneCount(); |
176 |
|
} |
177 |
|
}; |
178 |
|
|
179 |
|
preferences().addPropertyChangeListener("channelLanes.count", l); |
180 |
|
|
181 |
|
int h = preferences().getIntProperty("midiKeyboard.height"); |
182 |
|
setMidiKeyboardHeight(h); |
183 |
|
|
184 |
|
l = new PropertyChangeListener() { |
185 |
|
public void |
186 |
|
propertyChange(PropertyChangeEvent e) { |
187 |
|
int h = preferences().getIntProperty("midiKeyboard.height"); |
188 |
|
setMidiKeyboardHeight(h); |
189 |
|
} |
190 |
|
}; |
191 |
|
|
192 |
|
CC.preferences().addPropertyChangeListener("midiKeyboard.height", l); |
193 |
|
|
194 |
|
bottomPane = new BottomPane(); |
195 |
|
|
196 |
|
hSplitPane.setOpaque(false); |
197 |
rootPane.add(hSplitPane); |
rootPane.add(hSplitPane); |
198 |
|
rootPane.add(bottomPane, BorderLayout.SOUTH); |
199 |
|
add(rootPane); |
200 |
|
|
201 |
|
if(CC.isMacOS()) { |
202 |
|
try { |
203 |
|
String s = "org.jsampler.view.fantasia.MacOSApplicationHandler"; |
204 |
|
Class.forName(s).newInstance(); } |
205 |
|
catch(Throwable e) { } |
206 |
|
} |
207 |
|
|
208 |
addMenu(); |
addMenu(); |
209 |
|
|
210 |
addChannelsPane(mainPane.getChannelsPane()); |
if(CC.getViewConfig().isUsingScreenMenuBar()) { |
211 |
|
// fix for moving the menu bar on top of the screen |
212 |
getContentPane().add(rootPane); |
// when running on Mac OS and third party plugin is used |
213 |
|
((ViewConfig)CC.getViewConfig()).restoreMenuProperties(); |
214 |
|
} |
215 |
|
|
216 |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
217 |
hSplitPane.setDividerLocation(i); |
hSplitPane.setDividerLocation(i); |
218 |
|
|
219 |
setSavedSize(); |
setSavedSize(); |
220 |
|
|
221 |
|
guiTimer.start(); |
222 |
} |
} |
223 |
|
|
224 |
private JPanel |
private JPanel |
225 |
createRightPane() { |
createRightPane() { |
226 |
JPanel p = new JPanel(); |
JPanel p = new FantasiaPanel(); |
227 |
|
p.setOpaque(false); |
228 |
|
|
229 |
GridBagLayout gridbag = new GridBagLayout(); |
GridBagLayout gridbag = new GridBagLayout(); |
230 |
GridBagConstraints c = new GridBagConstraints(); |
GridBagConstraints c = new GridBagConstraints(); |
231 |
|
|
233 |
|
|
234 |
c.fill = GridBagConstraints.BOTH; |
c.fill = GridBagConstraints.BOTH; |
235 |
|
|
|
spDevicesPane.setViewportView(devicesPane); |
|
|
spDevicesPane.setBorder(BorderFactory.createEmptyBorder()); |
|
|
int h = spDevicesPane.getMinimumSize().height; |
|
|
spDevicesPane.setMinimumSize(new Dimension(200, h)); |
|
|
|
|
236 |
c.gridx = 1; |
c.gridx = 1; |
237 |
c.gridy = 0; |
c.gridy = 0; |
238 |
c.weightx = 1.0; |
c.weightx = 1.0; |
239 |
c.weighty = 1.0; |
c.weighty = 1.0; |
240 |
c.insets = new Insets(0, 3, 3, 0); |
c.insets = new Insets(0, 3, 0, 0); |
241 |
gridbag.setConstraints(spDevicesPane, c); |
gridbag.setConstraints(rightSidePane, c); |
242 |
p.add(spDevicesPane); |
p.add(rightSidePane); |
243 |
|
|
244 |
c.gridx = 0; |
c.gridx = 0; |
245 |
c.gridy = 0; |
c.gridy = 0; |
246 |
c.weightx = 0.0; |
c.weightx = 0.0; |
247 |
c.weighty = 1.0; |
c.weighty = 1.0; |
248 |
c.insets = new Insets(0, 3, 3, 3); |
c.insets = new Insets(0, 0, 0, 3); |
249 |
c.fill = GridBagConstraints.VERTICAL; |
c.fill = GridBagConstraints.VERTICAL; |
250 |
gridbag.setConstraints(mainPane, c); |
gridbag.setConstraints(mainPane, c); |
251 |
p.add(mainPane); |
p.add(mainPane); |
255 |
|
|
256 |
private void |
private void |
257 |
setSavedSize() { |
setSavedSize() { |
258 |
String s = preferences().getStringProperty("MainFrame.sizeAndLocation"); |
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
259 |
if(s == null) { |
if(r == null) { |
260 |
setDefaultSizeAndLocation(); |
setDefaultSizeAndLocation(); |
261 |
return; |
return; |
262 |
} |
} |
|
pack(); |
|
|
try { |
|
|
int i = s.indexOf(','); |
|
|
int x = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int y = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
i = s.indexOf(','); |
|
|
int width = Integer.parseInt(s.substring(0, i)); |
|
|
|
|
|
s = s.substring(i + 1); |
|
|
int height = Integer.parseInt(s); |
|
|
|
|
|
setBounds(x, y, width, height); |
|
|
} catch(Exception x) { |
|
|
String msg = "Parsing of window size and location string failed"; |
|
|
CC.getLogger().log(Level.INFO, msg, x); |
|
|
setDefaultSizeAndLocation(); |
|
|
} |
|
263 |
|
|
264 |
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
setBounds(r); |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
|
|
} |
|
265 |
} |
} |
266 |
|
|
267 |
private void |
private void |
273 |
|
|
274 |
|
|
275 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
276 |
protected void |
@Override |
277 |
|
public void |
278 |
onWindowClose() { |
onWindowClose() { |
279 |
if(CC.getSamplerModel().isModified()) { |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
280 |
|
if(b && CC.getSamplerModel().isModified()) { |
281 |
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
282 |
dlg.setVisible(true); |
dlg.setVisible(true); |
283 |
if(dlg.isCancelled()) return; |
if(dlg.isCancelled()) return; |
284 |
} |
} |
285 |
|
|
286 |
sidePane.savePreferences(); |
leftSidePane.savePreferences(); |
287 |
|
rightSidePane.savePreferences(); |
288 |
|
|
289 |
int i = hSplitPane.getDividerLocation(); |
int i = hSplitPane.getDividerLocation(); |
290 |
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
299 |
return; |
return; |
300 |
} |
} |
301 |
|
|
302 |
java.awt.Point p = getLocation(); |
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
|
Dimension d = getSize(); |
|
|
StringBuffer sb = new StringBuffer(); |
|
|
sb.append(p.x).append(',').append(p.y).append(','); |
|
|
sb.append(d.width).append(',').append(d.height); |
|
|
preferences().setStringProperty("MainFrame.sizeAndLocation", sb.toString()); |
|
303 |
|
|
304 |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
305 |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
308 |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
309 |
} |
} |
310 |
|
|
311 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
312 |
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
313 |
|
|
314 |
super.onWindowClose(); |
super.onWindowClose(); |
315 |
} |
} |
316 |
|
|
317 |
|
private void |
318 |
|
onChangeChannelLaneCount() { |
319 |
|
int newCount = preferences().getIntProperty("channelLanes.count"); |
320 |
|
if(newCount < 1 || newCount > MAX_CHANNEL_LANE_NUMBER) return; |
321 |
|
if(newCount == getChannelsPaneCount()) return; |
322 |
|
int current = getChannelsPaneIndex(getSelectedChannelsPane()); |
323 |
|
|
324 |
|
if(newCount > getChannelsPaneCount()) { |
325 |
|
int d = newCount - getChannelsPaneCount(); |
326 |
|
for(int i = 0; i < d; i++) { |
327 |
|
JSChannelsPane p = mainPane.addChannelsPane(); |
328 |
|
addChannelsPane(p); |
329 |
|
p.addListSelectionListener(pianoKeyboardPane); |
330 |
|
} |
331 |
|
} else { |
332 |
|
int d = getChannelsPaneCount() - newCount; |
333 |
|
for(int i = 0; i < d; i++) { |
334 |
|
int idx = getChannelsPaneCount() - 1 - i; |
335 |
|
if(getChannelsPane(idx).getChannelCount() > 0) { |
336 |
|
String s; |
337 |
|
s = i18n.getError("MainFrame.notEmptyChannelLane!", idx + 1); |
338 |
|
HF.showErrorMessage(s); |
339 |
|
return; |
340 |
|
} |
341 |
|
} |
342 |
|
|
343 |
|
for(int i = 0; i < d; i++) { |
344 |
|
int idx = getChannelsPaneCount() - 1; |
345 |
|
JSChannelsPane p = getChannelsPane(idx); |
346 |
|
removeChannelsPane(p); |
347 |
|
p.removeListSelectionListener(pianoKeyboardPane); |
348 |
|
mainPane.removeChannelsPane(idx); |
349 |
|
} |
350 |
|
} |
351 |
|
|
352 |
|
if(newCount == 1) { |
353 |
|
mainPane.getButtonsPanel().setVisible(false); |
354 |
|
} else if(!mainPane.getButtonsPanel().isVisible()) { |
355 |
|
mainPane.getButtonsPanel().setVisible(true); |
356 |
|
} |
357 |
|
mainPane.getButtonsPanel().setButtonNumber(newCount); |
358 |
|
if(current < 0 || current >= getChannelsPaneCount()) current = 0; |
359 |
|
setSelectedChannelsPane(getChannelsPane(current)); |
360 |
|
} |
361 |
|
|
362 |
|
@Override |
363 |
|
public void |
364 |
|
setVisible(boolean b) { |
365 |
|
if(b == isVisible()) return; |
366 |
|
|
367 |
|
super.setVisible(b); |
368 |
|
|
369 |
|
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
370 |
|
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
371 |
|
} |
372 |
|
} |
373 |
|
|
374 |
private void |
private void |
375 |
addMenu() { |
addMenu() { |
381 |
// Actions |
// Actions |
382 |
m = new FantasiaMenu(i18n.getMenuLabel("actions")); |
m = new FantasiaMenu(i18n.getMenuLabel("actions")); |
383 |
|
|
384 |
mi = new JMenuItem(a4n.connect); |
mi = new JMenuItem(a4n.refresh); |
385 |
mi.setIcon(null); |
mi.setIcon(null); |
386 |
//mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
387 |
m.add(mi); |
m.add(mi); |
388 |
|
|
389 |
mi = new JMenuItem(a4n.samplerInfo); |
mi = new JMenuItem(a4n.samplerInfo); |
390 |
mi.setIcon(null); |
mi.setIcon(null); |
391 |
m.add(mi); |
m.add(mi); |
392 |
|
|
393 |
|
mi = new JMenuItem(a4n.resetSampler); |
394 |
|
mi.setIcon(null); |
395 |
|
m.add(mi); |
396 |
|
|
397 |
m.addSeparator(); |
m.addSeparator(); |
398 |
|
|
399 |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
400 |
m.add(exportMenu); |
m.add(exportMenu); |
401 |
|
|
402 |
|
int modKey = CC.getViewConfig().getDefaultModKey(); |
403 |
|
|
404 |
mi = new JMenuItem(a4n.exportSamplerConfig); |
mi = new JMenuItem(a4n.exportSamplerConfig); |
405 |
mi.setIcon(null); |
mi.setIcon(null); |
406 |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, modKey)); |
407 |
exportMenu.add(mi); |
exportMenu.add(mi); |
408 |
|
|
409 |
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
414 |
|
|
415 |
mi = new JMenuItem(a4n.loadScript); |
mi = new JMenuItem(a4n.loadScript); |
416 |
mi.setIcon(null); |
mi.setIcon(null); |
417 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, modKey)); |
418 |
m.add(mi); |
m.add(mi); |
419 |
|
|
420 |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
426 |
|
|
427 |
m.addSeparator(); |
m.addSeparator(); |
428 |
|
|
429 |
|
mi = new JMenuItem(a4n.changeBackend); |
430 |
|
mi.setIcon(null); |
431 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, modKey)); |
432 |
|
m.add(mi); |
433 |
|
|
434 |
|
m.addSeparator(); |
435 |
|
|
436 |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
437 |
m.add(mi); |
m.add(mi); |
438 |
mi.addActionListener(new ActionListener() { |
mi.addActionListener(new ActionListener() { |
471 |
mi = new JMenuItem(a4n.editPreferences); |
mi = new JMenuItem(a4n.editPreferences); |
472 |
mi.setIcon(null); |
mi.setIcon(null); |
473 |
mi.setAccelerator(KeyStroke.getKeyStroke ( |
mi.setAccelerator(KeyStroke.getKeyStroke ( |
474 |
KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_P, modKey | KeyEvent.SHIFT_MASK |
475 |
)); |
)); |
476 |
m.add(mi); |
m.add(mi); |
477 |
|
|
492 |
cbmiToolBarVisible.setSelected(b); |
cbmiToolBarVisible.setSelected(b); |
493 |
showToolBar(b); |
showToolBar(b); |
494 |
|
|
495 |
cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
496 |
KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_L, modKey | KeyEvent.SHIFT_MASK |
497 |
)); |
)); |
498 |
m.add(cbmiSidePaneVisible); |
m.add(cbmiLeftSidePaneVisible); |
499 |
|
|
500 |
cbmiSidePaneVisible.addActionListener(new ActionListener() { |
cbmiLeftSidePaneVisible.addActionListener(new ActionListener() { |
501 |
public void |
public void |
502 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
503 |
showSidePane(cbmiSidePaneVisible.getState()); |
showSidePane(cbmiLeftSidePaneVisible.getState()); |
504 |
} |
} |
505 |
}); |
}); |
506 |
|
|
507 |
b = preferences().getBoolProperty("sidePane.visible"); |
b = preferences().getBoolProperty("leftSidePane.visible"); |
508 |
cbmiSidePaneVisible.setSelected(b); |
cbmiLeftSidePaneVisible.setSelected(b); |
509 |
showSidePane(b); |
showSidePane(b); |
510 |
|
|
511 |
cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
512 |
KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
KeyEvent.VK_R, modKey | KeyEvent.SHIFT_MASK |
513 |
)); |
)); |
514 |
m.add(cbmiDevicesPaneVisible); |
m.add(cbmiRightSidePaneVisible); |
515 |
|
|
516 |
cbmiDevicesPaneVisible.addActionListener(new ActionListener() { |
cbmiRightSidePaneVisible.addActionListener(new ActionListener() { |
517 |
public void |
public void |
518 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
519 |
showDevicesPane(cbmiDevicesPaneVisible.getState()); |
showDevicesPane(cbmiRightSidePaneVisible.getState()); |
520 |
} |
} |
521 |
}); |
}); |
522 |
|
|
523 |
b = preferences().getBoolProperty("devicesPane.visible"); |
b = preferences().getBoolProperty("rightSidePane.visible"); |
524 |
cbmiDevicesPaneVisible.setSelected(b); |
cbmiRightSidePaneVisible.setSelected(b); |
525 |
showDevicesPane(b); |
showDevicesPane(b); |
526 |
|
|
527 |
|
m.addSeparator(); |
528 |
|
|
529 |
|
m.add(cbmiMidiKeyboardVisible); |
530 |
|
|
531 |
|
cbmiMidiKeyboardVisible.addActionListener(new ActionListener() { |
532 |
|
public void |
533 |
|
actionPerformed(ActionEvent e) { |
534 |
|
setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState()); |
535 |
|
} |
536 |
|
}); |
537 |
|
|
538 |
|
b = preferences().getBoolProperty("midiKeyboard.visible"); |
539 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
540 |
|
setMidiKeyboardVisible(b); |
541 |
|
|
542 |
|
|
543 |
|
// Channels |
544 |
|
m = new FantasiaMenu(i18n.getMenuLabel("channels")); |
545 |
|
|
546 |
|
mi = new JMenuItem(i18n.getMenuLabel("channels.newChannel")); |
547 |
|
mi.addActionListener(new ActionListener() { |
548 |
|
public void |
549 |
|
actionPerformed(ActionEvent e) { |
550 |
|
CC.getSamplerModel().addBackendChannel(); |
551 |
|
} |
552 |
|
}); |
553 |
|
m.add(mi); |
554 |
|
|
555 |
|
m.addSeparator(); |
556 |
|
|
557 |
|
MenuManager.ChannelViewGroup group = new MenuManager.ChannelViewGroup(); |
558 |
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
559 |
|
|
560 |
|
for(JMenuItem menuItem : group.getMenuItems()) m.add(menuItem); |
561 |
|
|
562 |
|
m.addSeparator(); |
563 |
|
|
564 |
|
m.add(new JMenuItem(a4n.moveChannelsOnTop)); |
565 |
|
m.add(new JMenuItem(a4n.moveChannelsUp)); |
566 |
|
m.add(new JMenuItem(a4n.moveChannelsDown)); |
567 |
|
m.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
568 |
|
|
569 |
|
m.add(new ToPanelMenu()); |
570 |
|
|
571 |
|
m.addSeparator(); |
572 |
|
|
573 |
|
mi = new JMenuItem(a4n.selectAllChannels); |
574 |
|
mi.setIcon(null); |
575 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, modKey)); |
576 |
|
m.add(mi); |
577 |
|
|
578 |
|
mi = new JMenuItem(a4n.deselectChannels); |
579 |
|
mi.setIcon(null); |
580 |
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
581 |
|
KeyEvent.VK_A, modKey | KeyEvent.SHIFT_MASK |
582 |
|
)); |
583 |
|
m.add(mi); |
584 |
|
|
585 |
|
menuBar.add(m); |
586 |
|
|
587 |
// Window |
// Window |
588 |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
596 |
mi.setIcon(null); |
mi.setIcon(null); |
597 |
m.add(mi); |
m.add(mi); |
598 |
|
|
599 |
|
m.addSeparator(); |
600 |
|
|
601 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
602 |
|
m.add(mi2); |
603 |
|
mi2.addActionListener(new ActionListener() { |
604 |
|
public void |
605 |
|
actionPerformed(ActionEvent e) { |
606 |
|
if(getBackendLogFrame().isVisible()) { |
607 |
|
getBackendLogFrame().setVisible(false); |
608 |
|
} |
609 |
|
|
610 |
|
getBackendLogFrame().setVisible(true); |
611 |
|
} |
612 |
|
}); |
613 |
|
|
614 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
615 |
|
|
616 |
|
CC.addBackendProcessListener(new ActionListener() { |
617 |
|
public void |
618 |
|
actionPerformed(ActionEvent e) { |
619 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
620 |
|
} |
621 |
|
}); |
622 |
|
|
623 |
|
|
624 |
// Help |
// Help |
625 |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
637 |
menuBar.add(m); |
menuBar.add(m); |
638 |
} |
} |
639 |
|
|
640 |
|
public static class ToPanelMenu extends FantasiaMenu implements ListSelectionListener { |
641 |
|
public |
642 |
|
ToPanelMenu() { |
643 |
|
super(i18n.getMenuLabel("channels.toPanel")); |
644 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
645 |
|
|
646 |
|
CC.getMainFrame().addChannelsPaneSelectionListener(this); |
647 |
|
|
648 |
|
for(int i = 0; i < CC.getMainFrame().getChannelsPaneCount(); i++) { |
649 |
|
JSChannelsPane p = CC.getMainFrame().getChannelsPane(i); |
650 |
|
add(new JMenuItem(new A4n.MoveChannelsToPanel(p))); |
651 |
|
p.addListSelectionListener(this); |
652 |
|
} |
653 |
|
} |
654 |
|
|
655 |
|
@Override |
656 |
|
public void |
657 |
|
valueChanged(ListSelectionEvent e) { |
658 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
659 |
|
} |
660 |
|
} |
661 |
|
|
662 |
|
public RightSidePane |
663 |
|
getRightSidePane() { return rightSidePane; } |
664 |
|
|
665 |
|
@Override |
666 |
|
public A4n |
667 |
|
getA4n() { return A4n.a4n; } |
668 |
|
|
669 |
/** |
/** |
670 |
* This method does nothing, because <b>Fantasia</b> has exactly |
* This method does nothing, because <b>Fantasia</b> has constant |
671 |
* one pane containing sampler channels, which can not be changed. |
* number of panes containing sampler channels, which can not be changed. |
672 |
*/ |
*/ |
673 |
|
@Override |
674 |
public void |
public void |
675 |
insertChannelsPane(JSChannelsPane pane, int idx) { |
insertChannelsPane(JSChannelsPane pane, int idx) { |
676 |
|
|
677 |
} |
} |
678 |
|
|
679 |
/** |
@Override |
|
* This method always returns the <code>JSChannelsPane</code> at index 0, |
|
|
* because the <b>Fantasia</b> view has exactly one pane containing sampler channels. |
|
|
* @return The <code>JSChannelsPane</code> at index 0. |
|
|
*/ |
|
680 |
public JSChannelsPane |
public JSChannelsPane |
681 |
getSelectedChannelsPane() { return getChannelsPane(0); } |
getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); } |
682 |
|
|
683 |
/** |
@Override |
|
* This method does nothing because the <b>Fantasia</b> view has |
|
|
* exactly one pane containing sampler channels which is always shown. |
|
|
*/ |
|
684 |
public void |
public void |
685 |
setSelectedChannelsPane(JSChannelsPane pane) { } |
setSelectedChannelsPane(JSChannelsPane pane) { |
686 |
|
mainPane.setSelectedChannelsPane(pane); |
687 |
|
fireChannelsPaneSelectionChanged(); |
688 |
|
} |
689 |
|
|
690 |
|
@Override |
691 |
public void |
public void |
692 |
installJSamplerHome() { |
installJSamplerHome() { |
693 |
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
694 |
chooser.setVisible(true); |
chooser.setVisible(true); |
695 |
if(chooser.isCancelled()) return; |
if(chooser.isCancelled()) return; |
696 |
|
|
697 |
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
JSUtils.changeJSamplerHome(chooser.getJSamplerHome()); |
698 |
} |
} |
699 |
|
|
700 |
|
@Override |
701 |
public void |
public void |
702 |
showDetailedErrorMessage(Frame owner, String err, String details) { |
showDetailedErrorMessage(Frame owner, String err, String details) { |
703 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
706 |
dlg.setVisible(true); |
dlg.setVisible(true); |
707 |
} |
} |
708 |
|
|
709 |
|
@Override |
710 |
public void |
public void |
711 |
showDetailedErrorMessage(Dialog owner, String err, String details) { |
showDetailedErrorMessage(Dialog owner, String err, String details) { |
712 |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
715 |
dlg.setVisible(true); |
dlg.setVisible(true); |
716 |
} |
} |
717 |
|
|
718 |
protected LSConsoleModel |
/** |
719 |
|
* Gets the server address to which to connect. If the server should be |
720 |
|
* manually selected, a dialog asking the user to choose a server is displayed. |
721 |
|
*/ |
722 |
|
@Override |
723 |
|
public Server |
724 |
|
getServer() { |
725 |
|
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
726 |
|
return getServer(b); |
727 |
|
} |
728 |
|
|
729 |
|
/** |
730 |
|
* Gets the server address to which to connect. If the server should be |
731 |
|
* manually selected, a dialog asking the user to choose a server is displayed. |
732 |
|
* @param manualSelect Determines whether the server should be manually selected. |
733 |
|
*/ |
734 |
|
@Override |
735 |
|
public Server |
736 |
|
getServer(boolean manualSelect) { |
737 |
|
if(manualSelect) { |
738 |
|
JSConnectDlg dlg = new JSConnectDlg(); |
739 |
|
dlg.setVisible(true); |
740 |
|
|
741 |
|
return dlg.getSelectedServer(); |
742 |
|
} |
743 |
|
|
744 |
|
int i = preferences().getIntProperty(SERVER_INDEX); |
745 |
|
int size = CC.getServerList().getServerCount(); |
746 |
|
if(size == 0) return null; |
747 |
|
if(i >= size) return CC.getServerList().getServer(0); |
748 |
|
|
749 |
|
return CC.getServerList().getServer(i); |
750 |
|
} |
751 |
|
|
752 |
|
public Timer |
753 |
|
getGuiTimer() { return guiTimer; } |
754 |
|
|
755 |
|
@Override |
756 |
|
public LSConsoleModel |
757 |
getLSConsoleModel() { return getLSConsolePane().getModel(); } |
getLSConsoleModel() { return getLSConsolePane().getModel(); } |
758 |
|
|
759 |
protected LSConsolePane |
protected LSConsolePane |
764 |
protected LSConsoleFrame |
protected LSConsoleFrame |
765 |
getLSConsoleFrame() { return lsConsoleFrame; } |
getLSConsoleFrame() { return lsConsoleFrame; } |
766 |
|
|
767 |
protected void |
public JSBackendLogFrame |
768 |
|
getBackendLogFrame() { return backendLogFrame; } |
769 |
|
|
770 |
|
protected boolean |
771 |
runScript() { |
runScript() { |
772 |
String s = preferences().getStringProperty("lastScriptLocation"); |
File f = StdUtils.showOpenLscpFileChooser(); |
773 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return false; |
774 |
fc.setFileFilter(new LscpFileFilter()); |
runScript(f); |
775 |
int result = fc.showOpenDialog(this); |
|
776 |
if(result != JFileChooser.APPROVE_OPTION) return; |
return true; |
|
|
|
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastScriptLocation", path); |
|
|
|
|
|
runScript(fc.getSelectedFile()); |
|
777 |
} |
} |
778 |
|
|
779 |
private void |
@Override |
780 |
|
public void |
781 |
runScript(String script) { runScript(new File(script)); } |
runScript(String script) { runScript(new File(script)); } |
782 |
|
|
783 |
private void |
private void |
785 |
FileReader fr; |
FileReader fr; |
786 |
try { fr = new FileReader(script); } |
try { fr = new FileReader(script); } |
787 |
catch(FileNotFoundException e) { |
catch(FileNotFoundException e) { |
788 |
HF.showErrorMessage(i18n.getMessage("FileNotFound!")); |
HF.showErrorMessage(i18n.getError("fileNotFound!")); |
789 |
return; |
return; |
790 |
} |
} |
791 |
|
|
792 |
|
String prefix = "#jsampler.fantasia: "; |
793 |
|
Vector<String> v = new Vector<String>(); |
794 |
BufferedReader br = new BufferedReader(fr); |
BufferedReader br = new BufferedReader(fr); |
795 |
|
|
796 |
try { |
try { |
798 |
while(s != null) { |
while(s != null) { |
799 |
getLSConsoleModel().setCommandLineText(s); |
getLSConsoleModel().setCommandLineText(s); |
800 |
getLSConsoleModel().execCommand(); |
getLSConsoleModel().execCommand(); |
801 |
|
if(s.startsWith(prefix)) v.add(s.substring(prefix.length())); |
802 |
s = br.readLine(); |
s = br.readLine(); |
803 |
} |
} |
804 |
} catch(Exception e) { |
} catch(Exception e) { |
811 |
recentScripts.insertElementAt(s, 0); |
recentScripts.insertElementAt(s, 0); |
812 |
|
|
813 |
updateRecentScriptsMenu(); |
updateRecentScriptsMenu(); |
814 |
|
|
815 |
|
CC.getViewConfig().setSessionViewConfig( |
816 |
|
new SessionViewConfig(v.toArray(new String[v.size()])) |
817 |
|
); |
818 |
} |
} |
819 |
|
|
820 |
protected void |
protected void |
849 |
|
|
850 |
private void |
private void |
851 |
showSidePane(boolean b) { |
showSidePane(boolean b) { |
852 |
preferences().setBoolProperty("sidePane.visible", b); |
preferences().setBoolProperty("leftSidePane.visible", b); |
853 |
rootPane.remove(rightPane); |
rootPane.remove(rightPane); |
854 |
rootPane.remove(hSplitPane); |
rootPane.remove(hSplitPane); |
855 |
|
|
881 |
|
|
882 |
private void |
private void |
883 |
showDevicesPane(boolean b) { |
showDevicesPane(boolean b) { |
884 |
preferences().setBoolProperty("devicesPane.visible", b); |
preferences().setBoolProperty("rightSidePane.visible", b); |
885 |
|
|
886 |
int width = sidePane.getWidth(); |
int width = leftSidePane.getWidth(); |
887 |
int height = sidePane.getPreferredSize().height; |
int height = leftSidePane.getPreferredSize().height; |
888 |
if(width != 0) sidePane.setPreferredSize(new Dimension(width, height)); |
if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height)); |
889 |
|
|
890 |
if(b) { |
if(b) { |
891 |
int w = preferences().getIntProperty("devicesPane.width", 200); |
int w = preferences().getIntProperty("devicesPane.width", 200); |
892 |
|
|
893 |
int h = spDevicesPane.getPreferredSize().height; |
int h = rightSidePane.getPreferredSize().height; |
894 |
spDevicesPane.setPreferredSize(new Dimension(w, h)); |
rightSidePane.setPreferredSize(new Dimension(w, h)); |
895 |
} else { |
} else { |
896 |
int w = spDevicesPane.getWidth(); |
int w = rightSidePane.getWidth(); |
897 |
if(w > 0 && w < 200) w = 200; |
if(w > 0 && w < 200) w = 200; |
898 |
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
899 |
} |
} |
900 |
|
|
901 |
hSplitPane.setResizeWeight(0.0); |
hSplitPane.setResizeWeight(0.0); |
902 |
spDevicesPane.setVisible(b); |
rightSidePane.setVisible(b); |
903 |
hSplitPane.resetToPreferredSizes(); |
hSplitPane.resetToPreferredSizes(); |
904 |
|
|
905 |
int w = getPreferredSize().width; |
int w = getPreferredSize().width; |
916 |
}); |
}); |
917 |
} |
} |
918 |
|
|
919 |
|
public void |
920 |
|
setMidiKeyboardVisible(boolean b) { |
921 |
|
preferences().setBoolProperty("midiKeyboard.visible", b); |
922 |
|
pianoKeyboardPane.setVisible(b); |
923 |
|
|
924 |
|
if(cbmiMidiKeyboardVisible.isSelected() != b) { |
925 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
926 |
|
} |
927 |
|
|
928 |
|
if(standardBar.btnMidiKeyboard.isSelected() != b) { |
929 |
|
standardBar.btnMidiKeyboard.setSelected(b); |
930 |
|
} |
931 |
|
|
932 |
|
if(pianoKeyboardPane.btnPower.isSelected() != b) { |
933 |
|
pianoKeyboardPane.btnPower.setSelected(b); |
934 |
|
} |
935 |
|
|
936 |
|
rootPane.validate(); |
937 |
|
rootPane.repaint(); |
938 |
|
} |
939 |
|
|
940 |
|
public void |
941 |
|
setMidiKeyboardHeight(int height) { |
942 |
|
Dimension d = pianoKeyboardPane.getPreferredSize(); |
943 |
|
d = new Dimension(d.width, height); |
944 |
|
pianoKeyboardPane.setPreferredSize(d); |
945 |
|
pianoKeyboardPane.setMinimumSize(d); |
946 |
|
pianoKeyboardPane.revalidate(); |
947 |
|
pianoKeyboardPane.repaint(); |
948 |
|
} |
949 |
|
|
950 |
private void |
private void |
951 |
sidePanesVisibilityChanged() { |
sidePanesVisibilityChanged() { |
952 |
boolean sidePaneVisible = cbmiSidePaneVisible.isSelected(); |
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
953 |
boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected(); |
boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected(); |
954 |
|
|
955 |
if(sidePaneVisible && devicesPaneVisible) { |
if(leftSidePaneVisible && rightSidePaneVisible) { |
956 |
hSplitPane.setResizeWeight(0.5); |
hSplitPane.setResizeWeight(0.5); |
957 |
} else if(sidePaneVisible && !devicesPaneVisible) { |
} else if(leftSidePaneVisible && !rightSidePaneVisible) { |
958 |
hSplitPane.setResizeWeight(1.0); |
hSplitPane.setResizeWeight(1.0); |
959 |
} |
} |
960 |
|
|
961 |
if(!sidePaneVisible && !devicesPaneVisible) { |
if(!leftSidePaneVisible && !rightSidePaneVisible) { |
962 |
standardBar.showFantasiaLogo(false); |
standardBar.showFantasiaLogo(false); |
963 |
if(isResizable()) setResizable(false); |
if(isResizable()) setResizable(false); |
964 |
} else { |
} else { |
972 |
|
|
973 |
RecentScriptHandler(String script) { this.script = script; } |
RecentScriptHandler(String script) { this.script = script; } |
974 |
|
|
975 |
|
@Override |
976 |
public void |
public void |
977 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
978 |
runScript(script); |
runScript(script); |
987 |
super(s); |
super(s); |
988 |
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
989 |
setOpaque(false); |
setOpaque(false); |
990 |
|
setContentAreaFilled(false); |
991 |
} |
} |
992 |
} |
} |
993 |
|
|
994 |
private class FantasiaMenuBar extends JMenuBar { |
private class FantasiaMenuBar extends JMenuBar { |
|
private Insets pixmapInsets = new Insets(6, 6, 0, 6); |
|
|
private Insets pixmapInsets2 = new Insets(6, 6, 6, 6); |
|
|
|
|
995 |
FantasiaMenuBar() { |
FantasiaMenuBar() { |
996 |
setOpaque(false); |
setOpaque(false); |
997 |
|
setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0)); |
998 |
} |
} |
999 |
|
|
1000 |
|
@Override |
1001 |
protected void |
protected void |
1002 |
paintComponent(Graphics g) { |
paintComponent(Graphics g) { |
1003 |
super.paintComponent(g); |
//super.paintComponent(g); |
1004 |
|
Graphics2D g2 = (Graphics2D)g; |
1005 |
|
|
1006 |
|
Paint oldPaint = g2.getPaint(); |
1007 |
|
Composite oldComposite = g2.getComposite(); |
1008 |
|
|
1009 |
|
double h = getSize().getHeight(); |
1010 |
|
double w = getSize().getWidth(); |
1011 |
|
|
1012 |
|
FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5); |
1013 |
|
|
1014 |
|
FantasiaPainter.Border b; |
1015 |
|
|
1016 |
|
|
1017 |
if(standardBar.isVisible()) { |
if(standardBar.isVisible()) { |
1018 |
PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets); |
b = new FantasiaPainter.Border(true, true, false, true); |
1019 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b); |
1020 |
} else { |
} else { |
1021 |
PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2); |
b = new FantasiaPainter.Border(true, true, true, true); |
1022 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b); |
1023 |
} |
} |
1024 |
|
|
1025 |
|
g2.setPaint(oldPaint); |
1026 |
|
g2.setComposite(oldComposite); |
1027 |
|
} |
1028 |
|
} |
1029 |
|
|
1030 |
|
class RootPane extends FantasiaSubPanel { |
1031 |
|
private final Color color1 = new Color(0x454545); |
1032 |
|
private final Color color2 = new Color(0x2e2e2e); |
1033 |
|
|
1034 |
|
RootPane() { |
1035 |
|
setLayout(new BorderLayout()); |
1036 |
|
setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10)); |
1037 |
|
setOpaque(false); |
1038 |
|
|
1039 |
|
} |
1040 |
|
|
1041 |
|
@Override |
1042 |
|
public void |
1043 |
|
paintComponent(Graphics g) { |
1044 |
|
Graphics2D g2 = (Graphics2D)g; |
1045 |
|
|
1046 |
|
Paint oldPaint = g2.getPaint(); |
1047 |
|
Composite oldComposite = g2.getComposite(); |
1048 |
|
|
1049 |
|
double h = getSize().getHeight(); |
1050 |
|
double w = getSize().getWidth(); |
1051 |
|
|
1052 |
|
FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false); |
1053 |
|
paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2); |
1054 |
|
|
1055 |
|
g2.setPaint(oldPaint); |
1056 |
|
g2.setComposite(oldComposite); |
1057 |
|
} |
1058 |
|
} |
1059 |
|
|
1060 |
|
class BottomPane extends FantasiaPanel { |
1061 |
|
BottomPane() { |
1062 |
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
1063 |
|
setOpaque(false); |
1064 |
|
add(pianoKeyboardPane); |
1065 |
|
|
1066 |
} |
} |
1067 |
} |
} |
1068 |
} |
} |