Browse Source

Some cleanup and warning fixes.

Michael Ragazzon 5 years ago
parent
commit
e94fb0d690

+ 42 - 37
Include/RmlUi/Config/Config.h

@@ -26,8 +26,8 @@
  *
  *
  */
  */
 
 
-#ifndef RMLUI_USER_CONFIG_H
-#define RMLUI_USER_CONFIG_H
+#ifndef RMLUI_CONFIG_CONFIG_H
+#define RMLUI_CONFIG_CONFIG_H
 
 
 /*
 /*
  * This file provides means to configure various types used across RmlUi. It is possible to override container types
  * This file provides means to configure various types used across RmlUi. It is possible to override container types
@@ -142,6 +142,8 @@ inline UniquePtr<T> MakeUnique(Args... args) { return std::make_unique<T, Args..
 
 
 }
 }
 
 
+
+/***
 // The following defines should be used for inserting custom type cast operators for conversion of RmlUi types
 // The following defines should be used for inserting custom type cast operators for conversion of RmlUi types
 // to user types. RmlUi uses template math types, therefore conversion operators to non-templated types
 // to user types. RmlUi uses template math types, therefore conversion operators to non-templated types
 // should be done using SFINAE as in example below.
 // should be done using SFINAE as in example below.
@@ -149,49 +151,52 @@ inline UniquePtr<T> MakeUnique(Args... args) { return std::make_unique<T, Args..
 // Extra code to be inserted into RmlUi::Color<> class body. Note: be mindful of colorspaces used by different
 // Extra code to be inserted into RmlUi::Color<> class body. Note: be mindful of colorspaces used by different
 // color types. RmlUi assumes that float colors are interpreted in linear colorspace while byte colors are 
 // color types. RmlUi assumes that float colors are interpreted in linear colorspace while byte colors are 
 // interpreted as SRGB.
 // interpreted as SRGB.
-// #define RMLUI_COLOUR_USER_EXTRA                                                                         \
-//     template<typename U = ColourType, typename std::enable_if_t<std::is_same_v<U, byte>>* = nullptr>    \
-//     operator MyColor() const { return MyColor(                                                          \
-//         (float)red / 256.0f, (float)green / 255.0f, (float)blue / 255.0f, (float)alpha / 255.0f); }     \
-//     template<typename U = ColourType, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>   \
-//     operator MyColor() const { return MyColor(red, green, blue, alpha); }                               \
+
+#define RMLUI_COLOUR_USER_EXTRA                                                                         \
+	template<typename U = ColourType, typename std::enable_if_t<std::is_same_v<U, byte>>* = nullptr>    \
+	operator MyColor() const { return MyColor(                                                          \
+		(float)red / 256.0f, (float)green / 255.0f, (float)blue / 255.0f, (float)alpha / 255.0f); }     \
+	template<typename U = ColourType, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>   \
+	operator MyColor() const { return MyColor(red, green, blue, alpha); }                               \
 
 
 // Extra code to be inserted into RmlUi::Vector2<> class body.
 // Extra code to be inserted into RmlUi::Vector2<> class body.
-// #define RMLUI_VECTOR2_USER_EXTRA                                                                        \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     operator typename MyIntVector2() const { return MyIntVector2(x, y); }                               \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     operator MyVector2() const { return MyVector2(x, y); }                                              \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     Vector2(MyIntVector2 value) : Vector2(value.x_, value.y_) { }                                       \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     Vector2(MyVector2 value) : Vector2(value.x_, value.y_) { }                                          \
+#define RMLUI_VECTOR2_USER_EXTRA                                                                        \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	operator typename MyIntVector2() const { return MyIntVector2(x, y); }                               \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	operator MyVector2() const { return MyVector2(x, y); }                                              \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	Vector2(MyIntVector2 value) : Vector2(value.x_, value.y_) { }                                       \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	Vector2(MyVector2 value) : Vector2(value.x_, value.y_) { }                                          \
 
 
 // Extra code to be inserted into RmlUi::Vector3<> class body.
 // Extra code to be inserted into RmlUi::Vector3<> class body.
-// #define RMLUI_VECTOR3_USER_EXTRA                                                                        \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     operator typename MyIntVector3() const { return MyIntVector3(x, y, z); }                            \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     operator MyVector3() const { return MyVector3(x, y, z); }                                           \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     Vector3(MyIntVector3 value) : Vector3(value.x_, value.y_, value.z_) { }                             \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     Vector3(MyVector3 value) : Vector3(value.x_, value.y_, value.z_) { }                                \
+#define RMLUI_VECTOR3_USER_EXTRA                                                                        \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	operator typename MyIntVector3() const { return MyIntVector3(x, y, z); }                            \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	operator MyVector3() const { return MyVector3(x, y, z); }                                           \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	Vector3(MyIntVector3 value) : Vector3(value.x_, value.y_, value.z_) { }                             \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	Vector3(MyVector3 value) : Vector3(value.x_, value.y_, value.z_) { }                                \
 
 
 // Extra code to be inserted into RmlUi::Vector4<> class body.
 // Extra code to be inserted into RmlUi::Vector4<> class body.
-// #define RMLUI_VECTOR4_USER_EXTRA                                                                        \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     operator typename MyIntVector4() const { return MyIntVector4(x, y, z, w); }                         \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     operator MyVector4() const { return MyVector4(x, y, z, w); }                                        \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
-//     Vector4(MyIntVector4 value) : Vector4(value.x_, value.y_, value.z_, value.w_) { }                   \
-//     template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
-//     Vector4(MyVector4 value) : Vector4(value.x_, value.y_, value.z_, value.w_) { }                      \
+#define RMLUI_VECTOR4_USER_EXTRA                                                                        \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	operator typename MyIntVector4() const { return MyIntVector4(x, y, z, w); }                         \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	operator MyVector4() const { return MyVector4(x, y, z, w); }                                        \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, int>>* = nullptr>           \
+	Vector4(MyIntVector4 value) : Vector4(value.x_, value.y_, value.z_, value.w_) { }                   \
+	template<typename U = Type, typename std::enable_if_t<std::is_same_v<U, float>>* = nullptr>         \
+	Vector4(MyVector4 value) : Vector4(value.x_, value.y_, value.z_, value.w_) { }                      \
 
 
 // Extra code to be inserted into RmlUi::Matrix4<> class body.
 // Extra code to be inserted into RmlUi::Matrix4<> class body.
-// #define RMLUI_MATRIX4_USER_EXTRA operator MyMatrix4() const { return MyMatrix4(data()); }
+	#define RMLUI_MATRIX4_USER_EXTRA operator MyMatrix4() const { return MyMatrix4(data()); }
+***/
+
 
 
 #endif	// RMLUI_USER_CONFIG_FILE
 #endif	// RMLUI_USER_CONFIG_FILE
 
 
