basic drawing not compleate ...

This commit is contained in:
Edouard Dupin 2011-11-28 18:12:04 +01:00
parent 763ad9654f
commit 9458f41709
15 changed files with 653 additions and 69 deletions

View File

@ -103,7 +103,7 @@ int main(int argc, char *argv[])
ewol::SetFontFolder("Font");
ewol::SetDefaultFont("freefont/FreeMono", 14);
ewol::theme::LoadDefault("dataTest/exemple.eol");
ewol::theme::LoadDefault("dataTest/exemple.eol");
//ewol::theme::LoadDefault("dataTest/exemple.eol");
exit(0);
Plop * myWindowsExample = new Plop();

View File

@ -30,7 +30,7 @@
ewol::theme::EolBase::EolBase(void)
{
//EWOL_DEBUG("new...");
}
ewol::theme::EolBase::~EolBase(void)
@ -41,25 +41,5 @@ ewol::theme::EolBase::~EolBase(void)
void ewol::theme::EolBase::Parse(TiXmlNode * pNode)
{
m_name = pNode->ToElement()->Attribute("name");
EWOL_INFO("Group name=\"" << m_name << "\" " );
EWOL_INFO("Element Base .. Generic ... nothing to parse..." );
}
etk::String ewol::theme::EolBase::GetName(void)
{
return m_name;
}
void ewol::theme::EolBase::SetName(etk::String & newName)
{
m_name = newName;
}
bool ewol::theme::EolBase::HasName(etk::String & newName)
{
return m_name == newName;
}

View File

@ -39,13 +39,7 @@ namespace ewol {
public:
EolBase(void);
virtual ~EolBase(void);
void Parse(TiXmlNode * pNode);
etk::String GetName(void);
void SetName(etk::String & newName);
bool HasName(etk::String & newName);
private:
etk::String m_name;
virtual void Parse(TiXmlNode * pNode);
};
};
};

View File

@ -22,7 +22,57 @@
*******************************************************************************
*/
#include <ewol/theme/EolBaseLine.h>
#undef __class__
#define __class__ "ewol::theme::EolBaseLine"
ewol::theme::EolBaseLine::EolBaseLine(void)
{
//EWOL_DEBUG("new element Base : Line ...");
}
ewol::theme::EolBaseLine::~EolBaseLine(void)
{
}
void ewol::theme::EolBaseLine::Parse(TiXmlNode * pNode)
{
m_color = pNode->ToElement()->Attribute("color");
const char * tmp = pNode->ToElement()->Attribute("positionStart");
if (NULL == tmp) {
m_posStart.x=0;
m_posStart.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_posStart.x=xxx;
m_posStart.y=yyy;
}
tmp = pNode->ToElement()->Attribute("positionStop");
if (NULL == tmp) {
m_posStop.x=0;
m_posStop.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_posStop.x=xxx;
m_posStop.y=yyy;
}
tmp = pNode->ToElement()->Attribute("thickness");
if (NULL == tmp) {
m_thickness=0;
} else {
double th;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &th);
m_thickness=th;
}
EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"line\" : pos(" << m_posStart.x << "," << m_posStart.y << ") to pos(" << m_posStop.x << "," << m_posStop.y << ") thickness=" << m_thickness);
}

View File

@ -24,9 +24,34 @@
#include <ewol/theme/EolBase.h>
#include <ewol/theme/EolColor.h>
#ifndef __EWOL_THEME_EOL_BASE_LINE_H__
#define __EWOL_THEME_EOL_BASE_LINE_H__
namespace ewol {
namespace theme {
class EolBaseLine : public EolBase {
public:
EolBaseLine(void);
virtual ~EolBaseLine(void);
/*
<Line color="..."
positionStart="0.53;0.56"
positionStop="0.22;0.11"
thickness="0.05"
/>
*/
virtual void Parse(TiXmlNode * pNode);
private:
etk::String m_color;
coord2D_ts m_posStart;
coord2D_ts m_posStop;
etkFloat_t m_thickness;
};
};
};
#endif

View File

