/[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 1778 by iliev, Sun Sep 28 20:38:36 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;
# Line 96  import static org.jsampler.view.std.StdP Line 90  import static org.jsampler.view.std.StdP
90  public class MainFrame extends JSMainFrame {  public class MainFrame extends JSMainFrame {
91          private final StandardBar standardBar = new StandardBar();          private final StandardBar standardBar = new StandardBar();
92          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();          private final FantasiaMenuBar menuBar = new FantasiaMenuBar();
93          private final JPanel rootPane = new JPanel();          private final JPanel rootPane = new RootPane();
94            private final BottomPane bottomPane;
95          private final MainPane mainPane = new MainPane();          private final MainPane mainPane = new MainPane();
96          private final DevicesPane devicesPane = new DevicesPane();          private final PianoKeyboardPane pianoKeyboardPane;
         private final JScrollPane spDevicesPane = new JScrollPane();  
97                    
98          private final JMenu recentScriptsMenu =          private final JMenu recentScriptsMenu =
99                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));                  new JMenu(i18n.getMenuLabel("actions.recentScripts"));
100                    
101          private final JSplitPane hSplitPane;          private final JSplitPane hSplitPane;
102                    
103          private final SidePane sidePane = new SidePane();          private final LeftSidePane leftSidePane = new LeftSidePane();
104            private final RightSidePane rightSidePane = new RightSidePane();
105          private final JPanel rightPane;          private final JPanel rightPane;
106                    
107            //private final StatusBar statusBar = new StatusBar();
108            
109          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();          private final LSConsoleFrame lsConsoleFrame = new LSConsoleFrame();
110          private final Vector<String> recentScripts = new Vector<String>();          private final Vector<String> recentScripts = new Vector<String>();
111                                    
# Line 116  public class MainFrame extends JSMainFra Line 113  public class MainFrame extends JSMainFra
113          private final JCheckBoxMenuItem cbmiToolBarVisible =          private final JCheckBoxMenuItem cbmiToolBarVisible =
114                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.toolBar"));
115                    
116          private final JCheckBoxMenuItem cbmiSidePaneVisible =          private final JCheckBoxMenuItem cbmiLeftSidePaneVisible =
117                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.sidePane"));                          new JCheckBoxMenuItem(i18n.getMenuLabel("view.leftSidePane"));
118            
119            private final JCheckBoxMenuItem cbmiRightSidePaneVisible =
120                            new JCheckBoxMenuItem(i18n.getMenuLabel("view.rightSidePane"));
121            
122            private final JCheckBoxMenuItem cbmiMidiKeyboardVisible =
123                            new JCheckBoxMenuItem(i18n.getMenuLabel("view.midiKeyboard"));
124                    
125          private final JCheckBoxMenuItem cbmiDevicesPaneVisible =          private final Timer guiTimer = new Timer(1000, null);
                         new JCheckBoxMenuItem(i18n.getMenuLabel("view.devicesPane"));  
126                    
127          /** Creates a new instance of <code>MainFrame</code> */          /** Creates a new instance of <code>MainFrame</code> */
128          public          public
129          MainFrame() {          MainFrame() {
130                  setTitle(i18n.getLabel("MainFrame.title"));                  setTitle(i18n.getLabel("MainFrame.title"));
131                                    //setUndecorated(true);
132                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());                  if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
133                                    
134                  getContentPane().add(standardBar, BorderLayout.NORTH);                  getContentPane().add(standardBar, BorderLayout.NORTH);
# Line 136  public class MainFrame extends JSMainFra Line 138  public class MainFrame extends JSMainFra
138                  hSplitPane = new JSplitPane (                  hSplitPane = new JSplitPane (
139                          JSplitPane.HORIZONTAL_SPLIT,                          JSplitPane.HORIZONTAL_SPLIT,
140                          true,   // continuousLayout                          true,   // continuousLayout
141                          sidePane, rightPane                          leftSidePane, rightPane
142                  );                  );
143                  hSplitPane.setResizeWeight(0.5);                  hSplitPane.setResizeWeight(0.5);
144                                    
145                  rootPane.setLayout(new BorderLayout());                  addChannelsPane(mainPane.getChannelsPane());
                 rootPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 0, 0));  
                 rootPane.setOpaque(false);  
                 rootPane.add(hSplitPane);  
