Mercurial > projects > mde
comparison mde/gui/widget/layout.d @ 109:2a1428ec5344
Optional, visible spacing in grid layouts.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 04 Dec 2008 10:32:20 +0000 |
parents | 08651e8a8c51 |
children | 1655693702fc |
comparison
equal
deleted
inserted
replaced
108:c9fc2d303178 | 109:2a1428ec5344 |
---|---|
168 if (data.ints[1] & 2) | 168 if (data.ints[1] & 2) |
169 row = AlignColumns.getInstance (id~"R", rows); // id must be unique to that for cols! | 169 row = AlignColumns.getInstance (id~"R", rows); // id must be unique to that for cols! |
170 else | 170 else |
171 row = (new AlignColumns (rows)); | 171 row = (new AlignColumns (rows)); |
172 row.addSetCallback (&setRowHeight); | 172 row.addSetCallback (&setRowHeight); |
173 useSpacing = (data.ints[1] & 4) != 0; | |
173 } | 174 } |
174 | 175 |
175 /** Prior to finalizing but after sub-widgets are finalized, some information needs to be | 176 /** Prior to finalizing but after sub-widgets are finalized, some information needs to be |
176 * passed to the AlignColumns. */ | 177 * passed to the AlignColumns. */ |
177 void prefinalize () { | 178 void prefinalize () { |
274 void draw () { | 275 void draw () { |
275 super.draw (); | 276 super.draw (); |
276 | 277 |
277 foreach (widget; subWidgets) | 278 foreach (widget; subWidgets) |
278 widget.draw (); | 279 widget.draw (); |
280 | |
281 if (useSpacing) | |
282 mgr.renderer.drawSpacers (x,y, w,h, col.pos[1..$], row.pos[1..$]); | |
279 } | 283 } |
280 | 284 |
281 package: | 285 package: |
282 /* Calculations which need to be run whenever a new sub-widget structure is set | 286 /* Calculations which need to be run whenever a new sub-widget structure is set |
283 * (i.e. to produce cached data calculated from construction data). | 287 * (i.e. to produce cached data calculated from construction data). |
286 * rows, cols and subWidgets must be set before calling. Part of the set-up for AlignColumns | 290 * rows, cols and subWidgets must be set before calling. Part of the set-up for AlignColumns |
287 * (col and row). subWidgets need to know their minimal size and resizability. */ | 291 * (col and row). subWidgets need to know their minimal size and resizability. */ |
288 void genCachedConstructionData () { | 292 void genCachedConstructionData () { |
289 // Will only change if renderer changes: | 293 // Will only change if renderer changes: |
290 // NOTE shared AlignColumns get this set by all sharing GridWidgets | 294 // NOTE shared AlignColumns get this set by all sharing GridWidgets |
291 col.spacing = row.spacing = mgr.renderer.layoutSpacing; | 295 col.spacing = row.spacing = useSpacing ? mgr.renderer.layoutSpacing : 0; |
292 | 296 |
293 // Calculate the minimal column and row sizes: | 297 // Calculate the minimal column and row sizes: |
294 // AlignColumns (row, col) takes care of initializing minWidth. | 298 // AlignColumns (row, col) takes care of initializing minWidth. |
295 foreach (i,widget; subWidgets) { | 299 foreach (i,widget; subWidgets) { |
296 // Increase dimensions if current minimal size is larger: | 300 // Increase dimensions if current minimal size is larger: |
364 wdim dragX, dragY; // coords where drag starts | 368 wdim dragX, dragY; // coords where drag starts |
365 //END Col/row resizing callback | 369 //END Col/row resizing callback |
366 | 370 |
367 myIt cols, rows; // number of cells in grid | 371 myIt cols, rows; // number of cells in grid |
368 wdim[] initWidths; // see this / setInitialSize | 372 wdim[] initWidths; // see this / setInitialSize |
373 bool useSpacing; // true if spacing should be applied | |
369 | 374 |
370 /* All widgets in the grid, by row. Order: [ 0 1 ] | 375 /* All widgets in the grid, by row. Order: [ 0 1 ] |
371 * [ 2 3 ] */ | 376 * [ 2 3 ] */ |
372 //IChildWidget[] subWidgets; | 377 //IChildWidget[] subWidgets; |
373 | 378 |