Skip to main content

UiTextComponent Class

Component for displaying formatted text in the UI. More...

Declaration

class helios::engine::modules::ui::widgets::components::UiTextComponent { ... }

Public Constructors Index

UiTextComponent (helios::rendering::text::TextRenderable *renderable)

Constructs a UiTextComponent with the given renderable. More...

UiTextComponent (const UiTextComponent &other)

Copy constructor. More...

UiTextComponent (UiTextComponent &&) noexcept=default

Public Operators Index

UiTextComponent &operator= (const UiTextComponent &)=default
UiTextComponent &operator= (UiTextComponent &&) noexcept=default

Public Member Functions Index

boolisEnabled () const noexcept

Checks whether this component is enabled. More...

voidenable () noexcept

Enables this component. More...

voiddisable () noexcept

Disables this component. More...

const helios::rendering::text::TextRenderable *renderable () const noexcept

Returns the underlying text renderable as const pointer. More...

helios::rendering::text::TextRenderable *renderable () noexcept

Returns the underlying text renderable as a pointer. More...

voidreset () noexcept

Resets the component to its initial state. More...

voidonAcquire () noexcept

Called when the component is acquired from an object pool. More...

voidonRelease () noexcept

Called when the component is released back to an object pool. More...

voidupdate ()

Updates the text content if dirty. More...

voidsetText (const std::string &text)

Sets the text content and immediately updates the renderable. More...

voidsetText (std::string &&text)

Sets the text content by move and immediately updates the renderable. More...

boolneedsResize () const noexcept

Checks if the AABB bounds need recalculation. More...

voidresizeComplete () noexcept

Marks the resize as complete. More...

Protected Member Attributes Index

helios::rendering::text::TextRenderable *renderable_

Pointer to the underlying text renderable. Not owned. More...

std::stringtext_

The current text content. More...

boolisDirty_ = true

True if the text content needs to be updated. More...

boolneedsResize_ = true

True if the AABB bounds need to be recalculated. More...

boolisEnabled_ = true

Whether this component is enabled. More...

Description

Component for displaying formatted text in the UI.

Wraps a TextRenderable and provides template-based value formatting. Supports dirty tracking to minimize rendering updates.

Definition at line 34 of file UiTextComponent.ixx.

Public Constructors

UiTextComponent()

helios::engine::modules::ui::widgets::components::UiTextComponent::UiTextComponent (helios::rendering::text::TextRenderable * renderable)
inline explicit

Constructs a UiTextComponent with the given renderable.

Parameters
renderable

Pointer to the TextRenderable. Must not be nullptr.

Definition at line 94 of file UiTextComponent.ixx.

96
97 assert(renderable_ != nullptr && "TextRenderable must not be nullptr");
98 }

References renderable and renderable_.

Referenced by operator=, operator=, UiTextComponent and UiTextComponent.

UiTextComponent()

helios::engine::modules::ui::widgets::components::UiTextComponent::UiTextComponent (const UiTextComponent & other)
inline

Copy constructor.

Parameters
other

The component to copy from.

Definition at line 105 of file UiTextComponent.ixx.

106 assert(renderable_ != nullptr && "TextRenderable must not be nullptr");
107 }

References renderable_ and UiTextComponent.

UiTextComponent()

helios::engine::modules::ui::widgets::components::UiTextComponent::UiTextComponent (UiTextComponent &&)
noexcept default

Definition at line 110 of file UiTextComponent.ixx.

Reference UiTextComponent.

Public Operators

operator=()

UiTextComponent & helios::engine::modules::ui::widgets::components::UiTextComponent::operator= (const UiTextComponent &)
default

Definition at line 109 of file UiTextComponent.ixx.

Reference UiTextComponent.

operator=()

UiTextComponent & helios::engine::modules::ui::widgets::components::UiTextComponent::operator= (UiTextComponent &&)
noexcept default

Definition at line 111 of file UiTextComponent.ixx.

Reference UiTextComponent.

Public Member Functions

disable()

void helios::engine::modules::ui::widgets::components::UiTextComponent::disable ()
inline noexcept

Disables this component.

Definition at line 85 of file UiTextComponent.ixx.

85 void disable() noexcept {
86 isEnabled_ = false;
87 }

Reference isEnabled_.

enable()

void helios::engine::modules::ui::widgets::components::UiTextComponent::enable ()
inline noexcept

Enables this component.

Definition at line 78 of file UiTextComponent.ixx.

78 void enable() noexcept {
79 isEnabled_ = true;
80 }

Reference isEnabled_.

isEnabled()

bool helios::engine::modules::ui::widgets::components::UiTextComponent::isEnabled ()
inline nodiscard noexcept

Checks whether this component is enabled.

Returns

True if enabled, false otherwise.

Definition at line 71 of file UiTextComponent.ixx.

71 [[nodiscard]] bool isEnabled() const noexcept {
72 return isEnabled_;
73 }

Reference isEnabled_.

needsResize()

bool helios::engine::modules::ui::widgets::components::UiTextComponent::needsResize ()
inline nodiscard noexcept

Checks if the AABB bounds need recalculation.

Returns

True if a resize is needed, false otherwise.

Definition at line 209 of file UiTextComponent.ixx.

209 [[nodiscard]] bool needsResize() const noexcept {
210 return needsResize_;
211 }

Reference needsResize_.

