Mercurial > projects > mde
diff mde/gui/widget/miscWidgets.d @ 95:2a364c7d82c9
Boolean options can be adjusted from the gui now (using a very basic widget). Also some bug-fixes.
Fixed a minor bug where layouts with the same id but without shared alignments would be messed up.
Tracked down the "nothing trawn until a resize" bug (see jobs.txt).
If widgets throw during creation they're now replaced by debug widgets.
Function pointers are converted to delegates using a safer method.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 06 Nov 2008 11:07:18 +0000 |
parents | 4d5d53e4f881 |
children | b16a534f5302 |
line wrap: on
line diff
--- a/mde/gui/widget/miscWidgets.d Thu Oct 23 17:45:49 2008 +0100 +++ b/mde/gui/widget/miscWidgets.d Thu Nov 06 11:07:18 2008 +0000 @@ -76,48 +76,16 @@ } /// First interactible widget -class ButtonWidget : FixedWidget +class ButtonWidget : AButtonWidget { - bool pushed = false; // true if button is pushed in (visually) - // pushed is not the same as the button being clicked but not yet released. - // it is whether the mouse is over the button after being clicked. - this (IWidgetManager mgr, widgetID id, WidgetData data) { WDCheck (data, 3); + w = mw = cast(wdim) data.ints[1]; + h = mh = cast(wdim) data.ints[2]; super (mgr, id, data); } - void draw () { - mgr.renderer.drawButton (x,y, w,h, pushed); - } - - void clickEvent (wdabs, wdabs, ubyte b, bool state) { - if (b == 1 && state == true) { - pushed = true; - mgr.requestRedraw; - mgr.addClickCallback (&clickWhileHeld); - mgr.addMotionCallback (&motionWhileHeld); - } - } - // Called when a mouse motion/click event occurs while (held == true) - bool clickWhileHeld (wdabs cx, wdabs cy, ubyte b, bool state) { - if (b == 1 && state == false) { - if (cx >= x && cx < x+w && cy >= y && cy < y+h) // button event - Stdout ("Button clicked!").newline; - - pushed = false; - mgr.requestRedraw; - mgr.removeCallbacks (cast(void*) this); - - return true; - } - return false; - } - void motionWhileHeld (wdabs cx, wdabs cy) { - bool oldPushed = pushed; - if (cx >= x && cx < x+w && cy >= y && cy < y+h) pushed = true; - else pushed = false; - if (oldPushed != pushed) - mgr.requestRedraw; + void activated () { + Stdout ("Button clicked!").newline; } }