Add project files.
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
#include "GUIXMLTest.hpp"
|
||||
|
||||
void GUIXMLTest()
|
||||
{
|
||||
// cString
|
||||
printf("\nTesting GUI XML Test -----\n\n");
|
||||
|
||||
GUIXMLDefaultTest();
|
||||
|
||||
GUIXMLPositionTest();
|
||||
|
||||
GUIXMLAlignTest();
|
||||
}
|
||||
|
||||
void GUIXMLDefaultTest()
|
||||
{
|
||||
UTest u("GUI XML Default");
|
||||
|
||||
LoadFile("GUIXMLDefaultTest.xml");
|
||||
|
||||
std::vector<GUIEngine::cWindow*> objects = GUIEngine::cGUI::Inst().GetObjects();
|
||||
|
||||
GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0];
|
||||
|
||||
Settings sets;
|
||||
sets.pos = { 0, 0 };
|
||||
sets.size = { 200, 200 };
|
||||
sets.pad = { 0, 0, 0, 0 };
|
||||
sets.center = { 100, 100 };
|
||||
|
||||
cWindowTest("Panel", u, panel, sets);
|
||||
|
||||
GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0];
|
||||
|
||||
sets.pos = { 5, 5 };
|
||||
sets.size = { 190, 190 };
|
||||
sets.pad = { 5, 5, 5, 5 };
|
||||
|
||||
|
||||
cWindowTest("Layout", u, layout, sets);
|
||||
|
||||
GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0];
|
||||
|
||||
|
||||
sets.pos = { 56, 96 };
|
||||
sets.size = { 88, 8 };
|
||||
|
||||
cWindowTest("Label", u, label, sets);
|
||||
|
||||
u.report();
|
||||
|
||||
GUIEngine::cGUI::Inst().Delete();
|
||||
}
|
||||
|
||||
void GUIXMLPositionTest()
|
||||
{
|
||||
UTest u("GUI XML Position");
|
||||
|
||||
LoadFile("GUIXMLPositionTest.xml");
|
||||
|
||||
std::vector<GUIEngine::cWindow*> objects = GUIEngine::cGUI::Inst().GetObjects();
|
||||
|
||||
|
||||
GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0];
|
||||
|
||||
Settings sets;
|
||||
sets.pos = { 20, 20 };
|
||||
sets.size = { 200, 200 };
|
||||
sets.pad = { 0, 0, 0, 0 };
|
||||
sets.center = { 120, 120 };
|
||||
|
||||
cWindowTest("Panel", u, panel, sets);
|
||||
|
||||
|
||||
GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0];
|
||||
|
||||
sets.pos = { 25, 25 };
|
||||
sets.size = { 190, 190 };
|
||||
sets.pad = { 5, 5, 5, 5 };
|
||||
|
||||
cWindowTest("Layout", u, layout, sets);
|
||||
|
||||
|
||||
GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0];
|
||||
|
||||
sets.pos = { 76, 116 };
|
||||
sets.size = { 88, 8 };
|
||||
|
||||
cWindowTest("Label", u, label, sets);
|
||||
|
||||
u.report();
|
||||
|
||||
GUIEngine::cGUI::Inst().Delete();
|
||||
}
|
||||
|
||||
void GUIXMLAlignTest()
|
||||
{
|
||||
UTest u("GUI XML Default");
|
||||
|
||||
LoadFile("GUIXMLAlignTest.xml", true);
|
||||
|
||||
|
||||
std::vector<GUIEngine::cWindow*> objects = GUIEngine::cGUI::Inst().GetObjects();
|
||||
|
||||
GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0];
|
||||
|
||||
Settings sets;
|
||||
sets.pos = { 0, 0 };
|
||||
sets.size = { 400, 400 };
|
||||
sets.pad = { 0, 0, 0, 0 };
|
||||
sets.center = { 200, 200 };
|
||||
|
||||
cWindowTest("Panel", u, panel, sets);
|
||||
|
||||
GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0];
|
||||
|
||||
sets.pos = { 5, 5 };
|
||||
sets.size = { 390, 390 };
|
||||
sets.pad = { 5, 5, 5, 5 };
|
||||
|
||||
cWindowTest("Layout", u, layout, sets);
|
||||
|
||||
GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0];
|
||||
|
||||
switch (label->getAlign()) {
|
||||
case GUIHelpers::eAlign::LEFT:
|
||||
sets.pos = { 10, 178 };
|
||||
sets.center = { 74, 182 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::CENTER:
|
||||
sets.pos = { 136, 178 };
|
||||
sets.center = { 200, 182 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::RIGHT:
|
||||
sets.pos = { 262, 178 };
|
||||
sets.center = { 326, 182 };
|
||||
break;
|
||||
}
|
||||
|
||||
sets.size = { 128, 8 };
|
||||
|
||||
|
||||
cWindowTest("Label 'Hello world One'", u, label, sets);
|
||||
|
||||
label = (GUIEngine::cLabel*)layout->getChildren()[1];
|
||||
|
||||
|
||||
switch (label->getAlign()) {
|
||||
case GUIHelpers::eAlign::LEFT:
|
||||
sets.pos = { 10, 196 };
|
||||
sets.center = { 74, 200 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::CENTER:
|
||||
sets.pos = { 128, 196 };
|
||||
sets.center = { 200, 200 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::RIGHT:
|
||||
sets.pos = { 246, 196 };
|
||||
sets.center = { 318, 200 };
|
||||
break;
|
||||
}
|
||||
|
||||
sets.size = { 144, 8 };
|
||||
|
||||
cWindowTest("Label 'Hello world Two'", u, label, sets);
|
||||
|
||||
label = (GUIEngine::cLabel*)layout->getChildren()[2];
|
||||
|
||||
|
||||
/*sets.pos = { 132, 214 };*/
|
||||
switch (label->getAlign()) {
|
||||
case GUIHelpers::eAlign::LEFT:
|
||||
sets.pos = { 10, 214 };
|
||||
sets.center = { 78, 218 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::CENTER:
|
||||
sets.pos = { 136, 178 };
|
||||
sets.center = { 200, 218 };
|
||||
break;
|
||||
case GUIHelpers::eAlign::RIGHT:
|
||||
sets.pos = { 254, 214 };
|
||||
sets.center = { 322, 218 };
|
||||
break;
|
||||
}
|
||||
sets.size = { 136, 8 };
|
||||
|
||||
cWindowTest("Label 'Hello world Three'", u, label, sets);
|
||||
|
||||
u.report();
|
||||
|
||||
GUIEngine::cGUI::Inst().Delete();
|
||||
}
|
||||
|
||||
void LoadFile( const cString& filename, const bool show /*= false*/ )
|
||||
{
|
||||
GUIEngine::cGUI::Inst().Delete();
|
||||
GUIEngine::cGUI::Inst().Initialize(filename, "xml/");
|
||||
printf(cString("\nUsing " + filename + " file.\n").c_str());
|
||||
|
||||
if (show == true)
|
||||
GUIEngine::cGUI::Inst().Display();
|
||||
}
|
||||
|
||||
void cWindowTest(const cString& msg, UTest& u, GUIEngine::cWindow* win, const Settings sets)
|
||||
{
|
||||
cWindowTest(msg, u, win, sets.pos, sets.size, sets.pad, sets.center);
|
||||
}
|
||||
|
||||
void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos,
|
||||
const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center)
|
||||
{
|
||||
u.test(msg + " Position", win->getPosition() == pos);
|
||||
|
||||
u.test(msg + " Size", win->getSize(false) == size);
|
||||
|
||||
u.test(msg + " Padding", win->getPadding() == pad);
|
||||
|
||||
u.test(msg + " Center", win->getCenter() == center);
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef _CGFX_HPP_
|
||||
#define _CGFX_HPP_
|
||||
|
||||
/*** SDL Header Files ***/
|
||||
#include <SDL.h>
|
||||
|
||||
/*** DLL Header File ***/
|
||||
#include "dllExport.h"
|
||||
|
||||
/*** Custom Header Files ***/
|
||||
#include "../UtilityEngine/cString.hpp"
|
||||
|
||||
using UtilityEngine::cString;
|
||||
|
||||
namespace EXPORT_FROM_MYDLL FXEngine {
|
||||
/* Singleton */
|
||||
class cGFX
|
||||
{
|
||||
private:
|
||||
cGFX();
|
||||
~cGFX();
|
||||
|
||||
public:
|
||||
static cGFX& Inst();
|
||||
static void Delete();
|
||||
|
||||
void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour ) const;
|
||||
void StringDefault( const cString& text, const SDL_Rect& pos, const SDL_Colour& colour, SDL_Texture* texture ) const;
|
||||
|
||||
void Box( const SDL_Rect& rect, const SDL_Colour& colour ) const;
|
||||
void Box( const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const;
|
||||
|
||||
void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour ) const;
|
||||
void RoundedBox( const SDL_Rect& rect, const unsigned long int rad, const SDL_Colour& colour, SDL_Texture* texture ) const;
|
||||
|
||||
void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour ) const;
|
||||
void Pixel( const unsigned long int x, const unsigned long int y, const SDL_Colour& colour, SDL_Texture* texture ) const;
|
||||
|
||||
void Rectangle( const SDL_Rect& rect, const SDL_Colour& colour ) const;
|
||||
void Rectangle (const SDL_Rect& rect, const SDL_Colour& colour, SDL_Texture* texture ) const;
|
||||
|
||||
private:
|
||||
static cGFX* sp_inst;// = nullptr
|
||||
};/// END CLASS DEFINITION cGFX
|
||||
}/// END NAMESPACE DEFINITION FXEngine
|
||||
#endif/// END IFNDEF _CGFX_HPP_
|
||||
Reference in New Issue
Block a user