Changeset 4355 in josm
- Timestamp:
- 2011-08-27T15:50:37+02:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r4354 r4355 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.AWTEvent; 6 7 import java.awt.BorderLayout; 7 8 import java.awt.Component; … … 12 13 import java.awt.GridLayout; 13 14 import java.awt.Image; 15 import java.awt.Point; 14 16 import java.awt.Rectangle; 17 import java.awt.Toolkit; 18 import java.awt.event.AWTEventListener; 15 19 import java.awt.event.ActionEvent; 16 20 import java.awt.event.ActionListener; … … 51 55 * 52 56 */ 53 public class ToggleDialog extends JPanel implements Helpful {57 public class ToggleDialog extends JPanel implements Helpful, AWTEventListener { 54 58 55 59 /** The action to toggle this dialog */ … … 89 93 protected JToggleButton button; 90 94 protected boolean buttonHidden; 95 private JPanel buttonsPanel; 91 96 92 97 /** … … 671 676 add(data, BorderLayout.CENTER); 672 677 if(buttons != null && buttons.size() != 0) { 673 JPanelbuttonsPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false)678 buttonsPanel = new JPanel(Main.pref.getBoolean("dialog.align.left", false) 674 679 ? new FlowLayout(FlowLayout.LEFT) : new GridLayout(1,buttons.size())); 675 680 for(SideButton button : buttons) 676 681 buttonsPanel.add(button); 677 682 add(buttonsPanel, BorderLayout.SOUTH); 683 if(Main.pref.getBoolean("dialog.dynamic.buttons", false)) { 684 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_MOTION_EVENT_MASK); 685 buttonsPanel.setVisible(false); 686 } 687 } 688 } 689 690 @Override 691 public void eventDispatched(AWTEvent event) { 692 if(isShowing()) { 693 Rectangle b = this.getBounds(); 694 b.setLocation(getLocationOnScreen()); 695 if (b.contains(((MouseEvent)event).getLocationOnScreen())) { 696 if(!buttonsPanel.isVisible()) { 697 buttonsPanel.setVisible(true); 698 } 699 } else if (buttonsPanel.isVisible()) { 700 buttonsPanel.setVisible(false); 701 } 678 702 } 679 703 }
Note:
See TracChangeset
for help on using the changeset viewer.