Back to index

supertuxkart  0.5+dfsg1
Classes | Public Member Functions | Static Public Attributes | Private Types | Private Member Functions | Private Attributes
WidgetManager Class Reference

#include <widget_manager.hpp>

Collaboration diagram for WidgetManager:
Collaboration graph
[legend]

List of all members.

Classes

struct  WidgetElement
struct  WidgetID

Public Member Functions

 WidgetManager ()
 ~WidgetManager ()
bool isEmpty ()
bool addWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT)
bool breakLine ()
void switchOrder ()
void reset ()
void update (const float DELTA)
bool layout ()
 This argument-less layout() function serves as a recall to the other layout function in case you want to change the way widgets are put on the screen.
bool layout (const WidgetArea POSITION)
int getSelectedWgt () const
void setSelectedWgt (const int TOKEN)
bool selectionChanged () const
bool addEmptyWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT)
bool addTitleWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const std::string TEXT)
bool addTextWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const std::string TEXT)
bool addTextButtonWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const std::string TEXT)
bool addImgWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const int IMG)
bool addImgWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const char *FILENAME)
bool addImgButtonWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const int IMG)
bool addImgButtonWgt (const int TOKEN, const int MIN_WIDTH, const int MIN_HEIGHT, const char *FILENAME)
void setInitialActivationState (const bool ACTIVE)
void setInitialRectState (const bool SHOW, const WidgetArea ROUND_CORNERS, const int RADIUS, const GLfloat *const COLOR)
void setInitialTextureState (const bool SHOW, const int TEXTURE)
void setInitialBorderState (const bool SHOW, const int PERCENTAGE, const GLfloat *const COLOR)
void setInitialTextState (const bool SHOW, const std::string TEXT, const WidgetFontSize SIZE, const WidgetFont FONT, const GLfloat *const COLOR, const bool RESIZE_WGT)
void setInitialScrollState (const bool ENABLE, const WidgetScrollPos X_POS, const WidgetScrollPos Y_POS, const int X_SPEED, const int Y_SPEED)
void setInitialRotationState (const bool ENABLE, const float ANGLE, const int SPEED)
void setInitialTrackState (const bool SHOW, const int TRACK)
void restoreDefaultStates ()
void activateWgt (const int TOKEN)
void deactivateWgt (const int TOKEN)
void setWgtColor (const int TOKEN, const GLfloat *const COLOR)
void setWgtRoundCorners (const int TOKEN, const WidgetArea CORNERS)
void setWgtCornerRadius (const int TOKEN, const int RADIUS)
void showWgtRect (const int TOKEN)
void hideWgtRect (const int TOKEN)
void setWgtBorderColor (const int TOKEN, const GLfloat *const COLOR)
void setWgtBorderPercentage (const int TOKEN, const int PERCENTAGE)
void showWgtBorder (const int TOKEN)
void hideWgtBorder (const int TOKEN)
void setWgtTexture (const int TOKEN, const int TEXTURE)
void setWgtTexture (const int TOKEN, const char *FILENAME, const bool is_full_path=true)
void showWgtTexture (const int TOKEN)
void hideWgtTexture (const int TOKEN)
void setWgtText (const int TOKEN, const char *TEXT)
void setWgtText (const int TOKEN, const std::string TEXT)
void setWgtTextSize (const int TOKEN, const WidgetFontSize SIZE)
void setWgtFont (const int TOKEN, const WidgetFont FONT)
void setWgtTextColor (const int TOKEN, const GLfloat *const COLOR)
void setWgtResizeToText (const int TOKEN, const bool RESIZE)
void showWgtText (const int TOKEN)
void hideWgtText (const int TOKEN)
void resizeWgtToText (const int TOKEN)
void reloadFonts ()
 reloadFonts() sets the pointers to the fonts of the guis to their choosen fonts; it's useful in cases where you free the font's memory (which makes the pointers invalid), then reload the fonts, like it happens when you change resolution on the Macs or Windows.
void enableWgtScroll (const int TOKEN)
void disableWgtScroll (const int TOKEN)
void setWgtXScrollPos (const int TOKEN, const WidgetScrollPos POS)
void setWgtYScrollPos (const int TOKEN, const WidgetScrollPos POS)
void setWgtXScrollSpeed (const int TOKEN, const int SPEED)
void setWgtYScrollSpeed (const int TOKEN, const int SPEED)
void enableWgtRotation (const int TOKEN)
void disableWgtRotation (const int TOKEN)
void setWgtRotationAngle (const int TOKEN, const float ANGLE)
void setWgtRotationSpeed (const int TOKEN, const int SPEED)
void showWgtTrack (const int TOKEN)
void hideWgtTrack (const int TOKEN)
void setWgtTrackNum (const int TOKEN, const int TRACK)
void pulseWgt (const int TOKEN) const
 pulse_widget() passes the pulse order to the right widget.
void lightenWgtColor (const int TOKEN)
void darkenWgtColor (const int TOKEN)
int handlePointer (const int X, const int Y)
 The handlePointer() function returns the current widget under the pointer, if it's different from the selected widget.
int handleLeft ()
 The handle_<direction>() function stores the current widget under the cursor after receiving input from a key.
int handleRight ()
int handleUp ()
int handleDown ()
void increaseScrollSpeed (bool=false)
void decreaseScrollSpeed (bool=false)

Static Public Attributes

static const int WGT_NONE = -1

Private Types

enum  ElementTypes { ET_WGT, ET_BREAK, ET_SWITCH }

Private Member Functions

int findId (const int TOKEN) const
int calcLineWidth (const int POS)
 This calcLineWidth() function returns the width of the smallest rectangle that contains the widgets in the given line.
int calcLineHeight (const int POS)
 This calcLineHeight() function returns the height of the smallest rectangle that contains the widgets in the given line.
int calcColumnWidth (const int POS)
 This calcColumnWidth() function returns the width of the smallest rectangle that contains the widgets in the given column.
int calcColumnHeight (const int POS)
 This calcColumnHeight() function returns the height of the smallest rectangle that contains the widgets in the given column.
int getLineWidth (int &pos)
 This getLineWidth() function returns the width of the smallest rectangle that contains the widgets in the given line.
int getLineHeight (int &pos)
 This getLineHeight() function returns the height of the smallest rectangle that contains the widgets in the given line.
int getColumnWidth (int &pos)
 This getColumnWidth() function returns the width of the smallest rectangle that contains the widgets in the given column.
int getColumnHeight (int &pos)
 This getColumnHeight() function returns the height of the smallest rectangle that contains the widgets in the given column.
int calcLineX (const int POS)
int calcColumnX (const int POS)
int calcWidth ()
 The calcWidth() function retrieves the width of the smallest rectangle that contains all the widgets being handled by the widget manager.
int calcHeight ()
 The calcHeight() function retrieves the height of the smallest rectangle that contains all the widgets being handled by the widget manager.
bool layoutLine (int &x, int &y, int &pos)
bool layoutColumn (int &x, int &y, int &pos)
int findLeftWidget (const int START_WGT) const
 findLeftWidget() returns the closest widget to the left of START_WGT.
int findRightWidget (const int START_WGT) const
 findRightWidget() returns the closest widget to the right of START_WGT
int findTopWidget (const int START_WGT) const
 findTopWidget() returns the closest widget on top of START_WGT.
int findBottomWidget (const int START_WGT) const
 findBottomWidget() returns the closest widget under START_WGT.
int handleFinish (const int)
void setSelectedWgtToken (const int TOKEN)

Private Attributes

std::vector< WidgetElementm_elems
std::vector< WidgetIDm_widgets
WidgetArea m_prev_layout_pos
int m_x
int m_y
int m_selected_wgt_token
bool m_selection_change
bool m_default_active
bool m_default_resize_to_text
bool m_default_show_rect
WidgetArea m_default_rect_round_corners
int m_default_rect_radius
const GLfloat * m_default_rect_color
bool m_default_show_border
float m_default_border_percentage
const GLfloat * m_default_border_color
bool m_default_show_texture
int m_default_texture
bool m_default_show_text
std::string m_default_text
WidgetFontSize m_default_text_size
WidgetFont m_default_font
const GLfloat * m_default_text_color
bool m_default_enable_scroll
WidgetScrollPos m_default_scroll_preset_x
WidgetScrollPos m_default_scroll_preset_y
int m_default_scroll_x_speed
int m_default_scroll_y_speed
bool m_default_enable_rotation
float m_default_rotation_angle
int m_default_rotation_speed
int m_default_show_track
int m_default_track_num

