/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/RightSidePane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/RightSidePane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1778 - (show annotations) (download)
Sun Sep 28 20:38:36 2008 UTC (15 years, 7 months ago) by iliev
File size: 4245 byte(s)
* Fantasia: Improved look and feel
* Fantasia: Added buttons for increasing/decreasing the key number
  of the MIDI keyboard (Ctrl+Up Arrow/Ctrl+Down Arrow)
* Fantasia: Added buttons for scrolling left/right on the MIDI keyboard
  (Ctrl+Left Arrow/Ctrl+Right Arrow)
* Added key bindings for triggering MIDI notes using the computer keyboard
  (from a to ' for the white keys and from 0 to 7 for changing the octaves)
* Notes are now triggered when dragging the mouse over the MIDI keyboard

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5 *
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 import java.awt.BorderLayout;
26 import java.awt.Dimension;
27
28 import java.beans.PropertyChangeEvent;
29 import java.beans.PropertyChangeListener;
30
31 import javax.swing.BorderFactory;
32 import javax.swing.JPanel;
33 import javax.swing.JScrollPane;
34
35 import javax.swing.event.ChangeEvent;
36 import javax.swing.event.ChangeListener;
37
38 import net.sf.juife.JuifeUtils;
39
40 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
41 import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
42
43
44 /**
45 *
46 * @author Grigor Iliev
47 */
48 public class RightSidePane extends FantasiaPanel {
49 private FantasiaTabbedPane tabbedPane = new FantasiaTabbedPane();
50 private InstrumentsDbPane instrumentsDbPane = null;
51 private final DevicesPane devicesPane = new DevicesPane();
52 private final JScrollPane spDevicesPane = new JScrollPane();
53
54 private final JPanel mainPane = new FantasiaSubPanel(false, true);
55
56 /**
57 * Creates a new instance of <code>RightSidePane</code>
58 */
59 public
60 RightSidePane() {
61 setOpaque(false);
62 setLayout(new BorderLayout());
63
64 tabbedPane.getMainPane().setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
65
66 spDevicesPane.setOpaque(false);
67 spDevicesPane.getViewport().setOpaque(false);
68 spDevicesPane.setViewportView(devicesPane);
69 spDevicesPane.setBorder(BorderFactory.createEmptyBorder());
70 int h = spDevicesPane.getMinimumSize().height;
71 spDevicesPane.setMinimumSize(new Dimension(200, h));
72
73 final String s = "rightSidePane.showInstrumentsDb";
74 setTabbedView(preferences().getBoolProperty(s));
75
76 preferences().addPropertyChangeListener(s, getHandler());
77 setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 3));
78 }
79
80 public DevicesPane
81 getDevicesPane() { return devicesPane; }
82
83 private void
84 setTabbedView(boolean b) {
85 remove(mainPane);
86 remove(tabbedPane);
87
88 tabbedPane.removeChangeListener(getHandler());
89 tabbedPane.removeAll();
90
91 if(b) {
92 if(instrumentsDbPane == null) instrumentsDbPane = new InstrumentsDbPane();
93
94 FantasiaTabbedPane tp = tabbedPane;
95 tp.addTab(i18n.getLabel("RightSidePane.tabDevices"), spDevicesPane);
96 tp.addTab(i18n.getLabel("RightSidePane.tabInstrumentsDb"), instrumentsDbPane);
97 tp.addChangeListener(getHandler());
98
99 Dimension d = JuifeUtils.getUnionSize(tp.getTabButton(0), tp.getTabButton(1));
100 tp.getTabButton(0).setPreferredSize(d);
101 tp.getTabButton(1).setPreferredSize(d);
102 tp.getTabButton(0).setMinimumSize(d);
103 tp.getTabButton(1).setMinimumSize(d);
104
105 add(tabbedPane);
106
107 int i = preferences().getIntProperty("rightSidePane.tabIndex", 0);
108 if(tabbedPane.getTabCount() > i) tabbedPane.setSelectedIndex(i);
109 } else {
110 mainPane.add(spDevicesPane);
111 add(mainPane);
112 }
113
114 validate();
115 }
116
117 protected void
118 savePreferences() {
119 if(instrumentsDbPane != null) instrumentsDbPane.savePreferences();
120 }
121
122 private final EventHandler eventHandler = new EventHandler();
123
124 private EventHandler
125 getHandler() { return eventHandler; }
126
127 private class EventHandler implements ChangeListener, PropertyChangeListener {
128 @Override
129 public void
130 stateChanged(ChangeEvent e) {
131 int idx = tabbedPane.getSelectedIndex();
132 if(idx == -1) return;
133 preferences().setIntProperty("rightSidePane.tabIndex", idx);
134 }
135
136 @Override
137 public void
138 propertyChange(PropertyChangeEvent e) {
139 setTabbedView(preferences().getBoolProperty("rightSidePane.showInstrumentsDb"));
140 }
141 }
142 }

  ViewVC Help
Powered by ViewVC