annotate mde/gui/widget/Ifaces.d @ 179:1f9d00f392bd default tip

Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now. Optimised when ServiceContentList.opCall is called, I think without breaking anything.
author Diggory Hardy <diggory.hardy@gmail.com>
date Tue, 15 Sep 2009 20:09:59 +0200
parents af40e9679436
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify it under the terms
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 of the GNU General Public License as published by the Free Software Foundation, either
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 version 2 of the License, or (at your option) any later version.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 See the GNU General Public License for more details.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
16 /******************************************************************************
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: 72
diff changeset
17 * Widget interfaces.
130
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
18 *
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
19 * This module contains the primary documentation for the declared 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: 130
diff changeset
20 * also the Widget module has some brief comments and basic implementations.
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: 72
diff changeset
21 *
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
22 * Widgets are connected as the nodes of a tree. Widgets know their parent as a
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
23 * IParentWidget class and their children as IChildWidget classes. The gui
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
24 * manager is a special widget only implementing IParentWidget; all other
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
25 * widgets must implement IChildWidget and optionally IParentWidget.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
26 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
27 * It's recommended that widgets inherit one of the A*Widget classes rather
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
28 * than impement I*Widget directly.
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
29 *
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
30 * Protection: please keep it as tight as possible. List it explicitly for
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
31 * every function in this module; then the compiler checks overridden functions
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
32 * have the correct protection attribute.
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
33 * BUG: currently it's a bit of a mess, because of a compiler bug.
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
34 *****************************************************************************/
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35 module mde.gui.widget.Ifaces;
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
37 public import mde.gui.types;
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
38 public import mde.gui.renderer.IRenderer;
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
39 public import mde.content.IContent;
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: 72
diff changeset
40
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: 72
diff changeset
41
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
42 /******************************************************************************
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
43 * The root widget interface, for methods required by both IParentWidget and
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
44 * IChildWidget.
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
45 *****************************************************************************/
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
46 interface IWidget
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
47 {
171
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
48 /** When this is called, if the widget has any changed data to save it
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
49 * should do so (see widgetData/dimData) and return true. Otherwise it
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
50 * should return false.
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
51 *
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
52 * If the widget has subwidgets, it should also be recursively called on
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
53 * these, returning true if any data was saved.
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
54 *
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
55 * Actually the return value is ignored; I think widgets still return it
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
56 * correctly though. */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
57 public bool saveChanges ();
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
58
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
59 /** Draw, using the stored values of x and y.
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
60 *
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
61 * Maybe later enforce clipping of all sub-widget drawing, particularly for cases where only
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
62 * part of the widget is visible: scroll bars or a hidden window. */
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
63 public void draw ();
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
64
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
65 /** Called on a widget when something is dragged onto it.
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
66 *
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
67 * Generally, content editing widgets should implement this as:
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
68 * ---
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
69 public override bool dropContent (IContent content) {
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
70 if (content_.setContent (content))
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
71 return true;
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
72 return parent.dropContent (content);
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
73 }
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
74 * ---
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
75 * And other widgets should just:
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
76 * ---
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
77 * return parent.dropContent (content);
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
78 * ---
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
79 *
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
80 * Returns: true if the content was received (false if it reaches the
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
81 * WidgetManager and is still not used). */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
82 public bool dropContent (IContent content);
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
83 }
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
84
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
85 /******************************************************************************
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
86 * Interface for parent widgets, including IWidgetManager.
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
87 *
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
88 * All widgets implement this via AWidget to make things simpler (code sharing).
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
89 *
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
90 * Notation:
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
91 * Positive/negative direction: along the x/y axis in this direction.
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
92 * Layout widget: a widget containing multiple sub-widges (which hence
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
93 * controls how they are laid out).
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
94 *****************************************************************************/
162
2476790223b8 First drag and drop support: can drag from AStringContentWidget to any content editable. No visual feedback while dragging.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 160
diff changeset
95 interface IParentWidget : IWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
96 {
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
97 /** Checks for recursion of unsafe widgets to prevent infinite recursion.
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
98 *
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
99 * Only called by makeWidget() when creating child widgets and recursively
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
100 * from the same method in a child widget. */
133
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
101 void recursionCheck (widgetID, IContent);
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
102
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
103 /** IPPWs return self, other widgets recurse call on parent. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
104 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: 130
diff changeset
105
139
29a524e7c858 Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
106 /** Child widgets should call this on their parent if their minimal size
29a524e7c858 Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
107 * changes, since they cannot properly resize themselves.
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
108 *
179
1f9d00f392bd Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 177
diff changeset
109 * Parents $(I must) increase their child's size if the child is too small,
1f9d00f392bd Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 177
diff changeset
110 * and if the child is not resizable, shrink if too big (except for reasons
1f9d00f392bd Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 177
diff changeset
111 * like alignment within a grid).
1f9d00f392bd Fixed a bug where (non-resizible) widgets wouldn't get shrunk when minimal size decreases, meaning optional context menus are hiden properly now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 177
diff changeset
112 *
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
113 * Parents $(I must not) change their own size, even if they are not
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
114 * sizable; they may only change their childrens' sizes if it does not
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
115 * affect their own (i.e. WidgetManager and floating / popup widgets).
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
116 *
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
117 * (Hence most parents need to call this function on their parents to change
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
118 * size. In this case they also must propegate setWidth/setHeight calls on
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
119 * the child originally calling min[WH]Change.)
140
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
120 *
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
121 * Child widgets may depend on setPosition being called afterwards.
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
122 *
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
123 * Params:
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
124 * widget = The child widget calling the function
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
125 * mw = New minimal width
d3b2cefd46c9 minSizeChange() allows run-time changes to widgets' minimal size (except for shrinking in a GridLayoutWidget).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 121
diff changeset
126 * mh = New minimal height */
126
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 125
diff changeset
127 void minWChange (IChildWidget widget, wdim mw);
c9843fbaac88 Dynamic minimal size changing improved; works over layouts sharing alignment.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 125
diff changeset
128 void minHChange (IChildWidget widget, wdim mh); /// ditto
130
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
129
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
130 /** Governor of parent widget resizability, where this is determined by sub-widgets
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
131 * (e.g. this doesn't apply to FloatingAreaWidget).
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
132 *
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
133 * NEVER and ALWAYS often don't result in usable GUIs, and aren't expected to be used except
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
134 * for debugging.
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
135 *
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
136 * Note: ANY_SUBWIDGETS can cause problems like enlarging a menu bar containing a resizable
130
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
137 * blank instead of the main part of a window. */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
138 protected enum SIZABILITY_ENUM {
130
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
139 NEVER = 0, /// Parents are never resizable
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
140 ALL_SUBWIDGETS = 3, /// Parents are only resizable if all sub-widgets are
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
141 ANY_SUBWIDGETS = 2, /// Parents are resizable if any sub-widgets are
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
142 ALWAYS = 1, /// Parents are always resizable
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
143 START_TRUE = 1, /// Flag set by ALWAYS and ALL_SUBWIDGETS
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
144 SUBWIDGETS = 2, /// Flag set by ALL_SUBWIDGETS and ANY_SUBWIDGETS
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
145 }
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
146 protected static const SIZABILITY = SIZABILITY_ENUM.ANY_SUBWIDGETS; /// ditto
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: 72
diff changeset
147 }
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: 72
diff changeset
148
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
149 /******************************************************************************
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
150 * Interface for parents of popups and the widget manager.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
151 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
152 * An IPopupParentWidget (IPPW) may have 0 or 1 child IPPWs; the child may have
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
153 * its own IPPW. Each IPPW when added to a parent IPPW is responsible for
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
154 * managing one popup.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
155 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
156 * So any child IPPW should also be a descendant widget, and is usually the or
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
157 * a descendant of the popup.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
158 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
159 * An IPPW usually has one popup to manage (the popup being one of its child
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
160 * widgets), but the popup is only active if the IPPW is added as a child of
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
161 * its parent 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: 130
diff changeset
162 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
163 * The widget manager is an IPPW, but unlike most IPPWs its popup(s), if
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
164 * existing, probably have nothing to do with its child IPPWs.
166
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
165 *
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
166 * ----
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
167 * // No popups:
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
168 * WM
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
169 * // (IPPW) Widget X clicked on, which opens a menu:
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
170 * WM -> X (manages menu widget)
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
171 * ----
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
172 *****************************************************************************/
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
173 interface IPopupParentWidget : IParentWidget
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
174 {
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
175 /// menuActive's type
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
176 enum MenuPosition {
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
177 INACTIVE = 0,
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
178 ACTIVE = 1,
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
179 LEFT = 3,
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
180 RIGHT = 5
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
181 }
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
182
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
183 /** Add caller ippw as current child IPopupParentWidget of called 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: 130
diff changeset
184 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
185 * ippw is added as called IPPW's child IPPW, and its functions are
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
186 * called to draw popup and pass events. The called IPPW's previous child
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
187 * IPPW is replaced.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
188 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
189 * ippw is then responsible for managing a popup. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
190 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: 130
diff changeset
191 /** Remove ippw from being the called IPPW's child IPPW and disable
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
192 * 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: 130
diff changeset
193 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
194 * Do nothing if ippw is not the called IPPW's child 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: 130
diff changeset
195 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
196 * Returns: true if ippw was the child 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: 130
diff changeset
197 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
198 * I.e. this deactivates ippw's popup. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
199 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: 130
diff changeset
200
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
201 /** Notify the called IPPW that it has been removed. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
202 void 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: 130
diff changeset
203
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
204 /** Set/get menuActive state, which includes position information.
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
205 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
206 * This is set on the parent IPPW when a popup menu is opened and unset
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
207 * when the menu is closed.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
208 * If set on the parent IPPW, popup menus can be opened with just a mouse-
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
209 * over and buttons activated with an up-click.
171
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
210 * So given IPPWs U-Z (indentation shows ancestry):
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
211 *
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
212 * ---
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
213 * X (window manager): menuActive false
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
214 * Y (popup window): menuActive true
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
215 * U (menu button): menuActive true, open popup menu
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
216 * V (menu button): menuActive false, menu closed but opens on hover
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
217 * Z (menu button): menuActive false, menu closed
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
218 * ---
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
219 *
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
220 * It is also used by positionPopup to signal if the popup was left or
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
221 * right of the previous popup, to enable a further popup to be placed by
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
222 * positionPopup without overlapping previous popups. */
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
223 void menuActive (MenuPosition);
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
224 MenuPosition menuActive ();
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
225 /** Returns the IPPW's parent's menuActive (WM returns false). If
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
226 * (menuActive & MenuPosition.ACTIVE) popup widgets may assume they are
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
227 * sub-menu popups not top-level menu popups. */
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
228 MenuPosition parentMenuActive ();
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
229
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
230 /** Called by descendant widgets such as buttons when an action occurred,
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
231 * which should close a menu. (But also called when not in a menu.) */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
232 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: 130
diff changeset
233
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
234 /** Get the widget under 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: 130
diff changeset
235 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
236 * The IPPW should first recurse the call to its child IPPW if it exists.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
237 * If this doesn't yield a widget, it should try getting one from its popup
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
238 * and then itself. It should return the first widget found or 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: 130
diff changeset
239 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
240 * If closePopup is true and a widget isn't returned from the 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: 130
diff changeset
241 * the childIPPW should be removed (to close popups when a click is not on
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
242 * the popup or its parent) and menuActive set to INACTIVE. */
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
243 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: 130
diff changeset
244
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
245 /** Draw.
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
246 *
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
247 * The IPPW should first draw its popup, then call on its child IPPW if
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
248 * that exists. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
249 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: 130
diff changeset
250
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
251 /// Returns true if ippw is child 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: 130
diff changeset
252 debug 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: 130
diff changeset
253 }
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: 72
diff changeset
254
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
255 /******************************************************************************
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: 72
diff changeset
256 * Interface for the widget manager.
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: 72
diff changeset
257 *
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: 72
diff changeset
258 * This class handles widget rendering, input, loading and saving.
171
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
259 *
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
260 * The widget manager is also a popup-parent for it's main child widget
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
261 * (childRoot), working as a normal popup-parent except that parentMenuActive
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
262 * is always false. It also has two special popup children: childContext and
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
263 * childDragged, which are handled indirectly via PopupHandlerWidget so that
7f7b2011b759 Partially complete commit: code runs but context menus don't work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 166
diff changeset
264 * their menuActive state doesn't affect childRoot or decendants.
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
265 *****************************************************************************/
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
266 interface IWidgetManager : IPopupParentWidget
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: 72
diff changeset
267 {
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: 72
diff changeset
268 // Loading/saving:
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
269 /** Create a widget by looking up the data for id then looking up data.ints[0] in WIDGET_TYPES.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
270 *
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
271 * Params:
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
272 * id = Identifier, within data files, of the data for the widget.
103
42e241e7be3e ContentList content type; getting content items/lists from Options generically via content.Items, and a new addContent widget function. Several improvements to generic handling of content. New button-with-text widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 99
diff changeset
273 * data = Pass this data to the widget, not data looked up via id.
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
274 * content = An IContent may be passed to some widgets on creation.
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
275 *
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
276 * When used in a this(), super() should be called before any calls to makeWidget (or at least
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
277 * parent and id set) due to recursionCheck being called on the 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
278 *
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: 72
diff changeset
279 * Creates a widget, using the widget data with index id. Widget data is loaded from files,
116
5ee69b3ed9c9 Partial implementation of infinite widget recursion protection; some cleanup.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 115
diff changeset
280 * and per design (multiple gui layouts, called designs, may exist; data is per design). */
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
281 IChildWidget makeWidget (IParentWidget parent, widgetID id, IContent content = null);
93
08a4ae11454b Widgets now save dimensions without preventing structural changes in the base config file from applying.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 92
diff changeset
282
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
283 /** Get or set widget id's WidgetData or dimension 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
284 *
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
285 * WidgetData is for most data, dimensional data (wdims) is for dimensions.
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
286 *
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
287 * Data should only be set from IChildWidget.saveChanges() to
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
288 * avoid setting multiple times when a widget id has several instances. */
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
289 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
290 void widgetData (widgetID id, WidgetData data); /// ditto
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
291 wdims dimData (widgetID id); /// ditto
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 void dimData (widgetID id, wdims d); /// ditto
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
293
152
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
294 /** Position popup adjacent to parent.
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
295 *
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
296 * If position is 0, place popup below parent, or above if there isn't
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
297 * space below, and expand popup's width to at least that of parent.
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
298 *
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
299 * If (position & MenuPosition.ACTIVE), place popup to the side of parent,
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
300 * using the side indicated by LEFT or RIGHT, if any.
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
301 *
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
302 * Returns:
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
303 * MenuPosition.ACTIVE if popup placed above or below, and LEFT or RIGHT
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
304 * if placed left or right of parent. */
c67d074a7111 Menu placement now takes into account left/right placement of parent menus.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 146
diff changeset
305 MenuPosition positionPopup (IChildWidget parent, IChildWidget popup, MenuPosition position = MenuPosition.INACTIVE);
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
306
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: 72
diff changeset
307 // Rendering:
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: 72
diff changeset
308 /** For when a widget needs redrawing.
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: 72
diff changeset
309 *
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: 72
diff changeset
310 * Must be called because rendering may only be done on events.
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: 72
diff changeset
311 *
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: 72
diff changeset
312 * Currently it just causes everything to be redrawn next frame. */
41
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
313 void requestRedraw ();
b3a6ca4516b4 The renderer now controls which parts of the window border allow resizing.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 40
diff changeset
314
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
315 /** Get the window's renderer.
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
316 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
317 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
318 * provides the possibility of per-window renderers (if desired). */
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
319 IRenderer renderer ();
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
320 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
321
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: 72
diff changeset
322
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
323 /******************************************************************************
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: 72
diff changeset
324 * Interface for (child) widgets, i.e. all widgets other than the manager.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
325 *
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
326 * A widget is a region of a GUI window which handles rendering and user-
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
327 * interaction for itself and is able to communicate with its manager and other
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
328 * widgets as necessary.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
329 *
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
330 * If a widget is to be creatable by IWidgetManager.makeWidget, it must be
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
331 * listed in the AWidgetManager WIDGET_TYPE enum and WIDGETS list, and have a
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
332 * constructor of the following form.
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: 72
diff changeset
333 * It should use Ddoc to explain what initialization data is used.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
334 * ----------------------------------
65
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
335 * /++ Constructor for a ... widget.
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
336 * +
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
337 * + Widget uses the initialisation data:
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
338 * + [widgetID, x, y]
891211f034f2 Changes to widgets: widgets may now get strings as creation data. Strings for TextWidgets can be set in files (in a temporary mannor).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 58
diff changeset
339 * + where x is ... and y is ... +/
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
340 * this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data);
90
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
341 *
b525ff28774b Widgets generated dynamically from a list can now be standard widgets selected from data files.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 85
diff changeset
342 * /// The CTOR may take an IContent reference:
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
343 * this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
344 * ----------------------------------
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
345 * Where mgr is the widget manager, parent is the widget's _parent (another
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
346 * child widget or the widget manager), id is the _id passed to makeWidget()
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
347 * and data is initialisation _data. The method should throw a
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
348 * WidgetDataException if the data is invalid, and throw other GuiExceptions on
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
349 * other errors.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
350 *
146
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
351 * All widgets should set their own size in this() or setup() (must be setup()
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
352 * if it could change), although some parents may set child-widgets' size
783969f4665c Simple, inefficient context menus (displaying content description).
Diggory Hardy <diggory.hardy@gmail.com>
parents: 144
diff changeset
353 * during their creation.
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
354 *****************************************************************************/
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
355 //NOTE: add another this() without the data for default initialization, for the GUI editor?
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
356 interface IChildWidget : IWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
357 {
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
358 //BEGIN Load and save
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
359 /** 2nd stage of initialization for widgets; also called on some changes.
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
360 *
144
66c58e5b0062 Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 140
diff changeset
361 * Widgets should call recursively on their children, redo anything
66c58e5b0062 Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 140
diff changeset
362 * indicated by flags, and adjust their size and other cached data
66c58e5b0062 Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 140
diff changeset
363 * dependant on any thing which may have changed.
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
364 * Widgets may rely on setPosition being called afterwards.
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
365 *
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
366 * Params:
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
367 * n = Indicates this is the (n+1)-th time the function has been called.
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
368 * flags = if (flags & 1) the renderer has been changed,
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
369 * if (flags & 2) translation strings are being reloaded.
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
370 * These flags are always true on first run.
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
371 *
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
372 * Returns:
144
66c58e5b0062 Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 140
diff changeset
373 * The method must return true on initial setup and if its dimensions
66c58e5b0062 Added a BoolContent-based collapsible widget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 140
diff changeset
374 * (may) have changed. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
375 bool setup (uint n, uint flags);
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
376
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: 72
diff changeset
377 /+ Use when widget editing is available? Requires widgets to know their parents.
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: 72
diff changeset
378 /** Called when a child widget's size has changed.
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: 72
diff changeset
379 *
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: 72
diff changeset
380 * Should be propegated up to parents. */
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: 72
diff changeset
381 void childChanged ();
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: 72
diff changeset
382 +/
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
383 //END Load and save
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
384
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
385 //BEGIN Size and position
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
386 /** Is the width / height resizable?
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
387 *
130
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
388 * Normally, this means does the widget benifit from being enlarged? If not, the widget has
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
389 * "fixed" dimensions equal to it's minimal size; however it $(I may) still be enlarged.
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
390 *
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
391 * Parents normally take their resizability from sub-widgets; see SIZABILITY for how they do
c5c38eaadb64 Changed how sizability is set for parents: can require all sub-widgets resizable or only one to set parent resizable.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 129
diff changeset
392 * this. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
393 bool isWSizable ();
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
394 bool isHSizable (); /// ditto
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
395
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
396 /** The minimal size the widget could be shrunk to (or its fixed size).
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
397 *
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
398 * Takes into account child-widgets and any other contents. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
399 wdim minWidth ();
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
400 wdim minHeight(); /// ditto
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
401
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
402 /** Get the current size of the widget. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
403 wdim width ();
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
404 wdim height(); /// ditto
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
405
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
406 /** (Smallest) coordinates of widget. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
407 wdabs xPos ();
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
408 wdabs yPos (); /// ditto
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
409
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
410 /** Used to adjust the size.
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
411 *
46
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
412 * Params:
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
413 * nw/nh = The new width/height
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
414 * dir = Direction to resize from. This is only really applicable to layout widgets.
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
415 * It must be either -1 (start resizing from highest row/col index, decreasing the
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
416 * index as necessary), or +1 (resize from the lowest index, i.e. 0).
03fa79a48c48 Fixed resizing bugs in previous commit and made code cleaner and more efficient.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 45
diff changeset
417 * Most widgets can simply ignore it.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
418 *
91
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
419 * A widget should never be resized smaller than it's minimal size (if it is, it should assume
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
420 * it's minimal size and print a warning when in debug mode).
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
421 * A "fixed" size widget should enlarge itself as requested.
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
422 *
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: 72
diff changeset
423 * setPosition must be called after calling either setWidth or setHeight. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
424 void setWidth (wdim nw, int dir);
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
425 void setHeight (wdim nh, int dir); /// ditto
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
426
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
427 /** Set the current position (called after setup and to move widget). */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
428 void setPosition (wdim x, wdim y);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
429 //END Size and position
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
430
172
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
431 //BEGIN Content
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
432 /** Return the widget's content, or null. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
433 IContent content ();
172
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
434
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
435 /** Set the widget's content, if the widget takes content and changing it
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
436 * at this stage is feasible. (Also pass to sub-widgets, where the
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
437 * constructor normally does so.) */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
438 void setContent (IContent);
172
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
439 //END Content
0dd49f333189 Implemented "void setContent (IContent)".
Diggory Hardy <diggory.hardy@gmail.com>
parents: 171
diff changeset
440
177
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
441 //BEGIN Subwidgets
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
442 /** Recursively scan the widget tree to find the widget under (cx,cy).
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
443 *
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
444 * If called on a widget, that widget should assume the location is over itself, and so should
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
445 * either return itself or the result of calling getWidget on the appropriate child widget.
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
446 *
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
447 * In the case of Window this may not be the case; it should check and return null if not under
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
448 * (cx,cy).
34
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
449 *
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
450 * Note: use global coordinates (cx,cy) not coordinates relative to the widget. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
451 IChildWidget getWidget (wdabs cx, wdabs cy);
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
452
177
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
453 /** Return true if widget is
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
454 * this widget, a child of this widget or another descendant. */
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
455 bool isDescendant (IChildWidget widget);
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
456 //END Subwidgets
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
457
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
458 //BEGIN Events
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
459 /** Return true if (cx,cy) is on self's box (doesn't matter if actually on a subwidget). */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
460 bool onSelf (wdabs cx, wdabs cy);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
461
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: 96
diff changeset
462 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down)
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
463 * which is a down-click if state is true.
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
464 *
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
465 * Widget may assume coordinates are on the widget (caller must check).
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
466 *
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
467 * The return value has the following flags:
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
468 * $(TABLE
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
469 * $(TR $(TD 1) $(TD Request keyboard input))
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
470 * $(TR $(TD 2) $(TD Request the functions dragMotion and dragRelease are called))
166
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
471 * $(TR $(TD 4) $(TD Display the widget's content while dragging (requires 2)))
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
472 * ) */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
473 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state);
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: 96
diff changeset
474
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
475 /** Called when dragging motion occurs, originating from this widget.
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
476 *
166
55667d048c31 Made content displayable while being dragged.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 162
diff changeset
477 * Params: target = The widget under the mouse
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
478 *
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
479 * Only called if requested by clickEvent. */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
480 void dragMotion (wdabs cx, wdabs cy, IChildWidget target);
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
481
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
482 /** Called at the end of a drag which originated from this widget.
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
483 *
177
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
484 * Params:
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
485 * cx = X coord of click
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
486 * cy = Y coord of click
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
487 * b = Mouse button pressed
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
488 * target = The widget under the mouse when the click was released
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
489 *
177
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
490 * Returns: (true if the up-click event should not be passed to
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
491 * clickEvent on the relevent widget). Irrelevant now.
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
492 *
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
493 * Only called if requested by clickEvent. */
177
af40e9679436 Release-clicks don't cause problems now.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 175
diff changeset
494 bool dragRelease (wdabs cx, wdabs cy, ubyte b, IChildWidget target);
160
ccd01fde535e Replaced WidgetManager's click and motion callbacks with a drag event system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 152
diff changeset
495
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: 96
diff changeset
496 /** Receives keyboard events when requested.
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
497 *
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: 96
diff changeset
498 * Params:
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
499 * sym SDLKey key sym, useful for keys with no character code such as arrow keys
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
500 * letter The character input, in UTF-8 */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
501 public void keyEvent (ushort sym, char[] letter);
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: 96
diff changeset
502
5de5810e3516 Implemented an editable TextContent widget; it's now possible to edit text options using the GUI.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 96
diff changeset
503 /** Called when keyboard input focus is lost. */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
504 public void keyFocusLost ();
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
505
131
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
506 /** Called on all widgets when the mouse moves over it (state == true) and
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
507 * when it leaves (state == false). */
175
1cbde9807293 Compile/link-time fixes for ldc & non-debug builds.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 174
diff changeset
508 void underMouse (bool state);
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
509
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
510 /** When a pop-up is closed the manager calls requestRedraw and this function on its parent. */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
511 protected void popupClose ();
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
512 /** When a click is on the parent of a popup, this function is called instead of the usual
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
513 * clickEvent.
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
514 *
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
515 * Returns:
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
516 * true to close the popup.
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
517 *
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
518 * Note: this means the parent can't receive text input without code changes. */
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
519 protected bool popupParentClick ();
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
520
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
521 //END Events
37
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
522
129
ad91de8867a0 Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
523 /// Logs the current and minimal size of every widget.
174
3d58adc17d20 Temporary commit to allow backup
Diggory Hardy <diggory.hardy@gmail.com>
parents: 172
diff changeset
524 debug public void logWidgetSize ();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
525 }