onAcquire()

void helios::engine::modules::ui::widgets::components::UiTextComponent::onAcquire ()
inline noexcept

Called when the component is acquired from an object pool.

Resets the component to its initial dirty state.

Definition at line 143 of file UiTextComponent.ixx.

143 void onAcquire() noexcept {
144 reset();
145 }

Reference reset.

onRelease()

void helios::engine::modules::ui::widgets::components::UiTextComponent::onRelease ()
inline noexcept

Called when the component is released back to an object pool.

Resets the component to its initial dirty state.

Definition at line 152 of file UiTextComponent.ixx.

152 void onRelease() noexcept {
153 reset();
154 }

Reference reset.

renderable()

const helios::rendering::text::TextRenderable * helios::engine::modules::ui::widgets::components::UiTextComponent::renderable ()
inline nodiscard noexcept

Returns the underlying text renderable as const pointer.

Returns

Const pointer to the TextRenderable. Never nullptr.

Definition at line 118 of file UiTextComponent.ixx.

118 [[nodiscard]] const helios::rendering::text::TextRenderable* renderable() const noexcept {
119 return renderable_;
120 }

References renderable and renderable_.

Referenced by renderable and UiTextComponent.

renderable()

helios::rendering::text::TextRenderable * helios::engine::modules::ui::widgets::components::UiTextComponent::renderable ()
inline nodiscard noexcept

Returns the underlying text renderable as a pointer.

Returns

Pointer to the TextRenderable. Never nullptr.

Definition at line 127 of file UiTextComponent.ixx.

128 return renderable_;
129 }

Reference renderable_.

reset()

void helios::engine::modules::ui::widgets::components::UiTextComponent::reset ()
inline noexcept

Resets the component to its initial state.

Definition at line 134 of file UiTextComponent.ixx.

134 void reset() noexcept {
135 isDirty_ = true;
136 }

Reference isDirty_.

Referenced by onAcquire and onRelease.

resizeComplete()

void helios::engine::modules::ui::widgets::components::UiTextComponent::resizeComplete ()
inline noexcept

Marks the resize as complete.

Definition at line 216 of file UiTextComponent.ixx.

216 void resizeComplete() noexcept {
217 needsResize_ = false;
218 }

Reference needsResize_.

setText()

void helios::engine::modules::ui::widgets::components::UiTextComponent::setText (const std::string & text)
inline

Sets the text content and immediately updates the renderable.

No-op if the new text is identical to the current content. Otherwise marks the component as dirty and calls update().

Parameters
text

The new text content.

Definition at line 181 of file UiTextComponent.ixx.

181 void setText(const std::string& text) {
182 if (text == text_) {
183 return;
184 }
185 text_ = text;
186 isDirty_ = true;
187 update();
188 }

References isDirty_, text_ and update.

setText()

void helios::engine::modules::ui::widgets::components::UiTextComponent::setText (std::string && text)
inline

Sets the text content by move and immediately updates the renderable.

Sets the text content and immediately updates the renderable.

No-op if the new text is identical to the current content. Otherwise marks the component as dirty and calls update().

Parameters
text

The new text content.

Definition at line 195 of file UiTextComponent.ixx.

195 void setText(std::string&& text) {
196 if (text == text_) {
197 return;
198 }
199 text_ = std::move(text);
200 isDirty_ = true;
201 update();
202 }

References isDirty_, text_ and update.

update()

void helios::engine::modules::ui::widgets::components::UiTextComponent::update ()
inline

Updates the text content if dirty.

Applies the template to the current value and updates the renderable.

Definition at line 161 of file UiTextComponent.ixx.

161 void update() {
162
163 if (!isDirty_) {
164 return;
165 }
166
167 renderable_->setText(text_);
168
169 needsResize_ = true;
170 isDirty_ = false;
171 }

References isDirty_, needsResize_, renderable_ and text_.

Referenced by setText and setText.

Protected Member Attributes

isDirty_

bool helios::engine::modules::ui::widgets::components::UiTextComponent::isDirty_ = true
protected

True if the text content needs to be updated.

Definition at line 51 of file UiTextComponent.ixx.

51 bool isDirty_ = true;

Referenced by reset, setText, setText and update.

isEnabled_

bool helios::engine::modules::ui::widgets::components::UiTextComponent::isEnabled_ = true
protected

Whether this component is enabled.

Definition at line 61 of file UiTextComponent.ixx.

61 bool isEnabled_ = true;

Referenced by disable, enable and isEnabled.

needsResize_

bool helios::engine::modules::ui::widgets::components::UiTextComponent::needsResize_ = true
protected

True if the AABB bounds need to be recalculated.

Definition at line 56 of file UiTextComponent.ixx.

56 bool needsResize_ = true;

Referenced by needsResize, resizeComplete and update.

renderable_

helios::rendering::text::TextRenderable* helios::engine::modules::ui::widgets::components::UiTextComponent::renderable_
protected

Pointer to the underlying text renderable. Not owned.

Definition at line 41 of file UiTextComponent.ixx.

Referenced by renderable, renderable, UiTextComponent, UiTextComponent and update.

text_

std::string helios::engine::modules::ui::widgets::components::UiTextComponent::text_
protected

The current text content.

Definition at line 46 of file UiTextComponent.ixx.

46 std::string text_;

Referenced by setText, setText and update.


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.