Changeset 5664 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-01-10T01:57:33+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/ImageryMenu.java
r5660 r5664 70 70 private Map_Rectifier_WMSmenuAction rectaction = new Map_Rectifier_WMSmenuAction(); 71 71 private int offsPos; 72 private MenuScroller menuScroller; 72 73 73 74 public ImageryMenu() { 74 75 super(tr("Imagery")); 76 setupMenuScroller(); 77 MapView.addLayerChangeListener(this); 78 } 79 80 private final void setupMenuScroller() { 75 81 int screenHeight = Toolkit.getDefaultToolkit().getScreenSize().height; 76 82 int menuItemHeight = singleOffset.getPreferredSize().height; 77 MenuScroller.setScrollerFor(this, (screenHeight / menuItemHeight)-1); 78 MapView.addLayerChangeListener(this); 83 menuScroller = MenuScroller.setScrollerFor(this, (screenHeight / menuItemHeight)-1); 79 84 } 80 85 81 86 public void refreshImageryMenu() { 87 if (menuScroller != null) { 88 menuScroller.dispose(); 89 menuScroller = null; 90 } 91 setupMenuScroller(); 82 92 removeAll(); 83 93 -
trunk/src/org/openstreetmap/josm/gui/MenuScroller.java
r5088 r5664 1 1 /** 2 * @(#)MenuScroller.java 1.4.0 14/09/102 * @(#)MenuScroller.java 1.5.0 04/02/12 3 3 */ 4 4 package org.openstreetmap.josm.gui; … … 10 10 import java.awt.event.ActionEvent; 11 11 import java.awt.event.ActionListener; 12 import java.awt.event.MouseWheelEvent; 13 import java.awt.event.MouseWheelListener; 14 12 15 import javax.swing.Icon; 13 16 import javax.swing.JComponent; … … 15 18 import javax.swing.JMenuItem; 16 19 import javax.swing.JPopupMenu; 17 import javax.swing.JSeparator;18 20 import javax.swing.MenuSelectionManager; 19 21 import javax.swing.Timer; … … 41 43 private MenuScrollItem downItem; 42 44 private final MenuScrollListener menuListener = new MenuScrollListener(); 45 private final MouseWheelListener mouseWheelListener = new MouseScrollListener(); 43 46 private int scrollCount; 44 47 private int interval; … … 293 296 this.menu = menu; 294 297 menu.addPopupMenuListener(menuListener); 298 menu.addMouseWheelListener(mouseWheelListener); 295 299 } 296 300 … … 419 423 if (menu != null) { 420 424 menu.removePopupMenuListener(menuListener); 425 menu.removeMouseWheelListener(mouseWheelListener); 426 menu.setPreferredSize(null); 421 427 menu = null; 422 428 } … … 448 454 } 449 455 if (topFixedCount > 0) { 450 menu.add (new JSeparator());456 menu.addSeparator(); 451 457 } 452 458 … … 458 464 459 465 if (bottomFixedCount > 0) { 460 menu.add (new JSeparator());466 menu.addSeparator(); 461 467 } 462 468 for (int i = menuItems.length - bottomFixedCount; i < menuItems.length; i++) { … … 475 481 } 476 482 } 477 483 478 484 private class MenuScrollListener implements PopupMenuListener { 479 485 … … 590 596 } 591 597 } 598 599 private class MouseScrollListener implements MouseWheelListener { 600 public void mouseWheelMoved(MouseWheelEvent mwe) { 601 if (menu.getComponents().length > scrollCount) { 602 firstIndex += mwe.getWheelRotation(); 603 refreshMenu(); 604 } 605 mwe.consume(); // (Comment 16, Huw) 606 } 607 } 592 608 }
Note:
See TracChangeset
for help on using the changeset viewer.