Aether
SDL2 based UI Framework for NX
AsyncItem.hpp
1 #ifndef BASE_ASYNCITEM_HPP
2 #define BASE_ASYNCITEM_HPP
3 
4 #include "Aether/base/Texture.hpp"
5 
6 namespace Aether {
14  class AsyncItem : public Element {
15  private:
19  enum class Status {
20  NotRendered,
21  Rendering,
22  Rendered
23  };
24 
28  float fadeAmount;
29 
33  Status renderStatus;
34 
38  std::vector<Texture *> textures;
39 
47  virtual bool canRender();
48 
54  virtual int fadeSpeed();
55 
62  virtual void positionElements() = 0;
63 
72  virtual int renderThreshold();
73 
79  bool withinThreshold();
80 
81  protected:
88  void addTexture(Aether::Texture * texture);
89 
99  bool removeTexture(Aether::Texture * texture);
100 
105  bool ready();
106 
107  public:
111  AsyncItem();
112 
117  void update(uint32_t dt);
118 
125  void setW(int w);
126 
133  void setH(int h);
134  };
135 };
136 
137 #endif
void setW(int w)
Sets the width of the item, in pixels. Also calls updateElements() if textures are already rendered...
void addTexture(Aether::Texture *texture)
Adds the given texture to the item&#39;s monitoring list, causing it to be rendered/destroyed when needed...
bool removeTexture(Aether::Texture *texture)
Removes the given texture from the item&#39;s monitoring list, causing it to no longer be handled by the ...
void update(uint32_t dt)
Updates the state of child elements.
void setH(int h)
Sets the height of the item, in pixels. Also calls updateElements() if textures are already rendered...
int w()
Returns width of element.
bool ready()
Returns whether the element has all it&#39;s textures rendered.
A Texture is an element that stores a texture to render in the window. It can&#39;t be instantiated alone...
Definition: Texture.hpp:24
Element is the base class to be inherited to form all other types of elements.
Definition: Element.hpp:18
int h()
Returns height of element.
Base namespace for all Aether related classes and functions.
Abstract class which handles rendering child elements asynchronously based on the position of the ele...
Definition: AsyncItem.hpp:14
AsyncItem()
Creates a new AsyncItem.