annotate mde/menus.d @ 133:9fd705793568

Fixed menu popup bug, improved recursion detection. Menu popups can now determine whether or not they are sub-menus. Recursion detection can now also check content (if not the same, there's not a risk of infinite recursion).
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 23 Jan 2009 16:05:05 +0000
parents 264028f4115a
children 9f035cd139c6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
1 /* LICENSE BLOCK
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
2 Part of mde: a Modular D game-oriented Engine
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
3 Copyright © 2007-2008 Diggory Hardy
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
4
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
5 This program is free software: you can redistribute it and/or modify it under
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
6 the terms of the GNU General Public License as published by the Free Software
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
7 Foundation, either version 2 of the License, or (at your option) any later version.
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
8
264028f4115a Cleaned up mde.imde and a couple of widget functions.
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
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
11 PARTICULAR PURPOSE. See the GNU General Public License for more details.
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
12
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
13 You should have received a copy of the GNU General Public License
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
14 along with this program. If not, see <http://www.gnu.org/licenses/>. */
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
15
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
16 /******************************************************************************
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
17 * Import this module to add some standard menus to imde.menus.
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
18 *
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
19 * Note that the widget manager also adds menu items in debug mode.
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
20 *****************************************************************************/
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
21 module mde.menus;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
22
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
23 import mde.content.miscContent;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
24 import mde.imde;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
25 debug {
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
26 import tango.util.log.Log : Log, Logger;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
27 private Logger logger;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
28 static this () {
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
29 logger = Log.getLogger ("mde.menus");
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
30 }
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
31 }
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
32
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
33 static this () {
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
34 auto quit = new EventContent("quit");
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
35 quit.addCallback ((Content){
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
36 debug logger.trace ("Quit (from menu)");
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
37 run = false;
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
38 });
133
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
39 auto main = new ContentList ("main", [cast(Content)quit]);
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
40 debug {
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
41 main.append (new ContentList ("sm1", [cast(Content) new EventContent ("a"), new EventContent ("b")]));
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
42 main.append (new ContentList ("sm2", [cast(Content) new EventContent ("c"), new EventContent ("d")]));
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
43 }
9fd705793568 Fixed menu popup bug, improved recursion detection.
Diggory Hardy <diggory.hardy@gmail.com>
parents: 132
diff changeset
44 menus.append (main);
132
264028f4115a Cleaned up mde.imde and a couple of widget functions.
Diggory Hardy <diggory.hardy@gmail.com>
parents:
diff changeset
45 }