@ -22,7 +22,48 @@
*******************************************************************************
*/
#include <ewol/theme/EolBaseRect.h>
#undef __class__
#define __class__ "ewol::theme::EolBaseRect"
ewol::theme::EolBaseRect::EolBaseRect(void)
{
//EWOL_DEBUG("new element Base : Rectangle ...");
}
ewol::theme::EolBaseRect::~EolBaseRect(void)
{
}
void ewol::theme::EolBaseRect::Parse(TiXmlNode * pNode)
{
const char * tmp = pNode->ToElement()->Attribute("position");
if (NULL == tmp) {
m_position.x=0;
m_position.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_position.x=xxx;
m_position.y=yyy;
}
tmp = pNode->ToElement()->Attribute("size");
if (NULL == tmp) {
m_size.x=0;
m_size.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_size.x=xxx;
m_size.y=yyy;
}
m_color = pNode->ToElement()->Attribute("color");
EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"rect\" : pos(" << m_position.x << "," << m_position.y << ") size(" << m_size.x << "," << m_size.y << ") colorName=\"" << m_color << "\"");
}

View File

@ -24,9 +24,31 @@
#include <ewol/theme/EolBase.h>
#include <ewol/theme/EolColor.h>
#ifndef __EWOL_THEME_EOL_BASE_RECT_H__
#define __EWOL_THEME_EOL_BASE_RECT_H__
namespace ewol {
namespace theme {
class EolBaseRect : public EolBase {
public:
EolBaseRect(void);
virtual ~EolBaseRect(void);
/*
<rect color="..."
position="0.53;0.56"
size="0.22;0.11"
/>
*/
virtual void Parse(TiXmlNode * pNode);
private:
etk::String m_color;
coord2D_ts m_position;
coord2D_ts m_size;
};
};
};
#endif

View File

