Update basic object file
This commit is contained in:
parent
e8bd90cb48
commit
06f6cf283e
5
Makefile
5
Makefile
@ -178,6 +178,9 @@ CXXFILES += etk/etkDebug.cpp \
|
||||
CXXFILES += ewol.cpp \
|
||||
ewolDebug.cpp \
|
||||
ewolOObject.cpp \
|
||||
ewolOObject2DText.cpp \
|
||||
ewolOObject2DColored.cpp \
|
||||
ewolOObject2DTextured.cpp \
|
||||
ewolTexture.cpp
|
||||
ifeq ("$(FREETYPE_CFLAGS)", "")
|
||||
CXXFILES += ewolFontBitmap.cpp
|
||||
@ -193,6 +196,8 @@ CXXFILES += widget/ewolButton.cpp \
|
||||
widget/ewolList.cpp \
|
||||
widget/ewolSizerHori.cpp \
|
||||
widget/ewolSizerVert.cpp
|
||||
# only to test son internal element ...
|
||||
CXXFILES += widget/ewolTest.cpp
|
||||
|
||||
|
||||
# Ewol Test Software :
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <widget/ewolButton.h>
|
||||
#include <widget/ewolSizerHori.h>
|
||||
#include <widget/ewolSizerVert.h>
|
||||
#include <widget/ewolTest.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@ -55,6 +56,10 @@ class Plop :public ewol::Windows
|
||||
myButton->SetExpendX(true);
|
||||
//myButton->SetExpendY(true);
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
|
||||
ewol::Test * myTest = new ewol::Test();
|
||||
mySizerVert->SubWidgetAdd(myTest);
|
||||
|
||||
myButton = new ewol::Button(" 4 4 BT");
|
||||
//myButton->SetExpendY(true);
|
||||
mySizerVert->SubWidgetAdd(myButton);
|
||||
|
@ -25,261 +25,39 @@
|
||||
#include <etkTypes.h>
|
||||
#include <etkString.h>
|
||||
#include <ewolOObject.h>
|
||||
#include <ewolTexture.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DColored"
|
||||
#define __class__ "ewol::OObject"
|
||||
|
||||
|
||||
|
||||
void ewol::OObject2DColored::Draw(void)
|
||||
ewol::OObject::OObject(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
return;
|
||||
}
|
||||
// Enable Pointers
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
|
||||
// Set the vertex pointer to our vertex data
|
||||
glVertexPointer(2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glColorPointer(4, GL_FLOAT, 0, &m_coordColor[0] );
|
||||
// Render : draw all of the triangles at once
|
||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("Draw ..." << m_coord.Size()/3 << " triangle(s)");
|
||||
|
||||
// Disable Pointers
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
m_name="";
|
||||
}
|
||||
|
||||
|
||||
void ewol::OObject2DColored::Rectangle(float x, float y, float w, float h, float red, float green, float blue, float alpha)
|
||||
{
|
||||
//EWOL_DEBUG("Add rectangle : ...");
|
||||
coord2D_ts point;
|
||||
color_ts color;
|
||||
|
||||
color.red = red;
|
||||
color.green = green;
|
||||
color.blue = blue;
|
||||
color.alpha = alpha;
|
||||
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x + w;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x + w;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::OObject2DColored::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DTextured"
|
||||
|
||||
|
||||
|
||||
ewol::OObject2DTextured::OObject2DTextured(etk::File textureName)
|
||||
{
|
||||
EWOL_DEBUG("Create OObject textured : \"" << textureName << "\"");
|
||||
m_textureId = ewol::LoadTexture(textureName);
|
||||
}
|
||||
|
||||
ewol::OObject2DTextured::~OObject2DTextured(void)
|
||||
{
|
||||
ewol::UnLoadTexture(m_textureId);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::Draw(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_textureId);
|
||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::Rectangle(float x, float y, float w, float h, float texX, float texY, float texSX, float texSY)
|
||||
{
|
||||
//EWOL_DEBUG("Add rectangle : ...");
|
||||
coord2D_ts point;
|
||||
texCoord_ts tex;
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texY;
|
||||
point.x = x + w;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texSY;
|
||||
point.x = x + w;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texSY;
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DText"
|
||||
|
||||
ewol::OObject2DText::OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
{
|
||||
Text(x, y, FontName, size, mode, textColorFg, utf8String);
|
||||
}
|
||||
|
||||
ewol::OObject2DText::~OObject2DText(void)
|
||||
ewol::OObject::~OObject(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::Draw(void)
|
||||
void ewol::OObject::SetName(etk::String & name)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
|
||||
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
|
||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
||||
glDrawArrays( GL_QUADS, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
void ewol::OObject::SetName(const char * name)
|
||||
{
|
||||
m_FontTextureId = 0;
|
||||
m_coord.Clear();
|
||||
m_coordTex.Clear();
|
||||
// get font Name :
|
||||
if (FontName == "") {
|
||||
m_FontId = GetDefaultFontId();
|
||||
} else {
|
||||
EWOL_TODO("pas encore fait...");
|
||||
//m_FontId = GetFontIdWithName(FontName);
|
||||
return;
|
||||
}
|
||||
if (m_FontId == -1) {
|
||||
EWOL_ERROR("Can not find the font with the name : " << FontName);
|
||||
}
|
||||
EWOL_DEBUG("Font name : " << FontName << " id=" << m_FontId);
|
||||
m_textColorFg = textColorFg;
|
||||
coord2D_ts drawPosition;
|
||||
drawPosition.x = x;
|
||||
drawPosition.y = y;
|
||||
ewol::DrawText(m_FontId, drawPosition, utf8String, m_FontTextureId, m_coord, m_coordTex);
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
if (NULL != name) {
|
||||
m_name = name;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
uint32_t m_FontId; //!< font internal ID
|
||||
uint32_t m_FontTextureId; //!< font internal Texture ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
*/
|
||||
|
||||
|
||||
|
||||
etk::String ewol::OObject::GetName(void)
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,46 +43,19 @@ namespace ewol {
|
||||
class OObject
|
||||
{
|
||||
public:
|
||||
OObject(void) { m_name=""; };
|
||||
virtual ~OObject(void) {};
|
||||
OObject(void);
|
||||
virtual ~OObject(void);
|
||||
public:
|
||||
virtual void Draw(void) = 0;
|
||||
void SetName(etk::String & name)
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
void SetName(const char * name)
|
||||
{
|
||||
if (NULL != name) {
|
||||
m_name = name;
|
||||
}
|
||||
}
|
||||
etk::String GetName(void)
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
void SetName(etk::String & name);
|
||||
void SetName(const char * name);
|
||||
etk::String GetName(void);
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y) {};
|
||||
private:
|
||||
etk::String m_name;
|
||||
};
|
||||
|
||||
class OObject2DColored :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DColored(void) {};
|
||||
virtual ~OObject2DColored(void) {};
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
protected:
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<color_ts> m_coordColor; //!< internal color of the different point
|
||||
//etk::VectorType<linkCoord_ts> m_linkCoord; //!< internal link between point to generate triangle
|
||||
public:
|
||||
void Rectangle(float x, float y, float w, float h, float red, float green, float blue, float alpha);
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
/*
|
||||
class OObjectFile :public ewol::OObject
|
||||
{
|
||||
@ -97,62 +70,12 @@ namespace ewol {
|
||||
bool m_isBinaryFile; //!< to know th mode of saving the file
|
||||
};
|
||||
*/
|
||||
|
||||
class OObject2DTextured :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DTextured(etk::File textureName);
|
||||
virtual ~OObject2DTextured(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0);
|
||||
protected:
|
||||
uint32_t m_textureId; //!< texture internal ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
|
||||
|
||||
class OObject2DText :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
virtual ~OObject2DText(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
// set a specific text
|
||||
void Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
protected:
|
||||
int32_t m_FontId; //!< font internal ID
|
||||
color_ts m_textColorFg; //!< text color ...
|
||||
uint32_t m_FontTextureId; //!< font internal Texture ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
|
||||
/*
|
||||
class OObject2DTextMultiple :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DText(etk::String FontName);
|
||||
virtual ~OObject2DText(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
// set a specific text
|
||||
void TextAdd(float x, float y, int32_t size, fontMode_te mode, const char* utf8String);
|
||||
void Clear(void);
|
||||
protected:
|
||||
int32_t m_FontId; //!< font internal ID
|
||||
uint32_t m_FontTextureId[FONT_MODE_NUMBER]; //!< font internal Texture ID
|
||||
etk::VectorType<coord2D_ts> m_coord[FONT_MODE_NUMBER]; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex[FONT_MODE_NUMBER]; //!< internal texture coordinate for every point
|
||||
};
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#include <ewolOObject2DTextured.h>
|
||||
#include <ewolOObject2DColored.h>
|
||||
#include <ewolOObject2DText.h>
|
||||
|
||||
|
108
Sources/ewolOObject2DColored.cpp
Normal file
108
Sources/ewolOObject2DColored.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DColored.cpp
|
||||
* @brief ewol OpenGl Object system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewolOObject2DColored.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DColored"
|
||||
|
||||
|
||||
|
||||
void ewol::OObject2DColored::Draw(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
return;
|
||||
}
|
||||
// Enable Pointers
|
||||
glEnableClientState( GL_VERTEX_ARRAY );
|
||||
glEnableClientState( GL_COLOR_ARRAY );
|
||||
|
||||
|
||||
// Set the vertex pointer to our vertex data
|
||||
glVertexPointer(2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glColorPointer(4, GL_FLOAT, 0, &m_coordColor[0] );
|
||||
// Render : draw all of the triangles at once
|
||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("Draw ..." << m_coord.Size()/3 << " triangle(s)");
|
||||
|
||||
// Disable Pointers
|
||||
glDisableClientState( GL_COLOR_ARRAY );
|
||||
glDisableClientState( GL_VERTEX_ARRAY );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::OObject2DColored::Rectangle(float x, float y, float w, float h, float red, float green, float blue, float alpha)
|
||||
{
|
||||
//EWOL_DEBUG("Add rectangle : ...");
|
||||
coord2D_ts point;
|
||||
color_ts color;
|
||||
|
||||
color.red = red;
|
||||
color.green = green;
|
||||
color.blue = blue;
|
||||
color.alpha = alpha;
|
||||
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x + w;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x + w;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordColor.PushBack(color);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::OObject2DColored::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
}
|
||||
}
|
||||
|
50
Sources/ewolOObject2DColored.h
Normal file
50
Sources/ewolOObject2DColored.h
Normal file
@ -0,0 +1,50 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DColored.h
|
||||
* @brief ewol OpenGl Object system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_O_OBJECT_2D_COLORED_H__
|
||||
#define __EWOL_O_OBJECT_2D_COLORED_H__
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
namespace ewol {
|
||||
class OObject2DColored :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DColored(void) {};
|
||||
virtual ~OObject2DColored(void) {};
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
protected:
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<color_ts> m_coordColor; //!< internal color of the different point
|
||||
//etk::VectorType<linkCoord_ts> m_linkCoord; //!< internal link between point to generate triangle
|
||||
public:
|
||||
void Rectangle(float x, float y, float w, float h, float red, float green, float blue, float alpha);
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
96
Sources/ewolOObject2DText.cpp
Normal file
96
Sources/ewolOObject2DText.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DText.cpp
|
||||
* @brief ewol OpenGl Object system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewolOObject2DText.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DText"
|
||||
|
||||
ewol::OObject2DText::OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
{
|
||||
Text(x, y, FontName, size, mode, textColorFg, utf8String);
|
||||
}
|
||||
|
||||
ewol::OObject2DText::~OObject2DText(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::Draw(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
|
||||
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_FontTextureId);
|
||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
||||
glDrawArrays( GL_QUADS, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String)
|
||||
{
|
||||
m_FontTextureId = 0;
|
||||
m_coord.Clear();
|
||||
m_coordTex.Clear();
|
||||
// get font Name :
|
||||
if (FontName == "") {
|
||||
m_FontId = GetDefaultFontId();
|
||||
} else {
|
||||
EWOL_TODO("pas encore fait...");
|
||||
//m_FontId = GetFontIdWithName(FontName);
|
||||
return;
|
||||
}
|
||||
if (m_FontId == -1) {
|
||||
EWOL_ERROR("Can not find the font with the name : " << FontName);
|
||||
}
|
||||
EWOL_DEBUG("Font name : " << FontName << " id=" << m_FontId);
|
||||
m_textColorFg = textColorFg;
|
||||
coord2D_ts drawPosition;
|
||||
drawPosition.x = x;
|
||||
drawPosition.y = y;
|
||||
ewol::DrawText(m_FontId, drawPosition, utf8String, m_FontTextureId, m_coord, m_coordTex);
|
||||
}
|
||||
|
||||
void ewol::OObject2DText::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
52
Sources/ewolOObject2DText.h
Normal file
52
Sources/ewolOObject2DText.h
Normal file
@ -0,0 +1,52 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DText.h
|
||||
* @brief ewol OpenGl Object system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_O_OBJECT_2D_TEXT_H__
|
||||
#define __EWOL_O_OBJECT_2D_TEXT_H__
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
namespace ewol {
|
||||
class OObject2DText :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DText(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
virtual ~OObject2DText(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
// set a specific text
|
||||
void Text(float x, float y, etk::String FontName, int32_t size, fontMode_te mode, color_ts textColorFg, const char* utf8String);
|
||||
protected:
|
||||
int32_t m_FontId; //!< font internal ID
|
||||
color_ts m_textColorFg; //!< text color ...
|
||||
uint32_t m_FontTextureId; //!< font internal Texture ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
120
Sources/ewolOObject2DTextured.cpp
Normal file
120
Sources/ewolOObject2DTextured.cpp
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DTextured.cpp
|
||||
* @brief ewol OpenGl Object system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewolOObject2DTextured.h>
|
||||
#include <ewolTexture.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::OObject2DTextured"
|
||||
|
||||
|
||||
|
||||
ewol::OObject2DTextured::OObject2DTextured(etk::File textureName)
|
||||
{
|
||||
EWOL_DEBUG("Create OObject textured : \"" << textureName << "\"");
|
||||
m_textureId = ewol::LoadTexture(textureName);
|
||||
}
|
||||
|
||||
ewol::OObject2DTextured::~OObject2DTextured(void)
|
||||
{
|
||||
ewol::UnLoadTexture(m_textureId);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::Draw(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
|
||||
glColor4f(1.0, 1.0, 1.0, 1.0);
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, m_textureId);
|
||||
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
|
||||
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
|
||||
glVertexPointer( 2, GL_FLOAT, 0, &m_coord[0] );
|
||||
glTexCoordPointer( 2, GL_FLOAT, 0, &m_coordTex[0] );
|
||||
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
|
||||
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
|
||||
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
|
||||
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::Rectangle(float x, float y, float w, float h, float texX, float texY, float texSX, float texSY)
|
||||
{
|
||||
//EWOL_DEBUG("Add rectangle : ...");
|
||||
coord2D_ts point;
|
||||
texCoord_ts tex;
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texY;
|
||||
point.x = x + w;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texSY;
|
||||
point.x = x + w;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texSY;
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
}
|
||||
|
||||
void ewol::OObject2DTextured::UpdateOrigin(float x, float y)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_coord.Size(); iii++) {
|
||||
m_coord[iii].x += x;
|
||||
m_coord[iii].y += y;
|
||||
}
|
||||
}
|
||||
|
49
Sources/ewolOObject2DTextured.h
Normal file
49
Sources/ewolOObject2DTextured.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolOObject2DTextured.h
|
||||
* @brief ewol OpenGl Object system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 09/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_O_OBJECT_2D_TEXTURED_H__
|
||||
#define __EWOL_O_OBJECT_2D_TEXTURED_H__
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
namespace ewol {
|
||||
class OObject2DTextured :public ewol::OObject
|
||||
{
|
||||
public:
|
||||
OObject2DTextured(etk::File textureName);
|
||||
virtual ~OObject2DTextured(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
void Rectangle(float x, float y, float w, float h, float texX=0.0, float texY=0.0, float texSX=1.0, float texSY=1.0);
|
||||
protected:
|
||||
uint32_t m_textureId; //!< texture internal ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
|
||||
public:
|
||||
virtual void UpdateOrigin(float x, float y);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
97
Sources/widget/ewolTest.cpp
Normal file
97
Sources/widget/ewolTest.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolTest.cpp
|
||||
* @brief ewol Test widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <widget/ewolTest.h>
|
||||
|
||||
#include <ewolOObject.h>
|
||||
|
||||
|
||||
|
||||
//const char * ewolEventButtonPressed = "ewol Button Pressed";
|
||||
|
||||
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::Test"
|
||||
|
||||
ewol::Test::Test(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
ewol::Test::~Test(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool ewol::Test::CalculateMinSize(void)
|
||||
{
|
||||
m_minSize.x = 150;
|
||||
m_minSize.y = 150;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::Test::OnRegenerateDisplay(void)
|
||||
{
|
||||
// clean the object list ...
|
||||
ClearOObjectList();
|
||||
|
||||
ewol::OObject2DColored * tmpOObjects = new ewol::OObject2DColored;
|
||||
tmpOObjects->Rectangle( 0, 0, m_size.x, m_size.y, 1.0, 0.0, 0.0, 1.0);
|
||||
tmpOObjects->Rectangle( 3, 3, m_size.x-6, m_size.y-6, 1.0, 1.0, 1.0, 1.0);
|
||||
AddOObject(tmpOObjects, "BouttonDecoration");
|
||||
|
||||
color_ts textColorFg;
|
||||
textColorFg.red = 0.0;
|
||||
textColorFg.green = 0.0;
|
||||
textColorFg.blue = 0.0;
|
||||
textColorFg.alpha = 1.0;
|
||||
|
||||
|
||||
// Regenerate the event Area:
|
||||
/*
|
||||
EventAreaRemoveAll();
|
||||
coord origin;
|
||||
coord size;
|
||||
origin.x = 3.0;
|
||||
origin.y = 3.0;
|
||||
size.x = m_size.x-6;
|
||||
size.y = m_size.y-6;
|
||||
AddEventArea(origin, size, FLAG_EVENT_INPUT_1 | FLAG_EVENT_INPUT_CLICKED_ALL, ewolEventButtonPressed);
|
||||
*/
|
||||
}
|
||||
|
||||
bool ewol::Test::OnEventArea(const char * generateEventId, double x, double y)
|
||||
{
|
||||
bool eventIsOK = false;
|
||||
/*
|
||||
//EWOL_DEBUG("Receive event : \"" << generateEventId << "\"");
|
||||
if(ewolEventButtonPressed == generateEventId) {
|
||||
EWOL_INFO("BT pressed ... " << m_label);
|
||||
eventIsOK = true;
|
||||
}
|
||||
*/
|
||||
return eventIsOK;
|
||||
}
|
46
Sources/widget/ewolTest.h
Normal file
46
Sources/widget/ewolTest.h
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewolTest.h
|
||||
* @brief ewol test widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/11/2011
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_TEST_H__
|
||||
#define __EWOL_TEST_H__
|
||||
|
||||
#include <etkTypes.h>
|
||||
#include <ewolDebug.h>
|
||||
#include <ewolWidget.h>
|
||||
|
||||
namespace ewol {
|
||||
class Test :public ewol::Widget
|
||||
{
|
||||
public:
|
||||
Test(void);
|
||||
virtual ~Test(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
public:
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
public:
|
||||
virtual bool OnEventArea(const char * generateEventId, double x, double y);
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user