UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node_panel.cpp File Reference
#include "../ui_main.h"
#include "../ui_parse.h"
#include "../ui_behaviour.h"
#include "../ui_render.h"
#include "../ui_actions.h"
#include "../ui_input.h"
#include "../ui_sprite.h"
#include "../ui_lua.h"
#include "ui_node_abstractnode.h"
#include "ui_node_panel.h"
#include "../../../common/scripts.h"
#include "../../input/cl_keys.h"
#include "../../../common/scripts_lua.h"

Go to the source code of this file.

Macros

#define EXTRADATA_TYPE   panelExtraData_t
 
#define EXTRADATA(node)   UI_EXTRADATA(node, EXTRADATA_TYPE)
 
#define EXTRADATACONST(node)   UI_EXTRADATACONST(node, EXTRADATA_TYPE)
 

Functions

static void UI_TopDownFlowLayout (uiNode_t *node, int margin)
 Create a top-down flow layout with child of the node. Child position is automatically set, child height don't change and child width is set according to node width and padding. More...
 
static void UI_LeftRightFlowLayout (uiNode_t *node, int margin)
 Create a left-right flow layout with child of the node. Child position is automatically set, child width don't change and child height is set according to node width and padding. More...
 
static void UI_BorderLayout (uiNode_t *node, int margin)
 Create a border layout with child of the node. Child with BORDERLAYOUT_TOP and BORDERLAYOUT_BOTTOM num are first positioned, there height do not change but the width fill the parent node. Then child with BORDERLAYOUT_LEFT and BORDERLAYOUT_RIGHT are positioned between positioned nodes. Finally BORDERLAYOUT_MIDDLE is filled into available free space. More...
 
static void UI_PackLayout (uiNode_t *node, int margin)
 Create a pack layout with child of the node. Set position and size of nodes one by one. It is a usefull layout manager because it can create nice layout without sub panel. More...
 
void UI_StarLayout (uiNode_t *node)
 Do a star layout with child according to there num. More...
 
static void UI_ClientLayout (uiNode_t *node)
 
static void UI_ColumnLayout (uiNode_t *node)
 Do column layout. A grid layout according to a fixed number of column. Check to first row to see the needed size of columns, and the height. All rows will use the same row. More...
 
void UI_Panel_SetBackgroundByName (uiNode_t *node, const char *name)
 
void UI_RegisterPanelNode (uiBehaviour_t *behaviour)
 

Variables

static const value_tpropertyLayoutMargin
 
static const value_tpropertyLayoutColumns
 
static const value_tpropertyPadding
 
static const uiBehaviour_tlocalBehaviour
 
static int mouseScrollX
 
static int mouseScrollY
 

Macro Definition Documentation

#define EXTRADATA_TYPE   panelExtraData_t

Definition at line 41 of file ui_node_panel.cpp.

Referenced by UI_RegisterPanelNode().

#define EXTRADATACONST (   node)    UI_EXTRADATACONST(node, EXTRADATA_TYPE)

Definition at line 43 of file ui_node_panel.cpp.

Referenced by uiPanelNode::getClientPosition().

Function Documentation

static void UI_BorderLayout ( uiNode_t node,
int  margin 
)
static

Create a border layout with child of the node. Child with BORDERLAYOUT_TOP and BORDERLAYOUT_BOTTOM num are first positioned, there height do not change but the width fill the parent node. Then child with BORDERLAYOUT_LEFT and BORDERLAYOUT_RIGHT are positioned between positioned nodes. Finally BORDERLAYOUT_MIDDLE is filled into available free space.

Parameters
[in,out]nodeThe panel node to render the children for
[in]marginThe margin between all children nodes in their y-position of the panel
Note
test only

Definition at line 149 of file ui_node_panel.cpp.

References uiNode_t::align, uiNode_t::box, uiNode_t::firstChild, uiNode_t::invis, LAYOUTALIGN_BOTTOM, LAYOUTALIGN_LEFT, LAYOUTALIGN_MIDDLE, LAYOUTALIGN_RIGHT, LAYOUTALIGN_TOP, uiNode_t::next, uiNode_t::padding, uiBox_t::pos, uiBox_t::size, and UI_NodeSetSize().

Referenced by uiPanelNode::doLayout().

static void UI_ClientLayout ( uiNode_t node)
static
static void UI_ColumnLayout ( uiNode_t node)
static

Do column layout. A grid layout according to a fixed number of column. Check to first row to see the needed size of columns, and the height. All rows will use the same row.

Todo:
Use child@align to align each nodes inside respective cell.
Layout_column.png

Definition at line 368 of file ui_node_panel.cpp.

References uiNode_t::box, Com_Printf(), EXTRADATA, uiNode_t::firstChild, i, Mem_AllocTypeN, Mem_Free, uiNode_t::next, uiNode_t::padding, uiBox_t::pos, uiBox_t::size, UI_ExecuteEventActions(), UI_ExecuteLuaEventScript(), UI_GetPath(), and UI_Node_DoLayout().

Referenced by uiPanelNode::doLayout().

static void UI_LeftRightFlowLayout ( uiNode_t node,
int  margin 
)
static

Create a left-right flow layout with child of the node. Child position is automatically set, child width don't change and child height is set according to node width and padding.

Parameters
[in,out]nodeThe panel node to render the children for
[in]marginThe margin between all children nodes in their x-position of the panel

Definition at line 117 of file ui_node_panel.cpp.

