FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::ObjTextInputBox Class Reference
Inheritance diagram for fge::ObjTextInputBox:
fge::Object fge::Subscriber fge::GuiElement fge::Drawable fge::Transformable fge::Anchor

Public Types

enum class  DrawModes : uint8_t { DRAW_IF_ON_TARGET , DRAW_ALWAYS_HIDDEN , DRAW_ALWAYS_DRAWN , DRAW_DEFAULT = DRAW_IF_ON_TARGET }
 
enum class  CallbackContextModes : uint8_t { CONTEXT_MANUAL , CONTEXT_AUTO , CONTEXT_DEFAULT = CONTEXT_AUTO }
 
enum  ChildrenControlFlags : uint8_t { CHILDREN_AUTO_CLEAR_ON_REMOVE = 1 << 0 , CHILDREN_AUTO_UPDATE = 1 << 1 , CHILDREN_AUTO_DRAW = 1 << 2 , CHILDREN_DEFAULT = CHILDREN_AUTO_CLEAR_ON_REMOVE }
 
using ChildrenControlFlags_t = std::underlying_type_t<ChildrenControlFlags>
 
enum class  Types : uint8_t {
  ANCHOR_NONE , ANCHOR_UPLEFT_CORNER , ANCHOR_UPRIGHT_CORNER , ANCHOR_DOWNLEFT_CORNER ,
  ANCHOR_DOWNRIGHT_CORNER
}
 
enum class  Shifts : uint8_t { SHIFT_NONE , SHIFT_POSITIVE_BOUNDS , SHIFT_NEGATIVE_BOUNDS }
 
using Priority = uint8_t
 

Public Member Functions

 ObjTextInputBox (fge::Font const &font, uint16_t maxLength=10, fge::Vector2f const &pos=fge::Vector2f())
 
fge::GuiElementgetGuiElement () override
 Get the GuiElement attached to this object if there is one.
 
void setString (tiny_utf8::string string)
 
void setFont (fge::Font font)
 
void setCharacterSize (fge::CharacterSize size)
 
void setHideTextFlag (bool flag)
 
void setMaxLength (uint16_t length)
 
void setActiveStat (bool active)
 
void setBoxSize (fge::Vector2f const &size)
 
void setBoxSize (float w, float h)
 
void setBoxColor (fge::Color const &color)
 
void setBoxOutlineColor (fge::Color const &color)
 
void setTextColor (fge::Color const &color)
 
tiny_utf8::string const & getString () const
 
fge::CharacterSize getCharacterSize () const
 
bool isTextHide () const
 
uint16_t getMaxLength () const
 
bool getActiveStat () const
 
fge::Vector2f const & getBoxSize () const
 
fge::Color const & getBoxColor () const
 
fge::Color const & getBoxOutlineColor () const
 
fge::Color const & getTextColor () const
 
void callbackRegister (fge::Event &event, fge::GuiElementHandler *guiElementHandlerPtr) override
 Ask the object to register all callbacks it needs to receive events.
 
FGE_OBJ_UPDATE_DECLARE FGE_OBJ_DRAW_DECLARE void save (nlohmann::json &jsonObject, fge::Scene *scene) override
 Save the object to a json object.
 
void load (nlohmann::json &jsonObject, fge::Scene *scene) override
 Load the object from a json object.
 
void pack (fge::net::Packet &pck) override
 Pack the object into a packet.
 
void unpack (fge::net::Packet const &pck) override
 Unpack the object from a packet.
 
char const * getClassName () const override
 Get the unique class name of the object.
 
char const * getReadableClassName () const override
 Get a readable version of the class name.
 
fge::RectFloat getGlobalBounds () const override
 Get the global bounds of the object.
 
fge::RectFloat getLocalBounds () const override
 Get the local bounds of the object (without any transformations)
 
virtual fge::Objectcopy ()
 Duplicate the object.
 
virtual void first (fge::Scene &scene)
 Method called when the object is added to a scene for initialization purposes.
 
virtual void transfered (fge::Scene &oldScene, fge::Scene &newScene)
 Method called when the object is transferred from a scene to another.
 
