26#ifndef TGUI_GUI_BASE_HPP
27#define TGUI_GUI_BASE_HPP
30#include <TGUI/Container.hpp>
31#include <TGUI/RelFloatRect.hpp>
32#include <TGUI/Event.hpp>
33#include <TGUI/Cursor.hpp>
260 return m_container->get<T>(widgetName);
561 bool updateTime(
Duration elapsedTime);
571 Vector2f mapPixelToView(
int x,
int y)
const;
596 virtual void updateContainerSize();
608 std::chrono::steady_clock::time_point m_lastUpdateTime;
609 bool m_windowFocused =
true;
615 bool m_tooltipPossible =
false;
620 RelFloatRect m_view{RelativeValue{0}, RelativeValue{0}, RelativeValue{1}, RelativeValue{1}};
621 FloatRect m_lastView;
623 bool m_drawUpdatesTime =
true;
624 bool m_tabKeyUsageEnabled =
true;
626 Cursor::Type m_requestedMouseCursor = Cursor::Type::Arrow;
627 std::stack<Cursor::Type> m_overrideMouseCursors;
Type
List of available cursors.
Definition Cursor.hpp:48
Wrapper for durations.
Definition Duration.hpp:52
Base class for the Gui.
Definition GuiBase.hpp:45
bool handleEvent(Event event)
Passes the event to the widgets.
RelFloatRect getViewport() const
Returns to which part of the screen the gui will render.
void setAbsoluteView(const FloatRect &view)
Sets the part of the gui that will be used to fill the viewport in pixels.
void setRelativeView(const FloatRect &view)
Sets the part of the gui that will be used to fill the viewport.
bool remove(const Widget::Ptr &widget)
Removes a single widget that was added to the container.
RelFloatRect getView() const
Returns the part of the gui that will be used to fill the viewport.
Widget::Ptr get(const String &widgetName) const
Returns a pointer to an earlier created widget.
void setDrawingUpdatesTime(bool drawUpdatesTime)
Sets whether drawing the gui will automatically update the internal clock or whether the user does it...
std::size_t moveWidgetBackward(const Widget::Ptr &widget)
Places a widget one step backward in the z-order.
void setFont(const Font &font)
Changes the global font.
virtual void draw()=0
Draws all the widgets that were added to the gui.
void setAbsoluteViewport(const FloatRect &viewport)
Sets the part of the screen to which the gui will render in pixels.
bool isTabKeyUsageEnabled() const
Returns whether the tab key usage is enabled (if so, pressing tab will focus another widget)
void moveWidgetToBack(const Widget::Ptr &widget)
Places a widget behind all other widgets, to the back of the z-order.
Widget::Ptr getWidgetBelowMouseCursor(Vector2i mousePos) const
Returns the leaf child widget below the mouse.
void setOverrideMouseCursor(Cursor::Type type)
Overrides which cursor gets shown.
virtual void mainLoop()=0
Give the gui control over the main loop.
bool setWidgetIndex(const Widget::Ptr &widget, std::size_t index)
Changes the index of a widget in this container.
T::Ptr get(const String &widgetName) const
Returns a pointer to an earlier created widget.
Definition GuiBase.hpp:258
RootContainer::Ptr getContainer() const
Returns the internal container of the Gui.
unsigned int getTextSize() const
Returns the character size for future child widgets (and for existing widgets where the size wasn't c...
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 setOpacity(float opacity)
Changes the opacity of all widgets.
void loadWidgetsFromFile(const String &filename, bool replaceExisting=true)
Loads the child widgets from a text file.
void setTabKeyUsageEnabled(bool enabled)
When the tab key usage is enabled, pressing tab will focus another widget.
void restoreOverrideMouseCursor()
Undoes the effect of the last call to setOverrideCursor.
void requestMouseCursor(Cursor::Type type)
Function that is used by widgets to change the mouse cursor.
bool updateTime()
Updates the internal clock (for timers, animations and blinking edit cursors)
std::size_t moveWidgetForward(const Widget::Ptr &widget)
Places a widget one step forward in the z-order.
Widget::Ptr getFocusedChild() const
Returns the child widget that is focused inside this container.
bool focusPreviousWidget(bool recursive=true)
Focuses the previous widget in the gui.
void saveWidgetsToFile(const String &filename)
Saves the child widgets to a text file.
void saveWidgetsToStream(std::stringstream &stream) const
Saves this the child widgets to a text file.
Font getFont() const
Returns the global font for this gui.
void loadWidgetsFromStream(std::stringstream &&stream, bool replaceExisting=true)
Loads the child widgets from a string stream.
void removeAllWidgets()
Removes all widgets that were added to the container.
float getOpacity() const
Returns the opacity of all the widgets.
Widget::Ptr getWidgetAtPosition(Vector2f pos) const
Returns the leaf child widget that is located at the given position.
bool focusNextWidget(bool recursive=true)
Focuses the next widget in the gui.
void setTextSize(unsigned int size)
Changes the character size of all existing and future child widgets.
int getWidgetIndex(const Widget::Ptr &widget) const
Returns the current index of a widget in this container.
void unfocusAllWidgets()
Unfocus all the widgets.
void loadWidgetsFromStream(std::stringstream &stream, bool replaceExisting=true)
Loads the child widgets from a string stream.
void add(const Widget::Ptr &widgetPtr, const String &widgetName="")
Adds a widget to the container.
void moveWidgetToFront(const Widget::Ptr &widget)
Places a widget before all other widgets, to the front of the z-order.
const std::vector< Widget::Ptr > & getWidgets() const
Returns a list of all the widgets.
Widget::Ptr getFocusedLeaf() const
Returns the leaf child widget that is focused inside this container.
std::shared_ptr< RootContainer > Ptr
Shared widget pointer.
Definition Container.hpp:687
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
FloatRect that can contain absolute values or values relative to the parent size.
Definition RelFloatRect.hpp:41
Helper class to create an AbsoluteOrRelativeValue object containing a relative value without using a ...
Definition AbsoluteOrRelativeValue.hpp:177