Changeset 14425 in josm


Ignore:
Timestamp:
2018-11-16T09:35:34+01:00 (3 weeks ago)
Author:
GerdP
Message:

see #7561 comment 24
slightly modified 7561_storeHeight.patch,

1a) When JOSM is closed or all layers are removed so that the "splash screen" is showed, the current height of each dialog is stored in the preferences file. The values are stored in preferencePrefix+".lastHeight".
1b) When JOSM is started or a first layer is opened, the previously stored values are restored.
2) The hard coded preferredHeight values are now also stored in preferencePrefix+".preferredHeight". The expert can change that value to a higher or lower value. When the sizes are refreshed because a dialog is added, removed or minimized the modified value is taken into account. With the current implementation the change is only taken into account when JOSM is stopped/started.

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

Legend:

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

    r13265 r14425  
    6464
    6565        this.add(mSpltPane);
    66         reconstruct(Action.ELEMENT_SHRINKS, null);
     66        reconstruct(Action.RESTORE_SAVED, null);
    6767    }
    6868
     
    127127         */
    128128        COLLAPSED_TO_DEFAULT,
     129        /**
     130         * Restore saved heights.
     131         */
     132        RESTORE_SAVED,
    129133        /*  INVISIBLE_TO_COLLAPSED,    does not happen */
    130134        /**
     
    187191         * Determine the panel geometry
    188192         */
    189         if (action == Action.ELEMENT_SHRINKS) {
     193        if (action == Action.RESTORE_SAVED) {
     194            for (int i = 0; i < n; ++i) {
     195                final ToggleDialog dlg = allDialogs.get(i);
     196                if (dlg.isDialogInDefaultView()) {
     197                    final int ph = dlg.getLastHeight();
     198                    final int ah = dlg.getSize().height;
     199                    dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, ah < 20 ? ph : ah));
     200                }
     201            }
     202
     203        } else if (action == Action.ELEMENT_SHRINKS) {
    190204            for (int i = 0; i < n; ++i) {
    191205                final ToggleDialog dlg = allDialogs.get(i);
     
    237251            triggeredBy.setPreferredSize(new Dimension(Integer.MAX_VALUE, hnTrig));
    238252
    239             /** This is remainig for the other default view dialogs */
     253            /** This is remaining for the other default view dialogs */
    240254            final int r = s2 - hnTrig;
    241255
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r14397 r14425  
    240240        /** Override any minimum sizes of child elements so the user can resize freely */
    241241        setMinimumSize(new Dimension(0, 0));
    242         this.preferredHeight = preferredHeight;
     242        this.preferredHeight = Config.getPref().getInt(preferencePrefix+".preferredHeight", preferredHeight);
    243243        toggleAction = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortcut, helpTopic());
    244244
     
    457457    @Override
    458458    public void destroy() {
     459        rememberHeight();
    459460        closeDetachedDialog();
    460461        if (isShowing) {
     
    997998        stateChanged();
    998999    }
     1000
     1001    /**
     1002     * @return the last used height stored in preferences or preferredHeight
     1003     */
     1004    public int getLastHeight() {
     1005        return Config.getPref().getInt(preferencePrefix+".lastHeight", preferredHeight);
     1006    }
     1007
     1008    /**
     1009     * Store the current height in preferences so that we can restore it.
     1010     */
     1011    public void rememberHeight() {
     1012        int h = getHeight();
     1013        Config.getPref().put(preferencePrefix+".lastHeight", Integer.toString(h));
     1014    }
    9991015}
Note: See TracChangeset for help on using the changeset viewer.