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

Diff of /jsampler/trunk/src/org/jsampler/view/fantasia/MainFrame.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1688 by iliev, Thu Feb 14 16:52:36 2008 UTC revision 1785 by iliev, Tue Oct 7 00:07:14 2008 UTC
# Line 1  Line 1 
1  /*  /*
2   *   JSampler - a java front-end for LinuxSampler   *   JSampler - a java front-end for LinuxSampler
3   *   *
4   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>   *   Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 23  Line 23 
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;  import java.awt.Dialog;
29  import java.awt.Dimension;  import java.awt.Dimension;
30  import java.awt.Frame;  import java.awt.Frame;
31  import java.awt.Graphics;  import java.awt.Graphics;
32    import java.awt.Graphics2D;
33  import java.awt.GridBagConstraints;  import java.awt.GridBagConstraints;
34  import java.awt.GridBagLayout;  import java.awt.GridBagLayout;
35  import java.awt.Insets;  import java.awt.Insets;
36  import java.awt.Point;  import java.awt.Paint;
37    
38  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
39  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
40  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
41  import java.awt.event.MouseAdapter;  
42  import java.awt.event.MouseEvent;  import java.beans.PropertyChangeEvent;
43    import java.beans.PropertyChangeListener;
44    
45  import java.io.BufferedReader;  import java.io.BufferedReader;
46  import java.io.File;  import java.io.File;
# Line 47  import java.util.Vector; Line 51  import java.util.Vector;
51  import java.util.logging.Level;  import java.util.logging.Level;
52    
53  import javax.swing.BorderFactory;  import javax.swing.BorderFactory;
 import javax.swing.Box;  
54  import javax.swing.BoxLayout;  import javax.swing.BoxLayout;
55  import javax.swing.JCheckBoxMenuItem;  import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JComponent;  
 import javax.swing.JDialog;  
56  import javax.swing.JFileChooser;  import javax.swing.JFileChooser;
 import javax.swing.JFrame;  
57  import javax.swing.JMenu;  import javax.swing.JMenu;
58  import javax.swing.JMenuBar;  import javax.swing.JMenuBar;
59  import javax.swing.JMenuItem;  import javax.swing.JMenuItem;
60  import javax.swing.JPanel;  import javax.swing.JPanel;
 import javax.swing.JPopupMenu;  
 import javax.swing.JScrollPane;  
61  import javax.swing.JSplitPane;  import javax.swing.JSplitPane;
 import javax.swing.JToggleButton;  
62  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
63  import javax.swing.SwingUtilities;  import javax.swing.SwingUtilities;
64  import javax.swing.UIManager;  import javax.swing.Timer;
   
 import net.sf.juife.TitleBar;  
65    
66  import org.jsampler.CC;  import org.jsampler.CC;
67  import org.jsampler.HF;  import org.jsampler.HF;
68  import org.jsampler.LSConsoleModel;  import org.jsampler.LSConsoleModel;
69  import org.jsampler.Server;  import org.jsampler.Server;
70    
 import org.jsampler.view.JSChannel;  
71  import org.jsampler.view.JSChannelsPane;  import org.jsampler.view.JSChannelsPane;
72  import org.jsampler.view.JSMainFrame;  import org.jsampler.view.JSMainFrame;
73  import org.jsampler.view.LscpFileFilter;  import org.jsampler.view.LscpFileFilter;
74    
75    import org.jsampler.view.fantasia.basic.FantasiaPainter;
76    import org.jsampler.view.fantasia.basic.FantasiaPanel;
77    import org.jsampler.view.fantasia.basic.FantasiaSubPanel;
78    
79  import org.jsampler.view.std.JSConnectDlg;  import org.jsampler.view.std.JSConnectDlg;
80  import org.jsampler.view.std.JSDetailedErrorDlg;  import org.jsampler.view.std.JSDetailedErrorDlg;
81  import org.jsampler.view.std.JSQuitDlg;  import org.jsampler.view.std.JSQuitDlg;
# Line 96  import static org.jsampler.view.std.StdP Line 94  import static org.jsampler.view.std.StdP
94  public class MainFrame extends JSMainFrame {  public class MainFrame extends JSMainFrame {
95          private final StandardBar standardBar = new StandardBar();          private final StandardBar standardBar = new StandardBar();
96          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();
97          private final JPanel rootPane = new JPanel();          private final JPanel rootPane = new RootPane();
98          private final MainPane mainPane = new MainPane();          private final BottomPane bottomPane;
99          private final DevicesPane devicesPane = new DevicesPane();          private final MainPane mainPane;
100          private final JScrollPane spDevicesPane = new JScrollPane();          private final PianoKeyboardPane pianoKeyboardPane;
101                    
102          private final JMenu recentScriptsMenu =          private final JMenu recentScriptsMenu =
103                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));
104                    
105          private final JSplitPane hSplitPane;          private final JSplitPane hSplitPane;
106                    
107          private final SidePane sidePane = new SidePane();          private final LeftSidePane leftSidePane;
108            private final RightSidePane rightSidePane;
109          private final JPanel rightPane;          private final JPanel rightPane;
110                    
111            //private final StatusBar statusBar = new StatusBar();
112            
113          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();
114          private final Vector<String> recentScripts = new Vector<String>();          private final Vector<String> recentScripts = new Vector<String>();
115                                    
# Line 116  public class MainFrame extends JSMainFra Line 117  public class MainFrame extends JSMainFra
117          private final JCheckBoxMenuItem cbmiToolBarVisible =          private final JCheckBoxMenuItem cbmiToolBarVisible =
118                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));
119                    
120          private final JCheckBoxMenuItem cbmiSidePaneVisible =          private final JCheckBoxMenuItem cbmiLeftSidePaneVisible =
121                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane"));
122            
123            private final JCheckBoxMenuItem cbmiRightSidePaneVisible =
124                            new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane"));
125            
126            private final JCheckBoxMenuItem cbmiMidiKeyboardVisible =
127                            new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard"));
128                    
129          private final JCheckBoxMenuItem cbmiDevicesPaneVisible =          private final Timer guiTimer = new Timer(1000, null);
                         new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane"));  
130                    
131          /** Creates a new instance of <code>MainFrame</code> */          /** Creates a new instance of <code>MainFrame</code> */
132          public          public
133          MainFrame() {          MainFrame() {
134                  setTitle(i18n.getLabel("MainFrame.title"));                  setTitle(i18n.getLabel("MainFrame.title"));
135                                    //setUndecorated(true);
136                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
137                                    
138                    CC.setMainFrame(this); // TODO:
139                    mainPane = new MainPane();
140                    leftSidePane = new LeftSidePane();
141                    rightSidePane = new RightSidePane();
142                    
143                    setSelectedChannelsPane(mainPane.getChannelsPane(0));
144                    
145                  getContentPane().add(standardBar, BorderLayout.NORTH);                  getContentPane().add(standardBar, BorderLayout.NORTH);
146                                    
147                  rightPane = createRightPane();                  rightPane = createRightPane();
# Line 136  public class MainFrame extends JSMainFra Line 149  public class MainFrame extends JSMainFra
149                  hSplitPane = new JSplitPane (                  hSplitPane = new JSplitPane (
150                          JSplitPane.HORIZONTAL_SPLIT,                          JSplitPane.HORIZONTAL_SPLIT,
151                          true,   // continuousLayout                          true,   // continuousLayout
152                          sidePane, rightPane                          leftSidePane, rightPane
153                  );                  );
154                  hSplitPane.setResizeWeight(0.5);                  hSplitPane.setResizeWeight(0.5);
155                                    
156                  rootPane.setLayout(new BorderLayout());                  pianoKeyboardPane = new PianoKeyboardPane();
                 rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0));  
                 rootPane.setOpaque(false);  
                 rootPane.add(hSplitPane);  
