// @todo this should eventually read the tree from an xml file
protected void addMenuItems()
{
final Preferences prefs = getApplication().getUserPrefs();
MenuGroup mg, smg;
MenuCheckItem mci;
MenuRadioGroup rg;
// Action a;
BooleanPrefsMenuAction ba;
IntPrefsMenuAction ia;
int i;
// Ctrl on Mac / Ctrl+Alt on PC
final int myCtrl = MENU_SHORTCUT == InputEvent.CTRL_MASK ? InputEvent.CTRL_MASK | InputEvent.ALT_MASK : InputEvent.CTRL_MASK;
// --- file menu ---
mg = (MenuGroup) get( "file" );
smg = new MenuGroup( "new", getResourceString( "menuNew" ));
smg.add( new MenuItem( "empty", actionNewEmpty ));
smg.add( new MenuItem( "fromSelection", getResourceString( "menuNewFromSelection" )));
mg.add( smg, 0 );
i = mg.indexOf( "open" );
mg.add( new MenuItem( "openMultipleMono", actionOpenMM ), i + 1 );
i = mg.indexOf( "closeAll" );
mg.add( new MenuSeparator(), i + 3 );
i = mg.indexOf( "saveCopyAs" );
mg.add( new MenuItem( "saveSelectionAs", getResourceString( "menuSaveSelectionAs" )), i + 1 );
// --- timeline menu ---
i = indexOf( "edit" );
mg = new MenuGroup( "timeline", getResourceString( "menuTimeline" ));
mg.add( new MenuItem( "trimToSelection", getResourceString( "menuTrimToSelection" ),
KeyStroke.getKeyStroke( KeyEvent.VK_F5, MENU_SHORTCUT )));
mg.add( new MenuItem( "insertSilence", getResourceString( "menuInsertSilence" ),
KeyStroke.getKeyStroke( KeyEvent.VK_E, MENU_SHORTCUT + InputEvent.SHIFT_MASK )));
mg.add( new MenuItem( "insertRecording", getResourceString( "menuInsertRec" )));
add( mg, i + 1 );
// --- process menu ---
mg = new MenuGroup( "process", getResourceString( "menuProcess" ));
mg.add( new MenuItem( "again", getResourceString( "menuProcessAgain" ), KeyStroke.getKeyStroke( KeyEvent.VK_F, MENU_SHORTCUT )));
mg.addSeparator();
smg = new MenuGroup( "fscape", getResourceString( "menuFScape" ));
smg.add( new MenuItem( "needlehole", getResourceString( "menuFScNeedlehole" )));
mg.add( smg );
smg = new MenuGroup( "sc", getResourceString( "menuSuperCollider" ));
mg.add( smg );
mg.addSeparator();
mg.add( new MenuItem( "fadeIn", getResourceString( "menuFadeIn" ), KeyStroke.getKeyStroke( KeyEvent.VK_I, myCtrl )));
mg.add( new MenuItem( "fadeOut", getResourceString( "menuFadeOut" ), KeyStroke.getKeyStroke( KeyEvent.VK_O, myCtrl )));
mg.add( new MenuItem( "gain", getResourceString( "menuGain" ), KeyStroke.getKeyStroke( KeyEvent.VK_N, myCtrl )));
mg.add( new MenuItem( "invert", getResourceString( "menuInvert" )));
// mg.add( new MenuItem( "mix", getResourceString( "menuMix" )));
mg.add( new MenuItem( "reverse", getResourceString( "menuReverse" )));
mg.add( new MenuItem( "rotateChannels", getResourceString( "menuRotateChannels" )));
add( mg, i + 2 );
// --- operation menu ---
mg = new MenuGroup( "operation", getResourceString( "menuOperation" ));
ba = new BooleanPrefsMenuAction( getResourceString( "menuInsertionFollowsPlay" ), null );
mci = new MenuCheckItem( "insertionFollowsPlay", ba );
ba.setCheckItem( mci );
ba.setPreferences( prefs, PrefsUtil.KEY_INSERTIONFOLLOWSPLAY );
mg.add( mci );
add( mg, i + 3 );
// --- view menu ---
mg = new MenuGroup( "view", getResourceString( "menuView" ));
smg = new MenuGroup( "timeUnits", getResourceString( "menuTimeUnits" ));
ia = new IntPrefsMenuAction( getResourceString( "menuTimeUnitsSamples" ), null, PrefsUtil.TIME_SAMPLES );
rg = new MenuRadioGroup();
smg.add( new MenuRadioItem( rg, "samples", ia )); // crucial reihenfolge : erst item erzeugen, dann gruppe setzen, dann prefs
ia.setRadioGroup( rg );
ia.setPreferences( prefs, PrefsUtil.KEY_TIMEUNITS );
ia = new IntPrefsMenuAction( getResourceString( "menuTimeUnitsMinSecs" ), null, PrefsUtil.TIME_MINSECS );
smg.add( new MenuRadioItem( rg, "minSecs", ia ));
ia.setRadioGroup( rg );
ia.setPreferences( prefs, PrefsUtil.KEY_TIMEUNITS );
mg.add( smg );
smg = new MenuGroup( "vertscale", getResourceString( "menuVertScale" ));
ia = new IntPrefsMenuAction( getResourceString( "menuVertScaleAmpLin" ), null, PrefsUtil.VSCALE_AMP_LIN );
rg = new MenuRadioGroup();
smg.add( new MenuRadioItem( rg, "amplin", ia )); // crucial reihenfolge : erst item erzeugen, dann gruppe setzen, dann prefs
ia.setRadioGroup( rg );
ia.setPreferences( prefs, PrefsUtil.KEY_VERTSCALE );
ia = new IntPrefsMenuAction( getResourceString( "menuVertScaleAmpLog" ), null, PrefsUtil.VSCALE_AMP_LOG );
smg.add( new MenuRadioItem( rg, "amplog", ia ));
ia.setRadioGroup( rg );
ia.setPreferences( prefs, PrefsUtil.KEY_VERTSCALE );
ia = new IntPrefsMenuAction( getResourceString( "menuVertScaleFreqSpect" ), null, PrefsUtil.VSCALE_FREQ_SPECT );
smg.add( new MenuRadioItem( rg, "freqspect", ia ));
ia.setRadioGroup( rg );
ia.setPreferences( prefs, PrefsUtil.KEY_VERTSCALE );
final IntPrefsMenuAction freqSpectAction = ia;
// ia.setEnabled( prefs.node( PrefsUtil.NODE_VIEW ).getBoolean( PrefsUtil.KEY_SONAENABLED, false ));
new DynamicPrefChangeManager( prefs.node( PrefsUtil.NODE_VIEW ), new String[] {
PrefsUtil.KEY_SONAENABLED }, new PreferenceChangeListener() {
public void preferenceChange( PreferenceChangeEvent pce )
{
freqSpectAction.setEnabled( prefs.node( PrefsUtil.NODE_VIEW ).getBoolean( PrefsUtil.KEY_SONAENABLED, false ));
}
}).startListening();
mg.add( smg );
ba = new BooleanPrefsMenuAction( getResourceString( "menuViewNullLinie" ), null );
mci = new MenuCheckItem( "nullLinie", ba );
ba.setCheckItem( mci );
ba.setPreferences( prefs, PrefsUtil.KEY_VIEWNULLLINIE );
mg.add( mci );
ba = new BooleanPrefsMenuAction( getResourceString( "menuViewVerticalRulers" ), null );
mci = new MenuCheckItem( "verticalRulers", ba );
ba.setCheckItem( mci );
ba.setPreferences( prefs, PrefsUtil.KEY_VIEWVERTICALRULERS );
mg.add( mci );
ba = new BooleanPrefsMenuAction( getResourceString( "menuViewChanMeters" ), null );
mci = new MenuCheckItem( "channelMeters", ba );
ba.setCheckItem( mci );
ba.setPreferences( prefs, PrefsUtil.KEY_VIEWCHANMETERS );
mg.add( mci );
ba = new BooleanPrefsMenuAction( getResourceString( "menuViewMarkers" ), null );
mci = new MenuCheckItem( "markers", ba );
ba.setCheckItem( mci );
ba.setPreferences( prefs, PrefsUtil.KEY_VIEWMARKERS );
mg.add( mci );
add( mg, i + 4 );
// --- window menu ---
// mWindowRadioGroup = new MenuRadioGroup();
// mgWindow = new MenuGroup( "window", getResourceString( "menuWindow" ));
mg = (MenuGroup) get( "window" );
mg.add( new MenuItem( "ioSetup", new ActionIOSetup( getResourceString( "frameIOSetup" ), null )), 0 );
mg.add( new MenuSeparator(), 1 );
mg.add( new MenuItem( "main", new ActionShowWindow( getResourceString( "frameMain" ), null, Main.COMP_MAIN )), 2 );
mg.add( new MenuItem( "observer", new ActionObserver( getResourceString( "paletteObserver" ), KeyStroke.getKeyStroke( KeyEvent.VK_3, MENU_SHORTCUT ))), 3 );
mg.add( new MenuItem( "ctrlRoom", new ActionCtrlRoom( getResourceString( "paletteCtrlRoom" ), KeyStroke.getKeyStroke( KeyEvent.VK_2, MENU_SHORTCUT ))), 4 );
// mg.add( new MenuSeparator(), 5 );
// mgWindow.add( new MenuItem( "collect", ((WindowHandler) root.getWindowHandler()).getCollectAction() ));
// mgWindow.addSeparator();
// add( mgWindow );
// --- debug menu ---
mg = new MenuGroup( "debug", "Debug" );
mg.add( new MenuItem( "dumpPrefs", PrefsUtil.getDebugDumpAction() ));
mg.add( new MenuItem( "dumpRegions", "Dump Region Structure" ));
mg.add( new MenuItem( "verifyRegions", "Verify Regions Consistency" ));
mg.add( new MenuItem( "dumpCache", PrefCacheManager.getInstance().getDebugDumpAction() ));
mg.add( new MenuItem( "dumpAudioStakes", AudioStake.getDebugDumpAction() ));
mg.add( new MenuItem( "dumpNodeTree", SuperColliderClient.getInstance().getDebugNodeTreeAction() ));
mg.add( new MenuItem( "dumpKillAll", SuperColliderClient.getInstance().getDebugKillAllAction() ));
i = indexOf( "help" );
add( mg, i );
// // --- help menu ---
// mg = new MenuGroup( "help", getResourceString( "menuHelp" ));