26#ifndef TGUI_CHILD_WINDOW_HPP
27#define TGUI_CHILD_WINDOW_HPP
30#include <TGUI/CopiedSharedPtr.hpp>
31#include <TGUI/Container.hpp>
32#include <TGUI/Widgets/Button.hpp>
33#include <TGUI/Renderers/ChildWindowRenderer.hpp>
47 typedef std::shared_ptr<ChildWindow>
Ptr;
48 typedef std::shared_ptr<const ChildWindow>
ConstPtr;
76 ChildWindow(
const char* typeName =
"ChildWindow",
bool initRenderer =
true);
128 using Widget::setPosition;
140 using Widget::setSize;
378 void setParent(
Container* parent)
override;
392 void leftMousePressed(
Vector2f pos)
override;
397 void leftMouseReleased(
Vector2f pos)
override;
402 void rightMousePressed(
Vector2f pos)
override;
407 void rightMouseReleased(
Vector2f pos)
override;
412 void mouseMoved(
Vector2f pos)
override;
422 void mouseNoLongerOnWidget()
override;
427 void leftMouseButtonNoLongerDown()
override;
446 void updateTitleBarHeight();
452 void updateResizeMouseCursor(
Vector2f mousePos);
479 std::unique_ptr<DataIO::Node>
save(SavingRenderersMap& renderers)
const override;
485 void load(
const std::unique_ptr<DataIO::Node>& node,
const LoadingRenderersMap& renderers)
override;
505 return std::make_shared<ChildWindow>(*
this);
542 Vector2f m_draggingPosition;
543 Vector2f m_maximumSize = {std::numeric_limits<float>::infinity(), std::numeric_limits<float>::infinity()};
544 Vector2f m_minimumSize = {0, 0};
545 TitleAlignment m_titleAlignment = TitleAlignment::Center;
546 unsigned int m_titleButtons = TitleButton::Close;
547 unsigned int m_titleTextSize = 0;
548 Cursor::Type m_currentChildWindowMouseCursor = Cursor::Type::Arrow;
550 CopiedSharedPtr<Button> m_closeButton;
551 CopiedSharedPtr<Button> m_minimizeButton;
552 CopiedSharedPtr<Button> m_maximizeButton;
554 bool m_mouseDownOnTitleBar =
false;
555 bool m_keepInParent =
false;
557 bool m_positionLocked =
false;
558 bool m_resizable =
false;
559 int m_resizeDirection = ResizeNone;
561 Sprite m_spriteTitleBar;
562 Sprite m_spriteBackground;
565 Borders m_bordersCached;
566 Color m_borderColorCached;
567 Color m_borderColorFocusedCached;
568 Color m_titleColorCached;
569 Color m_titleBarColorCached;
570 Color m_backgroundColorCached;
571 float m_titleBarHeightCached = 20;
572 float m_borderBelowTitleBarCached = 0;
573 float m_distanceToSideCached = 0;
574 float m_paddingBetweenButtonsCached = 0;
575 float m_minimumResizableBorderWidthCached = 10;
576 bool m_showTextOnTitleButtonsCached =
false;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Definition ChildWindowRenderer.hpp:37
Child window widget.
Definition ChildWindow.hpp:44
ChildWindowRenderer * getSharedRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setClientSize(Vector2f size)
Changes the client size of the child window.
void setPositionLocked(bool positionLocked=true)
Changes whether the child window can be moved by dragging its title bar or not.
TitleAlignment
Title alignments, possible options for the setTitleAlignment function.
Definition ChildWindow.hpp:53
unsigned int getTitleTextSize() const
Returns the character size of the title.
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.
static ChildWindow::Ptr create(const String &title="", unsigned int titleButtons=TitleButton::Close)
Creates a new child window widget.
void setPosition(const Layout2d &position) override
Sets the position of the widget.
std::shared_ptr< ChildWindow > Ptr
Shared widget pointer.
Definition ChildWindow.hpp:47
Vector2f getMaximumSize() const
Returns the maximum size of the child window.
void setTitleButtons(unsigned int buttons)
Changes the title buttons.
void setTitleTextSize(unsigned int size)
Changes the character size of the title.
void setTitleAlignment(TitleAlignment alignment)
Changes the title alignment.
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...
TitleAlignment getTitleAlignment() const
Returns the title alignment.
bool isPositionLocked() const
Checks whether the child window can be moved by dragging its title bar or not.
Vector2f getClientSize() const
Returns the client size of the child window.
TitleButton
Title buttons (use bitwise OR to combine)
Definition ChildWindow.hpp:62
void setMinimumSize(Vector2f size)
Sets the minimum size of the child window.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void destroy()
Closes the window.
Vector2f getInnerSize() const override
Returns the space available for widgets inside the container.
void setMaximumSize(Vector2f size)
Sets the maximum size of the child window.
void mouseLeftWidget() override
This function is called when the mouse leaves the widget.
ChildWindowRenderer * getRenderer()
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
void setTitle(const String &title)
Changes the title that is displayed in the title bar of the child window.
std::shared_ptr< const ChildWindow > ConstPtr
Shared constant widget pointer.
Definition ChildWindow.hpp:48
void setKeepInParent(bool enabled=true)
Sets the child window to be kept inside its parent.
unsigned int getTitleButtons() const
Returns the title bar buttons.
const String & getTitle() const
Returns the title that is displayed in the title bar of the child window.
void mouseEnteredWidget() override
This function is called when the mouse enters the widget.
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
bool isKeptInParent() const
Tells whether the child window is kept inside its parent.
Vector2f getMinimumSize() const
Returns the minimum size of the child window.
void close()
Try to close the window.
void setResizable(bool resizable=true)
Changes whether the child window can be resized by dragging its borders or not.
bool isResizable() const
Checks whether the child window can be resized by dragging its borders or not.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition ChildWindow.hpp:503
void setSize(const Layout2d &size) override
Changes the size of the child window.
static ChildWindow::Ptr copy(ChildWindow::ConstPtr childWindow)
Makes a copy of another child window.
Signal & getSignal(String signalName) override
Retrieves a signal based on its name.
Container widget.
Definition Container.hpp:47
Class to store the position or size of a widget.
Definition Layout.hpp:262
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:467
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:287
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:58
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
KeyPressed event parameters.
Definition Event.hpp:167
States used for drawing.
Definition RenderStates.hpp:39