Mercurial > projects > mde
annotate mde/gui/widget/layout.d @ 72:159775502bb4
The first dynamically generated widget lists, based on Options, are here!
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 05 Jul 2008 18:27:46 +0100 |
parents | 77c7d3235114 |
children | 3dfd934100f7 |
rev | line source |
---|---|
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
1 /* LICENSE BLOCK |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
2 Part of mde: a Modular D game-oriented Engine |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
3 Copyright © 2007-2008 Diggory Hardy |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
4 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify it under the terms |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
6 of the GNU General Public License as published by the Free Software Foundation, either |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
7 version 2 of the License, or (at your option) any later version. |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
8 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
11 See the GNU General Public License for more details. |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
12 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
13 You should have received a copy of the GNU General Public License |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
15 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
16 /// Gui layout widgets. |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
17 module mde.gui.widget.layout; |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
19 import mde.gui.widget.Widget; |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
20 import mde.gui.exception; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
21 |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
22 import mde.gui.widget.TextWidget; |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
23 import mde.gui.content.options; |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
24 |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
25 debug { |
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 } |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
32 |
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
|
33 /************************************************************************************************* |
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 * 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
|
35 * |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
36 * Currently there is no support for changing number of cells, sub-widgets or sub-widget properties |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
37 * (namely isW/HSizable and minimal size) after this() has run. |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
38 * |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
39 * 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
|
40 * |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
41 * The grid has no border but has spacing between widgets. |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
42 *************************************************************************************************/ |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
43 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
|
44 { |
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
|
45 /** 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
|
46 * |
891211f034f2
Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
58
diff
changeset
|
47 * Widget uses the initialisation data: |
891211f034f2
Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
58
diff
changeset
|
48 * [widgetID, r, c, w11, w12, ..., w1c, ..., wr1, ..., wrc] |
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
|
49 * where r and c are the number of rows and columns, and wij is the ID (from parent Window's |
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
|
50 * list) for the widget in row i and column j. The number of parameters must be r*c + 3. */ |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
51 this (IWindow wind, int[] data) { |
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
|
52 // Get grid size and check data |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
53 // Check sufficient data for rows, cols, and at least one widget: |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
54 if (data.length < 4) throw new WidgetDataException; |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
55 |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
56 rows = data[1]; |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
57 cols = data[2]; |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
58 if (data.length != 3 + rows * cols) throw new WidgetDataException; |
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
|
59 /* data.length >= 4 so besides checking the length is correct, this tells us: |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
60 * rows * cols >= 4 - 3 = 1 a free check! |
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
|
61 * The only thing not checked is whether both rows and cols are negative, which would |
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
|
62 * cause an exception when dynamic arrays are allocated by genCachedConstructionData, which |
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
|
63 * is an acceptible method of failure (and is unlikely anyway). */ |
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) { |
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
|
68 subWidget = wind.makeWidget (data[i+3]); |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
69 } |
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
|
70 super (wind, data); |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
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 /** Return construction data to recreate this GridLayoutWidget. */ |
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
|
73 int[] getCreationData () { |
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
|
74 int[] ret; |
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
|
75 ret.length = 3 + subWidgets.length; |
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
|
76 |
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
|
77 ret [0..3] = [widgetType, rows, cols]; // first data |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
78 |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
79 foreach (i,widget; subWidgets) // sub 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
|
80 ret[i+3] = window.addCreationData (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
|
81 |
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
|
82 return ret; |
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
|
83 } |
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
|
84 } |
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
|
85 |
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
|
86 |
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
|
87 /************************************************************************************************* |
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
|
88 * Trial layout of sub-widgets of one type only. |
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 *************************************************************************************************/ |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
90 class TrialContentLayoutWidget : 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
|
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 this (IWindow wind, int[] data) { |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
93 debug scope (failure) |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
94 logger.warn ("TrialContentLayoutWidget: failure"); |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
95 if (data.length != 3) throw new WidgetDataException; |
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
|
96 |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
97 OptionList optsList = OptionList.trial(); |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
98 rows = optsList.list.length; |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
99 cols = 1; |
71
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
100 |
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
|
101 // Get all sub-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
|
102 subWidgets.length = rows*cols; |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
103 foreach (i, c; optsList.list) { |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
104 subWidgets[i] = new ContentOptionWidget (wind, data[1..3], c); |
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
|
105 } |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
106 super (wind, data); |
71
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
107 } |
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
|
108 |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
109 int[] getCreationData () { |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
110 return [widgetType]; |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
111 } |
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
|
112 |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
113 private: |
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
114 OptionList optsList; |
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
|
115 } |
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
|
116 |
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
|
117 |
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
|
118 /************************************************************************************************* |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
119 * 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
|
120 * |
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 * A deriving class must at least do some work in it's constructor (see Ddoc for this() below) |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
122 * and provide an implementation of getCreationData() (unless Widget's version is sufficient). |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
123 * |
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
|
124 * 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
|
125 * |
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
|
126 * The grid has no border but has spacing between widgets. |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
127 *************************************************************************************************/ |
72
159775502bb4
The first dynamically generated widget lists, based on Options, are here!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
71
diff
changeset
|
128 abstract class GridWidget : Widget |
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
|
129 { |
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
|
130 //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
|
131 /** 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
|
132 * |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
133 * Deriving classes should check data length, and set rows, cols, and the subWidgets array, |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
134 * before calling this super constructor. (If it's necessary to call super(...) first, |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
135 * the call to genCachedConstructionData can be moved to the derived this() methods.) */ |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
136 protected this (IWindow wind, int[] data) { |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
137 super (wind, data); |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
138 |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
139 // Needn't be set before genCachedConstructionData is called: |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
140 col.setColWidth = &setColWidth; |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
141 row.setColWidth = &setRowHeight; |
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
|
142 |
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
|
143 // Calculate cached construction data |
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
|
144 genCachedConstructionData; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
145 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
146 |
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
|
147 /** This implementation of adjust() does two things: |
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
|
148 * 1. Pass adjust data on to sub-widgets |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
149 * 2. Set the size, from the adjust data if possible |
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
|
150 * |
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 * Can be overridden (probably along with getMutableData()) if a different implementation is |
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 * wanted. adjustCache() may still be useful. */ |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
153 int[] adjust (int[] data) { |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
154 // Give all sub-widgets their data: |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
155 foreach (widget; subWidgets) |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
156 data = widget.adjust (data); |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
157 |
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
|
158 /** We basically short-cut setSize by loading previous col/row sizes and doing the final |
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
|
159 * calculations. |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
160 * Note: if setSize gets called afterwards, it should have same dimensions and so not do |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
161 * anything. */ |
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
|
162 int lenUsed = 0; |
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
|
163 if (data.length < rows + cols) { // data error; use defaults |
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
|
164 col.dupMin; |
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
|
165 row.dupMin; |
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
|
166 } else { // sufficient data |
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
|
167 lenUsed = rows+cols; |
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
|
168 col.setCheck (cast(wdim[])data[0..cols]); |
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
|
169 row.setCheck (cast(wdim[])data[cols..lenUsed]); |
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
|
170 } |
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
|
171 |
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
|
172 adjustCache(); |
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
|
173 return data[lenUsed..$]; |
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 /** Generates cached mutable data. |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
176 * |
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 * Should be called by adjust() after setting col and row widths (currently via dupMin or |
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
|
178 * setCheck). */ |
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
|
179 void adjustCache () { |
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
|
180 // Generate cached mutable data |
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
|
181 // Calculate column and row locations: |
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
|
182 w = col.genPositions; |
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
|
183 h = row.genPositions; |
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
|
184 |
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
|
185 // Tell subwidgets their new sizes. Positions are given by a later call to setPosition. |
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
|
186 foreach (i,widget; subWidgets) { |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
187 // Resizing direction is arbitrarily set to negative: |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
188 widget.setWidth (col.width[i % cols], -1); |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
189 widget.setHeight (row.width[i / cols], -1); |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
190 } |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
191 } |
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
|
192 /** Returns sub-widget mutable data along with column widths and row heights, as used by |
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
|
193 * adjust(). */ |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
194 int[] getMutableData () { |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
195 int[] ret; |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
196 foreach (widget; subWidgets) |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
197 ret ~= widget.getMutableData; |
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
198 |
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
|
199 return ret ~ cast(int[])col.width ~ cast(int[])row.width; |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
200 } |
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
|
201 //END Creation & saving |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
202 |
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
|
203 //BEGIN Size & position |
37
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
204 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
|
205 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
|
206 } |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
207 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
|
208 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
|
209 } |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
210 |
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
|
211 void setWidth (wdim nw, int dir) { |
46
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
212 if (nw == w) return; |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
213 |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
214 w += col.adjustCellSizes (nw - w, (dir == -1 ? col.lastSizable : col.firstSizable), dir); |
37
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
215 |
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
|
216 // 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
|
217 } |
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
|
218 void setHeight (wdim nh, int dir) { |
46
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
219 if (nh == h) return; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
220 |
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
|
221 h += row.adjustCellSizes (nh - h, (dir == -1 ? row.lastSizable : row.firstSizable), 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
|
222 |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
223 // Note: setPosition must be called after! |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
224 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
225 |
58
d43523ed4b62
Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
46
diff
changeset
|
226 void setPosition (wdim x, wdim y) { |
34
6b4116e6355c
Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
32
diff
changeset
|
227 this.x = x; |
6b4116e6355c
Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
32
diff
changeset
|
228 this.y = y; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
229 |
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
|
230 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
|
231 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
|
232 } |
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
|
233 //END Size & position |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
234 |
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
|
235 |
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
|
236 // Find the relevant widget. |
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
|
237 IWidget 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
|
238 debug scope (failure) |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
239 logger.warn ("getWidget: failure"); |
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
|
240 // Find row/column: |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
241 myDiff i = col.getCell (cx - x); |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
242 myDiff j = row.getCell (cy - y); |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
243 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
|
244 return this; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
245 |
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 // 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
|
247 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
|
248 } |
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
|
249 |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
250 // Resizing columns & 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
|
251 void 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
|
252 debug scope (failure) |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
253 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
|
254 if (b == 1 && state == true) { |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
255 /* 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
|
256 * 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
|
257 * 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
|
258 |
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
|
259 // find col/row's resizeD & resizeU |
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
|
260 if (col.findResize (cx - x) && row.findResize (cy - y)) |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
261 return; // unable to resize |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
262 |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
263 dragX = cx; |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
264 dragY = cy; |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
265 |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
266 window.gui.addClickCallback (&endCallback); |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
267 window.gui.addMotionCallback (&resizeCallback); |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
268 } |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
269 } |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
270 |
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
|
271 void draw () { |
6b4116e6355c
Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
32
diff
changeset
|
272 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
|
273 |
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 (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
|
275 widget.draw (); |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
276 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
277 |
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
|
278 private: |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
279 //BEGIN Cache calculation functions |
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
|
280 /* Calculations which need to be run whenever a new sub-widget structure is set |
71
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
281 * (i.e. to produce cached data calculated from construction data). |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
282 * Also need to be re-run if the renderer changes. |
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
283 * |
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
|
284 * rows, cols and subWidgets must be set before calling. */ |
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
|
285 void genCachedConstructionData () { |
71
77c7d3235114
Separated the grid layout widget's implementation into a base and a derived class, to allow other uses of layout.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
66
diff
changeset
|
286 // Will only change if renderer changes: |
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
|
287 col.spacing = row.spacing = window.renderer.layoutSpacing; |
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
|
288 |
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
|
289 // Calculate the minimal column and row sizes: |
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
|
290 // set length, making sure the arrays are initialised to zero: |
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
|
291 col.minWidth = new wdim[cols]; |
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
|
292 row.minWidth = new wdim[rows]; |
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
|
293 foreach (i,widget; subWidgets) { |
b28d7adc786b
Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
39
diff
changeset
|
294 // Increase dimensions if current minimal size is larger: |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
295 myIt n = i % cols; // column |
66
f54ae4fc2b2f
Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
296 wdim md = widget.minWidth; |
f54ae4fc2b2f
Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
297 if (col.minWidth[n] < md) col.minWidth[n] = md; |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
298 n = i / cols; // row |
66
f54ae4fc2b2f
Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
299 md = widget.minHeight; |
f54ae4fc2b2f
Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents:
65
diff
changeset
|
300 if (row.minWidth[n] < md) row.minWidth[n] = md; |
40
b28d7adc786b
Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
39
diff
changeset
|
301 } |
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
|
302 |
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
|
303 |
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
|
304 // Calculate the overall minimal size, starting with the spacing: |
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
|
305 mh = window.renderer.layoutSpacing; // use mh temporarily |
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
|
306 mw = mh * cast(wdim)(cols - 1); |
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
|
307 mh *= cast(wdim)(rows - 1); |
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
|
308 |
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
|
309 foreach (x; col.minWidth) // add the column/row's dimensions |
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
|
310 mw += x; |
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
|
311 foreach (x; row.minWidth) |
40
b28d7adc786b
Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
39
diff
changeset
|
312 mh += x; |
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
|
313 |
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
|
314 |
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
|
315 // Find which cols/rows are resizable: |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
316 // reset: |
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
|
317 col.sizable = new bool[cols]; |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
318 row.sizable = new bool[rows]; |
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
|
319 col.firstSizable = row.firstSizable = -1; |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
320 |
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
|
321 forCols: |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
322 for (myIt i = 0; i < cols; ++i) { // for each column |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
323 for (myIt j = 0; j < subWidgets.length; j += cols) // for each row |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
324 if (!subWidgets[i+j].isWSizable) // column not resizable |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
325 continue forCols; // continue the outer for loop |
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
|
326 |
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
|
327 // column is resizable if we get to here |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
328 col.sizable[i] = true; |
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
|
329 if (col.firstSizable < 0) |
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
|
330 col.firstSizable = i; |
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
|
331 col.lastSizable = i; |
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
|
332 } |
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
|
333 |
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
|
334 forRows: |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
335 for (myIt i = 0; i < subWidgets.length; i += cols) { // for each row |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
336 for (myIt j = 0; j < cols; ++j) // for each column |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
337 if (!subWidgets[i+j].isHSizable) |
40
b28d7adc786b
Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
39
diff
changeset
|
338 continue forRows; |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
339 |
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
|
340 row.lastSizable = i / cols; |
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
|
341 row.sizable[row.lastSizable] = true; |
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
|
342 if (row.firstSizable < 0) |
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
|
343 row.firstSizable = row.lastSizable; |
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
|
344 } |
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
345 } |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
346 //END Cache calculation functions |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
347 |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
348 |
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
|
349 void setColWidth (myIt i, wdim w, int dir) { |
46
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
350 for (myIt j = 0; j < rows; ++j) { |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
351 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
|
352 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
353 } |
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
|
354 void setRowHeight (myIt j, wdim h, int dir) { |
46
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
355 for (myIt i = 0; i < cols; ++i) { |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
356 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
|
357 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
358 } |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
359 |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
360 |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
361 //BEGIN Col/row resizing callback |
58
d43523ed4b62
Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
46
diff
changeset
|
362 void resizeCallback (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
|
363 col.resize (cx - dragX); |
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
|
364 row.resize (cy - dragY); |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
365 |
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
|
366 // NOTE: all adjustments are relative; might be better if they were absolute? |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
367 dragX = cx; |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
368 dragY = cy; |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
369 |
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
|
370 foreach (i,widget; subWidgets) |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
371 widget.setPosition (x + col.pos[i % cols], |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
372 y + row.pos[i / cols]); |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
373 window.requestRedraw; |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
374 } |
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
|
375 bool endCallback (wdabs cx, wdabs cy, ubyte b, bool state) { |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
376 if (b == 1 && state == false) { |
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
377 window.gui.removeCallbacks (cast(void*) this); |
45
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
378 return true; // we've handled the up-click |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
379 } |
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
|
380 return false; // we haven't handled it |
40
b28d7adc786b
Made GUI more robust to mutable data changes and improved much of GridLayoutWidget's code.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
39
diff
changeset
|
381 } |
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
|
382 |
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
|
383 protected: |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
384 // 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
|
385 wdim dragX, dragY; // coords where drag starts |
46
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
386 //END Col/row resizing callback |
42
8bf53e711cc7
Partially implemented column/row resizing (code not working well).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
41
diff
changeset
|
387 |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
388 |
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
|
389 myIt cols, rows; // number of cells in grid |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
390 |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
391 /* 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
|
392 * [ 2 3 ] */ |
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
393 IWidget[] subWidgets; |
37
052df9b2fe07
Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
394 |
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
|
395 /* Widths, positions, etc., either of columns or of rows |
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
|
396 * |
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
|
397 * The purpose of this struct is mostly to unify functionality which must work the same on both |
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
|
398 * horizontal and vertical cell placement. |
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
|
399 * |
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
|
400 * Most notation corresponds to horizontal layout (columns), simply for easy of naming. */ |
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
|
401 struct CellDimensions { |
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
|
402 wdim[] pos, // relative position (cumulative width[i-1] plus spacing) |
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
|
403 width, // current widths |
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
|
404 minWidth; // minimal widths (set by genCachedConstructionData) |
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
|
405 bool[] sizable; // true if col is resizable (set by genCachedConstructionData) |
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
|
406 myDiff firstSizable, // first col which is resizable, negative if none |
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
|
407 lastSizable; // as above, but last (set by genCachedConstructionData) |
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
|
408 myDiff resizeD, // resize down from this index (<0 if not resizing) |
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
|
409 resizeU; // and up from this index |
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
|
410 wdim spacing; // used by genPositions (which cannot access the layout class's data) |
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
|
411 /* This is a delegate to a enclosing class's function, since: |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
412 * a different implementation is needed for cols or rows |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
413 * we're unable to access enclosing class members directly */ |
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
|
414 void delegate (myIt,wdim,int) setColWidth; // set width of a column, with resize direction |
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
|
415 |
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
|
416 void dupMin () { |
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
|
417 width = minWidth.dup; |
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
|
418 } |
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
|
419 void setCheck (wdim[] data) { |
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
|
420 // Set to provided data: |
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
|
421 width = data; |
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
|
422 // And check sizes are valid: |
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
|
423 foreach (i, m; minWidth) |
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
|
424 // if fixed width or width is less than minimum: |
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
|
425 if (!sizable[i] || width[i] < m) |
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
|
426 width[i] = m; |
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
|
427 } |
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
|
428 |
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
|
429 // Generate position infomation and return total width (i.e. widget width/height) |
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
|
430 wdim genPositions () { |
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
|
431 pos.length = minWidth.length; |
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
|
432 |
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
|
433 wdim x = 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
|
434 foreach (i, w; width) { |
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
|
435 pos[i] = x; |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
436 x += w + spacing; |
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
|
437 } |
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
|
438 return x - spacing; |
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
|
439 } |
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
|
440 |
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
|
441 // Get the row/column a click occured in |
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
|
442 // Returns -i if in space to left of col i, or i if on col i |
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
|
443 myDiff getCell (wdim l) { |
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
|
444 myDiff i = minWidth.length - 1; // starting from right... |
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
|
445 while (l < pos[i]) { // decrement while left of this column |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
446 debug assert (i > 0, "getCell: l < pos[0] (code error)"); |
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
|
447 --i; |
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
|
448 } // now (l >= pos[i]) |
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
|
449 if (l >= pos[i] + width[i]) // between columns |
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
|
450 return -i - 1; // note: i might be 0 so cannot just return -i |
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
|
451 return i; |
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
|
452 } |
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
|
453 |
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
|
454 // Calculate resizeU/resizeD, and return true if unable to resize. |
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
|
455 bool findResize (wdim l) { |
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
|
456 resizeU = -getCell (l); // potential start for upward-resizes |
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
|
457 if (resizeU <= 0) return true; // not on a space between cells |
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
|
458 resizeD = resizeU - 1; // potential start for downward-resizes |
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
|
459 |
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
|
460 while (!sizable[resizeU]) { // find first actually resizable column (upwards) |
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
|
461 ++resizeU; |
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
|
462 if (resizeU >= minWidth.length) { // cannot resize |
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
|
463 resizeU = -1; |
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
|
464 return true; |
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
|
465 } |
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
|
466 } |
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
|
467 |
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
|
468 while (!sizable[resizeD]) { // find first actually resizable column (downwards) |
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
|
469 --resizeD; |
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
|
470 if (resizeD < 0) { // cannot resize |
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
|
471 resizeU = -1; // resizeU is tested to check whether resizes are possible |
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
|
472 return true; |
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
|
473 } |
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
|
474 } |
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
|
475 |
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
|
476 return false; // can resize |
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
|
477 } |
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
|
478 |
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
|
479 /* Adjust the total size of rows/columns (including spacing) by diff. |
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
|
480 * |
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
|
481 * Params: |
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
|
482 * diff = amount to increase/decrease the total size |
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
|
483 * start= index for col/row to start resizing on |
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
|
484 * incr = direction to resize in (added to index each step). Must be either -1 or +1. |
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
|
485 * |
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
|
486 * Returns: |
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
|
487 * The amount adjusted. This may be larger than diff, since cellD is clamped by cellDMin. |
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
|
488 * |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
489 * Note: Check variable used for start is valid before calling! If a non-sizable column's |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
490 * index is passed, this should get increased (if diff > 0) but not decreased. |
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
|
491 */ |
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
|
492 wdim adjustCellSizes (wdim diff, myDiff start, int incr) |
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
|
493 in { |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
494 // Could occur if adjust isn't called first, but this would be a code error: |
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
|
495 assert (width !is null, "adjustCellSizes: width is null"); |
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
|
496 // Most likely if passed negative when sizing is disabled: |
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
|
497 assert (start >= 0 && start < minWidth.length, "adjustCellSizes: invalid start"); |
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
|
498 assert (incr == 1 || incr == -1, "adjustCellSizes: invalid incr"); |
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
|
499 assert (setColWidth !is null, "adjustCellSizes: setColWidth is null"); |
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
|
500 } body { |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
501 debug scope(failure) |
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
|
502 logger.trace ("adjustCellSizes: failure"); |
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
|
503 myDiff i = start; |
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
|
504 if (diff > 0) { // increase size of first resizable cell |
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
|
505 width[i] += diff; |
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
|
506 setColWidth (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
|
507 } |
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
|
508 else if (diff < 0) { // decrease |
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
|
509 wdim rd = diff; // running diff |
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
|
510 aCSwhile: |
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
|
511 while (true) { |
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
|
512 width[i] += rd; // decrease this cell's size (but may be too much) |
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
|
513 rd = width[i] - minWidth[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
|
514 if (rd >= 0) { // OK; we're done |
03fa79a48c48
Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
45
diff
changeset
|
515 setColWidth (i, width[i], incr); // set new width |
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
|
516 break; // we hit the mark exactly: diff is correct |
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
|
517 } |
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
|
518 |
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
|
519 // else we decreased it too much! |
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
|
520 width[i] = minWidth[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
|
521 setColWidth (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
|
522 // rd is remainder to decrease by |
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
|
523 |
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
|
524 |
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
|
525 bool it = true; // iterate (force first time) |
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
|
526 while (it) { |
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
|
527 i += incr; |
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
|
528 if (i < 0 || i >= minWidth.length) { // run out of next cells |
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
|
529 diff -= rd; // still had rd left to decrease |
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
|
530 break aCSwhile; // exception: Array index out of bounds |
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
|
531 } |
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
|
532 it = !sizable[i]; // iterate again if row/col isn't resizable |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
533 } |
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
|
534 } |
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
|
535 } |
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
|
536 // else no adjustment needed (diff == 0) |
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
|
537 |
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
|
538 genPositions; |
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
|
539 return diff; |
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
|
540 } |
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
|
541 |
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
|
542 void resize (wdim diff) { |
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
|
543 if (resizeU <= 0) return; |
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
|
544 |
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
|
545 // do shrinking first (in case we hit the minimum) |
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
|
546 if (diff >= 0) { |
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
|
547 diff = -adjustCellSizes (-diff, resizeU, 1); |
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
|
548 adjustCellSizes (diff, resizeD, -1); |
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
|
549 } else { |
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
|
550 diff = -adjustCellSizes (diff, resizeD, -1); |
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
|
551 adjustCellSizes (diff, resizeU, 1); |
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
|
552 } |
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
|
553 } |
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
|
554 } |
0fd51d2c6c8a
Several changes to resising windows and layout widgets. This commit still has some bugs.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
43
diff
changeset
|
555 CellDimensions col, row; |
43
1530d9c04d4d
Column/row resizing implemented for GridLayoutWidget (finally)!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
42
diff
changeset
|
556 |
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
|
557 // Index types. Note that in some cases they need to hold negative values. |
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
|
558 // int is used for resizing direction (although ptrdiff_t would be more appropriate), |
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
|
559 // since the value must always be -1 or +1 and int is smaller on X86_64. |
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
|
560 alias size_t myIt; |
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
|
561 alias ptrdiff_t myDiff; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
562 } |