Mercurial > projects > mde
annotate mde/gui/widget/Floating.d @ 173:a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sat, 08 Aug 2009 15:53:10 +0200 |
parents | 0dd49f333189 |
children | 3d58adc17d20 |
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 |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
16 /** The "window" class − a widget. */ |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
17 module mde.gui.widget.Floating; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
18 |
131
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
130
diff
changeset
|
19 import mde.gui.widget.AParentWidget; |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
20 import mde.gui.exception; |
137
9f035cd139c6
BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
131
diff
changeset
|
21 import mde.content.IContent; |
159
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
22 import mde.content.AStringContent; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
23 |
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
|
24 import tango.util.log.Log : Log, Logger; |
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
|
25 |
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
|
26 private Logger logger; |
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
|
27 static this () { |
82
ac1e3fd07275
New ssi file format.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
80
diff
changeset
|
28 logger = Log.getLogger ("mde.gui.widget.Floating"); |
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
|
29 } |
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
|
30 |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
31 /** An area to contain floating widgets. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
32 * |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
33 * The position of each sub-widget is set from dimension data, but not the size. |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
34 * Rationale: parents' need to set subwidgets' positions when its position is set, so it needs to |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
35 * know their positions. |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
36 * |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
37 * Data: Each string item is interpreted as a sub-widget widgetID to add as a floating window. |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
38 * Ints consist of widget type followed by a border type (flags from IRenderer.Border.BTYPE) for |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
39 * each sub-widget. */ |
95
2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
92
diff
changeset
|
40 class FloatingAreaWidget : AParentWidget |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
41 { |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
42 static this () { |
159
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
43 raiseOnHover = new BoolContent ("GUI.raiseOnHover"); |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
44 } |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
45 |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
46 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content) { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
47 if (data.ints.length != 1 + data.strings.length) |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
48 throw new WidgetDataException (this); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
49 super (mgr, parent, id); |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
50 |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
51 subWidgets.length = data.strings.length; // widgets created from string data |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
52 sWOrder.length = subWidgets.length; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
53 sWData.length = subWidgets.length; |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
54 foreach (i,s; data.strings) { |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
55 subWidgets[i] = mgr.makeWidget (this, s, content); |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
56 sWOrder[i] = i; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
57 sWData[i].borderType = cast(BTYPE) data.ints[i+1]; |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
58 } |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
59 |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
60 wdim[] dd = mgr.dimData (id); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
61 if (dd.length == subWidgets.length * 4) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
62 foreach (i, ref d; sWData) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
63 (&d.x)[0..4] = dd[i*4..i*4+4]; |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
64 } |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
65 } |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
66 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
67 override bool setup (uint n, uint flags) { |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
68 debug (mdeWidgets) logger.trace ("FloatingAreaWidget.setup"); |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
69 foreach (i, ref d; sWData) with (d) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
70 auto widg = subWidgets[i]; |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
71 if (!widg.setup (n, flags) && !(flags & 1)) |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
103
diff
changeset
|
72 continue; // no changes; skip the rest |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
103
diff
changeset
|
73 |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
103
diff
changeset
|
74 d.border = mgr.renderer.getBorder (borderType, widg.isWSizable, widg.isHSizable); |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
75 mw = widg.minWidth + border.x1 + border.x2; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
76 mh = widg.minHeight + border.y1 + border.y2; |
103
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
77 if (w < mw || !widg.isWSizable) w = mw; |
42e241e7be3e
ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
99
diff
changeset
|
78 if (h < mh || !widg.isHSizable) h = mh; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
79 widg.setWidth (w - border.x1 - border.x2, -1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
80 widg.setHeight (h - border.y1 - border.y2, -1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
81 } |
144
66c58e5b0062
Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
139
diff
changeset
|
82 return n == 0; // floating area size is not changed |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
83 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
84 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
85 override bool saveChanges () { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
86 wdim[] dd = new wdim[sWData.length*4]; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
87 foreach (i, ref d; sWData) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
88 subWidgets[i].saveChanges (); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
89 dd[4*i..4*i+4] = (&d.x)[0..4]; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
90 } |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
91 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
114
diff
changeset
|
92 mgr.dimData (id, dd); // save positions |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
93 return true; |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
94 } |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
95 |
172
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
96 override void setContent (IContent c) { |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
97 // Pass the content on to sub-widgets, in case they want it |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
98 foreach (widg; subWidgets) |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
99 widg.setContent = c; |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
100 } |
0dd49f333189
Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents:
160
diff
changeset
|
101 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
102 override void setWidth (wdim nw, int) { |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
103 w = nw; |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
104 // check all floating widgets are visible |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
105 foreach (i, ref d; sWData) with (d) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
106 if (x + w > this.w) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
107 x = (w > this.w) ? 0 : this.w - w; |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
108 } |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
109 } |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
110 override void setHeight (wdim nh, int) { |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
111 h = nh; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
112 foreach (i, ref d; sWData) with (d) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
113 if (y + h > this.h) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
114 y = (h > this.h) ? 0 : this.h - h; |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
115 } |
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
|
116 } |
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
|
117 |
130
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
118 override bool isWSizable () { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
119 return true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
120 } |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
121 override bool isHSizable () { |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
122 return true; |
c5c38eaadb64
Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
123 } |
92
085f2ca31914
Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
91
diff
changeset
|
124 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
125 override void setPosition (wdim nx, wdim ny) { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
126 x = nx; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
127 y = ny; |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
128 |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
129 size_t n = subWidgets.length; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
130 foreach (i, ref d; sWData) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
131 subWidgets[i].setPosition (x + d.x + d.border.x1, y + d.y + d.border.y1); |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
132 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
133 |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
134 override void minWChange (IChildWidget widg, wdim nmw) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
135 with (sWData[getWidgetIndex(widg)]) { |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
136 mw = nmw + border.x1 + border.x2; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
137 |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
138 if (mw > w || !widg.isWSizable) { |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
139 w = mw; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
140 widg.setWidth (w - border.x1 - border.x2, -1); |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
141 } |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
142 |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
143 if (x + w > this.w) |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
144 x = (w > this.w) ? 0 : this.w - w; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
145 |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
146 widg.setPosition (this.x + border.x1 + x,this.y + border.y1 + y); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
147 mgr.requestRedraw; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
148 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
149 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
150 override void minHChange (IChildWidget widg, wdim nmh) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
151 with (sWData[getWidgetIndex(widg)]) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
152 mh = nmh + border.y1 + border.y2; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
153 |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
154 if (mh > h || !widg.isHSizable) { |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
155 h = mh; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
156 widg.setHeight (h - border.y1 - border.y2, -1); |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
157 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
158 |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
159 if (y + h > this.h) |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
160 y = (h > this.h) ? 0 : this.h - h; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
161 |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
162 widg.setPosition (this.x + border.x1 + x,this.y + border.y1 + y); |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
163 mgr.requestRedraw; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
164 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
165 } |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
166 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
167 override void draw () { |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
168 super.draw; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
169 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
170 mgr.renderer.restrict (x,y, w,h); |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
171 foreach (i; sWOrder) |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
172 with (sWData[i]) { |
147
075705ad664a
Added a border widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
144
diff
changeset
|
173 mgr.renderer.drawBorder (&border, this.x + x, this.y + y, w, h); |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
174 subWidgets[i].draw; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
175 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
176 mgr.renderer.relax; |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
177 } |
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
178 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
179 override IChildWidget getWidget (wdim cx, wdim cy) { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
180 debug scope (failure) |
139
29a524e7c858
Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
137
diff
changeset
|
181 logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h); |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
182 |
159
b06b04c75e86
Finished last commit, rearranged code for the WidgetManager class.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
158
diff
changeset
|
183 size_t event = getFloatingWidget (cx,cy, raiseOnHover()); |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
184 if (event > sWData.length) |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
185 return this; // no match |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
186 |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
187 with (sWData[event]) { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
188 wdim lx = cx - (this.x + x); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
189 wdim ly = cy - (this.y + y); |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
190 if (lx >= border.x1 && lx < w-border.x2 && |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
191 ly >= border.y1 && ly < h-border.y2) |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
192 return subWidgets[event].getWidget (cx,cy); |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
193 return this; |
96
dbf332403c6e
Improvements to FloatingAreaWidget: positioning, passing click events and draw order.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
95
diff
changeset
|
194 } |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
195 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
75
diff
changeset
|
196 |
114
b16a534f5302
Changes for tango r4201. Added override keyword in a lot of places.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
197 override int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state) { |
35
928db3c75ed3
Windows can now be moved.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
198 if (b == 1 && state == true) { |
173
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
199 size_t event = getFloatingWidget (cx,cy, true); |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
200 if (event > subWidgets.length) return 0; |
a1ba9157510e
Enabled ServiceContentList to call its callbacks when its value changes. Tried to fix some other bugs, but this is not a very clean commit, due to wanting to make some big changes to enable better use of invariants next.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
172
diff
changeset
|
201 active = event; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
202 with (sWData[active]) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
203 resizeType = border.getResize (cx - this.x - x, cy - this.y - y, w,h); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
204 alias border.RESIZE RESIZE; |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
205 |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
206 if (resizeType != RESIZE.NONE) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
207 // Set x/yDrag (unfortunately these need to be different for each edge) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
208 if (resizeType & RESIZE.X1) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
209 xDrag = w + cx; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
210 else if (resizeType & RESIZE.X2) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
211 xDrag = w - cx; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
212 |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
213 if (resizeType & RESIZE.Y1) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
214 yDrag = h + cy; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
215 else if (resizeType & RESIZE.Y2) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
216 yDrag = h - cy; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
217 |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
218 return 2; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
219 } else if (borderType & BTYPE.MOVE) { // window is being moved |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
220 xDrag = cx - x; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
221 yDrag = cy - y; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
222 |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
223 return 2; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
224 } |
38
8c4c96f04e7f
Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
37
diff
changeset
|
225 } |
35
928db3c75ed3
Windows can now be moved.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
226 } |
99
5de5810e3516
Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
97
diff
changeset
|
227 return 0; |
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
|
228 } |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
229 void dragMotion (wdabs cx, wdabs cy, IChildWidget) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
230 if (resizeType == RESIZE.NONE) { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
231 with (sWData[active]) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
232 x = cx-xDrag; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
233 y = cy-yDrag; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
234 |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
235 if (x < 0) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
236 x = 0; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
237 else if (x + w > this.w) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
238 x = (w > this.w) ? 0 : this.w - w; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
239 if (y < 0) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
240 y = 0; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
241 else if (y + h > this.h) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
242 y = (h > this.h) ? 0 : this.h - h; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
243 |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
244 subWidgets[active].setPosition (this.x + x + border.x1, this.y + y + border.y1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
245 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
246 mgr.requestRedraw; |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
247 } else { |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
248 with (sWData[active]) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
249 if (resizeType & RESIZE.X1) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
250 wdim ow = w; |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
251 w = xDrag - cx; // new width |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
252 if (w < mw) w = mw; // limit to min width |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
253 x += ow - w; // move by difference |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
254 if (x < 0) { // limit to left edge of area |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
255 w += x; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
256 x = 0; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
257 } |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
258 subWidgets[active].setWidth (w - border.x1 - border.x2, 1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
259 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
260 else if (resizeType & RESIZE.X2) { |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
261 w = xDrag + cx; // new width |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
262 if (w < mw) w = mw; // limit to min width |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
263 if (x + w > this.w) // limit to right edge of area |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
264 w = this.w - x; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
265 subWidgets[active].setWidth (w - border.x1 - border.x2, -1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
266 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
267 if (resizeType & RESIZE.Y1) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
268 wdim oh = h; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
269 h = yDrag - cy; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
270 if (h < mh) h = mh; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
271 y += oh - h; |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
272 if (y < 0) { |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
273 h += y; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
274 y = 0; |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
275 } |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
276 subWidgets[active].setHeight (h - border.y1 - border.y2, 1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
277 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
278 else if (resizeType & RESIZE.Y2) { |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
279 h = yDrag + cy; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
280 if (h < mh) h = mh; |
123
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
281 if (y + h > this.h) |
d3b2cefd46c9
minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
121
diff
changeset
|
282 h = this.h - y; |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
283 subWidgets[active].setHeight (h - border.y1 - border.y2, -1); |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
284 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
285 // Reposition widget and sub-widgets: |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
286 subWidgets[active].setPosition (this.x + x + border.x1, this.y + y + border.y1); |
38
8c4c96f04e7f
Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
37
diff
changeset
|
287 } |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
288 mgr.requestRedraw; |
38
8c4c96f04e7f
Windows can now be resized!
Diggory Hardy <diggory.hardy@gmail.com>
parents:
37
diff
changeset
|
289 } |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
290 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
291 bool dragRelease (wdabs, wdabs, IChildWidget) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
292 return true; // we've handled the up-click |
35
928db3c75ed3
Windows can now be moved.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
34
diff
changeset
|
293 } |
39
5132301e9ed7
Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
38
diff
changeset
|
294 |
160
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
295 protected: |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
296 /** Return the index of the floating object under (cx,cy). If no widget is, |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
297 * return size_t.max. |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
298 * |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
299 * Params: |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
300 * raiseWidget = if true, the widget returned is raised to be the top- |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
301 * most floating widget. */ |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
302 size_t getFloatingWidget (wdim cx, wdim cy, bool raiseWidget = false) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
303 debug assert (cx >= x && cx < x + w && cy >= y && cy < y + h, "getWidget: not on widget (code error)"); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
304 |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
305 foreach_reverse (j,i; sWOrder) with (sWData[i]) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
306 wdim lx = cx - (this.x + x); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
307 wdim ly = cy - (this.y + y); |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
308 if (lx >= 0 && lx < w && ly >= 0 && ly < h) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
309 if (raiseWidget) { |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
310 sWOrder[j..$-1] = sWOrder[j+1..$].dup; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
311 sWOrder[$-1] = i; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
312 mgr.requestRedraw; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
313 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
314 return i; |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
315 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
316 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
317 return size_t.max; // no match |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
318 } |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
319 |
ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
159
diff
changeset
|
320 |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
321 struct SWData { // NOTE: x,y,w,h must be first elements; search (&d.x) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
322 wdim x,y; // position (corner of border) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
323 wdim w,h; // size (including border) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
324 wdim mw,mh; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
325 BTYPE borderType; // what type of border to put around the widget |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
326 IRenderer.Border border; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
327 } |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
328 static assert (SWData.alignof == 4); // assumptions for optimization; search (&d.x) |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
329 SWData[] sWData; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
330 size_t[] sWOrder; // indexes for draw order (top widget at end of list) |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
331 |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
332 // Click/drag information: |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
333 alias IRenderer.Border.BTYPE BTYPE; |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
334 alias IRenderer.Border.RESIZE RESIZE; |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
335 size_t active = size_t.max; // refers to widget being moved/resized |
97
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
336 wdim xDrag, yDrag; // where a drag starts relative to x and y |
30470bc19ca4
Floating widgets now work nicely: customizable borders added, resizing, moving.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
96
diff
changeset
|
337 RESIZE resizeType; // Type of current resize |
158
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
338 |
f132e599043f
Re-enabled raising floating widgets, by clicking frame; disabled attempt at immediate language reloading for popup-button widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
157
diff
changeset
|
339 static BoolContent raiseOnHover; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
340 } |