1 |
iliev |
912 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2288 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
912 |
* |
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 |
1467 |
import java.awt.Container; |
26 |
iliev |
1732 |
import java.awt.Dimension; |
27 |
iliev |
1467 |
import java.awt.Rectangle; |
28 |
iliev |
912 |
|
29 |
|
|
import java.awt.event.ActionEvent; |
30 |
|
|
import java.awt.event.ActionListener; |
31 |
iliev |
1732 |
import java.awt.event.MouseAdapter; |
32 |
|
|
import java.awt.event.MouseEvent; |
33 |
iliev |
912 |
|
34 |
iliev |
1285 |
import java.beans.PropertyChangeEvent; |
35 |
|
|
import java.beans.PropertyChangeListener; |
36 |
|
|
|
37 |
iliev |
1732 |
import java.text.NumberFormat; |
38 |
|
|
|
39 |
|
|
import javax.swing.AbstractAction; |
40 |
|
|
import javax.swing.Action; |
41 |
iliev |
912 |
import javax.swing.BoxLayout; |
42 |
iliev |
1732 |
import javax.swing.ImageIcon; |
43 |
iliev |
912 |
import javax.swing.JButton; |
44 |
iliev |
1540 |
import javax.swing.JComponent; |
45 |
iliev |
1732 |
import javax.swing.JLabel; |
46 |
|
|
import javax.swing.JMenuItem; |
47 |
iliev |
912 |
import javax.swing.JPanel; |
48 |
iliev |
1732 |
import javax.swing.JPopupMenu; |
49 |
iliev |
1467 |
import javax.swing.JScrollPane; |
50 |
iliev |
1732 |
import javax.swing.JToolBar; |
51 |
iliev |
912 |
|
52 |
iliev |
1285 |
import org.jdesktop.swingx.JXCollapsiblePane; |
53 |
|
|
|
54 |
iliev |
912 |
import org.jsampler.CC; |
55 |
iliev |
1540 |
import org.jsampler.HF; |
56 |
iliev |
912 |
import org.jsampler.SamplerChannelModel; |
57 |
|
|
|
58 |
|
|
import org.jsampler.event.SamplerChannelEvent; |
59 |
iliev |
1285 |
import org.jsampler.event.SamplerChannelListEvent; |
60 |
|
|
import org.jsampler.event.SamplerChannelListListener; |
61 |
iliev |
912 |
import org.jsampler.event.SamplerChannelListener; |
62 |
|
|
|
63 |
iliev |
1734 |
import org.jsampler.view.JSChannel; |
64 |
iliev |
1737 |
import org.jsampler.view.JSChannelsPane; |
65 |
iliev |
1734 |
|
66 |
iliev |
1785 |
import org.jsampler.view.fantasia.basic.PixmapToggleButton; |
67 |
|
|
|
68 |
iliev |
1732 |
import org.jsampler.view.std.JSChannelOutputRoutingDlg; |
69 |
iliev |
1743 |
import org.jsampler.view.std.JSFxSendsDlg; |
70 |
iliev |
1732 |
import org.jsampler.view.std.JSFxSendsPane; |
71 |
|
|
import org.jsampler.view.std.JSInstrumentChooser; |
72 |
|
|
import org.jsampler.view.std.JSVolumeEditorPopup; |
73 |
iliev |
2288 |
import org.jsampler.view.swing.SHF; |
74 |
|
|
import org.jsampler.view.swing.SwingChannel; |
75 |
iliev |
1732 |
|
76 |
|
|
import org.linuxsampler.lscp.SamplerChannel; |
77 |
|
|
|
78 |
iliev |
1818 |
import static org.jsampler.view.fantasia.A4n.a4n; |
79 |
iliev |
1732 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
80 |
iliev |
1285 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
81 |
iliev |
1732 |
import static org.jsampler.view.fantasia.FantasiaUtils.*; |
82 |
|
|
import static org.jsampler.view.std.JSVolumeEditorPopup.VolumeType; |
83 |
iliev |
912 |
|
84 |
|
|
|
85 |
|
|
/** |
86 |
|
|
* |
87 |
|
|
* @author Grigor Iliev |
88 |
|
|
*/ |
89 |
iliev |
2288 |
public class Channel extends SwingChannel { |
90 |
iliev |
1285 |
private final JXCollapsiblePane mainPane; |
91 |
iliev |
1730 |
private final ChannelOptionsPane optionsPane = new ChannelOptionsPane(); |
92 |
iliev |
912 |
|
93 |
iliev |
1734 |
private final ViewTracker viewTracker; |
94 |
|
|
|
95 |
iliev |
1743 |
private JSFxSendsDlg fxSendsDlg = null; |
96 |
iliev |
1732 |
|
97 |
iliev |
1737 |
private final ContextMenu contextMenu; |
98 |
iliev |
1732 |
|
99 |
iliev |
1730 |
private boolean selected = false; |
100 |
iliev |
912 |
|
101 |
iliev |
1730 |
private AnimatedPorpetyListener animatedPorpetyListener = new AnimatedPorpetyListener(); |
102 |
iliev |
912 |
|
103 |
iliev |
1730 |
class AnimatedPorpetyListener implements PropertyChangeListener { |
104 |
|
|
public void |
105 |
|
|
propertyChange(PropertyChangeEvent e) { |
106 |
|
|
mainPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
107 |
|
|
} |
108 |
|
|
} |
109 |
iliev |
912 |
|
110 |
iliev |
1737 |
//////////////////////////////// |
111 |
|
|
// ******* Mouse tracker ******* |
112 |
|
|
//////////////////////////////// |
113 |
|
|
private static int mouseOverChannelId = -1; |
114 |
|
|
private static boolean mousePressed = false; |
115 |
|
|
|
116 |
|
|
private static ActionListener guiListener = null; |
117 |
|
|
|
118 |
|
|
private static Channel oldMouseOverChannel = null; |
119 |
|
|
private static Channel newMouseOverChannel = null; |
120 |
|
|
|
121 |
|
|
|
122 |
|
|
private static void |
123 |
|
|
mouseMoved() { |
124 |
iliev |
1975 |
JSChannelsPane cp = CC.getMainFrame().getSelectedChannelsPane(); |
125 |
iliev |
1737 |
for(int i = 0; i < cp.getChannelCount(); i++) { |
126 |
|
|
mouseMoved((Channel)cp.getChannel(i)); |
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
if(oldMouseOverChannel == newMouseOverChannel) return; |
130 |
|
|
|
131 |
|
|
if(oldMouseOverChannel != null) oldMouseOverChannel.mouseExited(); |
132 |
|
|
|
133 |
|
|
if(newMouseOverChannel != null) { |
134 |
|
|
mouseOverChannelId = newMouseOverChannel.getChannelId(); |
135 |
|
|
newMouseOverChannel.mouseEntered(); |
136 |
|
|
} |
137 |
|
|
|
138 |
|
|
oldMouseOverChannel = newMouseOverChannel = null; |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
private static void |
142 |
|
|
mouseMoved(Channel c) { |
143 |
|
|
int id = c.getChannelId(); |
144 |
|
|
if(c.mainPane.getMousePosition(true) != null) { |
145 |
|
|
newMouseOverChannel = c; |
146 |
|
|
} else if(id == mouseOverChannelId) { |
147 |
|
|
oldMouseOverChannel = c; |
148 |
|
|
} |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
//////////////////////////////// |
152 |
|
|
|
153 |
|
|
|
154 |
iliev |
912 |
/** |
155 |
|
|
* Creates a new instance of <code>Channel</code> using the specified |
156 |
|
|
* non-<code>null</code> channel model. |
157 |
|
|
* @param model The model to be used by this channel. |
158 |
|
|
* @throws IllegalArgumentException If the model is <code>null</code>. |
159 |
|
|
*/ |
160 |
|
|
public |
161 |
|
|
Channel(SamplerChannelModel model) { |
162 |
iliev |
1318 |
this(model, null); |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
/** |
166 |
|
|
* Creates a new instance of <code>Channel</code> using the specified |
167 |
|
|
* non-<code>null</code> channel model. |
168 |
|
|
* @param model The model to be used by this channel. |
169 |
|
|
* @param listener A listener which is notified when the newly created |
170 |
|
|
* channel is fully expanded on the screen. |
171 |
|
|
* @throws IllegalArgumentException If the model is <code>null</code>. |
172 |
|
|
*/ |
173 |
|
|
public |
174 |
|
|
Channel(SamplerChannelModel model, final ActionListener listener) { |
175 |
iliev |
1818 |
this ( |
176 |
|
|
model, listener, |
177 |
|
|
preferences().getIntProperty(DEFAULT_CHANNEL_VIEW) == 0 ? |
178 |
|
|
ChannelView.Type.SMALL : ChannelView.Type.NORMAL |
179 |
|
|
); |
180 |
|
|
} |
181 |
|
|
|
182 |
|
|
/** |
183 |
|
|
* Creates a new instance of <code>Channel</code> using the specified |
184 |
|
|
* non-<code>null</code> channel model. |
185 |
|
|
* @param model The model to be used by this channel. |
186 |
|
|
* @param listener A listener which is notified when the newly created |
187 |
|
|
* channel is fully expanded on the screen. |
188 |
|
|
* @param type Specifies the view type to be used. |
189 |
|
|
* @throws IllegalArgumentException If the model is <code>null</code>. |
190 |
|
|
*/ |
191 |
|
|
public |
192 |
|
|
Channel(SamplerChannelModel model, final ActionListener listener, ChannelView.Type type) { |
193 |
iliev |
912 |
super(model); |
194 |
|
|
|
195 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
196 |
|
|
optionsPane.setAlignmentX(JPanel.CENTER_ALIGNMENT); |
197 |
|
|
|
198 |
iliev |
1285 |
mainPane = new JXCollapsiblePane(); |
199 |
iliev |
1734 |
viewTracker = new ViewTracker(); |
200 |
iliev |
1737 |
contextMenu = new ContextMenu(); |
201 |
iliev |
1734 |
|
202 |
iliev |
1285 |
mainPane.getContentPane().setLayout ( |
203 |
|
|
new BoxLayout(mainPane.getContentPane(), BoxLayout.Y_AXIS) |
204 |
|
|
); |
205 |
iliev |
912 |
|
206 |
iliev |
1818 |
switch(type) { |
207 |
|
|
case SMALL: viewTracker.setView(new SmallChannelView(Channel.this)); break; |
208 |
|
|
case NORMAL: viewTracker.setView(new NormalChannelView(Channel.this)); break; |
209 |
|
|
default: viewTracker.setView(new NormalChannelView(Channel.this)); |
210 |
iliev |
1732 |
} |
211 |
iliev |
1730 |
|
212 |
iliev |
1285 |
setOpaque(false); |
213 |
|
|
|
214 |
iliev |
912 |
getModel().addSamplerChannelListener(getHandler()); |
215 |
|
|
|
216 |
|
|
updateChannelInfo(); |
217 |
iliev |
1285 |
|
218 |
|
|
add(mainPane); |
219 |
|
|
|
220 |
iliev |
1318 |
if(listener != null) { |
221 |
|
|
final String s = JXCollapsiblePane.ANIMATION_STATE_KEY; |
222 |
|
|
mainPane.addPropertyChangeListener(s, new PropertyChangeListener() { |
223 |
|
|
public void |
224 |
|
|
propertyChange(PropertyChangeEvent e) { |
225 |
|
|
if(e.getNewValue() == "expanded") { |
226 |
iliev |
1467 |
// TODO: this should be done regardles the listener != null? |
227 |
iliev |
1318 |
mainPane.removePropertyChangeListener(s, this); |
228 |
iliev |
1467 |
/////// |
229 |
iliev |
1318 |
listener.actionPerformed(null); |
230 |
iliev |
1467 |
ensureChannelIsVisible(); |
231 |
|
|
} else if(e.getNewValue() == "expanding/collapsing") { |
232 |
|
|
ensureChannelIsVisible(); |
233 |
iliev |
1318 |
} |
234 |
|
|
} |
235 |
|
|
}); |
236 |
|
|
} |
237 |
|
|
|
238 |
iliev |
1285 |
mainPane.setAnimated(false); |
239 |
|
|
mainPane.setCollapsed(true); |
240 |
|
|
mainPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
241 |
|
|
mainPane.setCollapsed(false); |
242 |
|
|
|
243 |
iliev |
1730 |
preferences().addPropertyChangeListener(ANIMATED, animatedPorpetyListener); |
244 |
iliev |
1318 |
|
245 |
|
|
if(listener != null) { |
246 |
|
|
javax.swing.SwingUtilities.invokeLater(new Runnable() { |
247 |
|
|
public void |
248 |
|
|
run() { listener.actionPerformed(null); } |
249 |
|
|
}); |
250 |
|
|
} |
251 |
iliev |
1341 |
|
252 |
|
|
CC.getSamplerModel().addSamplerChannelListListener(getHandler()); |
253 |
iliev |
1737 |
|
254 |
|
|
installGuiListener(); |
255 |
iliev |
912 |
} |
256 |
|
|
|
257 |
iliev |
1737 |
private static void |
258 |
|
|
installGuiListener() { |
259 |
|
|
if(guiListener != null) return; |
260 |
|
|
|
261 |
|
|
guiListener = new ActionListener() { |
262 |
|
|
public void |
263 |
|
|
actionPerformed(ActionEvent e) { |
264 |
|
|
mouseMoved(); |
265 |
|
|
} |
266 |
|
|
}; |
267 |
|
|
|
268 |
iliev |
2288 |
((MainFrame)SHF.getMainFrame()).getGuiTimer().addActionListener(guiListener); |
269 |
iliev |
1737 |
} |
270 |
|
|
|
271 |
iliev |
1467 |
private void |
272 |
iliev |
1737 |
mouseEntered() { |
273 |
|
|
viewTracker.mouseEntered(); |
274 |
|
|
} |
275 |
|
|
|
276 |
|
|
private void |
277 |
|
|
mouseExited() { |
278 |
|
|
viewTracker.mouseExited(); |
279 |
|
|
} |
280 |
|
|
|
281 |
|
|
private void |
282 |
iliev |
1467 |
ensureChannelIsVisible() { |
283 |
|
|
Container p = getParent(); |
284 |
|
|
JScrollPane sp = null; |
285 |
|
|
while(p != null) { |
286 |
|
|
if(p instanceof JScrollPane) { |
287 |
|
|
sp = (JScrollPane)p; |
288 |
|
|
break; |
289 |
|
|
} |
290 |
|
|
p = p.getParent(); |
291 |
|
|
} |
292 |
|
|
if(sp == null) return; |
293 |
|
|
int h = sp.getViewport().getView().getHeight(); |
294 |
|
|
sp.getViewport().scrollRectToVisible(new Rectangle(0, h - 2, 1, 1)); |
295 |
|
|
} |
296 |
|
|
|
297 |
iliev |
912 |
/** |
298 |
|
|
* Determines whether the channel is selected. |
299 |
|
|
* @return <code>true</code> if the channel is selected, <code>false</code> otherwise. |
300 |
|
|
*/ |
301 |
iliev |
1785 |
@Override |
302 |
|
|
public boolean |
303 |
|
|
isSelected() { return selected; } |
304 |
iliev |
912 |
|
305 |
|
|
/** |
306 |
|
|
* Sets the selection state of this channel. |
307 |
|
|
* This method is invoked when the selection state of the channel has changed. |
308 |
|
|
* @param select Specifies the new selection state of this channel; |
309 |
|
|
* <code>true</code> to select the channel, <code>false</code> otherwise. |
310 |
|
|
*/ |
311 |
iliev |
1785 |
@Override |
312 |
iliev |
912 |
public void |
313 |
|
|
setSelected(boolean select) { |
314 |
iliev |
1818 |
if(selected == select) return; |
315 |
iliev |
912 |
selected = select; |
316 |
iliev |
1818 |
repaint(); |
317 |
iliev |
912 |
} |
318 |
|
|
|
319 |
|
|
/** Shows the channel properties. */ |
320 |
|
|
public void |
321 |
iliev |
1285 |
expandChannel() { expandChannel(optionsPane.isAnimated()); } |
322 |
iliev |
912 |
|
323 |
iliev |
1285 |
/** Shows the channel properties. */ |
324 |
|
|
public void |
325 |
|
|
expandChannel(boolean animated) { |
326 |
|
|
boolean b = optionsPane.isAnimated(); |
327 |
|
|
optionsPane.setAnimated(animated); |
328 |
iliev |
1734 |
viewTracker.getCurrentView().expandChannel(); |
329 |
iliev |
1285 |
optionsPane.setAnimated(b); |
330 |
|
|
} |
331 |
iliev |
912 |
|
332 |
|
|
/** |
333 |
|
|
* Updates the channel settings. This method is invoked when changes to the |
334 |
|
|
* channel were made. |
335 |
|
|
*/ |
336 |
|
|
private void |
337 |
|
|
updateChannelInfo() { |
338 |
iliev |
1734 |
viewTracker.getCurrentView().updateChannelInfo(); |
339 |
iliev |
912 |
} |
340 |
|
|
|
341 |
iliev |
1732 |
public void |
342 |
|
|
loadInstrument() { |
343 |
iliev |
2288 |
JSInstrumentChooser dlg = FantasiaUtils.createInstrumentChooser(SHF.getMainFrame()); |
344 |
iliev |
1732 |
dlg.setVisible(true); |
345 |
|
|
|
346 |
|
|
if(!dlg.isCancelled()) { |
347 |
|
|
SamplerChannelModel m = getModel(); |
348 |
|
|
m.loadBackendInstrument(dlg.getInstrumentFile(), dlg.getInstrumentIndex()); |
349 |
|
|
} |
350 |
|
|
} |
351 |
|
|
|
352 |
iliev |
1734 |
public void |
353 |
|
|
fallbackToOriginalView() { |
354 |
|
|
viewTracker.fallbackToOriginalView(); |
355 |
|
|
} |
356 |
|
|
|
357 |
|
|
public boolean |
358 |
|
|
isUsingOriginalView() { |
359 |
|
|
return viewTracker.isUsingOriginalView(); |
360 |
|
|
} |
361 |
|
|
|
362 |
iliev |
1341 |
protected void |
363 |
|
|
onDestroy() { |
364 |
|
|
CC.getSamplerModel().removeSamplerChannelListListener(getHandler()); |
365 |
iliev |
1730 |
preferences().removePropertyChangeListener(ANIMATED, animatedPorpetyListener); |
366 |
iliev |
1743 |
if(fxSendsDlg != null) fxSendsDlg.dispose(); |
367 |
iliev |
1734 |
viewTracker.onDestroy(); |
368 |
iliev |
1341 |
} |
369 |
iliev |
1730 |
|
370 |
|
|
public void |
371 |
|
|
remove() { |
372 |
|
|
if(!mainPane.isAnimated()) { |
373 |
|
|
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
374 |
|
|
return; |
375 |
|
|
} |
376 |
|
|
|
377 |
|
|
String s = JXCollapsiblePane.ANIMATION_STATE_KEY; |
378 |
|
|
mainPane.addPropertyChangeListener(s, getHandler()); |
379 |
|
|
mainPane.setCollapsed(true); |
380 |
|
|
} |
381 |
iliev |
1341 |
|
382 |
iliev |
1730 |
public void |
383 |
|
|
showOptionsPane(boolean show) { optionsPane.showOptionsPane(show); } |
384 |
|
|
|
385 |
iliev |
1732 |
public void |
386 |
|
|
showFxSendsDialog() { |
387 |
|
|
if(fxSendsDlg != null && fxSendsDlg.isVisible()) { |
388 |
|
|
fxSendsDlg.toFront(); |
389 |
|
|
return; |
390 |
|
|
} |
391 |
iliev |
1743 |
|
392 |
|
|
fxSendsDlg = new JSFxSendsDlg(new FxSendsPane(getModel())); |
393 |
iliev |
1732 |
fxSendsDlg.setVisible(true); |
394 |
|
|
} |
395 |
|
|
|
396 |
iliev |
912 |
private final EventHandler eventHandler = new EventHandler(); |
397 |
|
|
|
398 |
|
|
private EventHandler |
399 |
|
|
getHandler() { return eventHandler; } |
400 |
|
|
|
401 |
iliev |
1730 |
private class EventHandler implements SamplerChannelListener, |
402 |
|
|
SamplerChannelListListener, PropertyChangeListener { |
403 |
iliev |
912 |
/** |
404 |
|
|
* Invoked when changes are made to a sampler channel. |
405 |
|
|
* @param e A <code>SamplerChannelEvent</code> instance |
406 |
|
|
* containing event information. |
407 |
|
|
*/ |
408 |
iliev |
1785 |
@Override |
409 |
iliev |
912 |
public void |
410 |
|
|
channelChanged(SamplerChannelEvent e) { updateChannelInfo(); } |
411 |
|
|
|
412 |
|
|
/** |
413 |
|
|
* Invoked when the number of active disk streams has changed. |
414 |
|
|
* @param e A <code>SamplerChannelEvent</code> instance |
415 |
|
|
* containing event information. |
416 |
|
|
*/ |
417 |
iliev |
1785 |
@Override |
418 |
iliev |
912 |
public void |
419 |
|
|
streamCountChanged(SamplerChannelEvent e) { |
420 |
iliev |
1734 |
viewTracker.getCurrentView().updateStreamCount(getModel().getStreamCount()); |
421 |
iliev |
912 |
} |
422 |
|
|
|
423 |
|
|
/** |
424 |
|
|
* Invoked when the number of active voices has changed. |
425 |
|
|
* @param e A <code>SamplerChannelEvent</code> instance |
426 |
|
|
* containing event information. |
427 |
|
|
*/ |
428 |
iliev |
1785 |
@Override |
429 |
iliev |
912 |
public void |
430 |
|
|
voiceCountChanged(SamplerChannelEvent e) { |
431 |
iliev |
1734 |
viewTracker.getCurrentView().updateVoiceCount(getModel().getVoiceCount()); |
432 |
iliev |
912 |
} |
433 |
iliev |
1341 |
|
434 |
|
|
/** |
435 |
|
|
* Invoked when a new sampler channel is created. |
436 |
|
|
* @param e A <code>SamplerChannelListEvent</code> |
437 |
|
|
* instance providing the event information. |
438 |
|
|
*/ |
439 |
iliev |
1785 |
@Override |
440 |
iliev |
1341 |
public void |
441 |
|
|
channelAdded(SamplerChannelListEvent e) { } |
442 |
|
|
|
443 |
|
|
/** |
444 |
|
|
* Invoked when a sampler channel is removed. |
445 |
|
|
* @param e A <code>SamplerChannelListEvent</code> |
446 |
|
|
* instance providing the event information. |
447 |
|
|
*/ |
448 |
iliev |
1785 |
@Override |
449 |
iliev |
1341 |
public void |
450 |
|
|
channelRemoved(SamplerChannelListEvent e) { |
451 |
|
|
// Some cleanup when the channel is removed. |
452 |
|
|
if(e.getChannelModel().getChannelId() == getChannelId()) { |
453 |
|
|
onDestroy(); |
454 |
|
|
} |
455 |
|
|
} |
456 |
iliev |
1285 |
|
457 |
iliev |
1785 |
@Override |
458 |
iliev |
912 |
public void |
459 |
iliev |
1285 |
propertyChange(PropertyChangeEvent e) { |
460 |
|
|
if(e.getNewValue() == "collapsed") { |
461 |
|
|
CC.getSamplerModel().removeBackendChannel(getChannelId()); |
462 |
|
|
} |
463 |
|
|
} |
464 |
iliev |
912 |
} |
465 |
iliev |
1732 |
|
466 |
iliev |
1767 |
public ViewTracker |
467 |
|
|
getViewTracker() { return viewTracker; } |
468 |
iliev |
1734 |
|
469 |
|
|
class ViewTracker extends MouseAdapter implements PropertyChangeListener { |
470 |
|
|
private ChannelView originalView; |
471 |
|
|
private ChannelView mouseOverView; |
472 |
|
|
private ChannelView currentView; |
473 |
|
|
|
474 |
iliev |
1737 |
private ChannelView.Type mouseOverViewType = null; |
475 |
iliev |
1734 |
|
476 |
|
|
ViewTracker() { |
477 |
|
|
|
478 |
iliev |
1737 |
|
479 |
iliev |
1734 |
updateMouseOverViewType(); |
480 |
|
|
|
481 |
|
|
String s = DIFFERENT_CHANNEL_VIEW_ON_MOUSE_OVER; |
482 |
|
|
preferences().addPropertyChangeListener(s, this); |
483 |
|
|
|
484 |
|
|
s = CHANNEL_VIEW_ON_MOUSE_OVER; |
485 |
|
|
preferences().addPropertyChangeListener(s, this); |
486 |
|
|
} |
487 |
|
|
|
488 |
|
|
public boolean |
489 |
|
|
isUsingOriginalView() { |
490 |
|
|
return currentView == originalView; |
491 |
|
|
} |
492 |
|
|
|
493 |
|
|
private void |
494 |
|
|
installListeners() { |
495 |
iliev |
1737 |
|
496 |
iliev |
1734 |
} |
497 |
|
|
|
498 |
|
|
private void |
499 |
|
|
uninstallListeners() { |
500 |
iliev |
1737 |
|
501 |
iliev |
1734 |
} |
502 |
|
|
|
503 |
|
|
private void |
504 |
|
|
updateMouseOverViewType() { |
505 |
|
|
if(mouseOverView != null) { |
506 |
|
|
mouseOverView.removeEnhancedMouseListener(this); |
507 |
|
|
} |
508 |
|
|
|
509 |
iliev |
1737 |
mouseOverView = null; |
510 |
|
|
|
511 |
iliev |
1734 |
boolean b; |
512 |
|
|
b = preferences().getBoolProperty(DIFFERENT_CHANNEL_VIEW_ON_MOUSE_OVER); |
513 |
|
|
if(!b) { |
514 |
iliev |
1737 |
mouseOverViewType = null; |
515 |
iliev |
1734 |
uninstallListeners(); |
516 |
|
|
return; |
517 |
|
|
} |
518 |
|
|
|
519 |
|
|
int i = preferences().getIntProperty(CHANNEL_VIEW_ON_MOUSE_OVER); |
520 |
|
|
|
521 |
|
|
switch(i) { |
522 |
iliev |
1737 |
case 0: mouseOverViewType = ChannelView.Type.SMALL; break; |
523 |
|
|
case 1: mouseOverViewType = ChannelView.Type.NORMAL; break; |
524 |
|
|
default:mouseOverViewType = null; |
525 |
iliev |
1734 |
} |
526 |
|
|
|
527 |
iliev |
1737 |
if(mouseOverViewType != null) { |
528 |
iliev |
1734 |
installListeners(); |
529 |
iliev |
1737 |
} |
530 |
|
|
} |
531 |
|
|
|
532 |
|
|
public ChannelView |
533 |
|
|
getMouseOverView() { |
534 |
|
|
if(mouseOverViewType == null) return null; |
535 |
|
|
|
536 |
|
|
if(mouseOverView == null) { |
537 |
|
|
Channel channel = Channel.this; |
538 |
|
|
|
539 |
|
|
switch(mouseOverViewType) { |
540 |
|
|
case SMALL: mouseOverView = new SmallChannelView(channel); break; |
541 |
|
|
case NORMAL: mouseOverView = new NormalChannelView(channel); break; |
542 |
|
|
default: mouseOverView = new NormalChannelView(channel); |
543 |
|
|
} |
544 |
|
|
|
545 |
iliev |
1734 |
mouseOverView.addEnhancedMouseListener(this); |
546 |
|
|
} |
547 |
iliev |
1737 |
|
548 |
|
|
return mouseOverView; |
549 |
iliev |
1734 |
} |
550 |
|
|
|
551 |
|
|
public ChannelView |
552 |
|
|
getCurrentView() { return currentView; } |
553 |
|
|
|
554 |
iliev |
1737 |
public ChannelView |
555 |
|
|
getOriginalView() { return originalView; } |
556 |
|
|
|
557 |
iliev |
1734 |
public void |
558 |
|
|
setView(ChannelView view) { |
559 |
|
|
setView(view, true); |
560 |
|
|
} |
561 |
|
|
|
562 |
|
|
public void |
563 |
|
|
setView(ChannelView view, boolean manual) { |
564 |
|
|
boolean selected = false; |
565 |
|
|
if(currentView != null) selected = currentView.isOptionsButtonSelected(); |
566 |
|
|
|
567 |
|
|
if(manual) { |
568 |
|
|
if(originalView != null) { |
569 |
|
|
originalView.removeEnhancedMouseListener(this); |
570 |
|
|
} |
571 |
|
|
|
572 |
|
|
if(originalView != currentView) destroyOriginalView(); |
573 |
|
|
if(currentView != null && currentView.getType() == view.getType()) { |
574 |
|
|
originalView = currentView; |
575 |
|
|
originalView.addEnhancedMouseListener(this); |
576 |
|
|
destroyView(view); |
577 |
|
|
return; |
578 |
|
|
} |
579 |
|
|
|
580 |
|
|
removeCurrentView(); |
581 |
|
|
|
582 |
|
|
originalView = view; |
583 |
|
|
originalView.addEnhancedMouseListener(this); |
584 |
|
|
currentView = view; |
585 |
|
|
} else { |
586 |
|
|
if(view.getType() == getCurrentView().getType()) { |
587 |
|
|
destroyView(view); |
588 |
|
|
return; |
589 |
|
|
} |
590 |
|
|
|
591 |
|
|
removeCurrentView(); |
592 |
|
|
currentView = view; |
593 |
|
|
} |
594 |
|
|
|
595 |
|
|
currentView.setOptionsButtonSelected(selected); |
596 |
|
|
|
597 |
|
|
updateView(); |
598 |
|
|
} |
599 |
|
|
|
600 |
|
|
private void |
601 |
|
|
updateView() { |
602 |
iliev |
1737 |
ChannelOptionsView view = getCurrentView().getChannelOptionsView(); |
603 |
|
|
if(view != null) optionsPane.setContentPane(view.getComponent()); |
604 |
iliev |
1734 |
|
605 |
|
|
updateChannelInfo(); |
606 |
|
|
|
607 |
|
|
mainPane.add(getCurrentView().getComponent()); |
608 |
|
|
mainPane.add(optionsPane); |
609 |
|
|
mainPane.validate(); |
610 |
|
|
mainPane.revalidate(); |
611 |
|
|
mainPane.repaint(); |
612 |
|
|
} |
613 |
|
|
|
614 |
|
|
public void |
615 |
|
|
fallbackToOriginalView() { |
616 |
|
|
if(currentView == originalView) return; |
617 |
|
|
|
618 |
|
|
boolean selected = false; |
619 |
|
|
if(currentView != null) selected = currentView.isOptionsButtonSelected(); |
620 |
|
|
|
621 |
|
|
removeCurrentView(); |
622 |
|
|
currentView = originalView; |
623 |
|
|
currentView.setOptionsButtonSelected(selected); |
624 |
|
|
|
625 |
|
|
updateView(); |
626 |
|
|
} |
627 |
|
|
|
628 |
|
|
private void |
629 |
|
|
removeCurrentView() { removeView(currentView); } |
630 |
|
|
|
631 |
|
|
private void |
632 |
|
|
destroyCurrentView() { destroyView(currentView); } |
633 |
|
|
|
634 |
|
|
private void |
635 |
|
|
removeOriginalView() { removeView(originalView); } |
636 |
|
|
|
637 |
|
|
private void |
638 |
|
|
destroyOriginalView() { destroyView(originalView); } |
639 |
|
|
|
640 |
|
|
private void |
641 |
|
|
removeView(ChannelView view) { |
642 |
|
|
if(view == null) return; |
643 |
|
|
|
644 |
|
|
mainPane.remove(view.getComponent()); |
645 |
|
|
mainPane.remove(optionsPane); |
646 |
|
|
|
647 |
|
|
destroyView(view); |
648 |
|
|
} |
649 |
|
|
|
650 |
|
|
private void |
651 |
|
|
destroyView(ChannelView view) { |
652 |
|
|
if(view == null) return; |
653 |
|
|
|
654 |
|
|
view.uninstallView(); |
655 |
|
|
|
656 |
|
|
view = null; |
657 |
|
|
} |
658 |
|
|
|
659 |
iliev |
1737 |
public boolean |
660 |
|
|
isMouseOverEnabled() { return mouseOverViewType != null; } |
661 |
|
|
|
662 |
iliev |
1734 |
private void |
663 |
|
|
mouseEntered() { |
664 |
iliev |
1737 |
if(!isMouseOverEnabled()) return; |
665 |
|
|
if(getCurrentView().getType() == getMouseOverView().getType()) return; |
666 |
iliev |
1734 |
|
667 |
|
|
JSChannel[] channels = CC.getMainFrame().getChannelsPane(0).getChannels(); |
668 |
|
|
for(JSChannel c : channels) { |
669 |
|
|
if(c == Channel.this) continue; |
670 |
|
|
|
671 |
|
|
Channel chn = (Channel)c; |
672 |
|
|
if(!(chn).isUsingOriginalView()) chn.fallbackToOriginalView(); |
673 |
|
|
} |
674 |
|
|
|
675 |
iliev |
1737 |
setView(getMouseOverView(), false); |
676 |
iliev |
1734 |
} |
677 |
|
|
|
678 |
|
|
private void |
679 |
|
|
mouseExited() { |
680 |
iliev |
1737 |
if(!isMouseOverEnabled()) return; |
681 |
iliev |
1734 |
if(getCurrentView().getType() == originalView.getType()) return; |
682 |
|
|
|
683 |
|
|
fallbackToOriginalView(); |
684 |
|
|
} |
685 |
|
|
|
686 |
iliev |
1785 |
@Override |
687 |
iliev |
1734 |
public void |
688 |
|
|
mouseEntered(MouseEvent e) { |
689 |
iliev |
1737 |
guiListener.actionPerformed(null); |
690 |
iliev |
1734 |
} |
691 |
|
|
|
692 |
iliev |
1785 |
@Override |
693 |
iliev |
1734 |
public void |
694 |
|
|
mouseExited(MouseEvent e) { |
695 |
iliev |
1737 |
guiListener.actionPerformed(null); |
696 |
iliev |
1734 |
} |
697 |
|
|
|
698 |
iliev |
1785 |
@Override |
699 |
iliev |
1734 |
public void |
700 |
|
|
mousePressed(MouseEvent e) { |
701 |
iliev |
1737 |
mousePressed = true; |
702 |
iliev |
1734 |
} |
703 |
|
|
|
704 |
iliev |
1785 |
@Override |
705 |
iliev |
1734 |
public void |
706 |
|
|
mouseReleased(MouseEvent e) { |
707 |
iliev |
1737 |
mousePressed = false; |
708 |
iliev |
1734 |
} |
709 |
|
|
|
710 |
|
|
public void |
711 |
|
|
onDestroy() { |
712 |
|
|
destroyCurrentView(); |
713 |
|
|
destroyOriginalView(); |
714 |
|
|
|
715 |
|
|
uninstallListeners(); |
716 |
|
|
|
717 |
|
|
if(currentView != null) { |
718 |
|
|
currentView.removeEnhancedMouseListener(this); |
719 |
|
|
} |
720 |
|
|
|
721 |
|
|
if(mouseOverView != null) { |
722 |
|
|
mouseOverView.removeEnhancedMouseListener(this); |
723 |
|
|
} |
724 |
|
|
|
725 |
|
|
String s = DIFFERENT_CHANNEL_VIEW_ON_MOUSE_OVER; |
726 |
|
|
preferences().removePropertyChangeListener(s, this); |
727 |
|
|
|
728 |
|
|
s = CHANNEL_VIEW_ON_MOUSE_OVER; |
729 |
|
|
preferences().removePropertyChangeListener(s, this); |
730 |
|
|
} |
731 |
|
|
|
732 |
iliev |
1785 |
@Override |
733 |
iliev |
1734 |
public void |
734 |
|
|
propertyChange(PropertyChangeEvent e) { |
735 |
|
|
updateMouseOverViewType(); |
736 |
|
|
} |
737 |
|
|
} |
738 |
|
|
|
739 |
iliev |
1732 |
class EditInstrumentAction extends AbstractAction implements SamplerChannelListener { |
740 |
|
|
EditInstrumentAction() { |
741 |
|
|
super(i18n.getMenuLabel("channels.editInstrument")); |
742 |
|
|
channelChanged(null); |
743 |
|
|
getModel().addSamplerChannelListener(this); |
744 |
|
|
} |
745 |
|
|
|
746 |
iliev |
1785 |
@Override |
747 |
iliev |
1732 |
public void |
748 |
|
|
actionPerformed(ActionEvent e) { |
749 |
|
|
CC.getSamplerModel().editBackendInstrument(getChannelId()); |
750 |
|
|
} |
751 |
|
|
|
752 |
iliev |
1785 |
@Override |
753 |
iliev |
1732 |
public void |
754 |
|
|
channelChanged(SamplerChannelEvent e) { |
755 |
|
|
boolean b = getChannelInfo().getInstrumentStatus() == 100; |
756 |
|
|
setEnabled(b); |
757 |
|
|
} |
758 |
|
|
|
759 |
iliev |
1785 |
@Override |
760 |
iliev |
1732 |
public void |
761 |
|
|
streamCountChanged(SamplerChannelEvent e) { } |
762 |
|
|
|
763 |
iliev |
1785 |
@Override |
764 |
iliev |
1732 |
public void |
765 |
|
|
voiceCountChanged(SamplerChannelEvent e) { } |
766 |
|
|
} |
767 |
|
|
|
768 |
|
|
class FxSendsAction extends AbstractAction { |
769 |
|
|
FxSendsAction() { |
770 |
|
|
super(i18n.getMenuLabel("channels.fxSends")); |
771 |
|
|
} |
772 |
|
|
|
773 |
iliev |
1785 |
@Override |
774 |
iliev |
1732 |
public void |
775 |
|
|
actionPerformed(ActionEvent e) { |
776 |
|
|
showFxSendsDialog(); |
777 |
|
|
} |
778 |
|
|
} |
779 |
|
|
|
780 |
|
|
class ChannelRoutingAction extends AbstractAction implements SamplerChannelListener { |
781 |
|
|
ChannelRoutingAction() { |
782 |
|
|
super(i18n.getMenuLabel("channels.channelRouting")); |
783 |
|
|
channelChanged(null); |
784 |
|
|
getModel().addSamplerChannelListener(this); |
785 |
|
|
} |
786 |
|
|
|
787 |
iliev |
1785 |
@Override |
788 |
iliev |
1732 |
public void |
789 |
|
|
actionPerformed(ActionEvent e) { |
790 |
|
|
SamplerChannel c = getChannelInfo(); |
791 |
iliev |
2288 |
new JSChannelOutputRoutingDlg(SHF.getMainFrame(), c).setVisible(true); |
792 |
iliev |
1732 |
} |
793 |
|
|
|
794 |
iliev |
1785 |
@Override |
795 |
iliev |
1732 |
public void |
796 |
|
|
channelChanged(SamplerChannelEvent e) { |
797 |
|
|
boolean b = getChannelInfo().getAudioOutputDevice() != -1; |
798 |
|
|
setEnabled(b); |
799 |
|
|
} |
800 |
|
|
|
801 |
iliev |
1785 |
@Override |
802 |
iliev |
1732 |
public void |
803 |
|
|
streamCountChanged(SamplerChannelEvent e) { } |
804 |
|
|
|
805 |
iliev |
1785 |
@Override |
806 |
iliev |
1732 |
public void |
807 |
|
|
voiceCountChanged(SamplerChannelEvent e) { } |
808 |
|
|
} |
809 |
|
|
|
810 |
|
|
public ContextMenu |
811 |
|
|
getContextMenu() { return contextMenu; } |
812 |
|
|
|
813 |
|
|
class ContextMenu extends MouseAdapter { |
814 |
iliev |
1737 |
private JPopupMenu menu = null; |
815 |
iliev |
1732 |
|
816 |
|
|
ContextMenu() { |
817 |
iliev |
1737 |
|
818 |
|
|
} |
819 |
|
|
|
820 |
|
|
private void |
821 |
|
|
createMenu() { |
822 |
|
|
menu = new JPopupMenu(); |
823 |
iliev |
1732 |
menu.add(new JMenuItem(new EditInstrumentAction())); |
824 |
|
|
menu.addSeparator(); |
825 |
|
|
|
826 |
iliev |
1818 |
MenuManager.ChannelViewGroup group; |
827 |
|
|
group = new MenuManager.ChannelViewGroup(true, true); |
828 |
|
|
MenuManager.getMenuManager().registerChannelViewGroup(group); |
829 |
iliev |
1732 |
|
830 |
iliev |
1818 |
for(JMenuItem mi : group.getMenuItems()) menu.add(mi); |
831 |
iliev |
1732 |
|
832 |
iliev |
1818 |
menu.addSeparator(); |
833 |
iliev |
1732 |
|
834 |
iliev |
1818 |
menu.add(new JMenuItem(a4n.moveChannelsOnTop)); |
835 |
|
|
menu.add(new JMenuItem(a4n.moveChannelsUp)); |
836 |
|
|
menu.add(new JMenuItem(a4n.moveChannelsDown)); |
837 |
|
|
menu.add(new JMenuItem(a4n.moveChannelsAtBottom)); |
838 |
|
|
|
839 |
|
|
menu.add(new MainFrame.ToPanelMenu()); |
840 |
|
|
|
841 |
iliev |
1732 |
menu.addSeparator(); |
842 |
iliev |
1818 |
|
843 |
iliev |
1732 |
menu.add(new JMenuItem(new FxSendsAction())); |
844 |
|
|
menu.add(new JMenuItem(new ChannelRoutingAction())); |
845 |
|
|
} |
846 |
|
|
|
847 |
iliev |
1737 |
private JPopupMenu |
848 |
|
|
getMenu() { |
849 |
|
|
if(menu == null) createMenu(); |
850 |
|
|
return menu; |
851 |
|
|
} |
852 |
|
|
|
853 |
iliev |
1785 |
@Override |
854 |
iliev |
1732 |
public void |
855 |
|
|
mousePressed(MouseEvent e) { |
856 |
|
|
if(e.isPopupTrigger()) show(e); |
857 |
|
|
} |
858 |
|
|
|
859 |
iliev |
1785 |
@Override |
860 |
iliev |
1732 |
public void |
861 |
|
|
mouseReleased(MouseEvent e) { |
862 |
|
|
if(e.isPopupTrigger()) show(e); |
863 |
|
|
} |
864 |
|
|
|
865 |
|
|
void |
866 |
|
|
show(MouseEvent e) { |
867 |
iliev |
1737 |
getMenu().show(e.getComponent(), e.getX(), e.getY()); |
868 |
iliev |
1732 |
} |
869 |
|
|
} |
870 |
|
|
|
871 |
|
|
class FxSendsPane extends JSFxSendsPane { |
872 |
|
|
FxSendsPane(SamplerChannelModel model) { |
873 |
|
|
super(model); |
874 |
|
|
|
875 |
|
|
actionAddFxSend.putValue(Action.SMALL_ICON, Res.iconNew16); |
876 |
|
|
actionRemoveFxSend.putValue(Action.SMALL_ICON, Res.iconDelete16); |
877 |
|
|
} |
878 |
|
|
|
879 |
iliev |
1785 |
@Override |
880 |
iliev |
1732 |
protected JToolBar |
881 |
|
|
createToolBar() { |
882 |
|
|
JToolBar tb = new JToolBar(); |
883 |
|
|
Dimension d = new Dimension(Short.MAX_VALUE, tb.getPreferredSize().height); |
884 |
|
|
tb.setMaximumSize(d); |
885 |
|
|
tb.setFloatable(false); |
886 |
|
|
tb.setAlignmentX(JPanel.RIGHT_ALIGNMENT); |
887 |
|
|
|
888 |
|
|
tb.add(new ToolbarButton(actionAddFxSend)); |
889 |
|
|
tb.add(new ToolbarButton(actionRemoveFxSend)); |
890 |
|
|
|
891 |
|
|
return tb; |
892 |
|
|
} |
893 |
|
|
} |
894 |
|
|
|
895 |
|
|
public static class StreamVoiceCountPane extends JPanel { |
896 |
|
|
private final Channel channel; |
897 |
|
|
|
898 |
|
|
private final JLabel lStreams = createScreenLabel(" --"); |
899 |
|
|
private final JLabel lSlash = createScreenLabel("/"); |
900 |
|
|
private final JLabel lVoices = createScreenLabel("-- "); |
901 |
|
|
|
902 |
|
|
public |
903 |
|
|
StreamVoiceCountPane(Channel channel) { |
904 |
|
|
this.channel = channel; |
905 |
|
|
|
906 |
|
|
setOpaque(false); |
907 |
|
|
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
908 |
|
|
lStreams.setFont(Res.fontScreenMono); |
909 |
|
|
lStreams.setHorizontalAlignment(JLabel.RIGHT); |
910 |
|
|
lStreams.setToolTipText(i18n.getLabel("Channel.streamVoiceCount")); |
911 |
|
|
|
912 |
|
|
Dimension d = lStreams.getPreferredSize(); |
913 |
|
|
lStreams.setMinimumSize(d); |
914 |
|
|
lStreams.setPreferredSize(d); |
915 |
|
|
lStreams.setMaximumSize(d); |
916 |
|
|
add(lStreams); |
917 |
|
|
|
918 |
|
|
lSlash.setFont(Res.fontScreenMono); |
919 |
|
|
lSlash.setToolTipText(i18n.getLabel("Channel.streamVoiceCount")); |
920 |
|
|
add(lSlash); |
921 |
|
|
|
922 |
|
|
lVoices.setFont(Res.fontScreenMono); |
923 |
|
|
lVoices.setToolTipText(i18n.getLabel("Channel.streamVoiceCount")); |
924 |
|
|
|
925 |
|
|
d = lStreams.getPreferredSize(); |
926 |
|
|
lVoices.setMinimumSize(d); |
927 |
|
|
lVoices.setPreferredSize(d); |
928 |
|
|
lVoices.setMaximumSize(d); |
929 |
|
|
add(lVoices); |
930 |
|
|
|
931 |
|
|
lStreams.addMouseListener(channel.getContextMenu()); |
932 |
|
|
lSlash.addMouseListener(channel.getContextMenu()); |
933 |
|
|
lVoices.addMouseListener(channel.getContextMenu()); |
934 |
|
|
} |
935 |
|
|
|
936 |
|
|
public void |
937 |
|
|
updateStreamCount(int count) { |
938 |
|
|
lStreams.setText(count == 0 ? " --" : String.valueOf(count)); |
939 |
|
|
} |
940 |
|
|
|
941 |
|
|
public void |
942 |
|
|
updateVoiceCount(int count) { |
943 |
|
|
lVoices.setText(count == 0 ? "-- " : String.valueOf(count)); |
944 |
|
|
} |
945 |
|
|
} |
946 |
|
|
|
947 |
|
|
public static class VolumePane extends JPanel { |
948 |
|
|
private final Channel channel; |
949 |
|
|
private final JButton btnVolume = createScreenButton(""); |
950 |
|
|
private JSVolumeEditorPopup popupVolume; |
951 |
|
|
|
952 |
|
|
private static NumberFormat numberFormat = NumberFormat.getInstance(); |
953 |
|
|
static { numberFormat.setMaximumFractionDigits(1); } |
954 |
|
|
|
955 |
|
|
public |
956 |
|
|
VolumePane(final Channel channel) { |
957 |
|
|
this.channel = channel; |
958 |
|
|
setOpaque(false); |
959 |
|
|
setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); |
960 |
|
|
|
961 |
|
|
btnVolume.setIcon(Res.iconVolume14); |
962 |
|
|
btnVolume.setIconTextGap(2); |
963 |
|
|
btnVolume.setAlignmentX(RIGHT_ALIGNMENT); |
964 |
|
|
btnVolume.setHorizontalAlignment(btnVolume.LEFT); |
965 |
|
|
updateVolumeInfo(100); |
966 |
|
|
Dimension d = btnVolume.getPreferredSize(); |
967 |
|
|
d.width = 57; |
968 |
|
|
btnVolume.setPreferredSize(d); |
969 |
|
|
btnVolume.setMinimumSize(d); |
970 |
|
|
|
971 |
|
|
add(btnVolume); |
972 |
|
|
|
973 |
|
|
btnVolume.addActionListener(new ActionListener() { |
974 |
|
|
public void |
975 |
|
|
actionPerformed(ActionEvent e) { |
976 |
|
|
if(popupVolume.isVisible()) { |
977 |
|
|
popupVolume.commit(); |
978 |
|
|
popupVolume.hide(); |
979 |
|
|
} else { |
980 |
|
|
float vol = channel.getModel().getChannelInfo().getVolume(); |
981 |
|
|
popupVolume.setCurrentVolume(vol); |
982 |
|
|
popupVolume.show(); |
983 |
|
|
} |
984 |
|
|
} |
985 |
|
|
}); |
986 |
|
|
|
987 |
|
|
popupVolume = new JSVolumeEditorPopup(btnVolume, VolumeType.CHANNEL); |
988 |
|
|
|
989 |
|
|
popupVolume.addActionListener(new ActionListener() { |
990 |
|
|
public void |
991 |
|
|
actionPerformed(ActionEvent e) { |
992 |
|
|
channel.getModel().setBackendVolume(popupVolume.getVolumeFactor()); |
993 |
|
|
} |
994 |
|
|
}); |
995 |
|
|
|
996 |
|
|
btnVolume.addMouseListener(channel.getContextMenu()); |
997 |
|
|
} |
998 |
|
|
|
999 |
|
|
public void |
1000 |
|
|
updateVolumeInfo(int volume) { |
1001 |
|
|
if(CC.getViewConfig().isMeasurementUnitDecibel()) { |
1002 |
|
|
String s = numberFormat.format(HF.percentsToDecibels(volume)); |
1003 |
|
|
btnVolume.setText(s + "dB"); |
1004 |
|
|
} else { |
1005 |
|
|
btnVolume.setText(String.valueOf(volume) + "%"); |
1006 |
|
|
} |
1007 |
|
|
} |
1008 |
|
|
} |
1009 |
|
|
|
1010 |
|
|
public static class PowerButton extends PixmapToggleButton implements ActionListener { |
1011 |
|
|
private final Channel channel; |
1012 |
|
|
|
1013 |
|
|
PowerButton(Channel channel) { |
1014 |
|
|
this(channel, Res.gfxPowerOff, Res.gfxPowerOn); |
1015 |
|
|
} |
1016 |
|
|
|
1017 |
|
|
PowerButton(Channel channel, ImageIcon defaultIcon, ImageIcon selectedIcon) { |
1018 |
|
|
super(defaultIcon, selectedIcon); |
1019 |
|
|
|
1020 |
|
|
this.channel = channel; |
1021 |
|
|
|
1022 |
|
|
setSelected(true); |
1023 |
|
|
addActionListener(this); |
1024 |
|
|
setToolTipText(i18n.getButtonLabel("Channel.ttRemoveChannel")); |
1025 |
|
|
} |
1026 |
|
|
|
1027 |
iliev |
1785 |
@Override |
1028 |
iliev |
1732 |
public void |
1029 |
|
|
actionPerformed(ActionEvent e) { |
1030 |
|
|
boolean b = preferences().getBoolProperty(CONFIRM_CHANNEL_REMOVAL); |
1031 |
|
|
if(b) { |
1032 |
|
|
String s = i18n.getMessage("Channel.remove?", channel.getChannelId()); |
1033 |
iliev |
2288 |
if(!SHF.showYesNoDialog(channel, s)) { |
1034 |
iliev |
1732 |
setSelected(true); |
1035 |
|
|
return; |
1036 |
|
|
} |
1037 |
|
|
} |
1038 |
|
|
channel.remove(); |
1039 |
|
|
} |
1040 |
|
|
|
1041 |
iliev |
1785 |
@Override |
1042 |
iliev |
1732 |
public boolean |
1043 |
|
|
contains(int x, int y) { return (x - 11)*(x - 11) + (y - 11)*(y - 11) < 71; } |
1044 |
|
|
} |
1045 |
|
|
|
1046 |
iliev |
1737 |
public static class OptionsButton extends PixmapToggleButton |
1047 |
|
|
implements ActionListener, PropertyChangeListener { |
1048 |
|
|
|
1049 |
iliev |
1732 |
private final Channel channel; |
1050 |
|
|
|
1051 |
|
|
OptionsButton(Channel channel) { |
1052 |
|
|
super(Res.gfxOptionsOff, Res.gfxOptionsOn); |
1053 |
|
|
|
1054 |
|
|
this.channel = channel; |
1055 |
|
|
|
1056 |
|
|
setRolloverIcon(Res.gfxOptionsOffRO); |
1057 |
|
|
this.setRolloverSelectedIcon(Res.gfxOptionsOnRO); |
1058 |
|
|
addActionListener(this); |
1059 |
|
|
setToolTipText(i18n.getButtonLabel("Channel.ttShowOptions")); |
1060 |
|
|
} |
1061 |
|
|
|
1062 |
iliev |
1785 |
@Override |
1063 |
iliev |
1732 |
public void |
1064 |
|
|
actionPerformed(ActionEvent e) { |
1065 |
iliev |
1737 |
ChannelView view = channel.viewTracker.getCurrentView(); |
1066 |
|
|
|
1067 |
|
|
if(isSelected() && view.getChannelOptionsView() == null) { |
1068 |
|
|
view.installChannelOptionsView(); |
1069 |
|
|
JComponent c = view.getChannelOptionsView().getComponent(); |
1070 |
|
|
channel.optionsPane.setContentPane(c); |
1071 |
|
|
} |
1072 |
|
|
|
1073 |
iliev |
1732 |
channel.showOptionsPane(isSelected()); |
1074 |
|
|
|
1075 |
|
|
String s; |
1076 |
|
|
if(isSelected()) s = i18n.getButtonLabel("Channel.ttHideOptions"); |
1077 |
|
|
else s = i18n.getButtonLabel("Channel.ttShowOptions"); |
1078 |
|
|
|
1079 |
|
|
setToolTipText(s); |
1080 |
iliev |
1737 |
|
1081 |
|
|
s = JXCollapsiblePane.ANIMATION_STATE_KEY; |
1082 |
|
|
channel.optionsPane.addPropertyChangeListener(s, this); |
1083 |
iliev |
1732 |
} |
1084 |
|
|
|
1085 |
iliev |
1785 |
@Override |
1086 |
iliev |
1737 |
public void |
1087 |
|
|
propertyChange(PropertyChangeEvent e) { |
1088 |
|
|
if(e.getNewValue() == "collapsed") { |
1089 |
|
|
ChannelView view = channel.viewTracker.getCurrentView(); |
1090 |
|
|
view.uninstallChannelOptionsView(); |
1091 |
|
|
channel.optionsPane.setContentPane(new JPanel()); |
1092 |
|
|
} |
1093 |
|
|
} |
1094 |
|
|
|
1095 |
|
|
public void |
1096 |
|
|
onDestroy() { |
1097 |
|
|
String s = JXCollapsiblePane.ANIMATION_STATE_KEY; |
1098 |
|
|
channel.optionsPane.removePropertyChangeListener(s, this); |
1099 |
|
|
} |
1100 |
|
|
|
1101 |
iliev |
1785 |
@Override |
1102 |
iliev |
1732 |
public boolean |
1103 |
|
|
contains(int x, int y) { return super.contains(x, y) & y < 13; } |
1104 |
|
|
} |
1105 |
iliev |
912 |
} |
1106 |
|
|
|
1107 |
iliev |
1730 |
class ChannelOptionsPane extends JXCollapsiblePane { |
1108 |
|
|
ChannelOptionsPane() { |
1109 |
iliev |
1285 |
setAnimated(false); |
1110 |
|
|
setCollapsed(true); |
1111 |
|
|
setAnimated(preferences().getBoolProperty(ANIMATED)); |
1112 |
|
|
|
1113 |
|
|
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
1114 |
|
|
public void |
1115 |
|
|
propertyChange(PropertyChangeEvent e) { |
1116 |
|
|
setAnimated(preferences().getBoolProperty(ANIMATED)); |
1117 |
|
|
} |
1118 |
|
|
}); |
1119 |
iliev |
912 |
} |
1120 |
|
|
|
1121 |
iliev |
1730 |
public void |
1122 |
|
|
showOptionsPane(boolean show) { setCollapsed(!show); } |
1123 |
iliev |
912 |
} |