comparison mde/gui/widget/Window.d @ 40:b28d7adc786b

Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 08 May 2008 16:05:51 +0100
parents 5132301e9ed7
children b3a6ca4516b4
comparison
equal deleted inserted replaced
39:5132301e9ed7 40:b28d7adc786b
56 void finalise (IGui gui) 56 void finalise (IGui gui)
57 in { 57 in {
58 assert (gui !is null, "Window.finalise ("~name~"): gui is null"); 58 assert (gui !is null, "Window.finalise ("~name~"): gui is null");
59 } body { 59 } body {
60 // Check data was loaded: 60 // Check data was loaded:
61 if (widgetData is null || mutableData is null) 61 if (widgetData is null)
62 throw new WindowLoadException ("No widget/mutable data"); 62 throw new WindowLoadException ("No widget creation data");
63 63
64 gui_ = gui; 64 gui_ = gui;
65 rend = gui.renderer; 65 rend = gui.renderer;
66 66
67 // Get border sizes 67 // Get border sizes
70 70
71 // Create the primary widget (and indirectly all sub-widgets), throwing on error: 71 // Create the primary widget (and indirectly all sub-widgets), throwing on error:
72 widget = makeWidget (0); // primary widget always has ID 0. 72 widget = makeWidget (0); // primary widget always has ID 0.
73 widgetData = null; // data is no longer needed: allow GC to collect (cannot safely delete) 73 widgetData = null; // data is no longer needed: allow GC to collect (cannot safely delete)
74 74
75 // Note: this should return an empty array, but nothing much should happen if it's not empty:
75 widget.adjust (mutableData); // adjust/set size, etc. 76 widget.adjust (mutableData); // adjust/set size, etc.
76 mutableData = null; // no longer needed 77 mutableData = null; // no longer needed
77 78
78 widget.getCurrentSize (w,h); // and get this size 79 widget.getCurrentSize (w,h); // and get this size
79 w += border.l + border.r; // Adjust for border 80 w += border.l + border.r; // Adjust for border
109 in { 110 in {
110 assert (widgetData is null, "Window.writeAll: widgetData !is null"); 111 assert (widgetData is null, "Window.writeAll: widgetData !is null");
111 } body { 112 } body {
112 /+ NOTE: currently editing is impossible... 113 /+ NOTE: currently editing is impossible...
113 if (edited) { // only save the widget creation data if it's been adjusted: 114 if (edited) { // only save the widget creation data if it's been adjusted:
114 addSaveData (widget); // generate widget save data 115 addCreationData (widget); // generate widget save data
115 dlg (INTAA, WDGD, parseFrom!(int[][int]) (widgetData)); 116 dlg (INTAA, WDGD, parseFrom!(int[][int]) (widgetData));
116 }+/ 117 }+/
117 // Save mutable data: 118 // Save mutable data:
118 dlg (INTA, MD, parseFrom!(int[]) (widget.getMutableData)); 119 dlg (INTA, MD, parseFrom!(int[]) (widget.getMutableData));
119 // Save the window position: 120 // Save the window position: