LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::Canvas Class Referenceabstract

Canvas interface for mobile platforms. More...

#include <Canvas.h>

Inheritance diagram for LLGL::Canvas:
LLGL::Surface LLGL::Interface LLGL::NonCopyable

Classes

class  EventListener
 Interface for all canvas event listeners. More...

Public Member Functions

 ~Canvas ()
 Releases the internal data.
virtual void SetTitle (const UTF8String &title)=0
 Sets the canvas title as UTF-8 string.
virtual UTF8String GetTitle () const =0
 Returns the canvas title as UTF16 string.
bool AdaptForVideoMode (Extent2D *resolution, bool *fullscreen) override
 This default implementation ignores the video mode descriptor completely and always return false.
Display * FindResidentDisplay () const override final
 Always returns Display::GetPrimary.
void SetUserData (void *userData)
 Sets a raw pointer to some user defined data. The initial value is null.
void * GetUserData () const
 Returns the raw pointer that was previously set with SetUserData. The initial value is null.
void AddEventListener (const std::shared_ptr< EventListener > &eventListener)
 Adds a new event listener to this canvas.
void RemoveEventListener (const EventListener *eventListener)
 Removes the specified event listener from this canvas.
void PostInit ()
 Posts a signal that the canvas is initialized or re-initialized.
void PostDestroy ()
 Posts a signal that the canvas is about to be destroyed.
void PostDraw ()
 Posts a draw event to all event listeners.
void PostResize (const Extent2D &clientAreaSize)
 Posts a resize event to all event listeners.
void PostTapGesture (const Offset2D &position, std::uint32_t numTouches)
 Posts a tap gesture event to all event listeners.
void PostPanGesture (const Offset2D &position, std::uint32_t numTouches, float dx, float dy, EventAction action)
 Posts a pan gesture event to all event listeners.
void PostKeyDown (Key keyCode)
 Posts a keycode event from a device button that has been pushed down.
void PostKeyUp (Key keyCode)
 Posts a keycode event from a device button that has been released.
Public Member Functions inherited from LLGL::Surface
virtual bool GetNativeHandle (void *nativeHandle, std::size_t nativeHandleSize)=0
 Returns the native surface handle.
virtual Extent2D GetContentSize () const =0
 Returns the size (in pixels) of the surface content, i.e. the drawable area.
Public Member Functions inherited from LLGL::Interface
virtual bool IsInstanceOf (int id) const
 Returns true if this object is an instance of the specified interface.
Public Member Functions inherited from LLGL::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
virtual ~NonCopyable ()=default

Static Public Member Functions

static std::unique_ptr< Canvas > Create (const CanvasDescriptor &desc)
 Creates a platform specific instance of the Canvas interface.
Static Public Member Functions inherited from LLGL::Surface
static bool ProcessEvents ()
 Processes all windowing system events, i.e. input-, movement-, resize-, and other events for all surfaces associated with the host process.

Protected Member Functions

 Canvas ()
 Allocates the internal data.
Protected Member Functions inherited from LLGL::NonCopyable
 NonCopyable ()=default

Detailed Description

Canvas interface for mobile platforms.

Remarks
This is the main interface for the windowing system in LLGL on mobile platforms. The counterpart is the Window interface for desktop platforms.
See also
Window

Constructor & Destructor Documentation

◆ ~Canvas()

LLGL::Canvas::~Canvas ( )

Releases the internal data.

◆ Canvas()

LLGL::Canvas::Canvas ( )
protected

Allocates the internal data.

Member Function Documentation

◆ AdaptForVideoMode()

bool LLGL::Canvas::AdaptForVideoMode ( Extent2D * resolution,
bool * fullscreen )
overridevirtual

This default implementation ignores the video mode descriptor completely and always return false.

Implements LLGL::Surface.

◆ AddEventListener()

void LLGL::Canvas::AddEventListener ( const std::shared_ptr< EventListener > & eventListener)

Adds a new event listener to this canvas.

◆ Create()

std::unique_ptr< Canvas > LLGL::Canvas::Create ( const CanvasDescriptor & desc)
static

Creates a platform specific instance of the Canvas interface.

Returns
Unique pointer to a new instance of the platform specific Canvas interface or null if the platform does not support canvas (such as Windows, Linux, and macOS).
Remarks
For desktop platforms the interface Window can be used.
See also
Window

◆ FindResidentDisplay()

Display * LLGL::Canvas::FindResidentDisplay ( ) const
finaloverridevirtual

Always returns Display::GetPrimary.

Implements LLGL::Surface.

◆ GetTitle()

virtual UTF8String LLGL::Canvas::GetTitle ( ) const
pure virtual

Returns the canvas title as UTF16 string.

◆ GetUserData()

void * LLGL::Canvas::GetUserData ( ) const

Returns the raw pointer that was previously set with SetUserData. The initial value is null.

See also
SetUserData

◆ PostDestroy()

void LLGL::Canvas::PostDestroy ( )

Posts a signal that the canvas is about to be destroyed.

Remarks
A canvas can not only be destroyed when the app is about to close, but also when the app is paused, although this is platform dependent. On Android, this will be signaled on the APP_CMD_TERM_WINDOW command.
See also
EventListener::OnDestroy

◆ PostDraw()

void LLGL::Canvas::PostDraw ( )

Posts a draw event to all event listeners.

See also
EventListener::OnDraw

◆ PostInit()

void LLGL::Canvas::PostInit ( )

Posts a signal that the canvas is initialized or re-initialized.

Remarks
A canvas can not only be initialized when the app is launched, but also when the app is resumed, although this is platform dependent. On Android, this will be signaled on the APP_CMD_INIT_WINDOW command.
See also
EventListener::OnInit

◆ PostKeyDown()

void LLGL::Canvas::PostKeyDown ( Key keyCode)

Posts a keycode event from a device button that has been pushed down.

See also
EventListener::OnKeyDown

◆ PostKeyUp()

void LLGL::Canvas::PostKeyUp ( Key keyCode)

Posts a keycode event from a device button that has been released.

See also
EventListener::OnKeyUp

◆ PostPanGesture()

void LLGL::Canvas::PostPanGesture ( const Offset2D & position,
std::uint32_t numTouches,
float dx,
float dy,
EventAction action )

Posts a pan gesture event to all event listeners.

See also
EventListener::OnPanGesture

◆ PostResize()

void LLGL::Canvas::PostResize ( const Extent2D & clientAreaSize)

Posts a resize event to all event listeners.

See also
EventListener::OnResize

◆ PostTapGesture()

void LLGL::Canvas::PostTapGesture ( const Offset2D & position,
std::uint32_t numTouches )

Posts a tap gesture event to all event listeners.

See also
EventListener::OnTapGesture

◆ RemoveEventListener()

void LLGL::Canvas::RemoveEventListener ( const EventListener * eventListener)

Removes the specified event listener from this canvas.

◆ SetTitle()

virtual void LLGL::Canvas::SetTitle ( const UTF8String & title)
pure virtual

Sets the canvas title as UTF-8 string.

◆ SetUserData()

void LLGL::Canvas::SetUserData ( void * userData)

Sets a raw pointer to some user defined data. The initial value is null.

Remarks
This can be used to quickly associate an instance of this class with custom data, especially during event handling.

The documentation for this class was generated from the following file: