1 #ifndef AETHER_ELEMENT_HPP 2 #define AETHER_ELEMENT_HPP 4 #include "Aether/types/Drawable.hpp" 5 #include "Aether/InputEvent.hpp" 34 std::function<void()> onPressFunc_;
110 Element(
int x = 0,
int y = 0,
int w = 100,
int h = 100);
145 virtual void setX(
int x);
152 virtual void setY(
int y);
159 virtual void setW(
int w);
166 virtual void setH(
int h);
174 virtual void setXY(
int x,
int y);
182 virtual void setWH(
int w,
int h);
427 void onPress(std::function<
void()> f);
443 virtual void update(
unsigned int dt);
virtual void removeAllElements()
Deletes all children elements.
void setHidden(bool b)
Set whether element is hidden or not.
std::function< void()> onPressFunc()
Returns function invoked when the element is pressed.
void setSelectable(bool b)
Set whether element is selectable or not.
virtual void setSelected(bool b)
Set whether element is selected or not.
static Colour selColour
Selected colour if element is highlighted.
Definition: Element.hpp:61
bool hasHighlighted()
Check if current element has highlighted children element.
virtual void update(unsigned int dt)
Update is passed time since last frame (for animations)
void setHasSelected(bool b)
Set whether element has selected children element or not.
virtual Drawable * renderHighlightBG()
Renders the highlight background.
virtual void setWH(int w, int h)
Set size of element.
bool selected()
Check if current element is selected.
virtual void setH(int h)
Set height of element.
Element(int x=0, int y=0, int w=100, int h=100)
Construct a new Element object.
virtual bool handleEvent(InputEvent *e)
Attempt to handle a given event.
virtual Drawable * renderHighlight()
Renders the highlight border.
virtual Drawable * renderSelection()
Renders the selection overlay.
static bool isTouch
Indicator on whether the touch is "active" (i.e. hide highlighting) or not.
Definition: Element.hpp:79
Element * parent_
Pointer to parent element, if there is one.
Definition: Element.hpp:81
void setHighlighted(bool b)
Set whether element is highlighted or not.
static Colour hiBorderColour
Border colour if element is highlighted.
Definition: Element.hpp:59
Element * focused()
Returns the currently focused element.
Aether's main renderer instance. It provides all methods relating to drawing directly to the screen...
Definition: Renderer.hpp:30
virtual void addElement(Element *e)
Adds new element a child.
bool hasSelectable()
Check if current element has selectable children element.
virtual void setW(int w)
Set width of element.
bool touchable()
Check if current element is touch responsive.
static Drawable * hiBGTex
Highlight background texture.
Definition: Element.hpp:65
Element * focussed()
Returns the currently focused element.
bool hidden()
Check if current element is hidden.
virtual void setY(int y)
Set y-coordinate of element.
int w()
Returns width of element.
Stores RGBA values representing a colour. Each component can be within the range 0 to 255 (inclusive)...
Definition: Colour.hpp:9
Stores either a surface or texture which can be drawn on screen by providing a renderer to render()...
Definition: Drawable.hpp:22
int x()
Returns x-coordinate of element.
void onPress(std::function< void()> f)
Sets the function to invoked when the element is pressed.
virtual void setInactive()
Set element as in-activated.
virtual void setX(int x)
Set x-coordinate of element.
Element is the base class to be inherited to form all other types of elements.
Definition: Element.hpp:18
static unsigned int hiSize
Size of highlight border.
Definition: Element.hpp:63
int h()
Returns height of element.
Base namespace for all Aether related classes and functions.
virtual void returnAllElements()
Removes (but does not delete) all children elements.
virtual void setActive()
Set element as activated.
void setTouchable(bool b)
Set whether element is touch responsive or not.
void setHasHighlighted(bool b)
Set whether element has highlighted children element or not.
void setFocussed(Element *e)
Sets current element as unfocused and instead focuses a sub-element.
std::vector< Element * > children
Vector of child elements (used to call their methods)
Definition: Element.hpp:83
friend void moveHighlight(Element *e)
Returns the element currently highlighted within given element or nullptr if none found...
virtual void setXYWH(int x, int y, int w, int h)
Setter size and co-ordinates of element.
bool isVisible()
Check if current element is visible on-screen.
static Drawable * selTex
Selection texture.
Definition: Element.hpp:69
virtual void render()
Render child elements + highlights.
void renderHighlightTextures()
Renders cached highlight textures.
bool hasSelected()
Check if current element has selected children element.
Element * focused_
Children element which is highlighted/focused (to regain focus on activation)
Definition: Element.hpp:85
virtual ~Element()
Destroy the Element object.
void setFocused(Element *e)
Sets current element as unfocused and instead focuses a sub-element.
static Drawable * hiBorderTex
Highlight border texture.
Definition: Element.hpp:67
virtual bool returnElement(Element *e)
Attempt to remove the given child element.
void setHasSelectable(bool b)
Set whether element has selectable children element or not.
void setParent(Element *p)
Set the parent element of this element.
The Window is the root element, which initializes Aether and contains all of the screens/elements to ...
Definition: Window.hpp:27
static Colour hiBGColour
Background colour if element is highlighted.
Definition: Element.hpp:57
virtual bool removeElement(Element *e)
Attempt to delete given child element.
void renderSelectionTexture()
Renders cached selection texture.
bool selectable()
Check if current element is selectable.
void addElementAt(Element *e, size_t i)
Add element at given index in vector.
Element * parent()
Returns the parent element of this element.
bool highlighted()
Check if current element is highlighted.
virtual void setXY(int x, int y)
Set co-ordinates of element.
int y()
Returns y-coordinate of element.