UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node_abstractscrollbar.cpp
Go to the documentation of this file.
1 
8 /*
9 Copyright (C) 2002-2020 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 
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) {
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 }
#define EXTRADATA(node)
void UI_AbstractScrollbarNodeSet(uiNode_t *node, int value)
Set the position of the scrollbar to a value.
LUA_EVENT lua_onChange
Definition: ui_nodes.h:162
const char * name
Definition: ui_behaviour.h:41
struct uiAction_s * onChange
Definition: ui_nodes.h:143
void UI_RegisterAbstractScrollbarNode(uiBehaviour_t *behaviour)
UINodePtr manager
Definition: ui_behaviour.h:43
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition: ui_lua.cpp:71
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
Definition: ui_behaviour.h:109
SharedPtr< uiNode > UINodePtr
void * lua_SWIG_typeinfo
Definition: ui_behaviour.h:57
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
Definition: ui_actions.cpp:726
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
intptr_t extraDataSize
Definition: ui_behaviour.h:54
Definition: scripts.h:50
node behaviour, how a node work
Definition: ui_behaviour.h:39
Definition: scripts.h:52
#define EXTRADATA_TYPE