28 #include "../ui_nodes.h"
29 #include "../ui_behaviour.h"
30 #include "../ui_parse.h"
31 #include "../ui_main.h"
32 #include "../ui_input.h"
33 #include "../ui_render.h"
34 #include "../ui_actions.h"
39 #include "../../input/cl_keys.h"
41 #include "../../../common/scripts_lua.h"
43 #define EXTRADATA_TYPE barExtraData_t
44 #define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
51 const float min =
getMin(node);
52 const float max =
getMax(node);
62 color[3] = node->
color[3];
67 fac = (value - min) / (max - min);
70 if (fac <= 0 || fac > 1)
101 else if (x > node->
box.
size[0])
105 else if (y > node->
box.
size[1])
109 const float min =
getMin(node);
110 const float max =
getMax(node);
117 frac = (float) y / node->
box.
size[1];
120 frac = (
float) x / node->
box.
size[0];
127 Com_Printf(
"UI_BarNodeCapturedMouseMove: Orientation %d not supported\n",
EXTRADATA(node).orientation);
131 setValue(node, min + frac * (max - min));
162 behaviour->
name =
"bar";
163 behaviour->
extends =
"abstractvalue";
float getMin(uiNode_t const *node)
static const vec3_t scale
void Com_Printf(const char *const fmt,...)
Define common thing for GUI controls which allow to edit a value (scroolbar, spinner, and more)
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
Called when the node is captured by the mouse.
#define VectorScale(in, scale, out)
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
float getMax(uiNode_t const *node)
void draw(uiNode_t *node) override
#define Vector4Set(v, r, g, b, a)
SharedPtr< uiNode > UINodePtr
Atomic structure used to define most of 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...
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
void onLoading(uiNode_t *node) override
Called before loading. Used to set default attribute values.
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
node behaviour, how a node work
bool setValue(uiNode_t *node, float value)
void UI_DrawFill(int x, int y, int w, int h, const vec4_t color)
Fills a box of pixels with a single color.
float getValue(uiNode_t const *node)
void onMouseUp(uiNode_t *node, int x, int y, int button) override
#define Vector4Copy(src, dest)
void UI_RegisterBarNode(uiBehaviour_t *behaviour)
void onMouseDown(uiNode_t *node, int x, int y, int button) override