Mercurial > projects > mde
comparison mde/gui/WidgetData.d @ 78:79a1809421aa
Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 29 Jul 2008 18:14:53 +0100 |
parents | 3dfd934100f7 |
children | 61ea26abe4dd |
comparison
equal
deleted
inserted
replaced
77:3dfd934100f7 | 78:79a1809421aa |
---|---|
177 * Is run when the manager is destroyed, but could be run at other times too. */ | 177 * Is run when the manager is destroyed, but could be run at other times too. */ |
178 void save () { | 178 void save () { |
179 mutex.lock; | 179 mutex.lock; |
180 scope(exit) mutex.unlock; | 180 scope(exit) mutex.unlock; |
181 | 181 |
182 if (noChanges) | 182 // Make all widgets save any changed data; return if no changes: |
183 if (!child.saveChanges ("root")) | |
183 return; | 184 return; |
184 | 185 |
185 if (loadUserFile) { // merge entries from user file into current changes | 186 if (loadUserFile) { // merge entries from user file into current changes |
186 try { | 187 try { |
187 scope IReader reader = confDir.makeMTReader ( | 188 scope IReader reader = confDir.makeMTReader ( |
232 return createWidget (this, curData[id]); | 233 return createWidget (this, curData[id]); |
233 } | 234 } |
234 | 235 |
235 /** For making changes. */ | 236 /** For making changes. */ |
236 void setData (widgetID id, WidgetData d) { | 237 void setData (widgetID id, WidgetData d) { |
237 noChanges = false; | |
238 changes[id] = d; // also updates WidgetDataSet in data. | 238 changes[id] = d; // also updates WidgetDataSet in data. |
239 } | 239 } |
240 | 240 |
241 /** Second stage of loading the widgets. | 241 /** Second stage of loading the widgets. |
242 * | 242 * |
262 private bool allLoaded = false; // applies to data | 262 private bool allLoaded = false; // applies to data |
263 WidgetDataSet curData; // Current data | 263 WidgetDataSet curData; // Current data |
264 WidgetDataChanges changes; // Changes for the current design. | 264 WidgetDataChanges changes; // Changes for the current design. |
265 scope mt.DataSet changesDS; // changes and sections from user file (used for saving) | 265 scope mt.DataSet changesDS; // changes and sections from user file (used for saving) |
266 bool loadUserFile = true; // still need to load user file for saving? | 266 bool loadUserFile = true; // still need to load user file for saving? |
267 bool noChanges = true; // do we have any changes to save? | |
268 | 267 |
269 scope IChildWidget child; // The primary widget. | 268 scope IChildWidget child; // The primary widget. |
270 | 269 |
271 Mutex mutex; // lock on methods for use outside the package. | 270 Mutex mutex; // lock on methods for use outside the package. |
272 } | 271 } |