157                                    
158                  addMenu();                  for(int i = 0; i < mainPane.getChannelsPaneCount(); i++) {
159                            addChannelsPane(mainPane.getChannelsPane(i));
160                            getChannelsPane(i).addListSelectionListener(pianoKeyboardPane);
161                    }
162                    
163                    
164                    int h = preferences().getIntProperty("midiKeyboard.height");
165                    setMidiKeyboardHeight(h);
166                    
167                    PropertyChangeListener l = new PropertyChangeListener() {
168                            public void
169                            propertyChange(PropertyChangeEvent e) {
170                                    int h = preferences().getIntProperty("midiKeyboard.height");
171                                    setMidiKeyboardHeight(h);
172                            }
173                    };
174                    
175                    CC.preferences().addPropertyChangeListener("midiKeyboard.height", l);
176                                    
177                  addChannelsPane(mainPane.getChannelsPane());                  bottomPane = new BottomPane();
178                                    
179                  getContentPane().add(rootPane);                  hSplitPane.setOpaque(false);
180                    rootPane.add(hSplitPane);
181                    rootPane.add(bottomPane, BorderLayout.SOUTH);
182                    add(rootPane);
183                    
184                    addMenu();
185                                    
186                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
187                  hSplitPane.setDividerLocation(i);                  hSplitPane.setDividerLocation(i);
188                                    
189                  setSavedSize();                  setSavedSize();
190                    
191                    guiTimer.start();
192          }          }
193                    
194          private JPanel          private JPanel
195          createRightPane() {          createRightPane() {
196                  JPanel p = new JPanel();                  JPanel p = new FantasiaPanel();
197                    p.setOpaque(false);
198                    
199                  GridBagLayout gridbag = new GridBagLayout();                  GridBagLayout gridbag = new GridBagLayout();
200                  GridBagConstraints c = new GridBagConstraints();                  GridBagConstraints c = new GridBagConstraints();
201                                    
# Line 167  public class MainFrame extends JSMainFra Line 203  public class MainFrame extends JSMainFra
203                                    
204                  c.fill = GridBagConstraints.BOTH;                  c.fill = GridBagConstraints.BOTH;
205                                    
                 spDevicesPane.setViewportView(devicesPane);  
                 spDevicesPane.setBorder(BorderFactory.createEmptyBorder());  
                 int h = spDevicesPane.getMinimumSize().height;  
                 spDevicesPane.setMinimumSize(new Dimension(200, h));  
                   
206                  c.gridx = 1;                  c.gridx = 1;
207                  c.gridy = 0;                  c.gridy = 0;
208                  c.weightx = 1.0;                  c.weightx = 1.0;
209                  c.weighty = 1.0;                  c.weighty = 1.0;
210                  c.insets = new Insets(0, 3, 3, 0);                  c.insets = new Insets(0, 3, 0, 0);
211                  gridbag.setConstraints(spDevicesPane, c);                  gridbag.setConstraints(rightSidePane, c);
212                  p.add(spDevicesPane);                  p.add(rightSidePane);
213                                    
214                  c.gridx = 0;                  c.gridx = 0;
215                  c.gridy = 0;                  c.gridy = 0;
216                  c.weightx = 0.0;                  c.weightx = 0.0;
217                  c.weighty = 1.0;                  c.weighty = 1.0;
218                  c.insets = new Insets(0, 3, 3, 3);                  c.insets = new Insets(0, 0, 0, 3);
219                  c.fill = GridBagConstraints.VERTICAL;                  c.fill = GridBagConstraints.VERTICAL;
220                  gridbag.setConstraints(mainPane, c);                  gridbag.setConstraints(mainPane, c);
221                  p.add(mainPane);                  p.add(mainPane);
# Line 236  public class MainFrame extends JSMainFra Line 267  public class MainFrame extends JSMainFra
267                    
268                    
269          /** Invoked when this window is about to close. */          /** Invoked when this window is about to close. */
270            @Override
271          protected void          protected void
272          onWindowClose() {          onWindowClose() {
273                  boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);                  boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);
# Line 245  public class MainFrame extends JSMainFra Line 277  public class MainFrame extends JSMainFra
277                          if(dlg.isCancelled()) return;                          if(dlg.isCancelled()) return;
278                  }                  }
279                                    
280                  sidePane.savePreferences();                  leftSidePane.savePreferences();
281                    rightSidePane.savePreferences();
282                                    
283                  int i = hSplitPane.getDividerLocation();                  int i = hSplitPane.getDividerLocation();
284                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);
# Line 396  public class MainFrame extends JSMainFra Line 429  public class MainFrame extends JSMainFra
429                  cbmiToolBarVisible.setSelected(b);                  cbmiToolBarVisible.setSelected(b);
430                  showToolBar(b);                  showToolBar(b);
431                                    
432                  cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
433                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
434                  ));                  ));
435                  m.add(cbmiSidePaneVisible);                  m.add(cbmiLeftSidePaneVisible);
436                                    
437                  cbmiSidePaneVisible.addActionListener(new ActionListener() {                  cbmiLeftSidePaneVisible.addActionListener(new ActionListener() {
438                          public void                          public void
439                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
440                                  showSidePane(cbmiSidePaneVisible.getState());                                  showSidePane(cbmiLeftSidePaneVisible.getState());
441                          }                          }
442                  });                  });
443                                    
444                  b = preferences().getBoolProperty("sidePane.visible");                  b = preferences().getBoolProperty("leftSidePane.visible");
445                  cbmiSidePaneVisible.setSelected(b);                  cbmiLeftSidePaneVisible.setSelected(b);
446                  showSidePane(b);                  showSidePane(b);
447                                    
448                  cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
449                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
450                  ));                  ));
451                  m.add(cbmiDevicesPaneVisible);                  m.add(cbmiRightSidePaneVisible);
452                                    
453                  cbmiDevicesPaneVisible.addActionListener(new ActionListener() {                  cbmiRightSidePaneVisible.addActionListener(new ActionListener() {
454                          public void                          public void
455                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
456                                  showDevicesPane(cbmiDevicesPaneVisible.getState());                                  showDevicesPane(cbmiRightSidePaneVisible.getState());
457                          }                          }
458                  });                  });
459                                    
460                  b = preferences().getBoolProperty("devicesPane.visible");                  b = preferences().getBoolProperty("rightSidePane.visible");
461                  cbmiDevicesPaneVisible.setSelected(b);                  cbmiRightSidePaneVisible.setSelected(b);
462                  showDevicesPane(b);                  showDevicesPane(b);
463                                    
464                    m.addSeparator();
465                    
466                    m.add(cbmiMidiKeyboardVisible);
467                    
468                    cbmiMidiKeyboardVisible.addActionListener(new ActionListener() {
469                            public void
470                            actionPerformed(ActionEvent e) {
471                                    setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState());
472                            }
473                    });
474                    
475                    b = preferences().getBoolProperty("midiKeyboard.visible");
476                    cbmiMidiKeyboardVisible.setSelected(b);
477                    setMidiKeyboardVisible(b);
478                    
479                                    
480                  // Window                  // Window
481                  m = new FantasiaMenu(i18n.getMenuLabel("window"));                  m = new FantasiaMenu(i18n.getMenuLabel("window"));
# Line 458  public class MainFrame extends JSMainFra Line 506  public class MainFrame extends JSMainFra
506                  menuBar.add(m);                  menuBar.add(m);
507          }          }
508                    
509            public RightSidePane
510            getRightSidePane() { return rightSidePane; }
511            
512          /**          /**
513           * This method does nothing, because <b>Fantasia</b> has exactly           * This method does nothing, because <b>Fantasia</b> has constant
514           * one pane containing sampler channels, which can not be changed.           * number of panes containing sampler channels, which can not be changed.
515           */           */
516            @Override
517          public void          public void
518          insertChannelsPane(JSChannelsPane pane, int idx) {          insertChannelsPane(JSChannelsPane pane, int idx) {
519                                    
520          }          }
521                    
522          /**          @Override
          * This method always returns the <code>JSChannelsPane</code> at index 0,  
          * because the <b>Fantasia</b> view has exactly one pane containing sampler channels.  
          * @return The <code>JSChannelsPane</code> at index 0.  
          */  
