41#define EXTRADATA_TYPE panelExtraData_t
42#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
43#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
85 newSize[1] = child->
box.
size[1];
88 child->
box.
pos[1] = positionY;
89 positionY += child->
box.
size[1] + margin;
100 if (
EXTRADATA(node).super.onViewChange) {
103 else if (
EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
129 newSize[0] = child->
box.
size[0];
131 child->
box.
pos[0] = positionX;
133 positionX += child->
box.
size[0] + margin;
164 newSize[0] = maxX - minX;
165 newSize[1] = child->
box.
size[1];
169 minY += child->
box.
size[1] + margin;
178 newSize[0] = maxX - minX;
179 newSize[1] = child->
box.
size[1];
183 maxY -= child->
box.
size[1] + margin;
192 newSize[0] = child->
box.
size[0];
193 newSize[1] = maxY - minY;
197 minX += child->
box.
size[0] + margin;
206 newSize[0] = child->
box.
size[0];
207 newSize[1] = maxY - minY;
211 maxX -= child->
box.
size[0] + margin;
220 newSize[0] = maxX - minX;
221 newSize[1] = maxY - minY;
250 switch (child->align) {
252 newSize[0] = maxX - minX;
253 newSize[1] = child->box.size[1];
255 child->box.pos[0] = minX;
256 child->box.pos[1] = minY;
257 minY += child->box.size[1] + margin;
260 newSize[0] = maxX - minX;
261 newSize[1] = child->box.size[1];
263 child->box.pos[0] = minX;
264 child->box.pos[1] = maxY - child->box.size[1];
265 maxY -= child->box.size[1] + margin;
268 newSize[0] = child->box.size[0];
269 newSize[1] = maxY - minY;
271 child->box.pos[0] = minX;
272 child->box.pos[1] = minY;
273 minX += child->box.size[0] + margin;
276 newSize[0] = child->box.size[0];
277 newSize[1] = maxY - minY;
279 child->box.pos[0] = maxX - child->box.size[0];
280 child->box.pos[1] = minY;
281 maxX -= child->box.size[0] + margin;
284 newSize[0] = maxX - minX;
285 newSize[1] = maxY - minY;
287 child->box.pos[0] = minX;
288 child->box.pos[1] = minY;
311 child->box.pos[0] = 0;
312 child->box.pos[1] = 0;
323 child->box.pos[0] += destination[0] - source[0];
324 child->box.pos[1] += destination[1] - source[1];
338 value = child->box.pos[0] + child->box.size[0];
341 value = child->box.pos[1] + child->box.size[1];
349 bool updated =
EXTRADATA(node).super.scrollX.set(-1, node->
box.
size[0], width);
350 updated =
EXTRADATA(node).super.scrollY.set(-1, node->
box.
size[1], height) || updated;
352 if (
EXTRADATA(node).super.onViewChange) {
355 else if (
EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
375 if (
EXTRADATA(node).layoutColumns <= 0) {
376 Com_Printf(
"UI_ColumnLayout: Column number must be positive (%s). Layout ignored.",
UI_GetPath(node));
386 if (child ==
nullptr)
389 if (child->
box.
size[1] > rowHeight) {
390 rowHeight = child->
box.
size[1];
398 columnPos[
i] = columnPos[
i - 1] + columnSize[
i - 1] +
EXTRADATA(node).layoutMargin;
405 const int column =
i %
EXTRADATA(node).layoutColumns;
410 y += rowHeight +
EXTRADATA(node).layoutMargin;
413 child->
box.
pos[0] = columnPos[column];
422 const int column =
EXTRADATA(node).layoutColumns;
423 int width = columnPos[column - 1] + columnSize[column - 1] + node->
padding;
424 int height = y + rowHeight + node->
padding;
428 updated =
EXTRADATA(node).super.scrollY.set(-1, node->
box.
size[1], height) || updated;
430 if (
EXTRADATA(node).super.onViewChange) {
433 else if (
EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
495 bool hasSomethingToScroll =
EXTRADATA(node).super.scrollX.fullSize >
EXTRADATA(node).super.scrollX.viewSize
567 if (!
EXTRADATA(node).wheelScrollable || deltaY == 0)
570 updated =
EXTRADATA(node).super.scrollX.moveDelta(deltaX * 50);
571 updated |=
EXTRADATA(node).super.scrollY.moveDelta(deltaY * 50);
573 if (
EXTRADATA(node).super.onViewChange) {
576 else if (
EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
605 behaviour->
extends =
"abstractscrollable";
606 behaviour->
name =
"panel";
Header file for keyboard handler.
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
virtual void onLoading(uiNode_t *node)
void onLoading(uiNode_t *node) override
Handled after the end of the load of the node from script (all data and/or child are set).
void getClientPosition(uiNode_t const *node, vec2_t position) override
bool onMouseLongPress(uiNode_t *node, int x, int y, int button) override
Send mouse event when a pressed mouse button is dragged.
void draw(uiNode_t *node) override
Handles Button draw.
void onPropertyChanged(uiNode_t *node, const value_t *property) override
void onLoaded(uiNode_t *node) override
Handled after the end of the load of the node from script (all data and/or child are set).
void onMouseUp(uiNode_t *node, int x, int y, int button) override
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Handle mouse wheel scrolling.
bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button) override
Send mouse event when a pressed mouse button is dragged.
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
void Com_Printf(const char *const fmt,...)
#define Mem_AllocTypeN(type, n)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
Header for script parsing functions.
Header for lua script functions.
node behaviour, how a node work
Atomic structure used to define most of the UI.
struct uiAction_s * onWheelDown
uiBehaviour_t * behaviour
struct uiAction_s * onWheel
struct uiAction_s * onWheelUp
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
const value_t * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name)
Get a property from a behaviour or his inheritance It use a dichotomic search.
#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.
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...
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
void UI_Node_DoLayout(uiNode_t *node)
bool UI_Node_IsDrawable(uiNode_t const *node)
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int direction)
return a relative position of a point into a node.
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
SharedPtr< uiNode > UINodePtr
#define EXTRADATACONST(node)
static const uiBehaviour_t * localBehaviour
static void UI_PackLayout(uiNode_t *node, int margin)
Create a pack layout with child of the node. Set position and size of nodes one by one....
static void UI_LeftRightFlowLayout(uiNode_t *node, int margin)
Create a left-right flow layout with child of the node. Child position is automatically set,...
void UI_Panel_SetBackgroundByName(uiNode_t *node, const char *name)
void UI_StarLayout(uiNode_t *node)
Do a star layout with child according to there num.
static const value_t * propertyLayoutColumns
static void UI_TopDownFlowLayout(uiNode_t *node, int margin)
Create a top-down flow layout with child of the node. Child position is automatically set,...
void UI_RegisterPanelNode(uiBehaviour_t *behaviour)
static void UI_BorderLayout(uiNode_t *node, int margin)
Create a border layout with child of the node. Child with BORDERLAYOUT_TOP and BORDERLAYOUT_BOTTOM nu...
static const value_t * propertyLayoutMargin
static const value_t * propertyPadding
static void UI_ColumnLayout(uiNode_t *node)
Do column layout. A grid layout according to a fixed number of column. Check to first row to see the ...
static void UI_ClientLayout(uiNode_t *node)
void UI_StarLayout(uiNode_t *node)
Do a star layout with child according to there num.
@ LAYOUTALIGN_BOTTOMRIGHT
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
#define UI_EXTRADATA(NODE, TYPE)
void UI_DrawSpriteInBox(bool flip, const uiSprite_t *sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY)
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
#define Vector2FromInt(x, y)