UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
ui_node_abstractscrollbar.cpp
Go to the documentation of this file.
1
7
8
/*
9
Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20
See the GNU General Public License for more details.
21
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26
*/
27
28
#include "
../ui_behaviour.h
"
29
#include "
../ui_actions.h
"
30
#include "
../ui_lua.h
"
31
32
#include "
ui_node_abstractscrollbar.h
"
33
34
#include "
../../../common/scripts_lua.h
"
35
36
#define EXTRADATA_TYPE abstractScrollbarExtraData_t
37
#define EXTRADATA(node) UI_EXTRADATA(node, abstractScrollbarExtraData_t)
38
42
void
UI_AbstractScrollbarNodeSet
(
uiNode_t
* node,
int
value)
43
{
44
int
pos = value;
45
46
if
(pos < 0) {
47
pos = 0;
48
}
else
if
(pos >
EXTRADATA
(node).fullsize -
EXTRADATA
(node).viewsize) {
49
pos =
EXTRADATA
(node).fullsize -
EXTRADATA
(node).viewsize;
50
}
51
if
(pos < 0)
52
pos = 0;
53
54
/* nothing change */
55
if
(
EXTRADATA
(node).pos == pos)
56
return
;
57
58
/* update status */
59
EXTRADATA
(node).pos = pos;
60
61
/* fire change event */
62
if
(node->
onChange
) {
63
UI_ExecuteEventActions
(node, node->
onChange
);
64
}
65
if
(node->
lua_onChange
!= LUA_NOREF) {
66
UI_ExecuteLuaEventScript
(node, node->
lua_onChange
);
67
}
68
}
69
70
void
UI_RegisterAbstractScrollbarNode
(
uiBehaviour_t
* behaviour)
71
{
72
behaviour->
name
=
"abstractscrollbar"
;
73
behaviour->
isAbstract
=
true
;
74
behaviour->
extraDataSize
=
sizeof
(
EXTRADATA_TYPE
);
75
behaviour->
manager
=
UINodePtr
(
new
uiAbstractScrollbarNode
());
76
behaviour->
lua_SWIG_typeinfo
=
UI_SWIG_TypeQuery
(
"uiAbstractScrollbarNode_t *"
);
77
78
/* Current position of the scroll. Image of the <code>viewpos</code> from <code>abstractscrollable</code> node. */
79
UI_RegisterExtradataNodeProperty
(behaviour,
"current"
,
V_INT
,
EXTRADATA_TYPE
, pos);
80
/* Image of the <code>viewsize</code> from <code>abstractscrollable</code> node. */
81
UI_RegisterExtradataNodeProperty
(behaviour,
"viewsize"
,
V_INT
,
EXTRADATA_TYPE
, viewsize);
82
/* Image of the <code>fullsize</code> from <code>abstractscrollable</code> node. */
83
UI_RegisterExtradataNodeProperty
(behaviour,
"fullsize"
,
V_INT
,
EXTRADATA_TYPE
, fullsize);
84
85
/* If true, hide the scroll when the position is 0 and can't change (when <code>viewsize</code> >= <code>fullsize</code>). */
86
UI_RegisterExtradataNodeProperty
(behaviour,
"hidewhenunused"
,
V_BOOL
,
EXTRADATA_TYPE
, hideWhenUnused);
87
}
uiAbstractScrollbarNode
Definition
ui_node_abstractscrollbar.h:31
V_BOOL
@ V_BOOL
Definition
scripts.h:50
V_INT
@ V_INT
Definition
scripts.h:52
scripts_lua.h
Header for lua script functions.
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::isAbstract
bool isAbstract
Definition
ui_behaviour.h:47
uiBehaviour_t::manager
UINodePtr manager
Definition
ui_behaviour.h:43
uiBehaviour_t::extraDataSize
intptr_t extraDataSize
Definition
ui_behaviour.h:54
uiNode_t
Atomic structure used to define most of the UI.
Definition
ui_nodes.h:80
uiNode_t::lua_onChange
LUA_EVENT lua_onChange
Definition
ui_nodes.h:162
uiNode_t::onChange
struct uiAction_s * onChange
Definition
ui_nodes.h:143
UI_ExecuteEventActions
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition
ui_actions.cpp:726
ui_actions.h
ui_behaviour.h
UI_RegisterExtradataNodeProperty
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
Definition
ui_behaviour.h:109
UI_ExecuteLuaEventScript
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition
ui_lua.cpp:71
ui_lua.h
Basic lua initialization for the ui.
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
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_abstractscrollbar.cpp:37
UI_RegisterAbstractScrollbarNode
void UI_RegisterAbstractScrollbarNode(uiBehaviour_t *behaviour)
Definition
ui_node_abstractscrollbar.cpp:70
UI_AbstractScrollbarNodeSet
void UI_AbstractScrollbarNodeSet(uiNode_t *node, int value)
Set the position of the scrollbar to a value.
Definition
ui_node_abstractscrollbar.cpp:42
ui_node_abstractscrollbar.h
src
client
ui
node
ui_node_abstractscrollbar.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0