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);
135 void setPosition(const
Layout2d& position) override;
136 using
Widget::setPosition;
155 TGUI_NODISCARD
Vector2f getInnerSize() const override;
225 TGUI_NODISCARD const
String& getTitle() const;
232 void setTitleTextSize(
unsigned int size);
238 TGUI_NODISCARD
unsigned int getTitleTextSize() const;
265 void setTitleButtons(
unsigned int buttons);
272 TGUI_NODISCARD
unsigned int getTitleButtons() const;
297 void setResizable(
bool resizable = true);
304 TGUI_NODISCARD
bool isResizable() const;
312 void setPositionLocked(
bool positionLocked = true);
318 TGUI_NODISCARD
bool isPositionLocked() const;
326 void setKeepInParent(
bool enabled = true);
328#ifndef TGUI_REMOVE_DEPRECATED_CODE
335 TGUI_DEPRECATED(
"Use getKeepInParent instead") TGUI_NODISCARD
bool isKeptInParent() const;
361 void setParent(
Container* parent)
override;
378 void leftMouseReleased(
Vector2f pos)
override;
383 void rightMousePressed(
Vector2f pos)
override;
388 void rightMouseReleased(
Vector2f pos)
override;
393 void mouseMoved(
Vector2f pos)
override;
414 void mouseNoLongerOnWidget()
override;
419 void leftMouseButtonNoLongerDown()
override;
435 void updateTitleBarHeight();
440 void updateResizeMouseCursor(
Vector2f mousePos);
463 TGUI_NODISCARD std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
468 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
491 void connectTitleButtonCallbacks();
524 Vector2f m_draggingPosition;
525 Vector2f m_maximumSize = {std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
526 Vector2f m_minimumSize = {0, 0};
527 Layout* m_decorationLayoutX =
nullptr;
528 Layout* m_decorationLayoutY =
nullptr;
529 HorizontalAlignment m_titleAlignment = HorizontalAlignment::Center;
530 unsigned int m_titleButtons = TitleButton::Close;
531 unsigned int m_titleTextSize = 0;
532 Cursor::Type m_currentChildWindowMouseCursor = Cursor::Type::Arrow;
534 CopiedSharedPtr<Button> m_closeButton;
535 CopiedSharedPtr<Button> m_minimizeButton;
536 CopiedSharedPtr<Button> m_maximizeButton;
538 bool m_mouseDownOnTitleBar =
false;
539 bool m_keepInParent =
false;
541 bool m_positionLocked =
false;
542 bool m_resizable =
false;
543 int m_resizeDirection = ResizeNone;
545 Sprite m_spriteTitleBar;
546 Sprite m_spriteBackground;
549 Borders m_bordersCached;
550 Color m_borderColorCached;
551 Color m_borderColorFocusedCached;
552 Color m_titleColorCached;
553 Color m_titleBarColorCached;
554 Color m_backgroundColorCached;
555 float m_titleBarHeightCached = 20;
556 float m_borderBelowTitleBarCached = 0;
557 float m_distanceToSideCached = 0;
558 float m_paddingBetweenButtonsCached = 0;
559 float m_minimumResizableBorderWidthCached = 10;
560 bool m_showTextOnTitleButtonsCached =
false;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Definition ChildWindowRenderer.hpp:35
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
Container widget.
Definition Container.hpp:48
Class to store the position or size of a widget.
Definition Layout.hpp:313
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:61
KeyPressed event parameters.
Definition Event.hpp:168
States used for drawing.
Definition RenderStates.hpp:38