Mercurial > projects > mde
changeset 60:23a1d2b1ec5f
Fixed a little bug giving the mouse pointer the correct position.
author | Diggory Hardy <diggory.hardy@gmail.com> |
---|---|
date | Tue, 24 Jun 2008 20:40:52 +0100 |
parents | 672b6b162a36 |
children | 7cab2af4ba21 |
files | codeDoc/gui/GUI notes.txt mde/input/Input.d |
diffstat | 2 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/codeDoc/gui/GUI notes.txt Sat Jun 14 17:52:22 2008 +0100 +++ b/codeDoc/gui/GUI notes.txt Tue Jun 24 20:40:52 2008 +0100 @@ -29,5 +29,5 @@ Notes: Some unifications of the coordinate system are needed: By default OpenGL uses the bottom left as the origin, with the first (bottom-left most) pixel at 0,0. - SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 1,1. -I decided, for the GUI, to use the top-left at the origin with the top-left most pixel at 0,0. For OpenGL, the projection can simply be modified to achieve this; for SDL's events 1 is subtracted from each coordinate when the event is recieved. + SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 0,0. +I decided, for the GUI, to use the top-left at the origin with the top-left most pixel at 0,0. For OpenGL, the projection can simply be modified to achieve this.
--- a/mde/input/Input.d Sat Jun 14 17:52:22 2008 +0100 +++ b/mde/input/Input.d Tue Jun 24 20:40:52 2008 +0100 @@ -190,15 +190,14 @@ * Mouse events don't need config for the GUI. Handle them first so that if no config exists * some functionality at least is retained. * - * Note that the mouse coordinates as reported by SDL put the top-left most pixel at 1,1. - * Internal coordinates put that pixel at 0,0 (see gui/GUI notes.txt). + * Coordinates don't need adjusting (they put the top-left most pixel at 0,0). */ switch (event.type) { case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: foreach (dg; mouseClickCallbacks) { try - dg (event.button.x - 1, event.button.y - 1, + dg (event.button.x, event.button.y, event.button.button, event.button.state == SDL_PRESSED); catch (Exception e) logger.error (CB_EXC ~ e.msg); @@ -206,12 +205,12 @@ break; case SDL_MOUSEMOTION: - mouse_x = event.motion.x - 1; - mouse_y = event.motion.y - 1; + mouse_x = event.motion.x; + mouse_y = event.motion.y; foreach (dg; mouseMotionCallbacks) { try - dg (event.motion.x - 1, event.motion.y - 1); + dg (event.motion.x, event.motion.y); catch (Exception e) logger.error (CB_EXC ~ e.msg); }