TGUI  1.3-dev
Loading...
Searching...
No Matches
Inheritance diagram for tgui::BackendSFML:
tgui::Backend

Classes

struct  GuiResources
 

Public Member Functions

void setGuiWindow (BackendGui *gui, sf::Window *window)
 Informs the backend which window belongs to the gui.
 
void detatchGui (BackendGui *gui) override
 Informs the backend that a gui object is being destroyed.
 
void setMouseCursorStyle (Cursor::Type type, const std::uint8_t *pixels, Vector2u size, Vector2u hotspot) override
 Changes the look of a certain mouse cursor by using a bitmap.
 
void resetMouseCursorStyle (Cursor::Type type) override
 Changes the look of a certain mouse cursor back to the system theme.
 
void setMouseCursor (BackendGui *gui, Cursor::Type type) override
 Changes the mouse cursor when the mouse is on top of the window to which the gui is attached.
 
void openVirtualKeyboard (const FloatRect &inputRect) override
 Opens the virtual keyboard on Android and iOS.
 
void closeVirtualKeyboard () override
 Closes the virtual keyboard on Android and iOS.
 
TGUI_NODISCARD bool isKeyboardModifierPressed (Event::KeyModifier modifierKey) override
 Checks the state for one of the modifier keys.
 
void setClipboard (const String &contents) override
 Changes the contents of the clipboard.
 
TGUI_NODISCARD String getClipboard () const override
 Returns the contents of the clipboard.
 
- Public Member Functions inherited from tgui::Backend
 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 TGUI_NODISCARD Font createDefaultFont ()
 Creates and returns the default font for all widgets.
 
TGUI_NODISCARD std::shared_ptr< BackendFontcreateFont ()
 Creates a new font object.
 
TGUI_NODISCARD std::shared_ptr< BackendTextcreateText ()
 Creates a new text object.
 
TGUI_NODISCARD 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 TGUI_NODISCARD 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.
 
TGUI_NODISCARD bool hasRenderer () const
 Checks whether a renderer has been attached to the backend.
 
TGUI_NODISCARD std::shared_ptr< BackendRenderergetRenderer () const
 Returns the renderer.
 
virtual void setRenderer (std::shared_ptr< BackendRenderer > renderer)
 Sets the renderer that the backend should use.
 
TGUI_NODISCARD bool hasFontBackend () const
 Checks whether a font factory has been attached to the backend.
 
TGUI_NODISCARD 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)
 

Static Public Member Functions

static void cleanupLeakedCursors ()
 Destroys any leaked cursors.
 

Protected Member Functions

TGUI_NODISCARD std::unique_ptr< sf::Cursor > createSystemCursor (Cursor::Type type)
 
void updateMouseCursor (Cursor::Type type, std::unique_ptr< sf::Cursor > cursor)
 
void updateMouseCursor (sf::Window *window, Cursor::Type type)
 

Protected Attributes

std::unordered_map< BackendGui *, GuiResources > m_guiResources
 
std::unordered_map< Cursor::Type, std::unique_ptr< sf::Cursor > > m_mouseCursors
 
- Protected Attributes inherited from tgui::Backend
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
 

Static Protected Attributes

static std::vector< std::unique_ptr< sf::Cursor > > m_leakedCursors
 

Member Function Documentation

◆ cleanupLeakedCursors()

static void tgui::BackendSFML::cleanupLeakedCursors ( )
static

Destroys any leaked cursors.

Proper cleanup of TGUI resources requires that the gui is destroyed before the SFML window. Unfortunately, SFML requires the cursor lifetime to exceed that of the window. To not end up with crashes or warnings in the terminal, TGUI may leak one cursor per window. This cursor won't be destroyed properly before the end of the program. You may call this function after both the Gui and SFML window have been destroyed to properly cleanup the leaked cursor.

Warning
This should not be called while the SFML window is still open.

◆ closeVirtualKeyboard()

void tgui::BackendSFML::closeVirtualKeyboard ( )
overridevirtual

Closes the virtual keyboard on Android and iOS.

Deprecated
Replaced by BackendGui::stopTextInput in TGUI 1.0

Reimplemented from tgui::Backend.

◆ detatchGui()

void tgui::BackendSFML::detatchGui ( BackendGui * gui)
overridevirtual

Informs the backend that a gui object is being destroyed.

Parameters
guiGui object that is about to be deconstructed

Reimplemented from tgui::Backend.

◆ getClipboard()

TGUI_NODISCARD String tgui::BackendSFML::getClipboard ( ) const
overridevirtual

Returns the contents of the clipboard.

Returns
Clipboard contents

Reimplemented from tgui::Backend.

◆ isKeyboardModifierPressed()

TGUI_NODISCARD bool tgui::BackendSFML::isKeyboardModifierPressed ( Event::KeyModifier modifierKey)
overridevirtual

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

Implements tgui::Backend.

◆ openVirtualKeyboard()

void tgui::BackendSFML::openVirtualKeyboard ( const FloatRect & inputRect)
overridevirtual

Opens the virtual keyboard on Android and iOS.

Parameters
inputRectPart of the screen where the text input is located
Deprecated
Replaced by BackendGui::startTextInput in TGUI 1.0

Reimplemented from tgui::Backend.

◆ resetMouseCursorStyle()

void tgui::BackendSFML::resetMouseCursorStyle ( Cursor::Type type)
overridevirtual

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

Parameters
typeCursor that should no longer use a custom bitmap

Implements tgui::Backend.

◆ setClipboard()

void tgui::BackendSFML::setClipboard ( const String & contents)
overridevirtual

Changes the contents of the clipboard.

Parameters
contentsNew contents of the clipboard

Reimplemented from tgui::Backend.

◆ setGuiWindow()

void tgui::BackendSFML::setGuiWindow ( BackendGui * gui,
sf::Window * window )

Informs the backend which window belongs to the gui.

Parameters
guiGui that was passed earlier via the attachGui function
windowThe window to associate with this gui

This function is called by the gui itself when it is given a window.

◆ setMouseCursor()

void tgui::BackendSFML::setMouseCursor ( BackendGui * gui,
Cursor::Type type )
overridevirtual

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

Implements tgui::Backend.

◆ setMouseCursorStyle()

void tgui::BackendSFML::setMouseCursorStyle ( Cursor::Type type,
const std::uint8_t * pixels,
Vector2u size,
Vector2u hotspot )
overridevirtual

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

Implements tgui::Backend.


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