1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2008 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; |
29 |
import java.awt.Dimension; |
import java.awt.Dimension; |
30 |
import java.awt.Point; |
import java.awt.Frame; |
31 |
|
import java.awt.Graphics; |
32 |
|
import java.awt.Graphics2D; |
33 |
|
import java.awt.GridBagConstraints; |
34 |
|
import java.awt.GridBagLayout; |
35 |
|
import java.awt.Insets; |
36 |
|
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.MouseAdapter; |
import java.awt.event.KeyEvent; |
|
import java.awt.event.MouseEvent; |
|
42 |
|
|
43 |
import java.util.logging.Level; |
import java.beans.PropertyChangeEvent; |
44 |
|
import java.beans.PropertyChangeListener; |
45 |
|
|
46 |
import javax.swing.Box; |
import java.io.BufferedReader; |
47 |
|
import java.io.File; |
48 |
|
import java.io.FileNotFoundException; |
49 |
|
import java.io.FileReader; |
50 |
|
|
51 |
|
import java.util.Vector; |
52 |
|
|
53 |
|
import javax.swing.BorderFactory; |
54 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
55 |
import javax.swing.JCheckBoxMenuItem; |
import javax.swing.JCheckBoxMenuItem; |
56 |
|
import javax.swing.JFileChooser; |
57 |
import javax.swing.JMenu; |
import javax.swing.JMenu; |
58 |
|
import javax.swing.JMenuBar; |
59 |
import javax.swing.JMenuItem; |
import javax.swing.JMenuItem; |
60 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
61 |
import javax.swing.JPopupMenu; |
import javax.swing.JSplitPane; |
62 |
import javax.swing.JToggleButton; |
import javax.swing.KeyStroke; |
63 |
import javax.swing.UIManager; |
import javax.swing.SwingUtilities; |
64 |
import javax.swing.plaf.synth.SynthLookAndFeel; |
import javax.swing.Timer; |
65 |
|
|
66 |
import net.sf.juife.TitleBar; |
import javax.swing.event.ListSelectionEvent; |
67 |
|
import javax.swing.event.ListSelectionListener; |
68 |
|
|
69 |
import org.jsampler.CC; |
import org.jsampler.CC; |
70 |
import org.jsampler.HF; |
import org.jsampler.HF; |
71 |
|
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.LscpFileFilter; |
76 |
|
import org.jsampler.view.SessionViewConfig; |
77 |
|
|
78 |
|
import org.jsampler.view.fantasia.basic.FantasiaPainter; |
79 |
|
import org.jsampler.view.fantasia.basic.FantasiaPanel; |
80 |
|
import org.jsampler.view.fantasia.basic.FantasiaSubPanel; |
81 |
|
|
82 |
|
import org.jsampler.view.std.JSBackendLogFrame; |
83 |
|
import org.jsampler.view.std.JSConnectDlg; |
84 |
|
import org.jsampler.view.std.JSDetailedErrorDlg; |
85 |
|
import org.jsampler.view.std.JSQuitDlg; |
86 |
|
import org.jsampler.view.std.JSamplerHomeChooser; |
87 |
|
import org.jsampler.view.std.StdMainFrame; |
88 |
|
import org.jsampler.view.std.StdUtils; |
89 |
|
|
90 |
|
import static org.jsampler.view.fantasia.A4n.a4n; |
91 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
92 |
|
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
93 |
|
import static org.jsampler.view.std.StdPrefs.*; |
94 |
|
|
95 |
|
|
96 |
/** |
/** |
97 |
* |
* |
98 |
* @author Grigor Iliev |
* @author Grigor Iliev |
99 |
*/ |
*/ |
100 |
public class MainFrame extends JSMainFrame { |
public class MainFrame extends StdMainFrame { |
101 |
private final static int TITLE_BAR_WIDTH = 420; |
private final StandardBar standardBar = new StandardBar(); |
102 |
private final static int TITLE_BAR_HEIGHT = 29; |
private final FantasiaMenuBar menuBar = new FantasiaMenuBar(); |
103 |
|
private final JPanel rootPane = new RootPane(); |
104 |
|
private final BottomPane bottomPane; |
105 |
|
private final MainPane mainPane; |
106 |
|
private final PianoKeyboardPane pianoKeyboardPane; |
107 |
|
|
108 |
|
private final JMenu recentScriptsMenu = |
109 |
|
new JMenu(i18n.getMenuLabel("actions.recentScripts")); |
110 |
|
|
111 |
|
private final JSplitPane hSplitPane; |
112 |
|
|
113 |
|
private final LeftSidePane leftSidePane; |
114 |
|
private final RightSidePane rightSidePane; |
115 |
|
private final JPanel rightPane; |
116 |
|
|
117 |
|
//private final StatusBar statusBar = new StatusBar(); |
118 |
|
|
119 |
|
private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame(); |
120 |
|
private final Vector<String> recentScripts = new Vector<String>(); |
121 |
|
|
122 |
|
private final JSBackendLogFrame backendLogFrame = new JSBackendLogFrame(); |
123 |
|
|
124 |
|
|
125 |
private final ChannelsPane channelsPane = new ChannelsPane(""); |
private final JCheckBoxMenuItem cbmiToolBarVisible = |
126 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar")); |
127 |
|
|
128 |
|
private final JCheckBoxMenuItem cbmiLeftSidePaneVisible = |
129 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane")); |
130 |
|
|
131 |
|
private final JCheckBoxMenuItem cbmiRightSidePaneVisible = |
132 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane")); |
133 |
|
|
134 |
|
private final JCheckBoxMenuItem cbmiMidiKeyboardVisible = |
135 |
|
new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard")); |
136 |
|
|
137 |
|
private final Timer guiTimer = new Timer(1000, null); |
138 |
|
|
139 |
/** Creates a new instance of <code>MainFrame</code> */ |
/** Creates a new instance of <code>MainFrame</code> */ |
140 |
public |
public |
141 |
MainFrame() { |
MainFrame() { |
|
try { |
|
|
SynthLookAndFeel synth = new SynthLookAndFeel(); |
|
|
synth.load(MainFrame.class.getResourceAsStream("gui.xml"), MainFrame.class); |
|
|
UIManager.setLookAndFeel(synth); |
|
|
} catch(Exception e) { |
|
|
CC.getLogger().log(Level.INFO, HF.getErrorMessage(e), e); |
|
|
} |
|
|
|
|
142 |
setTitle(i18n.getLabel("MainFrame.title")); |
setTitle(i18n.getLabel("MainFrame.title")); |
143 |
addChannelsPane(channelsPane); |
//setUndecorated(true); |
144 |
add(channelsPane); |
if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage()); |
|
setUndecorated(true); |
|
|
|
|
|
JToggleButton btn = new PixmapToggleButton(Res.iconPowerOff, Res.iconPowerOn) { |
|
|
public boolean |
|
|
contains(int x, int y) { |
|
|
return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; |
|
|
} |
|
|
}; |
|
145 |
|
|
146 |
btn.setSelected(true); |
CC.setMainFrame(this); // TODO: |
147 |
btn.setAlignmentX(JPanel.LEFT_ALIGNMENT); |
mainPane = new MainPane(); |
148 |
btn.addActionListener(new ActionListener() { |
leftSidePane = new LeftSidePane(); |
149 |
public void |
rightSidePane = new RightSidePane(); |
|
actionPerformed(ActionEvent e) { onWindowClose(); } |
|
|
}); |
|
150 |
|
|
151 |
|
setSelectedChannelsPane(mainPane.getChannelsPane(0)); |
152 |
|
|
153 |
FantasiaTitleBar tb = new FantasiaTitleBar(); |
getContentPane().add(standardBar, BorderLayout.NORTH); |
|
tb.setName("FantasiaTitleBar"); |
|
|
tb.setLayout(new BoxLayout(tb, BoxLayout.X_AXIS)); |
|
|
tb.setOpaque(true); |
|
|
tb.add(Box.createRigidArea(new Dimension(4, 0))); |
|
|
tb.add(btn); |
|
|
tb.add(Box.createRigidArea(new Dimension(3, 0))); |
|
154 |
|
|
155 |
|
rightPane = createRightPane(); |
156 |
|
|
157 |
|
hSplitPane = new JSplitPane ( |
158 |
|
JSplitPane.HORIZONTAL_SPLIT, |
159 |
|
true, // continuousLayout |
160 |
|
leftSidePane, rightPane |
161 |
|
); |
162 |
|
hSplitPane.setResizeWeight(0.5); |
163 |
|
|
164 |
tb.add(createVSeparator()); |
pianoKeyboardPane = new PianoKeyboardPane(); |
165 |
|
|
166 |
tb.add(Box.createRigidArea(new Dimension(275, 0))); |
for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) { |
167 |
|
addChannelsPane(mainPane.getChannelsPane(i)); |
168 |
|
getChannelsPane(i).addListSelectionListener(pianoKeyboardPane); |
169 |
|
} |
170 |
|
|
|
tb.add(createVSeparator()); |
|
171 |
|
|
172 |
tb.add(Box.createRigidArea(new Dimension(29, 0))); |
int h = preferences().getIntProperty("midiKeyboard.height"); |
173 |
|
setMidiKeyboardHeight(h); |
174 |
|
|
175 |
tb.add(createVSeparator()); |
PropertyChangeListener l = new PropertyChangeListener() { |
176 |
|
public void |
177 |
|
propertyChange(PropertyChangeEvent e) { |
178 |
|
int h = preferences().getIntProperty("midiKeyboard.height"); |
179 |
|
setMidiKeyboardHeight(h); |
180 |
|
} |
181 |
|
}; |
182 |
|
|
183 |
tb.add(Box.createRigidArea(new Dimension(40, 0))); |
CC.preferences().addPropertyChangeListener("midiKeyboard.height", l); |
184 |
|
|
185 |
tb.add(createVSeparator()); |
bottomPane = new BottomPane(); |
186 |
|
|
187 |
tb.setPreferredSize(new Dimension(TITLE_BAR_WIDTH, TITLE_BAR_HEIGHT)); |
hSplitPane.setOpaque(false); |
188 |
tb.setMinimumSize(tb.getPreferredSize()); |
rootPane.add(hSplitPane); |
189 |
tb.setMaximumSize(tb.getPreferredSize()); |
rootPane.add(bottomPane, BorderLayout.SOUTH); |
190 |
add(tb, BorderLayout.SOUTH); |
add(rootPane); |
191 |
|
|
192 |
getContentPane().setBackground(new java.awt.Color(0x818181)); |
addMenu(); |
|
getRootPane().setOpaque(false); |
|
|
getLayeredPane().setOpaque(false); |
|
|
//getContentPane().setVisible(false); |
|
193 |
|
|
194 |
setAlwaysOnTop(FantasiaPrefs.isAlwaysOnTop()); |
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
195 |
pack(); |
hSplitPane.setDividerLocation(i); |
196 |
|
|
197 |
String s = FantasiaPrefs.getWindowLocation(); |
setSavedSize(); |
198 |
|
|
199 |
try { |
guiTimer.start(); |
200 |
if(s == null) { |
} |
201 |
setDefaultLocation(); |
|
202 |
} else { |
private JPanel |
203 |
int i = s.indexOf(','); |
createRightPane() { |
204 |
int x = Integer.parseInt(s.substring(0, i)); |
JPanel p = new FantasiaPanel(); |
205 |
|
p.setOpaque(false); |
206 |
s = s.substring(i + 1); |
|
207 |
int y = Integer.parseInt(s); |
GridBagLayout gridbag = new GridBagLayout(); |
208 |
|
GridBagConstraints c = new GridBagConstraints(); |
209 |
setLocation(x, y); |
|
210 |
} |
p.setLayout(gridbag); |
211 |
} catch(Exception x) { |
|
212 |
String msg = "Parsing of window size and location string failed"; |
c.fill = GridBagConstraints.BOTH; |
213 |
CC.getLogger().log(Level.INFO, msg, x); |
|
214 |
setDefaultLocation(); |
c.gridx = 1; |
215 |
|
c.gridy = 0; |
216 |
|
c.weightx = 1.0; |
217 |
|
c.weighty = 1.0; |
218 |
|
c.insets = new Insets(0, 3, 0, 0); |
219 |
|
gridbag.setConstraints(rightSidePane, c); |
220 |
|
p.add(rightSidePane); |
221 |
|
|
222 |
|
c.gridx = 0; |
223 |
|
c.gridy = 0; |
224 |
|
c.weightx = 0.0; |
225 |
|
c.weighty = 1.0; |
226 |
|
c.insets = new Insets(0, 0, 0, 3); |
227 |
|
c.fill = GridBagConstraints.VERTICAL; |
228 |
|
gridbag.setConstraints(mainPane, c); |
229 |
|
p.add(mainPane); |
230 |
|
|
231 |
|
return p; |
232 |
|
} |
233 |
|
|
234 |
|
private void |
235 |
|
setSavedSize() { |
236 |
|
Rectangle r = StdUtils.getWindowBounds("MainFrame"); |
237 |
|
if(r == null) { |
238 |
|
setDefaultSizeAndLocation(); |
239 |
|
return; |
240 |
} |
} |
241 |
|
|
242 |
|
setBounds(r); |
243 |
} |
} |
244 |
|
|
245 |
private void |
private void |
246 |
setDefaultLocation() { |
setDefaultSizeAndLocation() { |
247 |
Dimension d = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); |
setPreferredSize(new Dimension(900, 600)); |
248 |
setLocation((d.width - TITLE_BAR_WIDTH) / 2, (d.height - TITLE_BAR_HEIGHT) / 2); |
pack(); |
249 |
|
setLocationRelativeTo(null); |
250 |
} |
} |
251 |
|
|
252 |
|
|
253 |
/** Invoked when this window is about to close. */ |
/** Invoked when this window is about to close. */ |
254 |
|
@Override |
255 |
protected void |
protected void |
256 |
onWindowClose() { |
onWindowClose() { |
257 |
FantasiaPrefs.setAlwaysOnTop(isAlwaysOnTop()); |
boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT); |
258 |
|
if(b && CC.getSamplerModel().isModified()) { |
259 |
|
JSQuitDlg dlg = new JSQuitDlg(Res.iconQuestion32); |
260 |
|
dlg.setVisible(true); |
261 |
|
if(dlg.isCancelled()) return; |
262 |
|
} |
263 |
|
|
264 |
|
leftSidePane.savePreferences(); |
265 |
|
rightSidePane.savePreferences(); |
266 |
|
|
267 |
java.awt.Point p = getLocation(); |
int i = hSplitPane.getDividerLocation(); |
268 |
Dimension d = getSize(); |
preferences().setIntProperty("MainFrame.hSplitDividerLocation", i); |
269 |
StringBuffer sb = new StringBuffer(); |
|
270 |
sb.append(p.x).append(',').append(p.y + getSize().height - TITLE_BAR_HEIGHT); |
preferences().setBoolProperty ( |
271 |
FantasiaPrefs.setWindowLocation(sb.toString()); |
"MainFrame.windowMaximized", |
272 |
|
(getExtendedState() & MAXIMIZED_BOTH) == MAXIMIZED_BOTH |
273 |
|
); |
274 |
|
|
275 |
|
if(preferences().getBoolProperty("MainFrame.windowMaximized")) { |
276 |
|
super.onWindowClose(); |
277 |
|
return; |
278 |
|
} |
279 |
|
|
280 |
|
StdUtils.saveWindowBounds("MainFrame", getBounds()); |
281 |
|
|
282 |
|
String[] list = recentScripts.toArray(new String[recentScripts.size()]); |
283 |
|
preferences().setStringListProperty(RECENT_LSCP_SCRIPTS, list); |
284 |
|
|
285 |
|
if(preferences().getBoolProperty(SAVE_LS_CONSOLE_HISTORY)) { |
286 |
|
if(lsConsoleFrame != null) getLSConsolePane().saveConsoleHistory(); |
287 |
|
} |
288 |
|
|
289 |
|
if(getBackendLogFrame() != null) getBackendLogFrame().stopTimer(); |
290 |
|
if(getLSConsolePane() != null) getLSConsolePane().disconnect(); |
291 |
|
|
292 |
super.onWindowClose(); |
super.onWindowClose(); |
293 |
} |
} |
294 |
|
|
295 |
private JPanel |
@Override |
296 |
createVSeparator() { |
public void |
297 |
JPanel p = new JPanel(); |
setVisible(boolean b) { |
298 |
p.setName("VSeparator"); |
if(b == isVisible()) return; |
299 |
p.setOpaque(false); |
|
300 |
p.setPreferredSize(new Dimension(2, 29)); |
super.setVisible(b); |
301 |
p.setMinimumSize(p.getPreferredSize()); |
|
302 |
p.setMaximumSize(p.getPreferredSize()); |
if(b && preferences().getBoolProperty("MainFrame.windowMaximized")) { |
303 |
return p; |
setExtendedState(getExtendedState() | MAXIMIZED_BOTH); |
304 |
|
} |
305 |
|
} |
306 |
|
|
307 |
|
private void |
308 |
|
addMenu() { |
309 |
|
JMenu m; |
310 |
|
JMenuItem mi; |
311 |
|
|
312 |
|
setJMenuBar(menuBar); |
313 |
|
|
314 |
|
// Actions |
315 |
|
m = new FantasiaMenu(i18n.getMenuLabel("actions")); |
316 |
|
|
317 |
|
mi = new JMenuItem(a4n.refresh); |
318 |
|
mi.setIcon(null); |
319 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F5, 0)); |
320 |
|
m.add(mi); |
321 |
|
|
322 |
|
mi = new JMenuItem(a4n.samplerInfo); |
323 |
|
mi.setIcon(null); |
324 |
|
m.add(mi); |
325 |
|
|
326 |
|
mi = new JMenuItem(a4n.resetSampler); |
327 |
|
mi.setIcon(null); |
328 |
|
m.add(mi); |
329 |
|
|
330 |
|
m.addSeparator(); |
331 |
|
|
332 |
|
JMenu exportMenu = new JMenu(i18n.getMenuLabel("actions.export")); |
333 |
|
m.add(exportMenu); |
334 |
|
|
335 |
|
mi = new JMenuItem(a4n.exportSamplerConfig); |
336 |
|
mi.setIcon(null); |
337 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_MASK)); |
338 |
|
exportMenu.add(mi); |
339 |
|
|
340 |
|
mi = new JMenuItem(a4n.exportMidiInstrumentMaps); |
341 |
|
mi.setIcon(null); |
342 |
|
exportMenu.add(mi); |
343 |
|
|
344 |
|
m.addSeparator(); |
345 |
|
|
346 |
|
mi = new JMenuItem(a4n.loadScript); |
347 |
|
mi.setIcon(null); |
348 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_MASK)); |
349 |
|
m.add(mi); |
350 |
|
|
351 |
|
String[] list = preferences().getStringListProperty(RECENT_LSCP_SCRIPTS); |
352 |
|
for(String s : list) recentScripts.add(s); |
353 |
|
|
354 |
|
updateRecentScriptsMenu(); |
355 |
|
|
356 |
|
m.add(recentScriptsMenu); |
357 |
|
|
358 |
|
m.addSeparator(); |
359 |
|
|
360 |
|
mi = new JMenuItem(a4n.changeBackend); |
361 |
|
mi.setIcon(null); |
362 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, KeyEvent.CTRL_MASK)); |
363 |
|
m.add(mi); |
364 |
|
|
365 |
|
m.addSeparator(); |
366 |
|
|
367 |
|
mi = new JMenuItem(i18n.getMenuLabel("actions.exit")); |
368 |
|
m.add(mi); |
369 |
|
mi.addActionListener(new ActionListener() { |
370 |
|
public void |
371 |
|
actionPerformed(ActionEvent e) { onWindowClose(); } |
372 |
|
}); |
373 |
|
|
374 |
|
menuBar.add(m); |
375 |
|
|
376 |
|
|
377 |
|
// Edit |
378 |
|
m = new FantasiaMenu(i18n.getMenuLabel("edit")); |
379 |
|
menuBar.add(m); |
380 |
|
|
381 |
|
mi = new JMenuItem(i18n.getMenuLabel("edit.addChannel")); |
382 |
|
m.add(mi); |
383 |
|
mi.addActionListener(new ActionListener() { |
384 |
|
public void |
385 |
|
actionPerformed(ActionEvent e) { |
386 |
|
CC.getSamplerModel().addBackendChannel(); |
387 |
|
} |
388 |
|
}); |
389 |
|
|
390 |
|
m.addSeparator(); |
391 |
|
|
392 |
|
mi = new JMenuItem(a4n.createMidiDevice); |
393 |
|
mi.setIcon(null); |
394 |
|
m.add(mi); |
395 |
|
|
396 |
|
mi = new JMenuItem(a4n.createAudioDevice); |
397 |
|
mi.setIcon(null); |
398 |
|
m.add(mi); |
399 |
|
|
400 |
|
m.addSeparator(); |
401 |
|
|
402 |
|
mi = new JMenuItem(a4n.editPreferences); |
403 |
|
mi.setIcon(null); |
404 |
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
405 |
|
KeyEvent.VK_P, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
406 |
|
)); |
407 |
|
m.add(mi); |
408 |
|
|
409 |
|
// View |
410 |
|
m = new FantasiaMenu(i18n.getMenuLabel("view")); |
411 |
|
menuBar.add(m); |
412 |
|
|
413 |
|
m.add(cbmiToolBarVisible); |
414 |
|
|
415 |
|
cbmiToolBarVisible.addActionListener(new ActionListener() { |
416 |
|
public void |
417 |
|
actionPerformed(ActionEvent e) { |
418 |
|
showToolBar(cbmiToolBarVisible.getState()); |
419 |
|
} |
420 |
|
}); |
421 |
|
|
422 |
|
boolean b = preferences().getBoolProperty("toolBar.visible"); |
423 |
|
cbmiToolBarVisible.setSelected(b); |
424 |
|
showToolBar(b); |
425 |
|
|
426 |
|
cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
427 |
|
KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
428 |
|
)); |
429 |
|
m.add(cbmiLeftSidePaneVisible); |
430 |
|
|
431 |
|
cbmiLeftSidePaneVisible.addActionListener(new ActionListener() { |
432 |
|
public void |
433 |
|
actionPerformed(ActionEvent e) { |
434 |
|
showSidePane(cbmiLeftSidePaneVisible.getState()); |
435 |
|
} |
436 |
|
}); |
437 |
|
|
438 |
|
b = preferences().getBoolProperty("leftSidePane.visible"); |
439 |
|
cbmiLeftSidePaneVisible.setSelected(b); |
440 |
|
showSidePane(b); |
441 |
|
|
442 |
|
cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke ( |
443 |
|
KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
444 |
|
)); |
445 |
|
m.add(cbmiRightSidePaneVisible); |
446 |
|
|
447 |
|
cbmiRightSidePaneVisible.addActionListener(new ActionListener() { |
448 |
|
public void |
449 |
|
actionPerformed(ActionEvent e) { |
450 |
|
showDevicesPane(cbmiRightSidePaneVisible.getState()); |
451 |
|
} |
452 |
|
}); |
453 |
|
|
454 |
|
b = preferences().getBoolProperty("rightSidePane.visible"); |
455 |
|
cbmiRightSidePaneVisible.setSelected(b); |
456 |
|
showDevicesPane(b); |
457 |
|
|
458 |
|
m.addSeparator(); |
459 |
|
|
460 |
|
m.add(cbmiMidiKeyboardVisible); |
461 |
|
|
462 |
|
cbmiMidiKeyboardVisible.addActionListener(new ActionListener() { |
463 |
|
public void |
464 |
|
actionPerformed(ActionEvent e) { |
465 |
|
setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState()); |
466 |
|
} |
467 |
|
}); |
468 |
|
|
469 |
|
b = preferences().getBoolProperty("midiKeyboard.visible"); |
470 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
471 |
|
setMidiKeyboardVisible(b); |
472 |
|
|
473 |
|
|
474 |
|
// Channels |
475 |
|
m = new FantasiaMenu(i18n.getMenuLabel("channels")); |
476 |
|
|
477 |
|
mi = new JMenuItem(i18n.getMenuLabel("channels.newChannel")); |
478 |
|
mi.addActionListener(new ActionListener() { |
479 |
|
public void |
480 |
|
actionPerformed(ActionEvent e) { |
481 |
|
CC.getSamplerModel().addBackendChannel(); |
482 |
|
} |
483 |
|
}); |
484 |
|
m.add(mi); |
485 |
|
|
486 |
|
m.addSeparator(); |
487 |
|
|
488 |
|
MenuManager.ChannelViewGroup group = new MenuManager.ChannelViewGroup(); |
489 |
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
490 |
|
|
491 |
|
for(JMenuItem menuItem : group.getMenuItems()) m.add(menuItem); |
492 |
|
|
493 |
|
m.addSeparator(); |
494 |
|
|
495 |
|
m.add(new JMenuItem(a4n.moveChannelsOnTop)); |
496 |
|
m.add(new JMenuItem(a4n.moveChannelsUp)); |
497 |
|
m.add(new JMenuItem(a4n.moveChannelsDown)); |
498 |
|
m.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
499 |
|
|
500 |
|
m.add(new ToPanelMenu()); |
501 |
|
|
502 |
|
m.addSeparator(); |
503 |
|
|
504 |
|
mi = new JMenuItem(a4n.selectAllChannels); |
505 |
|
mi.setIcon(null); |
506 |
|
mi.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_MASK)); |
507 |
|
m.add(mi); |
508 |
|
|
509 |
|
mi = new JMenuItem(a4n.deselectChannels); |
510 |
|
mi.setIcon(null); |
511 |
|
mi.setAccelerator(KeyStroke.getKeyStroke ( |
512 |
|
KeyEvent.VK_A, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK |
513 |
|
)); |
514 |
|
m.add(mi); |
515 |
|
|
516 |
|
menuBar.add(m); |
517 |
|
|
518 |
|
// Window |
519 |
|
m = new FantasiaMenu(i18n.getMenuLabel("window")); |
520 |
|
menuBar.add(m); |
521 |
|
|
522 |
|
mi = new JMenuItem(a4n.windowLSConsole); |
523 |
|
mi.setIcon(null); |
524 |
|
m.add(mi); |
525 |
|
|
526 |
|
mi = new JMenuItem(a4n.windowInstrumentsDb); |
527 |
|
mi.setIcon(null); |
528 |
|
m.add(mi); |
529 |
|
|
530 |
|
m.addSeparator(); |
531 |
|
|
532 |
|
final JMenuItem mi2 = new JMenuItem(i18n.getMenuLabel("window.backendLog")); |
533 |
|
m.add(mi2); |
534 |
|
mi2.addActionListener(new ActionListener() { |
535 |
|
public void |
536 |
|
actionPerformed(ActionEvent e) { |
537 |
|
if(getBackendLogFrame().isVisible()) { |
538 |
|
getBackendLogFrame().setVisible(false); |
539 |
|
} |
540 |
|
|
541 |
|
getBackendLogFrame().setVisible(true); |
542 |
|
} |
543 |
|
}); |
544 |
|
|
545 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
546 |
|
|
547 |
|
CC.addBackendProcessListener(new ActionListener() { |
548 |
|
public void |
549 |
|
actionPerformed(ActionEvent e) { |
550 |
|
mi2.setEnabled(CC.getBackendProcess() != null); |
551 |
|
} |
552 |
|
}); |
553 |
|
|
554 |
|
|
555 |
|
// Help |
556 |
|
m = new FantasiaMenu(i18n.getMenuLabel("help")); |
557 |
|
|
558 |
|
mi = new JMenuItem(a4n.browseOnlineTutorial); |
559 |
|
mi.setIcon(null); |
560 |
|
m.add(mi); |
561 |
|
|
562 |
|
m.addSeparator(); |
563 |
|
|
564 |
|
mi = new JMenuItem(a4n.helpAbout); |
565 |
|
mi.setIcon(null); |
566 |
|
m.add(mi); |
567 |
|
|
568 |
|
menuBar.add(m); |
569 |
} |
} |
570 |
|
|
571 |
|
public static class ToPanelMenu extends FantasiaMenu implements ListSelectionListener { |
572 |
|
public |
573 |
|
ToPanelMenu() { |
574 |
|
super(i18n.getMenuLabel("channels.toPanel")); |
575 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
576 |
|
|
577 |
|
CC.getMainFrame().addChannelsPaneSelectionListener(this); |
578 |
|
|
579 |
|
for(int i = 0; i < CC.getMainFrame().getChannelsPaneCount(); i++) { |
580 |
|
JSChannelsPane p = CC.getMainFrame().getChannelsPane(i); |
581 |
|
add(new JMenuItem(new A4n.MoveChannelsToPanel(p))); |
582 |
|
p.addListSelectionListener(this); |
583 |
|
} |
584 |
|
} |
585 |
|
|
586 |
|
@Override |
587 |
|
public void |
588 |
|
valueChanged(ListSelectionEvent e) { |
589 |
|
setEnabled(CC.getMainFrame().getSelectedChannelsPane().hasSelectedChannel()); |
590 |
|
} |
591 |
|
} |
592 |
|
|
593 |
|
public RightSidePane |
594 |
|
getRightSidePane() { return rightSidePane; } |
595 |
|
|
596 |
|
@Override |
597 |
|
public A4n |
598 |
|
getA4n() { return A4n.a4n; } |
599 |
|
|
600 |
/** |
/** |
601 |
* This method does nothing, because <b>Fantasia</b> has exactly |
* This method does nothing, because <b>Fantasia</b> has constant |
602 |
* one pane containing sampler channels, which can not be changed. |
* number of panes containing sampler channels, which can not be changed. |
603 |
*/ |
*/ |
604 |
|
@Override |
605 |
public void |
public void |
606 |
insertChannelsPane(JSChannelsPane pane, int idx) { |
insertChannelsPane(JSChannelsPane pane, int idx) { |
607 |
getChannelsPaneList().removeAllElements(); |
|
608 |
addChannelsPane(pane); |
} |
609 |
|
|
610 |
|
@Override |
611 |
|
public JSChannelsPane |
612 |
|
getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); } |
613 |
|
|
614 |
|
@Override |
615 |
|
public void |
616 |
|
setSelectedChannelsPane(JSChannelsPane pane) { |
617 |
|
mainPane.setSelectedChannelsPane(pane); |
618 |
|
fireChannelsPaneSelectionChanged(); |
619 |
|
} |
620 |
|
|
621 |
|
@Override |
622 |
|
public void |
623 |
|
installJSamplerHome() { |
624 |
|
JSamplerHomeChooser chooser = new JSamplerHomeChooser(this); |
625 |
|
chooser.setVisible(true); |
626 |
|
if(chooser.isCancelled()) return; |
627 |
|
|
628 |
|
CC.changeJSamplerHome(chooser.getJSamplerHome()); |
629 |
|
} |
630 |
|
|
631 |
|
@Override |
632 |
|
public void |
633 |
|
showDetailedErrorMessage(Frame owner, String err, String details) { |
634 |
|
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
635 |
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
636 |
|
); |
637 |
|
dlg.setVisible(true); |
638 |
|
} |
639 |
|
|
640 |
|
@Override |
641 |
|
public void |
642 |
|
showDetailedErrorMessage(Dialog owner, String err, String details) { |
643 |
|
JSDetailedErrorDlg dlg = new JSDetailedErrorDlg ( |
644 |
|
owner, Res.iconWarning32, i18n.getError("error"), err, details |
645 |
|
); |
646 |
|
dlg.setVisible(true); |
647 |
} |
} |
648 |
|
|
649 |
/** |
/** |
650 |
* This method always returns the <code>JSChannelsPane</code> at index 0, |
* Gets the server address to which to connect. If the server should be |
651 |
* because the <b>Fantasia</b> view has exactly one pane containing sampler channels. |
* manually selected, a dialog asking the user to choose a server is displayed. |
|
* @return The <code>JSChannelsPane</code> at index 0. |
|
652 |
*/ |
*/ |
653 |
public JSChannelsPane |
@Override |
654 |
getSelectedChannelsPane() { return getChannelsPane(0); } |
public Server |
655 |
|
getServer() { |
656 |
|
boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP); |
657 |
|
return getServer(b); |
658 |
|
} |
659 |
|
|
660 |
/** |
/** |
661 |
* This method does nothing because the <b>Fantasia</b> view has |
* Gets the server address to which to connect. If the server should be |
662 |
* exactly one pane containing sampler channels which is always shown. |
* manually selected, a dialog asking the user to choose a server is displayed. |
663 |
|
* @param manualSelect Determines whether the server should be manually selected. |
664 |
*/ |
*/ |
665 |
|
@Override |
666 |
|
public Server |
667 |
|
getServer(boolean manualSelect) { |
668 |
|
if(manualSelect) { |
669 |
|
JSConnectDlg dlg = new JSConnectDlg(); |
670 |
|
dlg.setVisible(true); |
671 |
|
|
672 |
|
return dlg.getSelectedServer(); |
673 |
|
} |
674 |
|
|
675 |
|
int i = preferences().getIntProperty(SERVER_INDEX); |
676 |
|
int size = CC.getServerList().getServerCount(); |
677 |
|
if(size == 0) return null; |
678 |
|
if(i >= size) return CC.getServerList().getServer(0); |
679 |
|
|
680 |
|
return CC.getServerList().getServer(i); |
681 |
|
} |
682 |
|
|
683 |
|
public Timer |
684 |
|
getGuiTimer() { return guiTimer; } |
685 |
|
|
686 |
|
protected LSConsoleModel |
687 |
|
getLSConsoleModel() { return getLSConsolePane().getModel(); } |
688 |
|
|
689 |
|
protected LSConsolePane |
690 |
|
getLSConsolePane() { |
691 |
|
return getLSConsoleFrame().getLSConsolePane(); |
692 |
|
} |
693 |
|
|
694 |
|
protected LSConsoleFrame |
695 |
|
getLSConsoleFrame() { return lsConsoleFrame; } |
696 |
|
|
697 |
|
public JSBackendLogFrame |
698 |
|
getBackendLogFrame() { return backendLogFrame; } |
699 |
|
|
700 |
|
protected boolean |
701 |
|
runScript() { |
702 |
|
String s = preferences().getStringProperty("lastScriptLocation"); |
703 |
|
JFileChooser fc = new JFileChooser(s); |
704 |
|
fc.setFileFilter(new LscpFileFilter()); |
705 |
|
int result = fc.showOpenDialog(this); |
706 |
|
if(result != JFileChooser.APPROVE_OPTION) return false; |
707 |
|
|
708 |
|
String path = fc.getCurrentDirectory().getAbsolutePath(); |
709 |
|
preferences().setStringProperty("lastScriptLocation", path); |
710 |
|
|
711 |
|
runScript(fc.getSelectedFile()); |
712 |
|
|
713 |
|
return true; |
714 |
|
} |
715 |
|
|
716 |
|
@Override |
717 |
public void |
public void |
718 |
setSelectedChannelsPane(JSChannelsPane pane) { } |
runScript(String script) { runScript(new File(script)); } |
719 |
|
|
720 |
|
private void |
721 |
|
runScript(File script) { |
722 |
|
FileReader fr; |
723 |
|
try { fr = new FileReader(script); } |
724 |
|
catch(FileNotFoundException e) { |
725 |
|
HF.showErrorMessage(i18n.getMessage("FileNotFound!")); |
726 |
|
return; |
727 |
|
} |
728 |
|
|
729 |
|
String prefix = "#jsampler.fantasia: "; |
730 |
|
Vector<String> v = new Vector<String>(); |
731 |
|
BufferedReader br = new BufferedReader(fr); |
732 |
|
|
733 |
|
try { |
734 |
|
String s = br.readLine(); |
735 |
|
while(s != null) { |
736 |
|
getLSConsoleModel().setCommandLineText(s); |
737 |
|
getLSConsoleModel().execCommand(); |
738 |
|
if(s.startsWith(prefix)) v.add(s.substring(prefix.length())); |
739 |
|
s = br.readLine(); |
740 |
|
} |
741 |
|
} catch(Exception e) { |
742 |
|
HF.showErrorMessage(e); |
743 |
|
return; |
744 |
|
} |
745 |
|
|
746 |
|
String s = script.getAbsolutePath(); |
747 |
|
recentScripts.remove(s); |
748 |
|
recentScripts.insertElementAt(s, 0); |
749 |
|
|
750 |
|
updateRecentScriptsMenu(); |
751 |
|
|
752 |
|
CC.getViewConfig().setSessionViewConfig( |
753 |
|
new SessionViewConfig(v.toArray(new String[v.size()])) |
754 |
|
); |
755 |
|
} |
756 |
|
|
757 |
public static void |
protected void |
758 |
repack(JSMainFrame frame) { |
clearRecentScripts() { |
759 |
int y = frame.getLocation().y; |
recentScripts.removeAllElements(); |
760 |
int height = frame.getSize().height; |
updateRecentScriptsMenu(); |
761 |
y += (height - frame.getPreferredSize().height); |
} |
762 |
|
|
763 |
if((height - frame.getPreferredSize().height) > 0) { |
protected void |
764 |
frame.pack(); |
updateRecentScriptsMenu() { |
765 |
frame.setLocation(frame.getLocation().x, y); |
int size = preferences().getIntProperty(RECENT_LSCP_SCRIPTS_SIZE); |
766 |
|
while(recentScripts.size() > size) { |
767 |
|
recentScripts.removeElementAt(recentScripts.size() - 1); |
768 |
|
} |
769 |
|
|
770 |
|
recentScriptsMenu.removeAll(); |
771 |
|
|
772 |
|
for(String script : recentScripts) { |
773 |
|
JMenuItem mi = new JMenuItem(script); |
774 |
|
recentScriptsMenu.add(mi); |
775 |
|
mi.addActionListener(new RecentScriptHandler(script)); |
776 |
|
} |
777 |
|
|
778 |
|
recentScriptsMenu.setEnabled(recentScripts.size() != 0); |
779 |
|
} |
780 |
|
|
781 |
|
private void |
782 |
|
showToolBar(boolean b) { |
783 |
|
preferences().setBoolProperty("toolBar.visible", b); |
784 |
|
standardBar.setVisible(b); |
785 |
|
} |
786 |
|
|
787 |
|
private void |
788 |
|
showSidePane(boolean b) { |
789 |
|
preferences().setBoolProperty("leftSidePane.visible", b); |
790 |
|
rootPane.remove(rightPane); |
791 |
|
rootPane.remove(hSplitPane); |
792 |
|
|
793 |
|
if(b) { |
794 |
|
hSplitPane.setRightComponent(rightPane); |
795 |
|
rootPane.add(hSplitPane); |
796 |
|
int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220); |
797 |
|
|
798 |
|
hSplitPane.setDividerLocation(i); |
799 |
|
hSplitPane.validate(); |
800 |
} else { |
} else { |
801 |
frame.setLocation(frame.getLocation().x, y); |
rootPane.add(rightPane); |
802 |
frame.pack(); |
|
803 |
} |
} |
804 |
|
|
805 |
|
int w = getPreferredSize().width; |
806 |
|
int h = getSize().height; |
807 |
|
setSize(new Dimension(w, h)); |
808 |
|
|
809 |
|
rootPane.revalidate(); |
810 |
|
rootPane.validate(); |
811 |
|
rootPane.repaint(); |
812 |
|
|
813 |
|
SwingUtilities.invokeLater(new Runnable() { |
814 |
|
public void |
815 |
|
run() { sidePanesVisibilityChanged(); } |
816 |
|
}); |
817 |
} |
} |
818 |
|
|
819 |
|
private void |
820 |
|
showDevicesPane(boolean b) { |
821 |
|
preferences().setBoolProperty("rightSidePane.visible", b); |
822 |
|
|
823 |
|
int width = leftSidePane.getWidth(); |
824 |
|
int height = leftSidePane.getPreferredSize().height; |
825 |
|
if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height)); |
826 |
|
|
827 |
|
if(b) { |
828 |
|
int w = preferences().getIntProperty("devicesPane.width", 200); |
829 |
|
|
830 |
|
int h = rightSidePane.getPreferredSize().height; |
831 |
|
rightSidePane.setPreferredSize(new Dimension(w, h)); |
832 |
|
} else { |
833 |
|
int w = rightSidePane.getWidth(); |
834 |
|
if(w > 0 && w < 200) w = 200; |
835 |
|
if(w != 0) preferences().setIntProperty("devicesPane.width", w); |
836 |
|
} |
837 |
|
|
838 |
|
hSplitPane.setResizeWeight(0.0); |
839 |
|
rightSidePane.setVisible(b); |
840 |
|
hSplitPane.resetToPreferredSizes(); |
841 |
|
|
842 |
|
int w = getPreferredSize().width; |
843 |
|
int h = getSize().height; |
844 |
|
setSize(new Dimension(w, h)); |
845 |
|
|
846 |
|
rootPane.validate(); |
847 |
|
rootPane.repaint(); |
848 |
|
//hSplitPane.validate(); |
849 |
|
|
850 |
|
SwingUtilities.invokeLater(new Runnable() { |
851 |
|
public void |
852 |
|
run() { sidePanesVisibilityChanged(); } |
853 |
|
}); |
854 |
|
} |
855 |
|
|
856 |
} |
public void |
857 |
|
setMidiKeyboardVisible(boolean b) { |
858 |
class FantasiaTitleBar extends TitleBar { |
preferences().setBoolProperty("midiKeyboard.visible", b); |
859 |
FantasiaTitleBar() { this.addMouseListener(new ContextMenu()); } |
pianoKeyboardPane.setVisible(b); |
860 |
|
|
861 |
|
if(cbmiMidiKeyboardVisible.isSelected() != b) { |
862 |
|
cbmiMidiKeyboardVisible.setSelected(b); |
863 |
|
} |
864 |
|
|
865 |
|
if(standardBar.btnMidiKeyboard.isSelected() != b) { |
866 |
|
standardBar.btnMidiKeyboard.setSelected(b); |
867 |
|
} |
868 |
|
|
869 |
|
if(pianoKeyboardPane.btnPower.isSelected() != b) { |
870 |
|
pianoKeyboardPane.btnPower.setSelected(b); |
871 |
|
} |
872 |
|
|
873 |
|
rootPane.validate(); |
874 |
|
rootPane.repaint(); |
875 |
|
} |
876 |
|
|
877 |
class ContextMenu extends MouseAdapter { |
public void |
878 |
private final JPopupMenu cmenu = new JPopupMenu(); |
setMidiKeyboardHeight(int height) { |
879 |
|
Dimension d = pianoKeyboardPane.getPreferredSize(); |
880 |
|
d = new Dimension(d.width, height); |
881 |
|
pianoKeyboardPane.setPreferredSize(d); |
882 |
|
pianoKeyboardPane.setMinimumSize(d); |
883 |
|
pianoKeyboardPane.revalidate(); |
884 |
|
pianoKeyboardPane.repaint(); |
885 |
|
} |
886 |
|
|
887 |
|
private void |
888 |
|
sidePanesVisibilityChanged() { |
889 |
|
boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected(); |
890 |
|
boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected(); |
891 |
|
|
892 |
|
if(leftSidePaneVisible && rightSidePaneVisible) { |
893 |
|
hSplitPane.setResizeWeight(0.5); |
894 |
|
} else if(leftSidePaneVisible && !rightSidePaneVisible) { |
895 |
|
hSplitPane.setResizeWeight(1.0); |
896 |
|
} |
897 |
|
|
898 |
|
if(!leftSidePaneVisible && !rightSidePaneVisible) { |
899 |
|
standardBar.showFantasiaLogo(false); |
900 |
|
if(isResizable()) setResizable(false); |
901 |
|
} else { |
902 |
|
standardBar.showFantasiaLogo(true); |
903 |
|
if(!isResizable()) setResizable(true); |
904 |
|
} |
905 |
|
} |
906 |
|
|
907 |
|
private class RecentScriptHandler implements ActionListener { |
908 |
|
private String script; |
909 |
|
|
910 |
|
RecentScriptHandler(String script) { this.script = script; } |
911 |
|
|
912 |
|
@Override |
913 |
|
public void |
914 |
|
actionPerformed(ActionEvent e) { |
915 |
|
runScript(script); |
916 |
|
if(preferences().getBoolProperty(SHOW_LS_CONSOLE_WHEN_RUN_SCRIPT)) { |
917 |
|
a4n.windowLSConsole.actionPerformed(null); |
918 |
|
} |
919 |
|
} |
920 |
|
} |
921 |
|
|
922 |
|
private static class FantasiaMenu extends JMenu { |
923 |
|
FantasiaMenu(String s) { |
924 |
|
super(s); |
925 |
|
setFont(getFont().deriveFont(java.awt.Font.BOLD)); |
926 |
|
setOpaque(false); |
927 |
|
setContentAreaFilled(false); |
928 |
|
} |
929 |
|
} |
930 |
|
|
931 |
|
private class FantasiaMenuBar extends JMenuBar { |
932 |
|
FantasiaMenuBar() { |
933 |
|
setOpaque(false); |
934 |
|
setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0)); |
935 |
|
} |
936 |
|
|
937 |
ContextMenu() { |
@Override |
938 |
JMenuItem mi; |
protected void |
939 |
|
paintComponent(Graphics g) { |
940 |
|
//super.paintComponent(g); |
941 |
|
Graphics2D g2 = (Graphics2D)g; |
942 |
|
|
943 |
final JCheckBoxMenuItem cmi = new JCheckBoxMenuItem ( |
Paint oldPaint = g2.getPaint(); |
944 |
i18n.getMenuLabel("FantasiaTitleBar.AlwaysOnTop") |
Composite oldComposite = g2.getComposite(); |
945 |
); |
|
946 |
cmi.setIcon(null); |
double h = getSize().getHeight(); |
947 |
cmi.setSelected(FantasiaPrefs.isAlwaysOnTop()); |
double w = getSize().getWidth(); |
|
|
|
|
cmenu.add(cmi); |
|
|
|
|
|
cmi.addActionListener(new ActionListener() { |
|
|
public void |
|
|
actionPerformed(ActionEvent e) { |
|
|
CC.getMainFrame().setAlwaysOnTop(cmi.isSelected()); |
|
|
} |
|
|
}); |
|
948 |
|
|
949 |
/*mi = new JMenuItem(A4n.moveChannelsUp); |
FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5); |
|
mi.setIcon(null); |
|
|
cmenu.add(mi); |
|
950 |
|
|
951 |
cmenu.addSeparator(); |
FantasiaPainter.Border b; |
952 |
|
|
953 |
|
|
954 |
|
if(standardBar.isVisible()) { |
955 |
|
b = new FantasiaPainter.Border(true, true, false, true); |
956 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b); |
957 |
|
} else { |
958 |
|
b = new FantasiaPainter.Border(true, true, true, true); |
959 |
|
FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b); |
960 |
|
} |
961 |
|
|
962 |
mi = new JMenuItem(A4n.removeChannels); |
g2.setPaint(oldPaint); |
963 |
mi.setIcon(null); |
g2.setComposite(oldComposite); |
|
cmenu.add(mi);*/ |
|
964 |
} |
} |
965 |
|
} |
966 |
|
|
967 |
|
class RootPane extends FantasiaSubPanel { |
968 |
|
private final Color color1 = new Color(0x454545); |
969 |
|
private final Color color2 = new Color(0x2e2e2e); |
970 |
|
|
971 |
|
RootPane() { |
972 |
|
setLayout(new BorderLayout()); |
973 |
|
setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10)); |
974 |
|
setOpaque(false); |
975 |
|
|
|
public void |
|
|
mousePressed(MouseEvent e) { |
|
|
if(e.isPopupTrigger()) show(e); |
|
976 |
} |
} |
977 |
|
|
978 |
|
@Override |
979 |
public void |
public void |
980 |
mouseReleased(MouseEvent e) { |
paintComponent(Graphics g) { |
981 |
if(e.isPopupTrigger()) show(e); |
Graphics2D g2 = (Graphics2D)g; |
982 |
|
|
983 |
|
Paint oldPaint = g2.getPaint(); |
984 |
|
Composite oldComposite = g2.getComposite(); |
985 |
|
|
986 |
|
double h = getSize().getHeight(); |
987 |
|
double w = getSize().getWidth(); |
988 |
|
|
989 |
|
FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false); |
990 |
|
paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2); |
991 |
|
|
992 |
|
g2.setPaint(oldPaint); |
993 |
|
g2.setComposite(oldComposite); |
994 |
} |
} |
995 |
|
} |
996 |
|
|
997 |
void |
class BottomPane extends FantasiaPanel { |
998 |
show(MouseEvent e) { |
BottomPane() { |
999 |
cmenu.show(e.getComponent(), e.getX(), e.getY()); |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
1000 |
|
setOpaque(false); |
1001 |
|
add(pianoKeyboardPane); |
1002 |
|
|
1003 |
} |
} |
1004 |
} |
} |
1005 |
} |
} |