Changeset 128


Ignore:
Timestamp:
07/04/08 17:30:09 (16 years ago)
Author:
bjn8
Message:

Fixed popups with widgets. Added custom popup support.

Location:
trunk/src/org/expeditee
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r121 r128  
    335335                        return;
    336336               
     337                // Remove any popups that are showing on the current frame
     338                PopupManager.hideAllPopups();
     339               
    337340                if (_TwinFrames) {
    338341                        if (_CurrentFrames[0] == null) {
  • trunk/src/org/expeditee/gui/FrameGraphics.java

    r125 r128  
    22
    33import java.awt.Color;
    4 import java.awt.Component;
    5 import java.awt.Container;
    64import java.awt.Dimension;
    75import java.awt.EventQueue;
     
    108import java.awt.GraphicsEnvironment;
    119import java.awt.Image;
    12 import java.awt.Point;
    1310import java.awt.Rectangle;
    1411import java.awt.RenderingHints;
     
    2118import java.util.LinkedList;
    2219import java.util.List;
    23 
    24 import javax.swing.JComponent;
    25 import javax.swing.JPopupMenu;
    26 import javax.swing.SwingUtilities;
    2720
    2821import org.expeditee.items.Circle;
     
    429422                                PaintNonLinesNonPicture(bg, freeItemsToPaint);
    430423
    431                         // BROOK: Ensure popups are repainted
    432                         if (Browser._theBrowser != null)
    433                                 repaintPopups(Browser._theBrowser.getLayeredPane(), bg);
     424                        // Repaint popups / drags...
     425                        if (isActualFrame)
     426                                PopupManager.paintLayeredPane(bg, clip);
    434427
    435428                        bg.dispose();
    436429                }
    437430
     431               
     432               
    438433                return toPaint.getBuffer();
    439434        }
     
    698693        }
    699694
    700         private static void repaintPopups(Container parent, Graphics g) {
    701                 for (Component c : parent.getComponents()) {
    702                         if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) {
    703                                 Point p = SwingUtilities.convertPoint(c, c.getLocation(),
    704                                                 Browser._theBrowser.getContentPane());
    705 
    706                                 c.setIgnoreRepaint(true);
    707                                 ((JComponent)c).setDoubleBuffered(false);
    708                                 g.translate(p.x, p.y);
    709                                 c.paint(g);
    710                                 g.translate(-p.x, -p.y);
    711                         } else if (c instanceof Container
    712                                         && c != Browser._theBrowser.getContentPane()) {
    713                                 repaintPopups((Container) c, g);
    714                         }
    715                 }
    716         }
    717 
     695       
    718696        public static int getMode() {
    719697                return _Mode;
     
    805783                                damagedAreas.clear();
    806784                        }
    807                         //System.out.println("FULLSCREEN REFRESH"); // TODO: REMOVE
     785                        System.out.println("FULLSCREEN REFRESH"); // TODO: REMOVE
    808786                }
    809787
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r121 r128  
    228228                // System.out.println("MousePressed " + e.getX() + "," + e.getY() + " "
    229229                // + e.getWhen());
     230               
     231                // Auto-hide popups when user clicks into expeditee world
     232                PopupManager.hideAllPopups();
    230233
    231234                // TODO WHY DID I NOT COMMENT THIS LINE!! MIKE SAYS
     
    26742677                return Math.round(MouseY);
    26752678        }
     2679
     2680        public static Item getlastHighlightedItem() {
     2681                return _lastHighlightedItem;
     2682        }
    26762683}
  • trunk/src/org/expeditee/gui/MouseEventRouter.java

    r74 r128  
    1515import javax.swing.SwingUtilities;
    1616
    17 import org.expeditee.items.InteractiveWidget;
     17import org.expeditee.items.Item;
    1818
    1919/**
     
    6565         */
    6666        private void routeMouseEvent(MouseEvent e) {
    67 
     67               
    6868                // First convert the point to expeditee space
    6969                Point containerPoint = SwingUtilities.convertPoint(e.getComponent(), e
     
    8888                        // whether an expeditee item is currently picked up
    8989                        boolean forwardToExpiditee = false;
     90                        boolean isOverPopup = PopupManager.isPointOverPopup(containerPoint);
     91                        if (isOverPopup && FreeItems.getInstance().isEmpty()) {
     92                                // Popups have highest preference
     93                                // forwardToExpiditee = false...
    9094
    9195                        // Note: all frame.content pane events belong to expeditee
    92                         if (e.getSource() == _contentPane
     96                        } else if (e.getSource() == _contentPane
    9397                                        || e.getSource() == Browser._theBrowser
    94                                         || Frame.itemAttachedToCursor()) {
     98                                        || !FreeItems.getInstance().isEmpty()) {
    9599                                forwardToExpiditee = true;
    96100                        } else if (DisplayIO.getCurrentFrame() != null) { // is mouse over
     
    113117                        if (forwardToExpiditee) {
    114118
    115                                 // If forwarding to Expiditee ensure that widgets highlighting
    116                                 // is enabled
    117                                 // do give visual feedback yo users such that Expiditee has
    118                                 // focus.
    119                                 InteractiveWidget.enableExepiteeHighlighting(true);
    120 
    121119                                // Ensure that underlying widgets don't get the event
    122120                                e.consume();
     
    175173                                // highlighted
    176174                                // to give visual feedback yo users such that swing has focus.
    177                                 InteractiveWidget.enableExepiteeHighlighting(false);
     175                                Item i = FrameMouseActions.getlastHighlightedItem();
     176                                if (i != null && i.getHighlightMode() != Item.HighlightMode.None) {
     177                                        FrameGraphics.changeHighlightMode(i, Item.HighlightMode.None);
     178                                }
    178179
    179180                                // Also bring expideditee behaviour to swing: Auto-focus on
     
    187188                                                }
    188189                                        }
     190                                        // Auto-hide popups when user click on something other other than
     191                                        // a popup - and is not a on a popup invoker
     192                                } else if (!isOverPopup && e.getID() == MouseEvent.MOUSE_PRESSED &&
     193                                                !PopupManager.isInvoker(e.getComponent())) {
     194                                        PopupManager.hideAllPopups();
    189195                                }
    190196                        }
  • trunk/src/org/expeditee/items/InteractiveWidget.java

    r127 r128  
    957957        }
    958958
    959         private static boolean _isExepiteeHighlightingEnabled = true;
    960 
    961         /**
    962          * Enables/Disables highlighting of all widgets - if the enable value has
    963          * changed the current frame will repaint.
    964          *
    965          * The purpose of this is so that widgets can have an extra context: no
    966          * expeditee highlighting if focus is on a swing componant.
    967          *
    968          * @param enable
    969          *            Set to true to enable painting, false to disable painting.
    970          */
    971         public static void enableExepiteeHighlighting(boolean enable) {
    972                 if (_isExepiteeHighlightingEnabled != enable) {
    973                         _isExepiteeHighlightingEnabled = enable;
    974                         FrameGraphics.Repaint();
    975                 }
    976         }
    977 
    978         public static boolean isExpediteeHighlightingEnabled() {
    979                 return _isExepiteeHighlightingEnabled;
    980         }
    981 
    982959        /**
    983960         * Removes this widget from the parent frame or free space
     
    1009986        }
    1010987       
    1011        
    1012988}
  • trunk/src/org/expeditee/items/WidgetCorner.java

    r121 r128  
    1010       
    1111        private InteractiveWidget _widgetSource;
     12        public static final float BORDER_THICKNESS = 2.0f;
    1213
    1314        WidgetCorner(int x, int y, int id, InteractiveWidget widgetSource) {
    1415                super(x, y, id);
    1516               
    16                 super.setThickness(2.0f);
     17                super.setThickness(BORDER_THICKNESS);
    1718               
    1819                if (widgetSource == null) throw new NullPointerException("widgetSource");
     
    6566        @Override
    6667        public void paint(Graphics2D g) {
    67                 if (InteractiveWidget.isExpediteeHighlightingEnabled()) { // only paint if flag is set to true
    68                        
    69                         // For fixed widgets, always have corner selected with connected context
    70                         HighlightMode tmp = _mode; // save mode
    71                         if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
    72                                 _mode = HighlightMode.Connected; // draw as connected context for fixed widgets
    73                         }
    74                         super.paint(g);
    75                         _mode = tmp; // restore mode
     68                // For fixed widgets, always have corner selected with connected context
     69                HighlightMode tmp = _mode; // save mode
     70                if (_mode == HighlightMode.Normal && _widgetSource.isFixedSize()) {
     71                        _mode = HighlightMode.Connected; // draw as connected context for fixed widgets
    7672                }
     73                super.paint(g);
     74                _mode = tmp; // restore mode
    7775        }
    7876       
Note: See TracChangeset for help on using the changeset viewer.