Ticket #7561: 7561_storeHeight.patch
| File 7561_storeHeight.patch, 3.8 KB (added by , 7 years ago) |
|---|
-
src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
63 63 } 64 64 65 65 this.add(mSpltPane); 66 reconstruct(Action. ELEMENT_SHRINKS, null);66 reconstruct(Action.RESTORE_SAVED, null); 67 67 } 68 68 69 69 /** … … 126 126 * The panel was collapsed by the user. 127 127 */ 128 128 COLLAPSED_TO_DEFAULT, 129 /** 130 * Restore saved heights. 131 */ 132 RESTORE_SAVED, 129 133 /* INVISIBLE_TO_COLLAPSED, does not happen */ 130 134 /** 131 135 * else. (Remaining elements have more space.) 132 136 */ 137 133 138 ELEMENT_SHRINKS 134 139 } 135 140 … … 186 191 /** 187 192 * Determine the panel geometry 188 193 */ 189 if (action == Action. ELEMENT_SHRINKS) {194 if (action == Action.RESTORE_SAVED) { 190 195 for (int i = 0; i < n; ++i) { 191 196 final ToggleDialog dlg = allDialogs.get(i); 192 197 if (dlg.isDialogInDefaultView()) { 198 final int ph = dlg.getLastHeight(); 199 final int ah = dlg.getSize().height; 200 dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, ah < 20 ? ph : ah)); 201 } 202 } 203 204 } else if (action == Action.ELEMENT_SHRINKS) { 205 for (int i = 0; i < n; ++i) { 206 final ToggleDialog dlg = allDialogs.get(i); 207 if (dlg.isDialogInDefaultView()) { 193 208 final int ph = dlg.getPreferredHeight(); 194 209 final int ah = dlg.getSize().height; 195 210 dlg.setPreferredSize(new Dimension(Integer.MAX_VALUE, ah < 20 ? ph : ah)); … … 236 251 final int hnTrig = hpTrig * s2 / (hpTrig + sumP); 237 252 triggeredBy.setPreferredSize(new Dimension(Integer.MAX_VALUE, hnTrig)); 238 253 239 /** This is remaini g for the other default view dialogs */254 /** This is remaining for the other default view dialogs */ 240 255 final int r = s2 - hnTrig; 241 256 242 257 /** -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
239 239 setPreferredSize(new Dimension(0, preferredHeight)); 240 240 /** Override any minimum sizes of child elements so the user can resize freely */ 241 241 setMinimumSize(new Dimension(0, 0)); 242 this.preferredHeight = preferredHeight;242 this.preferredHeight = Config.getPref().getInt(preferencePrefix+".preferredHeight", preferredHeight); 243 243 toggleAction = new ToggleDialogAction(name, "dialogs/"+iconName, tooltip, shortcut, helpTopic()); 244 244 245 245 isShowing = Config.getPref().getBoolean(preferencePrefix+".visible", defShow); … … 456 456 457 457 @Override 458 458 public void destroy() { 459 rememberHeight(); 459 460 closeDetachedDialog(); 460 461 if (isShowing) { 461 462 hideNotify(); … … 996 997 } 997 998 stateChanged(); 998 999 } 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 Logging.debug(preferencePrefix); 1013 int h = getHeight(); 1014 Config.getPref().put(preferencePrefix+".lastHeight", Integer.toString(h)); 1015 } 999 1016 }