523          public JSChannelsPane          public JSChannelsPane
524          getSelectedChannelsPane() { return getChannelsPane(0); }          getSelectedChannelsPane() { return mainPane.getSelectedChannelsPane(); }
525                    
526          /**          @Override
          * This method does nothing because the <b>Fantasia</b> view has  
          * exactly one pane containing sampler channels which is always shown.  
          */  
527          public void          public void
528          setSelectedChannelsPane(JSChannelsPane pane) { }          setSelectedChannelsPane(JSChannelsPane pane) {
529                    mainPane.setSelectedChannelsPane(pane);
530                    fireChannelsPaneSelectionChanged();
531            }
532                    
533            @Override
534          public void          public void
535          installJSamplerHome() {          installJSamplerHome() {
536                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);
# Line 491  public class MainFrame extends JSMainFra Line 540  public class MainFrame extends JSMainFra
540                  CC.changeJSamplerHome(chooser.getJSamplerHome());                  CC.changeJSamplerHome(chooser.getJSamplerHome());
541          }          }
542                    
543            @Override
544          public void          public void
545          showDetailedErrorMessage(Frame owner, String err, String details) {          showDetailedErrorMessage(Frame owner, String err, String details) {
546                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
# Line 499  public class MainFrame extends JSMainFra Line 549  public class MainFrame extends JSMainFra
549                  dlg.setVisible(true);                  dlg.setVisible(true);
550          }          }
551                    
552            @Override
553          public void          public void
554          showDetailedErrorMessage(Dialog owner, String err, String details) {          showDetailedErrorMessage(Dialog owner, String err, String details) {
555                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
# Line 511  public class MainFrame extends JSMainFra Line 562  public class MainFrame extends JSMainFra
562           * Gets the server address to which to connect. If the server should be           * Gets the server address to which to connect. If the server should be
563           * manually selected, a dialog asking the user to choose a server is displayed.           * manually selected, a dialog asking the user to choose a server is displayed.
564           */           */
565            @Override
566          public Server          public Server
567          getServer() {          getServer() {
568                  boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP);                  boolean b = preferences().getBoolProperty(MANUAL_SERVER_SELECT_ON_STARTUP);
# Line 522  public class MainFrame extends JSMainFra Line 574  public class MainFrame extends JSMainFra
574           * manually selected, a dialog asking the user to choose a server is displayed.           * manually selected, a dialog asking the user to choose a server is displayed.
575           * @param manualSelect Determines whether the server should be manually selected.           * @param manualSelect Determines whether the server should be manually selected.
576           */           */
577            @Override
578          public Server          public Server
579          getServer(boolean manualSelect) {          getServer(boolean manualSelect) {
580                  if(manualSelect) {                  if(manualSelect) {
# Line 538  public class MainFrame extends JSMainFra Line 591  public class MainFrame extends JSMainFra
591                  return CC.getServerList().getServer(i);                  return CC.getServerList().getServer(i);
592          }          }
593                    
594            public Timer
595            getGuiTimer() { return guiTimer; }
596            
597          protected LSConsoleModel          protected LSConsoleModel
598          getLSConsoleModel() { return getLSConsolePane().getModel(); }          getLSConsoleModel() { return getLSConsolePane().getModel(); }
599                    
# Line 630  public class MainFrame extends JSMainFra Line 686  public class MainFrame extends JSMainFra
686                    
687          private void          private void
688          showSidePane(boolean b) {          showSidePane(boolean b) {
689                  preferences().setBoolProperty("sidePane.visible", b);                  preferences().setBoolProperty("leftSidePane.visible", b);
690                  rootPane.remove(rightPane);                  rootPane.remove(rightPane);
691                  rootPane.remove(hSplitPane);                  rootPane.remove(hSplitPane);
692                                    
# Line 662  public class MainFrame extends JSMainFra Line 718  public class MainFrame extends JSMainFra
718                    
719          private void          private void
720          showDevicesPane(boolean b) {          showDevicesPane(boolean b) {
721                  preferences().setBoolProperty("devicesPane.visible", b);                  preferences().setBoolProperty("rightSidePane.visible", b);
722                                    
723                  int width = sidePane.getWidth();                  int width = leftSidePane.getWidth();
724                  int height = sidePane.getPreferredSize().height;                  int height = leftSidePane.getPreferredSize().height;
725                  if(width != 0) sidePane.setPreferredSize(new Dimension(width, height));                  if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height));
726                                    
727                  if(b) {                  if(b) {
728                          int w = preferences().getIntProperty("devicesPane.width", 200);                          int w = preferences().getIntProperty("devicesPane.width", 200);
729                                                    
730                          int h = spDevicesPane.getPreferredSize().height;                          int h = rightSidePane.getPreferredSize().height;
731                          spDevicesPane.setPreferredSize(new Dimension(w, h));                          rightSidePane.setPreferredSize(new Dimension(w, h));
732                  } else {                  } else {
733                          int w = spDevicesPane.getWidth();                          int w = rightSidePane.getWidth();
734                          if(w > 0 && w < 200) w = 200;                          if(w > 0 && w < 200) w = 200;
735                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);
736                  }                  }
737                                    
738                  hSplitPane.setResizeWeight(0.0);                  hSplitPane.setResizeWeight(0.0);
739                  spDevicesPane.setVisible(b);                  rightSidePane.setVisible(b);
740                  hSplitPane.resetToPreferredSizes();                  hSplitPane.resetToPreferredSizes();
741                                    
742                  int w = getPreferredSize().width;                  int w = getPreferredSize().width;
# Line 697  public class MainFrame extends JSMainFra Line 753  public class MainFrame extends JSMainFra
753                  });                  });
754          }          }
755                    
756            public void
757            setMidiKeyboardVisible(boolean b) {
758                    preferences().setBoolProperty("midiKeyboard.visible", b);
759                    pianoKeyboardPane.setVisible(b);
760                    
761                    if(cbmiMidiKeyboardVisible.isSelected() != b) {
762                            cbmiMidiKeyboardVisible.setSelected(b);
763                    }
764                    
765                    if(standardBar.btnMidiKeyboard.isSelected() != b) {
766                            standardBar.btnMidiKeyboard.setSelected(b);
767                    }
768                    
769                    if(pianoKeyboardPane.btnPower.isSelected() != b) {
770                            pianoKeyboardPane.btnPower.setSelected(b);
771                    }
772                    
773                    rootPane.validate();
774                    rootPane.repaint();
775            }
776            
777            public void
778            setMidiKeyboardHeight(int height) {
779                    Dimension d = pianoKeyboardPane.getPreferredSize();
780                    d = new Dimension(d.width, height);
781                    pianoKeyboardPane.setPreferredSize(d);
782                    pianoKeyboardPane.setMinimumSize(d);
783                    pianoKeyboardPane.revalidate();
784                    pianoKeyboardPane.repaint();
785            }
786            
787          private void          private void
788          sidePanesVisibilityChanged() {          sidePanesVisibilityChanged() {
789                  boolean sidePaneVisible = cbmiSidePaneVisible.isSelected();                  boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected();
790                  boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected();                  boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected();
791                                    
792                  if(sidePaneVisible && devicesPaneVisible) {                  if(leftSidePaneVisible && rightSidePaneVisible) {
793                          hSplitPane.setResizeWeight(0.5);                          hSplitPane.setResizeWeight(0.5);
794                  } else if(sidePaneVisible && !devicesPaneVisible) {                  } else if(leftSidePaneVisible && !rightSidePaneVisible) {
795                          hSplitPane.setResizeWeight(1.0);                          hSplitPane.setResizeWeight(1.0);
796                  }                  }
797                                    
798                  if(!sidePaneVisible && !devicesPaneVisible) {                  if(!leftSidePaneVisible && !rightSidePaneVisible) {
799                          standardBar.showFantasiaLogo(false);                          standardBar.showFantasiaLogo(false);
800                          if(isResizable()) setResizable(false);                          if(isResizable()) setResizable(false);
801                  } else {                  } else {
# Line 722  public class MainFrame extends JSMainFra Line 809  public class MainFrame extends JSMainFra
809                                    
810                  RecentScriptHandler(String script) { this.script = script; }                  RecentScriptHandler(String script) { this.script = script; }
811                                    
812                    @Override
813                  public void                  public void
814                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
815                          runScript(script);                          runScript(script);
# Line 736  public class MainFrame extends JSMainFra Line 824  public class MainFrame extends JSMainFra
824                          super(s);                          super(s);
825                          setFont(getFont().deriveFont(java.awt.Font.BOLD));                          setFont(getFont().deriveFont(java.awt.Font.BOLD));
826                          setOpaque(false);                          setOpaque(false);
827                            setContentAreaFilled(false);
828                  }                  }
829          }          }
830    
831          private class FantasiaMenuBar extends JMenuBar {          private class FantasiaMenuBar extends JMenuBar {
                 private Insets pixmapInsets = new Insets(6, 6, 0, 6);  
                 private Insets pixmapInsets2 = new Insets(6, 6, 6, 6);  
                   
832                  FantasiaMenuBar() {                  FantasiaMenuBar() {
833                          setOpaque(false);                          setOpaque(false);
834                            setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0));
835                  }                  }
836                                    
837                    @Override
838                  protected void                  protected void
839                  paintComponent(Graphics g) {                  paintComponent(Graphics g) {
840                          super.paintComponent(g);                          //super.paintComponent(g);
841                            Graphics2D g2 = (Graphics2D)g;
842                            
843                            Paint oldPaint = g2.getPaint();
844                            Composite oldComposite = g2.getComposite();
845                            
846                            double h = getSize().getHeight();
847                            double w = getSize().getWidth();
848                            
849                            FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5);
850                            
851                            FantasiaPainter.Border b;
852                            
853                            
854                          if(standardBar.isVisible()) {                          if(standardBar.isVisible()) {
855                                  PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets);                                  b = new FantasiaPainter.Border(true, true, false, true);
856                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b);
857                          } else {                          } else {
858                                  PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2);                                  b = new FantasiaPainter.Border(true, true, true, true);
859                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b);
860                          }                          }
861                            
862                            g2.setPaint(oldPaint);
863                            g2.setComposite(oldComposite);
864                    }
865            }
866            
867            class RootPane extends FantasiaSubPanel {
868                    private final Color color1 = new Color(0x454545);
869                    private final Color color2 = new Color(0x2e2e2e);
870                    
871                    RootPane() {
872                            setLayout(new BorderLayout());
873                            setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10));
874                            setOpaque(false);
875                    
876                    }
877            
878                    @Override
879                    public void
880                    paintComponent(Graphics g) {
881                            Graphics2D g2 = (Graphics2D)g;
882                            
883                            Paint oldPaint = g2.getPaint();
884                            Composite oldComposite = g2.getComposite();
885                            
886                            double h = getSize().getHeight();
887                            double w = getSize().getWidth();
888                            
889                            FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false);
890                            paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2);
891                            
892                            g2.setPaint(oldPaint);
893                            g2.setComposite(oldComposite);
894                    }
895            }
896            
897            class BottomPane extends FantasiaPanel {
898                    BottomPane() {
899                            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
900                            setOpaque(false);
901                            add(pianoKeyboardPane);
902                            
903                  }                  }
904          }          }
905  }  }

Legend:
Removed from v.1688  
changed lines
  Added in v.1785

  ViewVC Help
Powered by ViewVC