146                                    
147                  addMenu();                  pianoKeyboardPane = new PianoKeyboardPane();
148                    getChannelsPane(0).addListSelectionListener(pianoKeyboardPane);
149                    int h = preferences().getIntProperty("midiKeyboard.height");
150                    setMidiKeyboardHeight(h);
151                                    
152                  addChannelsPane(mainPane.getChannelsPane());                  PropertyChangeListener l = new PropertyChangeListener() {
153                            public void
154                            propertyChange(PropertyChangeEvent e) {
155                                    int h = preferences().getIntProperty("midiKeyboard.height");
156                                    setMidiKeyboardHeight(h);
157                            }
158                    };
159                    
160                    CC.preferences().addPropertyChangeListener("midiKeyboard.height", l);
161                                    
162                  getContentPane().add(rootPane);                  bottomPane = new BottomPane();
163                    
164                    hSplitPane.setOpaque(false);
165                    rootPane.add(hSplitPane);
166                    rootPane.add(bottomPane, BorderLayout.SOUTH);
167                    add(rootPane);
168                    
169                    addMenu();
170                                    
171                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);                  int i = preferences().getIntProperty("MainFrame.hSplitDividerLocation", 220);
172                  hSplitPane.setDividerLocation(i);                  hSplitPane.setDividerLocation(i);
173                                    
174                  setSavedSize();                  setSavedSize();
175                    
176                    guiTimer.start();
177          }          }
178                    
179          private JPanel          private JPanel
180          createRightPane() {          createRightPane() {
181                  JPanel p = new JPanel();                  JPanel p = new FantasiaPanel();
182                    p.setOpaque(false);
183                    
184                  GridBagLayout gridbag = new GridBagLayout();                  GridBagLayout gridbag = new GridBagLayout();
185                  GridBagConstraints c = new GridBagConstraints();                  GridBagConstraints c = new GridBagConstraints();
186                                    
# Line 167  public class MainFrame extends JSMainFra Line 188  public class MainFrame extends JSMainFra
188                                    
189                  c.fill = GridBagConstraints.BOTH;                  c.fill = GridBagConstraints.BOTH;
190                                    
                 spDevicesPane.setViewportView(devicesPane);  
                 spDevicesPane.setBorder(BorderFactory.createEmptyBorder());  
                 int h = spDevicesPane.getMinimumSize().height;  
                 spDevicesPane.setMinimumSize(new Dimension(200, h));  
                   
191                  c.gridx = 1;                  c.gridx = 1;
192                  c.gridy = 0;                  c.gridy = 0;
193                  c.weightx = 1.0;                  c.weightx = 1.0;
194                  c.weighty = 1.0;                  c.weighty = 1.0;
195                  c.insets = new Insets(0, 3, 3, 0);                  c.insets = new Insets(0, 3, 0, 0);
196                  gridbag.setConstraints(spDevicesPane, c);                  gridbag.setConstraints(rightSidePane, c);
197                  p.add(spDevicesPane);                  p.add(rightSidePane);
198                                    
199                  c.gridx = 0;                  c.gridx = 0;
200                  c.gridy = 0;                  c.gridy = 0;
201                  c.weightx = 0.0;                  c.weightx = 0.0;
202                  c.weighty = 1.0;                  c.weighty = 1.0;
203                  c.insets = new Insets(0, 3, 3, 3);                  c.insets = new Insets(0, 0, 0, 3);
204                  c.fill = GridBagConstraints.VERTICAL;                  c.fill = GridBagConstraints.VERTICAL;
205                  gridbag.setConstraints(mainPane, c);                  gridbag.setConstraints(mainPane, c);
206                  p.add(mainPane);                  p.add(mainPane);
# Line 236  public class MainFrame extends JSMainFra Line 252  public class MainFrame extends JSMainFra
252                    
253                    
254          /** Invoked when this window is about to close. */          /** Invoked when this window is about to close. */
255            @Override
256          protected void          protected void
257          onWindowClose() {          onWindowClose() {
258                  boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);                  boolean b = preferences().getBoolProperty(CONFIRM_APP_QUIT);
# Line 245  public class MainFrame extends JSMainFra Line 262  public class MainFrame extends JSMainFra
262                          if(dlg.isCancelled()) return;                          if(dlg.isCancelled()) return;
263                  }                  }
264                                    
265                  sidePane.savePreferences();                  leftSidePane.savePreferences();
266                    rightSidePane.savePreferences();
267                                    
268                  int i = hSplitPane.getDividerLocation();                  int i = hSplitPane.getDividerLocation();
269                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);                  preferences().setIntProperty("MainFrame.hSplitDividerLocation", i);
# Line 396  public class MainFrame extends JSMainFra Line 414  public class MainFrame extends JSMainFra
414                  cbmiToolBarVisible.setSelected(b);                  cbmiToolBarVisible.setSelected(b);
415                  showToolBar(b);                  showToolBar(b);
416                                    
417                  cbmiSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiLeftSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
418                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_L, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
419                  ));                  ));
420                  m.add(cbmiSidePaneVisible);                  m.add(cbmiLeftSidePaneVisible);
421                                    
422                  cbmiSidePaneVisible.addActionListener(new ActionListener() {                  cbmiLeftSidePaneVisible.addActionListener(new ActionListener() {
423                          public void                          public void
424                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
425                                  showSidePane(cbmiSidePaneVisible.getState());                                  showSidePane(cbmiLeftSidePaneVisible.getState());
426                          }                          }
427                  });                  });
428                                    
429                  b = preferences().getBoolProperty("sidePane.visible");                  b = preferences().getBoolProperty("leftSidePane.visible");
430                  cbmiSidePaneVisible.setSelected(b);                  cbmiLeftSidePaneVisible.setSelected(b);
431                  showSidePane(b);                  showSidePane(b);
432                                    
433                  cbmiDevicesPaneVisible.setAccelerator(KeyStroke.getKeyStroke (                  cbmiRightSidePaneVisible.setAccelerator(KeyStroke.getKeyStroke (
434                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK                          KeyEvent.VK_R, KeyEvent.CTRL_MASK | KeyEvent.SHIFT_MASK
435                  ));                  ));
436                  m.add(cbmiDevicesPaneVisible);                  m.add(cbmiRightSidePaneVisible);
437                                    
438                  cbmiDevicesPaneVisible.addActionListener(new ActionListener() {                  cbmiRightSidePaneVisible.addActionListener(new ActionListener() {
439                          public void                          public void
440                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) {
441                                  showDevicesPane(cbmiDevicesPaneVisible.getState());                                  showDevicesPane(cbmiRightSidePaneVisible.getState());
442                          }                          }
443                  });                  });
444                                    
445                  b = preferences().getBoolProperty("devicesPane.visible");                  b = preferences().getBoolProperty("rightSidePane.visible");
446                  cbmiDevicesPaneVisible.setSelected(b);                  cbmiRightSidePaneVisible.setSelected(b);
447                  showDevicesPane(b);                  showDevicesPane(b);
448                                    
449                    m.addSeparator();
450                    
451                    m.add(cbmiMidiKeyboardVisible);
452                    
453                    cbmiMidiKeyboardVisible.addActionListener(new ActionListener() {
454                            public void
455                            actionPerformed(ActionEvent e) {
456                                    setMidiKeyboardVisible(cbmiMidiKeyboardVisible.getState());
457                            }
458                    });
459                    
460                    b = preferences().getBoolProperty("midiKeyboard.visible");
461                    cbmiMidiKeyboardVisible.setSelected(b);
462                    setMidiKeyboardVisible(b);
463                    
464                                    
465                  // Window                  // Window
466                  m = new FantasiaMenu(i18n.getMenuLabel("window"));                  m = new FantasiaMenu(i18n.getMenuLabel("window"));
# Line 458  public class MainFrame extends JSMainFra Line 491  public class MainFrame extends JSMainFra
491                  menuBar.add(m);                  menuBar.add(m);
492          }          }
493                    
494            public RightSidePane
495            getRightSidePane() { return rightSidePane; }
496            
497          /**          /**
498           * This method does nothing, because <b>Fantasia</b> has exactly           * This method does nothing, because <b>Fantasia</b> has exactly
499           * one pane containing sampler channels, which can not be changed.           * one pane containing sampler channels, which can not be changed.
500           */           */
501            @Override
502          public void          public void
503          insertChannelsPane(JSChannelsPane pane, int idx) {          insertChannelsPane(JSChannelsPane pane, int idx) {
504                                    
# Line 472  public class MainFrame extends JSMainFra Line 509  public class MainFrame extends JSMainFra
509           * because the <b>Fantasia</b> view has exactly one pane containing sampler channels.           * because the <b>Fantasia</b> view has exactly one pane containing sampler channels.
510           * @return The <code>JSChannelsPane</code> at index 0.           * @return The <code>JSChannelsPane</code> at index 0.
511           */           */
512            @Override
513          public JSChannelsPane          public JSChannelsPane
514          getSelectedChannelsPane() { return getChannelsPane(0); }          getSelectedChannelsPane() { return getChannelsPane(0); }
515                    
# Line 479  public class MainFrame extends JSMainFra Line 517  public class MainFrame extends JSMainFra
517           * This method does nothing because the <b>Fantasia</b> view has           * This method does nothing because the <b>Fantasia</b> view has
518           * exactly one pane containing sampler channels which is always shown.           * exactly one pane containing sampler channels which is always shown.
519           */           */
520            @Override
521          public void          public void
522          setSelectedChannelsPane(JSChannelsPane pane) { }          setSelectedChannelsPane(JSChannelsPane pane) { }
523                    
524            @Override
525          public void          public void
526          installJSamplerHome() {          installJSamplerHome() {
527                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);                  JSamplerHomeChooser chooser = new JSamplerHomeChooser(this);
# Line 491  public class MainFrame extends JSMainFra Line 531  public class MainFrame extends JSMainFra
531                  CC.changeJSamplerHome(chooser.getJSamplerHome());                  CC.changeJSamplerHome(chooser.getJSamplerHome());
532          }          }
533                    
534            @Override
535          public void          public void
536          showDetailedErrorMessage(Frame owner, String err, String details) {          showDetailedErrorMessage(Frame owner, String err, String details) {
537                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
# Line 499  public class MainFrame extends JSMainFra Line 540  public class MainFrame extends JSMainFra
540                  dlg.setVisible(true);                  dlg.setVisible(true);
541          }          }
542                    
543            @Override
544          public void          public void
545          showDetailedErrorMessage(Dialog owner, String err, String details) {          showDetailedErrorMessage(Dialog owner, String err, String details) {
546                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (                  JSDetailedErrorDlg dlg = new JSDetailedErrorDlg (
# Line 511  public class MainFrame extends JSMainFra Line 553  public class MainFrame extends JSMainFra
553           * 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
554           * 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.
555           */           */
556            @Override
557          public Server          public Server
558          getServer() {          getServer() {
559                  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 565  public class MainFrame extends JSMainFra
565           * 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.
566           * @param manualSelect Determines whether the server should be manually selected.           * @param manualSelect Determines whether the server should be manually selected.
567           */           */
568            @Override
569          public Server          public Server
570          getServer(boolean manualSelect) {          getServer(boolean manualSelect) {
571                  if(manualSelect) {                  if(manualSelect) {
# Line 538  public class MainFrame extends JSMainFra Line 582  public class MainFrame extends JSMainFra
582                  return CC.getServerList().getServer(i);                  return CC.getServerList().getServer(i);
583          }          }
584                    
585            public Timer
586            getGuiTimer() { return guiTimer; }
587            
588          protected LSConsoleModel          protected LSConsoleModel
589          getLSConsoleModel() { return getLSConsolePane().getModel(); }          getLSConsoleModel() { return getLSConsolePane().getModel(); }
590                    
# Line 630  public class MainFrame extends JSMainFra Line 677  public class MainFrame extends JSMainFra
677                    
678          private void          private void
679          showSidePane(boolean b) {          showSidePane(boolean b) {
680                  preferences().setBoolProperty("sidePane.visible", b);                  preferences().setBoolProperty("leftSidePane.visible", b);
681                  rootPane.remove(rightPane);                  rootPane.remove(rightPane);
682                  rootPane.remove(hSplitPane);                  rootPane.remove(hSplitPane);
683                                    
# Line 662  public class MainFrame extends JSMainFra Line 709  public class MainFrame extends JSMainFra
709                    
710          private void          private void
711          showDevicesPane(boolean b) {          showDevicesPane(boolean b) {
712                  preferences().setBoolProperty("devicesPane.visible", b);                  preferences().setBoolProperty("rightSidePane.visible", b);
713                                    
714                  int width = sidePane.getWidth();                  int width = leftSidePane.getWidth();
715                  int height = sidePane.getPreferredSize().height;                  int height = leftSidePane.getPreferredSize().height;
716                  if(width != 0) sidePane.setPreferredSize(new Dimension(width, height));                  if(width != 0) leftSidePane.setPreferredSize(new Dimension(width, height));
717                                    
718                  if(b) {                  if(b) {
719                          int w = preferences().getIntProperty("devicesPane.width", 200);                          int w = preferences().getIntProperty("devicesPane.width", 200);
720                                                    
721                          int h = spDevicesPane.getPreferredSize().height;                          int h = rightSidePane.getPreferredSize().height;
722                          spDevicesPane.setPreferredSize(new Dimension(w, h));                          rightSidePane.setPreferredSize(new Dimension(w, h));
723                  } else {                  } else {
724                          int w = spDevicesPane.getWidth();                          int w = rightSidePane.getWidth();
725                          if(w > 0 && w < 200) w = 200;                          if(w > 0 && w < 200) w = 200;
726                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);                          if(w != 0) preferences().setIntProperty("devicesPane.width", w);
727                  }                  }
728                                    
729                  hSplitPane.setResizeWeight(0.0);                  hSplitPane.setResizeWeight(0.0);
730                  spDevicesPane.setVisible(b);                  rightSidePane.setVisible(b);
731                  hSplitPane.resetToPreferredSizes();                  hSplitPane.resetToPreferredSizes();
732                                    
733                  int w = getPreferredSize().width;                  int w = getPreferredSize().width;
# Line 697  public class MainFrame extends JSMainFra Line 744  public class MainFrame extends JSMainFra
744                  });                  });
745          }          }
746                    
747            public void
748            setMidiKeyboardVisible(boolean b) {
749                    preferences().setBoolProperty("midiKeyboard.visible", b);
750                    pianoKeyboardPane.setVisible(b);
751                    
752                    if(cbmiMidiKeyboardVisible.isSelected() != b) {
753                            cbmiMidiKeyboardVisible.setSelected(b);
754                    }
755                    
756                    if(standardBar.btnMidiKeyboard.isSelected() != b) {
757                            standardBar.btnMidiKeyboard.setSelected(b);
758                    }
759                    
760                    if(pianoKeyboardPane.btnPower.isSelected() != b) {
761                            pianoKeyboardPane.btnPower.setSelected(b);
762                    }
763                    
764                    rootPane.validate();
765                    rootPane.repaint();
766            }
767            
768            public void
769            setMidiKeyboardHeight(int height) {
770                    Dimension d = pianoKeyboardPane.getPreferredSize();
771                    d = new Dimension(d.width, height);
772                    pianoKeyboardPane.setPreferredSize(d);
773                    pianoKeyboardPane.setMinimumSize(d);
774                    pianoKeyboardPane.revalidate();
775                    pianoKeyboardPane.repaint();
776            }
777            
778          private void          private void
779          sidePanesVisibilityChanged() {          sidePanesVisibilityChanged() {
780                  boolean sidePaneVisible = cbmiSidePaneVisible.isSelected();                  boolean leftSidePaneVisible = cbmiLeftSidePaneVisible.isSelected();
781                  boolean devicesPaneVisible = cbmiDevicesPaneVisible.isSelected();                  boolean rightSidePaneVisible = cbmiRightSidePaneVisible.isSelected();
782                                    
783                  if(sidePaneVisible && devicesPaneVisible) {                  if(leftSidePaneVisible && rightSidePaneVisible) {
784                          hSplitPane.setResizeWeight(0.5);                          hSplitPane.setResizeWeight(0.5);
785                  } else if(sidePaneVisible && !devicesPaneVisible) {                  } else if(leftSidePaneVisible && !rightSidePaneVisible) {
786                          hSplitPane.setResizeWeight(1.0);                          hSplitPane.setResizeWeight(1.0);
787                  }                  }
788                                    
789                  if(!sidePaneVisible && !devicesPaneVisible) {                  if(!leftSidePaneVisible && !rightSidePaneVisible) {
790                          standardBar.showFantasiaLogo(false);                          standardBar.showFantasiaLogo(false);
791                          if(isResizable()) setResizable(false);                          if(isResizable()) setResizable(false);
792                  } else {                  } else {
# Line 722  public class MainFrame extends JSMainFra Line 800  public class MainFrame extends JSMainFra
800                                    
801                  RecentScriptHandler(String script) { this.script = script; }                  RecentScriptHandler(String script) { this.script = script; }
802                                    
803                    @Override
804                  public void                  public void
805                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
806                          runScript(script);                          runScript(script);
# Line 736  public class MainFrame extends JSMainFra Line 815  public class MainFrame extends JSMainFra
815                          super(s);                          super(s);
816                          setFont(getFont().deriveFont(java.awt.Font.BOLD));                          setFont(getFont().deriveFont(java.awt.Font.BOLD));
817                          setOpaque(false);                          setOpaque(false);
818                            setContentAreaFilled(false);
819                  }                  }
820          }          }
821    
822          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);  
                   
823                  FantasiaMenuBar() {                  FantasiaMenuBar() {
824                          setOpaque(false);                          setOpaque(false);
825                            setBorder(BorderFactory.createEmptyBorder(2, 6, 0, 0));
826                  }                  }
827                                    
828                    @Override
829                  protected void                  protected void
830                  paintComponent(Graphics g) {                  paintComponent(Graphics g) {
831                          super.paintComponent(g);                          //super.paintComponent(g);
832                            Graphics2D g2 = (Graphics2D)g;
833                            
834                            Paint oldPaint = g2.getPaint();
835                            Composite oldComposite = g2.getComposite();
836                            
837                            double h = getSize().getHeight();
838                            double w = getSize().getWidth();
839                            
840                            FantasiaPainter.paintGradient(g2, 0.0, 0.0, w - 1, h - 1, FantasiaPainter.color6, FantasiaPainter.color5);
841                            
842                            FantasiaPainter.Border b;
843                            
844                            
845                          if(standardBar.isVisible()) {                          if(standardBar.isVisible()) {
846                                  PixmapPane.paintComponent(this, g, Res.gfxMenuBarBg, pixmapInsets);                                  b = new FantasiaPainter.Border(true, true, false, true);
847                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h + 1, b);
848                          } else {                          } else {
849                                  PixmapPane.paintComponent(this, g, Res.gfxRoundBg14, pixmapInsets2);                                  b = new FantasiaPainter.Border(true, true, true, true);
850                                    FantasiaPainter.paintBoldOuterBorder(g2, 0, 0, w - 1, h - 1, b);
851                          }                          }
852                            
853                            g2.setPaint(oldPaint);
854                            g2.setComposite(oldComposite);
855                    }
856            }
857            
858            class RootPane extends FantasiaSubPanel {
859                    private final Color color1 = new Color(0x454545);
860                    private final Color color2 = new Color(0x2e2e2e);
861                    
862                    RootPane() {
863                            setLayout(new BorderLayout());
864                            setBorder(BorderFactory.createEmptyBorder(9, 10, 6, 10));
865                            setOpaque(false);
866                    
867                    }
868            
869                    @Override
870                    public void
871                    paintComponent(Graphics g) {
872                            Graphics2D g2 = (Graphics2D)g;
873                            
874                            Paint oldPaint = g2.getPaint();
875                            Composite oldComposite = g2.getComposite();
876                            
877                            double h = getSize().getHeight();
878                            double w = getSize().getWidth();
879                            
880                            FantasiaPainter.paintBorder(g2, 0, -3, w - 1, h - 1, 6, false);
881                            paintComponent(g2, 5, 1, w - 10, h - 6, color1, color2);
882                            
883                            g2.setPaint(oldPaint);
884                            g2.setComposite(oldComposite);
885                    }
886            }
887            
888            class BottomPane extends FantasiaPanel {
889                    BottomPane() {
890                            setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
891                            setOpaque(false);
892                            add(pianoKeyboardPane);
893                            
894                  }                  }
895          }          }
896  }  }

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

  ViewVC Help
Powered by ViewVC