virtual void update (fge::RenderWindow &screen, fge::Event &event, std::chrono::microseconds const &deltaTime, fge::Scene &scene)
 Main method called every frame.
 
void update (fge::RenderWindow &screen, fge::Event &event, std::chrono::microseconds const &deltaTime)
 
virtual void draw (fge::RenderTarget &target, fge::RenderStates const &states) const override
 Method called every frame to draw the object.
 
virtual void networkRegister ()
 Register all network types needed by the object.
 
virtual void netSignaled (int8_t signal)
 Method called when the object is signaled by the network.
 
virtual void removed (fge::Scene &scene)
 Method called when the object is removed from a scene.
 
virtual fge::Quad getGlobalQuad () const
 
virtual fge::Quad getLocalQuad () const
 
bool saveInFile (std::string const &path)
 Save the object in a file.
 
bool loadFromFile (std::string const &path)
 Load the object from a file.
 
glm::mat4 getParentsTransform () const
 Retrieve recursively all parents transform by combining them.
 
fge::Vector2f getParentsScale () const
 Retrieve recursively all parents scale by combining them.
 
void setPosition (Vector2f const &position)
 
Vector2f const & getPosition () const
 
void move (Vector2f const &offset)
 
void setRotation (float angle)
 
float getRotation () const
 
void rotate (float angle)
 
void setScale (Vector2f const &factors)
 
void setScale (float factor)
 
Vector2f const & getScale () const
 
void scale (Vector2f const &factor)
 
void scale (float factor)
 
void setOrigin (Vector2f const &origin)
 
Vector2f const & getOrigin () const
 
glm::mat4 const & getTransform () const
 
glm::mat4 const & getInverseTransform () const
 
void updateAnchor (fge::Vector2f const &customTargetSize={0.0f, 0.0f})
 
void setAnchor (Types type, fge::Vector2< Shifts > const &shift, fge::ObjectSid target=std::numeric_limits< fge::ObjectSid >::max())
 
void setAnchorType (Types type)
 
void setAnchorShift (fge::Vector2< Shifts > const &shift)
 
void setAnchorTarget (fge::ObjectSid target)
 
Types getAnchorType () const
 
fge::Vector2< Shifts > const & getAnchorShift () const
 
fge::ObjectSid getAnchorTarget () const
 
fge::ObjectgetAnchorOwner () const
 
void setAnchorSuccessor (fge::ObjectDataWeak successor)
 
fge::ObjectDataWeak getAnchorSuccessor () const
 
void needAnchorUpdate (bool flag)
 
bool isNeedingAnchorUpdate () const
 
void detachAll ()
 Detach from all subscriptions.
 
void detach (fge::Subscription *subscription)
 Detach from a specific subscription.
 
virtual bool isRecursive () const
 Check if this GuiElement is recursive.
 
void setGuiScale (fge::Vector2f const &scale)
 Set the scale of the element.
 
fge::Vector2f const & getGuiScale () const
 Get the scale of the element.
 
void setPriority (fge::GuiElement::Priority priority) const
 Set the priority of the element.
 
fge::GuiElement::Priority getPriority () const
 Get the priority of the element.
 
bool verifyPriority (fge::GuiElement *element) const
 Verify if the priority of the element is higher than the given element.
 

Static Public Member Functions

static fge::ObjectLoadFromFile (std::string const &path)
 Static form of the loadFromFile method.
 
static void setGlobalGuiScale (fge::Vector2f const &scale)
 
static fge::Vector2f const & getGlobalGuiScale ()
 

Public Attributes

fge::CallbackHandler< fge::ObjTextInputBox & > _onStatChange
 
fge::CallbackHandler< fge::ObjTextInputBox & > _onReturn
 
fge::TagList _tags
 The tags of the object.
 
fge::PropertyList _properties
 The properties of the object.
 
fge::net::NetworkTypeHandler _netList
 The network types container of the object.
 
fge::ObjectDataWeak _myObjectData
 The object data of the object (valid only if the object is in a scene)
 
fge::Object::DrawModes _drawMode
 Tell a scene when this object should be drawn.
 