Detailed Description

Definition at line 38 of file widget_manager.hpp.


Class Documentation

struct WidgetManager::WidgetID

Definition at line 40 of file widget_manager.hpp.

Collaboration diagram for WidgetManager::WidgetID:
Class Members
bool active
WidgetScrollPos last_preset_scroll_x
WidgetScrollPos last_preset_scroll_y
int min_height
int min_radius
int min_width
bool resize_to_text
int token
Widget * widget

Member Enumeration Documentation

Enumerator:
ET_WGT 
ET_BREAK 
ET_SWITCH 

Definition at line 64 of file widget_manager.hpp.

    {
        ET_WGT,
        ET_BREAK,
        ET_SWITCH //Switch orientation
    };

Constructor & Destructor Documentation

Definition at line 40 of file widget_manager.cpp.

Here is the call graph for this function:

Definition at line 50 of file widget_manager.cpp.

{
    reset();
}

Here is the call graph for this function:


Member Function Documentation

void WidgetManager::activateWgt ( const int  TOKEN)

Definition at line 1204 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].active = true;
    else
    {
        std::cerr << "WARNING: tried to activate unnamed widget with token "
            << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addEmptyWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT 
) [inline]

Definition at line 208 of file widget_manager.hpp.

{return addWgt(TOKEN,MIN_WIDTH,MIN_HEIGHT);}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addImgButtonWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const int  IMG 
)

Definition at line 1024 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    setWgtColor( TOKEN, WGT_GRAY );
    showWgtRect( TOKEN );
    setWgtRoundCorners( TOKEN, WGT_AREA_ALL );
    setWgtCornerRadius( TOKEN, 20 );
    setWgtTexture( TOKEN, IMG );
    showWgtTexture( TOKEN );
    activateWgt( TOKEN );

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addImgButtonWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const char *  FILENAME 
)

Definition at line 1046 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    setWgtColor( TOKEN, WGT_GRAY );
    showWgtRect( TOKEN );
    setWgtRoundCorners( TOKEN, WGT_AREA_ALL );
    setWgtCornerRadius( TOKEN, 20 );
    setWgtTexture( TOKEN, FILENAME );
    showWgtTexture( TOKEN );
    activateWgt( TOKEN );

    return true;
}

Here is the call graph for this function:

bool WidgetManager::addImgWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const int  IMG 
)

Definition at line 980 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    setWgtColor( TOKEN, WGT_WHITE );
    showWgtRect( TOKEN );
    setWgtBorderPercentage( TOKEN, 5 );
    setWgtBorderColor( TOKEN, WGT_BLACK );
    showWgtBorder( TOKEN );
    setWgtTexture( TOKEN, IMG );
    showWgtTexture( TOKEN );

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addImgWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const char *  FILENAME 
)

Definition at line 1002 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    setWgtColor( TOKEN, WGT_WHITE );
    showWgtRect( TOKEN );
    setWgtBorderPercentage( TOKEN, 5 );
    setWgtBorderColor( TOKEN, WGT_BLACK );
    showWgtBorder( TOKEN );
    setWgtTexture( TOKEN, FILENAME );
    showWgtTexture( TOKEN );

    return true;
}

Here is the call graph for this function:

bool WidgetManager::addTextButtonWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const std::string  TEXT 
)

Definition at line 959 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    showWgtRect( TOKEN );
    setWgtRoundCorners( TOKEN, WGT_AREA_ALL );
    setWgtCornerRadius( TOKEN, 20 );
    showWgtText( TOKEN );
    setWgtText( TOKEN, TEXT );
    activateWgt( TOKEN );

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addTextWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const std::string  TEXT 
)

Definition at line 939 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    showWgtRect( TOKEN );
    setWgtRoundCorners( TOKEN, WGT_AREA_ALL );
    setWgtCornerRadius( TOKEN, 20 );
    showWgtText( TOKEN );
    setWgtText( TOKEN, TEXT );

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addTitleWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT,
const std::string  TEXT 
)

Definition at line 918 of file widget_manager.cpp.

{
    if( !( addWgt( TOKEN, MIN_WIDTH, MIN_HEIGHT ))) return false;

    showWgtRect( TOKEN );
    setWgtTextSize( TOKEN, WGT_FNT_LRG );
    showWgtText( TOKEN );
    setWgtText( TOKEN, TEXT );
    setWgtRoundCorners( TOKEN, WGT_AREA_ALL );
    setWgtCornerRadius( TOKEN, 20 );

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::addWgt ( const int  TOKEN,
const int  MIN_WIDTH,
const int  MIN_HEIGHT 
)

Definition at line 57 of file widget_manager.cpp.

{
    if( TOKEN != WGT_NONE && findId( TOKEN ) != WGT_NONE )
    {
        std::cerr << "WARNING: tried to create widget with token " <<
            TOKEN << " but it is already in use.\n";
        return false;
    }

    WidgetID new_id;
    new_id.token = TOKEN;

    //There is no reason to make a token-less widget active, so if the token
    //WGT_NONE, the widget is forced to be inactive, preventing bugs.
    new_id.active = TOKEN != WGT_NONE ? m_default_active : false;

    new_id.min_width = MIN_WIDTH;
    new_id.min_height = MIN_HEIGHT;
    new_id.min_radius = m_default_rect_radius;

    new_id.last_preset_scroll_x = m_default_scroll_preset_x;
    new_id.last_preset_scroll_y = m_default_scroll_preset_y;

    new_id.resize_to_text = m_default_resize_to_text;

    new_id.widget = new Widget(0, 0, 0, 0);

    new_id.widget->m_enable_rect = m_default_show_rect;
    new_id.widget->m_round_corners = m_default_rect_round_corners;
    new_id.widget->m_rect_color = m_default_rect_color;

    new_id.widget->m_enable_border = m_default_show_border;
    new_id.widget->m_border_percentage = m_default_border_percentage;
    new_id.widget->m_border_color = m_default_border_color;

    new_id.widget->m_enable_texture = m_default_show_texture;
    new_id.widget->m_texture = m_default_texture;

    new_id.widget->m_enable_text = m_default_show_text;
    new_id.widget->m_text.assign(m_default_text);
    new_id.widget->m_text_size = m_default_text_size;
    new_id.widget->setFont( m_default_font );
    new_id.widget->m_text_color = m_default_text_color;

    new_id.widget->m_enable_scroll  = m_default_enable_scroll;
    new_id.widget->m_scroll_pos_x   = (float)m_default_scroll_preset_x;
    new_id.widget->m_scroll_pos_y   = (float)m_default_scroll_preset_y;
    new_id.widget->m_scroll_speed_x = m_default_scroll_x_speed;
    new_id.widget->m_scroll_speed_y = m_default_scroll_y_speed;

    new_id.widget->m_enable_rotation = m_default_enable_rotation;
    new_id.widget->m_rotation_angle = m_default_rotation_angle;
    new_id.widget->m_rotation_speed = m_default_rotation_speed;

    new_id.widget->m_enable_track = m_default_show_track;
    new_id.widget->m_track_num = m_default_track_num;

    m_elems.push_back(WidgetElement(ET_WGT, (int)m_widgets.size()));
    m_widgets.push_back(new_id);

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 131 of file widget_manager.cpp.

{
    const int LAST_WGT = (int)m_widgets.size() - 1;

    if( LAST_WGT < 0 )
    {
        std::cerr << "WARNING: tried to add a break before adding any " <<
            "widgets.\n";
        return false;
    }

    const int LAST_ELEM = (int)m_elems.size() - 1;
    if( m_elems[LAST_ELEM].type == ET_SWITCH )
    {
        std::cerr << "WARNING: tried to add a break after a switch, last " <<
            "widget had token " << m_widgets[ LAST_WGT ].token << ".\n";
        return false;
    }

    m_elems.push_back(WidgetElement( ET_BREAK, 0 ));

    return true;
}

Here is the caller graph for this function:

int WidgetManager::calcColumnHeight ( const int  POS) [private]

This calcColumnHeight() function returns the height of the smallest rectangle that contains the widgets in the given column.

It expects the first element of the column as the argument.

Definition at line 800 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int height = 0;

    for( int i = POS; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[i].type)
        {
        case ET_WGT:
            height += m_widgets[ m_elems[ i ].pos ].widget->m_height;
            break;

        case ET_BREAK:
            return height;

        case ET_SWITCH:
            ++i;
            height += getLineHeight( i );
            break;
        }
    }

    return height;
}

