Ported ChildWindow to new renderer
parent
7499d3d4b7
commit
6aacbdb06a
|
@ -238,15 +238,6 @@ namespace tgui
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void uncheckRadioButtons();
|
||||
|
||||
/**
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the opacity of the container and all its child widgets
|
||||
///
|
||||
/// @param opacity The opacity of the widgets. 0 means completely transparent, while 1 (default) means fully opaque
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setOpacity(float opacity) override;
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the distance between the position of the container and a widget that would be drawn inside
|
||||
|
|
|
@ -115,4 +115,23 @@
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define TGUI_RENDERER_PROPERTY_RENDERER(CLASS, NAME) \
|
||||
std::shared_ptr<RendererData> CLASS::get##NAME() const \
|
||||
{ \
|
||||
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
|
||||
if (it != m_data->propertyValuePairs.end()) \
|
||||
return it->second.getRenderer(); \
|
||||
else \
|
||||
{ \
|
||||
m_data->propertyValuePairs[toLower(#NAME)] = {std::make_shared<RendererData>()}; \
|
||||
return m_data->propertyValuePairs[toLower(#NAME)].getRenderer(); \
|
||||
} \
|
||||
} \
|
||||
void CLASS::set##NAME(std::shared_ptr<RendererData> renderer) \
|
||||
{ \
|
||||
setProperty(toLower(#NAME), {renderer}); \
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // TGUI_RENDERER_DEFINES_HPP
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TGUI - Texus' Graphical User Interface
|
||||
// Copyright (C) 2012-2016 Bruno Van de Velde (vdv_b@tgui.eu)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef TGUI_CHILD_WINDOW_RENDERER_HPP
|
||||
#define TGUI_CHILD_WINDOW_RENDERER_HPP
|
||||
|
||||
|
||||
#include <TGUI/Renderers/WidgetRenderer.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace tgui
|
||||
{
|
||||
class TGUI_API ChildWindowRenderer : public WidgetRenderer
|
||||
{
|
||||
public:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the size of the borders
|
||||
///
|
||||
/// @param borders Size of the borders
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setBorders(const Borders& borders);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the size of the borders
|
||||
///
|
||||
/// @return border size
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Borders getBorders() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the height of the title bar
|
||||
///
|
||||
/// @param width New height of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleBarHeight(float height);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the height of the title bar
|
||||
///
|
||||
/// @return Title bar height
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float getTitleBarHeight() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the title bar
|
||||
///
|
||||
/// @param color New title bar color
|
||||
///
|
||||
/// Note that this color is ignored when you set an image as title bar.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleBarColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the color of the title bar
|
||||
///
|
||||
/// @return Title bar color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Color getTitleBarColor() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the title that is displayed in the title bar of the child window
|
||||
///
|
||||
/// @param color New title color for the child window
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the color of the title that is displayed in the title bar of the child window
|
||||
///
|
||||
/// @return Title color for the child window
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Color getTitleColor() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the borders
|
||||
///
|
||||
/// @param color New border color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setBorderColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the color of the borders
|
||||
///
|
||||
/// @return border color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Color getBorderColor() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the distance of the title or close button from the side of the title bar
|
||||
///
|
||||
/// @param distanceToSide Distance between the title and the side of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setDistanceToSide(float distanceToSide);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the distance of the title or close button from the side of the title bar
|
||||
///
|
||||
/// @return Distance between the title and the side of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float getDistanceToSide() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the distance between the title buttons if multiple exist
|
||||
///
|
||||
/// @param padding Distance between the title buttons
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setPaddingBetweenButtons(float padding);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the distance between the title buttons if multiple exist
|
||||
///
|
||||
/// @return Distance between the title buttons
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
float getPaddingBetweenButtons() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the background
|
||||
///
|
||||
/// @param color New background color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setBackgroundColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the color of the background
|
||||
///
|
||||
/// @return Background color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Color getBackgroundColor() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the image of the title bar
|
||||
///
|
||||
/// @param texture New title bar texture
|
||||
///
|
||||
/// When this image is set, the title bar color property will be ignored.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTextureTitleBar(const Texture& texture);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the image of the title bar
|
||||
///
|
||||
/// @return title bar texture
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Texture& getTextureTitleBar() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Sets the renderer data of the optional close button
|
||||
///
|
||||
/// @param rendererData Data about how the close button should look
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setCloseButton(std::shared_ptr<RendererData> rendererData);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer data of the close button
|
||||
///
|
||||
/// @return Data about how the close button looks
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<RendererData> getCloseButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Sets the renderer data of the optional maximize button
|
||||
///
|
||||
/// @param rendererData Data about how the maximize button should look
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setMaximizeButton(std::shared_ptr<RendererData> rendererData);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer data of the maximize button
|
||||
///
|
||||
/// @return Data about how the maximize button looks
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<RendererData> getMaximizeButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Sets the renderer data of the optional minimize button
|
||||
///
|
||||
/// @param rendererData Data about how the minimize button should look
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setMinimizeButton(std::shared_ptr<RendererData> rendererData);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer data of the minimize button
|
||||
///
|
||||
/// @return Data about how the minimize button looks
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<RendererData> getMinimizeButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif // TGUI_CHILD_WINDOW_RENDERER_HPP
|
|
@ -44,8 +44,8 @@
|
|||
#include <TGUI/Widgets/Button.hpp>
|
||||
#include <TGUI/Widgets/Canvas.hpp>
|
||||
#include <TGUI/Widgets/ChatBox.hpp>
|
||||
#include <TGUI/Widgets/CheckBox.hpp>/**
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>*/
|
||||
#include <TGUI/Widgets/CheckBox.hpp>
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>
|
||||
#include <TGUI/Widgets/ClickableWidget.hpp>
|
||||
#include <TGUI/Widgets/ComboBox.hpp>
|
||||
#include <TGUI/Widgets/EditBox.hpp>
|
||||
|
|
|
@ -200,19 +200,6 @@ namespace tgui
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
sf::Vector2f findCharacterPos(std::size_t index) const;
|
||||
|
||||
/*
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Find the index of the character at a certain position
|
||||
///
|
||||
/// @param position Position to look at
|
||||
///
|
||||
/// @return Index of the character
|
||||
///
|
||||
/// If the position is behind or below the text then the index is the one directly behind the text.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::size_t findCharacterIndex(sf::Vector2f position) const;
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Draw the text to a render target
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
|
||||
#include <TGUI/Container.hpp>
|
||||
#include <TGUI/Widgets/Button.hpp>
|
||||
#include <TGUI/Renderers/ChildWindowRenderer.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace tgui
|
||||
{
|
||||
class ChildWindowRenderer;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Child window widget
|
||||
///
|
||||
|
@ -102,12 +101,12 @@ namespace tgui
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer, which gives access to functions that determine how the widget is displayed
|
||||
///
|
||||
/// @return Pointer to the renderer
|
||||
/// @return Temporary pointer to the renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<ChildWindowRenderer> getRenderer() const
|
||||
ChildWindowRenderer* getRenderer() const
|
||||
{
|
||||
return std::static_pointer_cast<ChildWindowRenderer>(m_renderer);
|
||||
return aurora::downcast<ChildWindowRenderer*>(m_renderer.get());
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,26 +149,6 @@ namespace tgui
|
|||
virtual sf::Vector2f getFullSize() const override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the font of the text in the widget and its children
|
||||
///
|
||||
/// @param font The new font
|
||||
///
|
||||
/// When you don't call this function then the font from the parent widget will be used.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setFont(const Font& font) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the opacity of the widget
|
||||
///
|
||||
/// @param opacity The opacity of the widget. 0 means completely transparent, while 1 (default) means fully opaque
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setOpacity(float opacity) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the title that is displayed in the title bar of the child window
|
||||
///
|
||||
|
@ -185,10 +164,7 @@ namespace tgui
|
|||
/// @return Title of the child window
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
const sf::String& getTitle() const
|
||||
{
|
||||
return m_titleText.getText();
|
||||
}
|
||||
const sf::String& getTitle() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -206,10 +182,7 @@ namespace tgui
|
|||
/// @return How the title is aligned in the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TitleAlignment getTitleAlignment() const
|
||||
{
|
||||
return m_titleAlignment;
|
||||
}
|
||||
TitleAlignment getTitleAlignment() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -223,7 +196,7 @@ namespace tgui
|
|||
/// childWindow->setTitleButtons(ChildWindow::TitleButtons::Minimize | ChildWindow::TitleButtons::Close);
|
||||
/// @endcode
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleButtons(TitleButtons buttons);
|
||||
void setTitleButtons(int buttons);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -232,21 +205,7 @@ namespace tgui
|
|||
/// @return Which buttons are available in the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
TitleButtons getTitleButtons() const
|
||||
{
|
||||
return m_titleButtons;
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the text within the title bar buttons
|
||||
///
|
||||
/// @param closeText New text for the close button (default is "x")
|
||||
/// @param minimizeText New text for the minimize button (default is "-")
|
||||
/// @param maximizeText New text for the maximize button (default is "+")
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleButtonsText(const sf::String& closeText = "x", const sf::String& minimizeText = "-", const sf::String& maximizeText = "+");
|
||||
int getTitleButtons() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -324,84 +283,6 @@ namespace tgui
|
|||
bool isKeptInParent() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the close button
|
||||
///
|
||||
/// @return closeButton The new close button
|
||||
///
|
||||
/// The close button should have no parent and you should no longer change it after calling this function.
|
||||
/// The function is meant to be used like this:
|
||||
/// @code
|
||||
/// childWindow->setCloseButton(theme->load("CloseButton"));
|
||||
/// @endcode
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setCloseButton(Button::Ptr closeButton);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the close button
|
||||
///
|
||||
/// @return close button of the child window
|
||||
///
|
||||
/// You should not change this close button yourself.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Button::Ptr getCloseButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Change the minimize button
|
||||
///
|
||||
/// @return minimizeButton The new minimize button
|
||||
///
|
||||
/// The minimize button should have no parent and you should no longer change it after calling this function.
|
||||
/// The function is meant to be used like this:
|
||||
/// @code
|
||||
/// childWindow->setMinimizeButton(theme->load("MinimizeButton"));
|
||||
/// @endcode
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setMinimizeButton(Button::Ptr minimizeButton);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the minimize button
|
||||
///
|
||||
/// @return minimize button of the child window
|
||||
///
|
||||
/// You should not change this minimize button yourself.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Button::Ptr getMinimizeButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Change the maximize button
|
||||
///
|
||||
/// @return maximizeButton The new maximize button
|
||||
///
|
||||
/// The maximize button should have no parent and you should no longer change it after calling this function.
|
||||
/// The function is meant to be used like this:
|
||||
/// @code
|
||||
/// childWindow->setMaximizeButton(theme->load("MaximizeButton"));
|
||||
/// @endcode
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setMaximizeButton(Button::Ptr maximizeButton);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the maximize button
|
||||
///
|
||||
/// @return maximize button of the child window
|
||||
///
|
||||
/// You should not change this maximize button yourself.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
Button::Ptr getMaximizeButton() const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the distance between the position of the container and a widget that would be drawn inside
|
||||
/// this container on relative position (0,0).
|
||||
|
@ -452,18 +333,26 @@ namespace tgui
|
|||
protected:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Reloads the widget
|
||||
// Updates the title bar texture, text and buttons after the title bar height has changed.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void updateTitleBarHeight();
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Function called when one of the properties of the renderer is changed
|
||||
///
|
||||
/// @param primary Primary parameter for the loader
|
||||
/// @param secondary Secondary parameter for the loader
|
||||
/// @param force Try to only change the looks of the widget and not alter the widget itself when false
|
||||
///
|
||||
/// @throw Exception when the connected theme could not create the widget
|
||||
///
|
||||
/// When primary is an empty string the built-in white theme will be used.
|
||||
/// @param property Lowercase name of the property that was changed
|
||||
/// @param value New value of the property
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void reload(const std::string& primary = "", const std::string& secondary = "", bool force = false) override;
|
||||
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @internal
|
||||
// Draws the widget on the render target.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -476,13 +365,15 @@ namespace tgui
|
|||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @internal
|
||||
// Draws the widget on the render target.
|
||||
private:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||
// Signal handler from the title buttons. This function propagates the signal to the user if needed.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void titleButtonPressed(const sf::String& signal);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
|
||||
enum ResizeDirection
|
||||
|
@ -502,14 +393,11 @@ namespace tgui
|
|||
Text m_titleText;
|
||||
sf::Vector2f m_draggingPosition;
|
||||
TitleAlignment m_titleAlignment = TitleAlignment::Center;
|
||||
TitleButtons m_titleButtons = TitleButtons::Close;
|
||||
sf::String m_closeButtonText = "x";
|
||||
sf::String m_minimizeButtonText = "-";
|
||||
sf::String m_maximizeButtonText = "+";
|
||||
int m_titleButtons = TitleButtons::Close;
|
||||
|
||||
std::shared_ptr<Button> m_closeButton = std::make_shared<Button>();
|
||||
std::shared_ptr<Button> m_minimizeButton = std::make_shared<Button>();
|
||||
std::shared_ptr<Button> m_maximizeButton = std::make_shared<Button>();
|
||||
std::shared_ptr<Button> m_closeButton;
|
||||
std::shared_ptr<Button> m_minimizeButton;
|
||||
std::shared_ptr<Button> m_maximizeButton;
|
||||
|
||||
bool m_mouseDownOnTitleBar = false;
|
||||
bool m_keepInParent = false;
|
||||
|
@ -522,220 +410,6 @@ namespace tgui
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class TGUI_API ChildWindowRenderer : public WidgetRenderer, public WidgetBorders
|
||||
{
|
||||
public:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// @param childWindow The child window that is connected to the renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
ChildWindowRenderer(ChildWindow* childWindow) : m_childWindow{childWindow} {}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes a property of the renderer
|
||||
///
|
||||
/// @param property The property that you would like to change
|
||||
/// @param value The new serialized value that you like to assign to the property
|
||||
///
|
||||
/// @throw Exception when deserialization fails or when the widget does not have this property
|
||||
/// @throw Exception when loading scrollbar fails with the theme connected to the list box
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setProperty(std::string property, const std::string& value) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes a property of the renderer
|
||||
///
|
||||
/// @param property The property that you would like to change
|
||||
/// @param value The new value that you like to assign to the property.
|
||||
/// The ObjectConverter is implicitly constructed from the possible value types
|
||||
///
|
||||
/// @throw Exception for unknown properties or when value was of a wrong type
|
||||
/// @throw Exception when loading scrollbar fails with the theme connected to the list box
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setProperty(std::string property, ObjectConverter&& value) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Retrieves the value of a certain property
|
||||
///
|
||||
/// @param property The property that you would like to retrieve
|
||||
///
|
||||
/// @return The value inside a ObjectConverter object which you can extract with the correct get function or
|
||||
/// an ObjectConverter object with type ObjectConverter::Type::None when the property did not exist.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual ObjectConverter getProperty(std::string property) const override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Gets a map with all properties and their values
|
||||
///
|
||||
/// @return Property-value pairs of the renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual std::map<std::string, ObjectConverter> getPropertyValuePairs() const override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the title bar
|
||||
///
|
||||
/// @param color New title bar color
|
||||
///
|
||||
/// Note that this color is ignored when you set an image as title bar.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleBarColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the height of the title bar
|
||||
///
|
||||
/// @param height New height of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleBarHeight(float height);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the color of the title that is displayed in the title bar of the child window
|
||||
///
|
||||
/// @param color New title color for the child window
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleColor(Color color);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Sets the border color
|
||||
///
|
||||
/// @param borderColor The color of the borders
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setBorderColor(Color borderColor);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the size of the borders
|
||||
///
|
||||
/// @param borders The size of the borders
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual void setBorders(const Borders& borders) override;
|
||||
using WidgetBorders::setBorders;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the distance between the title and the side of the title bar
|
||||
///
|
||||
/// @param distanceToSide distance between the title and the side of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setDistanceToSide(float distanceToSide);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the distance between the title buttons if multiple exist.
|
||||
///
|
||||
/// @param paddingBetweenButtons distance between the title and the side of the title bar
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setPaddingBetweenButtons(float paddingBetweenButtons);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the background color of the child window
|
||||
///
|
||||
/// @param backgroundColor New background color
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setBackgroundColor(Color backgroundColor);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Changes the image of the title bar
|
||||
///
|
||||
/// @param texture New title bar texture
|
||||
///
|
||||
/// When this image is set, the title bar color property will be ignored.
|
||||
/// Pass an empty string to unset the image, in this case the title bar color property will be used again.
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void setTitleBarTexture(const Texture& texture);
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer of the close button
|
||||
///
|
||||
/// @return The close button renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<ButtonRenderer> getCloseButton() const;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer of the minimize button
|
||||
///
|
||||
/// @return The minimize button renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<ButtonRenderer> getMinimizeButton() const;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief Returns the renderer of the maximize button
|
||||
///
|
||||
/// @return The maximize button renderer
|
||||
///
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
std::shared_ptr<ButtonRenderer> getMaximizeButton() const;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Draws the widget on the render target.
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Makes a copy of the renderer
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual std::shared_ptr<WidgetRenderer> clone(Widget* widget) override;
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
|
||||
ChildWindow* m_childWindow;
|
||||
|
||||
float m_titleBarHeight = 0;
|
||||
float m_distanceToSide = 0;
|
||||
float m_paddingBetweenButtons = 3; // Pixels between buttons
|
||||
|
||||
Texture m_textureTitleBar;
|
||||
|
||||
sf::Color m_titleColor;
|
||||
sf::Color m_titleBarColor;
|
||||
|
||||
sf::Color m_backgroundColor;
|
||||
sf::Color m_borderColor;
|
||||
|
||||
sf::String m_closeButtonClassName = "";
|
||||
sf::String m_minimizeButtonClassName = "";
|
||||
sf::String m_maximizeButtonClassName = "";
|
||||
|
||||
friend class ChildWindow;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ set(TGUI_SRC
|
|||
Loading/WidgetSaver.cpp
|
||||
Renderers/ButtonRenderer.cpp
|
||||
Renderers/ChatBoxRenderer.cpp
|
||||
Renderers/ChildWindowRenderer.cpp
|
||||
Renderers/ComboBoxRenderer.cpp
|
||||
Renderers/EditBoxRenderer.cpp
|
||||
Renderers/KnobRenderer.cpp
|
||||
|
@ -47,7 +48,7 @@ set(TGUI_SRC
|
|||
Widgets/Canvas.cpp
|
||||
Widgets/ChatBox.cpp
|
||||
Widgets/CheckBox.cpp
|
||||
#Widgets/ChildWindow.cpp
|
||||
Widgets/ChildWindow.cpp
|
||||
Widgets/ClickableWidget.cpp
|
||||
Widgets/ComboBox.cpp
|
||||
Widgets/EditBox.cpp
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace tgui
|
|||
|
||||
Font::Font(const std::string& id) :
|
||||
m_font{Deserializer::deserialize(ObjectConverter::Type::Font, id).getFont()},
|
||||
m_id {id}
|
||||
m_id {Deserializer::deserialize(ObjectConverter::Type::String, id).getString()}
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include <TGUI/Widgets/Button.hpp>
|
||||
#include <TGUI/Widgets/Canvas.hpp>
|
||||
#include <TGUI/Widgets/ChatBox.hpp>
|
||||
#include <TGUI/Widgets/CheckBox.hpp>/**
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>*/
|
||||
#include <TGUI/Widgets/CheckBox.hpp>
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>
|
||||
#include <TGUI/Widgets/ComboBox.hpp>
|
||||
#include <TGUI/Widgets/EditBox.hpp>
|
||||
#include <TGUI/Widgets/Knob.hpp>
|
||||
|
@ -325,7 +325,7 @@ namespace tgui
|
|||
|
||||
return checkbox;
|
||||
}
|
||||
/**
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TGUI_API Widget::Ptr loadChildWindow(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr)
|
||||
|
@ -348,6 +348,9 @@ namespace tgui
|
|||
throw Exception{"Failed to parse TitleAlignment property. Only the values Left, Center and Right are correct."};
|
||||
}
|
||||
|
||||
if (node->propertyValuePairs["titlebuttons"])
|
||||
childWindow->setTitleButtons(tgui::stoi(node->propertyValuePairs["titlebuttons"]->value));
|
||||
|
||||
if (node->propertyValuePairs["title"])
|
||||
childWindow->setTitle(DESERIALIZE_STRING("title"));
|
||||
|
||||
|
@ -357,12 +360,8 @@ namespace tgui
|
|||
if (node->propertyValuePairs["keepinparent"])
|
||||
childWindow->keepInParent(parseBoolean(node->propertyValuePairs["keepinparent"]->value));
|
||||
|
||||
for (const auto& childNode : node->children)
|
||||
{
|
||||
if (toLower(childNode->name) == "closebutton")
|
||||
childWindow->setCloseButton(std::static_pointer_cast<Button>(WidgetLoader::getLoadFunction("button")(childNode)));
|
||||
}
|
||||
REMOVE_CHILD("closebutton");
|
||||
if (node->propertyValuePairs["resizable"])
|
||||
childWindow->setResizable(parseBoolean(node->propertyValuePairs["resizable"]->value));
|
||||
|
||||
loadContainer(node, childWindow);
|
||||
|
||||
|
@ -370,7 +369,7 @@ namespace tgui
|
|||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
*/
|
||||
|
||||
TGUI_API Widget::Ptr loadClickableWidget(std::shared_ptr<DataIO::Node> node, Widget::Ptr widget = nullptr)
|
||||
{
|
||||
if (widget)
|
||||
|
@ -909,8 +908,8 @@ namespace tgui
|
|||
{"button", std::bind(loadButton, std::placeholders::_1, std::shared_ptr<Button>{})},
|
||||
{"canvas", std::bind(loadCanvas, std::placeholders::_1, std::shared_ptr<Canvas>{})},
|
||||
{"chatbox", std::bind(loadChatBox, std::placeholders::_1, std::shared_ptr<ChatBox>{})},
|
||||
{"checkbox", std::bind(loadCheckBox, std::placeholders::_1, std::shared_ptr<CheckBox>{})},/**
|
||||
{"childwindow", std::bind(loadChildWindow, std::placeholders::_1, std::shared_ptr<ChildWindow>{})},*/
|
||||
{"checkbox", std::bind(loadCheckBox, std::placeholders::_1, std::shared_ptr<CheckBox>{})},
|
||||
{"childwindow", std::bind(loadChildWindow, std::placeholders::_1, std::shared_ptr<ChildWindow>{})},
|
||||
{"clickablewidget", std::bind(loadClickableWidget, std::placeholders::_1, std::shared_ptr<ClickableWidget>{})},
|
||||
{"combobox", std::bind(loadComboBox, std::placeholders::_1, std::shared_ptr<ComboBox>{})},
|
||||
{"editbox", std::bind(loadEditBox, std::placeholders::_1, std::shared_ptr<EditBox>{})},
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
#include <TGUI/Loading/WidgetSaver.hpp>
|
||||
#include <TGUI/Loading/Serializer.hpp>
|
||||
#include <TGUI/Widgets/Button.hpp>
|
||||
#include <TGUI/Widgets/ChatBox.hpp>/**
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>*/
|
||||
#include <TGUI/Widgets/ChatBox.hpp>
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>
|
||||
#include <TGUI/Widgets/ComboBox.hpp>
|
||||
#include <TGUI/Widgets/EditBox.hpp>
|
||||
#include <TGUI/Widgets/Knob.hpp>
|
||||
|
@ -108,19 +108,22 @@ namespace tgui
|
|||
/// TODO: ToolTip
|
||||
/// TODO: Separate renderer section?
|
||||
|
||||
node->children.emplace_back(std::make_shared<DataIO::Node>());
|
||||
node->children.back()->name = "Renderer";
|
||||
for (const auto& pair : widget->getRenderer()->getPropertyValuePairs())
|
||||
if (!widget->getRenderer()->getPropertyValuePairs().empty())
|
||||
{
|
||||
sf::String value = ObjectConverter{pair.second}.getString();
|
||||
if (pair.second.getType() == ObjectConverter::Type::RendererData)
|
||||
node->children.emplace_back(std::make_shared<DataIO::Node>());
|
||||
node->children.back()->name = "Renderer";
|
||||
for (const auto& pair : widget->getRenderer()->getPropertyValuePairs())
|
||||
{
|
||||
std::stringstream ss{value};
|
||||
node->children.back()->children.push_back(DataIO::parse(ss)->children[0]);
|
||||
node->children.back()->children.back()->name = pair.first;
|
||||
sf::String value = ObjectConverter{pair.second}.getString();
|
||||
if (pair.second.getType() == ObjectConverter::Type::RendererData)
|
||||
{
|
||||
std::stringstream ss{value};
|
||||
node->children.back()->children.push_back(DataIO::parse(ss)->children[0]);
|
||||
node->children.back()->children.back()->name = pair.first;
|
||||
}
|
||||
else
|
||||
node->children.back()->propertyValuePairs[pair.first] = std::make_shared<DataIO::ValueNode>(value);
|
||||
}
|
||||
else
|
||||
node->children.back()->propertyValuePairs[pair.first] = std::make_shared<DataIO::ValueNode>(value);
|
||||
}
|
||||
|
||||
return node;
|
||||
|
@ -198,13 +201,15 @@ namespace tgui
|
|||
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TGUI_API std::shared_ptr<DataIO::Node> saveChildWindow(ChildWindow::Ptr childWindow)
|
||||
{
|
||||
auto node = WidgetSaver::getSaveFunction("container")(tgui::WidgetConverter{childWindow});
|
||||
|
||||
SET_PROPERTY("TitleButtons", Serializer::serialize(childWindow->getTitleButtons()));
|
||||
|
||||
if (childWindow->getTitleAlignment() == ChildWindow::TitleAlignment::Left)
|
||||
SET_PROPERTY("TitleAlignment", "Left");
|
||||
else if (childWindow->getTitleAlignment() == ChildWindow::TitleAlignment::Center)
|
||||
|
@ -221,13 +226,12 @@ namespace tgui
|
|||
if (childWindow->isKeptInParent())
|
||||
SET_PROPERTY("KeepInParent", "true");
|
||||
|
||||
node->children.push_back(WidgetSaver::getSaveFunction("button")(tgui::WidgetConverter{childWindow->getCloseButton()}));
|
||||
node->children.back()->parent = node.get();
|
||||
node->children.back()->name = "CloseButton";
|
||||
if (childWindow->isResizable())
|
||||
SET_PROPERTY("Resizable", "true");
|
||||
|
||||
return node;
|
||||
}
|
||||
*/
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TGUI_API std::shared_ptr<DataIO::Node> saveComboBox(ComboBox::Ptr comboBox)
|
||||
|
@ -582,8 +586,8 @@ namespace tgui
|
|||
{"button", saveButton},
|
||||
{"canvas", saveWidget},
|
||||
{"chatbox", saveChatBox},
|
||||
{"checkbox", saveRadioButton},/**
|
||||
{"childwindow", saveChildWindow},*/
|
||||
{"checkbox", saveRadioButton},
|
||||
{"childwindow", saveChildWindow},
|
||||
{"clickablewidget", saveWidget},
|
||||
{"combobox", saveComboBox},
|
||||
{"editbox", saveEditBox},
|
||||
|
|
|
@ -37,26 +37,7 @@ namespace tgui
|
|||
|
||||
TGUI_RENDERER_PROPERTY_TEXTURE(ChatBoxRenderer, TextureBackground)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ChatBoxRenderer::setScrollbar(std::shared_ptr<RendererData> texture)
|
||||
{
|
||||
setProperty("scrollbar", {texture});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<RendererData> ChatBoxRenderer::getScrollbar() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("scrollbar");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getRenderer();
|
||||
else
|
||||
{
|
||||
m_data->propertyValuePairs["scrollbar"] = {std::make_shared<RendererData>()};
|
||||
return m_data->propertyValuePairs["scrollbar"].getRenderer();
|
||||
}
|
||||
}
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ChatBoxRenderer, Scrollbar)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TGUI - Texus' Graphical User Interface
|
||||
// Copyright (C) 2012-2016 Bruno Van de Velde (vdv_b@tgui.eu)
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied warranty.
|
||||
// In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it freely,
|
||||
// subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented;
|
||||
// you must not claim that you wrote the original software.
|
||||
// If you use this software in a product, an acknowledgment
|
||||
// in the product documentation would be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such,
|
||||
// and must not be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source distribution.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include <TGUI/Renderers/ChildWindowRenderer.hpp>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace tgui
|
||||
{
|
||||
TGUI_RENDERER_PROPERTY_OUTLINE(ChildWindowRenderer, Borders)
|
||||
|
||||
TGUI_RENDERER_PROPERTY_COLOR(ChildWindowRenderer, TitleBarColor, sf::Color::White)
|
||||
TGUI_RENDERER_PROPERTY_COLOR(ChildWindowRenderer, TitleColor, sf::Color::Black)
|
||||
TGUI_RENDERER_PROPERTY_COLOR(ChildWindowRenderer, BackgroundColor, sf::Color::White)
|
||||
TGUI_RENDERER_PROPERTY_COLOR(ChildWindowRenderer, BorderColor, sf::Color::Black)
|
||||
|
||||
TGUI_RENDERER_PROPERTY_TEXTURE(ChildWindowRenderer, TextureTitleBar)
|
||||
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ChildWindowRenderer, CloseButton)
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ChildWindowRenderer, MaximizeButton)
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ChildWindowRenderer, MinimizeButton)
|
||||
|
||||
TGUI_RENDERER_PROPERTY_NUMBER(ChildWindowRenderer, DistanceToSide, 3)
|
||||
TGUI_RENDERER_PROPERTY_NUMBER(ChildWindowRenderer, PaddingBetweenButtons, 1)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
float ChildWindowRenderer::getTitleBarHeight() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("titlebarheight");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getNumber();
|
||||
else
|
||||
{
|
||||
it = m_data->propertyValuePairs.find("texturetitlebar");
|
||||
if (it != m_data->propertyValuePairs.end() && it->second.getTexture().isLoaded())
|
||||
return it->second.getTexture().getImageSize().y;
|
||||
else
|
||||
return 20;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ChildWindowRenderer::setTitleBarHeight(float number)
|
||||
{
|
||||
setProperty("titlebarheight", ObjectConverter{number});
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
@ -48,26 +48,7 @@ namespace tgui
|
|||
|
||||
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ComboBoxRenderer, TextStyle, sf::Text::Regular)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ComboBoxRenderer::setListBox(std::shared_ptr<RendererData> texture)
|
||||
{
|
||||
setProperty("listbox", {texture});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<RendererData> ComboBoxRenderer::getListBox() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("listbox");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getRenderer();
|
||||
else
|
||||
{
|
||||
m_data->propertyValuePairs["listbox"] = {std::make_shared<RendererData>()};
|
||||
return m_data->propertyValuePairs["listbox"].getRenderer();
|
||||
}
|
||||
}
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ComboBoxRenderer, ListBox)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -47,26 +47,7 @@ namespace tgui
|
|||
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ListBoxRenderer, TextStyle, sf::Text::Regular)
|
||||
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ListBoxRenderer, SelectedTextStyle, {})
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ListBoxRenderer::setScrollbar(std::shared_ptr<RendererData> texture)
|
||||
{
|
||||
setProperty("scrollbar", {texture});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<RendererData> ListBoxRenderer::getScrollbar() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("scrollbar");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getRenderer();
|
||||
else
|
||||
{
|
||||
m_data->propertyValuePairs["scrollbar"] = {std::make_shared<RendererData>()};
|
||||
return m_data->propertyValuePairs["scrollbar"].getRenderer();
|
||||
}
|
||||
}
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(ListBoxRenderer, Scrollbar)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -43,26 +43,7 @@ namespace tgui
|
|||
|
||||
TGUI_RENDERER_PROPERTY_NUMBER(TextBoxRenderer, CaretWidth, 1)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void TextBoxRenderer::setScrollbar(std::shared_ptr<RendererData> texture)
|
||||
{
|
||||
setProperty("scrollbar", {texture});
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::shared_ptr<RendererData> TextBoxRenderer::getScrollbar() const
|
||||
{
|
||||
auto it = m_data->propertyValuePairs.find("scrollbar");
|
||||
if (it != m_data->propertyValuePairs.end())
|
||||
return it->second.getRenderer();
|
||||
else
|
||||
{
|
||||
m_data->propertyValuePairs["scrollbar"] = {std::make_shared<RendererData>()};
|
||||
return m_data->propertyValuePairs["scrollbar"].getRenderer();
|
||||
}
|
||||
}
|
||||
TGUI_RENDERER_PROPERTY_RENDERER(TextBoxRenderer, Scrollbar)
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -142,13 +142,6 @@ namespace tgui
|
|||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
std::size_t Text::findCharacterIndex(sf::Vector2f position) const
|
||||
{
|
||||
/// TODO
|
||||
}
|
||||
*/
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Text::draw(sf::RenderTarget& target, sf::RenderStates states) const
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,7 +25,7 @@ set(TEST_SOURCES
|
|||
Widgets/Canvas.cpp
|
||||
Widgets/ChatBox.cpp
|
||||
Widgets/CheckBox.cpp
|
||||
#Widgets/ChildWindow.cpp
|
||||
Widgets/ChildWindow.cpp
|
||||
Widgets/ClickableWidget.cpp
|
||||
Widgets/ComboBox.cpp
|
||||
Widgets/EditBox.cpp
|
||||
|
@ -46,11 +46,6 @@ set(TEST_SOURCES
|
|||
Widgets/ToolTip.cpp
|
||||
)
|
||||
|
||||
# The tests require c++14
|
||||
if(SFML_COMPILER_GCC OR SFML_COMPILER_CLANG)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
endif()
|
||||
|
||||
add_executable(tests ${TEST_SOURCES})
|
||||
target_link_libraries(tests ${PROJECT_NAME} ${TGUI_EXT_LIBS})
|
||||
|
||||
|
|
|
@ -212,9 +212,9 @@ TEST_CASE("[ChatBox]")
|
|||
|
||||
SECTION("colored")
|
||||
{
|
||||
auto scrollbarRendererData = std::make_shared<tgui::RendererData>();
|
||||
scrollbarRendererData->propertyValuePairs["trackcolor"] = {sf::Color::Red};
|
||||
scrollbarRendererData->propertyValuePairs["thumbcolor"] = {sf::Color::Blue};
|
||||
tgui::ScrollbarRenderer scrollbarRenderer;
|
||||
scrollbarRenderer.setTrackColor(sf::Color::Red);
|
||||
scrollbarRenderer.setThumbColor(sf::Color::Blue);
|
||||
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
|
@ -231,7 +231,7 @@ TEST_CASE("[ChatBox]")
|
|||
REQUIRE_NOTHROW(renderer->setProperty("BorderColor", sf::Color{40, 50, 60}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRendererData));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
|
||||
}
|
||||
|
||||
SECTION("functions")
|
||||
|
@ -242,7 +242,7 @@ TEST_CASE("[ChatBox]")
|
|||
renderer->setPadding({5, 6, 7, 8});
|
||||
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 0);
|
||||
renderer->setScrollbar(scrollbarRendererData);
|
||||
renderer->setScrollbar(scrollbarRenderer.getData());
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
|
||||
|
@ -250,10 +250,9 @@ TEST_CASE("[ChatBox]")
|
|||
REQUIRE(renderer->getProperty("Borders").getOutline() == tgui::Borders(1, 2, 3, 4));
|
||||
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Borders(5, 6, 7, 8));
|
||||
|
||||
scrollbarRendererData = renderer->getScrollbar();
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs.size() == 2);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 2);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
}
|
||||
|
||||
SECTION("textured")
|
||||
|
|
|
@ -24,13 +24,15 @@
|
|||
|
||||
#include "../Tests.hpp"
|
||||
#include <TGUI/Widgets/ChildWindow.hpp>
|
||||
#include <TGUI/Widgets/Button.hpp>
|
||||
#include <TGUI/Widgets/Panel.hpp>
|
||||
|
||||
TEST_CASE("[ChildWindow]") {
|
||||
TEST_CASE("[ChildWindow]")
|
||||
{
|
||||
tgui::ChildWindow::Ptr childWindow = std::make_shared<tgui::ChildWindow>();
|
||||
childWindow->setFont("resources/DroidSansArmenian.ttf");
|
||||
childWindow->getRenderer()->setFont("resources/DroidSansArmenian.ttf");
|
||||
|
||||
SECTION("Signals") {
|
||||
SECTION("Signals")
|
||||
{
|
||||
REQUIRE_NOTHROW(childWindow->connect("MousePressed", [](){}));
|
||||
REQUIRE_NOTHROW(childWindow->connect("Closed", [](){}));
|
||||
REQUIRE_NOTHROW(childWindow->connect("Maximized", [](){}));
|
||||
|
@ -42,56 +44,148 @@ TEST_CASE("[ChildWindow]") {
|
|||
REQUIRE_NOTHROW(childWindow->connect("Minimized", [](tgui::ChildWindow::Ptr){}));
|
||||
}
|
||||
|
||||
SECTION("WidgetType") {
|
||||
SECTION("WidgetType")
|
||||
{
|
||||
REQUIRE(childWindow->getWidgetType() == "ChildWindow");
|
||||
}
|
||||
|
||||
SECTION("Position and Size")
|
||||
{
|
||||
childWindow->setPosition(40, 30);
|
||||
childWindow->setSize(150, 100);
|
||||
childWindow->getRenderer()->setTitleBarHeight(15);
|
||||
childWindow->getRenderer()->setBorders({1, 2, 3, 4});
|
||||
|
||||
REQUIRE(childWindow->getPosition() == sf::Vector2f(40, 30));
|
||||
REQUIRE(childWindow->getSize() == sf::Vector2f(150, 100));
|
||||
REQUIRE(childWindow->getFullSize() == sf::Vector2f(154, 121));
|
||||
REQUIRE(childWindow->getWidgetOffset() == sf::Vector2f(0, 0));
|
||||
|
||||
SECTION("Child widgets")
|
||||
{
|
||||
auto childWidget = std::make_shared<tgui::ClickableWidget>();
|
||||
childWidget->setPosition(60, 50);
|
||||
childWindow->add(childWidget);
|
||||
|
||||
REQUIRE(childWidget->getPosition() == sf::Vector2f(60, 50));
|
||||
REQUIRE(childWidget->getAbsolutePosition() == sf::Vector2f(101, 97));
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO: Test the functions in the ChildWindow class
|
||||
|
||||
SECTION("Renderer") {
|
||||
SECTION("Events / Signals")
|
||||
{
|
||||
unsigned int mousePressedCount = 0;
|
||||
unsigned int mouseReleasedCount = 0;
|
||||
unsigned int clickedCount = 0;
|
||||
|
||||
childWindow->setPosition(40, 30);
|
||||
childWindow->setSize(150, 100);
|
||||
childWindow->getRenderer()->setTitleBarHeight(20);
|
||||
childWindow->getRenderer()->setBorders({2});
|
||||
|
||||
SECTION("mouseOnWidget")
|
||||
{
|
||||
REQUIRE(!childWindow->mouseOnWidget({-1, -1}));
|
||||
REQUIRE(childWindow->mouseOnWidget({0, 0}));
|
||||
REQUIRE(childWindow->mouseOnWidget({75, 50}));
|
||||
REQUIRE(childWindow->mouseOnWidget({153, 123}));
|
||||
REQUIRE(!childWindow->mouseOnWidget({154, 124}));
|
||||
}
|
||||
|
||||
SECTION("mouse move")
|
||||
{
|
||||
unsigned int mouseEnteredCount = 0;
|
||||
unsigned int mouseLeftCount = 0;
|
||||
|
||||
childWindow->connect("MouseEntered", genericCallback, std::ref(mouseEnteredCount));
|
||||
childWindow->connect("MouseLeft", genericCallback, std::ref(mouseLeftCount));
|
||||
|
||||
auto parent = std::make_shared<tgui::Panel>(300, 200);
|
||||
parent->setPosition({30, 25});
|
||||
parent->add(childWindow);
|
||||
|
||||
parent->mouseMoved({10, 15});
|
||||
REQUIRE(mouseEnteredCount == 0);
|
||||
REQUIRE(mouseLeftCount == 0);
|
||||
|
||||
parent->mouseMoved({40, 30});
|
||||
REQUIRE(mouseEnteredCount == 1);
|
||||
REQUIRE(mouseLeftCount == 0);
|
||||
|
||||
parent->mouseMoved({193, 153});
|
||||
REQUIRE(mouseEnteredCount == 1);
|
||||
REQUIRE(mouseLeftCount == 0);
|
||||
|
||||
parent->mouseMoved({194, 154});
|
||||
REQUIRE(mouseEnteredCount == 1);
|
||||
REQUIRE(mouseLeftCount == 1);
|
||||
}
|
||||
|
||||
/// TODO: Test title button events and dragging and resizing window
|
||||
}
|
||||
|
||||
testWidgetRenderer(childWindow->getRenderer());
|
||||
SECTION("Renderer")
|
||||
{
|
||||
auto renderer = childWindow->getRenderer();
|
||||
|
||||
SECTION("colored") {
|
||||
SECTION("set serialized property") {
|
||||
childWindow->setTitleButtons(tgui::ChildWindow::TitleButtons::None);
|
||||
|
||||
SECTION("colored")
|
||||
{
|
||||
tgui::ButtonRenderer closeButtonRenderer;
|
||||
tgui::ButtonRenderer maximizeButtonRenderer;
|
||||
tgui::ButtonRenderer minimizeButtonRenderer;
|
||||
closeButtonRenderer.setBackgroundColor(sf::Color::Red);
|
||||
maximizeButtonRenderer.setBackgroundColor(sf::Color::Green);
|
||||
minimizeButtonRenderer.setBackgroundColor(sf::Color::Blue);
|
||||
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
REQUIRE_NOTHROW(renderer->setProperty("BackgroundColor", "rgb(10, 20, 30)"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleColor", "rgb(40, 50, 60)"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarColor", "rgb(70, 80, 90)"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("BorderColor", "rgb(100, 110, 120)"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Borders", "(1, 2, 3, 4)"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("DistanceToSide", "2"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("PaddingBetweenButtons", "1"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarHeight", "25"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("CloseButton", "{ BackgroundColor = Red; }"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("MaximizeButton", "{ BackgroundColor = Green; }"));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("MinimizeButton", "{ BackgroundColor = Blue; }"));
|
||||
}
|
||||
|
||||
SECTION("set object property") {
|
||||
SECTION("set object property")
|
||||
{
|
||||
REQUIRE_NOTHROW(renderer->setProperty("BackgroundColor", sf::Color{10, 20, 30}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleColor", sf::Color{40, 50, 60}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarColor", sf::Color{70, 80, 90}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("BorderColor", sf::Color{100, 110, 120}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("DistanceToSide", 2));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("PaddingBetweenButtons", 1));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarHeight", 25));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("CloseButton", closeButtonRenderer.getData()));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("MaximizeButton", maximizeButtonRenderer.getData()));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("MinimizeButton", minimizeButtonRenderer.getData()));
|
||||
}
|
||||
|
||||
SECTION("functions") {
|
||||
SECTION("functions")
|
||||
{
|
||||
renderer->setBackgroundColor({10, 20, 30});
|
||||
renderer->setTitleColor({40, 50, 60});
|
||||
renderer->setTitleBarColor({70, 80, 90});
|
||||
renderer->setBorderColor({100, 110, 120});
|
||||
renderer->setBorders({1, 2, 3, 4});
|
||||
renderer->setDistanceToSide(2);
|
||||
renderer->setPaddingBetweenButtons(1);
|
||||
renderer->setTitleBarHeight(25);
|
||||
|
||||
SECTION("getPropertyValuePairs") {
|
||||
auto pairs = renderer->getPropertyValuePairs();
|
||||
REQUIRE(pairs.size() == 7);
|
||||
REQUIRE(pairs["BackgroundColor"].getColor() == sf::Color(10, 20, 30));
|
||||
REQUIRE(pairs["TitleColor"].getColor() == sf::Color(40, 50, 60));
|
||||
REQUIRE(pairs["TitleBarColor"].getColor() == sf::Color(70, 80, 90));
|
||||
REQUIRE(pairs["BorderColor"].getColor() == sf::Color(100, 110, 120));
|
||||
REQUIRE(pairs["Borders"].getOutline() == tgui::Borders(1, 2, 3, 4));
|
||||
REQUIRE(pairs["DistanceToSide"].getNumber() == 2);
|
||||
REQUIRE(pairs["TitleBarHeight"].getNumber() == 25);
|
||||
}
|
||||
renderer->setCloseButton(closeButtonRenderer.getData());
|
||||
renderer->setMaximizeButton(maximizeButtonRenderer.getData());
|
||||
renderer->setMinimizeButton(minimizeButtonRenderer.getData());
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
|
||||
|
@ -100,90 +194,89 @@ TEST_CASE("[ChildWindow]") {
|
|||
REQUIRE(renderer->getProperty("BorderColor").getColor() == sf::Color(100, 110, 120));
|
||||
REQUIRE(renderer->getProperty("Borders").getOutline() == tgui::Borders(1, 2, 3, 4));
|
||||
REQUIRE(renderer->getProperty("DistanceToSide").getNumber() == 2);
|
||||
REQUIRE(renderer->getProperty("PaddingBetweenButtons").getNumber() == 1);
|
||||
REQUIRE(renderer->getProperty("TitleBarHeight").getNumber() == 25);
|
||||
|
||||
REQUIRE(renderer->getCloseButton()->propertyValuePairs["backgroundcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(renderer->getMaximizeButton()->propertyValuePairs["backgroundcolor"].getColor() == sf::Color::Green);
|
||||
REQUIRE(renderer->getMinimizeButton()->propertyValuePairs["backgroundcolor"].getColor() == sf::Color::Blue);
|
||||
}
|
||||
|
||||
SECTION("textured") {
|
||||
SECTION("textured")
|
||||
{
|
||||
tgui::Texture textureTitleBar("resources/Black.png", {48, 154, 75, 25}, {16, 16, 16, 16});
|
||||
|
||||
REQUIRE(!renderer->getProperty("TitleBarImage").getTexture().isLoaded());
|
||||
|
||||
SECTION("set serialized property") {
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarImage", tgui::Serializer::serialize(textureTitleBar)));
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TextureTitleBar", tgui::Serializer::serialize(textureTitleBar)));
|
||||
}
|
||||
|
||||
SECTION("set object property") {
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TitleBarImage", textureTitleBar));
|
||||
SECTION("set object property")
|
||||
{
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TextureTitleBar", textureTitleBar));
|
||||
}
|
||||
|
||||
SECTION("functions") {
|
||||
renderer->setTitleBarTexture(textureTitleBar);
|
||||
|
||||
SECTION("getPropertyValuePairs") {
|
||||
auto pairs = renderer->getPropertyValuePairs();
|
||||
REQUIRE(pairs.size() == 7);
|
||||
REQUIRE(pairs["TitleBarImage"].getTexture().getData() == textureTitleBar.getData());
|
||||
}
|
||||
SECTION("functions")
|
||||
{
|
||||
renderer->setTextureTitleBar(textureTitleBar);
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("TitleBarImage").getTexture().isLoaded());
|
||||
REQUIRE(renderer->getProperty("TextureTitleBar").getTexture().isLoaded());
|
||||
|
||||
REQUIRE(renderer->getProperty("TitleBarImage").getTexture().getData() == textureTitleBar.getData());
|
||||
REQUIRE(renderer->getTextureTitleBar().getData() == textureTitleBar.getData());
|
||||
}
|
||||
|
||||
SECTION("TitleBarHeight value")
|
||||
{
|
||||
SECTION("TitleBarHeight property set")
|
||||
{
|
||||
renderer->setTitleBarHeight(15);
|
||||
renderer->setTextureTitleBar({"resources/TitleBar.png"});
|
||||
REQUIRE(renderer->getTitleBarHeight() == 15);
|
||||
}
|
||||
|
||||
SECTION("Fallback to texture height")
|
||||
{
|
||||
renderer->setTextureTitleBar({"resources/TitleBar.png"});
|
||||
REQUIRE(renderer->getTitleBarHeight() == 25);
|
||||
}
|
||||
|
||||
SECTION("Fallback to default value")
|
||||
{
|
||||
REQUIRE(renderer->getTitleBarHeight() == 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SECTION("Saving and loading from file") {
|
||||
REQUIRE_NOTHROW(childWindow = std::make_shared<tgui::Theme>()->load("ChildWindow"));
|
||||
SECTION("Saving and loading from file")
|
||||
{
|
||||
childWindow = std::make_shared<tgui::ChildWindow>();
|
||||
childWindow->setSize(400, 300);
|
||||
|
||||
SECTION("independent ChildWindow") {
|
||||
auto theme = std::make_shared<tgui::Theme>("resources/Black.txt");
|
||||
REQUIRE_NOTHROW(childWindow = theme->load("ChildWindow"));
|
||||
REQUIRE(childWindow->getPrimaryLoadingParameter() == "resources/Black.txt");
|
||||
REQUIRE(childWindow->getSecondaryLoadingParameter() == "childwindow");
|
||||
|
||||
childWindow->setSize(400, 300);
|
||||
REQUIRE_NOTHROW(childWindow->saveWidgetsToFile("WidgetFileChildWindow1.txt"));
|
||||
SECTION("Only save contents")
|
||||
{
|
||||
REQUIRE_NOTHROW(childWindow->saveWidgetsToFile("ChildWindowWidgetFile1.txt"));
|
||||
|
||||
childWindow->setSize(200, 100);
|
||||
REQUIRE_NOTHROW(childWindow->loadWidgetsFromFile("WidgetFileChildWindow1.txt"));
|
||||
REQUIRE(childWindow->getSize() == sf::Vector2f(200, 100)); // The ChildWindow itself is not saved, only its children
|
||||
REQUIRE_NOTHROW(childWindow->loadWidgetsFromFile("ChildWindowWidgetFile1.txt"));
|
||||
REQUIRE(childWindow->getSize() == sf::Vector2f(200, 100)); // The child window itself is not saved, only its children
|
||||
|
||||
REQUIRE_NOTHROW(childWindow->saveWidgetsToFile("WidgetFileChildWindow2.txt"));
|
||||
REQUIRE(compareFiles("WidgetFileChildWindow1.txt", "WidgetFileChildWindow2.txt"));
|
||||
REQUIRE_NOTHROW(childWindow->saveWidgetsToFile("ChildWindowWidgetFile2.txt"));
|
||||
REQUIRE(compareFiles("ChildWindowWidgetFile1.txt", "ChildWindowWidgetFile2.txt"));
|
||||
}
|
||||
|
||||
SECTION("ChildWindow inside gui") {
|
||||
auto parent = std::make_shared<tgui::GuiContainer>();
|
||||
parent->add(childWindow);
|
||||
|
||||
tgui::Button::Ptr button = std::make_shared<tgui::Button>();
|
||||
button->setPosition(40, 20);
|
||||
childWindow->add(button);
|
||||
|
||||
childWindow->setOpacity(0.8f);
|
||||
SECTION("Save entire child window")
|
||||
{
|
||||
childWindow->setTitle("Title");
|
||||
childWindow->setTitleAlignment(tgui::ChildWindow::TitleAlignment::Left);
|
||||
childWindow->setIcon({"resources/image.png"});
|
||||
childWindow->keepInParent();
|
||||
|
||||
REQUIRE_NOTHROW(parent->saveWidgetsToFile("WidgetFileChildWindow3.txt"));
|
||||
auto widget = std::make_shared<tgui::ClickableWidget>();
|
||||
widget->setPosition(40, 20);
|
||||
childWindow->add(widget);
|
||||
|
||||
parent->removeAllWidgets();
|
||||
REQUIRE_NOTHROW(parent->loadWidgetsFromFile("WidgetFileChildWindow3.txt"));
|
||||
|
||||
REQUIRE_NOTHROW(parent->saveWidgetsToFile("WidgetFileChildWindow4.txt"));
|
||||
REQUIRE(compareFiles("WidgetFileChildWindow3.txt", "WidgetFileChildWindow4.txt"));
|
||||
|
||||
SECTION("Copying widget") {
|
||||
tgui::ChildWindow temp;
|
||||
temp = *childWindow;
|
||||
|
||||
parent->removeAllWidgets();
|
||||
parent->add(tgui::ChildWindow::copy(std::make_shared<tgui::ChildWindow>(temp)));
|
||||
|
||||
REQUIRE_NOTHROW(parent->saveWidgetsToFile("WidgetFileChildWindow4.txt"));
|
||||
REQUIRE(compareFiles("WidgetFileChildWindow3.txt", "WidgetFileChildWindow4.txt"));
|
||||
}
|
||||
testSavingWidget("ChildWindow", childWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -231,9 +231,9 @@ TEST_CASE("[ComboBox]")
|
|||
|
||||
SECTION("colored")
|
||||
{
|
||||
auto listBoxRendererData = std::make_shared<tgui::RendererData>();
|
||||
listBoxRendererData->propertyValuePairs["backgroundcolor"] = {sf::Color::Red};
|
||||
listBoxRendererData->propertyValuePairs["textcolor"] = {sf::Color::Blue};
|
||||
tgui::ListBoxRenderer listBoxRenderer;
|
||||
listBoxRenderer.setBackgroundColor(sf::Color::Red);
|
||||
listBoxRenderer.setTextColor(sf::Color::Blue);
|
||||
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
|
@ -262,7 +262,7 @@ TEST_CASE("[ComboBox]")
|
|||
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TextStyle", sf::Text::Bold));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("ListBox", listBoxRendererData));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("ListBox", listBoxRenderer.getData()));
|
||||
}
|
||||
|
||||
SECTION("functions")
|
||||
|
@ -279,7 +279,7 @@ TEST_CASE("[ComboBox]")
|
|||
renderer->setTextStyle(sf::Text::Bold);
|
||||
|
||||
REQUIRE(renderer->getListBox()->propertyValuePairs.size() == 0);
|
||||
renderer->setListBox(listBoxRendererData);
|
||||
renderer->setListBox(listBoxRenderer.getData());
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(20, 30, 40));
|
||||
|
@ -293,10 +293,9 @@ TEST_CASE("[ComboBox]")
|
|||
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Borders(5, 6, 7, 8));
|
||||
REQUIRE(renderer->getProperty("TextStyle").getTextStyle() == sf::Text::Bold);
|
||||
|
||||
listBoxRendererData = renderer->getListBox();
|
||||
REQUIRE(listBoxRendererData->propertyValuePairs.size() == 2);
|
||||
REQUIRE(listBoxRendererData->propertyValuePairs["backgroundcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(listBoxRendererData->propertyValuePairs["textcolor"].getColor() == sf::Color::Blue);
|
||||
REQUIRE(renderer->getListBox()->propertyValuePairs.size() == 2);
|
||||
REQUIRE(renderer->getListBox()->propertyValuePairs["backgroundcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(renderer->getListBox()->propertyValuePairs["textcolor"].getColor() == sf::Color::Blue);
|
||||
}
|
||||
|
||||
SECTION("textured")
|
||||
|
|
|
@ -241,9 +241,9 @@ TEST_CASE("[ListBox]")
|
|||
|
||||
SECTION("colored")
|
||||
{
|
||||
auto scrollbarRendererData = std::make_shared<tgui::RendererData>();
|
||||
scrollbarRendererData->propertyValuePairs["trackcolor"] = {sf::Color::Red};
|
||||
scrollbarRendererData->propertyValuePairs["thumbcolor"] = {sf::Color::Blue};
|
||||
tgui::ScrollbarRenderer scrollbarRenderer;
|
||||
scrollbarRenderer.setTrackColor(sf::Color::Red);
|
||||
scrollbarRenderer.setThumbColor(sf::Color::Blue);
|
||||
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
|
@ -278,7 +278,7 @@ TEST_CASE("[ListBox]")
|
|||
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("TextStyle", sf::Text::Bold));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("SelectedTextStyle", sf::Text::Italic));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRendererData));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
|
||||
}
|
||||
|
||||
SECTION("functions")
|
||||
|
@ -298,7 +298,7 @@ TEST_CASE("[ListBox]")
|
|||
renderer->setSelectedTextStyle(sf::Text::Italic);
|
||||
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 0);
|
||||
renderer->setScrollbar(scrollbarRendererData);
|
||||
renderer->setScrollbar(scrollbarRenderer.getData());
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(20, 30, 40));
|
||||
|
@ -315,10 +315,9 @@ TEST_CASE("[ListBox]")
|
|||
REQUIRE(renderer->getProperty("TextStyle").getTextStyle() == sf::Text::Bold);
|
||||
REQUIRE(renderer->getProperty("SelectedTextStyle").getTextStyle() == sf::Text::Italic);
|
||||
|
||||
scrollbarRendererData = renderer->getScrollbar();
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs.size() == 2);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 2);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
}
|
||||
|
||||
SECTION("textured")
|
||||
|
|
|
@ -194,7 +194,7 @@ TEST_CASE("[Panel]")
|
|||
{
|
||||
panel = std::make_shared<tgui::Panel>(400.f, 300.f);
|
||||
|
||||
SECTION("independent panel")
|
||||
SECTION("Only save contents")
|
||||
{
|
||||
REQUIRE_NOTHROW(panel->saveWidgetsToFile("PanelWidgetFile1.txt"));
|
||||
|
||||
|
@ -206,13 +206,13 @@ TEST_CASE("[Panel]")
|
|||
REQUIRE(compareFiles("PanelWidgetFile1.txt", "PanelWidgetFile2.txt"));
|
||||
}
|
||||
|
||||
SECTION("panel inside gui")
|
||||
SECTION("Save entire panel")
|
||||
{
|
||||
auto widget = std::make_shared<tgui::ClickableWidget>();
|
||||
widget->setPosition(40, 20);
|
||||
panel->add(widget);
|
||||
|
||||
testSavingWidget("Panel", panel, false);
|
||||
testSavingWidget("Panel", panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,9 +163,9 @@ TEST_CASE("[TextBox]")
|
|||
|
||||
SECTION("colored")
|
||||
{
|
||||
auto scrollbarRendererData = std::make_shared<tgui::RendererData>();
|
||||
scrollbarRendererData->propertyValuePairs["trackcolor"] = {sf::Color::Red};
|
||||
scrollbarRendererData->propertyValuePairs["thumbcolor"] = {sf::Color::Blue};
|
||||
tgui::ScrollbarRenderer scrollbarRenderer;
|
||||
scrollbarRenderer.setTrackColor(sf::Color::Red);
|
||||
scrollbarRenderer.setThumbColor(sf::Color::Blue);
|
||||
|
||||
SECTION("set serialized property")
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ TEST_CASE("[TextBox]")
|
|||
REQUIRE_NOTHROW(renderer->setProperty("Borders", tgui::Borders{1, 2, 3, 4}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Padding", tgui::Borders{5, 6, 7, 8}));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("CaretWidth", 2));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRendererData));
|
||||
REQUIRE_NOTHROW(renderer->setProperty("Scrollbar", scrollbarRenderer.getData()));
|
||||
}
|
||||
|
||||
SECTION("functions")
|
||||
|
@ -208,7 +208,7 @@ TEST_CASE("[TextBox]")
|
|||
renderer->setCaretWidth(2);
|
||||
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 0);
|
||||
renderer->setScrollbar(scrollbarRendererData);
|
||||
renderer->setScrollbar(scrollbarRenderer.getData());
|
||||
}
|
||||
|
||||
REQUIRE(renderer->getProperty("BackgroundColor").getColor() == sf::Color(10, 20, 30));
|
||||
|
@ -221,10 +221,9 @@ TEST_CASE("[TextBox]")
|
|||
REQUIRE(renderer->getProperty("Padding").getOutline() == tgui::Borders(5, 6, 7, 8));
|
||||
REQUIRE(renderer->getProperty("CaretWidth").getNumber() == 2);
|
||||
|
||||
scrollbarRendererData = renderer->getScrollbar();
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs.size() == 2);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(scrollbarRendererData->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs.size() == 2);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["trackcolor"].getColor() == sf::Color::Red);
|
||||
REQUIRE(renderer->getScrollbar()->propertyValuePairs["thumbcolor"].getColor() == sf::Color::Blue);
|
||||
}
|
||||
|
||||
SECTION("textured")
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
|
@ -22,16 +22,16 @@ Checkbox {
|
|||
}
|
||||
|
||||
ChildWindow {
|
||||
TitlebarImage = "Black.png" Part(48, 154, 75, 25) Middle(25, 0, 25, 25);
|
||||
TextureTitlebar = "Black.png" Part(48, 154, 75, 25) Middle(25, 0, 25, 25);
|
||||
TitleColor = rgb(190, 190, 190);
|
||||
BackgroundColor = rgb( 80, 80, 80);
|
||||
BorderColor = Black;
|
||||
Borders = (1, 1, 1, 1);
|
||||
DistanceToSide = 5;
|
||||
CloseButton = {
|
||||
NormalImage = "Black.png" Part(48, 179, 15, 15);
|
||||
HoverImage = "Black.png" Part(63, 179, 15, 15);
|
||||
DownImage = "Black.png" Part(78, 179, 15, 15);
|
||||
Texture = "Black.png" Part(48, 179, 15, 15);
|
||||
TextureHover = "Black.png" Part(63, 179, 15, 15);
|
||||
TextureDown = "Black.png" Part(78, 179, 15, 15);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue