ui_icon.c File Reference

#include "ui_main.h"
#include "ui_internal.h"
#include "ui_parse.h"
#include "ui_icon.h"
#include "ui_render.h"
Include dependency graph for ui_icon.c:

Go to the source code of this file.

Defines

#define TILE_HEIGHT   64
 normal, hovered, disabled, highlighted status are store in the same texture 256x256. Each use a row of 64 pixels

Functions

static uiIcon_tUI_AutoGenerateIcon (const char *name)
 Search a file name inside pics/icons/ according to the icon name If it exists, generate a "single" icon using the size of the image.
uiIcon_tUI_GetIconByName (const char *name)
 Return an icon by is name.
uiIcon_tUI_AllocStaticIcon (const char *name)
 Allocate an icon to the UI static memory.
void UI_DrawIconInBox (const uiIcon_t *icon, uiIconStatus_t status, int posX, int posY, int sizeX, int sizeY)

Variables

const value_t mn_iconProperties []

Detailed Description

Definition in file ui_icon.c.


Define Documentation

#define TILE_HEIGHT   64

normal, hovered, disabled, highlighted status are store in the same texture 256x256. Each use a row of 64 pixels

Definition at line 35 of file ui_icon.c.

Referenced by UI_DrawIconInBox(), UI_TabNodeDraw(), UI_TabNodeDrawJunction(), UI_TabNodeDrawPlain(), and UI_VScrollbarNodeDraw().


Function Documentation

uiIcon_t* UI_AllocStaticIcon ( const char *  name  ) 

Allocate an icon to the UI static memory.

Note:
Its not a dynamic memory allocation. Please only use it at the loading time
Parameters:
[in] name Name of the icon
Todo:
Assert out when we are not in parsing/loading stage

Todo:
understand why we must hide this assert in release build with mingw

Definition at line 133 of file ui_icon.c.

References Com_Error(), ERR_FATAL, uiGlobal_s::icons, uiIcon_s::name, uiGlobal_s::numIcons, Q_strncpyz(), ui_global, and UI_MAX_ICONS.

Referenced by UI_AutoGenerateIcon(), and UI_ParseIcon().

static uiIcon_t* UI_AutoGenerateIcon ( const char *  name  )  [static]

Search a file name inside pics/icons/ according to the icon name If it exists, generate a "single" icon using the size of the image.

Parameters:
name Name of the icon
Returns:
An icon, else NULL

Definition at line 67 of file ui_icon.c.

References image_s::height, i, ICON_STATUS_MAX, ICON_STATUS_NORMAL, uiIcon_s::image, uiIcon_s::size, UI_AllocStaticIcon(), UI_AllocStaticString(), UI_LoadImage(), va(), and image_s::width.

Referenced by UI_GetIconByName().

void UI_DrawIconInBox ( const uiIcon_t icon,
uiIconStatus_t  status,
int  posX,
int  posY,
int  sizeX,
int  sizeY 
)
Parameters:
[in] status The state of the icon node
[in] icon Context icon
[in] posX Absolute X position of the top-left corner
[in] posY Absolute Y position of the top-left corner
[in] sizeX Width of the bounded box
[in] sizeY Height of the bounded box
Todo:
use named const for status

Todo:
Add warning
Todo:
merge all this cases

Definition at line 160 of file ui_icon.c.

References uiIcon_s::blend, uiIcon_s::color, ICON_STATUS_MAX, ICON_STATUS_NORMAL, uiIcon_s::image, uiIcon_s::pack64, uiIcon_s::pos, R_Color(), uiIcon_s::single, uiIcon_s::size, TILE_HEIGHT, and UI_DrawNormImageByName().

Referenced by UI_ButtonNodeDraw(), UI_CustomButtonNodeDraw(), UI_MessageDraw(), UI_OptionListNodeDraw(), UI_OptionTreeNodeDraw(), UI_RadioButtonNodeDraw(), and UI_TabNodeDraw().

uiIcon_t* UI_GetIconByName ( const char *  name  ) 

Return an icon by is name.

Parameters:
[in] name Name of the icon
Returns:
The requested icon, else NULL
Note:
not very fast; if we use it often we should improve the search

Definition at line 116 of file ui_icon.c.

References uiGlobal_s::icons, MEMBER_SIZEOF, uiIcon_s::name, uiGlobal_s::numIcons, UI_AutoGenerateIcon(), and ui_global.

Referenced by UI_InitRawActionValue(), UI_MessageGetIcon(), UI_OptionTreeNodeDraw(), UI_ParseProperty(), and UP_GenerateSummary().


Variable Documentation

Initial value:
 {
    {"size", V_POS, offsetof(uiIcon_t, size), MEMBER_SIZEOF(uiIcon_t, size)},
    {"single", V_BOOL, offsetof(uiIcon_t, single), 0},
    {"blend", V_BOOL, offsetof(uiIcon_t, blend), 0},
    {"pack64", V_BOOL, offsetof(uiIcon_t, pack64), 0},

    {"texl", V_POS, offsetof(uiIcon_t, pos[ICON_STATUS_NORMAL]), MEMBER_SIZEOF(uiIcon_t, pos[ICON_STATUS_NORMAL])},
    {"hoveredtexl", V_POS, offsetof(uiIcon_t, pos[ICON_STATUS_HOVER]), MEMBER_SIZEOF(uiIcon_t, pos[ICON_STATUS_HOVER])},
    {"disabledtexl", V_POS, offsetof(uiIcon_t, pos[ICON_STATUS_DISABLED]), MEMBER_SIZEOF(uiIcon_t, pos[ICON_STATUS_DISABLED])},
    {"clickedtexl", V_POS, offsetof(uiIcon_t, pos[ICON_STATUS_CLICKED]), MEMBER_SIZEOF(uiIcon_t, pos[ICON_STATUS_CLICKED])},

    {"image", V_REF_OF_STRING, offsetof(uiIcon_t, image[ICON_STATUS_NORMAL]), 0},
    {"hoveredimage", V_REF_OF_STRING, offsetof(uiIcon_t, image[ICON_STATUS_HOVER]), 0},
    {"disabledimage", V_REF_OF_STRING, offsetof(uiIcon_t, image[ICON_STATUS_DISABLED]), 0},
    {"clickedimage", V_REF_OF_STRING, offsetof(uiIcon_t, image[ICON_STATUS_CLICKED]), 0},

    {"color", V_COLOR, offsetof(uiIcon_t, color[ICON_STATUS_NORMAL]), MEMBER_SIZEOF(uiIcon_t, color[ICON_STATUS_NORMAL])},
    {"hoveredcolor", V_COLOR, offsetof(uiIcon_t, color[ICON_STATUS_HOVER]), MEMBER_SIZEOF(uiIcon_t, color[ICON_STATUS_HOVER])},
    {"disabledcolor", V_COLOR, offsetof(uiIcon_t, color[ICON_STATUS_DISABLED]), MEMBER_SIZEOF(uiIcon_t, color[ICON_STATUS_DISABLED])},
    {"clickedcolor", V_COLOR, offsetof(uiIcon_t, color[ICON_STATUS_CLICKED]), MEMBER_SIZEOF(uiIcon_t, color[ICON_STATUS_CLICKED])},

    {NULL, V_NULL, 0, 0}
}

Definition at line 37 of file ui_icon.c.

Referenced by UI_ParseIcon().


Generated by  doxygen 1.6.2