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";
81 ChildWindow(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
144 void setPosition(const
Layout2d& position) override;
145 using
Widget::setPosition;
164 TGUI_NODISCARD
Vector2f getInnerSize() const override;
234 TGUI_NODISCARD const
String& getTitle() const;
241 void setTitleTextSize(
unsigned int size);
247 TGUI_NODISCARD
unsigned int getTitleTextSize() const;
274 void setTitleButtons(
unsigned int buttons);
281 TGUI_NODISCARD
unsigned int getTitleButtons() const;
320 TGUI_DEPRECATED("Use parent->remove(childWindow) instead")
void destroy();
327 void setResizable(
bool resizable = true);
334 TGUI_NODISCARD
bool isResizable() const;
342 void setPositionLocked(
bool positionLocked = true);
348 TGUI_NODISCARD
bool isPositionLocked() const;
356 void setKeepInParent(
bool enabled = true);
358#ifndef TGUI_REMOVE_DEPRECATED_CODE
365 TGUI_DEPRECATED(
"Use getKeepInParent instead") TGUI_NODISCARD
bool isKeptInParent() const;
391 void setParent(
Container* parent)
override;
408 void leftMouseReleased(
Vector2f pos)
override;
413 void rightMousePressed(
Vector2f pos)
override;
418 void rightMouseReleased(
Vector2f pos)
override;
423 void mouseMoved(
Vector2f pos)
override;
444 void mouseNoLongerOnWidget()
override;
449 void leftMouseButtonNoLongerDown()
override;
465 void updateTitleBarHeight();
470 void updateResizeMouseCursor(
Vector2f mousePos);
493 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
498 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
521 void connectTitleButtonCallbacks();
554 Vector2f m_draggingPosition;
555 Vector2f m_maximumSize = {std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
556 Vector2f m_minimumSize = {0, 0};
557 Layout* m_decorationLayoutX =
nullptr;
558 Layout* m_decorationLayoutY =
nullptr;
559 HorizontalAlignment m_titleAlignment = HorizontalAlignment::Center;
560 unsigned int m_titleButtons = TitleButton::Close;
561 unsigned int m_titleTextSize = 0;
562 Cursor::Type m_currentChildWindowMouseCursor = Cursor::Type::Arrow;
563 CloseBehavior m_closeBehavior = CloseBehavior::Remove;
565 CopiedSharedPtr<Button> m_closeButton;
566 CopiedSharedPtr<Button> m_minimizeButton;
567 CopiedSharedPtr<Button> m_maximizeButton;
569 bool m_mouseDownOnTitleBar =
false;
570 bool m_keepInParent =
false;
572 bool m_positionLocked =
false;
573 bool m_resizable =
false;
574 int m_resizeDirection = ResizeNone;
576 Sprite m_spriteTitleBar;
577 Sprite m_spriteBackground;
580 Borders m_bordersCached;
581 Color m_borderColorCached;
582 Color m_borderColorFocusedCached;
583 Color m_titleColorCached;
584 Color m_titleBarColorCached;
585 Color m_backgroundColorCached;
586 float m_titleBarHeightCached = 20;
587 float m_borderBelowTitleBarCached = 0;
588 float m_distanceToSideCached = 0;
589 float m_paddingBetweenButtonsCached = 0;
590 float m_minimumResizableBorderWidthCached = 10;
591 bool m_showTextOnTitleButtonsCached =
false;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Definition ChildWindowRenderer.hpp:35
Child window widget.
Definition ChildWindow.hpp:45
ChildWindow(const ChildWindow &)
Copy constructor.
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.
CloseBehavior
Definition ChildWindow.hpp:68
Vector2f getChildWidgetsOffset() const override
Returns the distance between the position of the container and a widget that would be drawn inside th...
bool isMouseOnWidget(Vector2f pos) const override
Returns whether the mouse position (which is relative to the parent widget) lies on top of the widget...
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.
bool getKeepInParent() const
Returns whether the child window is kept inside its parent.
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.
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.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
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.
std::shared_ptr< const ChildWindow > ConstPtr
Shared constant widget pointer.
Definition ChildWindow.hpp:49
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
Container widget.
Definition Container.hpp:48
Class to store the position or size of a widget.
Definition Layout.hpp:323
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:440
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:271
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
HorizontalAlignment
The horizontal alignment.
Definition Layout.hpp:62
KeyPressed event parameters.
Definition Event.hpp:168
States used for drawing.
Definition RenderStates.hpp:38