TurtleBrains  0.2.1
High quality, portable, C++ API for native application and game development.
TurtleBrains::Graphics::GraphicList Class Reference

#include <tb_graphic_list.h>

Inheritance diagram for TurtleBrains::Graphics::GraphicList:
TurtleBrains::Graphics::Graphic TurtleBrains::Game::Entity TurtleBrains::Game::EntityManager TurtleBrains::Game::GameScene

Public Member Functions

 GraphicList (void)
 
virtual ~GraphicList (void)
 
void AddGraphic (Graphic *graphic)
 
void AddGraphic (Graphic &graphic)
 
void RemoveGraphic (Graphic *graphic)
 
virtual void SetColor (const tbGraphics::Color &newColor) override
 
- Public Member Functions inherited from TurtleBrains::Graphics::Graphic
 Graphic (void)
 
 Graphic (const Graphic &other)
 
virtual ~Graphic (void)
 
bool IsActive (void) const
 
void SetActive (const bool isActive)
 
void Update (const float deltaTime)
 
bool IsVisible (void) const
 
void SetVisible (const bool isVisible)
 
void Render (void) const
 
const tbMath::Vector2GetPosition (void) const
 
void SetPosition (const float x, const float y)
 
void SetPosition (const tbMath::Vector2 &position)
 
void SetOrigin (const AnchorLocation &anchor)
 
void SetOrigin (const float originX, const float originY)
 
float GetDepth (void) const
 
void SetDepth (const float newDepth)
 
void SetScale (const float scale)
 
void SetScale (const float scaleX, const float scaleY)
 
void SetRotation (const float rotation)
 
float GetRotation (void) const
 
void SetScroll (const float scroll)
 
void SetScroll (const float scrollX, const float scrollY)
 
bool IsRelative (void) const
 
virtual PixelSpace GetPixelWidth (void) const
 
virtual PixelSpace GetPixelHeight (void) const
 
float GetWidth (void) const
 
float GetHeight (void) const
 

Protected Member Functions

virtual void OnUpdate (const float deltaTime) override
 
virtual void OnRender (void) const override
 
- Protected Member Functions inherited from TurtleBrains::Graphics::Graphic
const ColorGetColor (void) const
 
virtual void ApplyTransform (void) const
 
virtual void PopTransform (void) const
 

Detailed Description

A GraphicList is a container of Graphic objects that get updated and rendered when the GraphicList gets updated or rendered. The contained Graphic objects are sorted and updated/rendered based on their depth in the scene. Depending on how the Graphic object is added to the GraphicList, the memory may also be deleted. See the difference between AddGraphic(Graphic&) and AddGraphic(Graphic*).

Constructor & Destructor Documentation

TurtleBrains::Graphics::GraphicList::GraphicList ( void  )

Constructs an empty list of Graphic objects. Use AddGraphic() to add Graphic objects to be updated and rendered by the GraphicList object.

virtual TurtleBrains::Graphics::GraphicList::~GraphicList ( void  )
virtual

Destructs the GraphicList object, which does not clean up any resources associated with the Graphic objects that were added to the list with AddGraphic.

Member Function Documentation

void TurtleBrains::Graphics::GraphicList::AddGraphic ( Graphic graphic)

Adds a Graphic to the list so it will be updated, if active, and rendered, if visible, whenever the object is updated or rendered. The memory for the graphic is managed and delete graphic; will be called when either the GraphicList is destroyed or the Graphic is removed with RemoveGraphic().

void TurtleBrains::Graphics::GraphicList::AddGraphic ( Graphic graphic)

Adds a Graphic to the list so it will be updated, if active, and rendered, if visible, whenever the object is updated or rendered. The memory for the graphic is NOT managed and must remain available and in scope until it is removed with RemoveGraphic(). The GraphicList will not 'own' a Graphic added this way.

virtual void TurtleBrains::Graphics::GraphicList::OnRender ( void  ) const
overrideprotectedvirtual

Calls Render() on each Graphic object contained in the list which will then call OnRender() if the object is visible.

Note
This will currently trigger an error condition if the Graphic object is not relative to the parent location as this feature is currently unimplemented. TODO: TIM: Implementation: Needs to be implemented.

Implements TurtleBrains::Graphics::Graphic.

Reimplemented in TurtleBrains::Game::Entity, and TurtleBrains::Game::GameScene.

virtual void TurtleBrains::Graphics::GraphicList::OnUpdate ( const float  deltaTime)
overrideprotectedvirtual

Calls Update() on each Graphic object contained in the list which will then call OnUpdate() if the object is active.

Reimplemented from TurtleBrains::Graphics::Graphic.

Reimplemented in TurtleBrains::Game::Entity, TurtleBrains::Game::EntityManager, and TurtleBrains::Game::GameScene.

void TurtleBrains::Graphics::GraphicList::RemoveGraphic ( Graphic graphic)

Removes a Graphic from the list so it will no longer be updated or rendered. This will only clean up memory or resources used by the graphic if added with AddGraphic(Graphic*), but those added with AddGraphic(Graphic&) are expected that the graphic remained available until it was removed.

virtual void TurtleBrains::Graphics::GraphicList::SetColor ( const tbGraphics::Color newColor)
overridevirtual

Changes the color of all the Graphic objects in the GraphicList.

Reimplemented from TurtleBrains::Graphics::Graphic.