cButton Texture Generate
This commit is contained in:
@@ -19,11 +19,12 @@ namespace GUIHelpers {
|
|||||||
typedef struct SDL_Rect Area;
|
typedef struct SDL_Rect Area;
|
||||||
|
|
||||||
static const RGBA WHITE = { 255, 255, 255, 255 };
|
static const RGBA WHITE = { 255, 255, 255, 255 };
|
||||||
|
static const RGBA GRAY = { 127, 127, 127, 255 };
|
||||||
static const RGBA BLACK = { 0, 0, 0, 255 };
|
static const RGBA BLACK = { 0, 0, 0, 255 };
|
||||||
|
|
||||||
static const RGBA RED = { 255, 0, 0, 255 };
|
static const RGBA RED = { 255, 0, 0, 255 };
|
||||||
|
|
||||||
static const RGBA ORANGE = { 255, 128, 0, 255 };
|
static const RGBA ORANGE = { 255, 127, 0, 255 };
|
||||||
static const RGBA YELLOW = { 255, 255, 0, 255 };
|
static const RGBA YELLOW = { 255, 255, 0, 255 };
|
||||||
|
|
||||||
static const RGBA GREEN = { 0, 255, 0, 255 };
|
static const RGBA GREEN = { 0, 255, 0, 255 };
|
||||||
@@ -32,9 +33,9 @@ namespace GUIHelpers {
|
|||||||
|
|
||||||
static const RGBA BLUE = { 0, 0, 255, 255 };
|
static const RGBA BLUE = { 0, 0, 255, 255 };
|
||||||
|
|
||||||
static const RGBA VIOLET = { 128, 0, 255, 255 };
|
static const RGBA VIOLET = { 127, 0, 255, 255 };
|
||||||
static const RGBA MAGENTA = { 255, 0, 255, 255 };
|
static const RGBA MAGENTA = { 255, 0, 255, 255 };
|
||||||
static const RGBA ROSE = { 255, 0, 128, 255 };
|
static const RGBA ROSE = { 255, 0, 127, 255 };
|
||||||
|
|
||||||
static const RGBA DEFAULT = WHITE;
|
static const RGBA DEFAULT = WHITE;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "../../UtilityEngine/cUtility.hpp"
|
#include "../../UtilityEngine/cUtility.hpp"
|
||||||
|
|
||||||
#include "../cGUI.hpp"
|
#include "../cGUI.hpp"
|
||||||
#include "../cLayout.hpp"
|
|
||||||
|
|
||||||
using GUIHelpers::cXMLoader;
|
using GUIHelpers::cXMLoader;
|
||||||
|
|
||||||
@@ -66,6 +65,8 @@ void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* p
|
|||||||
tmp = LabelBuild(element, parent);
|
tmp = LabelBuild(element, parent);
|
||||||
if (name == "sizer")
|
if (name == "sizer")
|
||||||
tmp = SizerBuild(element, parent);
|
tmp = SizerBuild(element, parent);
|
||||||
|
if (name == "button")
|
||||||
|
tmp = ButtonBuild(element, parent);
|
||||||
|
|
||||||
tinyxml2::XMLElement* child = element.FirstChildElement();
|
tinyxml2::XMLElement* child = element.FirstChildElement();
|
||||||
if (child != nullptr)
|
if (child != nullptr)
|
||||||
@@ -93,7 +94,7 @@ const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, cons
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cXMLoader::Include(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const
|
void cXMLoader::Include( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const
|
||||||
{
|
{
|
||||||
cString dir = getDir(element);
|
cString dir = getDir(element);
|
||||||
cString filename = getFileName(element);
|
cString filename = getFileName(element);
|
||||||
@@ -133,7 +134,7 @@ void cXMLoader::Debug(const tinyxml2::XMLElement& element)
|
|||||||
GUIEngine::cGUI::Inst().setDebugLevel(debug);
|
GUIEngine::cGUI::Inst().setDebugLevel(debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIEngine::cPanel* cXMLoader::PanelBuild(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const
|
GUIEngine::cPanel* cXMLoader::PanelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const
|
||||||
{
|
{
|
||||||
signed long int id = getID(element);
|
signed long int id = getID(element);
|
||||||
GUIHelpers::eOrientation orientation = getOrientation(element);
|
GUIHelpers::eOrientation orientation = getOrientation(element);
|
||||||
@@ -193,7 +194,7 @@ GUIEngine::cLabel* cXMLoader::LabelBuild( const tinyxml2::XMLElement& element, G
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUIEngine::cSizer* cXMLoader::SizerBuild(const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent) const
|
GUIEngine::cSizer* cXMLoader::SizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const
|
||||||
{
|
{
|
||||||
signed long int id = getID(element);
|
signed long int id = getID(element);
|
||||||
//GUIHelpers::eOrientation orientation = getOrientation(element);
|
//GUIHelpers::eOrientation orientation = getOrientation(element);
|
||||||
@@ -210,12 +211,30 @@ GUIEngine::cSizer* cXMLoader::SizerBuild(const tinyxml2::XMLElement& element, GU
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::getDir(const tinyxml2::XMLElement& element) const
|
GUIEngine::cButton * cXMLoader::ButtonBuild( const tinyxml2::XMLElement & element, GUIEngine::cWindow* parent ) const
|
||||||
|
{
|
||||||
|
signed long int id = getID(element);
|
||||||
|
GUIHelpers::eOrientation orientation = getOrientation(element);
|
||||||
|
GUIHelpers::eAlign align = getAlign(element);
|
||||||
|
GUIHelpers::eLayout layout = getLayout(element);
|
||||||
|
GUIHelpers::Position pos = getPosition(element);
|
||||||
|
GUIHelpers::Size size = getSize(element);
|
||||||
|
GUIHelpers::Padding pad = getPadding(element);
|
||||||
|
|
||||||
|
GUIEngine::cButton* rtn = new GUIEngine::cButton(parent, id, align, layout, pos, size, pad);
|
||||||
|
|
||||||
|
if (parent == nullptr)
|
||||||
|
GUIEngine::cGUI::Inst().AddObject(rtn);
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cString cXMLoader::getDir( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
return GetAttribute(element, "dir");
|
return GetAttribute(element, "dir");
|
||||||
}
|
}
|
||||||
|
|
||||||
const cString cXMLoader::getFileName(const tinyxml2::XMLElement& element) const
|
const cString cXMLoader::getFileName( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
return GetAttribute(element, "filename");
|
return GetAttribute(element, "filename");
|
||||||
}
|
}
|
||||||
@@ -240,7 +259,7 @@ const unsigned long int cXMLoader::getDebug( const tinyxml2::XMLElement& element
|
|||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool cXMLoader::getDebugXML(const tinyxml2::XMLElement& element) const
|
const bool cXMLoader::getDebugXML( const tinyxml2::XMLElement& element ) const
|
||||||
{
|
{
|
||||||
bool rtn = false;
|
bool rtn = false;
|
||||||
cString str = GetAttribute(element, "xml").lower();
|
cString str = GetAttribute(element, "xml").lower();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "../cLayout.hpp"
|
#include "../cLayout.hpp"
|
||||||
#include "../cLabel.hpp"
|
#include "../cLabel.hpp"
|
||||||
#include "../cSizer.hpp"
|
#include "../cSizer.hpp"
|
||||||
|
#include "../cButton.hpp"
|
||||||
|
|
||||||
#include "../../UtilityEngine/cString.hpp"
|
#include "../../UtilityEngine/cString.hpp"
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ namespace GUIHelpers {
|
|||||||
GUIEngine::cLayout* LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
GUIEngine::cLayout* LayoutBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
GUIEngine::cLabel* LabelBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
GUIEngine::cSizer* SizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
GUIEngine::cSizer* SizerBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
|
GUIEngine::cButton* ButtonBuild( const tinyxml2::XMLElement& element, GUIEngine::cWindow* parent ) const;
|
||||||
|
|
||||||
const cString getDir( const tinyxml2::XMLElement& element ) const;
|
const cString getDir( const tinyxml2::XMLElement& element ) const;
|
||||||
const cString getFileName( const tinyxml2::XMLElement& element ) const;
|
const cString getFileName( const tinyxml2::XMLElement& element ) const;
|
||||||
|
|||||||
@@ -18,15 +18,14 @@ cButton::cButton()
|
|||||||
cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/,
|
cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/,
|
||||||
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/,
|
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/,
|
||||||
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
||||||
: cWindow(parent, id, sORIENTATION, align, layout, pos, size, padding, name)
|
|
||||||
{
|
{
|
||||||
//Create(parent, id, align, layout, pos, size, padding, name, image);
|
Create(parent, id, align, layout, pos, size, padding, name, image);
|
||||||
mp_texture = nullptr;
|
// mp_texture = nullptr;
|
||||||
mp_texturePress = nullptr;
|
// mp_texturePress = nullptr;
|
||||||
|
//
|
||||||
mpp_image = image;
|
// mpp_image = image;
|
||||||
|
//
|
||||||
GenerateImage();
|
// GenerateImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ cButton::~cButton()
|
/*virtual*/ cButton::~cButton()
|
||||||
@@ -44,13 +43,22 @@ void cButton::Create( cWindow* parent, const signed int id, const GUIHelpers::eA
|
|||||||
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding /*= sPADDING*/,
|
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding /*= sPADDING*/,
|
||||||
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
|
||||||
{
|
{
|
||||||
cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name);
|
cLayout::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name);
|
||||||
|
|
||||||
mp_texture = nullptr;
|
mp_texture = nullptr;
|
||||||
mp_texturePress = nullptr;
|
mp_texturePress = nullptr;
|
||||||
|
|
||||||
mpp_image = image;
|
mpp_image = image;
|
||||||
|
}
|
||||||
|
|
||||||
|
void cButton::Display()
|
||||||
|
{
|
||||||
GenerateImage();
|
GenerateImage();
|
||||||
|
|
||||||
|
m_sprite.setPosition(cWindow::getPosition());
|
||||||
|
m_sprite.Draw();
|
||||||
|
m_sprite.SaveImage("test.bmp", "xml/");
|
||||||
|
cWindow::Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ void cButton::Press()
|
/*virtual*/ void cButton::Press()
|
||||||
@@ -58,113 +66,47 @@ void cButton::Create( cWindow* parent, const signed int id, const GUIHelpers::eA
|
|||||||
mp_texture->SaveImage("hello.bmp");
|
mp_texture->SaveImage("hello.bmp");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void cButton::setLabel( const cString& label )
|
/*virtual*/ void cButton::OnLButtonUp()
|
||||||
// {
|
{
|
||||||
// if (label.size() > 0) {
|
|
||||||
// if (mp_label == nullptr)
|
}
|
||||||
// mp_label = new TextTypeEngine::cText(label);
|
|
||||||
// else
|
|
||||||
// mp_label->setText(label);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// Gets
|
/// Gets
|
||||||
// const cString cButton::getLabel() const
|
|
||||||
// {
|
|
||||||
// cString rtn = "";
|
|
||||||
// if (mp_label != nullptr)
|
|
||||||
// rtn = mp_label->getText();
|
|
||||||
// return rtn;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::eType cButton::getType() const
|
/*virtual*/ const GUIHelpers::eType cButton::getType() const
|
||||||
{
|
{
|
||||||
return GUIHelpers::eType::CBUTTON;
|
return GUIHelpers::eType::CBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GUIHelpers::RGBA& cButton::getDebugColour() const
|
||||||
|
{
|
||||||
|
return GUIHelpers::ORANGE;
|
||||||
|
}
|
||||||
|
|
||||||
/// private
|
/// private
|
||||||
void cButton::GenerateImage()
|
void cButton::GenerateImage()
|
||||||
{
|
{
|
||||||
|
m_sprite.setImageArea(this->getSize(false));
|
||||||
GenerateTexture();
|
GenerateTexture();
|
||||||
//GenerateTexture( mp_texturePress );
|
|
||||||
|
|
||||||
this->setImage((VideoEngine::cImage**)(&mp_texture));
|
m_sprite.setImage((VideoEngine::cImage**)(&mp_texture));
|
||||||
|
|
||||||
this->setImageArea(mp_texture->getWH());
|
m_sprite.setImageArea(mp_texture->getWH());
|
||||||
}
|
}
|
||||||
|
|
||||||
void cButton::GenerateTexture()
|
void cButton::GenerateTexture()
|
||||||
{
|
{
|
||||||
// SDL_Rect t = { 0, 0, 0, 0 };
|
GUIHelpers::RGBA colour = { 100, 100, 100, 255 };
|
||||||
// if (mp_label != nullptr)
|
|
||||||
// t = mp_label->getWH();
|
|
||||||
// SDL_Rect centerText = { 0, 0, 0, 0 };
|
|
||||||
// SDL_Rect centerButton = { 0, 0, 0, 0 };
|
|
||||||
// SDL_Rect dim = this->getImageArea();
|
|
||||||
//
|
|
||||||
// GUIHelpers::Padding TXTPADDING = PADDING;
|
|
||||||
// ///Find the min padding around the text.
|
|
||||||
// if (dim.w < (t.w + TXTPADDING.x + TXTPADDING.w) )
|
|
||||||
// dim.w += (t.w + TXTPADDING.x + TXTPADDING.w);
|
|
||||||
//
|
|
||||||
// if (dim.h < (t.h + TXTPADDING.y + TXTPADDING.z) )
|
|
||||||
// dim.h += (t.h + TXTPADDING.y + TXTPADDING.z);
|
|
||||||
//
|
|
||||||
// ///Find the center of the button
|
|
||||||
// centerButton.x = dim.w / 2;
|
|
||||||
// centerButton.y = dim.h / 2;
|
|
||||||
//
|
|
||||||
// ///Find the center of the text
|
|
||||||
// centerText.x = t.w / 2;
|
|
||||||
// centerText.y = t.h / 2;
|
|
||||||
//
|
|
||||||
// if (centerText.x < centerButton.x)
|
|
||||||
// t.x = centerButton.x - centerText.x;
|
|
||||||
//
|
|
||||||
// if (centerText.y < centerButton.y)
|
|
||||||
// t.y = centerButton.y - centerText.y;
|
|
||||||
//
|
|
||||||
// SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET );
|
|
||||||
//
|
|
||||||
// GUIHelpers::RBGA colour = { 100, 100, 100, 255 };
|
|
||||||
//
|
|
||||||
// FXEngine::cGFX::Inst().RoundedRectangle(dim, 4, colour, temptext);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// if (mp_label != nullptr)
|
|
||||||
// VideoEngine::cRenderer::Inst().RenderToTexture(mp_label->getImage(), nullptr, temptext, &t);
|
|
||||||
|
|
||||||
|
GUIHelpers::Size dim = this->getSize(false);
|
||||||
|
|
||||||
//cRenderer::Inst().Render(temptext, nullptr, nullptr);
|
SDL_Rect rect = { 0, 0, dim.x + 1, dim.y + 1 };
|
||||||
|
|
||||||
//cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr);
|
SDL_Texture* tmptexture = VideoEngine::cRenderer::Inst().NewTexture(dim.x, dim.y);
|
||||||
|
SDL_Texture* tmptexture2 = VideoEngine::cRenderer::Inst().NewTexture(dim.x, dim.y);
|
||||||
|
|
||||||
/*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(),
|
FXEngine::cGFX::Inst().RoundedBox(rect, 20, GUIHelpers::GRAY, tmptexture);
|
||||||
0, 0, 0, 0);
|
FXEngine::cGFX::Inst().RoundedBox(rect, 20, colour, tmptexture2);
|
||||||
|
|
||||||
SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0));
|
mp_texture = new VideoEngine::cImage(tmptexture);
|
||||||
|
mp_texturePress = new VideoEngine::cImage(tmptexture2);
|
||||||
/*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0)
|
|
||||||
cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/
|
|
||||||
|
|
||||||
|
|
||||||
/*if (text != nullptr) {
|
|
||||||
SDL_Rect srcrect, dstrect = dimensions;
|
|
||||||
cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect);
|
|
||||||
}
|
|
||||||
|
|
||||||
this->setImage(temptext);
|
|
||||||
this->setTransparent();*/
|
|
||||||
|
|
||||||
// delete mp_texture;
|
|
||||||
// mp_texture = nullptr;
|
|
||||||
//
|
|
||||||
// mp_texture = new VideoEngine::cImage(temptext);
|
|
||||||
//
|
|
||||||
// GUIHelpers::Size size = { 0, 0 };
|
|
||||||
// mp_texture->getWH((unsigned long&)size.x, (unsigned long&)size.y);
|
|
||||||
// cWindow::setSize(size);
|
|
||||||
// image->setImage(temptext);
|
|
||||||
//image->setImage(temptext);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,18 +13,18 @@
|
|||||||
#include "../VideoEngine/cImage.hpp"
|
#include "../VideoEngine/cImage.hpp"
|
||||||
#include "../MathEngine/iVector/iVector2.hpp"
|
#include "../MathEngine/iVector/iVector2.hpp"
|
||||||
|
|
||||||
#include "cPanel.hpp"
|
|
||||||
|
|
||||||
/*** DLL Header File ***/
|
/*** DLL Header File ***/
|
||||||
#include "dllExport.h"
|
#include "dllExport.h"
|
||||||
|
|
||||||
/*** Custom Header Files ***/
|
/*** Custom Header Files ***/
|
||||||
|
#include "cLayout.hpp"
|
||||||
#include "../UtilityEngine/cString.hpp"
|
#include "../UtilityEngine/cString.hpp"
|
||||||
|
#include "../EventEngine/cEvent.hpp"
|
||||||
|
|
||||||
using UtilityEngine::cString;
|
using UtilityEngine::cString;
|
||||||
|
|
||||||
namespace GUIEngine {
|
namespace GUIEngine {
|
||||||
class EXPORT_FROM_MYDLL cButton : public cWindow, public VideoEngine::cSprite
|
class EXPORT_FROM_MYDLL cButton : public cLayout, public EventEngine::cEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const cString sNAME; /*= "button";*/
|
static const cString sNAME; /*= "button";*/
|
||||||
@@ -40,12 +40,17 @@ namespace GUIEngine {
|
|||||||
const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING,
|
const GUIHelpers::Position& pos = sPOSITION, const GUIHelpers::Size& size = sSIZE, const GUIHelpers::Padding& padding = sPADDING,
|
||||||
const cString& name = sNAME, VideoEngine::cImage** image = nullptr );
|
const cString& name = sNAME, VideoEngine::cImage** image = nullptr );
|
||||||
|
|
||||||
|
virtual void Display();
|
||||||
|
|
||||||
virtual void Press();
|
virtual void Press();
|
||||||
|
|
||||||
|
virtual void OnLButtonUp();
|
||||||
|
|
||||||
/// Sets
|
/// Sets
|
||||||
|
|
||||||
/// Gets
|
/// Gets
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
|
virtual const GUIHelpers::RGBA& getDebugColour() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateLabel();
|
void CreateLabel();
|
||||||
@@ -54,10 +59,12 @@ namespace GUIEngine {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
/// Variables
|
/// Variables
|
||||||
|
VideoEngine::cSprite m_sprite;
|
||||||
|
|
||||||
VideoEngine::cImage* mp_texture;/// = nullptr
|
VideoEngine::cImage* mp_texture;/// = nullptr
|
||||||
VideoEngine::cImage* mp_texturePress;/// = nullptr
|
VideoEngine::cImage* mp_texturePress;/// = nullptr
|
||||||
|
|
||||||
//Pointer to the image that will be displayed on the button.
|
/// Pointer to the image that will be displayed on the button.
|
||||||
VideoEngine::cImage** mpp_image;/// = nullptr
|
VideoEngine::cImage** mpp_image;/// = nullptr
|
||||||
};/// END CLASS DEFINITION cButton
|
};/// END CLASS DEFINITION cButton
|
||||||
}/// END NAMESPACE DEFINITION GUIEngine
|
}/// END NAMESPACE DEFINITION GUIEngine
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ cGUI::~cGUI()
|
|||||||
m_children.clear();
|
m_children.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//public:
|
///public:
|
||||||
///Functions
|
///Functions
|
||||||
/*static*/ cGUI& cGUI::Inst()
|
/*static*/ cGUI& cGUI::Inst()
|
||||||
{
|
{
|
||||||
@@ -104,7 +104,6 @@ std::vector<GUIEngine::cWindow*>& cGUI::GetObjects()
|
|||||||
|
|
||||||
void cGUI::Display()
|
void cGUI::Display()
|
||||||
{
|
{
|
||||||
//m_obj->Display();
|
|
||||||
std::vector<GUIEngine::cWindow*>::iterator it;
|
std::vector<GUIEngine::cWindow*>::iterator it;
|
||||||
|
|
||||||
for (it = m_children.begin(); it < m_children.end(); it++) {
|
for (it = m_children.begin(); it < m_children.end(); it++) {
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ void cLabel::Create( cWindow* parent, const signed int id, const cString& label
|
|||||||
cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name);
|
cWindow::Create(parent, id, sORIENTATION, align, layout, pos, size, padding, name);
|
||||||
if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT)
|
if (layout == GUIHelpers::eLayout::DEFAULT_LAYOUT)
|
||||||
setLayout(sLAYOUT);
|
setLayout(sLAYOUT);
|
||||||
if (this->getParent() != nullptr) {
|
|
||||||
this->getParent()->AddChild(this);
|
|
||||||
}
|
|
||||||
setText(label);
|
setText(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,11 +45,6 @@ void cLabel::GenerateTexture()
|
|||||||
m_sprite.setImage((VideoEngine::cImage**)(&mp_text));
|
m_sprite.setImage((VideoEngine::cImage**)(&mp_text));
|
||||||
|
|
||||||
m_sprite.setImageArea(mp_text->getWH());
|
m_sprite.setImageArea(mp_text->getWH());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//this->setTransparent();
|
|
||||||
//this->setPosition()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets
|
/// Sets
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ cLayout::cLayout( cWindow* parent, const signed int id, const GUIHelpers::eOrien
|
|||||||
if (ori == GUIHelpers::eOrientation::DEFAULT_ORIENTATION)
|
if (ori == GUIHelpers::eOrientation::DEFAULT_ORIENTATION)
|
||||||
ori = sORIENTATION;
|
ori = sORIENTATION;
|
||||||
cWindow::Create(parent, id, ori, align, layout, pos, size, padding, name);
|
cWindow::Create(parent, id, ori, align, layout, pos, size, padding, name);
|
||||||
if (this->getParent() != nullptr) {
|
|
||||||
this->getParent()->AddChild(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ void cLayout::Display()
|
/*virtual*/ void cLayout::Display()
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ void cSizer::Create( cWindow* parent, const signed int id, const GUIHelpers::eAl
|
|||||||
if (size.x < 0)
|
if (size.x < 0)
|
||||||
sz = sSIZE;
|
sz = sSIZE;
|
||||||
cWindow::Create(parent, id, sORIENTATION, align, layout, pos, sz, padding, name);
|
cWindow::Create(parent, id, sORIENTATION, align, layout, pos, sz, padding, name);
|
||||||
if (this->getParent() != nullptr) {
|
|
||||||
this->getParent()->AddChild(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ const GUIHelpers::eType cSizer::getType() const
|
/*virtual*/ const GUIHelpers::eType cSizer::getType() const
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ cWindow::cWindow( cWindow* parent /*= nullptr*/, const signed int id /*= -1*/, c
|
|||||||
setSize(size);
|
setSize(size);
|
||||||
setPadding(padding);
|
setPadding(padding);
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
||||||
|
if (this->getParent() != nullptr) {
|
||||||
|
this->getParent()->AddChild(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*virtual*/ void cWindow::Display() {
|
/*virtual*/ void cWindow::Display() {
|
||||||
@@ -569,6 +573,9 @@ void cWindow::DebugDisplay() const
|
|||||||
typePos = { -10, -10, 0, 0 };
|
typePos = { -10, -10, 0, 0 };
|
||||||
type = "Label";
|
type = "Label";
|
||||||
break;
|
break;
|
||||||
|
case GUIHelpers::eType::CBUTTON:
|
||||||
|
type = "Button";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
type = "";
|
type = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,8 +93,6 @@ namespace GUIEngine {
|
|||||||
|
|
||||||
virtual const GUIHelpers::eType getType() const;
|
virtual const GUIHelpers::eType getType() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual void Resize();
|
virtual void Resize();
|
||||||
virtual void RebuildLayout( const GUIHelpers::eLayout& layout );
|
virtual void RebuildLayout( const GUIHelpers::eLayout& layout );
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ cImage::cImage( const bool transparent /*= false*/, const unsigned char red /*=
|
|||||||
m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel), m_isSurface(isSurface)
|
m_transRed(red), m_transBlue(blue), m_transGreen(green), m_transLevel(translevel), m_isSurface(isSurface)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
cImage::cImage( SDL_Surface* surface )
|
cImage::cImage(SDL_Surface* surface)
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
||||||
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255), m_isSurface(true)
|
||||||
{
|
{
|
||||||
setImage(surface);
|
setImage(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
cImage::cImage( SDL_Texture* texture )
|
cImage::cImage(SDL_Texture* texture)
|
||||||
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
: mp_texture(nullptr), mp_surface(nullptr), m_transparent(false),
|
||||||
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255)
|
m_transRed(0), m_transBlue(0), m_transGreen(255), m_transLevel(255), m_isSurface(false)
|
||||||
{
|
{
|
||||||
setImage(texture);
|
setImage(texture);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
/*** GUIEngine ***/
|
/*** GUIEngine ***/
|
||||||
#include "../TrooperEngine/GUIEngine/cGUI.hpp"
|
#include "../TrooperEngine/GUIEngine/cGUI.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cWindow.hpp"
|
#include "../TrooperEngine/GUIEngine/cWindow.hpp"
|
||||||
|
#include "../TrooperEngine/GUIEngine/cPanel.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cLayout.hpp"
|
#include "../TrooperEngine/GUIEngine/cLayout.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cLabel.hpp"
|
#include "../TrooperEngine/GUIEngine/cLabel.hpp"
|
||||||
#include "../TrooperEngine/GUIEngine/cButton.hpp"
|
#include "../TrooperEngine/GUIEngine/cButton.hpp"
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#include "GUI.hpp"
|
||||||
|
|
||||||
|
GUI::GUI()
|
||||||
|
{}
|
||||||
|
|
||||||
|
GUI::~GUI()
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef __GUI__
|
||||||
|
#define __GUI__
|
||||||
|
|
||||||
|
#include "dllExport.h"
|
||||||
|
|
||||||
|
class GUI {
|
||||||
|
public:
|
||||||
|
GUI();
|
||||||
|
~GUI();
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /// __GUI__
|
||||||
@@ -26,44 +26,44 @@ void GUIXMLTest()
|
|||||||
// }
|
// }
|
||||||
// align = leftRight;
|
// align = leftRight;
|
||||||
// }
|
// }
|
||||||
|
GUIXMLDefaultTest();
|
||||||
GUIXMLSizerTest();
|
//GUIXMLSizerTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIXMLDefaultTest()
|
void GUIXMLDefaultTest()
|
||||||
{
|
{
|
||||||
UTest u("GUI XML Default");
|
UTest u("GUI XML Default");
|
||||||
|
|
||||||
LoadFile("GUIXMLDefaultTest.xml");
|
LoadFile("GUIXMLDefaultTest.xml", true);
|
||||||
|
|
||||||
std::vector<GUIEngine::cWindow*> objects = GUIEngine::cGUI::Inst().GetObjects();
|
// std::vector<GUIEngine::cWindow*> objects = GUIEngine::cGUI::Inst().GetObjects();
|
||||||
|
//
|
||||||
GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0];
|
// GUIEngine::cPanel* panel = (GUIEngine::cPanel*)objects[0];
|
||||||
|
//
|
||||||
Settings sets;
|
// Settings sets;
|
||||||
sets.pos = { 0, 0 };
|
// sets.pos = { 0, 0 };
|
||||||
sets.size = { 200, 200 };
|
// sets.size = { 200, 200 };
|
||||||
sets.pad = { 0, 0, 0, 0 };
|
// sets.pad = { 0, 0, 0, 0 };
|
||||||
sets.center = { 100, 100 };
|
// sets.center = { 100, 100 };
|
||||||
|
//
|
||||||
cWindowTest("Panel", u, panel, sets);
|
// cWindowTest("Panel", u, panel, sets);
|
||||||
|
//
|
||||||
GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0];
|
// GUIEngine::cLayout* layout = (GUIEngine::cLayout*)panel->getChildren()[0];
|
||||||
|
//
|
||||||
sets.pos = { 5, 5 };
|
// sets.pos = { 5, 5 };
|
||||||
sets.size = { 190, 190 };
|
// sets.size = { 190, 190 };
|
||||||
sets.pad = { 5, 5, 5, 5 };
|
// sets.pad = { 5, 5, 5, 5 };
|
||||||
|
//
|
||||||
|
//
|
||||||
cWindowTest("Layout", u, layout, sets);
|
// cWindowTest("Layout", u, layout, sets);
|
||||||
|
//
|
||||||
GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0];
|
// GUIEngine::cLabel* label = (GUIEngine::cLabel*)layout->getChildren()[0];
|
||||||
|
//
|
||||||
|
//
|
||||||
sets.pos = { 56, 96 };
|
// sets.pos = { 56, 96 };
|
||||||
sets.size = { 88, 8 };
|
// sets.size = { 88, 8 };
|
||||||
|
//
|
||||||
cWindowTest("Label", u, label, sets);
|
// cWindowTest("Label", u, label, sets);
|
||||||
|
|
||||||
u.report();
|
u.report();
|
||||||
|
|
||||||
|
|||||||
@@ -146,6 +146,7 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="EventEngineTest\EventEngineTest.cpp" />
|
<ClCompile Include="EventEngineTest\EventEngineTest.cpp" />
|
||||||
|
<ClCompile Include="GUI.cpp" />
|
||||||
<ClCompile Include="GUIEngineTest\GUIXMLTest.cpp" />
|
<ClCompile Include="GUIEngineTest\GUIXMLTest.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="MathEngineTest\CollisionTest.cpp" />
|
<ClCompile Include="MathEngineTest\CollisionTest.cpp" />
|
||||||
@@ -160,6 +161,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="EventEngineTest\EventEngineTest.hpp" />
|
<ClInclude Include="EventEngineTest\EventEngineTest.hpp" />
|
||||||
|
<ClInclude Include="GUI.hpp" />
|
||||||
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
|
||||||
<ClInclude Include="MathEngineTest\CollisionTest.hpp" />
|
<ClInclude Include="MathEngineTest\CollisionTest.hpp" />
|
||||||
<ClInclude Include="MathEngineTest\MathEngineTest.hpp" />
|
<ClInclude Include="MathEngineTest\MathEngineTest.hpp" />
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<ClInclude Include="MathEngineTest\MathEngineTest.hpp">
|
<ClInclude Include="MathEngineTest\MathEngineTest.hpp">
|
||||||
<Filter>MathEngineTest</Filter>
|
<Filter>MathEngineTest</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="GUI.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="UTest\UTest.cpp">
|
<ClCompile Include="UTest\UTest.cpp">
|
||||||
@@ -93,6 +94,7 @@
|
|||||||
<ClCompile Include="MathEngineTest\MathEngineTest.cpp">
|
<ClCompile Include="MathEngineTest\MathEngineTest.cpp">
|
||||||
<Filter>MathEngineTest</Filter>
|
<Filter>MathEngineTest</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="GUI.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Xml Include="xml\GUI.xml">
|
<Xml Include="xml\GUI.xml">
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
class UTest {
|
class UTest {
|
||||||
private:
|
private:
|
||||||
UTest( UTest & ); // no copy constructor
|
UTest( UTest & ); /// no copy constructor
|
||||||
UTest operator = ( UTest & ); // no assignment operator
|
UTest operator = ( UTest & ); /// no assignment operator
|
||||||
UTest(){}
|
UTest(){}
|
||||||
public:
|
public:
|
||||||
static const char* version() { return __UTest_VERSION; }
|
static const char* version() { return __UTest_VERSION; }
|
||||||
@@ -27,8 +27,8 @@ private:
|
|||||||
static const char* sp_pstr; /*= "pass";*/
|
static const char* sp_pstr; /*= "pass";*/
|
||||||
static const char* sp_fstr; /*= "fail";*/
|
static const char* sp_fstr; /*= "fail";*/
|
||||||
|
|
||||||
static unsigned long int s_pass; //= 0
|
static unsigned long int s_pass; ///= 0
|
||||||
static unsigned long int s_fail; //= 0
|
static unsigned long int s_fail; ///= 0
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __UTEST__
|
#endif /// __UTEST__
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
MathEngineTest();
|
MathEngineTest();
|
||||||
|
|
||||||
//GUIXMLTest();
|
GUIXMLTest();
|
||||||
|
SDL_Rect rec = { 0, 0, 100, 20 };
|
||||||
|
|
||||||
//ImageTest();
|
//ImageTest();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Panel size="400,400">
|
<Panel size="400,400">
|
||||||
<debug/>
|
<debug />
|
||||||
<Layout>
|
<Layout>
|
||||||
<Label align="left">Hello world Left</Label>
|
<Label align="left">Hello world Left</Label>
|
||||||
<Label align="center">Hello world Center</Label>
|
<Label align="center">Hello world Center</Label>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Panel size="200,200">
|
<Panel size="200,200">
|
||||||
<debug/>
|
<debug />
|
||||||
<Layout>
|
<Layout>
|
||||||
<Label>Hello world</Label>
|
<Label>Hello world</Label>
|
||||||
<Include dir ="xml/" filename="include.xml"/>
|
<Button size="100,20" />
|
||||||
</Layout>
|
</Layout>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Panel position="20, 20" size="200,200">
|
<Panel position="20, 20" size="200,200">
|
||||||
<debug/>
|
<debug />
|
||||||
<Layout position="100, 1100">
|
<Layout position="100, 1100">
|
||||||
<Label position="100, 1002" text="Hello world" />
|
<Label position="100, 1002" text="Hello world" />
|
||||||
</Layout>
|
</Layout>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
Reference in New Issue
Block a user