Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
text_area.h
Go to the documentation of this file.
1 #ifndef TEXT_AREA_H
2 #define TEXT_AREA_H
3 
4 #include <memory>
5 #include "graphics/ui/element.h"
6 #include "graphics/ui/skin.h"
7 #include "graphics/ui/area.h"
9 #include "events/event.h"
10 //= SCRIPTABLE
11 //= SCRIPTABLE BASES Area
12 
13 namespace Graphics {
14  namespace UI {
18  class TextArea : public Area, virtual public el::Loggable {
19  private:
20  std::shared_ptr<WrappableText> text;
21  const glm::vec4 mouse_over_dim = glm::vec4(0.2, 0.2, 0.2, 0.0);
22  public:
23  //= BEGIN SCRIPTABLE
24 
32  TextArea(std::shared_ptr<WrappableText> text, VertexData vertex_data, std::shared_ptr<Skin> skin, const unsigned int layer);
50  static std::shared_ptr<TextArea> create(std::shared_ptr<Skin> skin, std::shared_ptr<WrappableText> text, glm::vec4 color, glm::vec4 text_color, float padding, float screen_width, float screen_height, float x_pos, float y_pos, float width, float height, const unsigned int layer);
51 
57  void setText(std::shared_ptr<WrappableText> text);
63  std::shared_ptr<WrappableText> getText() const noexcept;
64  virtual void onLeftClick() override;
65  virtual void onRightClick() override;
66  virtual void onLeftClickRelease() override;
67  virtual void onRightClickRelease() override;
68  virtual void onCursorEnter() override;
69  virtual void onCursorLeave() override;
70  virtual void onKeyDown(const int key) override;
71  virtual void onKeyUp(const int key) override;
72  virtual void onKeyRepeat(const int key) override;
73  virtual void onScroll(const glm::dvec2 position_change) override;
74  virtual void onDestroy() override;
75  virtual void onStart() override;
76  virtual bool onUpdate(const double delta) override;
82  virtual std::string to_string() const noexcept override;
83  virtual std::string className() const noexcept override;
84  //= END SCRIPTABLE
85 
86  void handleQueuedEvent(std::shared_ptr<Events::Event> event) override;
87  void onNotifyNow(std::shared_ptr<Events::Event> event) override;
88 
89 
90  virtual void log(el::base::type::ostream_t& os) const;
91  };
92  }
93 }
94 
95 #endif
virtual bool onUpdate(const double delta) override
Called every engine loop.
Definition: text_area.cpp:47
virtual std::string className() const noexceptoverride
Returns a string representing the class name.
Definition: text_area.cpp:99
TextArea(std::shared_ptr< WrappableText > text, VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
TextArea constructor.
Definition: text_area.cpp:8
virtual void onLeftClickRelease() override
Called when element has left click released over it.
Definition: text_area.cpp:73
virtual void onKeyRepeat(const int key) override
Called when a key is repeated while element is in focus.
Definition: text_area.cpp:93
virtual std::string to_string() const noexceptoverride
Returns a string representation of the object.
Definition: text_area.cpp:103
static std::shared_ptr< TextArea > create(std::shared_ptr< Skin > skin, std::shared_ptr< WrappableText > text, glm::vec4 color, glm::vec4 text_color, float padding, float screen_width, float screen_height, float x_pos, float y_pos, float width, float height, const unsigned int layer)
TextArea factory function.
Definition: text_area.cpp:12
virtual void onDestroy() override
Called when the engine is shutting down.
Definition: text_area.cpp:38
virtual void onLeftClick() override
Called when element is left clicked.
Definition: text_area.cpp:67
Class for vertex data.
Definition: vertex_data.h:17
virtual void onRightClickRelease() override
Called when element has right click released over it.
Definition: text_area.cpp:77
void setText(std::shared_ptr< WrappableText > text)
Sets the text.
Definition: text_area.cpp:30
virtual void onCursorLeave() override
Called when the mouse cursor goes off the element.
Definition: text_area.cpp:84
virtual void onRightClick() override
Called when element is right clicked.
Definition: text_area.cpp:70
virtual void onCursorEnter() override
Called when the mosue cursor goes over the element.
Definition: text_area.cpp:81
std::shared_ptr< WrappableText > getText() const noexcept
Gets the text.
Definition: text_area.cpp:34
virtual void log(el::base::type::ostream_t &os) const
Definition: text_area.cpp:109
virtual void onStart() override
Called when the engine starts and when a new scene is loaded.
Definition: text_area.cpp:42
void onNotifyNow(std::shared_ptr< Events::Event > event) override
When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure ...
Definition: text_area.cpp:63
void handleQueuedEvent(std::shared_ptr< Events::Event > event) override
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received...
Definition: text_area.cpp:51
virtual void onKeyUp(const int key) override
Called when a key is released while element is in focus.
Definition: text_area.cpp:90
virtual void onKeyDown(const int key) override
Called when a key is pressed while element is in focus.
Definition: text_area.cpp:87
Class for UI Area.
Definition: area.h:16
Class for text area.
Definition: text_area.h:18
virtual void onScroll(const glm::dvec2 position_change) override
Called when the mouse wheel is scrolled while element is in focus.
Definition: text_area.cpp:96