Mercurial > projects > mde
annotate mde/gui/WidgetManager.d @ 131:9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Moved Widget.AWidget to AChildWidget.AChildWidget and Widget.AParentWidget to AParentWidget.AParentWidget.
Removed ASingleParentWidget to improve code sharing.
AChildWidget doesn't implement IParentWidget like AWidget did.
New IPopupParentWidget extending IParentWidget for the WM and some widgets to handle popups.
Cut old popup management code.
New underMouse() function replacing highlight(); called on all widgets.
Separate menu-popup and button widgets aren't needed for menus now.
Functions returning content widgets have been moved to their own module.
Cleaned up jobs.txt.
Switched to 80 line length for Ddoc.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Wed, 21 Jan 2009 13:01:40 +0000 |
parents | ad91de8867a0 |
children | 264028f4115a |
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 |
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:
129
diff
changeset
|
16 /****************************************************************************** |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
17 * The gui manager class base. |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
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:
129
diff
changeset
|
19 * This contains most of the code required by a window manager, but does not |
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:
129
diff
changeset
|
20 * interact with a screen or get user input. Rendering is handled separately by |
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:
129
diff
changeset
|
21 * the renderer anyway. |
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:
129
diff
changeset
|
22 * |
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:
129
diff
changeset
|
23 * Public non IWidget* methods should be thread-safe. |
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:
129
diff
changeset
|
24 *****************************************************************************/ |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
25 module mde.gui.WidgetManager; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
26 |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
27 import mde.gui.WidgetDataSet; |
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
|
28 import mde.gui.widget.Ifaces; |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
29 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
|
30 |
36
57d000574d75
Enabled drawing on demand, and made the polling interval configurable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
35
diff
changeset
|
31 import imde = mde.imde; |
128
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
32 import mde.lookup.Options; // miscOpts.L10n callback |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
33 import mde.content.Content; |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
34 import Items = mde.content.Items; // loadTranslation |
129
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
35 debug import mde.content.miscContent; // Debug menu |
128
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
36 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
37 import mde.file.mergetag.Reader; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
38 import mde.file.mergetag.Writer; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
39 import mde.setup.paths; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
40 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
41 // Widgets to create: |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
42 import mde.gui.widget.layout; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
43 import mde.gui.widget.miscWidgets; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
44 import mde.gui.widget.TextWidget; |
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:
129
diff
changeset
|
45 import mde.gui.widget.contentFunctions; |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
46 import mde.gui.widget.miscContent; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
47 import mde.gui.widget.Floating; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
48 import mde.gui.widget.PopupMenu; |
36
57d000574d75
Enabled drawing on demand, and made the polling interval configurable.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
35
diff
changeset
|
49 |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
50 import tango.core.sync.Mutex; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
51 import tango.util.log.Log : Log, Logger; |
113
9824bee909fd
Popup menu; works for simple menus except that clicking an item doesn't close it.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
112
diff
changeset
|
52 import tango.util.container.SortedMap; |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
53 |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
54 private Logger logger; |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
55 static this () { |
75
25cb7420dc91
A massive overhaul/rewrite for the gui's data management and setup code. Currently much that was working is broken.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
74
diff
changeset
|
56 logger = Log.getLogger ("mde.gui.WidgetManager"); |
32
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
57 } |
316b0230a849
Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff
changeset
|
58 |
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:
129
diff
changeset
|
59 /****************************************************************************** |
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:
129
diff
changeset
|
60 * Contains the code for loading and saving an entire gui (more than one may |
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:
129
diff
changeset
|
61 * exist), but not the code for drawing it or handling user input. |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
62 * |
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
63 * This abstract class exists solely for separating out some of the functionality. |
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:
129
diff
changeset
|
64 *****************************************************************************/ |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
65 abstract scope class AWidgetManager : IWidgetManager |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
66 { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
67 /** Construct a new widget loader. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
68 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
69 * params: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
70 * fileName = Name of file specifying the gui, excluding path and extension. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
71 */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
72 protected this (char[] file) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
73 mutex = new Mutex; // Used on functions intended to be called from outside the gui package. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
74 fileName = file; |
128
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
75 miscOpts.L10n.addCallback (&reloadStrings); |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
76 |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
77 clickCallbacks = new typeof(clickCallbacks); |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
78 motionCallbacks = new typeof(motionCallbacks); |
129
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
79 |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
80 debug { |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
81 auto lWS = new EventContent ("logWidgetSize"); |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
82 lWS.addCallback (&logWidgetSize); |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
83 imde.menu.append (lWS); |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
84 } |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
85 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
86 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
87 /* Load the widgets' data from the file specified to the CTOR. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
88 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
89 * params: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
90 * allDesigns = Load all sections |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
91 */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
92 private void loadData (bool allDesigns = false) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
93 if (allLoaded || (defaultDesign !is null && allDesigns == false)) |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
94 return; // test if already loaded |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
95 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
96 // Set up a reader |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
97 scope IReader reader; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
98 try { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
99 reader = confDir.makeMTReader (fileName, PRIORITY.HIGH_LOW, null, true); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
100 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
101 // Read from the HEADER: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
102 // Get the renderer |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
103 char[]* p = "Renderer" in reader.dataset.header._charA; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
104 if (p is null || *p is null) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
105 logger.warn ("No renderer specified: using \"Simple\""); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
106 rendName = "Simple"; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
107 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
108 else |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
109 rendName = *p; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
110 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
111 // Get which section to use |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
112 p = "Design" in reader.dataset.header._charA; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
113 if (p is null || *p is null) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
114 logger.warn ("No gui design specified: trying \"Default\""); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
115 defaultDesign = "Default"; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
116 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
117 else |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
118 defaultDesign = *p; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
119 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
120 // Read the body: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
121 // Load the chosen design |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
122 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
123 WidgetDataSet* p = id in data; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
124 if (p is null) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
125 data[id] = new WidgetDataSet; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
126 return *(id in data); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
127 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
128 return *p; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
129 }; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
130 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
131 if (allDesigns) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
132 reader.read; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
133 allLoaded = true; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
134 } else |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
135 reader.read([defaultDesign]); |
81
d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
80
diff
changeset
|
136 } catch (NoFileException) { |
117
aba2dd815a1f
Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
116
diff
changeset
|
137 logger.error ("Unable to load GUI: no config file: "~fileName); |
81
d8fccaa45d5f
Moved file IO code from mde/mergetag to mde/file[/mergetag] and changed how some errors are caught.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
80
diff
changeset
|
138 // just return: not a fatal error (so long as the game can run without a GUI!) |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
139 } catch (Exception e) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
140 logger.error ("Unable to load GUI: errors parsing config file ("~confDir.getFileName(fileName,PRIORITY.HIGH_LOW)~"):"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
141 logger.error (e.msg); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
142 throw new GuiException ("Failure parsing config file"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
143 } |
128
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
144 |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
145 Items.loadTranslation (); |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
146 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
147 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
148 /** Load the gui from some design. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
149 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
150 * If a design was previously loaded, its changes are saved first. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
151 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
152 * Params: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
153 * name = Design to load. If null, the default will be loaded. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
154 */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
155 void loadDesign (char[] name = null) { |
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
|
156 if (changes !is null) // A design was previously loaded |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
157 save; // own lock |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
158 |
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
|
159 mutex.lock; |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
160 scope(exit) mutex.unlock; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
161 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
162 // Load data (loadData tests if it's already loaded first): |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
163 if (name is null) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
164 loadData (false); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
165 name = defaultDesign; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
166 } else |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
167 loadData (true); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
168 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
169 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
170 // Get data: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
171 auto p = name in data; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
172 while (p is null) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
173 if (name == defaultDesign) |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
174 throw new GuiException ("Unable to load [specified or] default design"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
175 name = defaultDesign; // try again with the default |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
176 p = name in data; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
177 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
178 curData = *p; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
179 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
180 // Get/create a changes section: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
181 if (changesDS is null) |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
182 changesDS = new mt.DataSet; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
183 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
184 mt.IDataSection* q = name in changesDS.sec; |
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
|
185 if (!q || ((changes = cast(WidgetDataChanges) *q) is null)) { |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
186 changes = new WidgetDataChanges (curData); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
187 changesDS.sec[name] = changes; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
188 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
189 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
190 // Create the widgets: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
191 createRootWidget; |
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:
129
diff
changeset
|
192 underMouse = child; // must be something |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
193 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
194 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
195 /** Save changes, if any exist. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
196 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
197 * Is run when the manager is destroyed, but could be run at other times too. */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
198 void save () { |
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
|
199 preSave; |
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
|
200 |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
201 mutex.lock; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
202 scope(exit) mutex.unlock; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
203 |
128
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
204 // Make all widgets save any changed data: |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
205 child.saveChanges; |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
206 |
41582439a42b
Added support for dynamic EnumContent loading and saving, with translation loading.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
126
diff
changeset
|
207 if (changes.noChanges) |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
208 return; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
209 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
210 if (loadUserFile) { // merge entries from user file into current changes |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
211 try { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
212 scope IReader reader = confDir.makeMTReader ( |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
213 fileName, PRIORITY.HIGH_ONLY, changesDS, true); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
214 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
215 // Create if necessary, only corresponding to existing designs read: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
216 reader.dataSecCreator = delegate mt.IDataSection(mt.ID id) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
217 WidgetDataSet* p = id in data; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
218 if (p is null) |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
219 throw new Exception ("File has changed since it was loaded!"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
220 return new WidgetDataChanges (*p); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
221 }; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
222 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
223 reader.read; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
224 } catch (NoFileException) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
225 // No user file exists; not an error. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
226 } catch (Exception e) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
227 logger.error ("Error reading "~confDir.getFileName(fileName,PRIORITY.HIGH_ONLY)~" prior to saving:"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
228 logger.error (e.msg); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
229 logger.error ("Overwriting the file."); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
230 // Continue... |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
231 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
232 loadUserFile = false; // don't need to do it again |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
233 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
234 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
235 try { // Save |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
236 IWriter writer; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
237 writer = confDir.makeMTWriter (fileName, changesDS); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
238 writer.write; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
239 } catch (Exception e) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
240 logger.error ("Saving to "~confDir.getFileName(fileName,PRIORITY.HIGH_ONLY)~" failed:"); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
241 logger.error (e.msg); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
242 // No point in throwing since it doesn't affect anything else. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
243 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
244 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
245 |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
246 /** Get the names of all designs available. */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
247 char[][] designs() { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
248 synchronized(mutex) { |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
249 loadData (true); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
250 return data.keys; |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
251 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
252 } |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
253 |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
254 /** Called when translation strings have been reloaded. */ |
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:
129
diff
changeset
|
255 protected void reloadStrings (Content) { |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
256 Items.loadTranslation; |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
257 child.setup (++setupN, 2); |
112
fe061009029d
EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
258 child.setWidth (w, -1); |
fe061009029d
EnumContent; log level can be selected from a popup list.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
111
diff
changeset
|
259 child.setHeight (h, -1); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
260 child.setPosition (0,0); |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
261 requestRedraw; |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
262 } |
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
263 |
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:
129
diff
changeset
|
264 // These methods are only intended for use within the gui package. |
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:
129
diff
changeset
|
265 // They are not necessarily thread-safe: |
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:
129
diff
changeset
|
266 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
267 //BEGIN IParentWidget methods |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
268 // If call reaches the widget manager there isn't any recursion. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
269 //NOTE: should be override |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
270 final void recursionCheck (widgetID) {} |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
271 |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
272 override void minWChange (IChildWidget widget, wdim nmw) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
273 debug assert (widget is child, "WM.mSC (code error)"); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
274 mw = nmw; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
275 if (w < nmw) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
276 child.setWidth (nmw, -1); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
277 w = nmw; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
278 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
279 child.setPosition (0,0); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
280 requestRedraw; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
281 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
282 override void minHChange (IChildWidget widget, wdim nmh) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
283 debug assert (widget is child, "WM.mSC (code error)"); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
284 mh = nmh; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
285 if (h < nmh) { |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
286 child.setHeight (nmh, -1); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
287 h = nmh; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
288 } |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
289 child.setPosition (0,0); |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
290 requestRedraw; |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
291 } |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
292 //END IParentWidget methods |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
293 |
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:
129
diff
changeset
|
294 //BEGIN IPopupParentWidget methods |
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:
129
diff
changeset
|
295 override IPopupParentWidget getParentIPPW () { |
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:
129
diff
changeset
|
296 return this; |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
297 } |
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:
129
diff
changeset
|
298 |
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:
129
diff
changeset
|
299 override void addChildIPPW (IPopupParentWidget ippw) { |
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:
129
diff
changeset
|
300 if (childIPPW) |
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:
129
diff
changeset
|
301 childIPPW.removedIPPW; |
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:
129
diff
changeset
|
302 childIPPW = ippw; |
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:
129
diff
changeset
|
303 requestRedraw; |
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:
129
diff
changeset
|
304 } |
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:
129
diff
changeset
|
305 override bool removeChildIPPW (IPopupParentWidget ippw) { |
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:
129
diff
changeset
|
306 if (childIPPW !is ippw) return false; |
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:
129
diff
changeset
|
307 childIPPW.removedIPPW; |
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:
129
diff
changeset
|
308 childIPPW = null; |
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:
129
diff
changeset
|
309 mAIPPW = false; |
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:
129
diff
changeset
|
310 requestRedraw; |
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:
129
diff
changeset
|
311 return false; |
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:
129
diff
changeset
|
312 } |
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:
129
diff
changeset
|
313 |
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:
129
diff
changeset
|
314 override void menuActive (bool mA) { |
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:
129
diff
changeset
|
315 mAIPPW = mA; |
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:
129
diff
changeset
|
316 if (childIPPW) |
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:
129
diff
changeset
|
317 childIPPW.menuActive = mA; |
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:
129
diff
changeset
|
318 } |
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:
129
diff
changeset
|
319 override bool menuActive () { |
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:
129
diff
changeset
|
320 return mAIPPW; |
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:
129
diff
changeset
|
321 } |
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:
129
diff
changeset
|
322 |
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:
129
diff
changeset
|
323 // Don't do anything. E.g. can get called by non-popup buttons. |
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:
129
diff
changeset
|
324 override void menuDone () {} |
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:
129
diff
changeset
|
325 |
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:
129
diff
changeset
|
326 override IChildWidget getPopupWidget (wdabs cx, wdabs cy, bool closePopup) { |
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:
129
diff
changeset
|
327 IChildWidget ret; |
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:
129
diff
changeset
|
328 if (childIPPW) { |
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:
129
diff
changeset
|
329 ret = childIPPW.getPopupWidget (cx, cy, closePopup); |
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:
129
diff
changeset
|
330 if (closePopup && ret is null) { |
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:
129
diff
changeset
|
331 menuActive = false; |
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:
129
diff
changeset
|
332 removeChildIPPW (childIPPW); |
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:
129
diff
changeset
|
333 } |
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:
129
diff
changeset
|
334 } |
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:
129
diff
changeset
|
335 return ret; |
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:
129
diff
changeset
|
336 } |
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:
129
diff
changeset
|
337 |
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:
129
diff
changeset
|
338 debug protected override bool isChild (IPopupParentWidget ippw) { |
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:
129
diff
changeset
|
339 return ippw is childIPPW; |
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:
129
diff
changeset
|
340 } |
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:
129
diff
changeset
|
341 |
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:
129
diff
changeset
|
342 override void removedIPPW () {} // irrelevant |
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:
129
diff
changeset
|
343 override void drawPopup () {} |
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:
129
diff
changeset
|
344 //END IPopupParentWidget methods |
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:
129
diff
changeset
|
345 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
346 //BEGIN IWidgetManager methods |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
347 override IChildWidget makeWidget (IParentWidget parent, widgetID id, IContent content = null) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
348 { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
349 debug assert (parent, "makeWidget: parent is null (code error)"); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
350 debug scope (failure) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
351 logger.warn ("Creating widget \""~id~"\" failed."); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
352 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
353 WidgetData data = curData[id]; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
354 if (data.ints.length < 1) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
355 logger.error ("No int data; creating a debug widget"); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
356 data.ints = [WIDGET_TYPE.Debug]; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
357 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
358 int type = data.ints[0]; // type is first element of data |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
359 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
360 try { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
361 // Statically programmed binary search on type, returning a new widget or calling a |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
362 // function: |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
363 //pragma (msg, binarySearch ("type", WIDGETS)); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
364 mixin (binarySearch ("type", WIDGETS)); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
365 // Not returned a new widget: |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
366 logger.error ("Bad widget type: {}; creating a debug widget instead",type); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
367 } catch (Exception e) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
368 logger.error ("Error creating widget: {}; creating a debug widget instead.", e.msg); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
369 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
370 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
371 return new DebugWidget (this, this, id, data); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
372 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
373 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
374 override WidgetData widgetData (widgetID id) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
375 return curData[id]; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
376 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
377 override void widgetData (widgetID id, WidgetData d) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
378 changes[id] = d; // also updates WidgetDataSet in data. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
379 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
380 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
381 override wdims dimData (widgetID id) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
382 return curData.dims (id); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
383 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
384 override void dimData (widgetID id, wdims d) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
385 changes.setDims(id, d); // also updates WidgetDataSet in data. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
386 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
387 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
388 IRenderer renderer () { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
389 assert (rend !is null, "WidgetManager.renderer: rend is null"); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
390 return rend; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
391 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
392 |
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:
129
diff
changeset
|
393 void positionPopup (IChildWidget parent, IChildWidget popup, int flags = 0) { |
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:
129
diff
changeset
|
394 debug assert (parent && popup, "positionPopup: null widget"); |
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:
129
diff
changeset
|
395 wdim w = popup.width, |
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:
129
diff
changeset
|
396 h = popup.height, |
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:
129
diff
changeset
|
397 x, y; |
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:
129
diff
changeset
|
398 if (flags & 1) { |
9cff74f68b84
Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
129
diff
changeset
|
399 y = parent.yPos; |
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:
129
diff
changeset
|
400 if (y+h > this.h) y += parent.height - h; |
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:
129
diff
changeset
|
401 x = parent.xPos + parent.width; |
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:
129
diff
changeset
|
402 if (x+w > this.w) x = parent.xPos - w; |
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:
129
diff
changeset
|
403 } else { |
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:
129
diff
changeset
|
404 x = parent.xPos; // align on left edge |
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:
129
diff
changeset
|
405 if (x+w > this.w) x += parent.width - w; // align on right edge |
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:
129
diff
changeset
|
406 y = parent.yPos + parent.height; // place below |
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:
129
diff
changeset
|
407 if (y+h > this.h) y = parent.yPos - h; // place above |
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:
129
diff
changeset
|
408 } |
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:
129
diff
changeset
|
409 popup.setPosition (x, y); |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
410 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
411 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
412 void requestRedraw () { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
413 imde.mainSchedule.request(imde.SCHEDULE.DRAW); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
414 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
415 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
416 void addClickCallback (bool delegate(wdabs, wdabs, ubyte, bool) dg) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
417 clickCallbacks[dg.ptr] = dg; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
418 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
419 void addMotionCallback (void delegate(wdabs, wdabs) dg) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
420 motionCallbacks[dg.ptr] = dg; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
421 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
422 void removeCallbacks (void* frame) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
423 clickCallbacks.removeKey(frame); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
424 motionCallbacks.removeKey(frame); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
425 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
426 //END IWidgetManager methods |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
427 |
129
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
428 debug void logWidgetSize (Content) { |
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:
129
diff
changeset
|
429 logger.trace ("size: {,4},{,4}; minimal: {,4},{,4} - WidgetManager", w,h, mw,mh); |
129
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
430 child.logWidgetSize; |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
431 } |
ad91de8867a0
Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
128
diff
changeset
|
432 |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
433 protected: |
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:
129
diff
changeset
|
434 void updateUnderMouse (wdabs cx, wdabs cy, bool closePopup) { |
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:
129
diff
changeset
|
435 auto oUM = underMouse; |
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:
129
diff
changeset
|
436 underMouse = getPopupWidget (cx, cy, closePopup); |
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:
129
diff
changeset
|
437 if (underMouse is null) { |
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:
129
diff
changeset
|
438 debug assert (child.onSelf (cx, cy), "WidgetManager: child doesn't cover whole area"); |
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:
129
diff
changeset
|
439 underMouse = child.getWidget (cx, cy); |
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:
129
diff
changeset
|
440 } |
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:
129
diff
changeset
|
441 if (underMouse !is oUM) { |
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:
129
diff
changeset
|
442 debug assert (oUM && underMouse, "no widget under mouse: error"); |
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:
129
diff
changeset
|
443 oUM.underMouse (false); |
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:
129
diff
changeset
|
444 underMouse.underMouse (true); |
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:
129
diff
changeset
|
445 } |
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:
129
diff
changeset
|
446 } |
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:
129
diff
changeset
|
447 |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
448 /** Second stage of loading the widgets. |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
449 * |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
450 * loadDesign handles the data; this method needs to: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
451 * --- |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
452 * // 1. Create the root widget: |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
453 * child = makeWidget ("root"); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
454 * child.setup (0, 3); |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
455 * // 2. Set the size: |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
456 * child.setWidth (child.minWidth, 1); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
457 * child.setHeight (child.minHeight, 1); |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
458 * // 3. Set the position (necessary part of initialization): |
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
459 * child.setPosition (0,0); |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
460 * --- |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
461 */ |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
462 void createRootWidget(); |
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
463 |
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
|
464 /** Called before saving (usually when the GUI is about to be destroyed, although not |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
465 * necessarily). */ |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
466 void preSave (); |
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
|
467 |
110
6acd96f8685f
Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
108
diff
changeset
|
468 public: |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
469 //BEGIN makeWidget metacode |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
470 private static { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
471 /// Widget types. Items match widget names without the "Widget" suffix. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
472 enum WIDGET_TYPE : int { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
473 FUNCTION = 0x2000, // Function called instead of widget created (no "Widget" appended to fct name) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
474 TAKES_CONTENT = 0x4000, // Flag indicates widget's this should be passed an IContent reference. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
475 SAFE_RECURSION = 0x8000, // Safe to instantiate recursively without infinite looping. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
476 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
477 // Use widget names rather than usual capitals convention |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
478 Unnamed = 0x0, // Only for use by widgets not created with createWidget |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
479 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
480 // blank: 0x1 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
481 FixedBlank = 0x1, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
482 SizableBlank = 0x2, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
483 Debug = 0xF, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
484 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
485 // popup widgets: 0x10 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
486 PopupMenu = TAKES_CONTENT | 0x11, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
487 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
488 // labels: 0x20 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
489 ContentLabel = TAKES_CONTENT | 0x20, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
490 TextLabel = 0x21, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
491 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
492 // content functions: 0x30 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
493 editContent = FUNCTION | TAKES_CONTENT | SAFE_RECURSION | 0x30, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
494 addContent = FUNCTION | 0x31, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
495 flatMenuContent = FUNCTION | TAKES_CONTENT | SAFE_RECURSION | 0x32, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
496 subMenuContent = FUNCTION | TAKES_CONTENT | 0x33, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
497 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
498 // content widgets: 0x40 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
499 DisplayContent = TAKES_CONTENT | 0x40, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
500 BoolContent = TAKES_CONTENT | 0x41, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
501 AStringContent = TAKES_CONTENT | 0x42, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
502 ButtonContent = TAKES_CONTENT | 0x43, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
503 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
504 GridLayout = TAKES_CONTENT | 0x100, |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
505 ContentList = TAKES_CONTENT | SAFE_RECURSION | 0x110, |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
506 |
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
|
507 FloatingArea = TAKES_CONTENT | 0x200, |
125
3e648bc53bde
Added a simple switch/tab widget (depends on existing EnumContent).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
508 Switch = TAKES_CONTENT | 0x210, |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
509 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
510 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
511 // Only used for binarySearch algorithm generation; must be ordered by numerical values. |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
512 const char[][] WIDGETS = [ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
513 "FixedBlank", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
514 "SizableBlank", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
515 "Debug", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
516 "TextLabel", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
517 "addContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
518 "PopupMenu", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
519 "ContentLabel", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
520 "DisplayContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
521 "BoolContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
522 "AStringContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
523 "ButtonContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
524 "GridLayout", |
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
|
525 "FloatingArea", |
125
3e648bc53bde
Added a simple switch/tab widget (depends on existing EnumContent).
Diggory Hardy <diggory.hardy@gmail.com>
parents:
123
diff
changeset
|
526 "Switch", |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
527 "subMenuContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
528 "ContentList", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
529 "editContent", |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
530 "flatMenuContent"]; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
531 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
532 /* Generates a binary search algorithm for makeWidget. */ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
533 char[] binarySearch (char[] var, char[][] consts) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
534 if (consts.length > 3) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
535 return `if (`~var~` <= WIDGET_TYPE.`~consts[$/2 - 1]~`) {` ~ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
536 binarySearch (var, consts[0 .. $/2]) ~ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
537 `} else {` ~ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
538 binarySearch (var, consts[$/2 .. $]) ~ |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
539 `}`; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
540 } else { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
541 char[] ret; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
542 foreach (c; consts) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
543 ret ~= `if (` ~ var ~ ` == WIDGET_TYPE.` ~ c ~ `) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
544 debug (mdeWidgets) logger.trace ("Creating new `~c~`."); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
545 if (!(WIDGET_TYPE.`~c~` & WIDGET_TYPE.SAFE_RECURSION)) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
546 parent.recursionCheck (id); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
547 static if (WIDGET_TYPE.`~c~` & WIDGET_TYPE.FUNCTION) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
548 return `~c~` (this, parent, id, data, content); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
549 else static if (WIDGET_TYPE.`~c~` & WIDGET_TYPE.TAKES_CONTENT) |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
550 return new `~c~`Widget (this, parent, id, data, content); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
551 else |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
552 return new `~c~`Widget (this, parent, id, data); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
553 } else `; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
554 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
555 ret = ret[0..$-6]; // remove last else |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
556 return ret; |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
557 } |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
558 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
559 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
560 debug { // check items in WIDGETS are listed in order |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
561 char[] WIDGETS_check () { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
562 char[] ret; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
563 for (int i = WIDGETS.length-2; i > 0; --i) { |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
564 ret ~= "WIDGET_TYPE."~WIDGETS[i] ~" >= WIDGET_TYPE."~ WIDGETS[i+1]; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
565 if (i>1) ret ~= " || "; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
566 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
567 return ret; |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
568 } |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
569 mixin ("static if ("~WIDGETS_check~") |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
570 static assert (false, \"WIDGETS is not in order!\");"); |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
571 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
572 } |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
573 //END makeWidget metacode |
108
c9fc2d303178
Added capability for border-less pop-up widgets. Simple pop-up menu.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
105
diff
changeset
|
574 |
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
|
575 protected: |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
576 // Dataset/design data: |
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
|
577 final char[] fileName; |
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
|
578 char[] defaultDesign; // The design specified in the file header. |
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
|
579 char[] rendName; // Name of renderer; for saving and creating renderers |
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
|
580 |
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
|
581 // Loaded data, indexed by design name. May not be loaded for all gui designs: |
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
|
582 scope WidgetDataSet[char[]] data; |
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
|
583 private bool allLoaded = false; // applies to data |
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
|
584 WidgetDataSet curData; // Current data |
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
|
585 WidgetDataChanges changes; // Changes for the current design. |
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
|
586 scope mt.DataSet changesDS; // changes and sections from user file (used for saving) |
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
|
587 bool loadUserFile = true; // still need to load user file for saving? |
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
|
588 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
589 IRenderer rend; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
590 |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
591 // Widgets: |
126
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
592 wdim w,h; // current widget size; should be at least (mw,mh) even if not displayable |
c9843fbaac88
Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
125
diff
changeset
|
593 wdim mw,mh; // minimal area required by widgets |
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
|
594 scope IChildWidget child; // The primary widget. |
111
1655693702fc
Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
110
diff
changeset
|
595 uint setupN; // n to pass to IChildWidget.setup |
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
|
596 |
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:
129
diff
changeset
|
597 bool mAIPPW; // IPPW variable |
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:
129
diff
changeset
|
598 IPopupParentWidget childIPPW; // child IPPW, if any active |
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:
129
diff
changeset
|
599 |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
600 // callbacks indexed by their frame pointers. Must support removal of elements in foreach: |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
601 SortedMap!(void*,bool delegate(wdabs cx, wdabs cy, ubyte b, bool state)) clickCallbacks; |
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
602 SortedMap!(void*,void delegate(wdabs cx, wdabs cy)) motionCallbacks; |
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:
129
diff
changeset
|
603 IChildWidget keyFocus; // widget receiving keyboard input |
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:
129
diff
changeset
|
604 IChildWidget underMouse; // widget under the mouse pointer |
121
5b37d0400732
Widgets now receive and store their parent (IParentWidget). Infinite widget recursion checks. WidgetManager code redistributed.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
117
diff
changeset
|
605 |
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
|
606 Mutex mutex; // lock on methods for use outside the package. |
80
ea58f277f487
Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
76
diff
changeset
|
607 } |