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

Annotation of /jsampler/trunk/src/org/jsampler/view/fantasia/StandardBar.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1864 - (hide annotations) (download)
Sat Mar 14 20:44:58 2009 UTC (15 years, 1 month ago) by iliev
File size: 6081 byte(s)
* Fixed bug in the parameter table when editing
  string list parameters with no possibilities
* Mac OS integration, work in progress:
* ant: added new target build-fantasia-osx
* Moved the menu bar on top of the screen
* Use custom application icon
* Register LSCP scripts to be opened with Fantasia
* Changed shortcut keys (use command key instead of ctrl key)

1 iliev 1286 /*
2     * JSampler - a java front-end for LinuxSampler
3     *
4 iliev 1864 * Copyright (C) 2005-2009 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     import java.awt.BorderLayout;
26 iliev 1778 import java.awt.Color;
27     import java.awt.Composite;
28 iliev 1286 import java.awt.Dimension;
29     import java.awt.Graphics;
30 iliev 1778 import java.awt.Graphics2D;
31     import java.awt.Paint;
32 iliev 1286
33 iliev 1778 import java.awt.event.ActionEvent;
34     import java.awt.event.ActionListener;
35    
36 iliev 1286 import javax.swing.Action;
37     import javax.swing.BorderFactory;
38     import javax.swing.Box;
39     import javax.swing.BoxLayout;
40     import javax.swing.JLabel;
41     import javax.swing.JPanel;
42 iliev 1778 import javax.swing.JToggleButton;
43 iliev 1286 import javax.swing.JToolBar;
44    
45 iliev 1778 import org.jsampler.CC;
46 iliev 1785 import org.jsampler.view.fantasia.basic.*;
47 iliev 1778
48 iliev 1286 import static org.jsampler.view.fantasia.A4n.a4n;
49    
50     /**
51     *
52     * @author Grigor Iliev
53     */
54 iliev 1778 public class StandardBar extends JPanel {
55 iliev 1286 private final JToolBar toolbar = new JToolBar();
56 iliev 1778 private final JPanel mainPane;
57 iliev 1286
58     private final ToolbarButton btnSamplerInfo = new ToolbarButton(a4n.samplerInfo);
59     private final ToolbarButton btnLoadSession = new ToolbarButton(a4n.loadScript);
60     private final ToolbarButton btnExportSession = new ToolbarButton(a4n.exportSamplerConfig);
61     private final ToolbarButton btnRefresh = new ToolbarButton(a4n.refresh);
62     private final ToolbarButton btnResetSampler = new ToolbarButton(a4n.resetSampler);
63    
64 iliev 1778 protected final ToggleButton btnMidiKeyboard = new ToggleButton();
65 iliev 1286 private final ToolbarButton btnLSConsole = new ToolbarButton(a4n.windowLSConsole);
66     private final ToolbarButton btnInstrumentsDb = new ToolbarButton(a4n.windowInstrumentsDb);
67    
68     private final ToolbarButton btnPreferences = new ToolbarButton(a4n.editPreferences);
69    
70 iliev 1323 private final JLabel lLogo = new JLabel(Res.gfxFantasiaLogo);
71 iliev 1864
72     private final Boolean screenMenuEnabled;
73 iliev 1323
74 iliev 1286 /** Creates a new instance of <code>StandardBar</code> */
75     public
76     StandardBar() {
77 iliev 1864 screenMenuEnabled = CC.getViewConfig().isUsingScreenMenuBar();
78 iliev 1778 //super(Res.gfxToolBarBg);
79     //setPixmapInsets(new Insets(0, 6, 6, 6));
80 iliev 1286
81     setLayout(new BorderLayout());
82     setOpaque(false);
83 iliev 1864
84     int h = screenMenuEnabled ? 56 : 51;
85     Dimension d = new Dimension(60, h);
86 iliev 1286 setMinimumSize(d);
87     setPreferredSize(d);
88 iliev 1778 d = new Dimension(Short.MAX_VALUE, 51);
89 iliev 1286 setMaximumSize(d);
90 iliev 1864 int top = screenMenuEnabled ? 5 : 0;
91     setBorder(BorderFactory.createEmptyBorder(top, 5, 2, 5));
92 iliev 1286
93    
94 iliev 1778 //mainPane = new PixmapPane(Res.gfxToolBar);
95     //mainPane.setPixmapInsets(Res.insetsToolBar);
96     mainPane = new MainPane();
97     mainPane.setOpaque(false);
98 iliev 1323 mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.X_AXIS));
99 iliev 1286
100     toolbar.setOpaque(false);
101     toolbar.setFloatable(false);
102    
103     toolbar.add(btnSamplerInfo);
104     toolbar.addSeparator();
105     toolbar.add(btnLoadSession);
106     toolbar.add(btnExportSession);
107     toolbar.add(btnRefresh);
108     toolbar.add(btnResetSampler);
109     toolbar.addSeparator();
110 iliev 1778 btnMidiKeyboard.setIcon(Res.iconMidiKeyboard32);
111     btnMidiKeyboard.addActionListener(new ActionListener() {
112     public void
113     actionPerformed(ActionEvent e) {
114     boolean b = btnMidiKeyboard.isSelected();
115     MainFrame frm = (MainFrame)CC.getMainFrame();
116     if(frm == null) return;
117     frm.setMidiKeyboardVisible(b);
118     }
119     });
120     toolbar.add(btnMidiKeyboard);
121 iliev 1286 toolbar.add(btnLSConsole);
122     toolbar.add(btnInstrumentsDb);
123     toolbar.addSeparator();
124     toolbar.add(btnPreferences);
125    
126 iliev 1323 mainPane.add(toolbar);
127     mainPane.add(Box.createGlue());
128 iliev 1286
129 iliev 1323 mainPane.add(lLogo);
130     mainPane.add(Box.createRigidArea(new Dimension(17, 0)));
131 iliev 1778 FantasiaSubPanel fsp = new FantasiaSubPanel(true, false, false);
132     fsp.add(mainPane);
133     add(fsp);
134 iliev 1286 }
135    
136 iliev 1323 public void
137     showFantasiaLogo(boolean b) { lLogo.setVisible(b); }
138 iliev 1778
139     private Color midColor = new Color(0x797979);
140    
141     @Override
142     public void
143     paintComponent(Graphics g) {
144     Graphics2D g2 = (Graphics2D)g;
145    
146     Paint oldPaint = g2.getPaint();
147     Composite oldComposite = g2.getComposite();
148    
149     double h = getSize().getHeight();
150     double w = getSize().getWidth();
151    
152     FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color5, midColor);
153 iliev 1864
154     boolean paintTop = screenMenuEnabled;
155     FantasiaPainter.Border b = new FantasiaPainter.Border(paintTop, true, false, true);
156 iliev 1778 FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 2, b);
157    
158     g2.setPaint(oldPaint);
159     g2.setComposite(oldComposite);
160     }
161    
162     class ToggleButton extends JToggleButton {
163     /** Creates a new instance of <code>ToolbarButton</code>. */
164     ToggleButton() {
165     setFocusable(false);
166     }
167    
168     /** Creates a new instance of <code>ToolbarButton</code>. */
169     public
170     ToggleButton(Action a) {
171     super(a);
172     setFocusable(false);
173     }
174    
175     /** This method does nothing. */
176     @Override
177     public void
178     setText(String text) { /* We don't want any text in toolbar buttons */ }
179     }
180    
181     class MainPane extends JPanel {
182     private final Color color1 = new Color(0x505050);
183     private final Color color2 = new Color(0x3e3e3e);
184    
185     @Override
186     public void
187     paintComponent(Graphics g) {
188     Graphics2D g2 = (Graphics2D)g;
189    
190     Paint oldPaint = g2.getPaint();
191     Composite oldComposite = g2.getComposite();
192    
193     double h = getSize().getHeight();
194     double w = getSize().getWidth();
195    
196     FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, color1, color2);
197    
198     FantasiaPainter.paintOuterBorder(g2, 0, 0, w - 1, h - 1, true, 0.5f, 0.3f);
199    
200     g2.setPaint(oldPaint);
201     g2.setComposite(oldComposite);
202     }
203     }
204 iliev 1286 }

  ViewVC Help
Powered by ViewVC