UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_rows.cpp
Go to the documentation of this file.
1
5
6
/*
7
Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9
This program is free software; you can redistribute it and/or
10
modify it under the terms of the GNU General Public License
11
as published by the Free Software Foundation; either version 2
12
of the License, or (at your option) any later version.
13
14
This program is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18
See the GNU General Public License for more details.
19
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24
*/
25
26
#include "
../ui_behaviour.h
"
27
#include "
../ui_render.h
"
28
#include "
ui_node_rows.h
"
29
#include "
ui_node_abstractnode.h
"
30
31
#include "
../../../common/scripts_lua.h
"
32
33
#define EXTRADATA_TYPE rowsExtraData_t
34
#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
35
#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
36
40
void
uiRowsNode::draw
(
uiNode_t
* node)
41
{
42
int
current = 0;
43
int
i
=
EXTRADATA
(node).current;
44
vec2_t
pos;
45
UI_GetNodeAbsPos
(node, pos);
46
47
while
(current < node->box.size[1]) {
48
const
float
* color;
49
const
int
height = std::min(
EXTRADATA
(node).lineHeight, (
int
)node->
box
.
size
[1] - current);
50
51
if
(
i
% 2)
52
color = node->
color
;
53
else
54
color = node->
selectedColor
;
55
UI_DrawFill
(pos[0], pos[1] + current, node->
box
.
size
[0], height, color);
56
current += height;
57
i
++;
58
}
59
}
60
61
void
uiRowsNode::onLoaded
(
uiNode_t
* node)
62
{
63
/* prevent infinite loop into the draw */
64
if
(
EXTRADATA
(node).lineHeight == 0) {
65
EXTRADATA
(node).lineHeight = 10;
66
}
67
}
68
69
void
UI_RegisterRowsNode
(
uiBehaviour_t
* behaviour)
70
{
71
behaviour->
name
=
"rows"
;
72
behaviour->
manager
=
UINodePtr
(
new
uiRowsNode
());
73
behaviour->
extraDataSize
=
sizeof
(
EXTRADATA_TYPE
);
74
behaviour->
lua_SWIG_typeinfo
=
UI_SWIG_TypeQuery
(
"uiRowsNode_t *"
);
75
76
/* Background color for odd elements */
77
UI_RegisterNodeProperty
(behaviour,
"color1"
,
V_COLOR
,
uiNode_t
, color);
78
/* Background color for even elements */
79
UI_RegisterNodeProperty
(behaviour,
"color2"
,
V_COLOR
,
uiNode_t
, selectedColor);
80
/* Element height */
81
UI_RegisterExtradataNodeProperty
(behaviour,
"lineheight"
,
V_INT
,
rowsExtraData_t
, lineHeight);
82
/* Element number on the top of the list. It is used to scroll the node content. */
83
UI_RegisterExtradataNodeProperty
(behaviour,
"current"
,
V_INT
,
rowsExtraData_t
, current);
84
}
uiRowsNode
Definition
ui_node_rows.h:29
uiRowsNode::draw
void draw(uiNode_t *node) override
Handles Button draw.
Definition
ui_node_rows.cpp:40
uiRowsNode::onLoaded
void onLoaded(uiNode_t *node) override
Definition
ui_node_rows.cpp:61
i
QGL_EXTERN GLint i
Definition
r_gl.h:113
V_INT
@ V_INT
Definition
scripts.h:52
V_COLOR
@ V_COLOR
Definition
scripts.h:57
scripts_lua.h
Header for lua script functions.
rowsExtraData_t
Definition
ui_node_rows.h:34
uiBehaviour_t
node behaviour, how a node work
Definition
ui_behaviour.h:39
uiBehaviour_t::name
const char * name
Definition
ui_behaviour.h:41
uiBehaviour_t::lua_SWIG_typeinfo
void * lua_SWIG_typeinfo
Definition
ui_behaviour.h:57
uiBehaviour_t::manager
UINodePtr manager
Definition
ui_behaviour.h:43
uiBehaviour_t::extraDataSize
intptr_t extraDataSize
Definition
ui_behaviour.h:54
uiBox_t::size
vec2_t size
Definition
ui_nodes.h:52
uiNode_t
Atomic structure used to define most of the UI.
Definition
ui_nodes.h:80
uiNode_t::color
vec4_t color
Definition
ui_nodes.h:127
uiNode_t::selectedColor
vec4_t selectedColor
Definition
ui_nodes.h:128
uiNode_t::box
uiBox_t box
Definition
ui_nodes.h:96
vec2_t
vec_t vec2_t[2]
Definition
ufotypes.h:38
ui_behaviour.h
UI_RegisterNodeProperty
#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE)
Initialize a property.
Definition
ui_behaviour.h:91
UI_RegisterExtradataNodeProperty
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
Definition
ui_behaviour.h:109
UI_SWIG_TypeQuery
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
Definition
ui_lua_shared.cpp:2903
UI_GetNodeAbsPos
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition
ui_node.cpp:526
ui_node_abstractnode.h
UINodePtr
SharedPtr< uiNode > UINodePtr
Definition
ui_node_abstractnode.h:66
EXTRADATA_TYPE
#define EXTRADATA_TYPE
Definition
ui_node_abstractoption.cpp:38
EXTRADATA
#define EXTRADATA(node)
Definition
ui_node_abstractoption.cpp:39
UI_RegisterRowsNode
void UI_RegisterRowsNode(uiBehaviour_t *behaviour)
Definition
ui_node_rows.cpp:69
ui_node_rows.h
UI_DrawFill
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
Definition
ui_render.cpp:37
ui_render.h
src
client
ui
node
ui_node_rows.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0