Here is the call graph for this function:

int WidgetManager::calcColumnWidth ( const int  POS) [private]

This calcColumnWidth() function returns the width of the smallest rectangle that contains the widgets in the given column.

It expects the first element of the column as the argument.

Definition at line 764 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int width = 0;
    int line_width;

    for( int i = POS; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[ i ].type )
        {
            case ET_WGT:
            if( m_widgets[ m_elems[ i ].pos ].widget->m_width > width )
            {
                width = m_widgets[ m_elems[ i ].pos ].widget->m_width;
            }
            break;

            case ET_BREAK:
                return width;

            case ET_SWITCH:
                ++i;
                line_width = getLineWidth( i );
                if( line_width > width ) width = line_width;
                break;

        }
    }

    return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::calcColumnX ( const int  POS) [private]

Definition at line 856 of file widget_manager.cpp.

{
    if( POS >= (int)m_elems.size() ) return 0;

    WidgetID* curr_wgt = &m_widgets[ m_elems[ POS ].pos ];

    if( m_elems[ POS ].type == ET_WGT )
    {
        return ( calcColumnWidth( POS ) - curr_wgt->widget->m_width ) / 2;
    }

    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::calcHeight ( ) [private]

The calcHeight() function retrieves the height of the smallest rectangle that contains all the widgets being handled by the widget manager.

Definition at line 891 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int height = 0;

    for( int i = 0; i < NUM_ELEMS; ++i )
    {
        height += getLineHeight( i );
    }

    return height;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::calcLineHeight ( const int  POS) [private]

This calcLineHeight() function returns the height of the smallest rectangle that contains the widgets in the given line.

It expects the first element of the line as the argument.

Definition at line 729 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int height = 0;
    int column_height;

    for( int i = POS; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[i].type)
        {
        case ET_WGT:
            if( m_widgets[ m_elems[ i ].pos ].widget->m_height > height )
            {
                height = m_widgets[ m_elems[ i ].pos ].widget->m_height;
            }
            break;

        case ET_BREAK:
            return height;

        case ET_SWITCH:
            ++i;
            column_height = getColumnHeight( i );
            if( column_height > height ) height = column_height;
            break;
        }
    }

    return height;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::calcLineWidth ( const int  POS) [private]

This calcLineWidth() function returns the width of the smallest rectangle that contains the widgets in the given line.

It expects the first element of the line as the argument.

Definition at line 699 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int width = 0;

    for( int i = POS; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[i].type)
        {
        case ET_WGT:
            width += m_widgets[ m_elems[ i ].pos ].widget->m_width;
            break;

        case ET_BREAK:
            return width;

        case ET_SWITCH:
            ++i;
            width += getColumnWidth( i );
            break;
        }
    }

    return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::calcLineX ( const int  POS) [private]

Definition at line 827 of file widget_manager.cpp.

{
    int width = 0;
    WidgetID* curr_wgt = 0;

    const int NUM_ELEMS = m_elems.size();

    for( int i = POS; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[ i ].type )
        {
        case ET_WGT:
            curr_wgt = &m_widgets[ m_elems[ i ].pos ];

            width += curr_wgt->widget->m_width;
            break;

        case ET_SWITCH:
            break;

        case ET_BREAK:
            return width;
        }
    }

    return width;
}
int WidgetManager::calcWidth ( ) [private]

The calcWidth() function retrieves the width of the smallest rectangle that contains all the widgets being handled by the widget manager.

Definition at line 873 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int width = 0;
    int line_width;

    for( int i = 0; i < NUM_ELEMS; ++i )
    {
        line_width = getLineWidth( i );
        if( line_width > width ) width = line_width;
    }

    return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::darkenWgtColor ( const int  TOKEN)

Definition at line 1729 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->darkenColor();
    else
    {
        std::cerr << "WARNING: tried to darken an unnamed widget with " <<
            "token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::deactivateWgt ( const int  TOKEN)

Definition at line 1216 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].active = false;
    else
    {
        std::cerr << "WARNING: tried to deactivate unnamed widget with " <<
            TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::decreaseScrollSpeed ( bool  fast = false)

Definition at line 1924 of file widget_manager.cpp.

{
       const int ID = findId(m_selected_wgt_token);
       if( m_widgets[ID].widget->m_enable_scroll )
       {
        int &speed = m_widgets[ID].widget->m_scroll_speed_y;
              //FIXME: these increases shouldn't be in pixels, but in percentages.
              //This should increase it by 1%, and the page buttons by 5%.
        if( fast )
        {
            if( speed < 0 && speed > -50 ) speed = 0;
            else speed += 50;
        }
        else
        {
            if( speed < 0 && speed > -10 ) speed = 0;
            else speed += 10;
        }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::disableWgtRotation ( const int  TOKEN)

Definition at line 1632 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_rotation = false;
    else
    {
        std::cerr << "WARNING: tried to disable rotation of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::disableWgtScroll ( const int  TOKEN)

Definition at line 1526 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_scroll = false;
    else
    {
        std::cerr << "WARNING: tried to disable scrolling of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::enableWgtRotation ( const int  TOKEN)

Definition at line 1620 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_rotation = true;
    else
    {
        std::cerr << "WARNING: tried to enable rotation of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::enableWgtScroll ( const int  TOKEN)

Definition at line 1514 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_scroll = true;
    else
    {
        std::cerr << "WARNING: tried to enable scrolling of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::findBottomWidget ( const int  START_WGT) const [private]

findBottomWidget() returns the closest widget under START_WGT.

Remember that for the widget manager, the value 0 in the y-axis is in the bottom of the screen.

Definition at line 2111 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();
    int closest_wgt = WGT_NONE;
    int closest_x_dist = user_config->m_width;
    int closest_y_dist = user_config->m_height;

    const int START_WGT_Y_CENTER = m_widgets[START_WGT].widget->m_y +
        ( m_widgets[START_WGT].widget->m_height / 2 );
    const int START_WGT_X_CENTER = m_widgets[START_WGT].widget->m_x +
        ( m_widgets[START_WGT].widget->m_width / 2 );

    int curr_wgt_x_center, curr_wgt_y_center;
    int x_dist, y_dist;

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if(!(m_widgets[i].active)) continue;

        curr_wgt_y_center = m_widgets[i].widget->m_y + ( m_widgets[i].widget->m_height / 2 );
        curr_wgt_x_center = m_widgets[i].widget->m_x + ( m_widgets[i].widget->m_width / 2 );

        //Notice that the order of this substraction is the *only* difference
        //from the findTopWidget() function
        y_dist = START_WGT_Y_CENTER - curr_wgt_y_center;
        x_dist = abs( curr_wgt_x_center - START_WGT_X_CENTER );

        if( y_dist > 0 && x_dist <= closest_x_dist )
        {
            closest_x_dist = x_dist;

            if( x_dist != closest_x_dist )
            {
                closest_y_dist = user_config->m_height;
                closest_wgt = i;
            }
            else if( y_dist <= closest_y_dist )
            {
                closest_y_dist = y_dist;
                closest_wgt = i;
            }
        }
    }

    return closest_wgt;
}

Here is the caller graph for this function:

int WidgetManager::findId ( const int  TOKEN) const [private]

Definition at line 175 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if( TOKEN == m_widgets[i].token )
            return i;
    }

    return WGT_NONE;
}
int WidgetManager::findLeftWidget ( const int  START_WGT) const [private]

findLeftWidget() returns the closest widget to the left of START_WGT.

We use the center of the widgets as the reference points; then, we filter any widget that is not to the left, and favor the ones that are closest in the Y-axis. If there is only one widget that is closest in the Y-axis, we pick that one as the closest, but if there is more than one widget with the same vertical distance, we have to break the tie by choosing the one closest in the X-axis.

Definition at line 1953 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();
    int closest_wgt = WGT_NONE;
    int closest_x_dist = user_config->m_width;
    int closest_y_dist = user_config->m_height;

    const int START_WGT_Y_CENTER = m_widgets[START_WGT].widget->m_y +
        ( m_widgets[START_WGT].widget->m_height / 2 );
    const int START_WGT_X_CENTER = m_widgets[START_WGT].widget->m_x +
        ( m_widgets[START_WGT].widget->m_width / 2 );

    int curr_wgt_x_center, curr_wgt_y_center;
    int x_dist, y_dist;

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if(!(m_widgets[i].active)) continue;

        curr_wgt_y_center = m_widgets[i].widget->m_y + ( m_widgets[i].widget->m_height / 2 );
        curr_wgt_x_center = m_widgets[i].widget->m_x + ( m_widgets[i].widget->m_width / 2 );

        x_dist = START_WGT_X_CENTER - curr_wgt_x_center;
        y_dist = abs( curr_wgt_y_center - START_WGT_Y_CENTER );

        //Filter out all widgets that are not to the left and choose the
        //widget that is closest in the Y-axis
        if( x_dist > 0 && y_dist <= closest_y_dist )
        {
            closest_y_dist = y_dist;

            //If this is the first widget with this vertical distance, pick
            //it as the current closest widget
            if( y_dist != closest_y_dist )
            {
                closest_x_dist = user_config->m_width; //Reset the distance
                closest_wgt = i;
            }
            //If there is more than one widget with the same vertical
            //distance, choose the one that is closest in the X-axis
            else if( x_dist <= closest_x_dist )
            {
                closest_x_dist = x_dist;
                closest_wgt = i;
            }
        }
    }

    return closest_wgt;
}

Here is the caller graph for this function:

int WidgetManager::findRightWidget ( const int  START_WGT) const [private]

findRightWidget() returns the closest widget to the right of START_WGT

Definition at line 2006 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();
    int closest_wgt = WGT_NONE;
    int closest_x_dist = user_config->m_width;
    int closest_y_dist = user_config->m_height;

    const int START_WGT_Y_CENTER = m_widgets[START_WGT].widget->m_y +
        ( m_widgets[START_WGT].widget->m_height / 2 );
    const int START_WGT_X_CENTER = m_widgets[START_WGT].widget->m_x +
        ( m_widgets[START_WGT].widget->m_width / 2 );

    int curr_wgt_x_center, curr_wgt_y_center;
    int x_dist, y_dist;

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if(!(m_widgets[i].active)) continue;

        curr_wgt_y_center = m_widgets[i].widget->m_y + ( m_widgets[i].widget->m_height / 2 );
        curr_wgt_x_center = m_widgets[i].widget->m_x + ( m_widgets[i].widget->m_width / 2 );

        //Notice that the order of this substraction is the *only* difference
        //from the findLeftWidget() function
        x_dist = curr_wgt_x_center - START_WGT_X_CENTER;
        y_dist = abs( curr_wgt_y_center - START_WGT_Y_CENTER );

        if( x_dist > 0 && y_dist <= closest_y_dist )
        {
            closest_y_dist = y_dist;

            if( y_dist != closest_y_dist )
            {
                closest_x_dist = user_config->m_width;
                closest_wgt = i;
            }
            else if( x_dist <= closest_x_dist )
            {
                closest_x_dist = x_dist;
                closest_wgt = i;
            }
        }
    }

    return closest_wgt;
}

