comparison mde/gui/widget/Widget.d @ 36:57d000574d75

Enabled drawing on demand, and made the polling interval configurable. Renamed mde.global to mde.imde. Enabled drawing on demand. Allowed options to take double values. Made the main loop's polling interval (sleep duration) settable from config files. committer: Diggory Hardy <diggory.hardy@gmail.com>
author Diggory Hardy <diggory.hardy@gmail.com>
date Fri, 02 May 2008 17:38:43 +0100
parents 6b4116e6355c
children 052df9b2fe07
comparison
equal deleted inserted replaced
35:928db3c75ed3 36:57d000574d75
112 } 112 }
113 113
114 void clickEvent (ushort, ushort, ubyte b, bool state) { 114 void clickEvent (ushort, ushort, ubyte b, bool state) {
115 if (b == 1 && state == true) { 115 if (b == 1 && state == true) {
116 pushed = true; 116 pushed = true;
117 window.gui.requestRedraw;
117 window.gui.addClickCallback (&clickWhileHeld); 118 window.gui.addClickCallback (&clickWhileHeld);
118 window.gui.addMotionCallback (&motionWhileHeld); 119 window.gui.addMotionCallback (&motionWhileHeld);
119 } 120 }
120 } 121 }
121 // Called when a mouse motion/click event occurs while (held == true) 122 // Called when a mouse motion/click event occurs while (held == true)
122 void clickWhileHeld (ushort cx, ushort cy, ubyte b, bool state) { 123 void clickWhileHeld (ushort cx, ushort cy, ubyte b, bool state) {
123 if (cx >= x && cx < x+w && cy >= y && cy < y+h) // button event 124 if (cx >= x && cx < x+w && cy >= y && cy < y+h) // button event
124 Stdout ("Button clicked!").newline; 125 Stdout ("Button clicked!").newline;
125 126
126 pushed = false; 127 pushed = false;
128 window.gui.requestRedraw;
127 window.gui.removeCallbacks (cast(void*) this); 129 window.gui.removeCallbacks (cast(void*) this);
128 } 130 }
129 void motionWhileHeld (ushort cx, ushort cy) { 131 void motionWhileHeld (ushort cx, ushort cy) {
132 bool oldPushed = pushed;
130 if (cx >= x && cx < x+w && cy >= y && cy < y+h) pushed = true; 133 if (cx >= x && cx < x+w && cy >= y && cy < y+h) pushed = true;
131 else pushed = false; 134 else pushed = false;
135 if (oldPushed != pushed)
136 window.gui.requestRedraw;
132 } 137 }
133 } 138 }
134 //END Widgets 139 //END Widgets