Mercurial > projects > mde
annotate mde/gui/widget/layout.d @ 176:d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 12 Sep 2009 09:14:43 +0200 |
parents | 1cbde9807293 |
children | af40e9679436 |
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 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
19 import mde.gui.widget.AParentWidget; |
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 |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
136
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 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
|
27 private Logger logger; |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
28 static this () { |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
29 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
|
30 } |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
31 |
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
|
32 /************************************************************************************************* |
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
|
33 * 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
|
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 * Currently there is no support for changing number of cells, sub-widgets or sub-widget properties |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
36 * (namely isW/HSizable) after this() has run. |
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
|
37 *************************************************************************************************/ |
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 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
|
39 { |
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
|
40 /** 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
|
41 * |
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
|
42 * 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
|
43 * --- |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
44 * 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
|
45 * strings = [w11, w12, ..., w1C, ..., wR1, ..., wRC] |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
46 * // dimData may be: |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
47 * dimData = [col1width, ..., colCwidth, row1height, ..., rowRheight] |
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
|
48 * --- |
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 * 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
|
50 * 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
|
51 * |
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
|
52 * The content parameter is passed on to all children accepting an IContent. */ |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
53 this (IWidgetManager mgr, IParentWidget parent, 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
|
54 // 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
|
55 // 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
|
56 if (data.ints.length != 4) throw new WidgetDataException (this); |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
57 |
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
|
58 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
|
59 cols = data.ints[3]; |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
60 // Check: at least one sub-widget and strings's length is correct: |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
61 if (rows < 1 || cols < 1 || 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
|
62 throw new WidgetDataException (this); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
63 super (mgr, parent, id, data); |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
64 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
65 // 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
|
66 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
|
67 foreach (i, ref subWidget; subWidgets) { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
68 subWidget = mgr.makeWidget (this, 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
|
69 } |
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
|
70 |
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
|
71 initWidths = mgr.dimData (id); // may be null, tested later |
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
|
72 } |
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
|
73 |
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
|
74 // Save column/row sizes. Currently always do so. |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
75 override bool saveChanges () { |
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 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
|
77 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
|
78 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
79 mgr.dimData (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
|
80 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
|
81 } |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
82 |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
83 override void setContent (IContent c) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
84 // Pass the content on to sub-widgets, in case they want it |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
85 foreach (widg; subWidgets) |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
86 widg.setContent = c; |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
87 } |
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
|
88 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
|
89 } |
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 /************************************************************************************************* |
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
|
93 * 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
|
94 * 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
|
95 * 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
|
96 * 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
|
97 *************************************************************************************************/ |
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
|
98 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
|
99 { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
100 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content) { |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
101 cList = cast(IContentList) content; |
138
3468e9bfded1
Popup widgets: are simpler to use and can show content fields like DisplayContentWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
102 WDCMinCheck (data, 2, 1, cList); |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
103 cols = 1; |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
104 rows = cList.list.length; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
105 subWidgets.length = rows; |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
106 if (data.ints[1] & 8) { // orient horizontally |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
107 cols = rows; |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
108 rows = 1; |
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
109 } |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
110 super (mgr, parent, id, data); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
111 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
112 if (subWidgets) { // i.e. rows*cols > 0 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
113 foreach (i, c; cList.list) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
114 subWidgets[i] = mgr.makeWidget (this, data.strings[0], c); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
115 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
116 } else { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
117 rows = cols = 1; |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
118 subWidgets = [mgr.makeWidget (this, data.strings[0], |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
119 new ErrorContent ("<empty list>",null)) ]; |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
120 } |
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 |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
123 override IContent content () { |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
124 return cList; |
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
125 } |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
126 override void setContent (IContent) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
127 logger.warn ("ContentListWidget: resetting content is not yet supported"); |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
168
diff
changeset
|
128 } |
146
783969f4665c
Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
129 |
174
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
130 public override bool dropContent (IContent content) { |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
131 if (cList.set (content)) |
162
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
132 return true; |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
133 return parent.dropContent (content); |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
134 } |
2476790223b8
First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
135 |
133
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
136 override void recursionCheck (widgetID wID, IContent c) { |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
137 if (wID is id && c is cList) |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
138 throw new WidgetRecursionException (wID); |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
139 parent.recursionCheck (wID, c); |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
140 } |
9fd705793568
Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
141 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
142 override bool saveChanges () { |
92
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
143 // 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
|
144 if (subWidgets is null) |
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
145 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
|
146 return subWidgets[0].saveChanges; |
92
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
147 } |
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
148 |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
149 private: |
115
1b1e2297e2fc
Enums handled more generically now via either a popup list or flat list of BoolContentWidgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
150 IContentList 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
|
151 } |
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
|
152 |
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
|
153 |
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
|
154 /************************************************************************************************* |
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
|
155 * 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
|
156 * |
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
|
157 * A deriving class must at least do some work in it's constructor (see Ddoc for this() below) |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
158 * and provide an implementation of saveChanges() (unless Widget's version is sufficient). |
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
|
159 * |
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
|
160 * 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
|
161 * |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
162 * The grid has no border but optionally has spacing between widgets. |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
163 * |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
164 * Several flags are tested against ints[1]: |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
165 * $(TABLE |
168
da8d3091fdaf
More work on the context menu: now roughly usable like an ordinary context menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
166 * $(TR $(TD 1) $(TD Column alignment is shared against other instances of this widget id)) |
da8d3091fdaf
More work on the context menu: now roughly usable like an ordinary context menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
163
diff
changeset
|
167 * $(TR $(TD 2) $(TD Row alignment is shared against other instances of this widget id)) |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
168 * $(TR $(TD 4) $(TD Spacing is inserted between elements; the renderer may draw this)) |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
169 * $(TR $(TD 8) $(TD For ContentListWidget only, list is horizontal instead of vertical)) |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
170 * ) |
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
|
171 *************************************************************************************************/ |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
172 // Note: mw, mh inherited from AWidget are not used; use col.mw, row.mw instead. |
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
|
173 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
|
174 { |
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
|
175 //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
|
176 /** 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
|
177 * |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
178 * Deriving classes should check data lengths, and set rows and cols |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
179 * before calling this super constructor. |
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
|
180 * |
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
|
181 * Derived constructors may also set initWidths to the array of column widths followed by |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
182 * row heights used to initially set the row/column dimensions. */ |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
183 protected this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
184 super (mgr, parent, id); |
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
|
185 |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
186 // Create cell aligners, potentially sharing |
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
|
187 if (data.ints[1] & 1) |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
188 col = AlignColumns.getInstance (id, parent, cols, false); |
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
|
189 else |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
190 col = (new AlignColumns (cols,null)); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
191 if (data.ints[1] & 2) |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
192 row = AlignColumns.getInstance (id, parent, rows, true); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
193 else |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
194 row = (new AlignColumns (rows,null)); |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
195 |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
196 AlignColumns.CallbackStruct cbS; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
197 cbS.setWidth = &setColWidth; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
198 cbS.sADD = &setupAlignDimData; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
199 cbS.newMW = &colNewMW; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
200 col.cbs ~= cbS; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
201 cbS.setWidth = &setRowHeight; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
202 cbS.newMW = &rowNewMW; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
203 row.cbs ~= cbS; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
204 |
109
2a1428ec5344
Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
205 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
|
206 } |
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
207 |
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
|
208 /** 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
|
209 * |
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
|
210 * As such, this must be the first function called after this(). */ |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
211 override bool setup (uint n, uint flags) { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
212 debug (mdeWidgets) logger.trace ("GridWidget.setup"); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
213 // Run all internal calculations regardless of changes, then check dimensions for changes. |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
214 // Don't try shortcutting internal calculations when there are no changes - I've tried, and |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
215 // doing so adds enough overhead to make doing so almost(?) worthless (or at least large |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
216 // increases in complexity). |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
217 wdim ow = w, oh = h; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
218 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
219 col.setup (n, flags); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
220 row.setup (n, flags); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
221 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
222 if (initWidths.length == cols + rows) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
223 col.setWidths (initWidths[0..cols]); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
224 row.setWidths (initWidths[cols..$]); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
225 } else { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
226 col.setWidths; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
227 row.setWidths; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
228 } |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
229 initWidths = null; // free |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
230 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
231 w = col.w; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
232 h = row.w; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
233 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
234 // Tell subwidgets their new sizes. Positions are given by a later call to setPosition. |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
235 foreach (i,widget; subWidgets) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
236 // Resizing direction is arbitrarily set to negative: |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
237 widget.setWidth (col.width[i % cols], -1); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
238 widget.setHeight (row.width[i / cols], -1); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
239 } |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
142
diff
changeset
|
240 return (ow != w || oh != h || n == 0); |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
241 } |
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
|
242 //END Creation & saving |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
243 |
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
|
244 //BEGIN Size & position |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
245 override 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
|
246 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
|
247 } |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
248 override 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
|
249 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
|
250 } |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
251 |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
252 // mw, mh not used |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
253 override wdim minWidth () { |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
254 return col.mw; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
255 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
256 override wdim minHeight () { |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
257 return row.mw; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
258 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
259 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
260 override 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
|
261 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
|
262 // 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
|
263 } |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
264 override 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
|
265 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
|
266 // 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
|
267 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
268 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
269 override 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
|
270 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
|
271 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
|
272 |
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
|
273 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
|
274 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
|
275 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
|
276 } |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
277 |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
278 // Unlike for most widgets, these actually resize self and sub-widgets, since the parent |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
279 // simply calling setWidth/setHeight wouldn't work. |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
280 override void minWChange (IChildWidget widg, wdim nmw) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
281 size_t i = getWidgetIndex(widg); |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
282 if (!col.newMinWidth (i%cols, i/cols + colR, nmw)) { |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
283 // don't propegate call to parent; set position as required |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
284 widg.setPosition (x + col.pos[i % cols], y + row.pos[i / cols]); |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
285 mgr.requestRedraw; |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
286 } // else callbacks to all sharing layouts do the rest |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
287 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
288 override void minHChange (IChildWidget widg, wdim nmh) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
289 size_t i = getWidgetIndex(widg); |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
290 if (!row.newMinWidth (i/cols, i%cols + rowR, nmh)) { |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
291 widg.setPosition (x + col.pos[i % cols], y + row.pos[i / cols]); |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
292 mgr.requestRedraw; |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
293 } |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
294 } |
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
|
295 //END Size & position |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
296 |
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
|
297 |
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
|
298 // Find the relevant widget. |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
299 override 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
|
300 debug scope (failure) |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
301 logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h); |
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
|
302 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
|
303 |
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 // Find row/column: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
305 ptrdiff_t i = col.getCell (cx - x); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
306 ptrdiff_t j = row.getCell (cy - y); |
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
|
307 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
|
308 return this; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
309 |
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
|
310 // 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
|
311 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
|
312 } |
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
|
313 |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
314 // Resizing columns & rows |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
315 override 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
|
316 debug scope (failure) |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
317 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
|
318 if (b == 1 && state == true) { |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
319 /* 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
|
320 * 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
|
321 * 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
|
322 |
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
|
323 // 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
|
324 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
|
325 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
|
326 |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
327 dragX = cx; |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
328 dragY = cy; |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
329 |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
330 return 2; |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
331 } |
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
|
332 return 0; |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
333 } |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
334 |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
335 //BEGIN Col/row resizing callback |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
336 override void dragMotion (wdim cx, wdim cy, IChildWidget) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
337 col.resizeCols (cx - dragX); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
338 row.resizeCols (cy - dragY); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
339 |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
340 // NOTE: all adjustments are relative; might be better if they were absolute? |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
341 dragX = cx; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
342 dragY = cy; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
343 |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
344 foreach (i,widget; subWidgets) |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
345 widget.setPosition (x + col.pos[i % cols], |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
346 y + row.pos[i / cols]); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
347 mgr.requestRedraw; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
348 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
349 override bool dragRelease (wdabs cx, wdabs cy, IChildWidget) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
350 return true; // we've handled the up-click |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
351 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
352 //END Col/row resizing callback |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
146
diff
changeset
|
353 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
354 override void draw () { |
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
|
355 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
|
356 |
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
|
357 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
|
358 widget.draw (); |
109
2a1428ec5344
Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
359 |
2a1428ec5344
Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
360 if (useSpacing) |
2a1428ec5344
Optional, visible spacing in grid layouts.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
361 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
|
362 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
363 |
174
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
364 private: |
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
|
365 /* Calculations which need to be run whenever a new sub-widget structure is set |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
366 * or other changes affecting widget sizes. Most of these need to happen regardless of whether |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
367 * changes have occurred, since AlignColumns have been reset. |
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
|
368 * |
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
|
369 * 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
|
370 * (col and row). subWidgets need to know their minimal size and resizability. */ |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
113
diff
changeset
|
371 override void setupAlignDimData (uint n, uint flags) { |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
372 if (sADD_n == n) return; // cached data is current |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
373 sADD_n = n; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
374 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
375 debug (mdeWidgets) logger.trace ("GridWidget: setup on subWidgets..."); |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
376 foreach (widg; subWidgets) { // make sure all subwidgets have been set up |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
377 debug assert (widg, "null widg"); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
378 widg.setup (n,flags); |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
379 } |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
380 debug (mdeWidgets) logger.trace ("GridWidget: setup on subWidgets...done"); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
381 // make sure both AlignColumns are set up (since first call to setup(n) calls reset): |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
382 col.setup (n, flags); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
383 row.setup (n, flags); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
118
diff
changeset
|
384 |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
385 // 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
|
386 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
|
387 |
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
|
388 // Calculate the minimal column and row sizes: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
389 if (colR == size_t.max) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
390 colR = col.addRows (rows); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
391 if (rowR == size_t.max) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
392 rowR = row.addRows (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
|
393 // AlignColumns (row, col) takes care of initializing minWidth. |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
394 for (size_t r = 0; r < rows; ++r) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
395 for (size_t c = 0; c < cols; ++c) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
396 size_t i = r*cols + c; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
397 col.minCellWidths[i+colR*cols] = subWidgets[i].minWidth; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
398 row.minCellWidths[(c+rowR)*rows+r] = subWidgets[i].minHeight; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
399 } |
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
|
400 } |
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
|
401 |
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
|
402 // 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
|
403 // AlignColumns initializes sizable, and sets first and last sizables. |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
404 static if (!(SIZABILITY & SIZABILITY_ENUM.SUBWIDGETS)) return; |
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
|
405 forCols: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
406 for (size_t i = 0; i < cols; ++i) { // for each column |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
407 for (size_t j = 0; j < subWidgets.length; j += cols) { // for each row |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
408 static if (SIZABILITY == SIZABILITY_ENUM.ALL_SUBWIDGETS) { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
409 if (!subWidgets[i+j].isWSizable) { // column not resizable |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
410 col.sizable[i] = false; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
411 continue forCols; // no point checking more |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
412 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
413 } else { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
414 if (subWidgets[i+j].isWSizable) { // column is resizable |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
415 col.sizable[i] = true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
416 continue forCols; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
417 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
418 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
419 } |
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
|
420 } |
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
|
421 |
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
|
422 forRows: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
423 for (size_t i = 0; i < subWidgets.length; i += cols) { // for each row |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
424 for (size_t j = 0; j < cols; ++j) { // for each column |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
425 static if (SIZABILITY == SIZABILITY_ENUM.ALL_SUBWIDGETS) { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
426 if (!subWidgets[i+j].isHSizable) { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
427 row.sizable[i / cols] = false; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
428 continue forRows; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
429 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
430 } else { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
431 if (subWidgets[i+j].isHSizable) { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
432 row.sizable[i / cols] = true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
433 continue forRows; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
434 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
435 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
436 } |
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
|
437 } |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
438 } |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
439 |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
440 override void setColWidth (size_t i, wdim w, int dir) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
441 for (size_t j = 0; j < rows; ++j) { |
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
|
442 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
|
443 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
444 } |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
445 override void setRowHeight (size_t j, wdim h, int dir) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
446 for (size_t i = 0; i < cols; ++i) { |
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
|
447 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
|
448 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
449 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
450 |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
451 void colNewMW () { |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
452 w = col.w; |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
453 parent.minWChange (this, col.mw); |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
454 } |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
455 void rowNewMW () { |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
456 h = row.w; |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
457 parent.minHChange (this, row.mw); |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
458 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
459 |
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
|
460 protected: |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
461 // 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
|
462 wdim dragX, dragY; // coords where drag starts |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
463 |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
464 size_t 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
|
465 wdim[] initWidths; // see this / setInitialSize |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
466 uint sADD_n = uint.max; // param n of last setup call after setupAlignDimData has run |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
467 bool useSpacing; // add inter-row/col spacing? |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
468 |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
469 /* 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
|
470 * [ 2 3 ] */ |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
471 //IChildWidget[] subWidgets; (inherited from AParentWidget) |
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
|
472 |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
473 AlignColumns col, row; // aligners for cols and rows |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
474 // "rows" allocated in col and row; return value of *.addRows(): |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
475 size_t colR = size_t.max, rowR = size_t.max; |
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
|
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 |
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
|
478 |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
479 /************************************************************************************************** |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
480 * 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
|
481 * |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
482 * 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
|
483 * 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
|
484 * 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
|
485 * |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
486 * 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
|
487 * |
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 * 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
|
489 * 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
|
490 *************************************************************************************************/ |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
491 private 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
|
492 { |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
493 /** Get an aligner. |
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
|
494 * |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
495 * Will be shared with other layouts with the same id which have the same |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
496 * parent or if the parents share an aligner. |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
497 * |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
498 * Also ensures each widget sharing an instance expects the same number of |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
499 * columns. */ |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
500 static AlignColumns getInstance (widgetID id, IParentWidget parent, size_t columns, bool horiz) { |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
501 if (horiz) |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
502 id ~= "H"; // make the ID different for each aligner |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
503 AlignColumns[]* p = id in instances; |
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
|
504 if (p) { |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
505 foreach (ac; *p) { |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
506 if (parent !is ac.parent) { // If parents are different |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
507 GridWidget parGrid = cast(GridWidget) parent, |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
508 acPGrid = cast(GridWidget) ac.parent; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
509 // and either is not a GridWidget |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
510 // or their aligners are different |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
511 if (parGrid is null || acPGrid is null || |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
512 horiz ? parGrid.row !is acPGrid.row |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
513 : parGrid.col !is acPGrid.col) { |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
514 continue; // don't share with it |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
515 } |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
516 } |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
517 if (ac.cols != columns) |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
518 continue; // Alignment sharing with ContentListWidgets?? |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
519 return ac; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
520 } |
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 } |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
522 auto a = new AlignColumns (columns, parent); |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
523 if (p) *p ~= a; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
524 else instances[id] = [a]; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
525 return a; |
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
|
526 } |
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 |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
528 /** Create an aligner. |
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
|
529 * |
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 * After creation, minimal widths should be set for all columns (minWidth) and |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
531 * setWidths must be called before other functions are used. |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
532 * |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
533 * Params: |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
534 * columns = Number of columns. Not expected to change. |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
535 * parent = The parent of the GridWidget using this aligner. (Used when sharing aligners.) */ |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
536 this (size_t columns, IParentWidget parent) { |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
537 if (columns < 1) |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
538 throw new GuiException("AlignColumns: created with <1 column (code error)"); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
539 minWidth.length = columns; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
540 sizable.length = columns; |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
541 static if (SIZABILITY & SIZABILITY_ENUM.START_TRUE) |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
542 sizable[] = true; |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
543 cols = columns; |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
544 this.parent = parent; |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
545 } |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
546 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
547 /** Like IChildWidget's setup; calls sADD delegates. */ |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
548 void setup (uint n, uint flags) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
549 if (n != setup_n) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
550 setup_n = n; |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
551 setupWidths = false; |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
552 reset (cols); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
553 |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
554 foreach (cb; cbs) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
555 cb.sADD (n, flags); // set flag 1 |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
556 } |
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
|
557 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
558 |
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 /** 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
|
560 * |
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 * Widths should be set after calling, as on creation. */ |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
562 void reset (size_t columns) { |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
563 assert (columns == cols, "no support for changing number of columns for now"); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
564 minWidth[] = 0; |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
565 static if (SIZABILITY & SIZABILITY_ENUM.START_TRUE) |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
566 sizable[] = true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
567 else |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
568 sizable[] = false; |
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
|
569 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
|
570 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
|
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 |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
573 /** Add num "rows" to the aligner. They start at the returned index r, thus the values in |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
574 * minCellWidths to set are minCellWidths[cols*r..cols*(r+num)]. |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
575 * |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
576 * Calling this function is necessary to allocate room in minCellWidths. */ |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
577 size_t addRows (size_t num) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
578 size_t r = rows; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
579 rows += num; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
580 minCellWidths.length = cols*rows; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
581 return r; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
582 } |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
583 |
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
|
584 /** 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
|
585 * |
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
|
586 * 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
|
587 */ |
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
|
588 void setWidths (wdim[] data = null) { |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
589 if (!setupWidths) { |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
590 setupWidths = true; |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
591 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
592 // Set minWidth |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
593 assert (minCellWidths.length == rows * cols, "minCellWidths: bad length"); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
594 for (size_t c = 0; c < cols; ++c) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
595 for (size_t r = 0; r < rows; ++r) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
596 wdim mcw = minCellWidths[c+r*cols]; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
597 if (minWidth[c] < mcw) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
598 minWidth[c] = mcw; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
599 } |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
600 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
601 /* Calculate the minimal width of all columns plus spacing. */ |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
602 mw = spacing * cast(wdim)(cols - 1); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
603 foreach (imw; minWidth) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
604 mw += imw; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
605 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
606 // set width |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
607 if (data || width) { // use existing/external data: need to check validity |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
608 if (data) { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
609 assert (data.length == cols, "setWidths called with bad data length (code error)"); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
610 width = data.dup; // data is shared by other widgets with same id so must be .dup'ed |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
611 } |
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
|
612 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
|
613 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
|
614 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
|
615 } |
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
|
616 } 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
|
617 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
|
618 |
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
|
619 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
|
620 |
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
|
621 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
|
622 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
|
623 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
|
624 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
|
625 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
626 } |
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
|
627 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
|
628 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
|
629 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
|
630 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
|
631 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
|
632 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
|
633 } |
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
|
634 } |
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
|
635 } |
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
|
636 } |
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
|
637 |
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
|
638 /** 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
|
639 * |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
640 * 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
|
641 * -i if in space to left of col i, or i if on col i. */ |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
642 ptrdiff_t 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
|
643 debug assert (width, "AlignColumns not initialized when getCell called (code error)"); |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
644 ptrdiff_t i = cols - 1; // starting from right... |
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
|
645 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
|
646 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
|
647 --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
|
648 } // 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
|
649 if (l >= pos[i] + width[i]) { // between columns |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
650 debug assert (i+1 < cols, "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
|
651 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
|
652 } |
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
|
653 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
|
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 |
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
|
656 /** 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
|
657 * |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
658 * nw should be at least the minimal width. |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
659 * |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
660 * Returns: the final width */ |
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
|
661 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
|
662 debug assert (width, "AlignColumns not initialized when resizeWidth called (code error)"); |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
663 debug if (nw < mw) { |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
664 logger.warn ("Widget dimension set below minimal (code error)"); |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
665 return w; |
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 } |
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 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
|
668 |
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 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
|
670 if (firstSizable == -1) |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
671 diff = adjustCellSizes (diff, cols-1, -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
|
672 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
|
673 diff = adjustCellSizes (diff, (dir == -1 ? lastSizable : firstSizable), dir); |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
674 genPositions; |
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
|
675 |
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 debug if (nw != w) { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
677 logger.trace ("resizeWidth on {} to {} failed, new width: {}, diff {}, firstSizable {}, columns {}",cast(void*)this, nw,w, diff, firstSizable, 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
|
678 /+ 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
|
679 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
|
680 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
|
681 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
|
682 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
683 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
|
684 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
685 |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
686 /** 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
|
687 * |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
688 * 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
|
689 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
|
690 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
|
691 if (resizeU <= 0) |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
692 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
|
693 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
|
694 |
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
|
695 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
|
696 ++resizeU; |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
697 if (resizeU >= cols) { // cannot resize |
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
|
698 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
|
699 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
|
700 } |
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
|
701 } |
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
|
702 |
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
|
703 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
|
704 --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
|
705 if (resizeD < 0) { // cannot resize |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
706 resizeU = -1; // resizeU is tested to check whether resizes are possible |
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
|
707 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
|
708 } |
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
|
709 } |
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
|
710 |
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
|
711 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
|
712 } |
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
|
713 /// 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
|
714 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
|
715 { |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
716 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
|
717 |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
718 // 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
|
719 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
|
720 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
|
721 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
|
722 } 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
|
723 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
|
724 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
|
725 } |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
726 genPositions; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
727 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
728 |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
729 /** Called when one of the cells in column col now has minimal width nmw. |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
730 * |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
731 * Enlarges column minimal width if necessary; tries to keep total width |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
732 * the same. |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
733 * |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
734 * Returns: true if min-width changes (callbacks do necessary work), |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
735 * false if no change to mw (position should still be reset). */ |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
736 bool newMinWidth (size_t col, size_t row, wdim nmw) { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
737 minCellWidths[col + row*cols] = nmw; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
738 wdim nd = 0; // negative diff to keep overall size constant if possible |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
739 if (minWidth[col] < nmw) { // increase minimal |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
740 minWidth[col] = nmw; |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
741 nd = width[col] - nmw; // negative diff |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
742 if (nd > 0) |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
743 nd = 0; // Don't decrease if already larger (mustn't shrink self) |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
744 } else if (minWidth[col] > nmw) { // potentially decrease minimal |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
745 // set nmw to max of all cell min widths in col: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
746 for (size_t r = 0; r < rows; ++r) { |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
747 wdim mcw = minCellWidths[col+r*cols]; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
748 if (nmw < mcw) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
749 nmw = mcw; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
750 } |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
751 if (minWidth[col] == nmw) // no change |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
752 return false; |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
753 minWidth[col] = nmw; |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
754 if (!sizable[col] && lastSizable >= 0) |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
755 nd = width[col] - nmw; // Not resizable but another column is |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
756 // Else leave larger; mustn't shrink ourself |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
757 } else |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
758 return false; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
759 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
760 mw = spacing * cast(wdim)(cols - 1); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
761 foreach (imw; minWidth) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
762 mw += imw; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
763 |
129
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
764 if (nd != 0) { // needs enlarging or shrinking |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
765 width[col] = nmw; |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
766 foreach (cb; cbs) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
767 cb.setWidth (col, nmw, -1); |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
768 if (lastSizable >= 0) |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
769 adjustCellSizes (nd, lastSizable, -1); |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
770 } |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
771 |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
772 debug wdim ow = w; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
773 genPositions; |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
774 debug if (w < ow) |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
775 logger.error ("newMinWidth: shrunk (code error); w={}, ow={}, nd={}", w,ow,nd); |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
776 |
141
6f69a9c111eb
Fix for using BoolContentWidget in a menu. Made popups' widths match their parents under certain conditions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
140
diff
changeset
|
777 //debug logger.trace ("newMW for col: minWidth: {}, nmw: {}, col: {}, nd: {}, mw: {}, w: {}", minWidth, nmw, col, nd, mw, w); |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
778 foreach (cb; cbs) |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
779 cb.newMW (); |
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
780 return true; |
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
|
781 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
782 |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
783 /* 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
|
784 private void genPositions () { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
785 pos.length = 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
|
786 |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
787 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
|
788 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
|
789 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
|
790 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
|
791 } |
4d5d53e4f881
Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
90
diff
changeset
|
792 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
|
793 } |
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
|
794 |
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
|
795 /* 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
|
796 * |
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
|
797 * 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
|
798 * diff = amount to increase/decrease the total size |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
799 * start= index for col/row to start resizing on; assumed to be sizable |
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
|
800 * 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
|
801 * |
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
|
802 * 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
|
803 * 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
|
804 * |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
805 * Will shrink non-sizable columns if they're over minimal size. |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
806 * Will increase column start, since it's assumed sizable. |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
807 * |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
808 * Note: Check variable used for start is valid before calling! If a non- |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
809 * sizable column's index is passed, this should get increased (if diff > 0) |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
810 * but not decreased. */ |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
811 private wdim adjustCellSizes (wdim diff, ptrdiff_t 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
|
812 in { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
813 assert (width.length == cols, "CellAlign.adjustCellSizes: width is invalid (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
|
814 // Most likely if passed negative when sizing is disabled: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
815 assert (start >= 0 && start < cols, "adjustCellSizes: invalid start"); |
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
|
816 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
|
817 } 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
|
818 debug scope(failure) logger.trace ("adjustCellSizes: failure"); |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
819 ptrdiff_t i = start; |
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
|
820 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
|
821 width[i] += diff; |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
822 foreach (cb; cbs) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
823 cb.setWidth (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
|
824 } |
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
|
825 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
|
826 wdim rd = diff; // running diff |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
827 while (i >= 0 && i < cols) { |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
828 if (width[i] > minWidth[i]) { |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
829 width[i] += rd; // decrease this cell's size (but may be too much) |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
830 rd = width[i] - minWidth[i]; |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
831 if (rd >= 0) { // OK; we're done |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
832 foreach (cb; cbs) |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
833 cb.setWidth (i, width[i], incr); |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
834 break; // we hit the mark exactly: diff is correct |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
835 } |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
836 |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
837 // else we decreased it too much! |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
838 width[i] = minWidth[i]; |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
839 foreach (cb; cbs) |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
840 cb.setWidth (i, width[i], incr); |
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
841 // rd is remainder to decrease by |
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
|
842 } |
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
|
843 |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
844 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
|
845 } |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
138
diff
changeset
|
846 diff -= rd; // still had rd left to decrease (may be 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
|
847 } |
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
|
848 // 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
|
849 |
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
|
850 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
|
851 } |
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
|
852 |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
853 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
854 /** Minimal widths per cell. |
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
|
855 * |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
856 * Array of all cells, organised like GridLayoutWidget.subWidgets when representing columns, |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
857 * with rows and columns swapped when representing rows. |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
858 * |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
859 * Then minWidth[i] = min(minCellWidths[i]) (where min acts on an array). */ |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
860 wdim[] minCellWidths; |
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
|
861 |
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
|
862 /** 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
|
863 * |
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
|
864 * 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
|
865 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
|
866 |
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
|
867 /** 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
|
868 * |
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
|
869 * 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
|
870 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
|
871 wdim[] pos; /// ditto |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
872 wdim spacing; // used by genPositions (which cannot access the layout class's data) |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
873 wdim w,mw; // current & minimal widths |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
874 |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
875 private struct CallbackStruct { |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
876 void delegate (size_t,wdim,int) setWidth; // set width of a column, with resize direction |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
877 void delegate (uint,uint) sADD; // setupAlignDimData dlgs |
140
c94ec5594449
Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
878 void delegate () newMW; // propegate or finalize minimal width change |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
879 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
880 CallbackStruct cbs[]; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
124
diff
changeset
|
881 |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
882 private: |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
883 /* Minimal width for each column. |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
884 * |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
885 * Set by setWidths. */ |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
886 wdim[] minWidth; |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
887 size_t cols, rows; // number of columns and rows (wrong way round when AlignColumns |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
888 // represents rows) |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
889 |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
890 ptrdiff_t 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
|
891 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
|
892 /* indicies of the first/last resizable column (negative if none are resizable). */ |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
893 ptrdiff_t firstSizable = -1, lastSizable = -1; // set by calcFLSbl |
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
|
894 // Callbacks used to actually adjust a column's width: |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
895 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
896 uint setup_n = uint.max; // param n of last setup call |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
109
diff
changeset
|
897 bool setupWidths; // setWidths has been run |
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
|
898 |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
899 IParentWidget parent; // Used to determine when to share aligner |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
900 |
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
901 static HashMap!(widgetID,AlignColumns[]) instances; |
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
|
902 static this () { |
142
9dabcc44f515
Tightened rules for alignment sharing of grid layouts (avoids a bug and generally preferable).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
141
diff
changeset
|
903 instances = new HashMap!(widgetID,AlignColumns[]); |
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
|
904 } |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
905 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
906 alias IParentWidget.SIZABILITY SIZABILITY; |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
907 alias IParentWidget.SIZABILITY_ENUM SIZABILITY_ENUM; |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
908 |
174
3d58adc17d20
Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
909 invariant |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
910 { |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
911 if (setupWidths) { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
912 assert (width.length == cols, "invariant: bad width length"); |
176
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
913 assert (minCellWidths.length == rows * cols, "minCellWidths: bad length"); |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
914 wdim[] checkMinWidth = new wdim[cols]; |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
915 for (size_t c = 0; c < cols; ++c) { |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
916 for (size_t r = 0; r < rows; ++r) { |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
917 wdim mcw = minCellWidths[c+r*cols]; |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
918 if (checkMinWidth[c] < mcw) |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
919 checkMinWidth[c] = mcw; |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
920 } |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
921 } |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
922 assert (checkMinWidth == minWidth); |
d5d5fe04ca6c
Fixes to CollapsibleWidget. Disabled AChildWidget.invariant.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
175
diff
changeset
|
923 |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
924 wdim x = 0; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
925 foreach (i,w; width) { |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
926 assert (minWidth[i] <= w, "invariant: min size not reached"); // even when "not sizable", cols may get enlarged |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
927 assert (x == pos[i], "invariant: position wrong"); |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
928 x += w + spacing; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
929 } |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
930 assert (x - spacing == w, "invariant: w is wrong"); |
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
931 x = spacing * cast(wdim)(cols - 1); |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
932 foreach (mw; minWidth) |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
933 x += mw; |
124
a2ef6b549101
Dynamic minimal size changing is now fully supported.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
934 assert (x == mw, "invariant: mw is wrong"); |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
935 } |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
936 } |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
937 |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
938 debug (mdeUnitTest) unittest { |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
939 AlignColumns a, a2, b; |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
940 a = getInstance ("a", null, 2, false); |
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
941 a2 = getInstance ("a", null, 2, false); |
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
942 b = getInstance ("a", null, 5, true); |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
943 assert (a is a2); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
944 assert (a !is b); |
163
24d77c52243f
Provided sensible conversions for setting the value of one AStringContent from another, along with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
162
diff
changeset
|
945 assert (getInstance ("a", null, 4, false) !is a); |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
946 |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
947 a.setup (0, 3); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
948 a.spacing = 6; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
949 a.minWidth[0] = 50; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
950 a.minWidth[1] = 6; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
951 a.sizable[1] = true; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
952 a.setWidths; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
953 assert (a.w == 62); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
954 |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
955 b.setup (0,3); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
956 b.spacing = 2; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
957 foreach (ref wd; b.minWidth) |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
958 wd = 10; |
136
4084f07f2c7a
Added simpler mergetag readers and writers, with unittest.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
133
diff
changeset
|
959 b.sizable = [false, true, false, true, false]; |
118
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
960 b.setWidths; |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
961 assert (b.w == 58); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
962 |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
963 assert (b.resizeWidth (60, -1) == 60); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
964 assert (b.width[3] == 12); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
965 |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
966 logger.info ("Unittest complete."); |
9ac208b53582
Unittest for mde.gui.widget.layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
115
diff
changeset
|
967 } |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
968 } |