AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
IDrawable Class Referenceabstract

An abstract image that determines itself how it is displayed. Essentially an abstraction from vector and raster graphics.

#include <AUI/Image/IDrawable.h>

Classes#

struct  Params
 

Public Member Functions#

virtual AImage rasterize (glm::ivec2 imageSize)
 Converts possibly vector drawable to a raster image.
 
virtual void draw (IRenderer &render, const IDrawable::Params &params)=0
 Called when the image needs to be displayed. It is assumed that the renderer is already set to the desired state (coordinates, color, etc.)
 
virtual glm::ivec2 getSizeHint ()=0
 
virtual bool isDpiDependent () const
 

Static Public Member Functions#

static API_AUI_VIEWS _< IDrawablefromUrl (const AUrl &url) noexcept
 Creates a drawable from an url.
 

Member Function Documentation#

◆ draw()#

virtual void IDrawable::draw ( IRenderer & render,
const IDrawable::Params & params )
pure virtual

◆ fromUrl()#

static API_AUI_VIEWS _< IDrawable > IDrawable::fromUrl ( const AUrl & url)
staticnoexcept
Parameters
urlurl to create a drawable from
Returns
drawable instance or null

If some kind of error occurs during loading the drawable, a log entry [Drawable] is outputted with detailed description of an error. The reason is we don't want to crash our application if we didn't loaded some graphics, which is usually pretty optional stuff. The user can still do his job with the application without fancy images.

Examples
examples/ui/views/src/ExampleWindow.cpp.

◆ getSizeHint()#

virtual glm::ivec2 IDrawable::getSizeHint ( )
pure virtual
Returns
Size of the stored image. Can be ignored by the renderer. If the size is unknown, it can be {0, 0}

Implemented in AAnimatedDrawable, AImageDrawable, ANoiseDrawable, and AVectorDrawable.

◆ isDpiDependent()#

virtual bool IDrawable::isDpiDependent ( ) const
inlinevirtual
Returns
true if the size hint of this drawable needs to be multiplied by the DPI ratio

Reimplemented in AVectorDrawable.

◆ rasterize()#

virtual AImage IDrawable::rasterize ( glm::ivec2 imageSize)
virtual
Parameters
imageSizeimage size
Returns
rasterized image

TODO Unimplemented for all drawables except raster image and svg

Reimplemented in AImageDrawable, and AVectorDrawable.