vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::UIElement Struct Reference

The 2D rect of a UI node - the screen-space analogue of Transform. More...

#include <ui_element.h>

Static Public Member Functions

static UIElement at (const glm::vec2 &anchorPivot, const glm::vec2 &position, const glm::vec2 &size)
 An element pinned to one normalised point of its parent by the matching point of itself.

Public Attributes

glm::vec2 anchor = {0.5f, 0.5f}
 Parent anchor point, normalised (0,0 = top-left, 1,1 = bottom-right).
glm::vec2 pivot = {0.5f, 0.5f}
 Element pivot, normalised; the point placed at the anchor.
glm::vec2 position = {0.0f, 0.0f}
glm::vec2 size = {100.0f, 100.0f}
 Element size, in canvas reference pixels, added to relativeSize's share.
glm::vec2 relativeSize = {0.0f, 0.0f}
 The share of the parent's size this element takes, added to size.
bool visible = true
 Skip this element and its whole subtree when false.
float opacity = 1.0f
 How opaque this element and its whole subtree draw, 0 to 1: what a panel fades in and out by, without touching each colour under it.
bool blocksPointer = true
 Whether this element stops a pointer reaching what is behind it.
bool clipChildren = false
 Whether this element's rect bounds what its descendants may draw.
UIRect screenRect = {}
 Resolved rect in screen pixels, written each frame.

Detailed Description

The 2D rect of a UI node - the screen-space analogue of Transform.

The element's pivot point is pinned to its parent rect's anchor point (both normalised, top-left origin). position and size are in canvas reference pixels.

Member Function Documentation

◆ at()

UIElement Vkm::Engine::UIElement::at ( const glm::vec2 & anchorPivot,
const glm::vec2 & position,
const glm::vec2 & size )
inlinestatic

An element pinned to one normalised point of its parent by the matching point of itself.

Parameters
anchorPivotNormalised point, 0..1 from the top-left, used as both.
positionOffset from the anchor, in canvas reference pixels.
sizeElement size, in canvas reference pixels.
Returns
The element, ready to hand to Scene::add.

Member Data Documentation

◆ position

glm::vec2 Vkm::Engine::UIElement::position = {0.0f, 0.0f}

Offset from the anchor, in canvas reference pixels.

◆ relativeSize

glm::vec2 Vkm::Engine::UIElement::relativeSize = {0.0f, 0.0f}

The share of the parent's size this element takes, added to size.

(1, 1) with size (-40, -40) at a centred anchor is a 20 inset on every side. A resolved size below zero is zero.

◆ opacity

float Vkm::Engine::UIElement::opacity = 1.0f

How opaque this element and its whole subtree draw, 0 to 1: what a panel fades in and out by, without touching each colour under it.

It multiplies down the tree, onto every colour's alpha. At nothing, the subtree is skipped as when not visible, and takes no clicks.

◆ blocksPointer

bool Vkm::Engine::UIElement::blocksPointer = true

Whether this element stops a pointer reaching what is behind it.

Consulted only on a UIImage or UIButton; clear it for a click-through overlay.

◆ clipChildren

bool Vkm::Engine::UIElement::clipChildren = false

Whether this element's rect bounds what its descendants may draw.

Off by default, since it costs a scissor change. Bounds the pointer as well as the pixels. A UIScroll clips whether or not this is set.


The documentation for this struct was generated from the following file: