1 |
iliev |
1286 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2195 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1286 |
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.fantasia; |
24 |
|
|
|
25 |
iliev |
1864 |
import java.util.HashMap; |
26 |
|
|
import java.util.Map; |
27 |
|
|
|
28 |
iliev |
1286 |
import javax.swing.Icon; |
29 |
iliev |
1786 |
import javax.swing.ImageIcon; |
30 |
iliev |
2148 |
import javax.swing.JPopupMenu; |
31 |
iliev |
1286 |
import javax.swing.UIManager; |
32 |
|
|
|
33 |
iliev |
1752 |
import org.jsampler.CC; |
34 |
iliev |
1286 |
import org.jsampler.JSPrefs; |
35 |
|
|
|
36 |
|
|
import org.jsampler.view.InstrumentsDbTableView; |
37 |
|
|
import org.jsampler.view.InstrumentsDbTreeView; |
38 |
iliev |
1752 |
import org.jsampler.view.BasicIconSet; |
39 |
iliev |
1818 |
import org.jsampler.view.JSMainFrame; |
40 |
iliev |
1286 |
import org.jsampler.view.JSViewConfig; |
41 |
iliev |
2148 |
import org.jsampler.view.fantasia.basic.MultiColumnMenu; |
42 |
iliev |
1286 |
|
43 |
iliev |
2146 |
import org.pushingpixels.substance.api.SubstanceConstants; |
44 |
|
|
import org.pushingpixels.substance.api.SubstanceLookAndFeel; |
45 |
iliev |
1286 |
|
46 |
iliev |
2195 |
import static org.jsampler.view.SamplerTreeModel.*; |
47 |
|
|
|
48 |
iliev |
1286 |
/** |
49 |
|
|
* |
50 |
|
|
* @author Grigor Iliev |
51 |
|
|
*/ |
52 |
|
|
public class ViewConfig extends JSViewConfig { |
53 |
|
|
private InstrumentsDbTreeView instrumentsDbTreeView = new TreeView(); |
54 |
|
|
private InstrumentsDbTableView instrumentsDbTableView = new TableView(); |
55 |
iliev |
2195 |
private SamplerBrowserView samplerBrowserView = new SamplerBrowserView(); |
56 |
iliev |
1752 |
private BasicIconSet basicIconSet = new IconSet(); |
57 |
iliev |
1864 |
|
58 |
|
|
private Map nativeMenuPropsMap = null; |
59 |
|
|
private Map menuPropsMap = null; |
60 |
iliev |
1286 |
|
61 |
|
|
/** Creates a new instance of <code>ViewConfig</code> */ |
62 |
|
|
public |
63 |
|
|
ViewConfig() { |
64 |
|
|
try { |
65 |
iliev |
1865 |
if(isUsingScreenMenuBar()) { |
66 |
iliev |
1864 |
// fix for setting the menu bar on top of the screen |
67 |
|
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
68 |
|
|
nativeMenuPropsMap = getMenuProperties(); |
69 |
|
|
} |
70 |
iliev |
2146 |
UIManager.setLookAndFeel(new SubstanceFantasiaLookAndFeel()); |
71 |
iliev |
1743 |
UIManager.put(SubstanceLookAndFeel.WATERMARK_VISIBLE, Boolean.FALSE); |
72 |
iliev |
1496 |
|
73 |
iliev |
1729 |
UIManager.put ( |
74 |
|
|
SubstanceLookAndFeel.TABBED_PANE_CONTENT_BORDER_KIND, |
75 |
|
|
SubstanceConstants.TabContentPaneBorderKind.SINGLE_FULL |
76 |
|
|
); |
77 |
iliev |
1864 |
|
78 |
iliev |
1865 |
if(isUsingScreenMenuBar()) { |
79 |
iliev |
1864 |
// fix for setting the menu bar on top of the screen |
80 |
|
|
menuPropsMap = getMenuProperties(); |
81 |
|
|
setNativeMenuProperties(); |
82 |
|
|
} |
83 |
iliev |
1729 |
|
84 |
iliev |
1496 |
if(!preferences().getBoolProperty("TurnOffCustomWindowDecoration")) { |
85 |
|
|
javax.swing.JFrame.setDefaultLookAndFeelDecorated(true); |
86 |
|
|
javax.swing.JDialog.setDefaultLookAndFeelDecorated(true); |
87 |
|
|
} |
88 |
|
|
|
89 |
|
|
Res.loadTheme(preferences().getStringProperty("Theme")); |
90 |
iliev |
1286 |
} catch(Exception e) { |
91 |
|
|
e.printStackTrace(); |
92 |
|
|
} |
93 |
|
|
} |
94 |
iliev |
1864 |
|
95 |
|
|
/** |
96 |
|
|
* If running on Mac OS and third party LaF is used |
97 |
|
|
* certain properties from the system LaF should be set |
98 |
|
|
* to be able to move the menu bar on top of the screen. |
99 |
|
|
*/ |
100 |
|
|
public void |
101 |
|
|
setNativeMenuProperties() { |
102 |
|
|
setMenuProperties(nativeMenuPropsMap); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
/** |
106 |
|
|
* If running on Mac OS and third party LaF is used |
107 |
|
|
* certain properties from the system LaF should be set |
108 |
|
|
* to be able to move the menu bar on top of the screen. |
109 |
|
|
* This method is used to reverse them back to the LaF to be used. |
110 |
|
|
*/ |
111 |
|
|
public void |
112 |
|
|
restoreMenuProperties() { |
113 |
|
|
setMenuProperties(menuPropsMap); |
114 |
|
|
} |
115 |
|
|
|
116 |
|
|
private void |
117 |
|
|
setMenuProperties(Map props) { |
118 |
|
|
if(props == null) return; |
119 |
|
|
for(Object o : props.keySet()) UIManager.put(o, props.get(o)); |
120 |
|
|
} |
121 |
|
|
|
122 |
|
|
public Map |
123 |
|
|
getMenuProperties() { |
124 |
|
|
Map props = new HashMap(); |
125 |
|
|
props.put("MenuBarUI", UIManager.get("MenuBarUI")); |
126 |
|
|
props.put("MenuUI", UIManager.get("MenuUI")); |
127 |
|
|
props.put("MenuItemUI", UIManager.get("MenuItemUI")); |
128 |
|
|
props.put("CheckBoxMenuItemUI", UIManager.get("CheckBoxMenuItemUI")); |
129 |
|
|
props.put("RadioButtonMenuItemUI", UIManager.get("RadioButtonMenuItemUI")); |
130 |
|
|
props.put("PopupMenuUI", UIManager.get("PopupMenuUI")); |
131 |
|
|
return props; |
132 |
|
|
} |
133 |
iliev |
1286 |
|
134 |
iliev |
1786 |
@Override |
135 |
iliev |
1286 |
public JSPrefs |
136 |
|
|
preferences() { return FantasiaPrefs.preferences(); } |
137 |
|
|
|
138 |
iliev |
1767 |
/** Exports the view configuration of the current session. */ |
139 |
iliev |
1786 |
@Override |
140 |
iliev |
1767 |
public String |
141 |
|
|
exportSessionViewConfig() { |
142 |
|
|
StringBuffer sb = new StringBuffer(); |
143 |
|
|
MainFrame frame = (MainFrame)CC.getMainFrame(); |
144 |
|
|
|
145 |
iliev |
1818 |
for(int i = 0; i < frame.getChannelsPaneCount(); i++) { |
146 |
|
|
exportSamplerChannels(sb, i); |
147 |
|
|
} |
148 |
|
|
|
149 |
|
|
MidiDevicesPane midi = frame.getRightSidePane().getDevicesPane().getMidiDevicesPane(); |
150 |
|
|
|
151 |
|
|
for(int i = 0; i < midi.getDevicePaneCount(); i++) { |
152 |
|
|
sb.append("#jsampler.fantasia: [MIDI device]\r\n"); |
153 |
iliev |
1767 |
|
154 |
iliev |
1818 |
boolean b = midi.getDevicePaneAt(i).isOptionsPaneExpanded(); |
155 |
|
|
sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n"); |
156 |
|
|
|
157 |
|
|
sb.append("#\r\n"); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
AudioDevicesPane au = frame.getRightSidePane().getDevicesPane().getAudioDevicesPane(); |
161 |
|
|
|
162 |
|
|
for(int i = 0; i < au.getDevicePaneCount(); i++) { |
163 |
|
|
sb.append("#jsampler.fantasia: [audio device]\r\n"); |
164 |
|
|
|
165 |
|
|
boolean b = au.getDevicePaneAt(i).isOptionsPaneExpanded(); |
166 |
|
|
sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n"); |
167 |
|
|
|
168 |
|
|
sb.append("#\r\n"); |
169 |
|
|
} |
170 |
|
|
|
171 |
|
|
return sb.toString(); |
172 |
|
|
} |
173 |
|
|
|
174 |
|
|
private void |
175 |
|
|
exportSamplerChannels(StringBuffer sb, int channelsPane) { |
176 |
|
|
JSMainFrame frame = CC.getMainFrame(); |
177 |
|
|
|
178 |
|
|
for(int i = 0; i < frame.getChannelsPane(channelsPane).getChannelCount(); i++) { |
179 |
|
|
Channel c = (Channel)frame.getChannelsPane(channelsPane).getChannel(i); |
180 |
|
|
|
181 |
iliev |
1767 |
sb.append("#jsampler.fantasia: [channel]\r\n"); |
182 |
|
|
|
183 |
iliev |
1867 |
sb.append("#jsampler.fantasia: channelLane = "); |
184 |
iliev |
1818 |
sb.append(channelsPane + 1).append("\r\n"); |
185 |
|
|
|
186 |
iliev |
1767 |
switch(c.getViewTracker().getOriginalView().getType()) { |
187 |
|
|
case SMALL: |
188 |
|
|
sb.append("#jsampler.fantasia: viewType = SMALL\r\n"); |
189 |
|
|
break; |
190 |
|
|
|
191 |
|
|
case NORMAL: |
192 |
|
|
sb.append("#jsampler.fantasia: viewType = NORMAL\r\n"); |
193 |
|
|
break; |
194 |
|
|
} |
195 |
|
|
|
196 |
iliev |
1818 |
boolean b = c.getViewTracker().getOriginalView().isOptionsButtonSelected(); |
197 |
|
|
sb.append("#jsampler.fantasia: expanded = ").append(b).append("\r\n"); |
198 |
iliev |
1767 |
|
199 |
iliev |
1818 |
sb.append("#\r\n"); |
200 |
iliev |
1767 |
} |
201 |
|
|
} |
202 |
|
|
|
203 |
iliev |
1786 |
@Override |
204 |
iliev |
1286 |
public InstrumentsDbTreeView |
205 |
|
|
getInstrumentsDbTreeView() { return instrumentsDbTreeView; } |
206 |
|
|
|
207 |
iliev |
1786 |
@Override |
208 |
iliev |
1286 |
public InstrumentsDbTableView |
209 |
|
|
getInstrumentsDbTableView() { return instrumentsDbTableView; } |
210 |
|
|
|
211 |
iliev |
1786 |
@Override |
212 |
iliev |
2195 |
public org.jsampler.view.SamplerBrowserView |
213 |
|
|
getSamplerBrowserView() { return samplerBrowserView; } |
214 |
|
|
|
215 |
|
|
@Override |
216 |
iliev |
1752 |
public BasicIconSet |
217 |
|
|
getBasicIconSet() { return basicIconSet; } |
218 |
|
|
|
219 |
iliev |
1286 |
private class TreeView implements InstrumentsDbTreeView { |
220 |
iliev |
1786 |
@Override |
221 |
iliev |
1286 |
public Icon |
222 |
|
|
getRootIcon() { return Res.iconDb16; } |
223 |
|
|
|
224 |
iliev |
1786 |
@Override |
225 |
iliev |
1286 |
public Icon |
226 |
|
|
getClosedIcon() { return Res.iconFolder16; } |
227 |
|
|
|
228 |
iliev |
1786 |
@Override |
229 |
iliev |
1286 |
public Icon |
230 |
|
|
getOpenIcon() { return Res.iconFolderOpen16; } |
231 |
|
|
|
232 |
iliev |
1786 |
@Override |
233 |
iliev |
1286 |
public Icon |
234 |
|
|
getInstrumentIcon() { return Res.iconInstrument16; } |
235 |
|
|
|
236 |
iliev |
1786 |
@Override |
237 |
iliev |
1286 |
public Icon |
238 |
|
|
getGigInstrumentIcon() { return Res.iconInstrument16; } |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
private static class TableView implements InstrumentsDbTableView { |
242 |
iliev |
1786 |
@Override |
243 |
iliev |
1286 |
public Icon |
244 |
|
|
getFolderIcon() { return Res.iconFolder16; } |
245 |
|
|
|
246 |
iliev |
1786 |
@Override |
247 |
iliev |
1286 |
public Icon |
248 |
|
|
getInstrumentIcon() { return Res.iconInstrument16; } |
249 |
|
|
|
250 |
iliev |
1786 |
@Override |
251 |
iliev |
1286 |
public Icon |
252 |
|
|
getGigInstrumentIcon() { return Res.iconInstrument16; } |
253 |
|
|
} |
254 |
|
|
|
255 |
iliev |
1752 |
private class IconSet implements BasicIconSet { |
256 |
iliev |
1786 |
@Override |
257 |
|
|
public ImageIcon |
258 |
|
|
getApplicationIcon() { return Res.iconAppIcon; } |
259 |
|
|
|
260 |
|
|
@Override |
261 |
iliev |
1752 |
public Icon |
262 |
|
|
getBack16Icon() { return Res.iconBack16; } |
263 |
|
|
|
264 |
iliev |
1786 |
@Override |
265 |
iliev |
1752 |
public Icon |
266 |
|
|
getUp16Icon() { return Res.iconUp16; } |
267 |
|
|
|
268 |
iliev |
1786 |
@Override |
269 |
iliev |
1752 |
public Icon |
270 |
|
|
getForward16Icon() { return Res.iconNext16; } |
271 |
|
|
|
272 |
iliev |
1786 |
@Override |
273 |
iliev |
1752 |
public Icon |
274 |
|
|
getReload16Icon() { return Res.iconReload16; } |
275 |
|
|
|
276 |
iliev |
1786 |
@Override |
277 |
iliev |
1752 |
public Icon |
278 |
|
|
getPreferences16Icon() { return Res.iconPreferences16; } |
279 |
iliev |
1767 |
|
280 |
iliev |
1786 |
@Override |
281 |
iliev |
1767 |
public Icon |
282 |
|
|
getWarning32Icon() { return Res.iconWarning32; } |
283 |
|
|
|
284 |
iliev |
1786 |
@Override |
285 |
iliev |
1767 |
public Icon |
286 |
|
|
getQuestion32Icon() { return Res.iconQuestion32; } |
287 |
iliev |
1752 |
} |
288 |
|
|
|
289 |
iliev |
2195 |
private class SamplerBrowserView implements org.jsampler.view.SamplerBrowserView { |
290 |
|
|
@Override |
291 |
|
|
public Icon |
292 |
|
|
getSamplerIcon() { return Res.iconSampler16; } |
293 |
|
|
|
294 |
|
|
@Override |
295 |
|
|
public Icon |
296 |
|
|
getAudioDevicesOpenIcon() { return Res.iconAudioDevsOpen16; } |
297 |
|
|
|
298 |
|
|
@Override |
299 |
|
|
public Icon |
300 |
|
|
getAudioDevicesCloseIcon() { return Res.iconAudioDevsClose16; } |
301 |
|
|
|
302 |
|
|
@Override |
303 |
|
|
public Icon |
304 |
|
|
getAudioDeviceIcon() { return Res.iconAudioDev16; } |
305 |
|
|
|
306 |
|
|
@Override |
307 |
|
|
public Icon |
308 |
|
|
getEffectsOpenIcon() { return Res.iconEffectsOpen16; } |
309 |
|
|
|
310 |
|
|
@Override |
311 |
|
|
public Icon |
312 |
|
|
getEffectsCloseIcon() { return Res.iconEffectsClose16; } |
313 |
|
|
|
314 |
|
|
@Override |
315 |
|
|
public Icon |
316 |
|
|
getEffectIcon() { return Res.iconEffect16; } |
317 |
|
|
|
318 |
|
|
@Override |
319 |
|
|
public Icon |
320 |
|
|
getEffectInstanceIcon() { return Res.iconEffectInstance16; } |
321 |
|
|
|
322 |
|
|
@Override |
323 |
|
|
public Icon |
324 |
|
|
getEffectChainIcon() { return Res.iconEffectChain16; } |
325 |
|
|
|
326 |
|
|
@Override |
327 |
|
|
public Icon |
328 |
|
|
getEffectChainsOpenIcon() { return Res.iconEffectChainsOpen16; } |
329 |
|
|
|
330 |
|
|
@Override |
331 |
|
|
public Icon |
332 |
|
|
getEffectChainsCloseIcon() { return Res.iconEffectChainsClose16; } |
333 |
|
|
|
334 |
|
|
@Override |
335 |
|
|
public Icon |
336 |
|
|
getIcon(Object value, boolean b) { |
337 |
|
|
if(value instanceof SamplerTreeNode) return getSamplerIcon(); |
338 |
|
|
|
339 |
|
|
if(value instanceof AudioDevicesTreeNode) { |
340 |
|
|
if(b) return getAudioDevicesOpenIcon(); |
341 |
|
|
else return getAudioDevicesCloseIcon(); |
342 |
|
|
} |
343 |
|
|
|
344 |
|
|
if(value instanceof AudioDeviceTreeNode) return getAudioDeviceIcon(); |
345 |
|
|
|
346 |
|
|
if(value instanceof SendEffectChainsTreeNode) { |
347 |
|
|
if(b) return getEffectChainsOpenIcon(); |
348 |
|
|
else return getEffectChainsCloseIcon(); |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
if(value instanceof SendEffectChainTreeNode) return getEffectChainIcon(); |
352 |
|
|
|
353 |
|
|
if(value instanceof EffectInstanceTreeNode) return getEffectInstanceIcon(); |
354 |
|
|
|
355 |
|
|
if(value instanceof InternalEffectsTreeNode) { |
356 |
|
|
if(b) return getEffectsOpenIcon(); |
357 |
|
|
else return getEffectsCloseIcon(); |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
if(value instanceof InternalEffectTreeNode) return getEffectIcon(); |
361 |
|
|
|
362 |
|
|
return null; |
363 |
|
|
} |
364 |
|
|
} |
365 |
|
|
|
366 |
iliev |
1786 |
@Override |
367 |
iliev |
1286 |
public boolean |
368 |
|
|
getInstrumentsDbSupport() { return true; } |
369 |
iliev |
2148 |
|
370 |
|
|
/** Constructs a new multicolumn menu with the supplied string as its text. */ |
371 |
|
|
@Override |
372 |
|
|
public javax.swing.JMenu |
373 |
|
|
createMultiColumnMenu(String s) { return new MultiColumnMenu(s); } |
374 |
|
|
|
375 |
|
|
/** Constructs a new multicolumn popup menu. */ |
376 |
|
|
@Override |
377 |
|
|
public JPopupMenu |
378 |
|
|
createMultiColumnPopupMenu() |
379 |
|
|
{ return new MultiColumnMenu.FantasiaPopupMenu(); } |
380 |
iliev |
1286 |
} |