fge::Object::CallbackContextModes _callbackContextMode
 Tell a scene how the callbackRegister must be called.
 
ChildrenControlFlags_t _childrenControlFlags {CHILDREN_DEFAULT}
 The control flags of the child objects.
 
fge::ChildObjectsAccessor _children
 An access to child objects of this object.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseWheelEvent const &, fge::GuiElementContext & > _onGuiMouseWheelScrolled
 Callback called when the element is verified and the mouse wheel is scrolled.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const &, fge::GuiElementContext & > _onGuiMouseButtonPressed
 Callback called when the element is verified and the mouse is pressed.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseButtonEvent const &, fge::GuiElementContext & > _onGuiMouseButtonReleased
 Callback called when the element is verified and a mouse button is released.
 
fge::CallbackHandler< fge::Event const &, SDL_MouseMotionEvent const &, fge::GuiElementContext & > _onGuiMouseMoved
 Callback called when the element is verified and the mouse is moved.
 

Static Public Attributes

static fge::CallbackHandler< fge::Vector2f const & > _onGlobalGuiScaleChange
 

Protected Member Functions

virtual void onDetach (fge::Subscription *subscription)
 Callback called when a subscription is detached.
 

Protected Attributes

fge::GuiElement::Priority _g_priority { 50 }
 
fge::Vector2f _g_scale {1.0f, 1.0f}
 

Member Function Documentation

◆ callbackRegister()

void fge::ObjTextInputBox::callbackRegister ( fge::Event & event,
fge::GuiElementHandler * guiElementHandlerPtr )
overridevirtual

Ask the object to register all callbacks it needs to receive events.

Parameters
eventThe event system
guiElementHandlerPtrThe GUI element handler

Reimplemented from fge::Object.

◆ copy()

virtual fge::Object * fge::Object::copy ( )
virtualinherited

Duplicate the object.

By default, if the copy method is not overridden, the object is duplicated with the help of the register manager (and the object class have to be registered).

Returns
A allocated pointer to the duplicated object

Reimplemented in fge::ObjAnimation, fge::ObjButton, fge::ObjLight, fge::ObjRenderMap, fge::ObjShaderChain, fge::ObjSprite, fge::ObjSpriteBatches, fge::ObjSpriteCluster, fge::ObjSwitch, fge::ObjText, fge::ObjTileMap, and fge::ObjWindow.

◆ detach()

void fge::Subscriber::detach ( fge::Subscription * subscription)
inherited

Detach from a specific subscription.

Parameters
subscription

◆ detachAll()

void fge::Subscriber::detachAll ( )
inherited

Detach from all subscriptions.

◆ draw()

virtual void fge::Object::draw ( fge::RenderTarget & target,
fge::RenderStates const & states ) const
overridevirtualinherited

Method called every frame to draw the object.

Parameters
targetThe target where the object is drawn
statesThe render states

Implements fge::Drawable.

Reimplemented in fge::ObjAnimation, fge::ObjButton, fge::ObjLight, fge::ObjRenderMap, fge::ObjShaderChain, fge::ObjShape, fge::ObjSprite, fge::ObjSpriteBatches, fge::ObjSpriteCluster, fge::ObjSwitch, fge::ObjText, fge::ObjTileMap, and fge::ObjWindow.

◆ first()

virtual void fge::Object::first ( fge::Scene & scene)
virtualinherited

Method called when the object is added to a scene for initialization purposes.

Parameters
sceneThe scene where the object is added

Reimplemented in fge::ObjLight, fge::ObjRenderMap, fge::ObjShaderChain, fge::ObjShape, fge::ObjSlider, fge::ObjTextList, and fge::ObjWindow.

◆ getClassName()

char const * fge::ObjTextInputBox::getClassName ( ) const
overridevirtual

Get the unique class name of the object.

Returns
The unique class name of the object

Reimplemented from fge::Object.

◆ getGlobalBounds()

fge::RectFloat fge::ObjTextInputBox::getGlobalBounds ( ) const
overridevirtual

Get the global bounds of the object.

Returns
The global bounds of the object

Reimplemented from fge::Object.

◆ getGuiElement()

