Ignore:
Timestamp:
May 13, 2011, 1:36:00 PM (12 years ago)
Author:
Sam Hocevar
Message:

imlib: clean up EventHandler? and JCMouse.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/sdlport/mouse.cpp

    r579 r645  
    5050// Constructor
    5151//
    52 JCMouse::JCMouse( image *Screen, palette *pal )
     52JCMouse::JCMouse(image *screen, palette *pal)
    5353{
    5454    image *im;
     
    5858    cx = cy = 0;
    5959    here = 1;
    60     sp = NULL;
    6160
    62     screen = Screen;
     61    m_screen = screen;
    6362    br = pal->brightest( 1 );
    6463    dr = pal->darkest( 1 );
     
    7776JCMouse::~JCMouse()
    7877{
    79     if( sp )
    80     {
    81         delete sp->visual;
    82         delete sp;
    83     }
     78    delete sp->visual;
     79    delete sp;
    8480}
    8581
     
    8884// Set the shape of the mouse cursor
    8985//
    90 void JCMouse::set_shape( image *im, int centerx, int centery )
     86void JCMouse::set_shape(image *im, int centerx, int centery)
    9187{
    92     sp->change_visual( im, 1 );
     88    sp->change_visual(im, 1);
    9389    cx = -centerx;
    9490    cy = -centery;
     
    9995// Set the position of the mouse cursor
    10096//
    101 void JCMouse::set_position( int new_mx, int new_my )
     97void JCMouse::set_position(int new_mx, int new_my)
    10298{
    10399    // Make sure the values we are given are sensible.
    104     if( new_mx > screen->Size().x - 1 )
    105     {
    106         new_mx = screen->Size().x - 1;
    107     }
    108     if( new_my > screen->Size().y - 1 )
    109     {
    110         new_my = screen->Size().y - 1;
    111     }
     100    mx = Min(new_mx, m_screen->Size().x - 1);
     101    my = Min(new_my, m_screen->Size().y - 1);
    112102
    113103    // Set the new position
    114     mx = new_mx;
    115     my = new_my;
    116     SDL_WarpMouse( new_mx, new_my );
     104    SDL_WarpMouse(mx, my);
    117105}
    118106
    119107//
    120108// update()
    121 // Update the mouses position and buttons states
     109// Update the mouse position and button states
    122110//
    123 void JCMouse::update( int newx, int newy, int new_but )
     111void JCMouse::update(int newx, int newy, int new_but)
    124112{
    125     if( newx < 0 )
     113    if (newx < 0)
    126114    {
    127         Uint8 mask;
    128 
    129115        lx = mx;
    130116        ly = my;
    131117        lbut = but;
    132         mask = SDL_GetMouseState( &mx, &my );
    133         but = ( ( mask & SDL_BUTTON(1) ) != 0 ) |
    134               ( ( mask & SDL_BUTTON(2) ) != 0 ) << 2 |
    135               ( ( mask & SDL_BUTTON(3) ) != 0 ) << 1;
     118
     119        uint8_t mask = SDL_GetMouseState(&mx, &my);
     120        but = ((mask & SDL_BUTTON(1)) != 0) |
     121              ((mask & SDL_BUTTON(2)) != 0) << 2 |
     122              ((mask & SDL_BUTTON(3)) != 0) << 1;
    136123    }
    137124    else
     
    142129    }
    143130}
     131
Note: See TracChangeset for help on using the changeset viewer.