Revision: 487 http://skycastle.svn.sourceforge.net/skycastle/?rev=487&view=rev Author: zzorn Date: 2008-04-26 17:52:45 -0700 (Sat, 26 Apr 2008) Log Message: ----------- Figured out how to make the menus and all popups and tooltips heavyweight, so that they can overlap the 3D view. Much nicer look without AWT menu! Modified Paths: -------------- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchView.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeRenderer.java trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeTool.java Modified: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchView.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchView.java 2008-04-27 00:15:19 UTC (rev 486) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/SketchView.java 2008-04-27 00:52:45 UTC (rev 487) @@ -14,11 +14,9 @@ import org.skycastle.util.simpleui.SimpleFrame; import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Frame; import java.util.HashMap; import java.util.Map; @@ -34,13 +32,13 @@ //====================================================================== // Private Fields - private final Map<String, Menu> myMenus = new HashMap<String, Menu>( 10 ); + private final Map<String, JMenu> myMenus = new HashMap<String, JMenu>( 10 ); private final SimpleFrame myMainFrame; private final Node myRoot3DNode; private Canvas3D myCanvas3D; private JToolBar myToolBar; - private MenuBar myMenuBar; + private JMenuBar myMenuBar; private Sketch mySketch; //====================================================================== @@ -57,7 +55,7 @@ ParameterChecker.checkNotNull( applicationName, "applicationName" ); myCanvas3D = new Canvas3D(); - myMenuBar = new MenuBar(); + myMenuBar = new JMenuBar(); myToolBar = new JToolBar(); myCanvas3D.removeAllNavigationGestures(); @@ -70,20 +68,13 @@ panel.add( myCanvas3D.get3DView(), BorderLayout.CENTER ); panel.add( myToolBar, BorderLayout.NORTH ); -/* - // Wrap toolbar in a border that gives it a bit of marigin on top, as the AWT menu overlaps it otherwsie. - myToolBar.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder( 0, 0, 0, 0, new Color( 128, 128,128)), - myToolBar.getBorder() )); -*/ - myMainFrame = new SimpleFrame( panel ); - myMainFrame.setMenuBar( myMenuBar ); + myMainFrame.setJMenuBar( myMenuBar ); myMainFrame.setTitle( applicationName ); -/* - final StrokeRenderer strokeRenderer = new StrokeRenderer( createTestStroke() ); - myCanvas3D.set3DNode( strokeRenderer ); -*/ + // Make all popup menus and tooltips heavyweight so that they can overlap the 3D view + JPopupMenu.setDefaultLightWeightPopupEnabled( false ); + ToolTipManager.sharedInstance().setLightWeightPopupEnabled( false ); } //---------------------------------------------------------------------- @@ -134,42 +125,8 @@ */ public void addMenuAction( final String menuName, final Action action ) { - // We need to use old style heavy AWT components, to render on top of the OpenGL surface. - // So we do a lot of adaption here, rahter than expose any clunky interface. - // The drawback is that it looks horrible, and overlaps the toolbar on 50% of the startups. - // TODO: Do a BannerBar in the style of Office 2007 instead of a separate menu and toolbar? - // It could maybe be a component that supports dockable / added panels/palettes too, for different tools. - - final MenuItem menuItem = new MenuItem( action.getValue( Action.NAME ).toString() ); - menuItem.setEnabled( action.isEnabled() ); - - // Listen to menu invocation - menuItem.addActionListener( new ActionListener() - { - - public void actionPerformed( final ActionEvent e ) - { - action.actionPerformed( e ); - } - - } ); - - // Listen to action enabled state changes - action.addPropertyChangeListener( new PropertyChangeListener() - { - - public void propertyChange( final PropertyChangeEvent evt ) - { - if ( "enabled".equals( evt.getPropertyName() ) ) - { - menuItem.setEnabled( action.isEnabled() ); - } - } - - } ); - // Add to menu - getOrCreateMenu( menuName ).add( menuItem ); + getOrCreateMenu( menuName ).add( action ); } @@ -273,12 +230,13 @@ } - private Menu getOrCreateMenu( final String menuName ) + private JMenu getOrCreateMenu( final String menuName ) { - Menu menu = myMenus.get( menuName ); + JMenu menu = myMenus.get( menuName ); if ( menu == null ) { - menu = new Menu( menuName ); + menu = new JMenu( menuName ); + menu.getPopupMenu().setLightWeightPopupEnabled( false ); myMenus.put( menuName, menu ); myMenuBar.add( menu ); } Modified: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeRenderer.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeRenderer.java 2008-04-27 00:15:19 UTC (rev 486) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeRenderer.java 2008-04-27 00:52:45 UTC (rev 487) @@ -290,7 +290,7 @@ final Vector3f positionMid = new Vector3f( xPos, yPos, zPos ); final ColorRGBA colorMid = strokePoint.getProperty( "color", - new ColorRGBA( 0, 0, 0, 1 ) ); + new ColorRGBA( 0, 0, 0, 0.7f ) ); final Vector3f positionRight = new Vector3f( xPos, yPos - width, zPos ); final ColorRGBA colorRight = strokePoint.getProperty( "color", Modified: trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeTool.java =================================================================== --- trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeTool.java 2008-04-27 00:15:19 UTC (rev 486) +++ trunk/skycastle/modules/ui/src/main/java/org/skycastle/sketch/StrokeTool.java 2008-04-27 00:52:45 UTC (rev 487) @@ -138,8 +138,8 @@ final float x = myStrokeX + getCamera().getLocation().getX(); final float y = myStrokeY + getCamera().getLocation().getY(); */ - final float x = myStrokeX / 20f; - final float y = -myStrokeY / 20f; + final float x = myStrokeX / 20f - 30; + final float y = -myStrokeY / 20f + 20; final StrokePointImpl strokePoint = new StrokePointImpl( x, y ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.