@ -81,9 +81,9 @@ void ewol::theme::EolColor::Parse(TiXmlNode * pNode)
}
}
if (NULL != color) {
EWOL_INFO("COLOR name=\"" << m_name << "\" \"" << color << "\" ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha );
EWOL_INFO("(l " << pNode->Row() << ") color name=\"" << m_name << "\" \"" << color << "\" ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha );
} else {
EWOL_INFO("COLOR name=\"" << m_name << "\" \"\"???? ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha );
EWOL_INFO("(l " << pNode->Row() << ") color name=\"" << m_name << "\" \"\"???? ==> red="<< m_color.red <<" green="<< m_color.green <<" blue="<< m_color.blue <<" alpha="<< m_color.alpha );
}
}

View File

@ -22,8 +22,266 @@
*******************************************************************************
*/
#include <ewol/theme/Theme.h>
#undef __class__
#define __class__ "ewol::theme::EolElement"
ewol::theme::EolElement::EolElement(void)
{
//EWOL_DEBUG("new...");
}
ewol::theme::EolElement::~EolElement(void)
{
RemoveAll();
}
void ewol::theme::EolElement::RemoveAll(void)
{
for(int32_t iii=0; iii<m_listColor.Size(); iii++) {
if (m_listColor[iii] != NULL) {
delete m_listColor[iii];
m_listColor[iii] = NULL;
}
}
m_listColor.Clear();
for(int32_t iii=0; iii<m_listGroup.Size(); iii++) {
if (m_listGroup[iii] != NULL) {
delete m_listGroup[iii];
m_listGroup[iii] = NULL;
}
}
m_listGroup.Clear();
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
if (m_listElement[iii] != NULL) {
delete m_listElement[iii];
m_listElement[iii] = NULL;
}
}
m_listElement.Clear();
}
void ewol::theme::EolElement::Parse(TiXmlNode * root)
{
// clean all internal elements ...
RemoveAll();
// get the name ...
m_name = root->ToElement()->Attribute("name");
const char * tmp = root->ToElement()->Attribute("ratio");
if (NULL == tmp) {
m_ratio=1.0;
} else {
double xxx;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &xxx);
m_ratio=xxx;
}
etk::String tmpString = root->ToElement()->Attribute("ClipX");
if (tmpString == "true") {
m_clipX = true;
} else {
m_clipX = false;
}
etk::String tmpString2 = root->ToElement()->Attribute("ClipY");
if (tmpString2 == "true") {
m_clipY = true;
} else {
m_clipY = false;
}
tmp = root->ToElement()->Attribute("internalElemStart");
if (NULL == tmp) {
m_internalElemStart.x=0;
m_internalElemStart.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_internalElemStart.x=xxx;
m_internalElemStart.y=yyy;
}
tmp = root->ToElement()->Attribute("internalElemStop");
if (NULL == tmp) {
m_internalElemStop.x=0;
m_internalElemStop.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_internalElemStop.x=xxx;
m_internalElemStop.y=yyy;
}
EWOL_INFO("(l " << root->Row() << ") ELEMENT name=\"" << m_name << "\" internalStart(" << m_internalElemStart.x << "," << m_internalElemStart.y << ") to internalStop(" << m_internalElemStop.x << "," << m_internalElemStop.y << ") ratio=" << m_ratio );
EWOL_INFO(" --------------------- START ---------------------");
for(TiXmlNode * pNode=root->FirstChild(); NULL!=pNode; pNode = pNode->NextSibling()) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
continue;
}
etk::String nodeValue = pNode->Value();
if (nodeValue == "group") {
//EWOL_INFO("Find group ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
// not added it
} else {
bool findASameName = false;
// check if existed ...
for (int32_t iii=0; iii < m_listGroup.Size(); iii++) {
if(NULL!=m_listGroup[iii]) {
if(m_listGroup[iii]->HasName(groupNameTmp) == true) {
findASameName = true;
EWOL_WARNING("(l " << pNode->Row() << ") Find a Group with the same Name : \"" << groupNameTmp <<"\"");
m_listGroup[iii]->Parse(pNode);
break;
}
}
}
if (findASameName == false) {
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Group : \"" << groupNameTmp <<"\"");
ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame();
if (NULL != myGroupTmp) {
myGroupTmp->Parse(pNode);
m_listGroup.PushBack(myGroupTmp);
} else {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
}
}
} else if (nodeValue == "frame") {
//EWOL_INFO("Find frame ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
// not added it
} else {
bool findASameName = false;
// check if existed ...
for (int32_t iii=0; iii < m_listElement.Size(); iii++) {
if(NULL!=m_listElement[iii]) {
if(m_listElement[iii]->HasName(groupNameTmp) == true) {
findASameName = true;
EWOL_WARNING("(l " << pNode->Row() << ") Find a Frame with the same Name : \"" << groupNameTmp <<"\"");
m_listGroup[iii]->Parse(pNode);
break;
}
}
}
if (findASameName == false) {
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Frame : \"" << groupNameTmp <<"\"");
ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame();
if (NULL != myGroupTmp) {
myGroupTmp->Parse(pNode);
m_listElement.PushBack(myGroupTmp);
} else {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
}
}
} else if (nodeValue == "color") {
etk::String colorNameTmp = pNode->ToElement()->Attribute("name");
if (colorNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Color with NO name ... (not parsed)");
// not added it
} else {
bool findASameName = false;
// check if existed ...
for (int32_t iii=0; iii < m_listColor.Size(); iii++) {
if(NULL!=m_listColor[iii]) {
if(m_listColor[iii]->HasName(colorNameTmp) == true) {
findASameName = true;
EWOL_WARNING("(l " << pNode->Row() << ") Find a color with the same Name : \"" << colorNameTmp <<"\"");
m_listColor[iii]->Parse(pNode);
break;
}
}
}
if (findASameName == false) {
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\"");
ewol::theme::EolColor * myColorTmp = new ewol::theme::EolColor();
if (NULL != myColorTmp) {
myColorTmp->Parse(pNode);
m_listColor.PushBack(myColorTmp);
} else {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
}
}
} else {
EWOL_ERROR("(l " << pNode->Row() << ") node not suported : \"" << nodeValue <<"\" must be [group,color,frame]");
}
}
EWOL_INFO(" --------------------- STOP ---------------------");
}
bool ewol::theme::EolElement::GetColor(etk::String colorName, color_ts & selectedColor)
{
for (int32_t iii=0; iii < m_listColor.Size(); iii++) {
if(NULL!=m_listColor[iii]) {
if(m_listColor[iii]->HasName(colorName) == true) {
selectedColor = m_listColor[iii]->Get();
return true;
}
}
}
selectedColor.red = 0.0;
selectedColor.green = 0.0;
selectedColor.blue = 0.0;
selectedColor.alpha = 1.0;
return false;
}
int32_t ewol::theme::EolElement::GetNbFrame(void)
{
return m_listElement.Size();
}
int32_t ewol::theme::EolElement::GetFrameId(etk::String & frameName)
{
for (int32_t iii=0; iii < m_listElement.Size(); iii++) {
if(NULL!=m_listElement[iii]) {
if(m_listElement[iii]->HasName(frameName) == true) {
return iii;;
}
}
}
return -1;
}
etk::String ewol::theme::EolElement::GetName(void)
{
return m_name;
}
void ewol::theme::EolElement::SetName(etk::String & newName)
{
m_name = newName;
}
bool ewol::theme::EolElement::HasName(etk::String & newName)
{
return m_name == newName;
}
void ewol::theme::EolElement::Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (0 > frameId || frameId > m_listElement.Size()) {
EWOL_ERROR("Did not find the frame id=" << frameId);
return;
}
if (NULL != m_listElement[frameId]) {
m_listElement[frameId]->Generate(myTheme, this, newObject, posX, posY, sizeX, sizeY);
}
}

