final InputMap imap = getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW );
final ActionMap amap = getActionMap();
// final AbstractButton ggAudioInfo, ggRevealFile;
final int myMeta = BasicMenuFactory.MENU_SHORTCUT == InputEvent.CTRL_MASK ?
InputEvent.CTRL_MASK | InputEvent.SHIFT_MASK : BasicMenuFactory.MENU_SHORTCUT; // META on Mac, CTRL+SHIFT on PC
final TopPainter trackPainter;
final MenuRoot mr;
final JPanel topPane = GUIUtil.createGradientPanel();
final Trail.Listener waveTrailListener;
Box box;
// internalFrames = app.getWindowHandler().usesInternalFrames();
timeTB = new TimelineToolBar( doc );
// transTB = new TransportToolBar( doc );
wavePanel = new ComponentHost();
timeAxis = new TimelineAxis( doc, wavePanel );
markAxis = new MarkerAxis( doc, wavePanel );
viewMarkers = app.getUserPrefs().getBoolean( PrefsUtil.KEY_VIEWMARKERS, false );
markVisible = viewMarkers && waveExpanded;
markAxisHeader = new TrackRowHeader( doc.markerTrack, doc.getTracks(), doc.getMutableSelectedTracks(), doc.getUndoManager() );
markAxisHeader.setPreferredSize( new Dimension( 63, markAxis.getPreferredSize().height )); // XXX
markAxisHeader.setMaximumSize( new Dimension( 128, markAxis.getMaximumSize().height )); // XXX
if( markVisible ) {
markAxis.startListening();
} else {
markAxis.setVisible( false );
markAxisHeader.setVisible( false );
}
flagsPanel = new JPanel( new StretchedGridLayout( 0, 1, 1, 1 ));
// metersPanel = new JPanel( new StretchedGridLayout( 0, 1, 1, 1 )); // SpringPanel( 0, 0, 1, 1 );
rulersPanel = new JPanel( new StretchedGridLayout( 0, 1, 1, 1 ));
// lmm.setDynamicComponent( metersPanel );
waveHeaderPanel = new JPanel( new BorderLayout() );
channelHeaderPanel = new JPanel();
channelHeaderPanel.setLayout( new BoxLayout( channelHeaderPanel, BoxLayout.X_AXIS ));
final Box bbb = Box.createVerticalBox();
final GradientPanel gp = GUIUtil.createGradientPanel();
gp.setBottomBorder( true );
gp.setLayout( null );
gp.setPreferredSize( new Dimension( 0, timeAxis.getPreferredSize().height ));
bbb.add( gp );
bbb.add( markAxisHeader );
waveHeaderPanel.add( bbb, BorderLayout.NORTH );
channelHeaderPanel.add( flagsPanel );
// channelHeaderPanel.add( metersPanel );
channelHeaderPanel.add( rulersPanel );
waveHeaderPanel.add( channelHeaderPanel, BorderLayout.CENTER );
waveView = new WaveformView( doc, wavePanel );
wavePanel.setLayout( new BoxLayout( wavePanel, BoxLayout.Y_AXIS ));
wavePanel.add( timeAxis );
wavePanel.add( markAxis );
wavePanel.add( waveView );
scroll = new TimelineScroll( doc );
ggTrackPanel = new JPanel( new BorderLayout() );
ggTrackPanel.add( wavePanel, BorderLayout.CENTER );
ggTrackPanel.add( waveHeaderPanel, BorderLayout.WEST );
ggTrackPanel.add( scroll, BorderLayout.SOUTH );
lbWriteProtected = new JLabel();
// EEE
// ggAudioInfo = new ModificationButton( ModificationButton.SHAPE_INFO );
// ggAudioInfo.setAction( new ActionAudioInfo() );
// ggRevealFile = new ModificationButton( ModificationButton.SHAPE_REVEAL );
// actionRevealFile = new ActionRevealFile();
// ggRevealFile.setAction( actionRevealFile );
// ggAudioFileDescr = new JTextField( 32 );
// ggAudioFileDescr.setEditable( false );
// ggAudioFileDescr.setFocusable( false );
// ggAudioFileDescr.setBackground( null );
// ggAudioFileDescr.setBorder( null );
// lbSRC = new JLabel( getResourceString( "buttonSRC" ));
// lbSRC.setForeground( colrClear );
box = Box.createHorizontalBox();
box.add( Box.createHorizontalStrut( 4 ));
box.add( lbWriteProtected );
// EEE
// box.add( ggAudioInfo );
// box.add( ggRevealFile );
// box.add( Box.createHorizontalStrut( 4 ));
//
// pProgress = new ProgressPanel();
// pOverlay = new CrossfadePanel();
// pOverlay.setComponentA( ggAudioFileDescr );
// pOverlay.setComponentB( pProgress );
// box.add( pOverlay );
//
// box.add( Box.createHorizontalStrut( 4 ));
// box.add( lbSRC );
box.add( CoverGrowBox.create( 2, 0 ));
//
// updateAFDGadget();
// updateCursorFormat();
//
// ----- afr export -----
// final JButton ggExportAFR = new JButton( getResourceString( "buttonDragRegion" ), new ImageIcon( getClass().getResource( "dragicon.png" )));
// ggExportAFR.setTransferHandler( new AFRTransferHandler() );
// final MouseInputAdapter expAFRmia = new MouseInputAdapter() {
// private MouseEvent dndInit = null;
// private boolean dndStarted = false;
//
// public void mousePressed( MouseEvent e )
// {
// dndInit = e;
// dndStarted = false;
// }
//
// public void mouseReleased( MouseEvent e )
// {
// dndInit = null;
// dndStarted = false;
// }
//
// public void mouseDragged( MouseEvent e )
// {
// if( !dndStarted && (dndInit != null) &&
// ((Math.abs( e.getX() - dndInit.getX() ) > 5) ||
// (Math.abs( e.getY() - dndInit.getY() ) > 5))) {
//
// JComponent c = (JComponent) e.getSource();
// c.getTransferHandler().exportAsDrag( c, e, TransferHandler.COPY );
// dndStarted = true;
// }
// }
// };
//
// ggExportAFR.addMouseListener( expAFRmia );
// ggExportAFR.addMouseMotionListener( expAFRmia );
//
// timeTB.add( Box.createHorizontalStrut( 4 ));
// timeTB.addButton( ggExportAFR );
// ----------
topPane.setBorder( BorderFactory.createEmptyBorder( 2, 2, 2, 2 ));
timeTB.setOpaque( false );
topPane.add( timeTB );
// transTB.setOpaque( false );
// topPane.add( transTB );
topPane.add( Box.createHorizontalGlue() );
cbr = new ComponentBoundsRestrictor();
ggTreeExp = new TreeExpanderButton();
ggTreeExp.setExpandedToolTip( getResourceString( "buttonExpWaveTT" ));
ggTreeExp.setCollapsedToolTip( getResourceString( "buttonCollWaveTT" ));
ggTreeExp.setExpanded( true );
ggTreeExp.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e )
{
final Dimension d = getSize();
waveExpanded = ggTreeExp.isExpanded();
markVisible = viewMarkers && waveExpanded;
if( waveExpanded ) {
cbr.remove( getWindow() );
waveView.setVisible( true );
channelHeaderPanel.setVisible( true );
if( viewMarkers ) {
markAxis.setVisible( true );
markAxisHeader.setVisible( true );
}
scroll.setVisible( true );
timeTB.setVisible( true );
pack();
} else {
checkDecimatedTrails();
setPreferredSize( getSize() );
waveView.setVisible( false );
channelHeaderPanel.setVisible( false );
markAxis.setVisible( false );
markAxisHeader.setVisible( false );
scroll.setVisible( false );
timeTB.setVisible( false );
actionZoomAllOut.perform();
final int h = d.height - (waveView.getHeight() + scroll.getHeight() +
(viewMarkers ? markAxis.getHeight() : 0));
setSize( new Dimension( d.width - timeTB.getWidth(), h ));
cbr.setMinimumHeight( h );
cbr.setMaximumHeight( h );
cbr.add( getWindow() );
}
}
});
topPane.add( ggTreeExp );
gp.setGradientShift( 0, topPane.getPreferredSize().height );
cp.add( topPane, BorderLayout.NORTH );
cp.add( ggTrackPanel, BorderLayout.CENTER );
cp.add( box, BorderLayout.SOUTH );
// --- Tools ---
pointerTool = new TimelinePointerTool();
tools.put( new Integer( ToolAction.POINTER ), pointerTool );
tools.put( new Integer( ToolAction.ZOOM ), new TimelineZoomTool() );
// ---- TopPainter ----
trackPainter = new TopPainter() {
public void paintOnTop( Graphics2D g2 )
{
Rectangle r;
r = new Rectangle( 0, 0, wavePanel.getWidth(), wavePanel.getHeight() ); // getViewRect();