Here is the caller graph for this function:

int WidgetManager::findTopWidget ( const int  START_WGT) const [private]

findTopWidget() returns the closest widget on top of START_WGT.

Remember that for the widget manager, the value 0 in the y-axis is in the bottom of the screen.

Definition at line 2056 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();
    int closest_wgt = WGT_NONE;
    int closest_x_dist = user_config->m_width;
    int closest_y_dist = user_config->m_height;

    const int START_WGT_Y_CENTER = m_widgets[START_WGT].widget->m_y +
        ( m_widgets[START_WGT].widget->m_height / 2 );
    const int START_WGT_X_CENTER = m_widgets[START_WGT].widget->m_x +
        ( m_widgets[START_WGT].widget->m_width / 2 );

    int curr_wgt_x_center, curr_wgt_y_center;
    int x_dist, y_dist;

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if(!(m_widgets[i].active)) continue;

        curr_wgt_y_center = m_widgets[i].widget->m_y + ( m_widgets[i].widget->m_height / 2 );
        curr_wgt_x_center = m_widgets[i].widget->m_x + ( m_widgets[i].widget->m_width / 2 );

        y_dist = curr_wgt_y_center - START_WGT_Y_CENTER;
        x_dist = abs( curr_wgt_x_center - START_WGT_X_CENTER );

        //Filter out all widgets that are not on top and choose the
        //widget that is closest in the X-axis
        if( y_dist > 0 && x_dist <= closest_x_dist )
        {
            closest_x_dist = x_dist;

            //If this is the first widget with this vertical distance, pick
            //it as the current closest widget
            if( x_dist != closest_x_dist )
            {
                closest_y_dist = user_config->m_height;
                closest_wgt = i;
            }
            //If there is more than one widget with the same horizontal
            //distance, choose the one that is closest in the Y-axis
            else if( y_dist <= closest_y_dist )
            {
                closest_y_dist = y_dist;
                closest_wgt = i;
            }
        }
    }

    return closest_wgt;
}

Here is the caller graph for this function:

int WidgetManager::getColumnHeight ( int &  pos) [private]

This getColumnHeight() function returns the height of the smallest rectangle that contains the widgets in the given column.

It expects the first element of the column as the argument, and will set pos to the last element of the column, usually a break.

Definition at line 669 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int height = 0;

    for( ; pos < NUM_ELEMS; ++pos )
    {
        switch( m_elems[ pos ].type)
        {
        case ET_WGT:
            height += m_widgets[ m_elems[ pos ].pos ].widget->m_height;
            break;

        case ET_BREAK:
            return height;

        case ET_SWITCH:
            ++pos;
            height += getLineHeight( pos );
            break;
        }
    }

    return height;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::getColumnWidth ( int &  pos) [private]

This getColumnWidth() function returns the width of the smallest rectangle that contains the widgets in the given column.

It expects the first element of the column as the argument, and will set pos to the last element of the column, usually a break.

Definition at line 632 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int width = 0;
    int line_width;

    for( ; pos < NUM_ELEMS; ++pos )
    {
        switch( m_elems[ pos ].type )
        {
            case ET_WGT:
            if( m_widgets[ m_elems[ pos ].pos ].widget->m_width > width )
            {
                width = m_widgets[ m_elems[ pos ].pos ].widget->m_width;
            }
            break;

            case ET_BREAK:
                return width;

            case ET_SWITCH:
                ++pos;
                line_width = getLineWidth( pos );
                if( line_width > width ) width = line_width;
                break;

        }
    }

    return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::getLineHeight ( int &  pos) [private]

This getLineHeight() function returns the height of the smallest rectangle that contains the widgets in the given line.

It expects the first element of the line as the argument, and will set pos to the last element of the line, usually a break.

Definition at line 596 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int height = 0;
    int column_height;

    for( ; pos < NUM_ELEMS; ++pos )
    {
        switch( m_elems[ pos ].type)
        {
        case ET_WGT:
            if( m_widgets[ m_elems[ pos ].pos ].widget->m_height > height )
            {
                height = m_widgets[ m_elems[ pos ].pos ].widget->m_height;
            }
            break;

        case ET_BREAK:
            return height;

        case ET_SWITCH:
            ++pos;
            column_height = getColumnHeight( pos );
            if( column_height > height ) height = column_height;
            break;
        }
    }

    return height;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::getLineWidth ( int &  pos) [private]

This getLineWidth() function returns the width of the smallest rectangle that contains the widgets in the given line.

It expects the first element of the line as the argument, and will set pos to the last element of the line, usually a break.