References uiNode_t::box, uiNode_t::firstChild, uiNode_t::next, uiNode_t::padding, uiBox_t::pos, uiBox_t::size, UI_Node_IsDrawable(), UI_NodeSetSize(), and Vector2FromInt.

Referenced by uiPanelNode::doLayout().

static void UI_PackLayout ( uiNode_t node,
int  margin 
)
static

Create a pack layout with child of the node. Set position and size of nodes one by one. It is a usefull layout manager because it can create nice layout without sub panel.

Parameters
[in,out]nodeThe panel node to render the children for
[in]marginThe margin between all children nodes
Note
test only

Definition at line 238 of file ui_node_panel.cpp.

References uiNode_t::box, uiNode_t::firstChild, LAYOUTALIGN_BOTTOM, LAYOUTALIGN_FILL, LAYOUTALIGN_LEFT, LAYOUTALIGN_RIGHT, LAYOUTALIGN_TOP, uiNode_t::next, uiNode_t::padding, uiBox_t::size, and UI_NodeSetSize().

Referenced by uiPanelNode::doLayout().

void UI_Panel_SetBackgroundByName ( uiNode_t node,
const char *  name 
)

Definition at line 597 of file ui_node_panel.cpp.

References UI_EXTRADATA, and UI_GetSpriteByName().

Referenced by uiPanelNode_t_set_background().

void UI_RegisterPanelNode ( uiBehaviour_t behaviour)

Select a layout manager to set position and size of child. Most of layout manager do not move or resize child without align property set. In the image, number identify the position of the child into node, and same color identify the same node. Text on child display the value of the "align" property of each child.

  • 0: no layout manager. Child keep there position and there size.
  • LAYOUT_TOP_DOWN_FLOW: layout child from top to down. Only child height do not change.
  • LAYOUT_PACK: Pack one by one child into the available space of the node.
  • LAYOUT_BORDER: Align nodes at a know position. Its look like pack layout, but the order is not the same. top and bottom child first, then left and right, then middle. We can show the difference into the image.
  • LAYOUT_STAR: Align the corner of child into the corner of the node. Child size do not change.
    Layout.png

Margin use to layout children (margin between children)

Number of column use to layout children (used with LAYOUT_COLUMN)

If scrolling via mousewheel is enabled

Definition at line 602 of file ui_node_panel.cpp.

References Com_RegisterConstInt(), uiBehaviour_t::extends, EXTRADATA_TYPE, uiBehaviour_t::extraDataSize, LAYOUT_BORDER, LAYOUT_CLIENT, LAYOUT_COLUMN, LAYOUT_LEFT_RIGHT_FLOW, LAYOUT_PACK, LAYOUT_STAR, LAYOUT_TOP_DOWN_FLOW, LAYOUTALIGN_BOTTOM, LAYOUTALIGN_BOTTOMLEFT, LAYOUTALIGN_BOTTOMRIGHT, LAYOUTALIGN_FILL, LAYOUTALIGN_LEFT, LAYOUTALIGN_MIDDLE, LAYOUTALIGN_RIGHT, LAYOUTALIGN_TOP, LAYOUTALIGN_TOPLEFT, LAYOUTALIGN_TOPRIGHT, uiBehaviour_t::lua_SWIG_typeinfo, uiBehaviour_t::manager, uiBehaviour_t::name, UI_RegisterExtradataNodeProperty, UI_SWIG_TypeQuery(), V_BOOL, V_INT, and V_UI_SPRITEREF.

void UI_StarLayout ( uiNode_t node)

Do a star layout with child according to there num.

Note
1=top-left 2=top-middle 3=top-right 4=middle-left 5=middle-middle 6=middle-right 7=bottom-left 8=bottom-middle 9=bottom-right 10=fill
Todo:
Tag it static when it is possible

Definition at line 304 of file ui_node_panel.cpp.

References uiNode_t::align, uiNode_t::box, uiNode_t::firstChild, LAYOUTALIGN_FILL, LAYOUTALIGN_NONE, LAYOUTALIGN_SPECIAL, uiNode_t::next, uiBox_t::size, UI_Node_DoLayout(), UI_NodeGetPoint(), UI_NodeRelativeToAbsolutePoint(), and UI_NodeSetSize().

Referenced by uiPanelNode::doLayout(), and uiWindowNode::doLayout().

static void UI_TopDownFlowLayout ( uiNode_t node,
int  margin 
)
static

Create a top-down flow layout with child of the node. Child position is automatically set, child height don't change and child width is set according to node width and padding.

Parameters
[in,out]nodeThe panel node to render the children for
[in]marginThe margin between all children nodes in their y-position of the panel
Note
test only

Definition at line 73 of file ui_node_panel.cpp.

References uiNode_t::box, EXTRADATA, uiNode_t::firstChild, uiNode_t::next, uiNode_t::padding, uiBox_t::pos, uiBox_t::size, UI_ExecuteEventActions(), UI_ExecuteLuaEventScript(), UI_Node_IsDrawable(), UI_NodeSetSize(), and Vector2FromInt.

Referenced by uiPanelNode::doLayout().

Variable Documentation

const uiBehaviour_t* localBehaviour
static

Definition at line 49 of file ui_node_panel.cpp.

int mouseScrollX
static
int mouseScrollY
static
const value_t* propertyLayoutColumns
static

Definition at line 46 of file ui_node_panel.cpp.

const value_t* propertyLayoutMargin
static

Definition at line 45 of file ui_node_panel.cpp.

const value_t* propertyPadding
static

Definition at line 47 of file ui_node_panel.cpp.