-#endif  // RMLUI_USER_CONFIG_H
+#endif  // RMLUI_CONFIG_CONFIG_H

+ 3 - 2
Include/RmlUi/Core/DataModel.h

@@ -34,7 +34,6 @@
 #include "Traits.h"
 #include "Traits.h"
 #include "DataTypes.h"
 #include "DataTypes.h"
 #include "DataTypeRegister.h"
 #include "DataTypeRegister.h"
-#include <functional>
 
 
 namespace Rml {
 namespace Rml {
 
 
@@ -155,7 +154,9 @@ public:
 	// Convenience wrapper around BindEventCallback for member functions.
 	// Convenience wrapper around BindEventCallback for member functions.
 	template<typename T>
 	template<typename T>
 	bool BindEventCallback(const String& name, DataEventMemberFunc<T> member_func, T* object_pointer) {
 	bool BindEventCallback(const String& name, DataEventMemberFunc<T> member_func, T* object_pointer) {
-		return BindEventCallback(name, std::bind(member_func, object_pointer, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+		return BindEventCallback(name, [member_func, object_pointer](DataModelHandle handle, Event& event, const VariantList& arguments) {
+			(object_pointer->*member_func)(handle, event, arguments);
+		});
 	}
 	}
 
 
 	// Register a struct type.
 	// Register a struct type.

+ 1 - 1
Include/RmlUi/Core/TransformPrimitive.h

@@ -60,7 +60,7 @@ protected:
 
 
 // An unresolved primitive may have values that depend on the final layout of a given element, such as its width.
 // An unresolved primitive may have values that depend on the final layout of a given element, such as its width.
 template< size_t N >
 template< size_t N >
-struct UnresolvedPrimitive
+struct RMLUICORE_API UnresolvedPrimitive
 {
 {
 	Array<NumericValue, N> values;
 	Array<NumericValue, N> values;
 
 

+ 3 - 3
Samples/basic/databinding/src/main.cpp

@@ -247,9 +247,9 @@ namespace InvadersExample {
 		{
 		{
 			using namespace Rml;
 			using namespace Rml;
 			const int num_items = 4;
 			const int num_items = 4;
-			static std::array<String, num_items> names = { "Angry invader", "Harmless invader", "Deceitful invader", "Cute invader" };
-			static std::array<String, num_items> sprites = { "icon-invader", "icon-flag", "icon-game", "icon-waves" };
-			static std::array<Colourb, num_items> colors = { { { 255, 40, 30 }, {20, 40, 255}, {255, 255, 30}, {230, 230, 230} } };
+			static Array<String, num_items> names = { "Angry invader", "Harmless invader", "Deceitful invader", "Cute invader" };
+			static Array<String, num_items> sprites = { "icon-invader", "icon-flag", "icon-game", "icon-waves" };
+			static Array<Colourb, num_items> colors = { { { 255, 40, 30 }, {20, 40, 255}, {255, 255, 30}, {230, 230, 230} } };
 
 
 			Invader new_invader;
 			Invader new_invader;
 			new_invader.name = names[rand() % num_items];
 			new_invader.name = names[rand() % num_items];

+ 1 - 1
Samples/basic/sdl2/src/SystemInterfaceSDL2.cpp

@@ -410,7 +410,7 @@ double RmlUiSDL2SystemInterface::GetElapsedTime()
 
 
 bool RmlUiSDL2SystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message)
 bool RmlUiSDL2SystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message)
 {
 {
-	std::string Type;
+	Rml::String Type;
 
 
 	switch(type)
 	switch(type)
 	{
 	{

+ 4 - 4
Samples/basic/sfml2/src/RenderInterfaceSFML.cpp

@@ -86,9 +86,9 @@ void RmlUiSFMLRenderer::RenderGeometry(Rml::Vertex* vertices, int num_vertices,
 
 
 	glTranslatef(translation.x, translation.y, 0);
 	glTranslatef(translation.x, translation.y, 0);
 
 
-	std::vector<Rml::Vector2f> Positions(num_vertices);
-	std::vector<Rml::Colourb> Colors(num_vertices);
-	std::vector<Rml::Vector2f> TexCoords(num_vertices);
+	Rml::Vector<Rml::Vector2f> Positions(num_vertices);
+	Rml::Vector<Rml::Colourb> Colors(num_vertices);
+	Rml::Vector<Rml::Vector2f> TexCoords(num_vertices);
 
 
 	for(int i = 0; i < num_vertices; i++)
 	for(int i = 0; i < num_vertices; i++)
 	{
 	{
@@ -135,7 +135,7 @@ void RmlUiSFMLRenderer::RenderGeometry(Rml::Vertex* vertices, int num_vertices,
 Rml::CompiledGeometryHandle RmlUiSFMLRenderer::CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::TextureHandle texture)
 Rml::CompiledGeometryHandle RmlUiSFMLRenderer::CompileGeometry(Rml::Vertex* vertices, int num_vertices, int* indices, int num_indices, const Rml::TextureHandle texture)
 {
 {
 #ifdef ENABLE_GLEW
 #ifdef ENABLE_GLEW
-	std::vector<RmlUiSFMLRendererVertex> Data(num_vertices);
+	Rml::Vector<RmlUiSFMLRendererVertex> Data(num_vertices);
 
 
 	for(std::size_t i = 0; i < Data.size(); i++)
 	for(std::size_t i = 0; i < Data.size(); i++)
 	{
 	{

+ 1 - 1
Samples/basic/sfml2/src/SystemInterfaceSFML.cpp

@@ -314,7 +314,7 @@ double RmlUiSFMLSystemInterface::GetElapsedTime()
 
 
 bool RmlUiSFMLSystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message)
 bool RmlUiSFMLSystemInterface::LogMessage(Rml::Log::Type type, const Rml::String& message)
 {
 {
-	std::string Type;
+	Rml::String Type;
 
 
 	switch(type)
 	switch(type)
 	{
 	{

+ 3 - 3
Samples/invaders/src/DecoratorStarfield.h

@@ -29,8 +29,8 @@
 #ifndef RMLUI_INVADERS_DECORATORSTARFIELD_H
 #ifndef RMLUI_INVADERS_DECORATORSTARFIELD_H
 #define RMLUI_INVADERS_DECORATORSTARFIELD_H
 #define RMLUI_INVADERS_DECORATORSTARFIELD_H
 
 
+#include <RmlUi/Core/Types.h>
 #include <RmlUi/Core/Decorator.h>
 #include <RmlUi/Core/Decorator.h>
-#include <vector>
 
 
 class DecoratorStarfield : public Rml::Decorator
 class DecoratorStarfield : public Rml::Decorator
 {
 {
@@ -63,7 +63,7 @@ private:
 
 
 	struct StarLayer
 	struct StarLayer
 	{
 	{
-		typedef std::vector< Rml::Vector2f > StarList;
+		typedef Rml::Vector< Rml::Vector2f > StarList;
 		StarList stars;
 		StarList stars;
 		Rml::Colourb colour;
 		Rml::Colourb colour;
 		float speed;
 		float speed;
@@ -75,7 +75,7 @@ private:
 		double last_update;
 		double last_update;
 		Rml::Vector2f dimensions;
 		Rml::Vector2f dimensions;
 
 
-		typedef std::vector< StarLayer > StarLayerList;
+		typedef Rml::Vector< StarLayer > StarLayerList;
 		StarLayerList star_layers;
 		StarLayerList star_layers;
 	};
 	};
 };
 };

+ 3 - 3
Samples/luainvaders/src/DecoratorStarfield.h

@@ -29,8 +29,8 @@
 #ifndef RMLUI_LUAINVADERS_DECORATORSTARFIELD_H
 #ifndef RMLUI_LUAINVADERS_DECORATORSTARFIELD_H
 #define RMLUI_LUAINVADERS_DECORATORSTARFIELD_H
 #define RMLUI_LUAINVADERS_DECORATORSTARFIELD_H
 
 
+#include <RmlUi/Core/Types.h>
 #include <RmlUi/Core/Decorator.h>
 #include <RmlUi/Core/Decorator.h>
-#include <vector>
 
 
 class DecoratorStarfield : public Rml::Decorator
 class DecoratorStarfield : public Rml::Decorator
 {
 {
@@ -63,7 +63,7 @@ private:
 
 
 	struct StarLayer
 	struct StarLayer
 	{
 	{
-		typedef std::vector< Rml::Vector2f > StarList;
+		typedef Rml::Vector< Rml::Vector2f > StarList;
 		StarList stars;
 		StarList stars;
 		Rml::Colourb colour;
 		Rml::Colourb colour;
 		float speed;
 		float speed;
@@ -75,7 +75,7 @@ private:
 		double last_update;
 		double last_update;
 		Rml::Vector2f dimensions;
 		Rml::Vector2f dimensions;
 
 
-		typedef std::vector< StarLayer > StarLayerList;
+		typedef Rml::Vector< StarLayer > StarLayerList;
 		StarLayerList star_layers;
 		StarLayerList star_layers;
 	};
 	};
 };
 };

+ 1 - 1
Source/Core/StyleSheetParser.h

@@ -39,7 +39,7 @@ class Stream;
 class StyleSheetNode;
 class StyleSheetNode;
 class AbstractPropertyParser;
 class AbstractPropertyParser;
 struct PropertySource;
 struct PropertySource;
-using StyleSheetNodeListRaw = std::vector<StyleSheetNode*>;
+using StyleSheetNodeListRaw = Vector<StyleSheetNode*>;
 
 
 /**
 /**
 	Helper class for parsing a style sheet into its memory representation.
 	Helper class for parsing a style sheet into its memory representation.

+ 2 - 2
Source/Core/XMLNodeHandlerBody.cpp

@@ -42,9 +42,9 @@ XMLNodeHandlerBody::~XMLNodeHandlerBody()
 {
 {
 }
 }
 
 
-Element* XMLNodeHandlerBody::ElementStart(XMLParser* parser, const String& RMLUI_UNUSED_ASSERT_PARAMETER(name), const XMLAttributes& attributes)
+Element* XMLNodeHandlerBody::ElementStart(XMLParser* parser, const String& RMLUI_UNUSED_PARAMETER(name), const XMLAttributes& attributes)
 {
 {
-	RMLUI_UNUSED_ASSERT(name);
+	RMLUI_UNUSED(name);
 
 
 	Element* element = parser->GetParseFrame()->element;
 	Element* element = parser->GetParseFrame()->element;
 
 

+ 7 - 5
Source/Debugger/ElementLog.cpp

@@ -131,15 +131,17 @@ bool ElementLog::Initialise()
 // Adds a log message to the debug log.
 // Adds a log message to the debug log.
 void ElementLog::AddLogMessage(Log::Type type, const String& message)
 void ElementLog::AddLogMessage(Log::Type type, const String& message)
 {
 {
+	LogMessageList& log_message_list = log_types[type].log_messages;
+	if (log_message_list.size() >= MAX_LOG_MESSAGES)
+	{
+		log_message_list.erase(log_message_list.begin());
+	}
+
 	// Add the message to the list of messages for the specified log type.
 	// Add the message to the list of messages for the specified log type.
 	LogMessage log_message;
 	LogMessage log_message;
 	log_message.index = current_index++;
 	log_message.index = current_index++;
 	log_message.message = StringUtilities::EncodeRml(message);
 	log_message.message = StringUtilities::EncodeRml(message);
-	log_types[type].log_messages.push_back(log_message);
-	if (log_types[type].log_messages.size() >= MAX_LOG_MESSAGES)
-	{
-		log_types[type].log_messages.pop_front();
-	}
+	log_message_list.push_back(log_message);
 
 
 	// If this log type is invisible, and there is a button for this log type, then change its text from
 	// If this log type is invisible, and there is a button for this log type, then change its text from
 	// "Off" to "Off*" to signal that there are unread logs.
 	// "Off" to "Off*" to signal that there are unread logs.

+ 2 - 2
Source/Debugger/ElementLog.h

@@ -31,7 +31,7 @@
 
 
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/ElementDocument.h"
 #include "../../Include/RmlUi/Core/EventListener.h"
 #include "../../Include/RmlUi/Core/EventListener.h"
-#include <deque>
+#include "../../Include/RmlUi/Core/Types.h"
 
 
 namespace Rml {
 namespace Rml {
 namespace Debugger {
 namespace Debugger {
@@ -67,7 +67,7 @@ private:
 		unsigned int index;
 		unsigned int index;
 		String message;
 		String message;
 	};
 	};
-	typedef std::deque< LogMessage > LogMessageList;
+	using LogMessageList = Vector< LogMessage >;
 
 
 	struct LogType
 	struct LogType
 	{
 	{