Definition at line 565 of file widget_manager.cpp.

{
    const int NUM_ELEMS = (int)m_elems.size();
    int width = 0;

    for( ; pos < NUM_ELEMS; ++pos )
    {
        switch( m_elems[ pos ].type)
        {
        case ET_WGT:
            width += m_widgets[ m_elems[ pos ].pos ].widget->m_width;
            break;

        case ET_BREAK:
            return width;

        case ET_SWITCH:
            ++pos;
            width += getColumnWidth( pos );
            break;
        }
    }

    return width;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::getSelectedWgt ( ) const [inline]

Definition at line 199 of file widget_manager.hpp.

Here is the caller graph for this function:

Definition at line 1882 of file widget_manager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::handleFinish ( const int  next_wgt) [private]

Definition at line 1890 of file widget_manager.cpp.

{
    if( next_wgt == WGT_NONE)
              return WGT_NONE;

    setSelectedWgtToken( m_widgets[next_wgt].token );
       return m_selected_wgt_token;
}

Here is the call graph for this function:

Here is the caller graph for this function:

The handle_<direction>() function stores the current widget under the cursor after receiving input from a key.

Definition at line 1858 of file widget_manager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int WidgetManager::handlePointer ( const int  X,
const int  Y 
)

The handlePointer() function returns the current widget under the pointer, if it's different from the selected widget.

If the widget under the pointer is the selected widget, it returns WGT_NONE.

Definition at line 1744 of file widget_manager.cpp.

{
    const int NUM_WGTS = (int)m_widgets.size();
    if( NUM_WGTS < 1 ) return WGT_NONE;

    //OpenGL provides a mechanism to select objects; simply 'draw' named
    //objects, and for each non-culled visible object a 'hit' will be saved
    //into a selection buffer. Objects are named by using OpenGL's name
    //stack. The information in each hit is the number of names in the name
    //stack, two hard-to-explain depth values that aren't used in this
    //function, and the contents of the name stack at the time of the hit.

    //This function loads 1 name into the stack (because if you pop an empty
    //stack you get an error), then uses glLoadName (which is a shortcut for
    //popping then pushing) to change the name. That means that each time a
    //hit is recorded, only the last drawn widget will be on the name stack.

    const int HIT_SIZE = 4; //1 Gluint for the number of names, 2 depth
                            //values, and 1 for the token of the widget.
    const int BUFFER_SIZE = HIT_SIZE * NUM_WGTS;

    GLuint* select_buffer = new GLuint[BUFFER_SIZE];
    glSelectBuffer(BUFFER_SIZE, select_buffer);

    glRenderMode(GL_SELECT);

    //Set the viewport to draw only what's under the mouse
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();

    GLint viewport[4];
    glGetIntegerv(GL_VIEWPORT,viewport);
    gluPickMatrix(X, Y, 1,1,viewport);
    glOrtho(0.0, user_config->m_width, 0.0, user_config->m_height, -1.0, 1.0);

    glMatrixMode(GL_MODELVIEW);

    glInitNames();
    glPushName(WGT_NONE);

    glPushMatrix();

    for( int i = 0; i < NUM_WGTS; ++i )
    {
        if(!(m_widgets[i].active)) continue;

        glLoadName( i );

        glPushMatrix();
        m_widgets[i].widget->applyTransformations();
        //In case this ever becomes a performance bottleneck:
        //the m_rect_list includes texture coordinates, which are not
        //needed for selection.
        glCallList( m_widgets[i].widget->m_rect_list );
        glPopMatrix();
    }
    glFlush();
    glPopMatrix();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);
    glFlush();

    GLuint* position = select_buffer;
    const GLint NUM_HITS = glRenderMode(GL_RENDER);

    if( NUM_HITS > 0 )
    {
        float dist;
        float near_dist = 9999999.0f;
        int curr_wgt_id;
        int nearest_id = WGT_NONE;
        int wgt_x_center, wgt_y_center;
        for( int i = 0; i < NUM_HITS; ++i )
        {
            position += 3;
            curr_wgt_id = *position;

            wgt_x_center = m_widgets[curr_wgt_id].widget->m_x +
                (m_widgets[i].widget->m_width / 2);
            wgt_y_center = m_widgets[curr_wgt_id].widget->m_y +
                (m_widgets[i].widget->m_height / 2);

            //Check if it's the closest one to the mouse
            dist = (float)( abs(X - wgt_x_center) + abs(Y - wgt_y_center));
            if(dist < near_dist )
            {
                near_dist = dist;
                nearest_id = curr_wgt_id;
            }

            ++position;
        }
        delete[] select_buffer;

        if( m_widgets[nearest_id].token == m_selected_wgt_token )
        {
            return WGT_NONE;
        }

        setSelectedWgtToken( m_widgets[nearest_id].token );
        return m_selected_wgt_token;
    }

    delete[] select_buffer;
    return WGT_NONE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1866 of file widget_manager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1874 of file widget_manager.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::hideWgtBorder ( const int  TOKEN)

Definition at line 1354 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_border = false;
    else
    {
        std::cerr << "WARNING: tried to hide the border of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::hideWgtRect ( const int  TOKEN)

Definition at line 1291 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_rect = false;
    else
    {
        std::cerr << "WARNING: tried to hide the rect of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::hideWgtText ( const int  TOKEN)

Definition at line 1502 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_text = false;
    else
    {
        std::cerr << "WARNING: tried to hide the text of an unnamed widget " <<
            "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::hideWgtTexture ( const int  TOKEN)

Definition at line 1404 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_texture = false;
    else
    {
        std::cerr << "WARNING: tried to hide the texture of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::hideWgtTrack ( const int  TOKEN)

Definition at line 1680 of file widget_manager.cpp.

{
    const int ID = findId( TOKEN );
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_track = false;
    else
    {
        std::cerr << "WARNING: tried to hide the track of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::increaseScrollSpeed ( bool  fast = false)

Definition at line 1900 of file widget_manager.cpp.

{
    //FIXME: to increase the scroll speed we substract, and to decrease
    //we add; this goes against logic, making code harder to read.
       const int ID = findId(m_selected_wgt_token);
       if( m_widgets[ID].widget->m_enable_scroll )
       {
        int &speed = m_widgets[ID].widget->m_scroll_speed_y;
              //FIXME: these increases shouldn't be in pixels, but in percentages.
              //This should increase it by 1%, and the page buttons by 5%.
        if( fast )
        {
            if( speed > 0 && speed < 50 ) speed = 0;
            else speed -= 50;
        }
        else
        {
            if( speed > 0 && speed < 10 ) speed = 0;
            else speed -= 10;
        }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::isEmpty ( ) [inline]

Definition at line 171 of file widget_manager.hpp.

{ return m_widgets.empty(); }

This argument-less layout() function serves as a recall to the other layout function in case you want to change the way widgets are put on the screen.

It calls layout(POSITION) with the last given position, forces the recalculation of the scrolling position (since after the change the text might not fit properly the widget), and the selected widget, since layout(POSITION) function changes the selected widget to the first active widget by default.

Definition at line 235 of file widget_manager.cpp.

{
    if( m_prev_layout_pos == WGT_AREA_NONE )
    {
        std::cerr << "WARNING: tried to call layout() with the previous " <<
            "layout position, but layout(WidgetArea POSITION) has never " <<
            "been called.\n";
        return false;
    }


    const int NUM_WIDGETS = (int)m_widgets.size();
    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        m_widgets[i].widget->m_scroll_pos_x =
            (float)m_widgets[i].last_preset_scroll_x;

        m_widgets[i].widget->m_scroll_pos_y =
            (float)m_widgets[i].last_preset_scroll_y;
    }


    const int PREV_SELECTED_WGT_TOKEN = m_selected_wgt_token;

    if( !layout( m_prev_layout_pos )) return false;

    if( findId( PREV_SELECTED_WGT_TOKEN ) != WGT_NONE )
    {
        setSelectedWgtToken( PREV_SELECTED_WGT_TOKEN );
    }

    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::layout ( const WidgetArea  POSITION)

Definition at line 270 of file widget_manager.cpp.

{
    //TODO: split layout(WidgetArea) into smaller functions
    if( POSITION == WGT_AREA_NONE )
    {
        std::cerr << "WARNING: called layout with WGT_AREA_NONE.\n";
        return false;
    }

    m_prev_layout_pos = POSITION;

    const int NUM_WIDGETS = (int)m_widgets.size();
    if( NUM_WIDGETS < 1 ) return true;

    const int SCREEN_WIDTH = user_config->m_width;
    const int SCREEN_HEIGHT = user_config->m_height;

    {
        int width, height;
        //Set the widgets' rect shape properties in pixels.
        for( int i = 0; i < NUM_WIDGETS; ++i )
        {
            width = (int)(SCREEN_WIDTH * m_widgets[i].min_width * 0.01);
            height = (int)(SCREEN_HEIGHT * m_widgets[i].min_height * 0.01);

            m_widgets[i].widget->m_width = width;
            m_widgets[i].widget->m_height = height;

            if( m_widgets[i].resize_to_text ) m_widgets[i].widget->
                resizeToText();

            if( width < height )
            {
                m_widgets[i].widget->m_radius = (int)( m_widgets[i].min_radius *
                    m_widgets[i].widget->m_width * 0.01 );
            }
            else
            {
                m_widgets[i].widget->m_radius = (int)( m_widgets[i].min_radius *
                    m_widgets[i].widget->m_height * 0.01 );
            }

            if( m_widgets[i].widget->m_radius < 1 )
            {
                m_widgets[i].widget->m_radius = 1;
            }
        }
    }

    const int WGTS_WIDTH = calcWidth();
    const int WGTS_HEIGHT = calcHeight();

    if( WGTS_WIDTH > SCREEN_WIDTH )
    {
        std::cerr << "WARNING: total width of the widgets is bigger than " <<
            "the screen, because the total minimum width given is bigger " <<
            "than 100%.\n";
    }
    if( WGTS_HEIGHT > SCREEN_HEIGHT )
    {
        std::cerr << "WARNING: total height of the widgets is bigger " <<
            "than the screen, because the total minimum height given is " <<
            "bigger than 100%.\n";
    }

    //To position things on the screen, remember that with OpenGL, in the
    //Y-axis the position 0 is in the bottom of the screen, just like the top
    //right quad of a cartesian plane.
    switch(POSITION)
    {
    case WGT_AREA_NW:
        m_x = 0;
        m_y = SCREEN_HEIGHT;
        break;

    case WGT_AREA_SW:
        m_x = 0;
        m_y = 0;
        break;

    case WGT_AREA_NE:
        m_x = SCREEN_WIDTH - WGTS_WIDTH;
        m_y = SCREEN_HEIGHT;
        break;

    case WGT_AREA_SE:
        m_x = SCREEN_WIDTH - WGTS_WIDTH;
        m_y = 0;
        break;

    case WGT_AREA_LFT:
        m_x = 0;
        m_y = (int)(SCREEN_HEIGHT * 0.5 + WGTS_HEIGHT * 0.5f );
        break;

    case WGT_AREA_RGT:
        m_x = SCREEN_WIDTH - WGTS_WIDTH;
        m_y = (int)(SCREEN_HEIGHT * 0.5 + WGTS_HEIGHT * 0.5f );
        break;

    case WGT_AREA_TOP:
        m_x = (int)(SCREEN_WIDTH * 0.5f - WGTS_WIDTH * 0.5f );
        m_y = SCREEN_HEIGHT;
        break;

    case WGT_AREA_BOT:
        m_x = (int)(SCREEN_WIDTH * 0.5f - WGTS_WIDTH * 0.5f );
        m_y = 0;
        break;

    case WGT_AREA_ALL:
        m_x = (int)(SCREEN_WIDTH * 0.5f - WGTS_WIDTH * 0.5f );
        m_y = (int)(SCREEN_HEIGHT * 0.5 + WGTS_HEIGHT * 0.5f );
        break;

    //This is just here to avoid a warning
    case WGT_AREA_NONE:
        break;
    }

    /* We have to give each widget it's pixel position and create their rect.
     * The position given to the widgets is their bottom left corner; since
     * OpenGL the bottom left corner of the screen for (0,0), it's easier
     * that way. Widgets are centered on the X-axis around their line or
     * column (if it's inside one), but are always stuck to the top of their
     * line or column.
     */

    int cursor_x = m_x + ( WGTS_WIDTH - calcLineWidth( 0 )) / 2;
    int cursor_y = m_y;
    int line_pos = 0;
    WidgetID* curr_wgt = 0;

    const int NUM_ELEMS = (int)m_elems.size();

    for( int i = 0; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[ i ].type )
        {
        case ET_WGT:
            curr_wgt = &m_widgets[ m_elems[ i ].pos ];

            curr_wgt->widget->m_x = cursor_x;

            //We have to give createRect() the bottom left corner
            curr_wgt->widget->m_y = cursor_y - curr_wgt->widget->m_height;

            if( !(curr_wgt->widget->createRect()) ) return false;

            cursor_x += curr_wgt->widget->m_width;
            break;

        case ET_BREAK:
            cursor_x = m_x + ( WGTS_WIDTH - calcLineWidth( i + 1 )) / 2;
            cursor_y -= calcLineHeight( line_pos );
            line_pos = i + 1;
            break;

        case ET_SWITCH:
            ++i;

            if( !layoutColumn( cursor_x, cursor_y, i )) return false;

            break;
        }
    }

    //Select the first active widget by default
    setSelectedWgtToken( WGT_NONE );

    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        if( m_widgets[i].active )
        {
            setSelectedWgtToken( m_widgets[i].token );
            break;
        }
    }

    return true;
}

Here is the call graph for this function:

bool WidgetManager::layoutColumn ( int &  x,
int &  y,
int &  pos 
) [private]

Definition at line 497 of file widget_manager.cpp.

{
    int cursor_x = x + calcColumnX( pos );
    int cursor_y = y;
    WidgetID* curr_wgt = 0;

    const int NUM_ELEMS = (int)m_elems.size();
    int i;

    for( i = pos; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[i].type )
        {
        case ET_WGT:
            curr_wgt = &m_widgets[ m_elems[ i ].pos ];

            curr_wgt->widget->m_x = cursor_x;

            //We have to give createRect() the bottom left corner
            curr_wgt->widget->m_y = cursor_y - curr_wgt->widget->m_height;

            if( !(curr_wgt->widget->createRect()) ) return false;

            if( i + 1 < NUM_ELEMS )
            {
                switch( m_elems[ i + 1 ].type )
                {
                    case ET_WGT:
                        cursor_x += ( curr_wgt->widget->m_width -
                            m_widgets[ m_elems[ i + 1 ].pos ].widget->
                            m_width ) / 2;
                        break;

                    case ET_SWITCH:
                        cursor_x += ( curr_wgt->widget->m_width -
                            calcLineWidth( i + 2 ) ) / 2;
                        break;

                    case ET_BREAK:
                        break;
                }

                cursor_y -= curr_wgt->widget->m_height;
            }
            break;

        case ET_BREAK:
            x += calcColumnWidth( pos );
            pos = i;
            return true;

        case ET_SWITCH:
            ++i;
            layoutLine( cursor_x, cursor_y, i );
            break;
        }
    }

    pos = i;
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool WidgetManager::layoutLine ( int &  x,
int &  y,
int &  pos 
) [private]

Definition at line 453 of file widget_manager.cpp.

{
    int cursor_x = x;
    int cursor_y = y;
    WidgetID* curr_wgt = 0;

    const int NUM_ELEMS = (int)m_elems.size();
    int i;

    for( i = pos; i < NUM_ELEMS; ++i )
    {
        switch( m_elems[ i ].type )
        {
        case ET_WGT:
            curr_wgt = &m_widgets[ m_elems[ i ].pos ];

            curr_wgt->widget->m_x = cursor_x;

            //We have to give createRect() the bottom left corner
            curr_wgt->widget->m_y = cursor_y - curr_wgt->widget->m_height;

            if( !(curr_wgt->widget->createRect()) ) return false;

            cursor_x += curr_wgt->widget->m_width;
            break;

        case ET_BREAK:
            x += ( calcLineWidth( pos ) - calcColumnWidth( i + 1 )) / 2;
            y = cursor_y - calcLineHeight( pos );
            pos = i;
            return true;

        case ET_SWITCH:
            ++i;
            layoutColumn( cursor_x, cursor_y, i );
            break;
        }
    }

    pos = i;
    return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::lightenWgtColor ( const int  TOKEN)

Definition at line 1717 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->lightenColor();
    else
    {
        std::cerr << "WARNING: tried to lighten an unnamed widget with " <<
            "token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::pulseWgt ( const int  TOKEN) const

pulse_widget() passes the pulse order to the right widget.

Definition at line 1705 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->pulse();
    else
    {
        std::cerr << "WARNING: tried to pulse unnamed widget with token " <<
            TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

reloadFonts() sets the pointers to the fonts of the guis to their choosen fonts; it's useful in cases where you free the font's memory (which makes the pointers invalid), then reload the fonts, like it happens when you change resolution on the Macs or Windows.

Definition at line 2199 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();
    for( int i = 0; i < NUM_WIDGETS; ++i )
    {
        m_widgets[i].widget->setFont(
            m_widgets[i].widget->m_curr_widget_font );
    }
}

Here is the caller graph for this function:

Definition at line 156 of file widget_manager.cpp.

{
    const int NUM_WIDGETS = (int)m_widgets.size();

    for(int i = 0; i < NUM_WIDGETS; ++i)
    {
        delete m_widgets[i].widget;
    }

    m_widgets.clear();
    m_elems.clear();

    restoreDefaultStates();

    m_selected_wgt_token = WGT_NONE;
    m_selection_change = false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::resizeWgtToText ( const int  TOKEN)

Definition at line 2169 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE )
    {
        m_widgets[ID].widget->resizeToText();

        const int SCREEN_WIDTH = user_config->m_width;
        const int SCREEN_HEIGHT = user_config->m_height;

        m_widgets[ID].min_width = ( m_widgets[ID].widget->m_width * 100 ) /
            SCREEN_WIDTH;
        m_widgets[ID].min_height = ( m_widgets[ID].widget->m_height * 100 ) /
            SCREEN_HEIGHT;

        layout();
    }
    else
    {
        std::cerr << "WARNING: tried to resize the text of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

bool WidgetManager::selectionChanged ( ) const [inline]

Definition at line 203 of file widget_manager.hpp.

{ return m_selection_change; }

Here is the caller graph for this function:

void WidgetManager::setInitialActivationState ( const bool  ACTIVE)

Definition at line 1067 of file widget_manager.cpp.

{
    m_default_active = ACTIVE;
}

Here is the caller graph for this function:

void WidgetManager::setInitialBorderState ( const bool  SHOW,
const int  PERCENTAGE,
const GLfloat *const  COLOR 
)

Definition at line 1089 of file widget_manager.cpp.

void WidgetManager::setInitialRectState ( const bool  SHOW,
const WidgetArea  ROUND_CORNERS,
const int  RADIUS,
const GLfloat *const  COLOR 
)

Definition at line 1074 of file widget_manager.cpp.

void WidgetManager::setInitialRotationState ( const bool  ENABLE,
const float  ANGLE,
const int  SPEED 
)

Definition at line 1149 of file widget_manager.cpp.

void WidgetManager::setInitialScrollState ( const bool  ENABLE,
const WidgetScrollPos  X_POS,
const WidgetScrollPos  Y_POS,
const int  X_SPEED,
const int  Y_SPEED 
)
void WidgetManager::setInitialTextState ( const bool  SHOW,
const std::string  TEXT,
const WidgetFontSize  SIZE,
const WidgetFont  FONT,
const GLfloat *const  COLOR,
const bool  RESIZE_WGT 
)

Definition at line 1113 of file widget_manager.cpp.

Here is the caller graph for this function:

void WidgetManager::setInitialTextureState ( const bool  SHOW,
const int  TEXTURE 
)

Definition at line 1102 of file widget_manager.cpp.

void WidgetManager::setInitialTrackState ( const bool  SHOW,
const int  TRACK 
)

Definition at line 1162 of file widget_manager.cpp.

void WidgetManager::setSelectedWgt ( const int  TOKEN)

Definition at line 905 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE )
    {
        setSelectedWgtToken( TOKEN );
    }
    else std::cerr << "WARNING: tried to select unnamed widget with " <<
        "token " << TOKEN << '\n';
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setSelectedWgtToken ( const int  TOKEN) [private]

Definition at line 2159 of file widget_manager.cpp.

{
    if( m_selected_wgt_token != TOKEN )
    {
        m_selected_wgt_token = TOKEN;
        m_selection_change = true;
    }
}

Here is the caller graph for this function:

void WidgetManager::setWgtBorderColor ( const int  TOKEN,
const GLfloat *const  COLOR 
)

Definition at line 1303 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_border_color = COLOR;
    else
    {
        std::cerr << "WARNING: tried to change the border color of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtBorderPercentage ( const int  TOKEN,
const int  PERCENTAGE 
)

Definition at line 1315 of file widget_manager.cpp.

{
    if( PERCENTAGE > 100 )
    {
        std::cerr << "WARNING: tried to set the border's percentage of " <<
            "widget with token " << TOKEN << " to something bigger than " <<
            "100% \n";
        return;
    }
    else if( PERCENTAGE < 1 )
    {
        std::cerr << "WARNING: tried to set the border's percentage of " <<
            "widget with token " << TOKEN << " to something smaller than " <<
            "1% \n";
        return;
    }

    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_border_percentage = PERCENTAGE * 0.01f;
    else
    {
        std::cerr << "WARNING: tried to change the rect color of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtColor ( const int  TOKEN,
const GLfloat *const  COLOR 
)

Definition at line 1228 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_rect_color = COLOR;
    else
    {
        std::cerr << "WARNING: tried to change the rect color of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtCornerRadius ( const int  TOKEN,
const int  RADIUS 
)

Definition at line 1252 of file widget_manager.cpp.

{
    if( RADIUS > 50 )
    {
        std::cerr << "WARNING: tried to set the corner's radius " <<
            "percentage of a widget with token " << TOKEN << " to " <<
            "something bigger than 50% \n";
        return;
    }
    else if( RADIUS < 1 )
    {
        std::cerr << "WARNING: tried to set the corner's radius " <<
            "percentage of a widget with token " << TOKEN << " to " <<
            "something smaller than 1% \n";
        return;
    }

    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].min_radius = RADIUS;
    else
    {
        std::cerr << "WARNING: tried to change the corner radius of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtFont ( const int  TOKEN,
const WidgetFont  FONT 
)

Definition at line 1454 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->setFont( FONT );
    else
    {
        std::cerr << "WARNING: tried to set the font of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtResizeToText ( const int  TOKEN,
const bool  RESIZE 
)

Definition at line 1478 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].resize_to_text = RESIZE;
    else
    {
        std::cerr << "WARNING: tried to set the resize to text value of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtRotationAngle ( const int  TOKEN,
const float  ANGLE 
)

Definition at line 1644 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_rotation_angle = ANGLE;
    else
    {
        std::cerr << "WARNING: tried to set the rotation angle of an "
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtRotationSpeed ( const int  TOKEN,
const int  SPEED 
)

Definition at line 1656 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_rotation_speed = SPEED;
    else
    {
        std::cerr << "WARNING: tried to set the rotation speed of an "
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtRoundCorners ( const int  TOKEN,
const WidgetArea  CORNERS 
)

Definition at line 1240 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_round_corners = CORNERS;
    else
    {
        std::cerr << "WARNING: tried to change the round corners of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtText ( const int  TOKEN,
const char *  TEXT 
)

Definition at line 1416 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE )
    {
        m_widgets[ID].widget->m_text = TEXT;

        //Reset the scroll position, because it will be the wrong value if
        //new text has a different size
        m_widgets[ID].widget->m_scroll_pos_x = (float)m_widgets[ID].last_preset_scroll_x;
        m_widgets[ID].widget->m_scroll_pos_y = (float)m_widgets[ID].last_preset_scroll_y;
    }
    else
    {
        std::cerr << "WARNING: tried to set text to an unnamed widget " <<
            "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtText ( const int  TOKEN,
const std::string  TEXT 
)

Definition at line 1436 of file widget_manager.cpp.

{
    setWgtText( TOKEN, TEXT.c_str());
}

Here is the call graph for this function:

void WidgetManager::setWgtTextColor ( const int  TOKEN,
const GLfloat *const  COLOR 
)

Definition at line 1466 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_color = COLOR;
    else
    {
        std::cerr << "WARNING: tried to set the text color of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtTextSize ( const int  TOKEN,
const WidgetFontSize  SIZE 
)

Definition at line 1442 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_text_size = SIZE;
    else
    {
        std::cerr << "WARNING: tried to set the text size of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtTexture ( const int  TOKEN,
const int  TEXTURE 
)

Definition at line 1367 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_texture = TEXTURE;
    else
    {
        std::cerr << "WARNING: tried to set the texture of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtTexture ( const int  TOKEN,
const char *  FILENAME,
const bool  is_full_path = true 
)

Definition at line 1379 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->setTexture( FILENAME, is_full_path );
    else
    {
        std::cerr << "WARNING: tried to set the texture of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtTrackNum ( const int  TOKEN,
const int  TRACK 
)

Definition at line 1692 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_track_num = TRACK;
    else
    {
        std::cerr << "WARNING: tried to set the track number of an unnamed "
            << "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtXScrollPos ( const int  TOKEN,
const WidgetScrollPos  POS 
)

Definition at line 1539 of file widget_manager.cpp.

{
    if( POS == WGT_SCROLL_START_TOP || POS == WGT_SCROLL_START_BOTTOM ||
        POS == WGT_SCROLL_END_TOP || POS == WGT_SCROLL_END_BOTTOM )
    {
        std::cerr << "WARNING: tried to set the X scroll position to a " <<
            "position for the Y axis, on widget with token " << TOKEN <<
            '\n';
        return;
    }

    const int ID = findId(TOKEN);
    if( ID != WGT_NONE )
    {
        m_widgets[ID].widget->m_scroll_pos_x = (float)POS;
        m_widgets[ID].last_preset_scroll_x = POS;
    }
    else
    {
        std::cerr << "WARNING: tried to set the X scroll position of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtXScrollSpeed ( const int  TOKEN,
const int  SPEED 
)

Definition at line 1596 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_x = SPEED;
    else
    {
        std::cerr << "WARNING: tried to set the X scroll speed of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

void WidgetManager::setWgtYScrollPos ( const int  TOKEN,
const WidgetScrollPos  POS 
)

Definition at line 1568 of file widget_manager.cpp.

{
    if( POS == WGT_SCROLL_START_LEFT || POS == WGT_SCROLL_START_RIGHT ||
        POS == WGT_SCROLL_END_LEFT || POS == WGT_SCROLL_END_RIGHT )
    {
        std::cerr << "WARNING: tried to set the Y scroll position to a " <<
            "position for the X axis, on widget with token " << TOKEN <<
            '\n';
        return;
    }

    const int ID = findId(TOKEN);
    if( ID != WGT_NONE )
    {
        m_widgets[ID].widget->m_scroll_pos_y = (float)POS;
        m_widgets[ID].last_preset_scroll_y = POS;
    }
    else
    {
        std::cerr << "WARNING: tried to set the Y scroll position of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::setWgtYScrollSpeed ( const int  TOKEN,
const int  SPEED 
)

Definition at line 1608 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_scroll_speed_y = SPEED;
    else
    {
        std::cerr << "WARNING: tried to set the Y scroll speed of an " <<
            "unnamed widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::showWgtBorder ( const int  TOKEN)

Definition at line 1342 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_border = true;
    else
    {
        std::cerr << "WARNING: tried to show the border of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::showWgtRect ( const int  TOKEN)

Definition at line 1279 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_rect = true;
    else
    {
        std::cerr << "WARNING: tried to show the rect of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::showWgtText ( const int  TOKEN)

Definition at line 1490 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_text = true;
    else
    {
        std::cerr << "WARNING: tried to show the text of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::showWgtTexture ( const int  TOKEN)

Definition at line 1392 of file widget_manager.cpp.

{
    const int ID = findId(TOKEN);
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_texture = true;
    else
    {
        std::cerr << "WARNING: tried to show the texture of an unnamed " <<
            "widget with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void WidgetManager::showWgtTrack ( const int  TOKEN)

Definition at line 1668 of file widget_manager.cpp.

{
    const int ID = findId( TOKEN );
    if( ID != WGT_NONE ) m_widgets[ID].widget->m_enable_track = true;
    else
    {
        std::cerr << "WARNING: tried to show the track of an unnamed widget "
            << "with token " << TOKEN << '\n';
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 125 of file widget_manager.cpp.

{
    m_elems.push_back( WidgetElement( ET_SWITCH, 0 ));
}

Here is the caller graph for this function:

void WidgetManager::update ( const float  DELTA)

Definition at line 189 of file widget_manager.cpp.

{
    m_selection_change = false;

    //Enable 2D rendering
    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    glLoadIdentity();
    glOrtho(0.0, user_config->m_width, 0.0, user_config->m_height, -1.0, 1.0);
    glMatrixMode(GL_MODELVIEW);

    glPushAttrib(GL_LIGHTING_BIT |
        GL_COLOR_BUFFER_BIT |
        GL_DEPTH_BUFFER_BIT |
        GL_STENCIL_BUFFER_BIT);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_COLOR_MATERIAL);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);
    glEnable (GL_STENCIL_TEST);

    const int NUM_WIDGETS = (int)m_widgets.size();
    for( int i = 0; i < NUM_WIDGETS; ++i)
    {
        m_widgets[i].widget->update(DELTA);
    }

    glPopAttrib();

    glMatrixMode(GL_PROJECTION);
    glPopMatrix();
    glMatrixMode(GL_MODELVIEW);

}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 98 of file widget_manager.hpp.

const GLfloat* WidgetManager::m_default_border_color [private]

Definition at line 108 of file widget_manager.hpp.

Definition at line 107 of file widget_manager.hpp.

Definition at line 125 of file widget_manager.hpp.

Definition at line 119 of file widget_manager.hpp.

Definition at line 116 of file widget_manager.hpp.

const GLfloat* WidgetManager::m_default_rect_color [private]

Definition at line 104 of file widget_manager.hpp.

Definition at line 103 of file widget_manager.hpp.

Definition at line 102 of file widget_manager.hpp.

Definition at line 99 of file widget_manager.hpp.

Definition at line 126 of file widget_manager.hpp.

Definition at line 127 of file widget_manager.hpp.

Definition at line 120 of file widget_manager.hpp.

Definition at line 121 of file widget_manager.hpp.

Definition at line 122 of file widget_manager.hpp.

Definition at line 123 of file widget_manager.hpp.

Definition at line 106 of file widget_manager.hpp.

Definition at line 101 of file widget_manager.hpp.

Definition at line 113 of file widget_manager.hpp.

Definition at line 110 of file widget_manager.hpp.

Definition at line 129 of file widget_manager.hpp.

std::string WidgetManager::m_default_text [private]

Definition at line 114 of file widget_manager.hpp.

const GLfloat* WidgetManager::m_default_text_color [private]

Definition at line 117 of file widget_manager.hpp.

Definition at line 115 of file widget_manager.hpp.

Definition at line 111 of file widget_manager.hpp.

Definition at line 130 of file widget_manager.hpp.

std::vector<WidgetElement> WidgetManager::m_elems [private]

Definition at line 87 of file widget_manager.hpp.

Definition at line 90 of file widget_manager.hpp.

Definition at line 95 of file widget_manager.hpp.

Definition at line 96 of file widget_manager.hpp.

std::vector<WidgetID> WidgetManager::m_widgets [private]

Definition at line 88 of file widget_manager.hpp.

int WidgetManager::m_x [private]

Definition at line 92 of file widget_manager.hpp.

int WidgetManager::m_y [private]

Definition at line 93 of file widget_manager.hpp.

const int WidgetManager::WGT_NONE = -1 [static]

Definition at line 166 of file widget_manager.hpp.


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