|
Capycore Engine
0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
|
A UI input field element. More...
#include <ui_input.h>
Public Member Functions | |
| UIInput (Scene &scene, float width, float height, Point pivot, Point anchor, const std::string &placeholder="", const std::string &font="", const std::string &font_path="", const std::string &sprite_path="") | |
| void | update (float dt) override |
| Update the UI object. | |
| void | add_on_focus (const std::function< void(UIInput &)> &handler) |
| void | add_on_unfocus (const std::function< void(UIInput &)> &handler) |
| void | add_on_text_changed (const std::function< void(UIInput &)> &handler) |
| void | on_hover () override |
| Event hook for when the element is hovered. | |
| void | on_unhover () override |
| Event hook for when the element is unhovered. | |
| void | on_focus () override |
| Event hook for when the element gains focus. | |
| void | on_unfocus () override |
| Event hook for when the element loses focus. | |
| std::string | text () const |
| UIInput & | text (const std::string &value) |
| Color | text_color () const |
| UIInput & | text_color (const Color &color) |
| int | font_size () const |
| UIInput & | font_size (int size) |
| Color | input_color () const |
| UIInput & | input_color (const Color &color) |
Public Member Functions inherited from UIInteractable | |
| UIInteractable (Scene &scene, float width, float height, Point pivot, Point anchor) | |
| void | update_interaction (float dt) |
| Update interaction state based on input. | |
| UIInteractionState & | state () |
| const UIInteractionState & | state () const |
| void | disable () |
| Disable the interactable element. | |
| void | enable () |
| Enable the interactable element. | |
| virtual void | on_press () |
| Event hook for when the element is pressed. | |
| virtual void | on_release () |
| Event hook for when the element is released. | |
| virtual void | on_hold () |
| Event hook for when the element is held down. | |
| void | add_on_hover (const std::function< void(UIInteractable &)> &handler) |
| void | add_on_unhover (const std::function< void(UIInteractable &)> &handler) |
| void | add_on_press (const std::function< void(UIInteractable &)> &handler) |
| void | add_on_release (const std::function< void(UIInteractable &)> &handler) |
| void | add_on_focus (const std::function< void(UIInteractable &)> &handler) |
| void | add_on_unfocus (const std::function< void(UIInteractable &)> &handler) |
Public Member Functions inherited from UIObject | |
| UIObject (Scene &scene, float width, float height, Point pivot, Point anchor) | |
| virtual void | render () const |
| Render the UI object. | |
| float | width () const |
| UIObject & | width (float width) |
| float | height () const |
| UIObject & | height (float height) |
| Point | pivot () const |
| UIObject & | pivot (Point pivot) |
| Point | anchor () const |
| UIObject & | anchor (Point anchor) |
Public Member Functions inherited from GameObject | |
| GameObject (Scene &scene) | |
| virtual | ~GameObject ()=default |
| GameObject (const GameObject &)=delete | |
| GameObject & | operator= (const GameObject &)=delete |
| GameObject (GameObject &&)=default | |
| GameObject & | operator= (GameObject &&)=default |
| std::optional< std::reference_wrapper< GameObject > > | parent () const |
| GameObject & | parent (GameObject &parent) |
| GameObject & | parent (std::nullopt_t null_opt) |
| std::string | id () const noexcept |
| bool | is_active_in_world () const noexcept |
| Retrieves whether the GameObject is active in the world. | |
| bool | is_active () const noexcept |
| Retrieves whether the GameObject is active. | |
| void | set_inactive () noexcept |
| void | set_active () noexcept |
| void | set_active_in_world () noexcept |
| void | set_inactive_in_world () noexcept |
| GameObject & | mark_for_deletion () noexcept |
| Marks the GameObject for deletion. | |
| bool | marked_for_deletion () const noexcept |
| void | mark_dont_destroy_on_load (bool dont_destroy) noexcept |
| Sets whether the GameObject should not be destroyed on scene load. | |
| bool | dont_destroy_on_load () const noexcept |
| GameObject & | name (const std::string &name) |
| const std::string & | name () const |
| GameObject & | tag (const std::string &tag) |
| const std::string & | tag () const |
| GameObject & | prefab_type_id (const std::string &id) |
| const std::string & | prefab_type_id () const |
| GameObject & | layer (int layer) |
| int | layer () const |
| GameObject & | transform (Transform transform) |
| Transform & | transform () |
| const Transform & | transform () const |
| Scene & | scene () const noexcept |
| void | scene (Scene &scene) noexcept |
| std::vector< std::reference_wrapper< GameObject > > & | children () |
| GameObject & | add_child (GameObject &child) |
| GameObject & | remove_child (GameObject &child) |
| template<IsComponent T> | |
| std::optional< std::reference_wrapper< T > > | get_component () const noexcept |
| Get the first component of type T attached to this GameObject. | |
| template<IsComponent T> | |
| std::vector< std::reference_wrapper< T > > | get_components () const |
| Get all components of type T attached to this GameObject. | |
| template<IsComponent BS, typename B > | |
| std::optional< std::reference_wrapper< B > > | get_script () const noexcept |
| Get the first script component of base type BS with behavior of type B. | |
| std::vector< std::reference_wrapper< Component > > | get_components_all () const |
| Get all components attached to this GameObject. | |
| template<IsComponent T> | |
| std::vector< std::reference_wrapper< T > > | get_components_from_children () const |
| Get all components of type T attached to this GameObject and its children. | |
| template<IsComponent T, typename... Args> | |
| T & | add_component (Args &&... args) |
| Adds a component of type T to this GameObject. | |
| template<IsComponent T> | |
| void | remove_component (T &component) |
| Removes a component of type T from this GameObject. | |
| void | remove_all_components () |
| void | serialize (std::vector< uint8_t > &out) const |
Serialize this GameObject's own state and its components into out. The format produced is: uint16_t name_len, name bytes uint16_t tag_len, tag bytes uint8_t is_active int32_t layer uint16_t component_count for each component: uint16_t type_name_len, type_name bytes uint32_t payload_len, payload bytes. | |
| void | deserialize (const std::vector< uint8_t > &data, size_t &offset) |
Deserialize this GameObject's state and dispatch component payloads from data starting at offset. Implementations should advance offset by the number of bytes consumed. Subclasses overriding this method should call GameObject::deserialize first to keep base behavior. | |
Additional Inherited Members | |
Protected Member Functions inherited from UIInteractable | |
| bool | in_range (const Point &mouse_pos) const |
Protected Attributes inherited from UIInteractable | |
| UIInteractionState | interaction_state_ |
| std::vector< std::function< void(UIInteractable &)> > | on_hover_handlers_ |
| std::vector< std::function< void(UIInteractable &)> > | on_unhover_handlers_ |
| std::vector< std::function< void(UIInteractable &)> > | on_press_handlers_ |
| std::vector< std::function< void(UIInteractable &)> > | on_release_handlers_ |
| std::vector< std::function< void(UIInteractable &)> > | on_focus_handlers_ |
| std::vector< std::function< void(UIInteractable &)> > | on_unfocus_handlers_ |
Protected Attributes inherited from UIObject | |
| float | width_ |
| float | height_ |
| Point | pivot_ |
| Point | anchor_ |
A UI input field element.
UIInput represents a text input field in the user interface. It inherits from UIInteractable and adds properties and behaviors specific to text input, such as handling focus, text content, and text color.
| UIInput::UIInput | ( | Scene & | scene, |
| float | width, | ||
| float | height, | ||
| Point | pivot, | ||
| Point | anchor, | ||
| const std::string & | placeholder = "", |
||
| const std::string & | font = "", |
||
| const std::string & | font_path = "", |
||
| const std::string & | sprite_path = "" |
||
| ) |
| int UIInput::font_size | ( | ) | const |
| Color UIInput::input_color | ( | ) | const |
|
overridevirtual |
Event hook for when the element gains focus.
Reimplemented from UIInteractable.
|
overridevirtual |
Event hook for when the element is hovered.
Reimplemented from UIInteractable.
|
overridevirtual |
Event hook for when the element loses focus.
Reimplemented from UIInteractable.
|
overridevirtual |
Event hook for when the element is unhovered.
Reimplemented from UIInteractable.
| std::string UIInput::text | ( | ) | const |
| Color UIInput::text_color | ( | ) | const |
Update the UI object.
This should be overridden by derived classes to implement specific update logic. Such as handling animations or state changes (e.g pressed, hovered, etc.).
| dt | Delta time since the last update. |
Reimplemented from UIObject.