TGUI  1.6.1
Loading...
Searching...
No Matches
tgui::Backend Class Referenceabstract

Base class for the backend. More...

#include <TGUI/Backend/Window/Backend.hpp>

Inheritance diagram for tgui::Backend:
tgui::BackendGLFW tgui::BackendRaylib tgui::BackendSDL tgui::BackendSFML

Public Member Functions

 Backend ()=default
 Default constructor.
 
 Backend (const Backend &)=delete
 
Backendoperator= (const Backend &)=delete
 
virtual ~Backend ()=default
 Virtual destructor.
 
void setDestroyOnLastGuiDetatch (bool destroyOnDetatch)
 Informs the backend whether it should destroy itself when the last Gui is detached from it.
 
virtual void attachGui (BackendGui *gui)
 Informs the backend that a new gui object has been created.
 
virtual void detatchGui (BackendGui *gui)
 Informs the backend that a gui object is being destroyed.
 
virtual Font createDefaultFont ()
 Creates and returns the default font for all widgets.
 
std::shared_ptr< BackendFontcreateFont ()
 Creates a new font object.
 
std::shared_ptr< BackendTextcreateText ()
 Creates a new text object.
 
std::shared_ptr< BackendTexturecreateTexture ()
 Creates a new texture object.
 
void setFontScale (float scale)
 Sets the scale factor to render text at a higher quality, e.g. to scale for DPI awareness.
 
float getFontScale () const
 Returns the scale factor to render text at a higher quality, e.g. to scale for DPI awareness.
 
virtual void setMouseCursorStyle (Cursor::Type type, const std::uint8_t *pixels, Vector2u size, Vector2u hotspot)=0
 Changes the look of a certain mouse cursor by using a bitmap.
 
virtual void resetMouseCursorStyle (Cursor::Type type)=0
 Changes the look of a certain mouse cursor back to the system theme.
 
virtual void setMouseCursor (BackendGui *gui, Cursor::Type type)=0
 Changes the mouse cursor when the mouse is on top of the window to which the gui is attached.
 
virtual void openVirtualKeyboard (const FloatRect &inputRect)
 Opens the virtual keyboard on Android and iOS.
 
virtual void closeVirtualKeyboard ()
 Closes the virtual keyboard on Android and iOS.
 
virtual bool isKeyboardModifierPressed (Event::KeyModifier modifierKey)=0
 Checks the state for one of the modifier keys.
 
virtual void setClipboard (const String &contents)
 Changes the contents of the clipboard.
 
virtual String getClipboard () const
 Returns the contents of the clipboard.
 
virtual std::unique_ptr< std::uint8_t[]> readFileFromAndroidAssets (const String &filename, std::size_t &fileSize) const
 Uses the AssetManager on Android to read a file and return its contents.
 
bool hasRenderer () const
 Checks whether a renderer has been attached to the backend.
 
std::shared_ptr< BackendRenderergetRenderer () const
 Returns the renderer.
 
virtual void setRenderer (std::shared_ptr< BackendRenderer > renderer)
 Sets the renderer that the backend should use.
 
bool hasFontBackend () const
 Checks whether a font factory has been attached to the backend.
 
std::shared_ptr< BackendFontFactorygetFontBackend () const
 Returns the font factory.
 
virtual void setFontBackend (std::shared_ptr< BackendFontFactory > fontBackend)
 Sets the font factory that the backend should use.
 
void registerFont (BackendFont *font)
 
void unregisterFont (BackendFont *font)
 
void registerSvgSprite (Sprite *sprite)
 
void unregisterSvgSprite (Sprite *sprite)
 

Protected Attributes

bool m_destroyOnLastGuiDetatch = false
 
String m_clipboardContents
 
float m_fontScale = 1
 
std::shared_ptr< BackendRendererm_renderer
 
std::shared_ptr< BackendFontFactorym_fontBackend
 
std::set< BackendGui * > m_guis
 
std::set< BackendFont * > m_registeredFonts
 
std::set< Sprite * > m_registeredSvgSprites
 

Detailed Description

Base class for the backend.

Member Function Documentation

◆ attachGui()

virtual void tgui::Backend::attachGui ( BackendGui * gui)
virtual

Informs the backend that a new gui object has been created.

Parameters
guiNewly created gui

◆ closeVirtualKeyboard()

virtual void tgui::Backend::closeVirtualKeyboard ( )
virtual

Closes the virtual keyboard on Android and iOS.

If this function isn't overriden then calling it does nothing.

Deprecated
Replaced by BackendGui::stopTextInput in TGUI 1.0

Reimplemented in tgui::BackendSDL, and tgui::BackendSFML.

◆ createDefaultFont()

virtual Font tgui::Backend::createDefaultFont ( )
nodiscardvirtual

Creates and returns the default font for all widgets.

Returns
Default font

◆ createFont()

std::shared_ptr< BackendFont > tgui::Backend::createFont ( )
nodiscard

Creates a new font object.

Returns
Font that is specific to the backend

◆ createText()

std::shared_ptr< BackendText > tgui::Backend::createText ( )
nodiscard

Creates a new text object.

Returns
Text that is specific to the backend

◆ createTexture()

std::shared_ptr< BackendTexture > tgui::Backend::createTexture ( )
nodiscard

Creates a new texture object.

Returns
Texture that is specific to the backend

◆ detatchGui()

virtual void tgui::Backend::detatchGui ( BackendGui * gui)
virtual

Informs the backend that a gui object is being destroyed.

Parameters
guiGui object that is about to be deconstructed

