Classes¶
UI
Brief descriptions¶
Structures |
|
Provides basic control over canvases and GUI elements within GUI hierarchy. |
|
Classes |
|
Manages GUI element state and input events. |
|
Detailed information¶
ui::UiManager¶
engine/core/modules/ui/include/nau/ui.h
-
struct UiManager¶
Provides basic control over canvases and GUI elements within GUI hierarchy.
Public Types
-
using TCanvasLoadedCallback = eastl::function<void(const eastl::string &canvasName)>¶
-
using TCallbackHandle = uint32_t¶
Public Functions
-
virtual void applicationDidEnterBackground() = 0¶
-
virtual void applicationWillEnterForeground() = 0¶
-
virtual void update() = 0¶
-
virtual void update(float dt) = 0¶
-
virtual void render(BaseTexture *backBuffer) = 0¶
-
virtual void setAnimationInterval(float interval) = 0¶
-
virtual bool shouldShutDown() const = 0¶
-
virtual void setScreenSize(float width, float height) = 0¶
-
virtual void setReferenceResolution(float width, float height) = 0¶
-
virtual void addCanvas(Canvas *canvas) = 0¶
Adds canvas to the GUI hierarchy.
- Parameters:
canvas – [in] A pointer to the canvas to add.
-
virtual Canvas *getCanvas(const eastl::string &canvasName) = 0¶
Retrieves the canvas from the GUI hierarchy.
- Parameters:
canvasName – [in] Name of the canvas object to retrieve.
- Returns:
A pointer to the requested canvas object or
NULL
if the canvas has not been found.
-
virtual void removeCanvas(const eastl::string &canvasName) = 0¶
Removes the canvas from the GUI hierarchy.
- Parameters:
canvasName – [in] Name of the canvas to delete.
-
virtual void updateCanvases() = 0¶
-
virtual TCallbackHandle setOnCanvasLoadedCallback(TCanvasLoadedCallback &&callback) = 0¶
-
virtual bool setOnCanvasLoadedCallback(TCallbackHandle handle) = 0¶
-
virtual void configureResourcePath() = 0¶
-
virtual Node *getCanvasChildUnderCursor(const eastl::string &canvasName) = 0¶
Retrieves a GUI element attached to the canvas that is currently located under the cursor.
- Parameters:
canvasName – [in] Name of the canvas that the object is attached to.
- Returns:
A pointer to the object that the cursor is currenrly pointing at or
NULL
if the cursor is not currently pointing at anything.
-
virtual void setElementChangedCallback(nau::Uid elementUid, TElementChangedCallback &&callback) = 0¶
Sets a function that is called when a GUI element is modified in update.
Warning
This is a debug-only function. Do not use it in release builds.
- Parameters:
elementUid – [in] Identifier of the changed element.
callback – [in] Callback to assign.
-
virtual void removeElementChangedCallback(nau::Uid id) = 0¶
Unbinds the onElementChangedCallback callback.
See setElementChangedCallback.
- Parameters:
id – [in] Identifier of the element to unbind the callback from.
Public Static Attributes
-
static const TCallbackHandle INVALID_CB_HANDLE = 0¶
-
using TCanvasLoadedCallback = eastl::function<void(const eastl::string &canvasName)>¶
ui::UiNodeAnimator¶
engine/core/modules/ui/include/nau/effects/node_animation.h
-
class UiNodeAnimator : public nau::animation::ITransformAndSkewAnimatable, public nau::animation::IGraphicPropsAnimatable¶
Public Functions
-
virtual void animateTransform(const math::Transform &transform) override¶
-
virtual void animateTranslation(const math::vec3 &translation) override¶
-
virtual void animateRotation(const math::quat &rotation) override¶
-
virtual void animateScale(const math::vec3 &scale) override¶
-
virtual void animateSkew(math::vec2 skew) override¶
-
virtual void animateColor(const math::Color3 &color) override¶
-
virtual void animateOpacity(float opacity) override¶
-
virtual void animateTransform(const math::Transform &transform) override¶
ui::SymbolFactory¶
engine/core/modules/ui/include/nau/ui/symbol_factory.h
-
class SymbolFactory¶
Public Functions
-
SymbolFactory()¶
-
SymbolFactory(const SymbolFactory&) = delete¶
-
SymbolFactory &operator=(const SymbolFactory&) = delete¶
-
SymbolFactory(SymbolFactory &&other) noexcept¶
-
SymbolFactory &operator=(SymbolFactory &&other) noexcept¶
-
~SymbolFactory()¶
-
void registerProvider(const std::string &fontFileName)¶
-
void unRegisterProvider(const std::string &fontFileName)¶
- bool tryGetSymbol (char32_t utf32Code, FontLetterDefinition &symbolDefinition, const std::u32string &font=U"") const
- bool hasSymbol (char32_t utf32Code, const std::u32string &font=U"") const
-
bool warmUpSymbosCache(const eastl::u32string &text) const¶
- cocos2d::Texture2D * getSymbolTexture (int textureId, char32_t utf32Code, const std::u32string &font=U"") const
-
int *getHorizontalKerning(const eastl::u32string &text, int &outNumLetters) const¶
Private Functions
-
std::string getFileExtension(const std::string &fileName) const¶
-
std::u32string extractFontName(const std::string &filePath) const¶
-
eastl::shared_ptr<ISymbolProvider> getProvider(const std::u32string &fontName) const¶
Private Members
-
eastl::vector<eastl::shared_ptr<ISymbolProvider>> m_providers = {}¶
-
SymbolFactory()¶
ui::UIControl¶
engine/core/modules/ui/include/nau/ui/ui_control.h
-
class UIControl : public nau::ui::Node¶
Manages GUI element state and input events.
Subclassed by nau::ui::NauButton, nau::ui::NauScroll, nau::ui::NauSlider
Public Types
-
using OnPressedCallback = std::function<void(math::vec2 mousePositionLocal)>¶
A functor type that is called upon EventType::press event triggering.
-
using OnReleasedCallback = std::function<void()>¶
A functor type that is called upon EventType::release event triggering.
-
using OnHoverCallback = std::function<void(math::vec2 mousePositionLocal)>¶
A functor type that is called upon EventType::hover event triggering.
-
using OnLeaveCallback = std::function<void()>¶
A functor type that is called upon EventType::leave event triggering.
-
using TouchMovedCallback = std::function<void(math::vec2 mousePositionLocal, math::vec2 delta)>¶
A functor type that is called when the cursor is held and moved within the element borders.
Public Functions
-
UIControl()¶
Default constructor.
-
virtual ~UIControl()¶
Destructor.
- inline FORCEINLINE void setOnPressedCallback (OnPressedCallback cb)
Changes the callback for EventType::press event.
- Parameters:
cb – [in] Callback to set.
- inline FORCEINLINE void setOnReleasedCallback (OnReleasedCallback cb)
Changes the callback for EventType::release event.
- Parameters:
cb – [in] Callback to set.
- inline FORCEINLINE void setOnHoverCallback (OnHoverCallback cb)
Changes the callback for EventType::hover event.
- Parameters:
cb – [in] Callback to set.
- inline FORCEINLINE void setOnLeaveCallback (OnLeaveCallback cb)
Changes the callback for EventType::leave event.
- Parameters:
cb – [in] Callback to set.
- inline FORCEINLINE void setOnTouchMovedCallback (TouchMovedCallback cb)
Changes the callback that is dispatched when the cursor is moved within the element borders.
- Parameters:
cb – [in] Callback to set.
- inline FORCEINLINE void setInputRestrictForChild (bool isRestrict)
Changes whether child interactable area should be restricted to the element area.
If
false
is passed, then cursor events can be triggered over the entire child area. Iftrue
is passed, then cursor events can be triggered only over the part of child area that is inside the parent (this) element area.- Parameters:
isRestrict – [in]
true
if children should be interactable only within the element borders,false
otherwise.
-
virtual void setInteractable(bool interactable)¶
Changes whether the GUI element can be interacted with (i.e. whether it can trigger cursor events).
- Parameters:
interactable – [in] Indicates whether the GUI element should be interactable.
-
virtual bool isInteractable() const¶
Checks whether the element can be interacted with (i.e. whether it can trigger cursor events).
- Returns:
true
if the element is interactable,false
otherwise.
-
virtual bool isTouchCaptured() const¶
Checks whether the element is currently being pressed on (given that it is interactable at the cursor location point).
- Returns:
true
if the EventType::press is currently being registered,false
otherwise.
-
virtual bool isMouseCaptured() const¶
Checks whether the element is currently being hovered on (given that it is interactable at the cursor location point).
- Returns:
true
if the EventType::hover is currently being registered,false
otherwise.
-
virtual void handleEvent(nau::ui::EventType eventType)¶
This function is called when any cursor event is triggered.
Note
This is a callback with default no-op implementation. Users can provide their own overloads in the custom elemnts implementing UIControl.
Note
Event-specific callbacks (like
OnPressed
) are called outside this function, so user do not need to call them manually.- Parameters:
eventType – [in] Type of the triggered event.
Protected Functions
-
virtual bool initialize() override¶
-
virtual bool isInputEventInElementBorder(math::vec2 inputPosition)¶
Protected Attributes
-
OnPressedCallback m_onPressed¶
-
OnReleasedCallback m_onReleased¶
-
OnHoverCallback m_onHover¶
-
OnLeaveCallback m_onLeave¶
-
TouchMovedCallback m_touchMovedCallback¶
-
bool m_interactable = {true}¶
-
bool m_inNeedRestrictInputForChildWidgets = {false}¶
-
using OnPressedCallback = std::function<void(math::vec2 mousePositionLocal)>¶
ui::UiComponent¶
engine/core/modules/ui/include/nau/ui/components/ui_component.h
-
class UiComponent : public nau::scene::SceneComponent, public nau::scene::IComponentEvents, public nau::scene::IComponentActivation¶
Private Functions
- NAU_OBJECT(nau::ui::UiComponent, scene::SceneComponent, scene::IComponentEvents, scene::IComponentActivation) 1 1(1(scene ~UiComponent ()
-
virtual async::Task activateComponentAsync() override¶
-
virtual void deactivateComponent() override¶
Deactivates the component.
-
void clearCanvas()¶
ui::ClippingNode¶
engine/core/modules/ui/include/nau/ui/elements/clipping_node.h
-
class ClippingNode : public nau::ui::Node, protected cocos2d::ClippingNode¶
-
Public Static Functions
-
static ClippingNode *create()¶
-
static ClippingNode *create()¶
ui::DrawNode¶
engine/core/modules/ui/include/nau/ui/elements/draw_node.h
-
class DrawNode : public nau::ui::Node, protected cocos2d::DrawNode¶
Public Functions
-
void drawPoint(const math::vec2 &point, const float pointSize, const math::Color4 &color)¶
-
void drawPoints(const math::vec2 *position, unsigned int numberOfPoints, const math::Color4 &color)¶
-
void drawPoints(const math::vec2 *position, unsigned int numberOfPoints, const float pointSize, const math::Color4 &color)¶
-
void drawLine(const math::vec2 &origin, const math::vec2 &destination, const math::Color4 &color)¶
-
void drawRect(const math::vec2 &origin, const math::vec2 &destination, const math::Color4 &color)¶
-
void drawPoly(const math::vec2 *poli, unsigned int numberOfPoints, bool closePolygon, const math::Color4 &color)¶
-
void drawCircle(const math::vec2 ¢er, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY, const math::Color4 &color)¶
-
void drawCircle(const math::vec2 ¢er, float radius, float angle, unsigned int segments, bool drawLineToCenter, const math::Color4 &color)¶
-
void drawQuadBezier(const math::vec2 &origin, const math::vec2 &control, const math::vec2 &destination, unsigned int segments, const math::Color4 &color)¶
-
void drawCubicBezier(const math::vec2 &origin, const math::vec2 &control1, const math::vec2 &control2, const math::vec2 &destination, unsigned int segments, const math::Color4 &color)¶
-
void drawDot(const math::vec2 &pos, float radius, const math::Color4 &color)¶
-
void drawRect(const math::vec2 &p1, const math::vec2 &p2, const math::vec2 &p3, const math::vec2 &p4, const math::Color4 &color)¶
-
void drawSolidRect(const math::vec2 &origin, const math::vec2 &destination, const math::Color4 &color)¶
-
void drawSolidPoly(const math::vec2 *poli, unsigned int numberOfPoints, const math::Color4 &color)¶
-
void drawSolidCircle(const math::vec2 ¢er, float radius, float angle, unsigned int segments, float scaleX, float scaleY, const math::Color4 &color)¶
-
void drawSolidCircle(const math::vec2 ¢er, float radius, float angle, unsigned int segments, const math::Color4 &color)¶
-
void drawSegment(const math::vec2 &from, const math::vec2 &to, float radius, const math::Color4 &color)¶
-
void drawPolygon(const math::vec2 *verts, int count, const math::Color4 &fillColor, float borderWidth, const math::Color4 &borderColor)¶
-
void drawTriangle(const math::vec2 &p1, const math::vec2 &p2, const math::vec2 &p3, const math::Color4 &color)¶
-
void clearDrawNode()¶
-
void drawPoint(const math::vec2 &point, const float pointSize, const math::Color4 &color)¶
ui::Layer¶
engine/core/modules/ui/include/nau/ui/elements/layer.h
ui::Node¶
engine/core/modules/ui/include/nau/ui/elements/node.h
-
class Node : protected virtual cocos2d::Node¶
Subclassed by nau::ui::Canvas, nau::ui::ClippingNode, nau::ui::DrawNode, nau::ui::Layer, nau::ui::NauLabel, nau::ui::Sprite, nau::ui::UIControl
Public Functions
-
Node()¶
-
virtual ~Node()¶
-
nau::Uid getUid() const¶
-
virtual bool initialize()¶
-
animation::IAnimationTarget *getAnimator()¶
-
animation::AnimationComponent *getAnimationComponent()¶
-
virtual void setZOrder(uint32_t order)¶
-
virtual uint32_t geZOrder() const¶
-
virtual void setScaleX(float scaleX) override¶
-
virtual void setScaleY(float scaleY) override¶
-
virtual void setScale(float scale) override¶
-
virtual void setScale(float scaleX, float scaleY) override¶
-
virtual void setPosition(const math::vec2 &position)¶
-
virtual math::vec2 getPosition() const¶
-
virtual void setPositionX(float x) override¶
-
virtual void setPositionY(float y) override¶
-
virtual void setSkewX(float skewX) override¶
-
virtual void setSkewY(float skewY) override¶
-
virtual void setAnchorPoint(const math::vec2 &anchorPoint)¶
-
virtual math::vec2 getAnchorPoint() const¶
-
virtual void setContentSize(const math::vec2 &contentSize)¶
-
virtual math::vec2 getContentSize() const¶
-
virtual void setVisible(bool visible) override¶
-
virtual void setRotation(float rotation) override¶
-
virtual void setRotationSkewX(float rotationX) override¶
-
virtual void setRotationSkewY(float rotationY) override¶
-
virtual void removeAllChildren() override¶
-
virtual void setTag(int tag) override¶
-
void nau_setName(const eastl::string &name)¶
-
math::vec2 convertToNodeSpace(const math::vec2 &worldPoint) const¶
-
math::vec2 convertToWorldSpace(const math::vec2 &nodePoint) const¶
-
math::vec2 convertToNodeSpaceAR(const math::vec2 &worldPoint) const¶
-
math::vec2 convertToWorldSpaceAR(const math::vec2 &nodePoint) const¶
-
virtual void setOpacity(uint8_t opacity) override¶
-
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override¶
-
virtual nau::math::E3DCOLOR getColor() const¶
-
virtual void setColor(const nau::math::E3DCOLOR &color)¶
-
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override¶
-
virtual void setOpacityModifyRGB(bool value) override¶
-
void enableDebugDraw(bool isEnable, DebugDrawLevel level = DebugDrawLevel::borders, const math::Color4 &debugColor = {1.0f, 1.0f, 1.0f, 1.0f})¶
-
virtual void redrawDebug()¶
Protected Attributes
-
math::Color4 m_debugColor¶
-
bool m_isDebugEnable = false¶
-
DebugDrawLevel m_debugLevel = DebugDrawLevel::borders¶
Private Functions
-
void setUid(nau::Uid uid)¶
-
virtual void *getPointer(const std::type_info &t) override¶
-
virtual nau::Ptr<UiNodeAnimator> createAnimator()¶
-
void removeFromEngineScene()¶
Private Members
-
nau::Uid m_uid¶
-
Ptr<UiNodeAnimator> m_animatorCached¶
-
scene::ObjectWeakRef<scene::SceneObject> m_sceneObject¶
Friends
- friend class UiManagerImpl
- friend class TestCanvasFitToSize
- friend class TestCanvasFitVertically
- friend class TestCanvasFitHorizontally
- friend class TestCanvasStretch
- friend class TestCanvasNoRescale
-
Node()¶