26#ifndef TGUI_CHILD_WINDOW_HPP
27#define TGUI_CHILD_WINDOW_HPP
30#include <TGUI/Container.hpp>
31#include <TGUI/Widgets/Button.hpp>
32#include <TGUI/Widgets/Label.hpp>
38 class ChildWindowRenderer;
64 typedef std::shared_ptr<ChildWindow>
Ptr;
65 typedef std::shared_ptr<const ChildWindow>
ConstPtr;
120 return std::static_pointer_cast<ChildWindowRenderer>(m_renderer);
246 return m_titleText.getText();
267 return m_titleAlignment;
293 return m_titleButtons;
305 void setTitleButtonsText(
const sf::String& closeText =
"x",
const sf::String& minimizeText =
"-",
const sf::String& maximizeText =
"+");
474 virtual bool mouseOnWidget(
float x,
float y)
const override;
479 virtual void leftMousePressed(
float x,
float y)
override;
484 virtual void leftMouseReleased(
float x,
float y)
override;
489 virtual void mouseMoved(
float x,
float y)
override;
494 virtual void mouseWheelMoved(
int delta,
int x,
int y)
override;
499 virtual void mouseNoLongerOnWidget()
override;
504 virtual void mouseNoLongerDown()
override;
522 virtual void reload(
const std::string& primary =
"",
const std::string& secondary =
"",
bool force =
false)
override;
530 return std::make_shared<ChildWindow>(*
this);
538 virtual void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
556 Texture m_iconTexture;
559 sf::Vector2f m_draggingPosition;
560 sf::Vector2f m_maximumSize;
561 sf::Vector2f m_minimumSize;
562 TitleAlignment m_titleAlignment = TitleAlignment::Center;
563 unsigned int m_titleButtons = TitleButtons::Close;
564 sf::String m_closeButtonText =
"x";
565 sf::String m_minimizeButtonText =
"-";
566 sf::String m_maximizeButtonText =
"+";
568 std::shared_ptr<Button> m_closeButton = std::make_shared<Button>();
569 std::shared_ptr<Button> m_minimizeButton = std::make_shared<Button>();
570 std::shared_ptr<Button> m_maximizeButton = std::make_shared<Button>();
572 bool m_mouseDownOnTitleBar =
false;
573 bool m_keepInParent =
false;
575 bool m_resizable =
false;
576 int m_resizeDirection = ResizeNone;
578 friend class ChildWindowRenderer;
609 virtual void setProperty(std::string property,
const std::string& value)
override;
759 void draw(sf::RenderTarget& target, sf::RenderStates states)
const;
768 virtual std::shared_ptr<WidgetRenderer> clone(
Widget* widget)
override;
776 float m_titleBarHeight = 0;
777 float m_distanceToSide = 0;
778 float m_paddingBetweenButtons = 3;
782 sf::Color m_titleColor;
783 sf::Color m_titleBarColor;
785 sf::Color m_backgroundColor;
786 sf::Color m_borderColor;
788 sf::String m_closeButtonClassName =
"";
789 sf::String m_minimizeButtonClassName =
"";
790 sf::String m_maximizeButtonClassName =
"";
Definition: Borders.hpp:38
Definition: ChildWindow.hpp:587
std::shared_ptr< ButtonRenderer > getCloseButton() const
Returns the renderer of the close button.
void setPaddingBetweenButtons(float paddingBetweenButtons)
Changes the distance between the title buttons if multiple exist.
std::shared_ptr< ButtonRenderer > getMaximizeButton() const
Returns the renderer of the maximize button.
virtual ObjectConverter getProperty(std::string property) const override
Retrieve the value of a certain property.
virtual std::map< std::string, ObjectConverter > getPropertyValuePairs() const override
Get a map with all properties and their values.
void setTitleBarHeight(float height)
Change the height of the title bar.
void setTitleBarTexture(const Texture &texture)
Change the image of the title bar.
void setTitleColor(const Color &color)
Changes the color of the title that is displayed in the title bar of the child window.
std::shared_ptr< ButtonRenderer > getMinimizeButton() const
Returns the renderer of the minimize button.
void setTitleBarColor(const Color &color)
Changes the color of the title bar.
virtual void setBorders(const Borders &borders) override
Changes the size of the borders.
void setBorderColor(const Color &borderColor)
Set the border color.
ChildWindowRenderer(ChildWindow *childWindow)
Constructor.
Definition: ChildWindow.hpp:596
void setBackgroundColor(const Color &backgroundColor)
Changes the background color of the child window.
virtual void setProperty(std::string property, ObjectConverter &&value) override
Change a property of the renderer.
virtual void setProperty(std::string property, const std::string &value) override
Change a property of the renderer.
void setDistanceToSide(float distanceToSide)
Changes the distance between the title and the side of the title bar.
Child window widget.
Definition: ChildWindow.hpp:61
virtual void setFont(const Font &font) override
Changes the font of the text in the widget and its children.
void setMinimumSize(sf::Vector2f size)
Sets the minimum size of the child window.
TitleAlignment
Title alignments, possible options for the setTitleAlignment function.
Definition: ChildWindow.hpp:70
virtual void reload(const std::string &primary="", const std::string &secondary="", bool force=false) override
Reload the widget.
void setMaximumSize(sf::Vector2f size)
Sets the maximum size of the child window.
const sf::String & getTitle() const
Returns the title that is displayed in the title bar of the child window.
Definition: ChildWindow.hpp:244
virtual sf::Vector2f getChildWidgetsOffset() const override
Returns the distance between the position of the container and a widget that would be drawn inside th...
std::shared_ptr< ChildWindowRenderer > getRenderer() const
Returns the renderer, which gives access to functions that determine how the widget is displayed.
Definition: ChildWindow.hpp:118
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
Definition: ChildWindow.hpp:528
void keepInParent(bool enabled=true)
Set the child window to be kept inside its parent.
void setPosition(const Layout2d &position) override
Set the position of the widget.
virtual void setOpacity(float opacity) override
Changes the opacity of the widget.
std::shared_ptr< ChildWindow > Ptr
Shared widget pointer.
Definition: ChildWindow.hpp:64
void setTitleButtons(unsigned int buttons)
Changes the title buttons.
void setTitleAlignment(TitleAlignment alignment)
Changes the title alignment.
sf::Vector2f getMaximumSize() const
Returns the maximum size of the child window.
TitleAlignment getTitleAlignment() const
Returns the title alignment.
Definition: ChildWindow.hpp:265
void setTitle(const sf::String &title)
Changes the title that is displayed in the title bar of the child window.
void setCloseButton(Button::Ptr closeButton)
Change the close button.
void destroy()
Destroys the window.
void setTitleButtonsText(const sf::String &closeText="x", const sf::String &minimizeText="-", const sf::String &maximizeText="+")
Changes the text within the title bar buttons.
void setIcon(const Texture &icon)
Changes the icon in the top left corner of the child window.
Button::Ptr getMinimizeButton() const
Returns the minimize button.
void setMaximizeButton(Button::Ptr maximizeButton)
Change the maximize button.
const Texture & getIcon()
Returns the icon in the top left corner of the child window.
static ChildWindow::Ptr create()
Creates a new child window widget.
Button::Ptr getCloseButton() const
Returns the close button.
std::shared_ptr< const ChildWindow > ConstPtr
Shared constant widget pointer.
Definition: ChildWindow.hpp:65
void setMinimizeButton(Button::Ptr minimizeButton)
Change the minimize button.
TitleButtons
Title buttons (bitwise OR to combine)
Definition: ChildWindow.hpp:79
sf::Vector2f getMinimumSize() const
Returns the minimum size of the child window.
unsigned int getTitleButtons() const
Returns the title bar buttons.
Definition: ChildWindow.hpp:291
bool isKeptInParent() const
Tells whether the child window is kept inside its parent.
Button::Ptr getMaximizeButton() const
Returns the maximize button.
void setResizable(bool resizable=true)
Changes whether the child window can be resized by dragging its borders or not.
bool isResizable() const
Check whether the child window can be resized by dragging its borders or not.
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.
virtual sf::Vector2f getFullSize() const override
Returns the size of the full child window.
Implicit converter for colors.
Definition: Color.hpp:40
Container widget.
Definition: Container.hpp:48
Class to store the position or size of a widget.
Definition: Layout.hpp:255
Implicit converter for settable properties.
Definition: ObjectConverter.hpp:43
Definition: Texture.hpp:45
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:34