Changeset 12347 in josm


Ignore:
Timestamp:
2017-06-08T23:22:59+02:00 (2 years ago)
Author:
michael2402
Message:

Use preferences to store modeless setting and toggle dialog widht

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

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

    r12267 r12347  
    5454import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
    5555import org.openstreetmap.josm.data.ViewportData;
     56import org.openstreetmap.josm.data.preferences.BooleanProperty;
     57import org.openstreetmap.josm.data.preferences.IntegerProperty;
    5658import org.openstreetmap.josm.gui.dialogs.ChangesetDialog;
    5759import org.openstreetmap.josm.gui.dialogs.CommandStackDialog;
     
    8385import org.openstreetmap.josm.tools.Shortcut;
    8486
    85 
    8687/**
    8788 * One Map frame with one dataset behind. This is the container gui class whose
     
    9192 */
    9293public class MapFrame extends JPanel implements Destroyable, ActiveLayerChangeListener, LayerChangeListener {
    93 
     94    /**
     95     * Default width of the toggle dialog area.
     96     */
     97    public static final int DEF_TOGGLE_DLG_WIDTH = 330;
     98
     99    private final static IntegerProperty TOGGLE_DIALOGS_WIDTH = new IntegerProperty("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH);
     100    /**
     101     * Do not require to switch modes (potlatch style workflow) for drawing/selecting map modes.
     102     * @since 12347
     103     */
     104    public final static BooleanProperty MODELESS = new BooleanProperty("modeless", false);
    94105    /**
    95106     * The current mode, this frame operates.
     
    177188
    178189    /**
    179      * Default width of the toggle dialog area.
    180      */
    181     public static final int DEF_TOGGLE_DLG_WIDTH = 330;
    182 
    183     /**
    184190     * Constructs a new {@code MapFrame}.
    185191     * @param viewportData the initial viewport of the map. Can be null, then
     
    221227
    222228        dialogsPanel.setLayout(new BoxLayout(dialogsPanel, BoxLayout.Y_AXIS));
    223         dialogsPanel.setPreferredSize(new Dimension(Main.pref.getInteger("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH), 0));
     229        dialogsPanel.setPreferredSize(new Dimension(TOGGLE_DIALOGS_WIDTH.get(), 0));
    224230        dialogsPanel.setMinimumSize(new Dimension(24, 0));
    225231        mapView.setMinimumSize(new Dimension(10, 0));
     
    289295
    290296    public boolean selectSelectTool(boolean onlyIfModeless) {
    291         if (onlyIfModeless && !Main.pref.getBoolean("modeless", false))
     297        if (onlyIfModeless && !MODELESS.get())
    292298            return false;
    293299
     
    296302
    297303    public boolean selectDrawTool(boolean onlyIfModeless) {
    298         if (onlyIfModeless && !Main.pref.getBoolean("modeless", false))
     304        if (onlyIfModeless && !MODELESS.get())
    299305            return false;
    300306
     
    303309
    304310    public boolean selectZoomTool(boolean onlyIfModeless) {
    305         if (onlyIfModeless && !Main.pref.getBoolean("modeless", false))
     311        if (onlyIfModeless && !MODELESS.get())
    306312            return false;
    307313
     
    335341    }
    336342
     343    /**
     344     * Gets the action of the default (first) map mode
     345     * @return That action
     346     */
    337347    public Action getDefaultButtonAction() {
    338348        return ((AbstractButton) toolBarActions.getComponent(0)).getAction();
     
    346356    }
    347357
     358    /**
     359     * Adds a new toggle dialog to the left button list. It is displayed in expert and normal mode
     360     * @param dlg The dialog
     361     * @return The button
     362     */
    348363    public IconToggleButton addToggleDialog(final ToggleDialog dlg) {
    349364        return addToggleDialog(dlg, false);
     
    663678    }
    664679
     680    /**
     681     * Shows or hides the side dialog panel
     682     * @param visible The new visibility
     683     */
    665684    public void setDialogsPanelVisible(boolean visible) {
    666685        rememberToggleDialogWidth();
    667686        dialogsPanel.setVisible(visible);
    668         splitPane.setDividerLocation(visible ? splitPane.getWidth()-Main.pref.getInteger("toggleDialogs.width", DEF_TOGGLE_DLG_WIDTH) : 0);
     687        splitPane.setDividerLocation(visible ? splitPane.getWidth() - TOGGLE_DIALOGS_WIDTH.get() : 0);
    669688        splitPane.setDividerSize(visible ? 5 : 0);
    670689    }
     
    675694    public void rememberToggleDialogWidth() {
    676695        if (dialogsPanel.isVisible()) {
    677             Main.pref.putInteger("toggleDialogs.width", splitPane.getWidth()-splitPane.getDividerLocation());
     696            TOGGLE_DIALOGS_WIDTH.put(splitPane.getWidth() - splitPane.getDividerLocation());
    678697        }
    679698    }
  • trunk/src/org/openstreetmap/josm/gui/preferences/display/LafPreference.java

    r11713 r12347  
    2727import org.openstreetmap.josm.actions.ExpertToggleAction;
    2828import org.openstreetmap.josm.data.preferences.StringProperty;
     29import org.openstreetmap.josm.gui.MapFrame;
    2930import org.openstreetmap.josm.gui.MapMover;
    3031import org.openstreetmap.josm.gui.NavigatableComponent;
     
    135136
    136137        modeless.setToolTipText(tr("Do not require to switch modes (potlatch style workflow)"));
    137         modeless.setSelected(Main.pref.getBoolean("modeless", false));
     138        modeless.setSelected(MapFrame.MODELESS.get());
    138139        ExpertToggleAction.addVisibilitySwitcher(modeless);
    139140
     
    203204        Main.pref.put("osm-primitives.showid", showID.isSelected());
    204205        Main.pref.put("osm-primitives.localize-name", showLocalizedName.isSelected());
    205         Main.pref.put("modeless", modeless.isSelected());
     206        MapFrame.MODELESS.put(modeless.isSelected());
    206207        Main.pref.put(ToggleDialog.PROP_DYNAMIC_BUTTONS.getKey(), dynamicButtons.isSelected());
    207208        Main.pref.put(DateUtils.PROP_ISO_DATES.getKey(), isoDates.isSelected());
Note: See TracChangeset for help on using the changeset viewer.