View File

@ -39,8 +39,22 @@ namespace ewol {
namespace theme {
class EolElement {
public:
EolElement(void) { };
virtual ~EolElement(void) { };
EolElement(void);
virtual ~EolElement(void);
void Parse(TiXmlNode * pNode);
etk::String GetName(void);
void SetName(etk::String & newName);
bool HasName(etk::String & newName);
void Generate(const ewol::theme::Theme * myTheme, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GenerateGroup(const ewol::theme::Theme * myTheme, etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::String colorName, color_ts & selectedColor);
int32_t GetNbFrame(void);
int32_t GetFrameId(etk::String & frameName);
private:
void RemoveAll(void);
etk::String m_name;
/*
void Load(etk::File & newFile) { };
void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) {};
@ -50,13 +64,13 @@ namespace ewol {
*/
private:
etk::VectorType<ewol::theme::EolColor*> m_listColor;
etk::VectorType<ewol::theme::EolBase*> m_listGroup;
etk::VectorType<ewol::theme::EolElementFrame*> m_listGroup;
etk::VectorType<ewol::theme::EolElementFrame*> m_listElement;
etkFloat_t m_ratio;
bool m_clipX;
bool m_clipY;
coord2D_ts m_internalElemX;
coord2D_ts m_internalElemY;
coord2D_ts m_internalElemStart;
coord2D_ts m_internalElemStop;
public:
// acces to manage and create object ==> drawing system

View File

@ -23,7 +23,105 @@
*/
#include <ewol/theme/Theme.h>
#include <ewol/theme/EolElementFrame.h>
#undef __class__
#define __class__ "ewol::theme::EolElementFrame"
ewol::theme::EolElementFrame::EolElementFrame(void)
{
//EWOL_DEBUG("new...");
}
ewol::theme::EolElementFrame::~EolElementFrame(void)
{
RemoveAll();
}
void ewol::theme::EolElementFrame::RemoveAll(void)
{
for(int32_t iii=0; iii<m_description.Size(); iii++) {
if (m_description[iii] != NULL) {
delete m_description[iii];
m_description[iii] = NULL;
}
}
m_description.Clear();
}
void ewol::theme::EolElementFrame::Parse(TiXmlNode * root)
{
RemoveAll();
m_name = root->ToElement()->Attribute("name");
EWOL_INFO("(l " << root->Row() << ") Group name=\"" << m_name << "\" " );
for(TiXmlNode * pNode=root->FirstChild(); NULL!=pNode; pNode = pNode->NextSibling()) {
if (pNode->Type()==TiXmlNode::TINYXML_COMMENT) {
continue;
}
etk::String nodeValue = pNode->Value();
ewol::theme::EolBase * myBaseTmp = NULL;
if (nodeValue == "line") {
//EWOL_INFO("Find baseElement Line");
myBaseTmp = new ewol::theme::EolBaseLine();
if (NULL == myBaseTmp) {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
} else if (nodeValue == "rect") {
//EWOL_INFO("Find baseElement Rectangle");
myBaseTmp = new ewol::theme::EolBaseRect();
if (NULL == myBaseTmp) {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
} else if (nodeValue == "link") {
EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\"");
} else if (nodeValue == "triangle") {
EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\"");
} else if (nodeValue == "polygone") {
EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\"");
} else if (nodeValue == "circle") {
EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\"");
} else if (nodeValue == "circlePart") {
EWOL_WARNING("(l " << pNode->Row() << ") Not Parsed now : \"" << nodeValue <<"\"");
} else {
EWOL_ERROR("(l " << pNode->Row() << ") Node not suported : \"" << nodeValue <<"\" must be [line,rect,link,triangle,polygone,circle,circlePart]");
}
if (NULL != myBaseTmp) {
myBaseTmp->Parse(pNode);
m_description.PushBack(myBaseTmp);
}
}
}
etk::String ewol::theme::EolElementFrame::GetName(void)
{
return m_name;
}
void ewol::theme::EolElementFrame::SetName(etk::String & newName)
{
m_name = newName;
}
bool ewol::theme::EolElementFrame::HasName(etk::String & newName)
{
return m_name == newName;
}
void ewol::theme::EolElementFrame::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
}

View File

@ -32,22 +32,27 @@
#include <etk/File.h>
#include <ewol/OObject.h>
#include <ewol/theme/EolColor.h>
#include <ewol/theme/EolBase.h>
#include <ewol/theme/EolBaseLine.h>
#include <ewol/theme/EolBaseRect.h>
namespace ewol {
namespace theme {
class EolElementFrame {
public:
EolElementFrame(void) { };
virtual ~EolElementFrame(void) { };
/*
void Load(etk::File & newFile) { };
void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) {};
int32_t GetNbFrame(int32_t id) {return 0;};
int32_t GetFrameId(int32_t id, etk::String & frameName) {return 0;};
int32_t GetObjectId(etk::String name) { return -1; };
*/
EolElementFrame(void);
virtual ~EolElementFrame(void);
void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
void Parse(TiXmlNode * pNode);
etk::String GetName(void);
void SetName(etk::String & newName);
bool HasName(etk::String & newName);
private:
void RemoveAll(void);
etk::String m_name;
etk::VectorType<ewol::theme::EolBase*> m_description; // all element to draw the image ...
public:
// acces to manage and create object ==> drawing system

View File

@ -70,11 +70,37 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
etk::String nodeValue = pNode->Value();
if (nodeValue == "element") {
EWOL_INFO("Find ELEMENT ... ");
// Need to call the sub parser ...
// TODO ...
//EWOL_INFO("Find ELEMENT ... ");
etk::String elementNameTmp = pNode->ToElement()->Attribute("name");
if (elementNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Element with NO name ... (not parsed)");
// not added it
} else {
bool findASameName = false;
// check if existed ...
for (int32_t iii=0; iii < m_listElement.Size(); iii++) {
if(NULL!=m_listElement[iii]) {
if(m_listElement[iii]->HasName(elementNameTmp) == true) {
findASameName = true;
EWOL_WARNING("(l " << pNode->Row() << ") Find a Group with the same Name : \"" << elementNameTmp <<"\"");
m_listElement[iii]->Parse(pNode);
break;
}
}
}
if (findASameName == false) {
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Element : \"" << elementNameTmp <<"\"");
ewol::theme::EolElement * myElementTmp = new ewol::theme::EolElement();
if (NULL != myElementTmp) {
myElementTmp->Parse(pNode);
m_listElement.PushBack(myElementTmp);
} else {
EWOL_ERROR("(l " << pNode->Row() << ") Error Allocation : \"" << nodeValue <<"\"");
}
}
}
} else if (nodeValue == "group") {
EWOL_INFO("Find group ... ");
//EWOL_INFO("Find group ... ");
etk::String groupNameTmp = pNode->ToElement()->Attribute("name");
if (groupNameTmp == "") {
EWOL_ERROR("(l " << pNode->Row() << ") Group with NO name ... (not parsed)");
@ -93,8 +119,8 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
}
if (findASameName == false) {
EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << groupNameTmp <<"\"");
ewol::theme::EolBase * myGroupTmp = new ewol::theme::EolBase();
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new Group : \"" << groupNameTmp <<"\"");
ewol::theme::EolElementFrame * myGroupTmp = new ewol::theme::EolElementFrame();
if (NULL != myGroupTmp) {
myGroupTmp->Parse(pNode);
m_listGroup.PushBack(myGroupTmp);
@ -122,7 +148,7 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
}
if (findASameName == false) {
EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\"");
//EWOL_DEBUG("(l " << pNode->Row() << ") Add a new COLOR : \"" << colorNameTmp <<"\"");
ewol::theme::EolColor * myColorTmp = new ewol::theme::EolColor();
if (NULL != myColorTmp) {
myColorTmp->Parse(pNode);
@ -141,23 +167,88 @@ void ewol::theme::Theme::Load(etk::File & newFile, bool defaultTheme)
}
void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
bool ewol::theme::Theme::GetColor(etk::String colorName, color_ts & selectedColor)
{
for (int32_t iii=0; iii < m_listColor.Size(); iii++) {
if(NULL!=m_listColor[iii]) {
if(m_listColor[iii]->HasName(colorName) == true) {
selectedColor = m_listColor[iii]->Get();
return true;
}
}
}
selectedColor.red = 0.0;
selectedColor.green = 0.0;
selectedColor.blue = 0.0;
selectedColor.alpha = 1.0;
return false;
}
void ewol::theme::Theme::Generate(int32_t id, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (0 > id || id > m_listElement.Size()) {
return;
}
if (NULL != m_listElement[id]) {
m_listElement[id]->Generate(this, frameId, newObject, posX, posY, sizeX, sizeY);
}
}
bool ewol::theme::Theme::GenerateGroup(etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (groupName == "") {
EWOL_ERROR("Did not find the group name=" << groupName);
return -1;
}
for (int32_t iii=0; iii < m_listGroup.Size(); iii++) {
if(NULL!=m_listGroup[iii]) {
if(m_listGroup[iii]->HasName(groupName) == true) {
// TODO : Call Group display ...
return true;
}
}
}
return false;
}
int32_t ewol::theme::Theme::GetNbFrame(int32_t id)
{
if (0 > id || id > m_listElement.Size()) {
EWOL_ERROR("Did not find the Element id=" << id);
return 0;
}
if (NULL != m_listElement[id]) {
return m_listElement[id]->GetNbFrame();
}
return 0;
}
int32_t ewol::theme::Theme::GetFrameId(int32_t id, etk::String & frameName)
{
return 0;
if (0 > id || id > m_listElement.Size()) {
EWOL_ERROR("Did not find the Element named=" << frameName);
return -1;
}
if (NULL != m_listElement[id]) {
return m_listElement[id]->GetFrameId(frameName);
}
return -1;
}
int32_t ewol::theme::Theme::GetObjectId(etk::String name)
{
if (name == "") {
return -1;
}
for (int32_t iii=0; iii < m_listElement.Size(); iii++) {
if(NULL!=m_listElement[iii]) {
if(m_listElement[iii]->HasName(name) == true) {
return iii;
}
}
}
EWOL_ERROR("Did not find the Element named=" << name);
return -1;
}

View File

@ -26,6 +26,12 @@
#ifndef __EWOL_EOL_THEME_H__
#define __EWOL_EOL_THEME_H__
namespace ewol {
namespace theme {
class Theme;
class EolElement;
}
}
#include <etk/Types.h>
#include <etk/String.h>
@ -44,14 +50,16 @@ namespace ewol {
Theme(void);
virtual ~Theme(void);
void Load(etk::File & newFile, bool defaultTheme=false);
void Generate(int32_t id, int32_t frameId, OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
void Generate(int32_t id, int32_t frameId, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GenerateGroup(etk::String groupName, ewol::OObject2DTextured & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
bool GetColor(etk::String colorName, color_ts & selectedColor);
int32_t GetNbFrame(int32_t id);
int32_t GetFrameId(int32_t id, etk::String & frameName);
int32_t GetObjectId(etk::String name);
private:
etk::VectorType<ewol::theme::EolColor*> m_listColor;
etk::VectorType<ewol::theme::EolBase*> m_listGroup; // TODO : we need really to star a frame here ...
etk::VectorType<ewol::theme::EolElement*> m_listElement;
etk::VectorType<ewol::theme::EolColor*> m_listColor;
etk::VectorType<ewol::theme::EolElementFrame*> m_listGroup;
etk::VectorType<ewol::theme::EolElement*> m_listElement;
public:
// acces to manage and create object ==> drawing system

View File

@ -13,7 +13,7 @@
position="0.53;0.56"
size="0.22;0.11"
/>
<Line color="..."
<line color="..."
positionStart="0.53;0.56"
positionStop="0.22;0.11"
thickness="0.05"
@ -26,10 +26,8 @@
ratio="1.0"
ClipX="false"
ClipY="false"
internalElemXStart="0.25"
internalElemXStop="0.75"
internalElemYStart="0.25"
internalElemYStop="0.75">
internalElemStart="0.25;0.75"
internalElemStop="0.75;0.75">
<!--
note we have 5 methode to reference a color :
- #RRGGBB ==> in hexa 0x00<=x<=0xFF
@ -48,7 +46,7 @@
position="0.53;0.56"
size="0.22;0.11"
/>
<Line color="..."
<line color="..."
positionStart="0.53;0.56"
positionStop="0.22;0.11"
thickness="0.05"
@ -57,18 +55,18 @@
</group>
<!--...-->
<frame id=0 name="basic">
<frame id="0" name="basic">
<rect color="..."
position="0.53;0.56"
size="0.22;0.11"
/>
</frame>
<frame id=0 name="hover">
<frame id="0" name="hover">
<rect color="..."
position="0.53;0.56"
size="0.22;0.11"
/>
<group name="basicRect"/>
<link name="basicRect"/>
</frame>
<!--...-->