Ignore:
Timestamp:
2020-07-14T19:50:11+02:00 (4 years ago)
Author:
simon04
Message:

see #13173 - Fix cursor hotspot for HiDPI (patch by johsin18, modified)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r16643 r16764  
    13301330
    13311331    /**
     1332     * The cursor hotspot constants {@link #DEFAULT_HOTSPOT} and {@link #CROSSHAIR_HOTSPOT} are relative to this cursor size
     1333     */
     1334    protected static final int CURSOR_SIZE_HOTSPOT_IS_RELATIVE_TO = 32;
     1335    private static final Point DEFAULT_HOTSPOT = new Point(3, 2);  // FIXME: define better hotspot for rotate.png
     1336    private static final Point CROSSHAIR_HOTSPOT = new Point(10, 10);
     1337
     1338    /**
    13321339     * Load a cursor image with a given file name, optionally decorated with an overlay image
    13331340     *
     
    13451352                                                .setMaxSize(ImageSizes.CURSOROVERLAY)));
    13461353        }
    1347         hotSpot.setLocation("crosshair".equals(name) ? new Point(10, 10) : new Point(3, 2));
    13481354        ImageIcon imageIcon = imageProvider.get();
    13491355        Image image = imageIcon.getImage();
     
    13611367                image = image.getScaledInstance(bestCursorSize.width, bestCursorSize.height, Image.SCALE_DEFAULT);
    13621368            }
    1363 
    1364             hotSpot.x = hotSpot.x * bestCursorSize.width / width;
    1365             hotSpot.y = hotSpot.y * bestCursorSize.height / height;
    1366         }
     1369        }
     1370
     1371        hotSpot.setLocation("crosshair".equals(name) ? CROSSHAIR_HOTSPOT : DEFAULT_HOTSPOT);
     1372        hotSpot.x = hotSpot.x * image.getWidth(null) / CURSOR_SIZE_HOTSPOT_IS_RELATIVE_TO;
     1373        hotSpot.y = hotSpot.y * image.getHeight(null) / CURSOR_SIZE_HOTSPOT_IS_RELATIVE_TO;
    13671374
    13681375        return image;
Note: See TracChangeset for help on using the changeset viewer.