comparison mde/gui/widget/Floating.d @ 159:b06b04c75e86

Finished last commit, rearranged code for the WidgetManager class. There is now a GUI options section. Created a third WidgetManager class called WidgetLoader to handle file loading/saving. Moved most of the code in WMScreen's draw/clickEvent/motionEvent functions to WidgetManager.
author Diggory Hardy <diggory.hardy@gmail.com>
date Thu, 21 May 2009 20:55:10 +0200
parents f132e599043f
children ccd01fde535e
comparison
equal deleted inserted replaced
158:f132e599043f 159:b06b04c75e86
17 module mde.gui.widget.Floating; 17 module mde.gui.widget.Floating;
18 18
19 import mde.gui.widget.AParentWidget; 19 import mde.gui.widget.AParentWidget;
20 import mde.gui.exception; 20 import mde.gui.exception;
21 import mde.content.IContent; 21 import mde.content.IContent;
22 import mde.content.AStringContent;
22 23
23 import tango.util.log.Log : Log, Logger; 24 import tango.util.log.Log : Log, Logger;
24 25
25 private Logger logger; 26 private Logger logger;
26 static this () { 27 static this () {
37 * Ints consist of widget type followed by a border type (flags from IRenderer.Border.BTYPE) for 38 * Ints consist of widget type followed by a border type (flags from IRenderer.Border.BTYPE) for
38 * each sub-widget. */ 39 * each sub-widget. */
39 class FloatingAreaWidget : AParentWidget 40 class FloatingAreaWidget : AParentWidget
40 { 41 {
41 static this () { 42 static this () {
42 raiseOnHover = ; 43 raiseOnHover = new BoolContent ("GUI.raiseOnHover");
43 } 44 }
44 45
45 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content) { 46 this (IWidgetManager mgr, IParentWidget parent, widgetID id, WidgetData data, IContent content) {
46 if (data.ints.length != 1 + data.strings.length) 47 if (data.ints.length != 1 + data.strings.length)
47 throw new WidgetDataException (this); 48 throw new WidgetDataException (this);
171 172
172 override IChildWidget getWidget (wdim cx, wdim cy) { 173 override IChildWidget getWidget (wdim cx, wdim cy) {
173 debug scope (failure) 174 debug scope (failure)
174 logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h); 175 logger.warn ("getWidget: failure; values: click; pos; width: {},{}; {},{}; {},{}", cx, cy, x, y, w, h);
175 176
176 size_t event = getFloatingWidget (cx,cy, raiseOnHover); 177 size_t event = getFloatingWidget (cx,cy, raiseOnHover());
177 if (event > sWData.length) 178 if (event > sWData.length)
178 return this; // no match 179 return this; // no match
179 180
180 with (sWData[event]) { 181 with (sWData[event]) {
181 wdim lx = cx - (this.x + x); 182 wdim lx = cx - (this.x + x);