25#ifndef TGUI_BACKEND_GUI_HPP
26#define TGUI_BACKEND_GUI_HPP
28#include <TGUI/Container.hpp>
29#include <TGUI/RelFloatRect.hpp>
30#include <TGUI/Event.hpp>
31#include <TGUI/Cursor.hpp>
32#include <TGUI/TwoFingerScrollDetect.hpp>
34#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
41TGUI_MODULE_EXPORT
namespace tgui
204 TGUI_NODISCARD
const std::vector<Widget::Ptr>&
getWidgets()
const;
246 template <
class W
idgetType>
247 TGUI_NODISCARD
typename WidgetType::Ptr
get(
const String& widgetName)
const
249 return m_container->get<WidgetType>(widgetName);
284#ifndef TGUI_REMOVE_DEPRECATED_CODE
294 TGUI_DEPRECATED(
"Use getWidgetAtPos(pos, true) instead") TGUI_NODISCARD
Widget::Ptr getWidgetAtPosition(
Vector2f pos) const;
313#ifndef TGUI_REMOVE_DEPRECATED_CODE
323 TGUI_DEPRECATED(
"Use getWidgetBelowMouseCursor(mousePos, true) instead") TGUI_NODISCARD
Widget::Ptr getWidgetBelowMouseCursor(
Vector2i mousePos) const;
551 bool updateTime(
Duration elapsedTime);
643 bool handleTwoFingerScroll(
bool wasAlreadyScrolling);
649 virtual void updateContainerSize();
655 Signal onWindowFocus = {
"WindowFocused"};
656 Signal onWindowUnfocus = {
"WindowUnfocused"};
661 std::chrono::steady_clock::time_point m_lastUpdateTime;
662 bool m_windowFocused =
true;
668 bool m_tooltipPossible =
false;
675 RelFloatRect m_view{RelativeValue{0}, RelativeValue{0}, RelativeValue{1}, RelativeValue{1}};
676 FloatRect m_lastView;
678 bool m_drawUpdatesTime =
true;
679 bool m_tabKeyUsageEnabled =
true;
680 bool m_keyboardNavigationEnabled =
false;
682 Cursor::Type m_requestedMouseCursor = Cursor::Type::Arrow;
683 std::stack<Cursor::Type> m_overrideMouseCursors;
685 std::shared_ptr<BackendRenderTarget> m_backendRenderTarget =
nullptr;
Base class for the Gui.
Definition BackendGui.hpp:47
TGUI_NODISCARD const std::vector< Widget::Ptr > & getWidgets() const
Returns a list of all the widgets.
void add(const Widget::Ptr &widgetPtr, const String &widgetName="")
Adds a widget to the container.
virtual void stopTextInput()
This function is called by TGUI when unfocusing a text field (EditBox or TextArea)....
std::size_t moveWidgetForward(const Widget::Ptr &widget)
Places a widget one step forward in the z-order.
TGUI_NODISCARD Widget::Ptr getWidgetAtPos(Vector2f pos, bool recursive) const
Returns the widget that is located at the given position.
void moveWidgetToBack(const Widget::Ptr &widget)
Places a widget behind all other widgets, to the back of the z-order.
void setFont(const Font &font)
Changes the global font.
void loadWidgetsFromFile(const String &filename, bool replaceExisting=true)
Loads the child widgets from a text file.
TGUI_NODISCARD WidgetType::Ptr get(const String &widgetName) const
Returns a pointer to an earlier created widget.
Definition BackendGui.hpp:247
TGUI_NODISCARD Font getFont() const
Returns the global font for this gui.
TGUI_NODISCARD RelFloatRect getViewport() const
Returns to which part of the screen the gui will render.
bool updateTime()
Updates the internal clock (for timers, animations and blinking edit cursors)
void setRelativeViewport(const FloatRect &viewport)
Sets the part of the screen to which the gui will render as a ratio relative to the window size.
void setAbsoluteView(const FloatRect &view)
Sets the part of the gui that will be used to fill the viewport in pixels.
virtual void startTextInput(FloatRect inputRect)
This function is called by TGUI when focusing a text field (EditBox or TextArea). It may result in th...
TGUI_NODISCARD Widget::Ptr getWidgetBelowMouseCursor(Vector2i mousePos, bool recursive) const
Returns the widget below the mouse.
TGUI_NODISCARD RootContainer::Ptr getContainer() const
Returns the internal container of the Gui.
virtual void updateTextCursorPosition(FloatRect inputRect, Vector2f caretPos)
This function is called by TGUI when the position of the caret changes in a text field (EditBox or Te...
virtual void mainLoop(Color clearColor={240, 240, 240})=0
Give the gui control over the main loop.
TGUI_NODISCARD int getWidgetIndex(const Widget::Ptr &widget) const
Returns the current index of a widget in this container.
TGUI_NODISCARD unsigned int getTextSize() const
Returns the character size for future child widgets (and for existing widgets where the size wasn't c...
void setAbsoluteViewport(const FloatRect &viewport)
Sets the part of the screen to which the gui will render in pixels.
TGUI_NODISCARD bool isKeyboardNavigationEnabled() const
Returns whether using the arrow keys can be used to navigate between widgets.
void loadWidgetsFromStream(std::stringstream &stream, bool replaceExisting=true)
Loads the child widgets from a string stream.
void saveWidgetsToStream(std::stringstream &stream) const
Saves this the child widgets to a text file.
std::size_t moveWidgetBackward(const Widget::Ptr &widget)
Places a widget one step backward in the z-order.
bool focusPreviousWidget(bool recursive=true)
Focuses the previous widget in the gui.
TGUI_NODISCARD RelFloatRect getView() const
Returns the part of the gui that will be used to fill the viewport.
virtual void draw()
Draws all the widgets that were added to the gui.
void setOpacity(float opacity)
Changes the opacity of all widgets.
void restoreOverrideMouseCursor()
Undoes the effect of the last call to setOverrideCursor.
void removeAllWidgets()
Removes all widgets that were added to the container.
void setRelativeView(const FloatRect &view)
Sets the part of the gui that will be used to fill the viewport.
void moveWidgetToFront(const Widget::Ptr &widget)
Places a widget before all other widgets, to the front of the z-order.
void saveWidgetsToFile(const String &filename)
Saves the child widgets to a text file.
bool handleEvent(Event event)
Passes the event to the widgets.
bool focusNextWidget(bool recursive=true)
Focuses the next widget in the gui.
TGUI_NODISCARD Widget::Ptr get(const String &widgetName) const
Returns a pointer to an earlier created widget.
void unfocusAllWidgets()
Unfocus all the widgets.
void setDrawingUpdatesTime(bool drawUpdatesTime)
Sets whether drawing the gui will automatically update the internal clock or whether the user does it...
TGUI_NODISCARD Widget::Ptr getFocusedLeaf() const
Returns the leaf child widget that is focused inside this container.
TGUI_NODISCARD Widget::Ptr getFocusedChild() const
Returns the child widget that is focused inside this container.
TGUI_NODISCARD bool isTabKeyUsageEnabled() const
Returns whether the tab key usage is enabled (if so, pressing tab will focus another widget)
void setTabKeyUsageEnabled(bool enabled)
When the tab key usage is enabled, pressing tab will focus another widget.
bool setWidgetIndex(const Widget::Ptr &widget, std::size_t index)
Changes the index of a widget in this container.
TGUI_NODISCARD std::shared_ptr< BackendRenderTarget > getBackendRenderTarget() const
Returns the backend render target that is assigned to the gui.
TGUI_NODISCARD Vector2f mapPixelToCoords(Vector2i pixel) const
Converts the pixel coordinate to a position within the view.
TGUI_NODISCARD Vector2f mapCoordsToPixel(Vector2f coord) const
Converts a position within the view to the corresponding pixel coordinate.
TGUI_NODISCARD float getOpacity() const
Returns the opacity of all the widgets.
void setTextSize(unsigned int size)
Changes the character size of all existing and future child widgets.
virtual TGUI_NODISCARD bool isKeyboardModifierPressed(Event::KeyModifier modifierKey) const
Checks the state for one of the modifier keys.
bool remove(const Widget::Ptr &widget)
Removes a single widget that was added to the container.
void loadWidgetsFromStream(std::stringstream &&stream, bool replaceExisting=true)
Loads the child widgets from a string stream.
BackendGui()
Default constructor.
void setKeyboardNavigationEnabled(bool enabled)
Changes whether using the arrow keys can be used to navigate between widgets.
void setOverrideMouseCursor(Cursor::Type type)
Overrides which cursor gets shown.
void requestMouseCursor(Cursor::Type type)
Function that is used by widgets to change the mouse cursor.
Wrapper for colors.
Definition Color.hpp:73
Type
List of available cursors.
Definition Cursor.hpp:50
Wrapper for durations.
Definition Duration.hpp:55
Wrapper around the backend-specific font. All copies of the font will share the same internal font re...
Definition Font.hpp:58
std::shared_ptr< RootContainer > Ptr
Shared widget pointer.
Definition Container.hpp:653
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Wrapper class to store strings.
Definition String.hpp:96
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
KeyModifier
Modifiers keys.
Definition Event.hpp:157
FloatRect that can contain absolute values or values relative to the parent size.
Definition RelFloatRect.hpp:39
Helper class to create an AbsoluteOrRelativeValue object containing a relative value without using a ...
Definition AbsoluteOrRelativeValue.hpp:166