fge::GuiElement * fge::ObjTextInputBox::getGuiElement ( )
inlineoverridevirtual

Get the GuiElement attached to this object if there is one.

Returns
The GuiElement pointer or nullptr

Reimplemented from fge::Object.

◆ getGuiScale()

fge::Vector2f const & fge::GuiElement::getGuiScale ( ) const
inlinenodiscardinherited

Get the scale of the element.

Returns
The scale of the element

◆ getLocalBounds()

fge::RectFloat fge::ObjTextInputBox::getLocalBounds ( ) const
overridevirtual

Get the local bounds of the object (without any transformations)

Returns
The local bounds of the object

Reimplemented from fge::Object.

◆ getParentsScale()

fge::Vector2f fge::Object::getParentsScale ( ) const
inherited

Retrieve recursively all parents scale by combining them.

Returns
Parents scale

◆ getParentsTransform()

glm::mat4 fge::Object::getParentsTransform ( ) const
inherited

Retrieve recursively all parents transform by combining them.

Returns
Parents transform

◆ getPriority()

fge::GuiElement::Priority fge::GuiElement::getPriority ( ) const
inlinenodiscardinherited

Get the priority of the element.

Returns
The priority of the element

◆ getReadableClassName()

char const * fge::ObjTextInputBox::getReadableClassName ( ) const
overridevirtual

Get a readable version of the class name.

Returns
A readable version of the class name

Reimplemented from fge::Object.

◆ isRecursive()

virtual bool fge::GuiElement::isRecursive ( ) const
inlinenodiscardvirtualinherited

Check if this GuiElement is recursive.

A gui element is recursive if it handle others GuiElements.

Returns
true if it is recursive, false otherwise

Reimplemented in fge::GuiElementRecursive.

◆ load()

void fge::ObjTextInputBox::load ( nlohmann::json & jsonObject,
fge::Scene * scene )
overridevirtual

Load the object from a json object.

Parameters
jsonObjectThe json object where the object is loaded
sceneThe scene where the object is loaded (can be nullptr)

Reimplemented from fge::Object.

◆ LoadFromFile()

static fge::Object * fge::Object::LoadFromFile ( std::string const & path)
staticinherited

Static form of the loadFromFile method.

Parameters
pathThe path of the file
Returns
The allocated pointer of the loaded object or nullptr if the object was not loaded

◆ loadFromFile()

bool fge::Object::loadFromFile ( std::string const & path)
inherited

Load the object from a file.

Parameters
pathThe path of the file
Returns
true if the object was loaded, false otherwise

◆ netSignaled()

virtual void fge::Object::netSignaled ( int8_t signal)
virtualinherited

Method called when the object is signaled by the network.

Parameters
signalThe signal received

◆ networkRegister()

virtual void fge::Object::networkRegister ( )
virtualinherited

Register all network types needed by the object.

◆ onDetach()

virtual void fge::Subscriber::onDetach ( fge::Subscription * subscription)
inlineprotectedvirtualinherited

Callback called when a subscription is detached.

Parameters
subscriptionThe subscription that was detached

◆ pack()

void fge::ObjTextInputBox::pack ( fge::net::Packet & pck)
overridevirtual

Pack the object into a packet.

Parameters
pckThe packet where the object is packed

Reimplemented from fge::Object.

◆ removed()

virtual void fge::Object::removed ( fge::Scene & scene)
virtualinherited

Method called when the object is removed from a scene.

Parameters
sceneThe scene where the object is removed

Reimplemented in fge::ObjRenderMap, and fge::ObjWindow.

◆ save()

FGE_OBJ_UPDATE_DECLARE FGE_OBJ_DRAW_DECLARE void fge::ObjTextInputBox::save ( nlohmann::json & jsonObject,
fge::Scene * scene )
overridevirtual

Save the object to a json object.

Parameters
jsonObjectThe json object where the object is saved
sceneThe scene where the object is saved (can be nullptr)

Reimplemented from fge::Object.

◆ saveInFile()

bool fge::Object::saveInFile ( std::string const & path)
inherited

Save the object in a file.

