annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify it under the terms
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /// Gui layout widgets.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 module mde.gui.widget.layout;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 import mde.gui.widget.Widget;
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 38
diff changeset
20 import mde.gui.exception;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21
105
08651e8a8c51 Quit button, big changes to content system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 103
diff changeset
22 import mde.content.Content;
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 71
diff changeset
23
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
24 import tango.util.container.HashMap;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
25
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
26 debug {
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
27 import tango.util.log.Log : Log, Logger;
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
28 private Logger logger;
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
29 static this () {
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
30 logger = Log.getLogger ("mde.gui.widget.layout");
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
31 }
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
32 }
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
33
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
34 /*************************************************************************************************
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
35 * Encapsulates a grid of Widgets.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
36 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
37 * Currently there is no support for changing number of cells, sub-widgets or sub-widget properties
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
38 * (namely isW/HSizable and minimal size) after this() has run.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
39 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
40 * Since a grid with either dimension zero is not useful, there must be at least one sub-widget.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
41 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
42 * The grid has no border but has spacing between widgets.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
43 *************************************************************************************************/
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
44 class GridLayoutWidget : GridWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
45 {
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
46 /** Constructor for a grid layout widget.
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
47 *
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
48 * Widget uses the initialisation data:
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
49 * ---
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
50 * ints = [widget_type, align_flags, rows, cols]
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
51 * // or with column widths and row heights:
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
52 * ints = [widget_type, align_flags, rows, cols, col1width, ..., colCwidth, row1height, ..., rowRheight]
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
53 * strings = [w11, w12, ..., w1C, ..., wR1, ..., wRC]
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
54 * ---
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
55 * where R and C are the number of rows and columns, and wij is the ID (from parent Window's
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
56 * list) for the widget in row i and column j. The number of parameters must be r*c + 3.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
57 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
58 * The content parameter is passed on to all children accepting an IContent. */
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
59 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent content) {
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
60 // Get grid size and check data
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
61 // Check sufficient data for type, align-flags, rows, cols, and possibly row/col widths.
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
62 if (data.ints.length != 4) throw new WidgetDataException (this);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 38
diff changeset
63
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
64 rows = data.ints[2];
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
65 cols = data.ints[3];
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
66 // Check: at least one sub-widget, ints length == 3, strings' length is correct:
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
67 if (rows < 1 || cols < 1 || data.ints.length != 4 || data.strings.length != rows * cols)
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
68 throw new WidgetDataException (this);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
69
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
70 // Get all sub-widgets
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
71 subWidgets.length = rows*cols;
41
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
72 foreach (i, ref subWidget; subWidgets) {
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
73 subWidget = mgr.makeWidget (data.strings[i], content);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
74 }
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
75
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
76 initWidths = mgr.dimData (id); // may be null, tested later
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
77
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
78 super (mgr, id, data);
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
79 }
78
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
80
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
81 // Save column/row sizes. Currently always do so.
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
82 bool saveChanges () {
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
83 foreach (widget; subWidgets) // recurse on subwidgets
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
84 widget.saveChanges ();
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
85
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
86 mgr.setDimData (id, col.width ~ row.width);
78
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
87 return true;
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
88 }
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
89 protected:
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
90 }
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
91
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
92
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
93 /*************************************************************************************************
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
94 * Iterates on an ContentList to produce a list of widgets, each of which is created with widgetID
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
95 * data.strings[0]. If an IContent is passed, this is cast to a ContentList, otherwise
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
96 * content.Items is used to get an IContent. It is an error if the content fails to cast to
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
97 * ContentList.
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
98 *************************************************************************************************/
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
99 class ContentListWidget : GridWidget
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
100 {
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
101 this (IWidgetManager mgr, widgetID id, WidgetData data, IContent content) {
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 71
diff changeset
102 debug scope (failure)
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 71
diff changeset
103 logger.warn ("TrialContentLayoutWidget: failure");
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
104 WDCheck (data, 2, 1);
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
105
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
106 cList = cast(ContentList) content;
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
107 if (cList is null)
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
108 throw new ContentException;
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
109
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 71
diff changeset
110 cols = 1;
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
111 if ((rows = cList.list.length) > 0) {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
112 subWidgets.length = rows;
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
113 foreach (i, c; cList.list) {
94
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 93
diff changeset
114 subWidgets[i] = mgr.makeWidget (data.strings[0], c);
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 93
diff changeset
115 }
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 93
diff changeset
116 } else {
9520cc0448e5 Boolean options are now encapsulated within a Content class (currently an experiment).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 93
diff changeset
117 rows = 1;
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
118 subWidgets = [mgr.makeWidget (data.strings[0], new ErrorContent ("<empty list>"))];
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
119 }
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
120 super (mgr, id, data);
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
121 }
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
122
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
123 bool saveChanges () {
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
124 // Since all sub-widgets have the same id, it only makes sense to call on one
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
125 if (subWidgets is null)
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
126 return false;
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
127 return subWidgets[0].saveChanges;
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
128 }
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
129
72
159775502bb4 The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 71
diff changeset
130 private:
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
131 ContentList cList;
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
132 }
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
133
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
134
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
135 /*************************************************************************************************
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
136 * Backend for grid-based (includes column/row) layout widgets.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
137 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
138 * A deriving class must at least do some work in it's constructor (see Ddoc for this() below)
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
139 * and provide an implementation of getCreationData() (unless Widget's version is sufficient).
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
140 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
141 * Since a grid with either dimension zero is not useful, there must be at least one sub-widget.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
142 *
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
143 * The grid has no border but has spacing between widgets.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
144 *************************************************************************************************/
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
145 abstract class GridWidget : AParentWidget
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
146 {
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
147 //BEGIN Creation & saving
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
148 /** Partial constructor for a grid layout widget.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
149 *
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
150 * Deriving classes should check data lengths, and set rows, cols, and the subWidgets array,
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
151 * before calling this super constructor. (If it's necessary to call super(...) first,
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
152 * the call to genCachedConstructionData can be moved to the derived this() methods.)
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
153 *
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
154 * Derived constructors may also set initWidths to the array of column widths followed by
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
155 * row heights used to initially set the row/column dimensions.
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
156 *
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
157 * Sub-widgets are finalized here, so no methods should be called on sub-widgets before calling
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
158 * this super. */
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
159 protected this (IWidgetManager mgr, widgetID id, WidgetData data) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
160 super (mgr, id, data);
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
161
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
162 // Create cell aligners with appropriate col/row adjustment function
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
163 if (data.ints[1] & 1)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
164 col = AlignColumns.getInstance (id, cols);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
165 else
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
166 col = (new AlignColumns (cols));
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
167 col.addSetCallback (&setColWidth);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
168 if (data.ints[1] & 2)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
169 row = AlignColumns.getInstance (id~"R", rows); // id must be unique to that for cols!
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
170 else
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
171 row = (new AlignColumns (rows));
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
172 row.addSetCallback (&setRowHeight);
109
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
173 useSpacing = (data.ints[1] & 4) != 0;
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
174 }
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
175
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
176 /** Prior to finalizing but after sub-widgets are finalized, some information needs to be
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
177 * passed to the AlignColumns. */
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
178 void prefinalize () {
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
179 genCachedConstructionData; // min widths, sizableness
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
180 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
181
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
182 /** Responsible for calculating the minimal size and initializing some stuff.
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
183 *
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
184 * As such, this must be the first function called after this(). */
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
185 void finalize () {
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
186 if (initWidths.length == cols + rows) {
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
187 col.setWidths (initWidths[0..cols]);
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
188 row.setWidths (initWidths[cols..$]);
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
189 } else {
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
190 col.setWidths;
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
191 row.setWidths;
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
192 }
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
193 initWidths = null; // free
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
194
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
195 mw = col.mw;
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
196 mh = row.mw;
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
197 w = col.w;
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
198 h = row.w;
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
199
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
200 // Tell subwidgets their new sizes. Positions are given by a later call to setPosition.
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
201 foreach (i,widget; subWidgets) {
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
202 // Resizing direction is arbitrarily set to negative:
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
203 widget.setWidth (col.width[i % cols], -1);
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
204 widget.setHeight (row.width[i / cols], -1);
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
205 }
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 38
diff changeset
206 }
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
207 //END Creation & saving
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 38
diff changeset
208
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
209 //BEGIN Size & position
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
210 bool isWSizable () {
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
211 return col.firstSizable >= 0;
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
212 }
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
213 bool isHSizable () {
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
214 return row.firstSizable >= 0;
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
215 }
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
216
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
217 void setWidth (wdim nw, int dir) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
218 w = col.resizeWidth (nw, dir);
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
219 // Note: setPosition must be called after!
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
220 }
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
221 void setHeight (wdim nh, int dir) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
222 h = row.resizeWidth (nh, dir);
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
223 // Note: setPosition must be called after!
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
224 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
225
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
226 void setPosition (wdim x, wdim y) {
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
227 this.x = x;
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
228 this.y = y;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
229
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
230 debug assert (col.pos && row.pos, "setPosition: col/row.pos not set (code error)");
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
231 foreach (i,widget; subWidgets)
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
232 widget.setPosition (x + col.pos[i % cols], y + row.pos[i / cols]);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
233 }
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
234 //END Size & position
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
235
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
236
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
237 // Find the relevant widget.
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
238 IChildWidget getWidget (wdim cx, wdim cy) {
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
239 debug scope (failure)
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
240 logger.warn ("getWidget: failure; values: click, pos, width - {}, {}, {} - {}, {}, {}", cx, x, w, cy, y, h);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
241 debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)");
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
242
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
243 // Find row/column:
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
244 myDiff i = col.getCell (cx - x);
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
245 myDiff j = row.getCell (cy - y);
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
246 if (i < 0 || j < 0) // on a space between widgets
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
247 return this;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
248
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
249 // On a subwidget; recurse call:
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
250 return subWidgets[i + j*cols].getWidget (cx, cy);
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
251 }
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
252
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
253 // Resizing columns & rows
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
254 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) {
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
255 debug scope (failure)
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
256 logger.warn ("clickEvent: failure");
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
257 if (b == 1 && state == true) {
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
258 /* Note: Because of getWidget, this function is only called if the click is not on a
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
259 * sub-widget, so we know it's on some divisor (so at least one of resizeCol and
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
260 * resizeRow is non-negative). */
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
261
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
262 // find col/row's resizeD & resizeU
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
263 if (col.findResizeCols (cx - x) && row.findResizeCols (cy - y))
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
264 return 0; // unable to resize
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
265
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
266 dragX = cx;
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
267 dragY = cy;
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
268
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
269 mgr.addClickCallback (&endCallback);
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
270 mgr.addMotionCallback (&resizeCallback);
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
271 }
99
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 95
diff changeset
272 return 0;
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
273 }
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
274
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
275 void draw () {
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
276 super.draw ();
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
277
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
278 foreach (widget; subWidgets)
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
279 widget.draw ();
109
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
280
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
281 if (useSpacing)
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
282 mgr.renderer.drawSpacers (x,y, w,h, col.pos[1..$], row.pos[1..$]);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
283 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
284
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
285 package:
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
286 /* Calculations which need to be run whenever a new sub-widget structure is set
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
287 * (i.e. to produce cached data calculated from construction data).
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
288 * Also need to be re-run if the renderer changes.
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
289 *
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
290 * rows, cols and subWidgets must be set before calling. Part of the set-up for AlignColumns
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
291 * (col and row). subWidgets need to know their minimal size and resizability. */
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
292 void genCachedConstructionData () {
71
77c7d3235114 Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 66
diff changeset
293 // Will only change if renderer changes:
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
294 // NOTE shared AlignColumns get this set by all sharing GridWidgets
109
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
295 col.spacing = row.spacing = useSpacing ? mgr.renderer.layoutSpacing : 0;
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
296
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
297 // Calculate the minimal column and row sizes:
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
298 // AlignColumns (row, col) takes care of initializing minWidth.
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
299 foreach (i,widget; subWidgets) {
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
300 // Increase dimensions if current minimal size is larger:
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
301 myIt n = i % cols; // column
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
302 wdim md = widget.minWidth;
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
303 if (col.minWidth[n] < md) col.minWidth[n] = md;
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
304 n = i / cols; // row
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
305 md = widget.minHeight;
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
306 if (row.minWidth[n] < md) row.minWidth[n] = md;
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
307 }
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
308
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
309 // Find which cols/rows are resizable:
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
310 // AlignColumns initializes sizable, and sets first and last sizables.
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
311 forCols:
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
312 for (myIt i = 0; i < cols; ++i) { // for each column
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
313 for (myIt j = 0; j < subWidgets.length; j += cols) // for each row
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
314 if (!subWidgets[i+j].isWSizable) // column not resizable
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
315 continue forCols; // continue the outer for loop
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
316
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
317 // column is resizable if we get to here
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
318 col.sizable[i] = true;
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
319 }
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
320
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
321 forRows:
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
322 for (myIt i = 0; i < subWidgets.length; i += cols) { // for each row
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
323 for (myIt j = 0; j < cols; ++j) // for each column
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
324 if (!subWidgets[i+j].isHSizable)
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
325 continue forRows;
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
326
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
327 row.sizable[i / cols] = true;
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
328 }
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
329 }
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 38
diff changeset
330
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
331 private:
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
332 void setColWidth (myIt i, wdim w, int dir) {
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
333 for (myIt j = 0; j < rows; ++j) {
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
334 subWidgets[i + cols*j].setWidth (w, dir);
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
335 }
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
336 }
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
337 void setRowHeight (myIt j, wdim h, int dir) {
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
338 for (myIt i = 0; i < cols; ++i) {
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
339 subWidgets[i + cols*j].setHeight (h, dir);
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
340 }
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
341 }
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
342
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
343
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
344 //BEGIN Col/row resizing callback
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
345 void resizeCallback (wdim cx, wdim cy) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
346 col.resizeCols (cx - dragX);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
347 row.resizeCols (cy - dragY);
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
348
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
349 // NOTE: all adjustments are relative; might be better if they were absolute?
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
350 dragX = cx;
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
351 dragY = cy;
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
352
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
353 foreach (i,widget; subWidgets)
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
354 widget.setPosition (x + col.pos[i % cols],
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
355 y + row.pos[i / cols]);
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
356 mgr.requestRedraw;
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
357 }
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
358 bool endCallback (wdabs cx, wdabs cy, ubyte b, bool state) {
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
359 if (b == 1 && state == false) {
77
3dfd934100f7 Continuing widget data changes started in last commit: all previous widgets work again now (but lacking saving).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 72
diff changeset
360 mgr.removeCallbacks (cast(void*) this);
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
361 return true; // we've handled the up-click
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
362 }
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
363 return false; // we haven't handled it
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
364 }
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
365
40
b28d7adc786b Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 39
diff changeset
366 protected:
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
367 // Data for resizing cols/rows:
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 46
diff changeset
368 wdim dragX, dragY; // coords where drag starts
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
369 //END Col/row resizing callback
42
8bf53e711cc7 Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 41
diff changeset
370
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
371 myIt cols, rows; // number of cells in grid
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
372 wdim[] initWidths; // see this / setInitialSize
109
2a1428ec5344 Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 105
diff changeset
373 bool useSpacing; // true if spacing should be applied
43
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
374
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
375 /* All widgets in the grid, by row. Order: [ 0 1 ]
1530d9c04d4d Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents: 42
diff changeset
376 * [ 2 3 ] */
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
377 //IChildWidget[] subWidgets;
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 34
diff changeset
378
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
379 AlignColumns col, row;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
380 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
381
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
382
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
383 /**************************************************************************************************
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
384 * Alignment device
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
385 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
386 * E.g. can control widths of columns within a grid, and provide sensible resizing, respecting the
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
387 * minimal width required by each cell in a column. Is not restricted to horizontal widths, but to
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
388 * ease descriptions, a horizontal context (column widths) is assumed.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
389 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
390 * Cells should be of type IChildWidget.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
391 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
392 * Cells are not directly interacted with, but minimal widths for each column are passed, and
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
393 * callback functions are used to adjust the width of any column.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
394 *************************************************************************************************/
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
395 package class AlignColumns
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
396 {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
397 /** Instance returned will be shared with any other widgets of same widgetID.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
398 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
399 * Also ensures each widget sharing an instance expects the same number of columns. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
400 static AlignColumns getInstance (widgetID id, myIt columns) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
401 AlignColumns* p = id in instances;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
402 if (p) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
403 if (p.minWidth.length != columns)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
404 throw new GuiException ("AlignColumns: no. of columns varies between sharing widgets (code error)");
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
405 //logger.trace ("Shared alignment for: "~id);
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
406 return *p;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
407 } else {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
408 auto a = new AlignColumns (columns);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
409 instances[id] = a;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
410 return a;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
411 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
412 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
413
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
414 /** Create an instance. After creation, the number of columns can only be changed by calling
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
415 * reset.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
416 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
417 * After creation, minimal widths should be set for all columns (minWidth) and
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
418 * setWidths must be called before other functions are used. */
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
419 this (myIt columns) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
420 reset (columns);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
421 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
422
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
423 /** Reset all column information (only keep set callbacks).
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
424 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
425 * Widths should be set after calling, as on creation. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
426 void reset (myIt columns) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
427 if (columns < 1)
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
428 throw new GuiException("AlignColumns: created with <1 column (code error)");
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
429 minWidth = new wdim[columns];
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
430 sizable = new bool[columns];
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
431 width = null; // enforce calling setWidths after this
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
432 firstSizable = -1;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
433 lastSizable = -1;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
434 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
435
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
436 /** Initialize widths, either from minWidths or from supplied list, checking validity.
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
437 *
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
438 * Also calculates first/lastSizable from sizable, overall minimal width and column positions.
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
439 */
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
440 void setWidths (wdim[] data = null) {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
441 if (!width) {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
442 if (data) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
443 debug assert (data.length == minWidth.length, "setWidths called with bad data length (code error)");
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
444 width = data.dup; // data is shared by other widgets with same id so must be .dup'ed
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
445 // And check sizes are valid:
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
446 foreach (i, m; minWidth) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
447 if (!sizable[i] || width[i] < m) // if width is fixed or less than minimum
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
448 width[i] = m;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
449 }
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
450 } else
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
451 width = minWidth.dup;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
452
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
453 /* Calculate the minimal width of all columns plus spacing. */
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
454 mw = spacing * cast(wdim)(minWidth.length - 1);
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
455 foreach (imw; minWidth)
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
456 mw += imw;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
457
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
458 genPositions;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
459
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
460 foreach (i,s; sizable) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
461 if (s) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
462 firstSizable = i;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
463 goto gotFirst;
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
464 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
465 }
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
466 return; // none resizable - don't search for lastSizable
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
467 gotFirst:
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
468 foreach_reverse (i,s; sizable) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
469 if (s) {
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
470 lastSizable = i;
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
471 return; // done
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
472 }
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
473 }
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
474 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
475 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
476
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
477 /** Add a callback to be called to notify changes in a column's width.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
478 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
479 * All callbacks added are called on a width change so that multiple objects may share a
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
480 * CellAlign object. */
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
481 typeof(this) addSetCallback (void delegate (myIt,wdim,int) setCW) {
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
482 assert (setCW, "CellAlign.this: setCW is null (code error)");
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
483 setWidthCb ~= setCW;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
484 return this;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
485 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
486
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
487 /** Get the row/column of relative position l.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
488 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
489 * returns:
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
490 * -i if in space to left of col i, or i if on col i. */
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
491 myDiff getCell (wdim l) {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
492 debug assert (width, "AlignColumns not initialized when getCell called (code error)");
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
493 myDiff i = minWidth.length - 1; // starting from right...
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
494 while (l < pos[i]) { // decrement while left of this column
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
495 debug assert (i > 0, "getCell: l < pos[0] (code error)");
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
496 --i;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
497 } // now (l >= pos[i])
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
498 if (l >= pos[i] + width[i]) { // between columns
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
499 debug assert (i+1 < minWidth.length, "getCell: l >= total width (code error)");
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
500 return -i - 1; // note: i might be 0 so cannot just return -i
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
501 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
502 return i;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
503 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
504
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
505 /** Adjust total size with direction dir.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
506 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
507 * nw should be at least the minimal width. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
508 wdim resizeWidth (wdim nw, int dir) {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
509 debug assert (width, "AlignColumns not initialized when resizeWidth called (code error)");
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
510 if (nw < mw) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
511 debug logger.warn ("Widget dimension set below minimal");
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
512 nw = mw;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
513 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
514 if (nw == w) return w;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
515
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
516 wdim diff = nw - w;
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
517 if (firstSizable == -1)
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
518 diff = adjustCellSizes (diff, minWidth.length-1, -1);
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
519 else
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
520 diff = adjustCellSizes (diff, (dir == -1 ? lastSizable : firstSizable), dir);
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
521
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
522 debug if (nw != w) {
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
523 logger.trace ("resizeWidth on {} to {} failed, new width: {}, diff {}, firstSizable {}, columns {}",cast(void*)this, nw,w, diff, firstSizable, minWidth.length);
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
524 /+ Also print column widths & positions:
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
525 logger.trace ("resizeWidth to {} failed! Column dimensions and positions:",nw);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
526 foreach (i,w; width)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
527 logger.trace ("\t{}\t{}", w,pos[i]);+/
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
528 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
529 return w;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
530 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
531
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
532 /** Calculate resizeU/resizeD, and return true if unable to resize.
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
533 *
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
534 * This and resizeCols are for moving dividers between cells. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
535 bool findResizeCols (wdim l) {
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
536 resizeU = -getCell (l); // potential start for upward-resizes
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
537 if (resizeU <= 0)
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
538 return true; // not on a space between cells
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
539 resizeD = resizeU - 1; // potential start for downward-resizes
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
540
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
541 while (!sizable[resizeU]) { // find first actually resizable column (upwards)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
542 ++resizeU;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
543 if (resizeU >= minWidth.length) { // cannot resize
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
544 resizeU = -1;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
545 return true;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
546 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
547 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
548
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
549 while (!sizable[resizeD]) { // find first actually resizable column (downwards)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
550 --resizeD;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
551 if (resizeD < 0) { // cannot resize
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
552 resizeU = -1; // resizeU is tested to check whether resizes are possible
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
553 return true;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
554 }
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
555 }
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
556
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
557 return false; // can resize
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
558 }
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
559 /// Resize columns based on findResizeCols
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
560 void resizeCols (wdim diff)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
561 {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
562 if (resizeU <= 0) return;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
563
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
564 // do shrinking first (in case we hit the minimum)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
565 if (diff >= 0) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
566 diff = -adjustCellSizes (-diff, resizeU, 1);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
567 adjustCellSizes (diff, resizeD, -1);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
568 } else {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
569 diff = -adjustCellSizes (diff, resizeD, -1);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
570 adjustCellSizes (diff, resizeU, 1);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
571 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
572 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
573
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
574 /* Generate position infomation for each column and set w. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
575 private void genPositions () {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
576 pos.length = minWidth.length;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
577
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
578 w = 0;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
579 foreach (i, cw; width) {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
580 pos[i] = w;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
581 w += cw + spacing;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
582 }
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
583 w -= spacing;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
584 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
585
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
586 /* Adjust the total size of rows/columns (including spacing) by diff.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
587 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
588 * Params:
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
589 * diff = amount to increase/decrease the total size
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
590 * start= index for col/row to start resizing on
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
591 * incr = direction to resize in (added to index each step). Must be either -1 or +1.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
592 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
593 * Returns:
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
594 * The amount adjusted. This may be larger than diff, since cellD is clamped by cellDMin.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
595 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
596 * Note: Check variable used for start is valid before calling! If a non-sizable column's
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
597 * index is passed, this should get increased (if diff > 0) but not decreased.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
598 */
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
599 private wdim adjustCellSizes (wdim diff, myDiff start, int incr)
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
600 in {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
601 assert (width.length == minWidth.length, "CellAlign.adjustCellSizes: width is null (code error)");
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
602 // Most likely if passed negative when sizing is disabled:
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
603 assert (start >= 0 && start < minWidth.length, "adjustCellSizes: invalid start");
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
604 debug assert (incr == 1 || incr == -1, "adjustCellSizes: invalid incr");
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
605 } body {
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
606 debug scope(failure) logger.trace ("adjustCellSizes: failure");
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
607 myDiff i = start;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
608 if (diff > 0) { // increase size of first resizable cell
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
609 width[i] += diff;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
610 foreach (dg; setWidthCb)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
611 dg(i, width[i], incr);
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
612 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
613 else if (diff < 0) { // decrease
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
614 wdim rd = diff; // running diff
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
615 aCSwhile:
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
616 while (true) {
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
617 width[i] += rd; // decrease this cell's size (but may be too much)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
618 rd = width[i] - minWidth[i];
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
619 if (rd >= 0) { // OK; we're done
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
620 foreach (dg; setWidthCb)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
621 dg(i, width[i], incr);
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
622 break; // we hit the mark exactly: diff is correct
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
623 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
624
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
625 // else we decreased it too much!
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
626 width[i] = minWidth[i];
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
627 foreach (dg; setWidthCb)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
628 dg(i, width[i], incr);
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
629 // rd is remainder to decrease by
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
630
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
631 do {
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
632 i += incr;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
633 if (i < 0 || i >= minWidth.length) { // run out of next cells
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
634 diff -= rd; // still had rd left to decrease
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
635 break aCSwhile; // exception: Array index out of bounds
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
636 }
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
637 } while (!sizable[i]) // iterate again if row/col isn't resizable
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
638 }
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
639 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
640 // else no adjustment needed (diff == 0)
45
0fd51d2c6c8a Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 43
diff changeset
641
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
642 genPositions;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
643 return diff;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
644 }
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
645
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
646 /** Minimal width for each column.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
647 *
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
648 * Initialized to zero. Each class using this AlignColumns should, for each column, increase
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
649 * this value to the maximum of the minimal widths (in other words, set
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
650 * minWidth[i] = max(minWidth[i], cell.minWidth) for each cell in column i). */
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
651 wdim[] minWidth; // minimal widths (set by genCachedConstructionData)
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
652
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
653 /** For each column i, sizable[i] is true if that column is resizable.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
654 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
655 * Set along with minWidth before calling setWidths. */
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
656 bool[] sizable; // set by genCachedConstructionData
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
657
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
658 /** Current width, relative position (for each column)
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
659 *
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
660 * Treat as READ ONLY outside this class! */
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
661 wdim[] width; // only adjusted within the class
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
662 wdim[] pos; /// ditto
95
2a364c7d82c9 Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 94
diff changeset
663 protected:
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
664 myDiff resizeD, // resizeCols works down from this index (<0 if not resizing)
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
665 resizeU; // and up from this index
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
666 wdim spacing; // used by genPositions (which cannot access the layout class's data)
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
667 wdim w,mw; // current & minimal widths
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
668 /* indicies of the first/last resizable column (negative if none are resizable). */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
669 myDiff firstSizable = -1, lastSizable = -1; // set by calcFLSbl
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
670 // Callbacks used to actually adjust a column's width:
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
671 void delegate (myIt,wdim,int) setWidthCb[]; // set width of a column, with resize direction
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
672
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
673 static HashMap!(widgetID,AlignColumns) instances;
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
674 static this () {
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
675 instances = new HashMap!(widgetID,AlignColumns);
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
676 }
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
677 }
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
678
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
679 // Index types. Note that in some cases they need to hold negative values.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
680 // int is used for resizing direction (although ptrdiff_t would be more appropriate),
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
681 // since the value must always be -1 or +1.
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
682 alias size_t myIt;
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
683 alias ptrdiff_t myDiff;