annotate mde/gui/widget/Ifaces.d @ 140:c94ec5594449

Fixed a bug with changing the minimal size and optimised it slightly.
author Diggory Hardy <diggory.hardy@gmail.com>
date Sun, 08 Feb 2009 15:20:11 +0000
parents 29a524e7c858
children 66c58e5b0062
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.
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
29 *****************************************************************************/
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 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
31
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
32 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
33 public import mde.gui.renderer.IRenderer;
137
9f035cd139c6 BIG commit. Major change: old Options class is gone, all content values are loaded and saved automatically. All options updated to reflect this, some changed.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 133
diff changeset
34 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
35
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
36
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
37 /******************************************************************************
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
38 * 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
39 *
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
40 * 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
41 *
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
42 * 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
43 * 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
44 * 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
45 * 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
46 *****************************************************************************/
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
47 interface IParentWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
48 {
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
49 /** Checks for recursion of unsafe widgets to prevent infinite recursion. */
133
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
50 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
51
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
52 /** 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
53 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
54
139
29a524e7c858 Fixed a resizing issue and added a popup menu for all content.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 137
diff changeset
55 /** 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
56 * 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
57 *
140
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
58 * Parents $(I must) increase their child's size if the child is too small.
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
59 * Parents $(I must not) decrease their own size, even if they are not
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
60 * sizable; they may only decrease their childrens' sizes if it does not
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
61 * affect their own (i.e. WidgetManager and FloatingAreaWidget).
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
62 *
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
63 * 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
64 *
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
65 * 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
66 * 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
67 * 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
68 * 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
69 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
70 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
71
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
72 /** 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
73 * (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
74 *
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
75 * 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
76 * 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
77 *
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
78 * 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
79 * blank instead of the main part of a window. */
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
80 enum SIZABILITY_ENUM {
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
81 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
82 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
83 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
84 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
85 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
86 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
87 }
140
c94ec5594449 Fixed a bug with changing the minimal size and optimised it slightly.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 139
diff changeset
88 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
89 }
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
90
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
91 /******************************************************************************
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 * 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
93 *
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 * 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
95 * 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
96 * 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
97 *
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
98 * 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
99 * 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
100 *
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
101 * 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
102 * 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
103 * 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
104 *
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 * 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
106 * existing, probably have nothing to do with its child IPPWs.
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
107 *****************************************************************************/
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
108 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
109 {
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
110 /** 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
111 *
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
112 * 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
113 * 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
114 * 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
115 *
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
116 * 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
117 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
118 /** 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
119 * 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
120 *
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
121 * 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
122 *
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
123 * 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
124 *
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
125 * 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
126 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
127
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
128 /** 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
129 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
130
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
131 /** Set/get menuActive state.
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
132 *
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
133 * 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
134 * 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
135 * If set on the parent IPPW, popup menus can be opened with just a mouse-
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 * over and buttons activated with an up-click. */
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
137 void menuActive (bool);
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
138 bool menuActive ();
133
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
139 /** Returns the IPPW's parent's menuActive (WM returns false). If true,
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
140 * popup widgets may assume they are sub-menu popups not top-level menu
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
141 * popups. */
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 131
diff changeset
142 bool 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
143
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
144 /** 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
145 * 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
146 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
147
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
148 /** 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
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 * 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
151 * 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
152 * 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
153 *
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 * 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
155 * the childIPPW should be removed (to close popups when a click is not on
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 * the popup or its parent) and menuActive set false. */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
157 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
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 /** 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
160 *
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 * 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
162 * 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
163 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
164
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
165 /// 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
166 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
167 }
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
168
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
169 /******************************************************************************
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
170 * 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
171 *
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
172 * This class handles widget rendering, input, loading and saving.
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
173 *****************************************************************************/
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 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
175 {
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
176 // 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
177 /** 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
178 *
80
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
179 * Params:
ea58f277f487 Gui reorganization and changes; partial implementation of floating widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 78
diff changeset
180 * 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
181 * 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
182 * 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
183 *
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
184 * 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
185 * 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
186 *
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
187 * 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
188 * 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
189 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
190
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
191 /** 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
192 *
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
193 * 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
194 *
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
195 * 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
196 * 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
197 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
198 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
199 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
200 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
201
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
202 /** Position popup left or right of parent, or left or right of 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
203 * (flags & 1 == 1). */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
204 void positionPopup (IChildWidget parent, IChildWidget popup, int flags = 0);
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
205
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
206 // 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
207 /** 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
208 *
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
209 * 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
210 *
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
211 * 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
212 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
213
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
214 /** 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
215 *
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
216 * 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
217 * 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
218 IRenderer renderer ();
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
219
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
220 // User input:
76
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
221 /** Add a mouse click callback.
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
222 *
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
223 * This is a delegate this will be called for all mouse click events recieved by the gui, not
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
224 * simply all click events on the widget (as clickEvent recieves).
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
225 *
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
226 * The delegate should return true if it accepts the event and no further processing is
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
227 * required (i.e. the event should not be handled by anything else), false otherwise. */
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
228 void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg);
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
229
76
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
230 /** Add a mouse motion callback: delegate will be called for all motion events recieved by the
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
231 * gui. */
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
232 void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg);
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
233
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
234 /** Remove all event callbacks on this widget (according to the delegate's .ptr). */
76
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
235 // Note: don't try to pass a reference and cast to void* in the function; it's a different address.
65780e0e48e6 Re-enabled click event passing in the gui to make ButtonWidget work.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 75
diff changeset
236 void removeCallbacks (void* frame);
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
237 }
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
238
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
239
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
240 /******************************************************************************
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
241 * 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
242 *
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
243 * A widget is a region of a GUI window which handles rendering and user-interaction for itself
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
244 * and is able to communicate with its manager and child widgets as necessary. (Passing widgets
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
245 * a reference to their parent has not been found useful.)
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
246 *
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
247 * If a widget is to be creatable by IWidgetManager.makeWidget, it must be listed in the
85
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
248 * createWidget module, and have a constructor of the following form. It should also update it's
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
249 * creation data if necessary, either when changed or when saveChanges() is called, using
56c0ddd90193 Intermediate commit (not stable). Changes to init system.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 80
diff changeset
250 * IWidgetManager.setData().
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
251 * 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
252 * ----------------------------------
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
253 * /++ 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
254 * +
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
255 * + 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
256 * + [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
257 * + where x is ... and y is ... +/
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
258 * this (IWidgetManager mgr, 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
259 *
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
260 * /// The CTOR may take an IContent reference:
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
261 * this (IWidgetManager mgr, widgetID id, WidgetData data, IContent content);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
262 * ----------------------------------
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
263 * Where mgr is the widget manager, id is the _id passed to makeWidget() and data is
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
264 * initialisation data. The method should throw a WidgetDataException (created without
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
265 * parameters) if the data has wrong length or is otherwise invalid.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
266 *
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
267 * All widgets should set their own size in this() or setup() (must be setup() if it could change),
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
268 * although some parents may set child-widgets' size 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
269 *****************************************************************************/
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
270 //NOTE: add another this() without the data for default initialization, for the GUI editor?
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
271 interface IChildWidget
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
272 {
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
273 //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
274 /** 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
275 *
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
276 * Widgets should call recursively on their children, redo anything indicated by flags, and
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
277 * adjust their size and other cached data dependant on any thing which may have 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
278 * 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
279 *
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
280 * 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
281 * 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
282 * 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
283 * 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
284 * 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
285 *
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
286 * Returns:
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
287 * The method should return true if the dimensions (may) have been changed. This may not be
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
288 * the case on the first run (when n == 0)!.
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
289 */
1655693702fc Resolved ticket #4, allowing widgets to reload strings and recalculate sizes mid-run.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 110
diff changeset
290 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
291
78
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
292 /** When this is called, if the widget has any changed data to save it should call
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
293 * IWidgetManager.setData (id, data) to set it and return true. Otherwise it should return
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
294 * false.
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
295 *
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
296 * If the widget has subwidgets, it should also be recursively called on these (passing their
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
297 * ids). */
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
298 bool saveChanges ();
78
79a1809421aa Widget data saving reimplemented for the new data system. (Now grid layout widgets remember their row & column sizes.)
Diggory Hardy <diggory.hardy@gmail.com>
parents: 77
diff changeset
299
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
300 /+ 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
301 /** 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
302 *
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
303 * 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
304 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
305 +/
110
6acd96f8685f Translation reloading as far as AContent name/desc supported. Limited & crude support for updating gui.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 108
diff changeset
306
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
307 //END Load and save
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
308
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
309 //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
310 /** 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
311 *
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
312 * 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
313 * "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
314 *
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
315 * 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
316 * this. */
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
317 bool isWSizable ();
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
318 bool isHSizable (); /// ditto
052df9b2fe07 Allowed widget resizing, changed widget IDs and made Input catch any callback exceptions.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 36
diff changeset
319
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
320 /** 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
321 *
92
085f2ca31914 Shared alignments supported in more complex cases.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 91
diff changeset
322 * Takes into account child-widgets and any other contents. */
66
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
323 wdim minWidth ();
f54ae4fc2b2f Replaced IWidget.getMinimalSize(out w,out h) with minWidth() and minHeight().
Diggory Hardy <diggory.hardy@gmail.com>
parents: 65
diff changeset
324 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
325
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
326 /** Get the current size of the widget. */
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
327 wdim width ();
4d5d53e4f881 Shared alignment for dynamic content lists - finally implemented! Lots of smaller changes too.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 90
diff changeset
328 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
329
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
330 /** (Smallest) coordinates of widget. */
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
331 wdabs xPos ();
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
332 wdabs yPos (); /// ditto
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
333
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
334 /** 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
335 *
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
336 * 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
337 * 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
338 * 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
339 * 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
340 * 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
341 * Most widgets can simply ignore it.
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
342 *
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
343 * 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
344 * 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
345 * 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
346 *
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
347 * setPosition must be called after calling either setWidth or setHeight. */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
348 void setWidth (wdim nw, int dir);
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
349 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
350
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
351 /** Set the current position (called after setup and to move widget). */
58
d43523ed4b62 Included a wdim typedef for all variables to do with window position or size instead of just using int.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 48
diff changeset
352 void setPosition (wdim x, wdim y);
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
353 //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
354
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
355 //BEGIN Events
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
356 /** 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
357 *
6b4116e6355c Work on the Gui: some of the framework for drag & drop. Also made Window an IWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 32
diff changeset
358 * 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
359 * 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
360 *
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
361 * 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
362 * (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
363 *
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
364 * Note: use global coordinates (cx,cy) not coordinates relative to the widget. */
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
365 IChildWidget getWidget (wdabs cx, wdabs cy);
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
366
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
367 /** Return true if (cx,cy) is on self's box (doesn't matter if actually on a subwidget). */
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
368 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
369
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
370 /** 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
371 * 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
372 *
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
373 * 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
374 *
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
375 * The return value has the following flags: 1 to request keyboard input. */
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
376 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state);
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
377
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
378 /** 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
379 *
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
380 * 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
381 * 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
382 * letter The character input, in UTF-8 */
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
383 void keyEvent (ushort sym, char[] letter);
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
384
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
385 /** Called when keyboard input focus is lost. */
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
386 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
387
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
388 /** 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
389 * when it leaves (state == false). */
9cff74f68b84 Major revisions to popup handling. Buttons can close menus now, plus some smaller impovements. Removed Widget module.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 130
diff changeset
390 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
391
117
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
392 /** When a pop-up is closed the manager calls requestRedraw and this function on its parent. */
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
393 void popupClose ();
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
394 /** 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
395 * clickEvent.
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
396 *
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
397 * Returns:
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
398 * true to close the popup.
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
399 *
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
400 * Note: this means the parent can't receive text input without code changes. */
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
401 bool popupParentClick ();
aba2dd815a1f Some tweaks to popup events and widgets.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 116
diff changeset
402
39
5132301e9ed7 Implemented widget saving.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 37
diff changeset
403 //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
404
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
405 /** Draw, using the stored values of x and y.
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
406 *
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
407 * Maybe later enforce clipping of all sub-widget drawing, particularly for cases where only
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
408 * part of the widget is visible: scroll bars or a hidden window. */
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
409 void draw ();
129
ad91de8867a0 Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
410
ad91de8867a0 Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
411 /// Logs the current and minimal size of every widget.
ad91de8867a0 Added a widget size printing debug function. Fixed a bug in SwitchWidget.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 126
diff changeset
412 debug void logWidgetSize ();
32
316b0230a849 Lots more work on the GUI. Also renamed lots of files.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
413 }