![]() |
Skylicht Engine
|
Grid view control (list view with multi-column layout). More...
#include <UserInterface/CUIGridView.h>
Public Member Functions | |
| CUIGridView (CUIContainer *container, CGUIElement *element, CGUIElement *baseItem, CGUIElement *listElement=NULL) | |
| Create a grid view. | |
| virtual void | updateLimitOffset () |
| Update computed limits for allowable offset (m_maxOffset and related). | |
| virtual void | updateItemPosition () |
| Recompute and apply item world/local positions based on m_offset. | |
| void | setItemSpacing (float x, float y) |
| Set spacing between items on X and Y axes. | |
| Public Member Functions inherited from Skylicht::UI::CUIListView | |
| CUIListView (CUIContainer *container, CGUIElement *element, CGUIElement *baseItem, CGUIElement *listElement=NULL) | |
| Create a list view. | |
| CGUIElement * | addItem () |
| Create a new item using the m_baseItem template and append it to the list. | |
| CGUIElement * | addItem (CObjectSerializable *data) |
| Create a new item and attach data to it (using serialization template). | |
| CGUIMask * | getMask () |
| Get the current mask element used for clipping the list viewport. | |
| void | enableMask (bool b) |
| Enable or disable visual masking for the list viewport. | |
| bool | removeItem (CGUIElement *item) |
| Remove a specific item from the list, The function also remove and destroy all child UI elements created from the list's base item. | |
| void | clear () |
| Remove and destroy all child UI elements created from the list's base item. | |
| int | getItemCount () |
| Return number of items currently in the list. | |
| CGUIElement * | getItem (int id) |
| Get item by index. | |
| virtual void | update () |
| virtual void | onPointerDown (int pointerId, float pointerX, float pointerY) |
| Called when pointer is pressed down on the element. | |
| virtual void | onPointerUp (int pointerId, float pointerX, float pointerY) |
| Called when pointer is released over the element. | |
| virtual void | onPointerMove (int pointerId, float pointerX, float pointerY) |
| Called when pointer moves while over or dragging the element. | |
| void | setVertical (bool b) |
| Set vertical layout mode. | |
| bool | isVertical () |
| Returns true when layout is vertical. | |
| void | setItemSpacing (float b) |
| Set spacing between items. | |
| float | getItemSpacing () |
| Get spacing between items. | |
| float | getOffset () |
| Get current scroll offset. | |
| void | setOffset (float offset) |
| Set content offset programmatically. | |
| float | getMaxOffset () |
| Returns maximum computed offset (content size - viewport size). | |
| virtual bool | acceptDragFocus () |
| Whether this UI element should accept drag-focus when the pointer is already down and the user drags over it. | |
| Public Member Functions inherited from Skylicht::UI::CUIBase | |
| CUIBase (CUIContainer *container, CGUIElement *element) | |
| Constructor. | |
| virtual | ~CUIBase () |
| Virtual destructor. | |
| void | remove () |
| Remove this UI object from its container and perform cleanup. | |
| virtual void | setEnable (bool b) |
| Enable or disable this UI object. | |
| virtual void | setVisible (bool b) |
| Set visibility of this UI object. | |
| bool | isEnable () |
| Returns true if the object is enabled. | |
| bool | isVisible () |
| Returns true if the object is visible. | |
| int | getPointerId () |
| Get the pointer ID associated with this UI object. | |
| void | setPointerId (int id) |
| Set the pointer ID for this UI object. | |
| void | resetTouch () |
| Reset pointer internal state (hover/down). | |
| void | setContinueGameEvent (bool b) |
| Control whether input events continue to the game layer. | |
| bool | isContinueGameEvent () |
| Returns true when events are allowed to continue to the game layer. | |
| bool | isContinueKeyEvent () |
| void | setSkipPointerEventWhenDrag (bool b) |
| When true pointer events will be skipped while dragging. | |
| bool | isPointerHover () |
| Returns true if pointer is hovering this object. | |
| bool | isPointerDown () |
| Returns true if pointer is down on this object. | |
| CGUIElement * | getElement () |
| Get the underlying CGUIElement pointer. | |
| CCanvas * | getCanvas () |
| Retrieve the canvas that the underlying element belongs to. | |
| CUIContainer * | getContainer () |
| Get parent container. | |
| core::vector3df * | getRectTransform () |
| Returns a pointer to the internal rect transform (4 corners). | |
| void | getRectTransform (CGUIElement *element, core::vector3df *t) |
| virtual void | onPointerHover (int pointerId, float pointerX, float pointerY) |
| Called when pointer enters or hovers over the element. | |
| virtual void | onPointerOut (int pointerId, float pointerX, float pointerY) |
| Called when pointer leaves the element. | |
| virtual void | onPressed () |
| Called when the element is considered "pressed" (high-level event). Subclasses may trigger OnPressed callback from here. | |
| virtual void | onFocus () |
| Called when element receives focus. | |
| virtual void | onLostFocus () |
| Called when element loses focus. | |
| virtual void | onKeyEvent (const SEvent &event) |
| Called when a keyboard event is delivered to this element. | |
| void | startMotion (EMotionEvent event) |
| Start motions associated with a specific motion event. | |
| void | stopMotion (EMotionEvent event) |
| Stop motions associated with a specific motion event. | |
| bool | isMotionPlaying (EMotionEvent event) |
| Query whether any motion is currently playing for the given event. | |
| virtual CMotion * | addMotion (EMotionEvent event, CMotion *motion) |
| Add a CMotion instance to the list for the given event. The motion will be initialized and managed by this object. | |
| virtual CMotion * | addMotion (EMotionEvent event, CGUIElement *element, CMotion *motion) |
| Add a CMotion instance bound to a specific CGUIElement for the given event. | |
| bool | removeMotion (EMotionEvent event, CMotion *motion) |
| Remove a motion instance from the given event list. | |
| void | removeMotions (EMotionEvent event) |
| Remove all motions attached to the specified event. | |
| std::vector< CMotion * > & | getMotions (EMotionEvent event) |
| Access the motion vector for a specific event. | |
| void | convertToUICoordinate (float &pointerX, float &pointerY) |
| Convert screen pointer coordinates to this UI object's local UI coordinates. | |
| void | convertWorldToLocal (CGUIElement *element, float &x, float &y) |
| Convert world coordinates to the local coordinate space of a CGUIElement. | |
| void | convertLocalToWorld (CGUIElement *element, float &x, float &y) |
| Convert local coordinates of a CGUIElement to world coordinates. | |
| void | setSoundId (int slot, int soundId) |
| Set the sound id associated with this UI object. | |
| int | getSoundId (int slot) |
| Get the sound id associated with this UI object. | |
| void | setUserData (void *data) |
| Attach an application-defined pointer to this UI object. | |
| void * | getUserData () |
| Retrieve the pointer previously set via setUserData. | |
Protected Attributes | |
| float | m_itemSpacingX |
| float | m_itemSpacingY |
| Protected Attributes inherited from Skylicht::UI::CUIListView | |
| bool | m_vertical |
| CGUIMask * | m_mask |
| std::vector< CGUIElement * > | m_allItems |
| std::vector< CGUIElement * > | m_visibleItems |
| CGUIElement * | m_listElement |
| CGUIElement * | m_baseItem |
| CObjectSerializable * | m_itemSerializable |
| float | m_offset |
| float | m_speed |
| float | m_lastPointerX |
| float | m_lastPointerY |
| float | m_pointerX |
| float | m_pointerY |
| float | m_maxOffset |
| float | m_springOffset |
| float | m_itemSpacing |
| Protected Attributes inherited from Skylicht::UI::CUIBase | |
| CUIContainer * | m_container |
| CGUIElement * | m_element |
| core::vector3df | m_rectTransform [4] |
| std::vector< CMotion * > | m_motions [(int) EMotionEvent::NumEvent] |
| bool | m_enable |
| bool | m_visible |
| bool | m_isPointerHover |
| bool | m_isPointerDown |
| bool | m_skipPointerEventWhenDrag |
| bool | m_continueGameEvent |
| bool | m_continueKeyEvent |
| int | m_pointerId |
| float | m_pointerDownX |
| float | m_pointerDownY |
| int | m_soundId [4] |
| void * | m_userData |
Additional Inherited Members | |
| Public Attributes inherited from Skylicht::UI::CUIBase | |
| std::function< void(int, float, float)> | OnPointerHover |
| std::function< void(int, float, float)> | OnPointerOut |
| std::function< void(int, float, float)> | OnPointerDown |
| std::function< void(int, float, float)> | OnPointerUp |
| std::function< void(int, float, float, bool)> | OnPointerMove |
| std::function< void(CUIBase *)> | OnPressed |
| std::function< void(CUIBase *)> | OnFocus |
| std::function< void(CUIBase *)> | OnLostFocus |
| std::function< void(CUIBase *, const SEvent &)> | OnKeyEvent |
| std::function< void(CUIBase *, EMotionEvent)> | OnMotionFinish [(int) EMotionEvent::NumEvent] |
| Protected Member Functions inherited from Skylicht::UI::CUIListView | |
| virtual void | updateItemMovement () |
| Update item movement logic (applies m_speed, clamps and spring-back). | |
| virtual void | updateInertia () |
| Compute and apply inertia when the pointer is released and m_speed != 0. | |
| virtual void | updateStopSpeed () |
| Damp and stop the scrolling speed smoothly when near rest. | |
Grid view control (list view with multi-column layout).
CUIGridView extends CUIListView to arrange items in a two-dimensional grid instead of a single row/column. Items are positioned using horizontal and vertical spacing values; scrolling and input behavior are inherited from CUIListView.
The class overrides the limit and layout update hooks:
| Skylicht::UI::CUIGridView::CUIGridView | ( | CUIContainer * | container, |
| CGUIElement * | element, | ||
| CGUIElement * | baseItem, | ||
| CGUIElement * | listElement = NULL ) |
Create a grid view.
| container | Parent CUIContainer that owns this control. |
| element | Root CGUIElement node for the grid view. |
| baseItem | Template CGUIElement used to instantiate grid cells. |
| listElement | The list display items (if null, it will be element). |
The baseItem is duplicated/cloned to create each grid entry (same behaviour as CUIListView).
|
inline |
Set spacing between items on X and Y axes.
| x | Horizontal spacing (pixels / world units). |
| y | Vertical spacing (pixels / world units). |
This affects how updateItemPosition() arranges items in the grid.
|
virtual |
Recompute and apply item world/local positions based on m_offset.
Positions should account for m_itemSpacing and m_vertical mode.
Reimplemented from Skylicht::UI::CUIListView.
|
virtual |
Update computed limits for allowable offset (m_maxOffset and related).
Called when items change or layout needs recalculation. Subclasses may override to implement different bounds logic.
Reimplemented from Skylicht::UI::CUIListView.