Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
button.h
Go to the documentation of this file.
1 #ifndef BUTTON_H
2 #define BUTTON_H
3 
5 
6 //= SCRIPTABLE
7 //= SCRIPTABLE BASES TextArea
8 namespace Graphics {
9  namespace UI {
13  class Button : public TextArea {
14  private:
15  bool cursor_over;
16  protected:
17  const glm::vec4 mouse_over_dim = glm::vec4(0.1, 0.1, 0.1, 0.0);
18  public:
19  //= BEGIN SCRIPTABLE
20 
28  Button(std::shared_ptr<WrappableText> text, VertexData vertex_data, std::shared_ptr<Skin> skin, const unsigned int layer);
46  static std::shared_ptr<Button> 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);
47 
48  virtual void onLeftClick() override;
49  virtual void onRightClick() override;
50  virtual void onLeftClickRelease() override;
51  virtual void onRightClickRelease() override;
52  virtual void onCursorEnter() override;
53  virtual void onCursorLeave() override;
54  virtual void onKeyDown(const int key) override;
55  virtual void onKeyUp(const int key) override;
56  virtual void onKeyRepeat(const int key) override;
57  virtual void onScroll(const glm::dvec2 position_change) override;
58  virtual std::string className() const noexcept override;
59  //= END SCRIPTABLE
60  void handleQueuedEvent(std::shared_ptr<Events::Event> event) override;
61  void onNotifyNow(std::shared_ptr<Events::Event> event) override;
62 
63  virtual void log(el::base::type::ostream_t& os) const;
64  };
65  }
66 }
67 
68 #endif
virtual void log(el::base::type::ostream_t &os) const
Definition: button.cpp:83
Class for UI button.
Definition: button.h:13
void handleQueuedEvent(std::shared_ptr< Events::Event > event) override
HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received...
Definition: button.cpp:28
virtual void onRightClickRelease() override
Called when element has right click released over it.
Definition: button.cpp:49
virtual std::string className() const noexceptoverride
Returns a string representing the class name.
Definition: button.cpp:79
static std::shared_ptr< Button > 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)
Factory function for Button.
Definition: button.cpp:10
Class for vertex data.
Definition: vertex_data.h:17
virtual void onLeftClickRelease() override
Called when element has left click released over it.
Definition: button.cpp:45
Button(std::shared_ptr< WrappableText > text, VertexData vertex_data, std::shared_ptr< Skin > skin, const unsigned int layer)
Button constructor.
Definition: button.cpp:6
virtual void onKeyRepeat(const int key) override
Called when a key is repeated while element is in focus.
Definition: button.cpp:71
virtual void onCursorLeave() override
Called when the mouse cursor goes off the element.
Definition: button.cpp:58
virtual void onKeyUp(const int key) override
Called when a key is released while element is in focus.
Definition: button.cpp:67
virtual void onKeyDown(const int key) override
Called when a key is pressed while element is in focus.
Definition: button.cpp:63
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: button.cpp:32
virtual void onCursorEnter() override
Called when the mosue cursor goes over the element.
Definition: button.cpp:53
Class for text area.
Definition: text_area.h:18
virtual void onLeftClick() override
Called when element is left clicked.
Definition: button.cpp:36
virtual void onScroll(const glm::dvec2 position_change) override
Called when the mouse wheel is scrolled while element is in focus.
Definition: button.cpp:75
const glm::vec4 mouse_over_dim
Definition: button.h:17
virtual void onRightClick() override
Called when element is right clicked.
Definition: button.cpp:41