Changeset 2217 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2009-09-30T01:21:34+02:00 (15 years ago)
Author:
xeen
Message:

Fix #3576 (now takes width constraints into account when moving the popup)
Remove some superflous repaint calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapStatus.java

    r2143 r2217  
    249249            Point p = mv.getLocationOnScreen();
    250250            Dimension scrn = Toolkit.getDefaultToolkit().getScreenSize();
    251             Dimension dim = content.getPreferredSize();
    252 
    253             int xPos = p.x + ms.mousePos.x + 16;
    254             // Display the popup to the left of the cursor if it would be cut
    255             // off on its right
    256             if(xPos + dim.width > scrn.width) {
    257                 xPos = p.x + ms.mousePos.x - 4 - dim.width;
    258             }
    259             int yPos = p.y + ms.mousePos.y + 16;
    260             // Move the popup up if it would be cut off at its bottom but do not
    261             // move it off screen on the top
    262             if(yPos + dim.height > scrn.height - 5) {
    263                 yPos = Math.max(5, scrn.height - dim.height - 5);
    264             }
    265 
    266             // Create a JScrollPane around the content, in case there's still
    267             // not enough space
     251
     252            // Create a JScrollPane around the content, in case there's not
     253            // enough space
    268254            JScrollPane sp = new JScrollPane(content);
    269255            sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
     
    271257            // Implement max-size content-independent
    272258            Dimension prefsize = sp.getPreferredSize();
    273             int w = Math.min(prefsize.width, scrn.width/2);
     259            int w = Math.min(prefsize.width, Math.min(800, (scrn.width/2) - 16));
    274260            int h = Math.min(prefsize.height, scrn.height - 10);
    275261            sp.setPreferredSize(new Dimension(w, h));
     262
     263            int xPos = p.x + ms.mousePos.x + 16;
     264            // Display the popup to the left of the cursor if it would be cut
     265            // off on its right, but only if more space is available
     266            if(xPos + w > scrn.width && xPos > scrn.width/2) {
     267                xPos = p.x + ms.mousePos.x - 4 - w;
     268            }
     269            int yPos = p.y + ms.mousePos.y + 16;
     270            // Move the popup up if it would be cut off at its bottom but do not
     271            // move it off screen on the top
     272            if(yPos + h > scrn.height - 5) {
     273                yPos = Math.max(5, scrn.height - h - 5);
     274            }
    276275
    277276            PopupFactory pf = PopupFactory.getSharedInstance();
     
    324323            }
    325324            DataSet.fireSelectionChanged(Main.main.getCurrentDataSet().getSelected());
    326             mv.repaint();
    327325        }
    328326
     
    383381         * Sets the colors for the given label depending on the selected status of
    384382         * the given OsmPrimitive
    385          * 
     383         *
    386384         * @param lbl The label to color
    387385         * @param osm The primitive to derive the colors from
     
    453451                    osm.setSelected(!osm.isSelected());
    454452                    DataSet.fireSelectionChanged(Main.main.getCurrentDataSet().getSelected());
    455                     mv.repaint();
    456453                    l.validate();
    457454                }
Note: See TracChangeset for help on using the changeset viewer.