Mercurial > projects > mde
comparison mde/gui/widget/miscWidgets.d @ 116:5ee69b3ed9c9
Partial implementation of infinite widget recursion protection; some cleanup.
Implemented recursion protection which only allowed unsafe widgets to be instantiated once; realised this was far too restrictive (multiple sibling instances are needed) and a check against parent widgets would be needed. Could be implemented by passing widgets a reference to parents.
Removed ButtonWidget aka First interactible widget.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Sun, 21 Dec 2008 12:03:50 +0000 |
parents | b16a534f5302 |
children | 5b37d0400732 |
comparison
equal
deleted
inserted
replaced
115:1b1e2297e2fc | 116:5ee69b3ed9c9 |
---|---|
18 | 18 |
19 import mde.gui.widget.Widget; | 19 import mde.gui.widget.Widget; |
20 import mde.gui.exception; | 20 import mde.gui.exception; |
21 import mde.gui.renderer.IRenderer; | 21 import mde.gui.renderer.IRenderer; |
22 | 22 |
23 import tango.io.Stdout; | 23 import tango.util.log.Log : Log, Logger; |
24 | |
25 private Logger logger; | |
26 static this () { | |
27 logger = Log.getLogger ("mde.gui.widget.miscWidgets"); | |
28 } | |
24 | 29 |
25 | 30 |
26 /// A fixed-size blank widget. | 31 /// A fixed-size blank widget. |
27 class FixedBlankWidget : FixedWidget | 32 class FixedBlankWidget : FixedWidget |
28 { | 33 { |
56 /// A debug widget. Essentially as SizableBlankWidget but doesn't mind any amount of data and prints it. | 61 /// A debug widget. Essentially as SizableBlankWidget but doesn't mind any amount of data and prints it. |
57 class DebugWidget : SizableWidget | 62 class DebugWidget : SizableWidget |
58 { | 63 { |
59 this (IWidgetManager mgr, widgetID id, WidgetData data) { | 64 this (IWidgetManager mgr, widgetID id, WidgetData data) { |
60 super (mgr, id, data); | 65 super (mgr, id, data); |
61 | 66 logger.warn ("Debug widget - parameters: ints = {}, strings = {}", data.ints, data.strings); |
62 Stdout ("Debug widget - parameters: int: ["); | |
63 foreach (x; data.ints) | |
64 Stdout (" ")(x); | |
65 Stdout (" ], char[]: ["); | |
66 foreach (x; data.strings) | |
67 Stdout (" \"")(x)('"'); | |
68 Stdout (" ]").newline; | |
69 } | 67 } |
70 | 68 |
71 override void draw () { | 69 override void draw () { |
72 super.draw; | 70 super.draw; |
73 | 71 |
74 mgr.renderer.drawBlank (x,y, w,h); | 72 mgr.renderer.drawBlank (x,y, w,h); |
75 } | 73 } |
76 } | 74 } |
77 | |
78 /// First interactible widget | |
79 class ButtonWidget : AButtonWidget | |
80 { | |
81 this (IWidgetManager mgr, widgetID id, WidgetData data) { | |
82 WDCheck (data, 3); | |
83 w = mw = cast(wdim) data.ints[1]; | |
84 h = mh = cast(wdim) data.ints[2]; | |
85 super (mgr, id, data); | |
86 } | |
87 | |
88 override void activated () { | |
89 Stdout ("Button clicked!").newline; | |
90 } | |
91 } |