25#ifndef TGUI_CHILD_WINDOW_HPP
26#define TGUI_CHILD_WINDOW_HPP
28#include <TGUI/CopiedSharedPtr.hpp>
29#include <TGUI/Container.hpp>
30#include <TGUI/Widgets/Button.hpp>
31#include <TGUI/Renderers/ChildWindowRenderer.hpp>
33#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
39TGUI_MODULE_EXPORT
namespace tgui
48 using Ptr = std::shared_ptr<ChildWindow>;
49 using ConstPtr = std::shared_ptr<const ChildWindow>;
51 static constexpr const char StaticWidgetType[] =
"ChildWindow";
72 ChildWindow(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
138 void setPosition(const
Layout2d& position) override;
139 using
Widget::setPosition;
158 TGUI_NODISCARD
Vector2f getInnerSize() const override;
230 TGUI_NODISCARD const
String& getTitle() const;
237 void setTitleTextSize(
unsigned int size);
243 TGUI_NODISCARD
unsigned int getTitleTextSize() const;
273 void setTitleButtons(
unsigned int buttons);
281 TGUI_NODISCARD
unsigned int getTitleButtons() const;
307 void setResizable(
bool resizable = true);
315 TGUI_NODISCARD
bool isResizable() const;
323 void setPositionLocked(
bool positionLocked = true);
329 TGUI_NODISCARD
bool isPositionLocked() const;
337 void setKeepInParent(
bool enabled = true);
339#ifndef TGUI_REMOVE_DEPRECATED_CODE
346 TGUI_DEPRECATED(
"Use getKeepInParent instead") TGUI_NODISCARD
bool isKeptInParent() const;
373 void setParent(
Container* parent)
override;
391 void leftMouseReleased(
Vector2f pos)
override;
396 void rightMousePressed(
Vector2f pos)
override;
401 void rightMouseReleased(
Vector2f pos)
override;
406 void mouseMoved(
Vector2f pos)
override;
427 void mouseNoLongerOnWidget()
override;
432 void leftMouseButtonNoLongerDown()
override;
449 void updateTitleBarHeight();
454 void updateResizeMouseCursor(
Vector2f mousePos);
478 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
483 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
506 void connectTitleButtonCallbacks();
539 Vector2f m_draggingPosition;
540 Vector2f m_maximumSize = {std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
541 Vector2f m_minimumSize = {0, 0};
542 Layout* m_decorationLayoutX =
nullptr;
543 Layout* m_decorationLayoutY =
nullptr;
544 HorizontalAlignment m_titleAlignment = HorizontalAlignment::Center;
545 unsigned int m_titleButtons = TitleButton::Close;
546 unsigned int m_titleTextSize = 0;
547 Cursor::Type m_currentChildWindowMouseCursor = Cursor::Type::Arrow;
549 CopiedSharedPtr<Button> m_closeButton;
550 CopiedSharedPtr<Button> m_minimizeButton;
551 CopiedSharedPtr<Button> m_maximizeButton;
553 bool m_mouseDownOnTitleBar =
false;
554 bool m_keepInParent =
false;
556 bool m_positionLocked =
false;
557 bool m_resizable =
false;
558 int m_resizeDirection = ResizeNone;
560 Sprite m_spriteTitleBar;
561 Sprite m_spriteBackground;
564 Borders m_bordersCached;
565 Color m_borderColorCached;
566 Color m_borderColorFocusedCached;
567 Color m_titleColorCached;
568 Color m_titleBarColorCached;
569 Color m_backgroundColorCached;
570 float m_titleBarHeightCached = 20;
571 float m_borderBelowTitleBarCached = 0;
572 float m_distanceToSideCached = 0;
573 float m_paddingBetweenButtonsCached = 0;
574 float m_minimumResizableBorderWidthCached = 10;
575 bool m_showTextOnTitleButtonsCached =
false;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Child window widget.
Definition ChildWindow.hpp:45
TGUI_NODISCARD std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
ChildWindow(const ChildWindow &)
Copy constructor.
std::shared_ptr< ChildWindow > Ptr
Shared widget pointer.
Definition ChildWindow.hpp:48
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
void mouseLeftWidget() override
This function is called when the mouse leaves the widget.
TGUI_NODISCARD Vector2f getChildWidgetsOffset() const override
Returns the distance between the position of the container and a widget that would be drawn inside th...
TitleButton
Title buttons (use bitwise OR to combine)
Definition ChildWindow.hpp:58
bool canHandleKeyPress(const Event::KeyEvent &event) override
Called by the parent of the widget to check if keyPressed would process the event.
ChildWindow(ChildWindow &&) noexcept
Move constructor.
TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
TGUI_NODISCARD Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
bool leftMousePressed(Vector2f pos) override
Called by the parent when the left mouse button goes down on top of the widget.
void mouseEnteredWidget() override
This function is called when the mouse enters the widget.
TGUI_NODISCARD bool getKeepInParent() const
Returns whether the child window is kept inside its parent.
std::shared_ptr< const ChildWindow > ConstPtr
Shared constant widget pointer.
Definition ChildWindow.hpp:49
Definition ChildWindowRenderer.hpp:37
Container widget.
Definition Container.hpp:49
Class to store the position or size of a widget.
Definition Layout.hpp:328
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:470
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:291
Wrapper class to store strings.
Definition String.hpp:101
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:52
KeyPressed event parameters.
Definition Event.hpp:169
States used for drawing.
Definition RenderStates.hpp:39