Reimplemented in tgui::BackendGLFW, tgui::BackendSDL, and tgui::BackendSFML.

◆ getClipboard()

virtual String tgui::Backend::getClipboard ( ) const
nodiscardvirtual

Returns the contents of the clipboard.

Returns
Clipboard contents

Reimplemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ getFontBackend()

std::shared_ptr< BackendFontFactory > tgui::Backend::getFontBackend ( ) const
nodiscard

Returns the font factory.

Returns
Font factory attached to the backend
Warning
This function will assert if no font factory has been set.
See also
hasFontBackend()

◆ getFontScale()

float tgui::Backend::getFontScale ( ) const

Returns the scale factor to render text at a higher quality, e.g. to scale for DPI awareness.

Returns
Multiplier for the font size
See also
setFontScale

◆ getRenderer()

std::shared_ptr< BackendRenderer > tgui::Backend::getRenderer ( ) const
nodiscard

Returns the renderer.

Returns
Renderer attached to the backend
Warning
This function will assert if no renderer has been set.
See also
hasRenderer()

◆ hasFontBackend()

bool tgui::Backend::hasFontBackend ( ) const
nodiscard

Checks whether a font factory has been attached to the backend.

Returns
Has setFontBackend been called with a valid font factory?

◆ hasRenderer()

bool tgui::Backend::hasRenderer ( ) const
nodiscard

Checks whether a renderer has been attached to the backend.

Returns
Has setRenderer been called with a valid backend renderer?

◆ isKeyboardModifierPressed()

virtual bool tgui::Backend::isKeyboardModifierPressed ( Event::KeyModifier modifierKey)
nodiscardpure virtual

Checks the state for one of the modifier keys.

Parameters
modifierKeyThe modifier key of which the state is being queried
Returns
Whether queries modifier key is being pressed

Implemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ openVirtualKeyboard()

virtual void tgui::Backend::openVirtualKeyboard ( const FloatRect & inputRect)
virtual

Opens the virtual keyboard on Android and iOS.

Parameters
inputRectPart of the screen where the text input is located

If this function isn't overriden then calling it does nothing.

Deprecated
Replaced by BackendGui::startTextInput in TGUI 1.0

Reimplemented in tgui::BackendSDL, and tgui::BackendSFML.

◆ readFileFromAndroidAssets()

virtual std::unique_ptr< std::uint8_t[]> tgui::Backend::readFileFromAndroidAssets ( const String & filename,
std::size_t & fileSize ) const
nodiscardvirtual

Uses the AssetManager on Android to read a file and return its contents.

Parameters
filenamePath to the file to read
fileSizeSize of the file, to be filled in by this function if loading succeeds (untouched on failure)
Returns
File contents if the file was successfully read, or a nullptr on failure or if platform isn't Android.

◆ resetMouseCursorStyle()

virtual void tgui::Backend::resetMouseCursorStyle ( Cursor::Type type)
pure virtual

Changes the look of a certain mouse cursor back to the system theme.

Parameters
typeCursor that should no longer use a custom bitmap

Implemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ setClipboard()

virtual void tgui::Backend::setClipboard ( const String & contents)
virtual

Changes the contents of the clipboard.

Parameters
contentsNew contents of the clipboard

Reimplemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ setDestroyOnLastGuiDetatch()

void tgui::Backend::setDestroyOnLastGuiDetatch ( bool destroyOnDetatch)

Informs the backend whether it should destroy itself when the last Gui is detached from it.

Parameters
destroyOnDetatchShould setBackend(nullptr) be called when there are no more Gui objects left?

This function will be called with "true" as parameter if the Backend is created by a Gui object.

◆ setFontBackend()

virtual void tgui::Backend::setFontBackend ( std::shared_ptr< BackendFontFactory > fontBackend)
virtual

Sets the font factory that the backend should use.

Parameters
fontBackendFont factory to attach to the backend

◆ setFontScale()

void tgui::Backend::setFontScale ( float scale)

Sets the scale factor to render text at a higher quality, e.g. to scale for DPI awareness.

Parameters
scaleMultiplier for the font size

Text may be rendered blurry if the font scale doesn't match the ratio between the window size and gui view. Default scaling is 1. If the scale is set to 1.5 then a font with text size 20 would be internally rendered at 30px.

The font scale is also used rasterize SVG images at a different resolution.

◆ setMouseCursor()

virtual void tgui::Backend::setMouseCursor ( BackendGui * gui,
Cursor::Type type )
pure virtual

Changes the mouse cursor when the mouse is on top of the window to which the gui is attached.

Parameters
guiThe gui that represents the window for which the mouse cursor should be changed
typeWhich cursor to use

Implemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ setMouseCursorStyle()

virtual void tgui::Backend::setMouseCursorStyle ( Cursor::Type type,
const std::uint8_t * pixels,
Vector2u size,
Vector2u hotspot )
pure virtual

Changes the look of a certain mouse cursor by using a bitmap.

Parameters
typeCursor that should make use of the bitmap
pixelsPointer to an array with 4*size.x*size.y elements, representing the pixels in 32-bit RGBA format
sizeSize of the cursor
hotspotPixel coordinate within the cursor image which will be located exactly at the mouse pointer position

Implemented in tgui::BackendGLFW, tgui::BackendRaylib, tgui::BackendSDL, and tgui::BackendSFML.

◆ setRenderer()

virtual void tgui::Backend::setRenderer ( std::shared_ptr< BackendRenderer > renderer)
virtual

Sets the renderer that the backend should use.

Parameters
rendererRenderer to attach to the backend

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