UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_abstractscrollbar.cpp
Go to the documentation of this file.
1
7
8/*
9Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11This program is free software; you can redistribute it and/or
12modify it under the terms of the GNU General Public License
13as published by the Free Software Foundation; either version 2
14of the License, or (at your option) any later version.
15
16This program is distributed in the hope that it will be useful,
17but WITHOUT ANY WARRANTY; without even the implied warranty of
18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20See the GNU General Public License for more details.
21
22You should have received a copy of the GNU General Public License
23along with this program; if not, write to the Free Software
24Foundation, 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
33
35
36#define EXTRADATA_TYPE abstractScrollbarExtraData_t
37#define EXTRADATA(node) UI_EXTRADATA(node, abstractScrollbarExtraData_t)
38
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) {
64 }
65 if (node->lua_onChange != LUA_NOREF) {
67 }
68}
69
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}
@ V_BOOL
Definition scripts.h:50
@ V_INT
Definition scripts.h:52
Header for lua script functions.
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
UINodePtr manager
intptr_t extraDataSize
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
LUA_EVENT lua_onChange
Definition ui_nodes.h:162
struct uiAction_s * onChange
Definition ui_nodes.h:143
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition ui_lua.cpp:71
Basic lua initialization for the ui.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
SharedPtr< uiNode > UINodePtr
#define EXTRADATA_TYPE
#define EXTRADATA(node)
void UI_RegisterAbstractScrollbarNode(uiBehaviour_t *behaviour)
void UI_AbstractScrollbarNodeSet(uiNode_t *node, int value)
Set the position of the scrollbar to a value.