Parameters
pathThe path of the file
Returns
true if the object was saved, false otherwise

◆ setGuiScale()

void fge::GuiElement::setGuiScale ( fge::Vector2f const & scale)
inlineinherited

Set the scale of the element.

Parameters
scaleThe scale of the element

◆ setPriority()

void fge::GuiElement::setPriority ( fge::GuiElement::Priority priority) const
inlineinherited

Set the priority of the element.

The priority value can be used with the scene DepthPlan.

Parameters
priorityThe priority of the element

◆ transfered()

virtual void fge::Object::transfered ( fge::Scene & oldScene,
fge::Scene & newScene )
virtualinherited

Method called when the object is transferred from a scene to another.

This method is called after the object is removed from the old scene and added to the new scene. The _myObjectData is updated to the new scene when this method is called.

Parameters
oldSceneThe old scene where the object was
newSceneThe new scene where the object is

◆ unpack()

void fge::ObjTextInputBox::unpack ( fge::net::Packet const & pck)
overridevirtual

Unpack the object from a packet.

Parameters
pckThe packet where the object is unpacked

Reimplemented from fge::Object.

◆ update()

virtual void fge::Object::update ( fge::RenderWindow & screen,
fge::Event & event,
std::chrono::microseconds const & deltaTime,
fge::Scene & scene )
virtualinherited

Main method called every frame.

Parameters
screenThe screen where the object is drawn
eventThe event system
deltaTimeThe time since the last frame
sceneThe scene where the object is updated

Reimplemented in fge::ObjAnimation, fge::ObjLight, fge::ObjRenderMap, fge::ObjSwitch, and fge::ObjWindow.

◆ verifyPriority()

bool fge::GuiElement::verifyPriority ( fge::GuiElement * element) const
inlinenodiscardinherited

Verify if the priority of the element is higher than the given element.

If the provided element is null, the function will assume that the element is the highest priority.

Parameters
elementThe element to compare with
Returns
true if the priority of the element is higher than the given element, false otherwise

Member Data Documentation

◆ _callbackContextMode

fge::Object::CallbackContextModes fge::Object::_callbackContextMode
inherited
Initial value:
{
fge::Object::CallbackContextModes::
CONTEXT_DEFAULT}

Tell a scene how the callbackRegister must be called.

◆ _children

fge::ChildObjectsAccessor fge::Object::_children
inherited

An access to child objects of this object.

◆ _childrenControlFlags

ChildrenControlFlags_t fge::Object::_childrenControlFlags {CHILDREN_DEFAULT}
inherited

The control flags of the child objects.

◆ _drawMode

fge::Object::DrawModes fge::Object::_drawMode
inherited
Initial value:
{
fge::Object::DrawModes::DRAW_DEFAULT}

Tell a scene when this object should be drawn.

◆ _myObjectData

fge::ObjectDataWeak fge::Object::_myObjectData
inherited

The object data of the object (valid only if the object is in a scene)

◆ _netList

fge::net::NetworkTypeHandler fge::Object::_netList
inherited

The network types container of the object.

◆ _onGuiMouseButtonPressed

fge::CallbackHandler<fge::Event const&, SDL_MouseButtonEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseButtonPressed
inherited

Callback called when the element is verified and the mouse is pressed.

◆ _onGuiMouseButtonReleased

fge::CallbackHandler<fge::Event const&, SDL_MouseButtonEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseButtonReleased
inherited

Callback called when the element is verified and a mouse button is released.

◆ _onGuiMouseMoved

fge::CallbackHandler<fge::Event const&, SDL_MouseMotionEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseMoved
inherited

Callback called when the element is verified and the mouse is moved.

◆ _onGuiMouseWheelScrolled

fge::CallbackHandler<fge::Event const&, SDL_MouseWheelEvent const&, fge::GuiElementContext&> fge::GuiElement::_onGuiMouseWheelScrolled
inherited

Callback called when the element is verified and the mouse wheel is scrolled.

◆ _properties

fge::PropertyList fge::Object::_properties
inherited

The properties of the object.

◆ _tags

fge::TagList fge::Object::_tags
inherited

The tags of the object.


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