Mercurial > projects > mde
comparison mde/gui/widget/Ifaces.d @ 160:ccd01fde535e
Replaced WidgetManager's click and motion callbacks with a drag event system.
This is less flexible, but much closer to what is required (and is simpler and less open to bugs through unintended use).
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Thu, 21 May 2009 22:15:32 +0200 |
parents | c67d074a7111 |
children | 2476790223b8 |
comparison
equal
deleted
inserted
replaced
159:b06b04c75e86 | 160:ccd01fde535e |
---|---|
235 /** Get the window's renderer. | 235 /** Get the window's renderer. |
236 * | 236 * |
237 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this | 237 * Normally specific to the GUI, but widgets have no direct contact with the GUI and this |
238 * provides the possibility of per-window renderers (if desired). */ | 238 * provides the possibility of per-window renderers (if desired). */ |
239 IRenderer renderer (); | 239 IRenderer renderer (); |
240 | |
241 // User input: | |
242 /** Add a mouse click callback. | |
243 * | |
244 * This is a delegate this will be called for all mouse click events recieved by the gui, not | |
245 * simply all click events on the widget (as clickEvent recieves). | |
246 * | |
247 * The delegate should return true if it accepts the event and no further processing is | |
248 * required (i.e. the event should not be handled by anything else), false otherwise. */ | |
249 void addClickCallback (bool delegate (wdabs cx, wdabs cy, ubyte b, bool state) dg); | |
250 | |
251 /** Add a mouse motion callback: delegate will be called for all motion events recieved by the | |
252 * gui. */ | |
253 void addMotionCallback (void delegate (wdabs cx, wdabs cy) dg); | |
254 | |
255 /** Remove all event callbacks on this widget (according to the delegate's .ptr). */ | |
256 // Note: don't try to pass a reference and cast to void* in the function; it's a different address. | |
257 void removeCallbacks (void* frame); | |
258 } | 240 } |
259 | 241 |
260 | 242 |
261 /****************************************************************************** | 243 /****************************************************************************** |
262 * Interface for (child) widgets, i.e. all widgets other than the manager. | 244 * Interface for (child) widgets, i.e. all widgets other than the manager. |
395 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down) | 377 /** Receive a mouse click event at cx,cy from button b (1-5 correspond to L,M,B, wheel up,down) |
396 * which is a down-click if state is true. | 378 * which is a down-click if state is true. |
397 * | 379 * |
398 * Widget may assume coordinates are on the widget (caller must check). | 380 * Widget may assume coordinates are on the widget (caller must check). |
399 * | 381 * |
400 * The return value has the following flags: 1 to request keyboard input. */ | 382 * The return value has the following flags: |
383 * $(TABLE | |
384 * $(TR $(TD 1) $(TD Request keyboard input)) | |
385 * $(TR $(TD 2) $(TD Request the functions dragMotion and dragRelease are called)) | |
386 * ) */ | |
401 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state); | 387 int clickEvent (wdabs cx, wdabs cy, ubyte b, bool state); |
388 | |
389 /** Called when dragging motion occurs, originating from this widget. | |
390 * | |
391 * Params: target = The widget under the mouse when the click was released | |
392 * | |
393 * Only called if requested by clickEvent. */ | |
394 void dragMotion (wdabs cx, wdabs cy, IChildWidget target); | |
395 | |
396 /** Called at the end of a drag which originated from this widget. | |
397 * | |
398 * Params: target = The widget under the mouse when the click was released | |
399 * | |
400 * Returns: true if the up-click event should not be passed to | |
401 * clickEvent on the relevent widget. | |
402 * | |
403 * Only called if requested by clickEvent. */ | |
404 bool dragRelease (wdabs cx, wdabs cy, IChildWidget target); | |
402 | 405 |
403 /** Receives keyboard events when requested. | 406 /** Receives keyboard events when requested. |
404 * | 407 * |
405 * Params: | 408 * Params: |
406 * sym SDLKey key sym, useful for keys with no character code such as arrow keys | 409 * sym SDLKey key sym, useful for keys with no character code such as arrow keys |