Changeset 60:23a1d2b1ec5f

Show
Ignore:
Timestamp:
06/24/08 15:40:52 (7 months ago)
Author:
Diggory Hardy <diggory.hardy@gmail.com>
branch:
default
Message:

Fixed a little bug giving the mouse pointer the correct position.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • codeDoc/gui/GUI notes.txt

    r34 r60  
    3030Some unifications of the coordinate system are needed: 
    3131    By default OpenGL uses the bottom left as the origin, with the first (bottom-left most) pixel at 0,0. 
    32     SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 1,1
    33 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
     32    SDL's mouse events use the top left as the origin, with the first (top-left most) pixel at 0,0
     33I 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
  • mde/input/Input.d

    r37 r60  
    191191        * some functionality at least is retained. 
    192192        * 
    193         * Note that the mouse coordinates as reported by SDL put the top-left most pixel at 1,1. 
    194         * Internal coordinates put that pixel at 0,0 (see gui/GUI notes.txt). 
     193        * Coordinates don't need adjusting (they put the top-left most pixel at 0,0). 
    195194        */ 
    196195        switch (event.type) { 
     
    199198                foreach (dg; mouseClickCallbacks) { 
    200199                    try 
    201                         dg (event.button.x - 1, event.button.y - 1
     200                        dg (event.button.x, event.button.y
    202201                            event.button.button, event.button.state == SDL_PRESSED); 
    203202                    catch (Exception e) 
     
    207206             
    208207            case SDL_MOUSEMOTION: 
    209                 mouse_x = event.motion.x - 1
    210                 mouse_y = event.motion.y - 1
     208                mouse_x = event.motion.x
     209                mouse_y = event.motion.y
    211210                 
    212211                foreach (dg; mouseMotionCallbacks) { 
    213212                    try 
    214                         dg (event.motion.x - 1, event.motion.y - 1); 
     213                        dg (event.motion.x, event.motion.y); 
    215214                    catch (Exception e) 
    216215                        logger.error (CB_EXC ~ e.msg);