Back to index

extremetuxracer  0.5beta
Public Member Functions | Private Member Functions | Private Attributes
pp::UIManager Class Reference

#include <ui_mgr.h>

Collaboration diagram for pp::UIManager:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 UIManager ()
 ~UIManager ()
void add (pp::Widget *widget)
void remove (pp::Widget *widget)
void setDirty ()
void checkDirty ()
void setupDisplay ()
void draw ()
void mouseEvent (int button, int state, int x, int y)
void motionEvent (int x, int y)
pp::Vec2d getMousePosition ()
bool keyboardEvent (SDLKey key, SDLMod mod, bool release)
void grabFocus (pp::Widget *widget, bool focus)

Private Member Functions

void drawCursor ()

Private Attributes

std::list< pp::Widget * > widgets
pp::WidgetfocusWidget
bool leftMouseButtonDown
bool middleMouseButtonDown
bool rightMouseButtonDown
bool dirty
pp::Vec2d cursorPos

Detailed Description

Definition at line 36 of file ui_mgr.h.


Constructor & Destructor Documentation

Definition at line 32 of file ui_mgr.cpp.

       : cursorPos(0.0,0.0)
{
       leftMouseButtonDown = false;
       middleMouseButtonDown = false;
       rightMouseButtonDown = false;
       dirty = true;
       focusWidget = NULL;
}

Definition at line 42 of file ui_mgr.cpp.

{
}

Member Function Documentation

void pp::UIManager::add ( pp::Widget widget)

Definition at line 207 of file ui_mgr.cpp.

{
       widgets.push_back(widget);  
}

Here is the caller graph for this function:

Definition at line 152 of file ui_mgr.cpp.

{
    if( dirty){
              winsys_post_redisplay();
              dirty = false;
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 67 of file ui_mgr.cpp.

{
       setupDisplay();
       std::list<pp::Widget*>::iterator it;
       for(it=widgets.begin();it!=widgets.end();it++){
              (*it)->draw();              
       }
       drawCursor(); 
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::UIManager::drawCursor ( ) [private]

Definition at line 78 of file ui_mgr.cpp.

{
    GLuint texobj;
    char *binding;

    binding = "mouse_cursor";
    if ( !get_texture_binding( binding, &texobj ) ) {
       texobj = 0;
    }

    setupDisplay();

    glBindTexture( GL_TEXTURE_2D, texobj );

    glBegin( GL_QUADS );
    {
       glTexCoord2f( 0, 1 );
       glVertex2f( cursorPos.x, 
                  cursorPos.y );

       glTexCoord2f( 0, 0 );
       glVertex2f( cursorPos.x, 
                  cursorPos.y - 32 );

       glTexCoord2f( 1, 0 );
       glVertex2f( cursorPos.x + 32, 
                  cursorPos.y - 32 );

       glTexCoord2f( 1, 1 );
       glVertex2f( cursorPos.x + 32, 
                  cursorPos.y );

    }
    glEnd();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 161 of file ui_mgr.cpp.

{
    return cursorPos;
}

Here is the caller graph for this function:

void pp::UIManager::grabFocus ( pp::Widget widget,
bool  focus 
)

Definition at line 231 of file ui_mgr.cpp.

{
       if(focus){
              if(focusWidget!=NULL){
                     focusWidget->removeFocus();
              }
              focusWidget=widget;
       }else{
              if(focusWidget==widget){
                     focusWidget=NULL;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool pp::UIManager::keyboardEvent ( SDLKey  key,
SDLMod  mod,
bool  release 
)

Definition at line 222 of file ui_mgr.cpp.

{
       if(focusWidget!=NULL){
              return focusWidget->keyboardEvent(key, mod, release);   
       }
       return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::UIManager::motionEvent ( int  x,
int  y 
)

Definition at line 167 of file ui_mgr.cpp.

{
    if ( is_mode_change_pending() ) {
              // Don't process events until mode change occurs 
              return;
    }

    // Reverse y coordinate
    y = getparam_y_resolution() - y;
       
       std::list<pp::Widget*>::iterator it;
       
       for(it=widgets.begin();it!=widgets.end();it++){
              (*it)->mouseMotion(x,y);
       }
       
    pp::Vec2d oldPos = cursorPos;
    cursorPos = pp::Vec2d(x,y);

    if ( oldPos.x != x || oldPos.y != y ) {
              // Update UI snow 
              if ( getparam_ui_snow() ) {
                     if ( rightMouseButtonDown ) {
                            make_ui_snow( cursorPos );
                            reset_ui_snow_cursor_pos( cursorPos );
                     } else if ( middleMouseButtonDown ) {
                            make_ui_snow( cursorPos );
                            push_ui_snow( cursorPos );
                     } else {
                            push_ui_snow( cursorPos );
                     }
              }

              // Need to redraw cursor
              setDirty();
              checkDirty();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::UIManager::mouseEvent ( int  button,
int  state,
int  x,
int  y 
)

Definition at line 115 of file ui_mgr.cpp.

{
    if ( is_mode_change_pending() ) {
              // Don't process events until mode change occurs 
              return;
    }

    // Reverse y coordinate 
    y = getparam_y_resolution() - y;
       
       
       std::list<pp::Widget*>::iterator it;
       
       if ( state == SDL_PRESSED ) {
              for(it=widgets.begin();it!=widgets.end();it++){
                     (*it)->mouseDown(button,x,y);
              }
       } else {
              for(it=widgets.begin();it!=widgets.end();it++){
                     (*it)->mouseUp(button,x,y);
              }
       }

    if ( button == SDL_BUTTON_LEFT ) {
              leftMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }
    if ( button == SDL_BUTTON_MIDDLE ) {
              middleMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }
    if ( button == SDL_BUTTON_RIGHT ) {
              rightMouseButtonDown = (bool) ( state == SDL_PRESSED );
    }

    checkDirty();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pp::UIManager::remove ( pp::Widget widget)

Definition at line 213 of file ui_mgr.cpp.

{
       if(focusWidget==widget){
              focusWidget=NULL;
       }      
       widgets.remove(widget);
}

Here is the caller graph for this function:

Definition at line 47 of file ui_mgr.cpp.

{
    dirty = true;
}

Definition at line 53 of file ui_mgr.cpp.

{
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glOrtho( 0, getparam_x_resolution(), 
              0, getparam_y_resolution(), -1.0, 1.0 );
    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();
    glTranslatef( 0.0, 0.0, -1.0 );

    glColor4f( 1.0, 1.0, 1.0, 1.0 );
}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 47 of file ui_mgr.h.

bool pp::UIManager::dirty [private]

Definition at line 46 of file ui_mgr.h.

Definition at line 40 of file ui_mgr.h.

Definition at line 42 of file ui_mgr.h.

Definition at line 43 of file ui_mgr.h.

Definition at line 44 of file ui_mgr.h.

std::list<pp::Widget*> pp::UIManager::widgets [private]

Definition at line 38 of file ui_mgr.h.


The documentation for this class was generated from the following files: