Mostly stuff related to the renderers

0.8
Bruno Van de Velde 2016-07-11 00:01:18 +02:00
parent b484d0a321
commit c43cbc61eb
187 changed files with 3405 additions and 2391 deletions

View File

@ -1,4 +1,12 @@
coverage:
status: false
ignore: "tests/*"
comment: false
coverage:
range: 50...90
status:
project: false
patch: false
changes: false
ignore:
- tests/*
- examples/.*
- include/TGUI/Widgets/devel/.*
- src/TGUI/Widgets/devel/.*

View File

@ -1,4 +1,4 @@
TGUI - Texus's Graphical User Interface
TGUI - Texus' Graphical User Interface
=======================================
[![Build Status](https://travis-ci.org/texus/TGUI.svg?branch=0.8-WIP-dev)](https://travis-ci.org/texus/TGUI)

View File

@ -1,5 +1,5 @@
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(SFML_OS_WINDOWS 1)
# don't use the OpenGL ES implementation on Windows
@ -8,15 +8,15 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# detect the architecture (note: this test won't work for cross-compilation)
include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
if(${SIZEOF_VOID_PTR} STREQUAL "4")
set(ARCH_32BITS 1)
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
elseif(${SIZEOF_VOID_PTR} STREQUAL "8")
set(ARCH_64BITS 1)
else()
message(FATAL_ERROR "Unsupported architecture")
return()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(SFML_OS_UNIX 1)
if(ANDROID)
set(SFML_OS_ANDROID 1)
@ -27,11 +27,11 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# don't use the OpenGL ES implementation on Linux
set(OPENGL_ES 0)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(SFML_OS_FREEBSD 1)
# don't use the OpenGL ES implementation on FreeBSD
set(OPENGL_ES 0)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(IOS)
set(SFML_OS_IOS 1)
@ -59,13 +59,13 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
return()
endif()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
set(SFML_OS_ANDROID 1)
# use the OpenGL ES implementation on Android
set(OPENGL_ES 1)
else()
message(FATAL_ERROR "Unsupported operating system")
message(FATAL_ERROR "Unsupported operating system or environment")
return()
endif()
@ -86,7 +86,7 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
if(${GCC_MACHINE} MATCHES ".*w64.*")
if(GCC_MACHINE MATCHES ".*w64.*")
set(SFML_COMPILER_GCC_W64 1)
endif()
elseif(MSVC)

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -26,15 +26,21 @@
#ifndef TGUI_COLOR_HPP
#define TGUI_COLOR_HPP
#include <TGUI/Global.hpp>
#include <TGUI/Loading/Deserializer.hpp>
#include <TGUI/Config.hpp>
#include <SFML/Graphics/Color.hpp>
#include <string>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Implicit converter for colors
/// @brief Wrapper for colors
///
/// The class is used for 2 purposes:
/// - Implicit converter for parameters. A function taking a Color as parameter can be given an sf::Color, RGB values or
/// even a serialized string as argument.
/// - Storing no color at all. Some colors may be optionally set and can thus remain unspecified.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API Color
@ -42,15 +48,21 @@ namespace tgui
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object from an sf::Color
/// @brief Creates the object without a color
///
/// @param color Color to copy
/// The isSet function will return false when the object was created using this constructor.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color(const sf::Color& color):
m_color{color}
{
}
Color();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object from an sf::Color
///
/// @param color Color to set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color(const sf::Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -62,10 +74,7 @@ namespace tgui
/// @param alpha Alpha component
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color(sf::Uint8 red, sf::Uint8 green, sf::Uint8 blue, sf::Uint8 alpha = 255) :
m_color{red, green, blue, alpha}
{
}
Color(sf::Uint8 red, sf::Uint8 green, sf::Uint8 blue, sf::Uint8 alpha = 255);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -76,10 +85,7 @@ namespace tgui
/// The Deserializer class is used to convert the string into a color.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color(const char* string) :
Color{std::string{string}}
{
}
Color(const std::string& string);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -90,26 +96,67 @@ namespace tgui
/// The Deserializer class is used to convert the string into a color.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color(const std::string& string) :
m_color{Deserializer::deserialize(tgui::ObjectConverter::Type::Color, string).getColor()}
{
}
Color(const char* string);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Checks if a color was set
///
/// @return True if a color was passed to the constructor, false when the default constructor was used
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool isSet() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Converts this object into an sf::Color object
///
/// @return The color stored in this object
/// @return The color stored in this object, or the default color if no color was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
operator sf::Color() const
{
return m_color;
}
operator sf::Color() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the red component of the color
///
/// @return Red component of the stored color or the one from the default color is no color was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 getRed() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the green component of the color
///
/// @return Green component of the stored color or the one from the default color is no color was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 getGreen() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the blue component of the color
///
/// @return Blue component of the stored color or the one from the default color is no color was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 getBlue() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the alpha component of the color
///
/// @return Alpha component of the stored color or the one from the default color is no color was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 getAlpha() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
bool m_isSet;
sf::Color m_color;
};

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -78,17 +78,6 @@ namespace tgui
Container& operator= (const Container& right);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 Returns a list of all the widgets
///
@ -367,7 +356,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -26,7 +26,11 @@
#ifndef TGUI_FONT_HPP
#define TGUI_FONT_HPP
#include <TGUI/Global.hpp>
#include <TGUI/Config.hpp>
#include <SFML/Graphics/Font.hpp>
#include <string>
#include <cstddef>
#include <memory>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -42,14 +46,7 @@ namespace tgui
/// @brief Default constructor which will set the font to nullptr
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Constructor which will explicitly set the font to nullptr
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font(std::nullptr_t);
Font(std::nullptr_t = nullptr);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -88,6 +85,15 @@ namespace tgui
Font(const sf::Font& font);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the id that was used to load the font
///
/// @return Id of the font or an empty string when no id was passed when this object was created
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string& getId() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets the underlying SFML font
///
@ -97,10 +103,71 @@ namespace tgui
std::shared_ptr<sf::Font> getFont() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets the underlying SFML font
///
/// @return Font stored in this object
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
operator std::shared_ptr<sf::Font>() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Converts the font to a boolean to check if it is a nullptr of not
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
operator bool() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Compares the font with a nullptr
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool operator==(std::nullptr_t) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Compares the font with a nullptr
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool operator!=(std::nullptr_t) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the kerning offset of two glyphs
///
/// The kerning is an extra offset (negative) to apply between two glyphs when rendering them, to make the pair look
/// more "natural". For example, the pair "AV" have a special kerning to make them closer than other characters.
/// Most of the glyphs pairs have a kerning offset of zero, though.
///
/// @param first Unicode code point of the first character
/// @param second Unicode code point of the second character
/// @param characterSize Size of the characters
///
/// @return Kerning value for \a first and \a second, in pixels
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getKerning(sf::Uint32 first, sf::Uint32 second, unsigned int characterSize) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the line spacing
///
/// Line spacing is the vertical offset to apply between two consecutive lines of text.
///
/// @param characterSize Size of the characters
///
/// @return Line spacing, in pixels
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getLineSpacing(unsigned int characterSize) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
std::shared_ptr<sf::Font> m_font;
std::string m_id;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -192,10 +192,7 @@ namespace tgui
/// @param font Font to use
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setFont(const Font& font)
{
m_container->setFont(font);
}
void setFont(const Font& font);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -204,10 +201,7 @@ namespace tgui
/// @return global font
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<sf::Font> getFont() const
{
return m_container->getFont();
}
std::shared_ptr<sf::Font> getFont() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -216,7 +210,7 @@ namespace tgui
/// @return Vector of all widget pointers
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::vector< Widget::Ptr >& getWidgets()
const std::vector<Widget::Ptr>& getWidgets()
{
return m_container->getWidgets();
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -29,6 +29,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <TGUI/Config.hpp>
#include <SFML/System/String.hpp>
#include <sstream>
#include <memory>
#include <vector>
@ -65,11 +66,11 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct ValueNode
{
ValueNode(const std::string& v = "") : value(v) {}
ValueNode(const sf::String& v = "") : value(v) {}
std::string value;
sf::String value;
bool listNode = false;
std::vector<std::string> valueList;
std::vector<sf::String> valueList;
};

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -27,7 +27,7 @@
#define TGUI_DESERIALIZER_HPP
#include <TGUI/Loading/ObjectConverter.hpp>
#include <TGUI/ObjectConverter.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -27,7 +27,7 @@
#define TGUI_SERIALIZER_HPP
#include <TGUI/Loading/ObjectConverter.hpp>
#include <TGUI/ObjectConverter.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -27,8 +27,11 @@
#define TGUI_OBJECT_CONVERTER_HPP
#include <TGUI/TextStyle.hpp>
#include <TGUI/Outline.hpp>
#include <TGUI/Texture.hpp>
#include <TGUI/Color.hpp>
#include <TGUI/Font.hpp>
#include <cassert>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -50,7 +53,8 @@ namespace tgui
String,
Number,
Outline,
Texture
Texture,
TextStyle
};
@ -84,7 +88,7 @@ namespace tgui
/// @param font Font to store
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter(const std::shared_ptr<sf::Font>& font) :
ObjectConverter(Font font) :
m_type{Type::Font},
m_font{font}
{
@ -97,7 +101,19 @@ namespace tgui
/// @param color Color to store
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter(const sf::Color& color) :
ObjectConverter(sf::Color color) :
ObjectConverter(Color(color))
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Stores a color object for later retrieval
///
/// @param color Color to store
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter(Color color) :
m_type {Type::Color},
m_color{color}
{
@ -143,6 +159,33 @@ namespace tgui
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Stores a color object for later retrieval
///
/// @param color Color to store
///
/// To combine multiple text styles, wrap the value inside the TextStyle object before passing it.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter(sf::Text::Style style) :
ObjectConverter(TextStyle(style))
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Stores a text style for later retrieval
///
/// @param style Text style to store
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter(TextStyle style) :
m_type {Type::TextStyle},
m_textStyle{style}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves the saved string
///
@ -160,7 +203,7 @@ namespace tgui
/// This function will assert when something other than a font was saved
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::shared_ptr<sf::Font>& getFont();
const Font& getFont();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -171,7 +214,7 @@ namespace tgui
/// This function will assert when something other than a color was saved
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const sf::Color& getColor();
const Color& getColor();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -207,6 +250,17 @@ namespace tgui
Texture& getTexture();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves the saved text style
///
/// @return Saved text style
///
/// This function will assert when something other than a text style was saved
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const TextStyle& getTextStyle();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Retrieves the type of the object that has been stored
///
@ -221,12 +275,13 @@ namespace tgui
Type m_type = Type::None;
bool m_serialized = false;
std::shared_ptr<sf::Font> m_font;
sf::Color m_color;
Font m_font;
Color m_color;
sf::String m_string;
float m_number = 0;
Outline m_outline;
Texture m_texture;
TextStyle m_textStyle;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -29,21 +29,15 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TGUI_RENDERER_PROPERTY_GET_OUTLINE(CLASS, NAME, DEFAULT) \
#define TGUI_RENDERER_PROPERTY_OUTLINE(CLASS, NAME) \
Outline CLASS::get##NAME() const \
{ \
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
if (it != m_data->propertyValuePairs.end()) \
return it->second.getOutline(); \
else \
{ \
m_data->propertyValuePairs[toLower(#NAME)] = {DEFAULT}; \
return m_data->propertyValuePairs[toLower(#NAME)].getOutline(); \
} \
}
#define TGUI_RENDERER_PROPERTY_OUTLINE(CLASS, NAME, DEFAULT) \
TGUI_RENDERER_PROPERTY_GET_OUTLINE(CLASS, NAME, DEFAULT) \
return {}; \
} \
void CLASS::set##NAME(const Outline& outline) \
{ \
setProperty(toLower(#NAME), {outline}); \
@ -51,28 +45,38 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TGUI_RENDERER_PROPERTY_GET_COLOR(CLASS, NAME, DEFAULT) \
sf::Color CLASS::get##NAME() const \
#define TGUI_RENDERER_PROPERTY_COLOR(CLASS, NAME, DEFAULT) \
Color CLASS::get##NAME() const \
{ \
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
if (it != m_data->propertyValuePairs.end()) \
return it->second.getColor(); \
else \
{ \
m_data->propertyValuePairs[toLower(#NAME)] = {DEFAULT}; \
return m_data->propertyValuePairs[toLower(#NAME)].getColor(); \
} \
}
#define TGUI_RENDERER_PROPERTY_COLOR(CLASS, NAME, DEFAULT) \
TGUI_RENDERER_PROPERTY_GET_COLOR(CLASS, NAME, DEFAULT) \
void CLASS::set##NAME(const Color& color) \
return DEFAULT; \
} \
void CLASS::set##NAME(Color color) \
{ \
setProperty(toLower(#NAME), {color}); \
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TGUI_RENDERER_PROPERTY_TEXT_STYLE(CLASS, NAME, DEFAULT) \
TextStyle CLASS::get##NAME() const \
{ \
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
if (it != m_data->propertyValuePairs.end()) \
return it->second.getTextStyle(); \
else \
return DEFAULT; \
} \
void CLASS::set##NAME(TextStyle style) \
{ \
setProperty(toLower(#NAME), ObjectConverter{style}); \
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TGUI_RENDERER_PROPERTY_GET_NUMBER(CLASS, NAME, DEFAULT) \
float CLASS::get##NAME() const \
{ \
@ -80,10 +84,7 @@
if (it != m_data->propertyValuePairs.end()) \
return it->second.getNumber(); \
else \
{ \
m_data->propertyValuePairs[toLower(#NAME)] = {DEFAULT}; \
return m_data->propertyValuePairs[toLower(#NAME)].getNumber(); \
} \
return DEFAULT; \
}
#define TGUI_RENDERER_PROPERTY_NUMBER(CLASS, NAME, DEFAULT) \
@ -94,30 +95,8 @@
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/**
#define TGUI_RENDERER_PROPERTY_GET_STRING(CLASS, NAME, DEFAULT) \
const sf::String& CLASS::get##NAME() const \
{ \
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
if (it != m_data->propertyValuePairs.end()) \
return it->second.getString(); \
else \
{ \
m_data->propertyValuePairs[toLower(#NAME)] = {DEFAULT}; \
return m_data->propertyValuePairs[toLower(#NAME)].getString(); \
} \
}
#define TGUI_RENDERER_PROPERTY_STRING(CLASS, NAME, DEFAULT) \
TGUI_RENDERER_PROPERTY_GET_STRING(CLASS, NAME, DEFAULT) \
void CLASS::set##NAME(const sf::String& string) \
{ \
setProperty(toLower(#NAME), {string}); \
}
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define TGUI_RENDERER_PROPERTY_GET_TEXTURE(CLASS, NAME) \
#define TGUI_RENDERER_PROPERTY_TEXTURE(CLASS, NAME) \
Texture& CLASS::get##NAME() const \
{ \
auto it = m_data->propertyValuePairs.find(toLower(#NAME)); \
@ -128,10 +107,7 @@
m_data->propertyValuePairs[toLower(#NAME)] = {Texture{}}; \
return m_data->propertyValuePairs[toLower(#NAME)].getTexture(); \
} \
}
#define TGUI_RENDERER_PROPERTY_TEXTURE(CLASS, NAME) \
TGUI_RENDERER_PROPERTY_GET_TEXTURE(CLASS, NAME) \
} \
void CLASS::set##NAME(const Texture& texture) \
{ \
setProperty(toLower(#NAME), {texture}); \

View File

@ -0,0 +1,452 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_BUTTON_RENDERER_HPP
#define TGUI_BUTTON_RENDERER_HPP
#include <TGUI/Renderers/WidgetRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
struct TGUI_API ButtonRenderer : public WidgetRenderer
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 color of the text
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text in the hover state (mouse on button, but not pressed)
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the hover state (mouse on button, but not pressed)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text in the down state (mouse on button and left mouse button being held down)
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorDown(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the down state (mouse on button and left mouse button being held down)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColorDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text that is used when the button is disabled
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorDisabled(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color that is used when the button is disabled
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColorDisabled() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the hover state (mouse on button, but not pressed)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the hover state (mouse on button, but not pressed)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the down state (mouse on button and left mouse button being held down)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorDown(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the down state (mouse on button and left mouse button being held down)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColorDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background that is used when the button is disabled
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorDisabled(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color that is used when the button is disabled
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColorDisabled() 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 color of the borders in the hover state (mouse on button, but not pressed)
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders in the hover state (mouse on button, but not pressed)
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBorderColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the borders in the down state (mouse on button and left mouse button being held down)
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColorDown(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders in the down state (mouse on button and left mouse button being held down)
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBorderColorDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the borders that is used when the button is disabled
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColorDisabled(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders that is used when the button is disabled
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBorderColorDisabled() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Change the image that is displayed
///
/// @param texture The new texture
///
/// When this image is set, the background color property will be ignored.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTexture(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed
///
/// @return texture of the button
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTexture() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is located on top of the button
///
/// @param texture The new hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is located on top of the button
///
/// @return hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is held down on top of the button
///
/// @param texture The new down texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureDown(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is held down on top of the button
///
/// @return down texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the button is disabled
///
/// @param texture The new disabled texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureDisabled(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the button is disabled
///
/// @return disabled texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureDisabled() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Change the image that is drawn on top of the button image when the button is focused
///
/// @param texture The new focus texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureFocused(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is drawn on top of the button image when the button is focused
///
/// @return focused texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureFocused() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyle(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style in the hover state (mouse on button, but not pressed)
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyleHover(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style in the hover state (mouse on button, but not pressed)
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyleHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style in the down state (mouse on button and left mouse button being held down)
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyleDown(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style in the down state (mouse on button and left mouse button being held down)
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyleDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style that is used when the button is disabled
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyleDisabled(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style used when the button is disabled
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyleDisabled() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_BUTTON_RENDERER_HPP

View File

@ -0,0 +1,394 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_EDIT_BOX_RENDERER_HPP
#define TGUI_EDIT_BOX_RENDERER_HPP
#include <TGUI/Renderers/WidgetRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
class TGUI_API EditBoxRenderer : public WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyle(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style of the default text (the text drawn when the edit box is empty)
///
/// @param style The new default text style
///
/// @code
/// editBox->getRenderer()->setDefaultTextStyle(sf::Text::Italic | sf::Text::Bold);
/// @endcode
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setDefaultTextStyle(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text style of the default text (the text drawn when the edit box is empty)
///
/// @return Style of the default text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getDefaultTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 padding of the edit box
///
/// When the text is auto-scaled then it will be drawn within the area defined by the size minus the border and padding.
/// The padding is also used to define the clipping area for when the text it too long.
///
/// This padding will be scaled together with the background image.
/// If there is no background image, or when 9-slice scaling is used, the padding will be exactly what you pass here.
///
/// @param padding The padding width and height
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void setPadding(const Padding& padding);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the size of the padding
///
/// @return padding size
///
/// @see setPadding
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Padding getPadding() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the width of the caret
///
/// @param width New width of the caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretWidth(float width);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the caret width
///
/// @param Width of the caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getCaretWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the text color that will be used inside the edit box
///
/// @param textColor The new text color.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(Color textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color that will be used inside the edit box
///
/// @return Text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the text color of the selected text that will be used inside the edit box
///
/// @param selectedTextColor The new selected text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(Color selectedTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color of the selected text that will be used inside the edit box
///
/// @return Text color of selected text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getSelectedTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the background color of the selected text that will be used inside the edit box
///
/// @param selectedTextBackgroundColor The new background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextBackgroundColor(Color selectedTextBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the selected text that will be used inside the edit box
///
/// @return Background color of selected text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getSelectedTextBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the color of the default text that can optionally be displayed when the edit box is empty
///
/// @param defaultTextColor The new default text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setDefaultTextColor(Color defaultTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the default text that can optionally be displayed when the edit box is empty
///
/// @return Default text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getDefaultTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the background
///
/// @return Background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the hover state (mouse on edit box, but not pressed)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the background in the hover state (mouse on edit box)
///
/// @return Background color in hover state
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the color that will be used inside the edit box for the blinking caret
///
/// @param caretColor The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretColor(Color caretColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color that will be used inside the edit box for the blinking caret
///
/// @return The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getCaretColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the color that will be used for the blinking caret when the mouse is on top of the edit box
///
/// @param caretColor The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretColorHover(Color caretColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color that will be used for the blinking caret when the mouse is on top of the edit box
///
/// @return The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getCaretColorHover() 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 color of the borders used when the mouse is on top of the edit box
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders used when the mouse is on top of the edit box
///
/// @return border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBorderColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed
///
/// @param texture The new edit box texture
///
/// When this image is set, the background color property will be ignored.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTexture(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed
///
/// @return edit box texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTexture() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is located on top of the edit box
///
/// @param texture The new hover texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is located on top of the edit box
///
/// @return hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is drawn on top of the edit box image when the edit box is focused
///
/// @param texture The new focus texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureFocused(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is drawn on top of the edit box image when the edit box is focused
///
/// @return focused texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureFocused() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_EDIT_BOX_RENDERER_HPP

View File

@ -0,0 +1,165 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_LABEL_RENDERER_HPP
#define TGUI_LABEL_RENDERER_HPP
#include <TGUI/Renderers/WidgetRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
struct TGUI_API LabelRenderer : public WidgetRenderer
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 size of the padding
///
/// @param padding Size of the padding
///
/// The padding is the distance between the side of the background and the text.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setPadding(const Padding& padding);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the size of the padding
///
/// @return padding size
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Padding getPadding() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the text
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the background color of the label
///
/// @param color New background color
///
/// The background color is transparent by default.
///
/// When auto-size is enabled (default), then the background is just as big as the text.
/// When a manual size is set, the background will fill this whole area.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the label
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColor() 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 style of the text
///
/// The possible styles can be found in the sf::Text::Style enum.
/// You can also pass a combination of multiple styles, for example sf::Text::Bold | sf::Text::Italic.
/// The default style is sf::Text::Regular.
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyle(TextStyle style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the style of the text
///
/// @return The current text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle getTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_LABEL_RENDERER_HPP

View File

@ -0,0 +1,105 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_PANEL_RENDERER_HPP
#define TGUI_PANEL_RENDERER_HPP
#include <TGUI/Renderers/WidgetRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
struct TGUI_API PanelRenderer : public WidgetRenderer
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 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 background color of the panel
///
/// @param color New background color
///
/// The background color is transparent by default.
///
/// When auto-size is enabled (default), then the background is just as big as the text.
/// When a manual size is set, the background will fill this whole area.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the panel
///
/// @return Background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color getBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_PANEL_RENDERER_HPP

View File

@ -0,0 +1,202 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_WIDGET_RENDERER_HPP
#define TGUI_WIDGET_RENDERER_HPP
#include <TGUI/Config.hpp>
#include <TGUI/ObjectConverter.hpp>
#include <TGUI/RendererDefines.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Shared data used in renderer classes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct RendererData
{
std::map<std::string, ObjectConverter> propertyValuePairs;
std::map<void*, std::function<void(const std::string& property, ObjectConverter& value)>> observers;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Base class for all renderer classes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Virtual destructor
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual ~WidgetRenderer() {};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the opacity of the widget
///
/// @return The opacity of the widget. 0 means completely transparent, while 1 (default) means fully opaque
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getOpacity() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font used for the text in the widget
///
/// @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(Font font);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the font associated with the widget (if any)
///
/// @return Font used by widget
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font getFont() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 value can either be a string value or a serialized string
///
/// @throw Exception for unknown properties or when value was of a wrong type
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setProperty(const std::string& property, const std::string& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setProperty(const std::string& property, ObjectConverter&& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter getProperty(const std::string& property) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets a map with all properties and their values
///
/// @return Property-value pairs of the renderer
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::map<std::string, ObjectConverter>& getPropertyValuePairs() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Subscribes a callback function to changes in the renderer
///
/// @param id Unique identifier for this callback function so that you can unsubscribe it later
/// @param function Callback function to call when the renderer changes
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void subscribe(void* id, const std::function<void(const std::string& property, ObjectConverter& value)>& function);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Subscribes a callback function to changes in the renderer
///
/// @param id Unique identifier used when subscribing the callback function
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void unsubscribe(void* id);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the renderer data
///
/// @return Data that is shared between the renderers
///
/// @warning You should not make changed to this data directly. Instead, use the function from the renderer classes
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<RendererData> getData() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets a clone of the renderer data
///
/// You can pass this to a widget with the setRenderer function to have a separate non-shared copy of this renderer.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<RendererData> clone() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
std::shared_ptr<RendererData> m_data = std::make_shared<RendererData>();
friend class Widget; // Only Widget is allowed to replace the m_data variable
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_WIDGETS_HPP

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

125
include/TGUI/TextStyle.hpp Normal file
View File

@ -0,0 +1,125 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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_TEXT_STYLE_HPP
#define TGUI_TEXT_STYLE_HPP
#include <TGUI/Config.hpp>
#include <SFML/Graphics/Text.hpp>
#include <string>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Wrapper for text styles
///
/// The class is used for 2 purposes:
/// - Implicit converter for parameters. A function taking a TextStyle as parameter can be given either an sf::Text::Style
/// or a string representation as argument.
/// - Storing no style at all. Some style settings may be optionally set and can thus remain unspecified.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API TextStyle
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object without a text style
///
/// The isSet function will return false when the object was created using this constructor.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object from one or more sf::Text::Style enum members
///
/// @param style Text style to set
///
/// @code
/// TextStyle style{sf::Text::Italic | sf::Text::Bold};
/// @endcode
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle(sf::Uint32 style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object from a string representing the text styles
///
/// @param string String to be deserialized as text styles
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle(const std::string& string);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Creates the object from a string representing the text styles
///
/// @param string String to be deserialized as text styles
///
/// @code
/// TextStyle style{"Italic | Bold"};
/// @endcode
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TextStyle(const char* string);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Checks if a style was set
///
/// @return True if a text style was passed to the constructor, false when the default constructor was used
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool isSet() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Converts this object into an sf::Uint32 object
///
/// @return The text styles stored in this object, or sf::Text::Regular if no style was set
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
operator sf::Uint32() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
bool m_isSet;
sf::Uint32 m_style;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_TEXT_STYLE_HPP

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -23,19 +23,14 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef TGUI_WIDGETS_HPP
#define TGUI_WIDGETS_HPP
#ifndef TGUI_WIDGET_HPP
#define TGUI_WIDGET_HPP
#include <TGUI/Global.hpp>
#include <TGUI/Signal.hpp>
#include <TGUI/Transformable.hpp>
#include <TGUI/Texture.hpp>
#include <TGUI/Color.hpp>
#include <TGUI/Font.hpp>
#include <TGUI/Loading/Deserializer.hpp>
#include <TGUI/RendererDefines.hpp>
#include <TGUI/Renderers/WidgetRenderer.hpp>
#include <TGUI/Aurora/SmartPtr/CopiedPtr.hpp>
#include <TGUI/Aurora/Tools/Downcast.hpp>
@ -44,8 +39,6 @@
namespace tgui
{
class Container;
class WidgetRenderer;
struct RendererData;
enum class ShowAnimationType;
namespace priv
@ -381,28 +374,6 @@ namespace tgui
Widget::Ptr getToolTip();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font of the text in the widget
///
/// @param font The new font
///
/// When you don't call this function then the font from the parent widget will be used.
///
/// Some widget don't need a font and won't do anything when this function is called.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void setFont(const Font& font);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the font associated with the widget (if any)
///
/// @return Font used by widget
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<sf::Font> getFont() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the distance between the position where the widget is drawn and where the widget is placed
///
@ -516,7 +487,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value);
virtual void rendererChanged(const std::string& property, ObjectConverter& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -534,7 +505,7 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Draw a shape with the right opacity
// Draw a rectangle shape with the right opacity
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void drawRectangleShape(sf::RenderTarget& target, const sf::RenderStates& states, sf::Vector2f position,
sf::Vector2f size, sf::Color color) const;
@ -557,7 +528,7 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Callback function which is called on a renderer change and which calls the virtual rendererChanged function
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void rendererChangedCallback(const std::string& property, ObjectConverter&& value);
void rendererChangedCallback(const std::string& property, ObjectConverter& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -596,9 +567,6 @@ namespace tgui
// The tool tip connected to the widget
Widget::Ptr m_toolTip = nullptr;
// The font that the widget can use
std::shared_ptr<sf::Font> m_font = nullptr;
// Renderer of the widget
aurora::CopiedPtr<WidgetRenderer> m_renderer = aurora::makeCopied<WidgetRenderer>();
@ -610,152 +578,11 @@ namespace tgui
friend class Container;
friend class BaseTheme;
friend class WidgetRenderer;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Data used in renderer classes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct RendererData
{
std::map<std::string, ObjectConverter> propertyValuePairs;
std::map<void*, std::function<void(const std::string& property, ObjectConverter&& value)>> observers;
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Base class for all renderer classes
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Virtual destructor
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual ~WidgetRenderer() {};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the opacity of the widget
///
/// @return The opacity of the widget. 0 means completely transparent, while 1 (default) means fully opaque
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getOpacity() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 value can either be a string value or a serialized string
///
/// @throw Exception for unknown properties or when value was of a wrong type
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setProperty(const std::string& property, const std::string& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setProperty(const std::string& property, ObjectConverter&& value);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter getProperty(const std::string& property) const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets a map with all properties and their values
///
/// @return Property-value pairs of the renderer
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::map<std::string, ObjectConverter>& getPropertyValuePairs() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Subscribes a callback function to changes in the renderer
///
/// @param id Unique identifier for this callback function so that you can unsubscribe it later
/// @param function Callback function to call when the renderer changes
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void subscribe(void* id, const std::function<void(const std::string& property, ObjectConverter&& value)>& function);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Subscribes a callback function to changes in the renderer
///
/// @param id Unique identifier used when subscribing the callback function
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void unsubscribe(void* id);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the renderer data
///
/// @return Data that is shared between the renderers
///
/// @warning You should not make changed to this data directly. Instead, use the function from the renderer classes
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<RendererData> getData() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Gets a clone of the renderer data
///
/// You can pass this to a widget with the setRenderer function to have a separate non-shared copy of this renderer.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<RendererData> clone() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
std::shared_ptr<RendererData> m_data = std::make_shared<RendererData>();
friend class Widget; // Only Widget is allowed to replace the m_data variable
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_WIDGETS_HPP
#endif // TGUI_WIDGET_HPP

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -27,15 +27,13 @@
#define TGUI_BUTTON_HPP
#include <TGUI/Renderers/ButtonRenderer.hpp>
#include <TGUI/Widgets/Label.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
class Container;
class ButtonRenderer;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Button widget
///
@ -94,17 +92,6 @@ namespace tgui
using Transformable::setSize;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font of the text in the widget
///
/// @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 caption of the button
///
@ -166,22 +153,6 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Function called when one of the properties of the renderer is changed
///
/// @param property Lowercase name of the property that was changed
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Returns the size without the borders
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Vector2f getInnerSize() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function is called when the mouse enters the widget. If requested, a callback will be send.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -194,6 +165,22 @@ namespace tgui
virtual void mouseLeftWidget() override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Function called when one of the properties of the renderer is changed
///
/// @param property Lowercase name of the property that was changed
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Returns the size without the borders
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Vector2f getInnerSize() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Draws the widget on the render target.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -212,8 +199,11 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
// Sets the text to the correct position
void recalculateTextPosition();
// Returns the background color that is being used in the current state
sf::Color getCurrentBackgroundColor() const;
// Sets the color and style of m_text depending on the current state
void updateTextColorAndStyle();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -227,278 +217,6 @@ namespace tgui
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API ButtonRenderer : public WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text
///
/// @param color New text color
///
/// This color will overwrite the color for any state (normal, hover and down).
///
/// @see setTextColorNormal
/// @see setTextColorHover
/// @see setTextColorDown
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background
///
/// @param color New background color
///
/// This color will overwrite the color for any state (normal, hover and down).
///
/// Note that this color is ignored when you set an image as background.
///
/// @see setBackgroundColorNormal
/// @see setBackgroundColorHover
/// @see setBackgroundColorDown
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 color of the text in the normal state (mouse not on button)
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorNormal(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the normal state (mouse not on button)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColorNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text in the hover state (mouse on button, but not pressed)
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorHover(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the hover state (mouse on button, but not pressed)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text in the down state (mouse on button and left mouse button being held down)
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorDown(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the down state (mouse on button and left mouse button being held down)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColorDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the normal state (mouse not on button)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorNormal(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the normal state (mouse not on button)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the hover state (mouse on button, but not pressed)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the hover state (mouse on button, but not pressed)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the down state (mouse on button and left mouse button being held down)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorDown(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the down state (mouse on button and left mouse button being held down)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the borders
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBorderColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Change the image that is displayed when the mouse is not on the button
///
/// @param texture The new normal texture
///
/// When this image is set, the background color property will be ignored.
/// Pass an empty texture to unset the image, in this case the background color property will be used again.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureNormal(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is not on the button
///
/// @param normal texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is located on top of the button
///
/// @param texture The new hover texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is located on top of the button
///
/// @param hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is held down on top of the button
///
/// @param texture The new down texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureDown(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is held down on top of the button
///
/// @param hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureDown() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Change the image that is drawn on top of the button image when the button is focused
///
/// @param texture The new focus texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureFocused(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is drawn on top of the button image when the button is focused
///
/// @param focused texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureFocused() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -127,7 +127,7 @@ namespace tgui
/// @param color Fill color to use to clear the canvas
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void clear(const Color& color = sf::Color(0, 0, 0, 255));
void clear(Color color = sf::Color(0, 0, 0, 255));
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -333,7 +333,7 @@ namespace tgui
/// @param color The new default text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -645,7 +645,7 @@ namespace tgui
/// @param borderColor The color of the borders
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& borderColor);
void setBorderColor(Color borderColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -656,7 +656,7 @@ namespace tgui
/// Note that this color is ignored when you set a background image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -485,7 +485,7 @@ namespace tgui
/// Note that this color is ignored when you set an image as title bar.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTitleBarColor(const Color& color);
void setTitleBarColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -503,7 +503,7 @@ namespace tgui
/// @param color New title color for the child window
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTitleColor(const Color& color);
void setTitleColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -512,7 +512,7 @@ namespace tgui
/// @param borderColor The color of the borders
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& borderColor);
void setBorderColor(Color borderColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -540,7 +540,7 @@ namespace tgui
/// @param backgroundColor New background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -758,7 +758,7 @@ namespace tgui
/// This color will be ignored when a background image was set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -774,7 +774,7 @@ namespace tgui
/// @see setArrowBackgroundColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColor(const Color& color);
void setArrowBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -785,7 +785,7 @@ namespace tgui
/// This color will be ignored when a up and down image were loaded for the normal state.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColorNormal(const Color& color);
void setArrowBackgroundColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -796,7 +796,7 @@ namespace tgui
/// This color will be ignored when a up and down image were loaded for the normal state.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColorHover(const Color& color);
void setArrowBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -812,7 +812,7 @@ namespace tgui
/// @see setArrowColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColor(const Color& color);
void setArrowColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -823,7 +823,7 @@ namespace tgui
/// This color will be ignored when a up and down image were loaded for the normal state.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorNormal(const Color& color);
void setArrowColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -834,7 +834,7 @@ namespace tgui
/// This color will be ignored when a up and down image were loaded for the normal state.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorHover(const Color& color);
void setArrowColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -843,7 +843,7 @@ namespace tgui
/// @param textColor The color of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& textColor);
void setTextColor(Color textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -852,7 +852,7 @@ namespace tgui
/// @param borderColor The color of the borders
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& borderColor);
void setBorderColor(Color borderColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -27,15 +27,13 @@
#include <TGUI/Widgets/ClickableWidget.hpp>
#include <TGUI/Renderers/EditBoxRenderer.hpp>
#include <regex>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
class EditBoxRenderer;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Edit box widget
///
@ -125,17 +123,6 @@ namespace tgui
using Transformable::setSize;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font of the text in the widget
///
/// @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 text of the editbox
///
@ -388,7 +375,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -502,346 +489,9 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API EditBoxRenderer : public WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyle(sf::Uint32 style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns text style
///
/// @return Style of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint32 getTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the text style of the default text (the text drawn when the edit box is empty)
///
/// @param style The new default text style
///
/// @code
/// editBox->getRenderer()->setDefaultTextStyle(sf::Text::Italic | sf::Text::Bold);
/// @endcode
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setDefaultTextStyle(sf::Uint32 style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text style of the default text (the text drawn when the edit box is empty)
///
/// @return Style of the default text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint32 getDefaultTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background
///
/// @param color New background color
///
/// This color will overwrite the color for both the normal and hover state.
///
/// Note that this color is ignored when you set an image as background.
///
/// @see setTextColorNormal
/// @see setTextColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 padding of the edit box
///
/// When the text is auto-scaled then it will be drawn within the area defined by the size minus the border and padding.
/// The padding is also used to define the clipping area for when the text it too long.
///
/// This padding will be scaled together with the background image.
/// If there is no background image, or when 9-slice scaling is used, the padding will be exactly what you pass here.
///
/// @param padding The padding width and height
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void setPadding(const Padding& padding);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the size of the padding
///
/// @return padding size
///
/// @see setPadding
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Padding getPadding() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the width of the caret
///
/// @param width New width of the caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretWidth(float width);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the caret width
///
/// @param Width of the caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float getCaretWidth() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the text color that will be used inside the edit box
///
/// @param textColor The new text color.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color that will be used inside the edit box
///
/// @return Text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the text color of the selected text that will be used inside the edit box
///
/// @param selectedTextColor The new selected text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(const Color& selectedTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color of the selected text that will be used inside the edit box
///
/// @return Text color of selected text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getSelectedTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the background color of the selected text that will be used inside the edit box
///
/// @param selectedTextBackgroundColor The new background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextBackgroundColor(const Color& selectedTextBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the selected text that will be used inside the edit box
///
/// @return Background color of selected text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getSelectedTextBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the color of the default text that can optionally be displayed when the edit box is empty
///
/// @param defaultTextColor The new default text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setDefaultTextColor(const Color& defaultTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the default text that can optionally be displayed when the edit box is empty
///
/// @return Default text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getDefaultTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the normal state (mouse not on edit box)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorNormal(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the background in the normal state (mouse not on edit box)
///
/// @return Background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the background in the hover state (mouse on edit box, but not pressed)
///
/// @param color New background color
///
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the background in the hover state (mouse on edit box)
///
/// @return Background color in hover state
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the color that will be used inside the edit box for the blinking caret
///
/// @param caretColor The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretColor(const Color& caretColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color that will be used inside the edit box for the blinking caret
///
/// @return The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getCaretColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the borders
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders
///
/// @return border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBorderColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is not on the edit box
///
/// @param texture The new normal texture
///
/// When this image is set, the background color property will be ignored.
/// Pass an empty texture to unset the image, in this case the background color property will be used again.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureNormal(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is not on the edit box
///
/// @param normal texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed when the mouse is located on top of the edit box
///
/// @param texture The new hover texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the mouse is located on top of the edit box
///
/// @param hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is drawn on top of the edit box image when the edit box is focused
///
/// @param texture The new focus texture
///
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextureFocused(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is drawn on top of the edit box image when the edit box is focused
///
/// @param focused texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureFocused() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // TGUI_EDIT_BOX_HPP

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -464,7 +464,7 @@ namespace tgui
/// Note that this color is ignored when a background and foreground image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -475,7 +475,7 @@ namespace tgui
/// Note that this is ignored when a background and foreground image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColor(const Color& color);
void setThumbColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -486,7 +486,7 @@ namespace tgui
/// Note that the borders are ignored when a background and foreground image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -28,13 +28,12 @@
#include <TGUI/Widgets/ClickableWidget.hpp>
#include <TGUI/Renderers/LabelRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
class LabelRenderer;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Label widget
///
@ -124,17 +123,6 @@ namespace tgui
using Transformable::setSize;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font of the text in the widget
///
/// @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 text
///
@ -157,28 +145,6 @@ namespace tgui
const sf::String& getText() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the style of the text
///
/// The possible styles can be found in the sf::Text::Style enum.
/// You can pass a combination of one or more styles, for example sf::Text::Bold | sf::Text::Italic.
/// The default style is sf::Text::Regular.
///
/// @param style New text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextStyle(sf::Uint32 style);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the style of the text
///
/// @return The current text style
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint32 getTextStyle() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the character size of the text
///
@ -311,7 +277,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -366,113 +332,6 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API LabelRenderer : 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 size of the padding
///
/// @param padding Size of the padding
///
/// The padding is the distance between the side of the background and the text.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setPadding(const Padding& padding);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the size of the padding
///
/// @return padding size
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Padding getPadding() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the text
///
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the text
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the background color of the label
///
/// @param color New background color
///
/// The background color is transparent by default.
///
/// When auto-size is enabled (default), then the background is just as big as the text.
/// When a manual size is set, the background will fill this whole area.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the label
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color of the borders
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBorderColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -743,7 +743,7 @@ namespace tgui
/// @param backgroundColor The color of the background of the list box
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -757,7 +757,7 @@ namespace tgui
/// @see setTextColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& textColor);
void setTextColor(Color textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -766,7 +766,7 @@ namespace tgui
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorNormal(const Color& color);
void setTextColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -775,7 +775,7 @@ namespace tgui
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorHover(const Color& color);
void setTextColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -784,7 +784,7 @@ namespace tgui
/// @param hoverBackgroundColor The color of the background of unselected item below the mouse
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setHoverBackgroundColor(const Color& hoverBackgroundColor);
void setHoverBackgroundColor(Color hoverBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -793,7 +793,7 @@ namespace tgui
/// @param selectedBackgroundColor The color of the background of the selected item
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedBackgroundColor(const Color& selectedBackgroundColor);
void setSelectedBackgroundColor(Color selectedBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -802,7 +802,7 @@ namespace tgui
/// @param selectedTextColor The color of the text when it is selected
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(const Color& selectedTextColor);
void setSelectedTextColor(Color selectedTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -811,7 +811,7 @@ namespace tgui
/// @param borderColor The color of the borders
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& borderColor);
void setBorderColor(Color borderColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -415,7 +415,7 @@ namespace tgui
/// @param backgroundColor The color of the background of the menu bar
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -424,7 +424,7 @@ namespace tgui
/// @param textColor The color of the text
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& textColor);
void setTextColor(Color textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -433,7 +433,7 @@ namespace tgui
/// @param selectedBackgroundColor The color of the background of the selected item
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedBackgroundColor(const Color& selectedBackgroundColor);
void setSelectedBackgroundColor(Color selectedBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -442,7 +442,7 @@ namespace tgui
/// @param selectedTextColor The color of the text when it is selected
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(const Color& selectedTextColor);
void setSelectedTextColor(Color selectedTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -472,7 +472,7 @@ namespace tgui
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -293,7 +293,7 @@ namespace tgui
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -28,13 +28,12 @@
#include <TGUI/Container.hpp>
#include <TGUI/Renderers/PanelRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
class PanelRenderer;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Panel widget
///
@ -143,7 +142,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -165,74 +164,6 @@ namespace tgui
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API PanelRenderer : 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 color of the borders
///
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the color of the borders
///
/// @return Border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBorderColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the background color of the panel
///
/// @param color New background color
///
/// The background color is transparent by default.
///
/// When auto-size is enabled (default), then the background is just as big as the text.
/// When a manual size is set, the background will fill this whole area.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color of the panel
///
/// @return Background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColor() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -225,7 +225,7 @@ namespace tgui
/// @param value New value of the property
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void rendererChanged(const std::string& property, ObjectConverter&& value) override;
virtual void rendererChanged(const std::string& property, ObjectConverter& value) override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -463,7 +463,7 @@ namespace tgui
/// @see setTextColorFront
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -474,7 +474,7 @@ namespace tgui
/// This color is displayed on top of the unfilled part. The front text color will be used on top of the filled part.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorBack(const Color& color);
void setTextColorBack(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -485,7 +485,7 @@ namespace tgui
/// This color is displayed on top of the filled part. The back text color will be used on top of the unfilled part.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorFront(const Color& color);
void setTextColorFront(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -498,7 +498,7 @@ namespace tgui
/// Note that this color is ignored when you set an image as background.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -511,7 +511,7 @@ namespace tgui
/// Note that this color is ignored when you set an image as foreground.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setForegroundColor(const Color& color);
void setForegroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -520,7 +520,7 @@ namespace tgui
/// @param color The color that is used for the borders that are optionally drawn around the progress bar
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -81,23 +81,10 @@ namespace tgui
/// @return Temporary pointer to the renderer
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RadioButtonRenderer* getRenderer() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Sets the position of the widget
///
/// This function completely overwrites the previous position.
/// See the move function to apply an offset based on the previous position instead.
/// The default position of a transformable widget is (0, 0).
///
/// @param position New position
///
/// @see move, getPosition
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void setPosition(const Layout2d& position) override;
using Transformable::setPosition;
RadioButtonRenderer* getRenderer() const
{
return aurora::downcast<RadioButtonRenderer*>(m_renderer.get());
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -116,11 +103,24 @@ namespace tgui
/// @return Full size of the radio button
///
/// The returned size includes the text next to the radio button.
/// When textures are loaded, the height of the checked image is used (in case the check goes outside of the box).
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual sf::Vector2f getFullSize() const override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the distance between the position where the widget is drawn and where the widget is placed
///
/// When using textures and the checked texture is larger than the unchecked one (when the check mark leaves the box)
/// then this function will return (0, -heightDiff), otherwise (0,0) is returned.
///
/// @return Offset of the widget
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual sf::Vector2f getWidgetOffset() const override;
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the font of the text in the widget
///
@ -130,7 +130,7 @@ namespace tgui
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void setFont(const Font& font) override;
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Checks the radio button
@ -175,10 +175,7 @@ namespace tgui
/// @return The text that is drawn next to the radio button
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::String getText() const
{
return m_text.getText();
}
const sf::String& getText() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -287,11 +284,22 @@ namespace tgui
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
// Reset the sizes of the textures if they are used
void updateTextureSizes();
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
// This is the checked flag. When the radio button is checked then this variable will be true.
bool m_checked = false;
bool m_checked = false; // This member is protected instead of private because it is accessed in the CheckBox class
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
// When this boolean is true (default) then the radio button will also be checked by clicking on the text.
bool m_allowTextClick = true;
@ -311,18 +319,9 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class TGUI_API RadioButtonRenderer : public WidgetRenderer/**, public WidgetPadding*/
class TGUI_API RadioButtonRenderer : public WidgetRenderer
{
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Constructor
///
/// @param radioButton The radio button that is connected to the renderer
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
RadioButtonRenderer(RadioButton* radioButton) : m_radioButton{radioButton} {}
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes a property of the renderer
@ -370,6 +369,24 @@ namespace tgui
virtual std::map<std::string, ObjectConverter> getPropertyValuePairs() const override;
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @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 color of the text
///
@ -381,7 +398,7 @@ namespace tgui
/// @see setTextColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -390,7 +407,16 @@ namespace tgui
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorNormal(const Color& color);
void setTextColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the normal state (mouse not on radio button)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColorNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -399,9 +425,20 @@ namespace tgui
/// @param color New text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColorHover(const Color& color);
void setTextColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the text color in the hover state (mouse on radio button)
///
/// @return text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getTextColorHover() const;
///TODO: Background color becomes border color (and can also be used when images are set).
/// Foreground color becomes background color (and is replaced by images when they are set)
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the background color
///
@ -417,7 +454,7 @@ namespace tgui
/// @see setBackgroundColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -430,7 +467,16 @@ namespace tgui
/// This color can be seen as the border color. It is only visible when there is some padding.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorNormal(const Color& color);
void setBackgroundColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the normal state (mouse not on radio button)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorNormal() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -443,7 +489,16 @@ namespace tgui
/// This color can be seen as the border color. It is only visible when there is some padding.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(const Color& color);
void setBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the background color in the hover state (mouse on radio button)
///
/// @return background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Color getBackgroundColorHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -462,7 +517,7 @@ namespace tgui
/// @see setForegroundColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setForegroundColor(const Color& color);
void setForegroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -478,7 +533,7 @@ namespace tgui
/// This color will overwrite the color for both the normal and hover state.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setForegroundColorNormal(const Color& color);
void setForegroundColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -492,8 +547,8 @@ namespace tgui
/// When there is padding, the background color will thus serve as the border color.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setForegroundColorHover(const Color& color);
void setForegroundColorHover(Color color);
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the color that is used to fill the radio button when it is checked
@ -508,7 +563,7 @@ namespace tgui
/// @see setCheckColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCheckColor(const Color& color);
void setCheckColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -519,7 +574,7 @@ namespace tgui
/// @param color New check color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCheckColorNormal(const Color& color);
void setCheckColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -530,7 +585,7 @@ namespace tgui
/// @param color New check color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCheckColorHover(const Color& color);
void setCheckColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -538,11 +593,20 @@ namespace tgui
///
/// @param texture The new unchecked texture
///
/// When checked and unchecked images are set, the background and foreground color properties will be ignored.
/// Pass an empty string to unset the image.
/// When checked and unchecked images are set, the background and check color properties will be ignored.
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setUncheckedTexture(const Texture& texture);
void setTextureUnchecked(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the checkbox is not checked
///
/// @return unchecked texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureUnchecked() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -550,11 +614,20 @@ namespace tgui
///
/// @param texture The new checked texture
///
/// When checked and unchecked images are set, the background and foreground color properties will be ignored.
/// Pass an empty string to unset the image.
/// When checked and unchecked images are set, the background and check color properties will be ignored.
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCheckedTexture(const Texture& texture);
void setTextureChecked(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the checkbox is checked
///
/// @return checked texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureChecked() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -563,10 +636,19 @@ namespace tgui
/// @param texture The new unchecked hover texture
///
/// This only has effect when the normal checked and unchecked images are also set.
/// Pass an empty string to unset the image.
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setUncheckedHoverTexture(const Texture& texture);
void setTextureUncheckedHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the checkbox is not checked and the mouse is on top of the checkbox
///
/// @return unchecked hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureUncheckedHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -575,29 +657,47 @@ namespace tgui
/// @param texture The new checked hover texture
///
/// This only has effect when the normal checked and unchecked images are also set.
/// Pass an empty string to unset the image.
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCheckedHoverTexture(const Texture& texture);
void setTextureCheckedHover(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed when the checkbox is checked and the mouse is on top of the checkbox
///
/// @return checked hover texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureCheckedHover() const;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Changes the image that is displayed on top of the checkbox when it is focused
///
/// @param texture The new checked hover texture
/// @param texture The new focused texture
///
/// This only has effect when the normal checked and unchecked images are also set.
/// Pass an empty string to unset the image.
/// Pass an empty texture to unset the image.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setFocusedTexture(const Texture& texture);
void setTextureFocused(const Texture& texture);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @brief Returns the image that is displayed on top of the checkbox when it is focused
///
/// @return focused texture
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Texture& getTextureFocused() const;
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Draws the widget on the render target.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
*/
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
@ -607,7 +707,7 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
virtual std::shared_ptr<WidgetRenderer> clone(Widget* widget) override;
*/
/**
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
protected:
@ -632,7 +732,7 @@ namespace tgui
sf::Color m_checkColorHover;
friend class RadioButton;
*/
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
};

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -446,7 +446,7 @@ namespace tgui
/// @see setTrackColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColor(const Color& color);
void setTrackColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -457,7 +457,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColorNormal(const Color& color);
void setTrackColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -468,7 +468,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColorHover(const Color& color);
void setTrackColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -484,7 +484,7 @@ namespace tgui
/// @see setTrackColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColor(const Color& color);
void setThumbColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -495,7 +495,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColorNormal(const Color& color);
void setThumbColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -506,7 +506,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColorHover(const Color& color);
void setThumbColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -522,7 +522,7 @@ namespace tgui
/// @see setArrowBackgroundColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColor(const Color& color);
void setArrowBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -533,7 +533,7 @@ namespace tgui
/// Note that this color is ignored when all normal images have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColorNormal(const Color& color);
void setArrowBackgroundColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -544,7 +544,7 @@ namespace tgui
/// Note that this color is ignored when all normal images have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowBackgroundColorHover(const Color& color);
void setArrowBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -560,7 +560,7 @@ namespace tgui
/// @see setArrowColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColor(const Color& color);
void setArrowColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -571,7 +571,7 @@ namespace tgui
/// Note that this color is ignored when all normal images have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorNormal(const Color& color);
void setArrowColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -582,7 +582,7 @@ namespace tgui
/// Note that this color is ignored when all normal images have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorHover(const Color& color);
void setArrowColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -387,7 +387,7 @@ namespace tgui
/// @see setTrackColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColor(const Color& color);
void setTrackColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -398,7 +398,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColorNormal(const Color& color);
void setTrackColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -409,7 +409,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTrackColorHover(const Color& color);
void setTrackColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -425,7 +425,7 @@ namespace tgui
/// @see setTrackColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColor(const Color& color);
void setThumbColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -436,7 +436,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColorNormal(const Color& color);
void setThumbColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -447,7 +447,7 @@ namespace tgui
/// Note that this color is ignored when a track and thumb image have been set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setThumbColorHover(const Color& color);
void setThumbColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -456,7 +456,7 @@ namespace tgui
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -385,7 +385,7 @@ namespace tgui
/// @see setBackgroundColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -396,7 +396,7 @@ namespace tgui
/// Note that this color is ignored when an up and down arrow image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorNormal(const Color& color);
void setBackgroundColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -407,7 +407,7 @@ namespace tgui
/// Note that this color is ignored when an up and down arrow image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColorHover(const Color& color);
void setBackgroundColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -423,7 +423,7 @@ namespace tgui
/// @see setArrowColorHover
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColor(const Color& color);
void setArrowColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -434,7 +434,7 @@ namespace tgui
/// Note that this color is ignored when an up and down arrow image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorNormal(const Color& color);
void setArrowColorNormal(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -445,7 +445,7 @@ namespace tgui
/// Note that this color is ignored when an up and down arrow image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setArrowColorHover(const Color& color);
void setArrowColorHover(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -454,7 +454,7 @@ namespace tgui
/// @param color New border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -538,7 +538,7 @@ namespace tgui
/// @param color The new text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& color);
void setTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -547,7 +547,7 @@ namespace tgui
/// @param color The new text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(const Color& color);
void setSelectedTextColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -567,7 +567,7 @@ namespace tgui
/// Note that this color is ignored when a normal and selected image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& color);
void setBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -578,7 +578,7 @@ namespace tgui
/// Note that this color is ignored when a normal and selected image were set.
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedBackgroundColor(const Color& color);
void setSelectedBackgroundColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -587,7 +587,7 @@ namespace tgui
/// @param color The new border color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& color);
void setBorderColor(Color color);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -583,7 +583,7 @@ namespace tgui
/// @param backgroundColor The new background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBackgroundColor(const Color& backgroundColor);
void setBackgroundColor(Color backgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -592,7 +592,7 @@ namespace tgui
/// @param textColor The new text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setTextColor(const Color& textColor);
void setTextColor(Color textColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -601,7 +601,7 @@ namespace tgui
/// @param selectedTextColor The new text color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextColor(const Color& selectedTextColor);
void setSelectedTextColor(Color selectedTextColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -610,7 +610,7 @@ namespace tgui
/// @param selectedTextBackgroundColor The new background color
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setSelectedTextBackgroundColor(const Color& selectedTextBackgroundColor);
void setSelectedTextBackgroundColor(Color selectedTextBackgroundColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -619,7 +619,7 @@ namespace tgui
/// @param borderColor The color of the borders
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setBorderColor(const Color& borderColor);
void setBorderColor(Color borderColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -628,7 +628,7 @@ namespace tgui
/// @param caretColor The color of the blinking caret
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setCaretColor(const Color& caretColor);
void setCaretColor(Color caretColor);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,4 +1,4 @@
TGUI - Texus's Graphical User Interface
TGUI - Texus' Graphical User Interface
---------------------------------------
TGUI - Copyright (c) 2012-2016 Bruno Van de Velde - vdv_b@tgui.eu

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -2,13 +2,16 @@ set(TGUI_SRC
Animation.cpp
#BoxLayout.cpp
Clipboard.cpp
Color.cpp
Container.cpp
Font.cpp
Global.cpp
Gui.cpp
#HorizontalLayout.cpp
Layout.cpp
ObjectConverter.cpp
Signal.cpp
TextStyle.cpp
Texture.cpp
TextureManager.cpp
Transformable.cpp
@ -16,13 +19,17 @@ set(TGUI_SRC
Widget.cpp
Loading/DataIO.cpp
Loading/Deserializer.cpp
Loading/ObjectConverter.cpp
Loading/Serializer.cpp
Loading/Theme.cpp
Loading/ThemeLoader.cpp
Loading/WidgetConverter.cpp
Loading/WidgetLoader.cpp
Loading/WidgetSaver.cpp
Renderers/ButtonRenderer.cpp
Renderers/EditBoxRenderer.cpp
Renderers/LabelRenderer.cpp
Renderers/PanelRenderer.cpp
Renderers/WidgetRenderer.cpp
Widgets/Button.cpp
#Widgets/Canvas.cpp
#Widgets/ChatBox.cpp

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// TGUI - Texus' Graphical User Interface
// Copyright (C) 2012-2016 Bruno Van de Velde (vdv_b@tgui.eu)
// Koushtav Chakrabarty (koushtav@fleptic.eu)
//

116
src/TGUI/Color.cpp Normal file
View File

@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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/Color.hpp>
#include <TGUI/Loading/Deserializer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::Color() :
m_isSet{false}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::Color(const sf::Color& color) :
m_isSet{true},
m_color{color}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::Color(sf::Uint8 red, sf::Uint8 green, sf::Uint8 blue, sf::Uint8 alpha) :
m_isSet{true},
m_color{red, green, blue, alpha}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::Color(const std::string& string) :
m_isSet{true},
m_color{Deserializer::deserialize(tgui::ObjectConverter::Type::Color, string).getColor()}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::Color(const char* string) :
Color{std::string{string}}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Color::isSet() const
{
return m_isSet;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Color::operator sf::Color() const
{
return m_color;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 Color::getRed() const
{
return m_color.r;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 Color::getGreen() const
{
return m_color.g;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 Color::getBlue() const
{
return m_color.b;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sf::Uint8 Color::getAlpha() const
{
return m_color.a;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -81,23 +81,13 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Container::setFont(const Font& font)
{
Widget::setFont(font);
for (auto& widget : m_widgets)
widget->setFont(font);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Container::add(const Widget::Ptr& widgetPtr, const sf::String& widgetName)
{
assert(widgetPtr != nullptr);
// Let the widget inherit our font if it did not had a font yet
if (!widgetPtr->getFont() && getFont())
widgetPtr->setFont(getFont());
if (!widgetPtr->getRenderer()->getFont() && getRenderer()->getFont())
widgetPtr->getRenderer()->setFont(getRenderer()->getFont());
widgetPtr->setParent(this);
m_widgets.push_back(widgetPtr);
@ -555,15 +545,20 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Container::rendererChanged(const std::string& property, ObjectConverter&& value)
void Container::rendererChanged(const std::string& property, ObjectConverter& value)
{
if (property == "opacity")
{
for (std::size_t i = 0; i < m_widgets.size(); ++i)
m_widgets[i]->getRenderer()->setOpacity(value.getNumber());
}
Widget::rendererChanged(property, std::move(value));
else if (property == "font")
{
for (auto& widget : m_widgets)
widget->getRenderer()->setFont(value.getFont());
}
else
Widget::rendererChanged(property, value);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -32,22 +32,15 @@ namespace tgui
{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font::Font() :
m_font{nullptr}
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font::Font(std::nullptr_t) :
m_font{nullptr}
Font::Font(std::nullptr_t)
{
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font::Font(const std::string& id) :
m_font{Deserializer::deserialize(ObjectConverter::Type::Font, id).getFont()}
m_font{Deserializer::deserialize(ObjectConverter::Type::Font, id).getFont()},
m_id {id}
{
}
@ -74,12 +67,67 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::string& Font::getId() const
{
return m_id;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<sf::Font> Font::getFont() const
{
return m_font;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font::operator std::shared_ptr<sf::Font>() const
{
return m_font;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Font::operator bool() const
{
return m_font != nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Font::operator==(std::nullptr_t) const
{
return m_font == nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool Font::operator!=(std::nullptr_t) const
{
return m_font != nullptr;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float Font::getKerning(sf::Uint32 first, sf::Uint32 second, unsigned int characterSize) const
{
if (m_font)
return m_font->getKerning(first, second, characterSize);
else
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
float Font::getLineSpacing(unsigned int characterSize) const
{
if (m_font)
return m_font->getLineSpacing(characterSize);
else
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -267,6 +267,20 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Gui::setFont(const Font& font)
{
m_container->getRenderer()->setFont(font);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
std::shared_ptr<sf::Font> Gui::getFont() const
{
return m_container->getRenderer()->getFont();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void Gui::add(const Widget::Ptr& widgetPtr, const sf::String& widgetName)
{
m_container->add(widgetPtr, widgetName);

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -110,7 +110,7 @@ namespace tgui
void DataIO::emit(std::shared_ptr<Node> rootNode, std::stringstream& stream)
{
for (auto& pair : rootNode->propertyValuePairs)
stream << pair.first << ": " << pair.second->value << ";" << std::endl;
stream << pair.first << ": " << pair.second->value.toAnsiString() << ";" << std::endl;
if (rootNode->propertyValuePairs.size() > 0 && rootNode->children.size() > 0)
stream << std::endl;
@ -282,13 +282,13 @@ namespace tgui
}
else if (line[i] == '"')
{
valueNode->valueList.back().push_back(line[i]);
valueNode->valueList.back().insert(valueNode->valueList.back().getSize(), line[i]);
i++;
bool backslash = false;
while (i < line.size()-1)
{
valueNode->valueList.back().push_back(line[i]);
valueNode->valueList.back().insert(valueNode->valueList.back().getSize(), line[i]);
if (line[i] == '"' && !backslash)
{
@ -306,7 +306,7 @@ namespace tgui
}
else
{
valueNode->valueList.back().push_back(line[i]);
valueNode->valueList.back().insert(valueNode->valueList.back().getSize(), line[i]);
i++;
}
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -80,11 +80,11 @@ namespace tgui
TGUI_API ObjectConverter deserializeFont(const std::string& value)
{
if (value == "null" || value == "nullptr")
return std::shared_ptr<sf::Font>();
return Font{};
auto font = std::make_shared<sf::Font>();
font->loadFromFile(Deserializer::deserialize(ObjectConverter::Type::String, value).getString());
return font;
return Font(font);
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -112,7 +112,7 @@ namespace tgui
// Check if the color is represented by a string with its name
auto it = colorMap.find(toLower(str));
if (it != colorMap.end())
return it->second;
return Color(it->second);
// The color can be represented with a hexadecimal number
if (str[0] == '#')
@ -127,29 +127,29 @@ namespace tgui
// Parse the different types of strings (#123, #1234, #112233 and #11223344)
if (value.length() == 4)
{
return sf::Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[1])),
static_cast<sf::Uint8>(hexToDec(value[2]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[3]))};
return Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[1])),
static_cast<sf::Uint8>(hexToDec(value[2]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[3]))};
}
else if (value.length() == 5)
{
return sf::Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[1])),
static_cast<sf::Uint8>(hexToDec(value[2]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[3])),
static_cast<sf::Uint8>(hexToDec(value[4]) * 16 + hexToDec(value[4]))};
return Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[1])),
static_cast<sf::Uint8>(hexToDec(value[2]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[3])),
static_cast<sf::Uint8>(hexToDec(value[4]) * 16 + hexToDec(value[4]))};
}
else if (value.length() == 7)
{
return sf::Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[4])),
static_cast<sf::Uint8>(hexToDec(value[5]) * 16 + hexToDec(value[6]))};
return Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[4])),
static_cast<sf::Uint8>(hexToDec(value[5]) * 16 + hexToDec(value[6]))};
}
else if (value.length() == 9)
{
return sf::Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[4])),
static_cast<sf::Uint8>(hexToDec(value[5]) * 16 + hexToDec(value[6])),
static_cast<sf::Uint8>(hexToDec(value[7]) * 16 + hexToDec(value[8]))};
return Color{static_cast<sf::Uint8>(hexToDec(value[1]) * 16 + hexToDec(value[2])),
static_cast<sf::Uint8>(hexToDec(value[3]) * 16 + hexToDec(value[4])),
static_cast<sf::Uint8>(hexToDec(value[5]) * 16 + hexToDec(value[6])),
static_cast<sf::Uint8>(hexToDec(value[7]) * 16 + hexToDec(value[8]))};
}
else
throw Exception{"Failed to deserialize color '" + value + "'. Value started but '#' but has the wrong length."};
@ -168,10 +168,10 @@ namespace tgui
std::vector<std::string> tokens = tgui::split(str, ',');
if (tokens.size() == 3 || tokens.size() == 4)
{
return sf::Color{static_cast<sf::Uint8>(tgui::stoi(tokens[0])),
static_cast<sf::Uint8>(tgui::stoi(tokens[1])),
static_cast<sf::Uint8>(tgui::stoi(tokens[2])),
static_cast<sf::Uint8>((tokens.size() == 4) ? tgui::stoi(tokens[3]) : 255)};
return Color{static_cast<sf::Uint8>(tgui::stoi(tokens[0])),
static_cast<sf::Uint8>(tgui::stoi(tokens[1])),
static_cast<sf::Uint8>(tgui::stoi(tokens[2])),
static_cast<sf::Uint8>((tokens.size() == 4) ? tgui::stoi(tokens[3]) : 255)};
}
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -76,9 +76,12 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TGUI_API std::string serializeFont(ObjectConverter&&)
TGUI_API std::string serializeFont(ObjectConverter&& value)
{
return "null";
if (value.getFont() && !value.getFont().getId().empty())
return Serializer::serialize({sf::String{value.getFont().getId()}});
else
return "null";
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -23,6 +23,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <TGUI/Loading/Deserializer.hpp>
#include <TGUI/Loading/ThemeLoader.hpp>
#include <TGUI/Loading/DataIO.hpp>
@ -104,8 +105,8 @@ namespace tgui
if (quotePos != std::string::npos)
{
///TODO: Detect absolute pathname on windows
if ((pair.second->value.size() > quotePos + 1) && (pair.second->value[quotePos+1] != '/'))
pair.second->value = pair.second->value.substr(0, quotePos+1) + resourcePath + pair.second->value.substr(quotePos+1);
if ((pair.second->value.getSize() > quotePos + 1) && (pair.second->value[quotePos+1] != '/'))
pair.second->value = pair.second->value.substring(0, quotePos+1) + resourcePath + pair.second->value.substring(quotePos+1);
}
}

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -23,6 +23,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <TGUI/Loading/Deserializer.hpp>
#include <TGUI/Loading/WidgetLoader.hpp>
#include <TGUI/Widgets/Button.hpp>/**
#include <TGUI/Widgets/Canvas.hpp>
@ -163,14 +164,33 @@ namespace tgui
if (node->propertyValuePairs["size"])
widget->setSize(parseLayout(node->propertyValuePairs["size"]->value));
/// TODO: Font and ToolTip (and Theme?)
/// TODO: ToolTip
/// TODO: Separate renderer?
for (auto& childNode : node->children)
{
if (toLower(childNode->name) == "renderer")
{
auto rendererData = std::make_shared<RendererData>();
for (auto& pair : childNode->propertyValuePairs)
rendererData->propertyValuePairs[pair.first] = {pair.second->value};
widget->setRenderer(rendererData);
/**
auto renderer = std::make_shared<WidgetRenderer>();
for (auto& pair : childNode->propertyValuePairs)
renderer->setProperty(pair.first, pair.second->value);
widget->setRenderer(renderer->getData());
*/
/**
widget->getRenderer()->getData()->propertyValuePairs = {};
for (auto& pair : childNode->propertyValuePairs)
widget->getRenderer()->setProperty(pair.first, pair.second->value);
*/
}
}
REMOVE_CHILD("renderer");
@ -488,15 +508,6 @@ namespace tgui
loadWidget(node, label);
if (node->propertyValuePairs["textstyle"])
{
sf::Uint32 style = decodeTextStyle(node->propertyValuePairs["textstyle"]->value);
if (style == sf::Text::Regular && toLower(node->propertyValuePairs["textstyle"]->value) != "regular")
throw Exception{"Failed to parse TextStyle property, found unknown style '" + node->propertyValuePairs["textstyle"]->value + "'."};
label->setTextStyle(style);
}
if (node->propertyValuePairs["horizontalalignment"])
{
std::string alignment = toLower(DESERIALIZE_STRING("horizontalalignment"));

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -304,10 +304,6 @@ namespace tgui
{
auto node = saveWidget(label);
std::string style = encodeTextStyle(label->getTextStyle());
if (style != "Regular")
SET_PROPERTY("TextStyle", style);
if (label->getHorizontalAlignment() == Label::HorizontalAlignment::Center)
SET_PROPERTY("HorizontalAlignment", "Center");
else if (label->getHorizontalAlignment() == Label::HorizontalAlignment::Right)

View File

@ -1,6 +1,6 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// TGUI - Texus's Graphical User Interface
// 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.
@ -23,7 +23,7 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <TGUI/Loading/ObjectConverter.hpp>
#include <TGUI/ObjectConverter.hpp>
#include <TGUI/Loading/Serializer.hpp>
#include <TGUI/Loading/Deserializer.hpp>
#include <cassert>
@ -51,6 +51,8 @@ namespace tgui
m_string = Serializer::serialize(m_outline);
else if (m_type == Type::Texture)
m_string = Serializer::serialize(m_texture);
else if (m_type == Type::TextStyle)
m_string = encodeTextStyle(m_textStyle);
m_serialized = true;
return m_string;
@ -58,13 +60,13 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const std::shared_ptr<sf::Font>& ObjectConverter::getFont()
const Font& ObjectConverter::getFont()
{
assert(m_type == Type::Font || m_type == Type::String);
if (m_type == Type::String)
{
m_font = Deserializer::deserialize(ObjectConverter::Type::Font, m_string).getFont();
m_font = Font(m_string);
m_type = Type::Font;
}
@ -73,13 +75,13 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const sf::Color& ObjectConverter::getColor()
const Color& ObjectConverter::getColor()
{
assert(m_type == Type::Color || m_type == Type::String);
if (m_type == Type::String)
{
m_color = Deserializer::deserialize(ObjectConverter::Type::Color, m_string).getColor();
m_color = Color(m_string);
m_type = Type::Color;
}
@ -133,6 +135,21 @@ namespace tgui
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const TextStyle& ObjectConverter::getTextStyle()
{
assert(m_type == Type::TextStyle || m_type == Type::String);
if (m_type == Type::String)
{
m_textStyle = decodeTextStyle(m_string);
m_type = Type::TextStyle;
}
return m_textStyle;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ObjectConverter::Type ObjectConverter::getType() const
{
return m_type;

View File

@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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/ButtonRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
TGUI_RENDERER_PROPERTY_OUTLINE(ButtonRenderer, Borders)
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, TextColor, sf::Color::Black)
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, TextColorHover, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, TextColorDown, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, TextColorDisabled, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BackgroundColor, sf::Color::White)
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BackgroundColorHover, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BackgroundColorDown, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BackgroundColorDisabled, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BorderColor, sf::Color::Black)
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BorderColorHover, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BorderColorDown, {})
TGUI_RENDERER_PROPERTY_COLOR(ButtonRenderer, BorderColorDisabled, {})
TGUI_RENDERER_PROPERTY_TEXTURE(ButtonRenderer, Texture)
TGUI_RENDERER_PROPERTY_TEXTURE(ButtonRenderer, TextureHover)
TGUI_RENDERER_PROPERTY_TEXTURE(ButtonRenderer, TextureDown)
TGUI_RENDERER_PROPERTY_TEXTURE(ButtonRenderer, TextureDisabled)
TGUI_RENDERER_PROPERTY_TEXTURE(ButtonRenderer, TextureFocused) /// TODO
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ButtonRenderer, TextStyle, sf::Text::Regular)
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ButtonRenderer, TextStyleHover, {})
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ButtonRenderer, TextStyleDown, {})
TGUI_RENDERER_PROPERTY_TEXT_STYLE(ButtonRenderer, TextStyleDisabled, {})
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// 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/EditBoxRenderer.hpp>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace tgui
{
TGUI_RENDERER_PROPERTY_OUTLINE(EditBoxRenderer, Borders)
TGUI_RENDERER_PROPERTY_OUTLINE(EditBoxRenderer, Padding)
TGUI_RENDERER_PROPERTY_NUMBER(EditBoxRenderer, CaretWidth, 1)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, TextColor, sf::Color::Black)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, SelectedTextColor, sf::Color::White)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, SelectedTextBackgroundColor, Color(0, 110, 255))
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, DefaultTextColor, Color(160, 160, 160))
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, BackgroundColor, sf::Color::White)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, BackgroundColorHover, {})
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, CaretColor, sf::Color::Black)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, CaretColorHover, {})
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, BorderColor, sf::Color::Black)
TGUI_RENDERER_PROPERTY_COLOR(EditBoxRenderer, BorderColorHover, {})
TGUI_RENDERER_PROPERTY_TEXTURE(EditBoxRenderer, Texture)
TGUI_RENDERER_PROPERTY_TEXTURE(EditBoxRenderer, TextureHover)
TGUI_RENDERER_PROPERTY_TEXTURE(EditBoxRenderer, TextureFocused)
TGUI_RENDERER_PROPERTY_TEXT_STYLE(EditBoxRenderer, TextStyle, sf::Text::Regular)
TGUI_RENDERER_PROPERTY_TEXT_STYLE(EditBoxRenderer, DefaultTextStyle, sf::Text::Italic)
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Some files were not shown because too many files have changed in this diff Show More