# HG changeset patch # User Diggory Hardy # Date 1214336452 -3600 # Node ID 23a1d2b1ec5f0dae92ddb1addb0e4c81629c6c55 # Parent 672b6b162a36b98cb0772cfc480552e77c74b5ca Fixed a little bug giving the mouse pointer the correct position. diff -r 672b6b162a36 -r 23a1d2b1ec5f codeDoc/gui/GUI notes.txt --- 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. diff -r 672b6b162a36 -r 23a1d2b1ec5f mde/input/Input.d --- 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); }