[DEV] change namespacing to clarify the API ==> (not work)

This commit is contained in:
Edouard DUPIN 2013-12-11 01:19:33 +01:00
parent 5c295fcca9
commit dad1b90812
113 changed files with 6153 additions and 5941 deletions

2
build

@ -1 +1 @@
Subproject commit b02c8b5221d94dd8446319ea224ff25f801a2924 Subproject commit 5ea83bfddea9a0c93f65170b73d3be07f8a100e0

View File

@ -10,9 +10,9 @@
#include <ewol/compositing/Area.h> #include <ewol/compositing/Area.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Area" #define __class__ "ewol::compositing::Area"
ewol::Area::Area(const ivec2& _size) : ewol::compositing::Area::Area(const ivec2& _size) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_color(etk::color::white), m_color(etk::color::white),
m_GLprogram(NULL), m_GLprogram(NULL),
@ -28,12 +28,12 @@ ewol::Area::Area(const ivec2& _size) :
loadProgram(); loadProgram();
} }
ewol::Area::~Area(void) { ewol::compositing::Area::~Area(void) {
ewol::Texture::release(m_resource); ewol::Texture::release(m_resource);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Area::loadProgram(void) { void ewol::compositing::Area::loadProgram(void) {
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:textured3D.prog"); m_GLprogram = ewol::Program::keep("DATA:textured3D.prog");
@ -46,7 +46,7 @@ void ewol::Area::loadProgram(void) {
} }
} }
void ewol::Area::draw(bool _disableDepthTest) { void ewol::compositing::Area::draw(bool _disableDepthTest) {
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
return; return;
@ -76,7 +76,7 @@ void ewol::Area::draw(bool _disableDepthTest) {
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Area::clear(void) { void ewol::compositing::Area::clear(void) {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
@ -87,7 +87,7 @@ void ewol::Area::clear(void) {
m_position = vec3(0.0, 0.0, 0.0); m_position = vec3(0.0, 0.0, 0.0);
} }
void ewol::Area::print(const ivec2& _size) { void ewol::compositing::Area::print(const ivec2& _size) {
vec3 point(0,0,0); vec3 point(0,0,0);
vec2 tex(0,1); vec2 tex(0,1);
point.setX(m_position.x()); point.setX(m_position.x());

View File

@ -10,78 +10,91 @@
#define __EWOL_COMPOSITING_AREA_H__ #define __EWOL_COMPOSITING_AREA_H__
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol namespace ewol {
{ namespace compositing {
class Area : public ewol::Compositing class Area : public ewol::compositing::Compose {
{ private:
private: vec3 m_position; //!< The current position to draw
vec3 m_position; //!< The current position to draw etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_color; //!< The text foreground color private:
private: ewol::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::Program* m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int32_t m_GLtexID; //!< openGL id on the element (texture ID)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) private:
private: ewol::Texture* m_resource; //!< texture resources
ewol::Texture* m_resource; //!< texture resources std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec3 > m_coord; //!< internal coord of the object std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point private:
private: /**
/** * @brief load the openGL program and get all the ID needed
* @brief load the openGL program and get all the ID needed */
*/ void loadProgram(void);
void loadProgram(void); public:
public: /**
/** * @brief generic constructor
* @brief generic constructor * @param[in] _size Basic size of the area.
* @param[in] _size Basic size of the area. */
*/ Area(const ivec2& _size);
Area(const ivec2& _size); /**
/** * @brief generic destructor
* @brief generic destructor */
*/ ~Area(void);
~Area(void); public:
public: /**
/** * @brief draw All the refistered text in the current element on openGL
* @brief draw All the refistered text in the current element on openGL */
*/ void draw(bool _disableDepthTest=true);
void draw(bool _disableDepthTest=true); /**
/** * @brief clear alll the registered element in the current element
* @brief clear alll the registered element in the current element */
*/ void clear(void);
void clear(void); /**
/** * @brief get the current display position (sometime needed in the gui control)
* @brief get the current display position (sometime needed in the gui control) * @return the current position.
* @return the current position. */
*/ const vec3& getPos(void) {
const vec3& getPos(void) { return m_position; }; return m_position;
/** };
* @brief set position for the next text writen /**
* @param[in] _pos Position of the text (in 3D) * @brief set position for the next text writen
*/ * @param[in] _pos Position of the text (in 3D)
void setPos(const vec3& _pos) { m_position = _pos; }; */
inline void setPos(const vec2& _pos) { setPos(vec3(_pos.x(),_pos.y(),0)); }; void setPos(const vec3& _pos) {
/** m_position = _pos;
* @brief set relative position for the next text writen };
* @param[in] _pos ofset apply of the text (in 3D) inline void setPos(const vec2& _pos) {
*/ setPos(vec3(_pos.x(),_pos.y(),0));
void setRelPos(const vec3& _pos) { m_position += _pos; }; };
inline void setRelPos(const vec2& _pos) { setRelPos(vec3(_pos.x(),_pos.y(),0)); }; /**
/** * @brief set relative position for the next text writen
* @brief add a compleate of the image to display with the requested size * @param[in] _pos ofset apply of the text (in 3D)
* @param[in] _size size of the output image */
*/ void setRelPos(const vec3& _pos) {
void print(const ivec2& _size); m_position += _pos;
};
egami::Image& get(void) { return m_resource->get(); }; inline void setRelPos(const vec2& _pos) {
void flush(void) { m_resource->flush(); }; setRelPos(vec3(_pos.x(),_pos.y(),0));
};
/**
* @brief add a compleate of the image to display with the requested size
* @param[in] _size size of the output image
*/
void print(const ivec2& _size);
egami::Image& get(void) {
return m_resource->get();
};
void flush(void) {
m_resource->flush();
};
};
}; };
}; };

View File

@ -13,41 +13,41 @@
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compositing.h>
ewol::Compositing::Compositing(void) { ewol::compositing::Compose::Compose(void) {
// nothing to do // nothing to do
} }
ewol::Compositing::~Compositing(void) { ewol::compositing::Compose::~Compose(void) {
// nothing to do // nothing to do
} }
void ewol::Compositing::resetMatrix(void) { void ewol::compositing::Compose::resetMatrix(void) {
m_matrixApply.identity(); m_matrixApply.identity();
} }
void ewol::Compositing::translate(const vec3& _vect) { void ewol::compositing::Compose::translate(const vec3& _vect) {
m_matrixApply *= etk::matTranslate(_vect); m_matrixApply *= etk::matTranslate(_vect);
} }
void ewol::Compositing::rotate(const vec3& _vect, float _angle) { void ewol::compositing::Compose::rotate(const vec3& _vect, float _angle) {
m_matrixApply *= etk::matRotate(_vect, _angle); m_matrixApply *= etk::matRotate(_vect, _angle);
} }
void ewol::Compositing::scale(const vec3& _vect) { void ewol::compositing::Compose::scale(const vec3& _vect) {
m_matrixApply *= etk::matScale(_vect); m_matrixApply *= etk::matScale(_vect);
} }
void ewol::Compositing::clear(void) { void ewol::compositing::Compose::clear(void) {
m_matrixApply.identity(); m_matrixApply.identity();
} }
void ewol::Compositing::setMatrix(const mat4& _mat) { void ewol::compositing::Compose::setMatrix(const mat4& _mat) {
m_matrixApply = _mat; m_matrixApply = _mat;
} }

View File

@ -0,0 +1,66 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_COMPOSITING_COMPOSE_H__
#define __EWOL_COMPOSITING_COMPOSE_H__
#include <ewol/debug.h>
#include <etk/UString.h>
#include <etk/math/Matrix4.h>
namespace ewol {
namespace compositing {
class Compose {
protected:
mat4 m_matrixApply;
public:
/**
* @brief generic constructor
*/
Compose(void);
/**
* @brief Generic destructor
*/
virtual ~Compose(void);
/**
* @brief Virtal pure function that request the draw of all openGl elements
*/
virtual void draw(bool _disableDepthTest=true)=0;
/**
* @brief clear alll tre registered element in the current element
*/
virtual void clear(void);
/**
* @brief reset to the eye matrix the openGL mouving system
*/
virtual void resetMatrix(void);
/**
* @brief translate the current display of this element
* @param[in] _vect The translation vector to apply at the transformation matrix
*/
virtual void translate(const vec3& _vect);
/**
* @brief rotate the curent display of this element
* @param[in] _vect The rotation vector to apply at the transformation matrix
*/
virtual void rotate(const vec3& _vect, float _angle);
/**
* @brief scale the current diaplsy of this element
* @param[in] _vect The scaling vector to apply at the transformation matrix
*/
virtual void scale(const vec3& _vect);
/**
* @brief set the transformation matrix
* @param[in] _mat The new matrix.
*/
virtual void setMatrix(const mat4& _mat);
};
};
};
#endif

View File

@ -1,66 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __EWOL_COMPOSITING_H__
#define __EWOL_COMPOSITING_H__
#include <ewol/debug.h>
#include <etk/UString.h>
#include <etk/math/Matrix4.h>
namespace ewol
{
class Compositing
{
protected:
mat4 m_matrixApply;
public:
/**
* @brief generic constructor
*/
Compositing(void);
/**
* @brief Generic destructor
*/
virtual ~Compositing(void);
/**
* @brief Virtal pure function that request the draw of all openGl elements
*/
virtual void draw(bool _disableDepthTest=true)=0;
/**
* @brief clear alll tre registered element in the current element
*/
virtual void clear(void);
/**
* @brief reset to the eye matrix the openGL mouving system
*/
virtual void resetMatrix(void);
/**
* @brief translate the current display of this element
* @param[in] _vect The translation vector to apply at the transformation matrix
*/
virtual void translate(const vec3& _vect);
/**
* @brief rotate the curent display of this element
* @param[in] _vect The rotation vector to apply at the transformation matrix
*/
virtual void rotate(const vec3& _vect, float _angle);
/**
* @brief scale the current diaplsy of this element
* @param[in] _vect The scaling vector to apply at the transformation matrix
*/
virtual void scale(const vec3& _vect);
/**
* @brief set the transformation matrix
* @param[in] _mat The new matrix.
*/
virtual void setMatrix(const mat4& _mat);
};
};
#endif

View File

@ -217,7 +217,7 @@ static void SutherlandHodgman(std::vector<vec2 > & input, std::vector<vec2 > & o
} }
#endif #endif
ewol::Drawing::Drawing(void) : ewol::compositing::Drawing::Drawing(void) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
@ -237,11 +237,11 @@ ewol::Drawing::Drawing(void) :
} }
} }
ewol::Drawing::~Drawing(void) { ewol::compositing::Drawing::~Drawing(void) {
unLoadProgram(); unLoadProgram();
} }
void ewol::Drawing::generateTriangle(void) { void ewol::compositing::Drawing::generateTriangle(void) {
m_triElement = 0; m_triElement = 0;
m_coord.push_back(m_triangle[0]); m_coord.push_back(m_triangle[0]);
@ -252,7 +252,7 @@ void ewol::Drawing::generateTriangle(void) {
m_coordColor.push_back(m_tricolor[2]); m_coordColor.push_back(m_tricolor[2]);
} }
void ewol::Drawing::internalSetColor(const etk::Color<>& _color) { void ewol::compositing::Drawing::internalSetColor(const etk::Color<>& _color) {
if (m_triElement < 1) { if (m_triElement < 1) {
m_tricolor[0] = _color; m_tricolor[0] = _color;
} }
@ -264,7 +264,7 @@ void ewol::Drawing::internalSetColor(const etk::Color<>& _color) {
} }
} }
void ewol::Drawing::setPoint(const vec3& _point) { void ewol::compositing::Drawing::setPoint(const vec3& _point) {
m_triangle[m_triElement] = _point; m_triangle[m_triElement] = _point;
m_triElement++; m_triElement++;
if (m_triElement >= 3) { if (m_triElement >= 3) {
@ -272,15 +272,15 @@ void ewol::Drawing::setPoint(const vec3& _point) {
} }
} }
void ewol::Drawing::resetCount(void) { void ewol::compositing::Drawing::resetCount(void) {
m_triElement = 0; m_triElement = 0;
} }
void ewol::Drawing::unLoadProgram(void) { void ewol::compositing::Drawing::unLoadProgram(void) {
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Drawing::loadProgram(void) { void ewol::compositing::Drawing::loadProgram(void) {
// remove previous loading ... in case // remove previous loading ... in case
unLoadProgram(); unLoadProgram();
// oad the new ... // oad the new ...
@ -293,7 +293,7 @@ void ewol::Drawing::loadProgram(void) {
} }
} }
void ewol::Drawing::draw(bool _disableDepthTest) { void ewol::compositing::Drawing::draw(bool _disableDepthTest) {
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
// TODO : a remÚtre ... // TODO : a remÚtre ...
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
@ -316,7 +316,7 @@ void ewol::Drawing::draw(bool _disableDepthTest) {
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Drawing::clear(void) { void ewol::compositing::Drawing::clear(void) {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// reset Buffer : // reset Buffer :
@ -338,7 +338,7 @@ void ewol::Drawing::clear(void) {
} }
} }
void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) { void ewol::compositing::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -364,7 +364,7 @@ void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) {
m_clippingEnable = true; m_clippingEnable = true;
} }
void ewol::Drawing::setThickness(float _thickness) { void ewol::compositing::Drawing::setThickness(float _thickness) {
m_thickness = _thickness; m_thickness = _thickness;
// thickness must be positive // thickness must be positive
if (m_thickness < 0) { if (m_thickness < 0) {
@ -372,12 +372,12 @@ void ewol::Drawing::setThickness(float _thickness) {
} }
} }
void ewol::Drawing::addVertex(void) { void ewol::compositing::Drawing::addVertex(void) {
internalSetColor(m_color); internalSetColor(m_color);
setPoint(m_position); setPoint(m_position);
} }
void ewol::Drawing::lineTo(const vec3& _dest) { void ewol::compositing::Drawing::lineTo(const vec3& _dest) {
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(m_color);
EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest); EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest);
@ -411,7 +411,7 @@ void ewol::Drawing::lineTo(const vec3& _dest) {
m_position = _dest; m_position = _dest;
} }
void ewol::Drawing::rectangle(const vec3& _dest) { void ewol::compositing::Drawing::rectangle(const vec3& _dest) {
resetCount(); resetCount();
internalSetColor(m_color); internalSetColor(m_color);
/* Bitmap position /* Bitmap position
@ -464,11 +464,11 @@ void ewol::Drawing::rectangle(const vec3& _dest) {
setPoint(vec3(dxA, dyD, 0) ); setPoint(vec3(dxA, dyD, 0) );
} }
void ewol::Drawing::cube(const vec3& _dest) { void ewol::compositing::Drawing::cube(const vec3& _dest) {
} }
void ewol::Drawing::circle(float _radius, float _angleStart, float _angleStop) { void ewol::compositing::Drawing::circle(float _radius, float _angleStart, float _angleStop) {
resetCount(); resetCount();
if (_radius<0) { if (_radius<0) {

View File

@ -12,170 +12,206 @@
#include <etk/Color.h> #include <etk/Color.h>
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol { namespace ewol {
class Drawing : public ewol::Compositing { namespace compositing {
private: class Drawing : public ewol::compositing::Compose {
vec3 m_position; //!< The current position to draw private:
vec3 m_clippingPosStart; //!< Clipping start position vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStop; //!< Clipping stop position vec3 m_clippingPosStart; //!< Clipping start position
bool m_clippingEnable; //!< true if the clipping must be activated vec3 m_clippingPosStop; //!< Clipping stop position
private: bool m_clippingEnable; //!< true if the clipping must be activated
etk::Color<> m_color; //!< The text foreground color private:
etk::Color<> m_colorBg; //!< The text background color etk::Color<> m_color; //!< The text foreground color
private: etk::Color<> m_colorBg; //!< The text background color
ewol::Program* m_GLprogram; //!< pointer on the opengl display program private:
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) ewol::Program* m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
private: // Background Color (display only when needed) int32_t m_GLColor; //!< openGL id on the element (color buffer)
std::vector<vec3 > m_coord; //!< internal position for the text display private: // Background Color (display only when needed)
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background std::vector<vec3 > m_coord; //!< internal position for the text display
public: std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background
/** public:
* @brief Basic constructor /**
*/ * @brief Basic constructor
Drawing(void); */
/** Drawing(void);
* @brief Basic destructor /**
*/ * @brief Basic destructor
~Drawing(void); */
private: ~Drawing(void);
/** private:
* @brief load the openGL program and get all the ID needed /**
*/ * @brief load the openGL program and get all the ID needed
void loadProgram(void); */
/** void loadProgram(void);
* @brief Un-Load the openGL program and get all the ID needed /**
*/ * @brief Un-Load the openGL program and get all the ID needed
void unLoadProgram(void); */
float m_thickness; //!< when drawing line and other things void unLoadProgram(void);
int32_t m_triElement; //!< special counter of the single dot generated float m_thickness; //!< when drawing line and other things
vec3 m_triangle[3]; //!< Register every system with a combinaison of tiangle int32_t m_triElement; //!< special counter of the single dot generated
etk::Color<float> m_tricolor[3]; //!< Register every the associated color foreground vec3 m_triangle[3]; //!< Register every system with a combinaison of tiangle
// internal API for the generation abstraction of triangles etk::Color<float> m_tricolor[3]; //!< Register every the associated color foreground
/** // internal API for the generation abstraction of triangles
* @brief Lunch the generation of triangle /**
*/ * @brief Lunch the generation of triangle
void generateTriangle(void); */
/** void generateTriangle(void);
* @brief in case of some error the count can be reset /**
*/ * @brief in case of some error the count can be reset
void resetCount(void); */
/** void resetCount(void);
* @brief set the Color of the current triangle drawing /**
* @param[in] _color Color to current dots generated * @brief set the Color of the current triangle drawing
*/ * @param[in] _color Color to current dots generated
void internalSetColor(const etk::Color<>& _color); */
/** void internalSetColor(const etk::Color<>& _color);
* @brief internal add of the specific point /**
* @param[in] _point The requeste dpoint to add * @brief internal add of the specific point
*/ * @param[in] _point The requeste dpoint to add
void setPoint(const vec3& point); */
void setPoint(const vec3& point);
public:
/** public:
* @brief draw All the refistered text in the current element on openGL /**
*/ * @brief draw All the refistered text in the current element on openGL
void draw(bool _disableDepthTest=true); */
/** void draw(bool _disableDepthTest=true);
* @brief clear alll tre registered element in the current element /**
*/ * @brief clear alll tre registered element in the current element
void clear(void); */
/** void clear(void);
* @brief get the current display position (sometime needed in the gui control) /**
* @return the current position. * @brief get the current display position (sometime needed in the gui control)
*/ * @return the current position.
const vec3& getPos(void) { return m_position; }; */
/** const vec3& getPos(void) {
* @brief set position for the next text writen return m_position;
* @param[in] _pos Position of the text (in 3D) };
*/ /**
void setPos(const vec3& _pos) { m_position = _pos; }; * @brief set position for the next text writen
inline void setPos(const vec2& _pos) { setPos(vec3(_pos.x(), _pos.y(), 0)); }; * @param[in] _pos Position of the text (in 3D)
/** */
* @brief set relative position for the next text writen void setPos(const vec3& _pos) {
* @param[in] _pos ofset apply of the text (in 3D) m_position = _pos;
*/ };
void setRelPos(const vec3& _pos) { m_position += _pos; }; inline void setPos(const vec2& _pos) {
inline void setRelPos(const vec2& _pos) { setRelPos(vec3(_pos.x(), _pos.y(), 0)); }; setPos(vec3(_pos.x(), _pos.y(), 0));
/** };
* @brief set the Color of the current foreground font /**
* @param[in] _color Color to set on foreground (for next print) * @brief set relative position for the next text writen
*/ * @param[in] _pos ofset apply of the text (in 3D)
void setColor(const etk::Color<>& _color) { m_color = _color; }; */
/** void setRelPos(const vec3& _pos) {
* @brief set the background color of the font (for selected Text (not the global BG)) m_position += _pos;
* @param[in] _color Color to set on background (for next print) };
*/ inline void setRelPos(const vec2& _pos) {
void setColorBg(const etk::Color<>& _color) { m_colorBg = _color; }; setRelPos(vec3(_pos.x(), _pos.y(), 0));
/** };
* @brief Request a clipping area for the text (next draw only) /**
* @param[in]_ pos Start position of the clipping * @brief set the Color of the current foreground font
* @param[in] _width Width size of the clipping * @param[in] _color Color to set on foreground (for next print)
*/ */
void setClippingWidth(const vec3& _pos, const vec3& _width) { setClipping(_pos, _pos+_width); }; void setColor(const etk::Color<>& _color) {
inline void setClippingWidth(const vec2& _pos, const vec2& _width) { setClippingWidth(vec3(_pos.x(),_pos.y(),-1), vec3(_width.x(),_width.y(), 2)); }; m_color = _color;
/** };
* @brief Request a clipping area for the text (next draw only) /**
* @param[in] _pos Start position of the clipping * @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _posEnd End position of the clipping * @param[in] _color Color to set on background (for next print)
*/ */
void setClipping(const vec3& _pos, const vec3& _posEnd); void setColorBg(const etk::Color<>& _color) {
inline void setClipping(const vec2& _pos, const vec2& _posEnd) { setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(), 1)); }; m_colorBg = _color;
/** };
* @brief enable/Disable the clipping (without lose the current clipping position) /**
* @brief _newMode The new status of the clipping * @brief Request a clipping area for the text (next draw only)
*/ * @param[in]_ pos Start position of the clipping
void setClippingMode(bool _newMode) { m_clippingEnable = _newMode; }; * @param[in] _width Width size of the clipping
/** */
* @brief Specify the line thickness for the next elements void setClippingWidth(const vec3& _pos, const vec3& _width) {
* @param[in] _thickness The thickness disired for the next print setClipping(_pos, _pos+_width);
*/ };
void setThickness(float _thickness); inline void setClippingWidth(const vec2& _pos, const vec2& _width) {
/** setClippingWidth(vec3(_pos.x(),_pos.y(),-1), vec3(_width.x(),_width.y(), 2));
* @brief add a point reference at the current position (this is a vertex reference at the current position };
*/ /**
void addVertex(void); * @brief Request a clipping area for the text (next draw only)
/** * @param[in] _pos Start position of the clipping
* @brief draw a line to a specific position * @param[in] _posEnd End position of the clipping
* @param[in] _dest Position of the end of the line. */
*/ void setClipping(const vec3& _pos, const vec3& _posEnd);
void lineTo(const vec3& _dest); inline void setClipping(const vec2& _pos, const vec2& _posEnd) {
inline void lineTo(const vec2& _dest) { lineTo(vec3(_dest.x(), _dest.y(), 0)); }; setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(), 1));
/** };
* @brief Relative drawing a line (spacial vector) /**
* @param[in] _vect Vector of the curent line. * @brief enable/Disable the clipping (without lose the current clipping position)
*/ * @brief _newMode The new status of the clipping
void lineRel(const vec3& _vect) { lineTo(m_position+_vect); }; */
inline void lineRel(const vec2& _vect) { lineRel(vec3(_vect.x(), _vect.y(), 0)); }; void setClippingMode(bool _newMode) {
/** m_clippingEnable = _newMode;
* @brief draw a 2D rectangle to the position requested. };
* @param[in] _dest Position the the end of the rectangle /**
*/ * @brief Specify the line thickness for the next elements
void rectangle(const vec3& _dest); * @param[in] _thickness The thickness disired for the next print
inline void rectangle(const vec2& _dest) { rectangle(vec3(_dest.x(), _dest.y(), 0)); }; */
/** void setThickness(float _thickness);
* @brief draw a 2D rectangle to the requested size. /**
* @param[in] _size size of the rectangle * @brief add a point reference at the current position (this is a vertex reference at the current position
*/ */
void rectangleWidth(const vec3& _size) { rectangle(m_position+_size); }; void addVertex(void);
inline void rectangleWidth(const vec2& _size) { rectangleWidth(vec3(_size.x(), _size.y(), 0)); }; /**
/** * @brief draw a line to a specific position
* @brief draw a 3D rectangle to the position requested. * @param[in] _dest Position of the end of the line.
* @param[in] _dest Position the the end of the rectangle */
*/ void lineTo(const vec3& _dest);
void cube(const vec3& _dest); inline void lineTo(const vec2& _dest) {
/** lineTo(vec3(_dest.x(), _dest.y(), 0));
* @brief draw a 2D circle with the specify rafdius parameter. };
* @param[in] _radius Distence to the dorder /**
* @param[in] _angleStart start angle of this circle ([0..2PI] otherwithe == > disable) * @brief Relative drawing a line (spacial vector)
* @param[in] _angleStop stop angle of this circle ([0..2PI] otherwithe == > disable) * @param[in] _vect Vector of the curent line.
*/ */
void circle(float _radius, float _angleStart = 0, float _angleStop = 2*M_PI); void lineRel(const vec3& _vect) {
lineTo(m_position+_vect);
};
inline void lineRel(const vec2& _vect) {
lineRel(vec3(_vect.x(), _vect.y(), 0));
};
/**
* @brief draw a 2D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle
*/
void rectangle(const vec3& _dest);
inline void rectangle(const vec2& _dest) {
rectangle(vec3(_dest.x(), _dest.y(), 0));
};
/**
* @brief draw a 2D rectangle to the requested size.
* @param[in] _size size of the rectangle
*/
void rectangleWidth(const vec3& _size) {
rectangle(m_position+_size);
};
inline void rectangleWidth(const vec2& _size) {
rectangleWidth(vec3(_size.x(), _size.y(), 0));
};
/**
* @brief draw a 3D rectangle to the position requested.
* @param[in] _dest Position the the end of the rectangle
*/
void cube(const vec3& _dest);
/**
* @brief draw a 2D circle with the specify rafdius parameter.
* @param[in] _radius Distence to the dorder
* @param[in] _angleStart start angle of this circle ([0..2PI] otherwithe == > disable)
* @param[in] _angleStop stop angle of this circle ([0..2PI] otherwithe == > disable)
*/
void circle(float _radius, float _angleStart = 0, float _angleStop = 2*M_PI);
};
}; };
}; };

View File

@ -10,9 +10,9 @@
#include <ewol/compositing/Image.h> #include <ewol/compositing/Image.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Image" #define __class__ "ewol::compositing::Image"
ewol::Image::Image(const std::string& _imageName) : ewol::compositing::Image::Image(const std::string& _imageName) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
@ -30,12 +30,12 @@ ewol::Image::Image(const std::string& _imageName) :
loadProgram(); loadProgram();
} }
ewol::Image::~Image(void) { ewol::compositing::Image::~Image(void) {
ewol::TextureFile::release(m_resource); ewol::TextureFile::release(m_resource);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Image::loadProgram(void) { void ewol::compositing::Image::loadProgram(void) {
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:textured3D.prog"); m_GLprogram = ewol::Program::keep("DATA:textured3D.prog");
@ -48,7 +48,7 @@ void ewol::Image::loadProgram(void) {
} }
} }
void ewol::Image::draw(bool _disableDepthTest) { void ewol::compositing::Image::draw(bool _disableDepthTest) {
if (m_coord.size() <= 0) { if (m_coord.size() <= 0) {
//EWOL_WARNING("Nothink to draw..."); //EWOL_WARNING("Nothink to draw...");
return; return;
@ -83,9 +83,9 @@ void ewol::Image::draw(bool _disableDepthTest) {
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Image::clear(void) { void ewol::compositing::Image::clear(void) {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::compositing::Compose::clear();
// reset Buffer : // reset Buffer :
m_coord.clear(); m_coord.clear();
m_coordTex.clear(); m_coordTex.clear();
@ -99,7 +99,7 @@ void ewol::Image::clear(void) {
m_angle = 0.0; m_angle = 0.0;
} }
void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd) { void ewol::compositing::Image::setClipping(const vec3& _pos, vec3 _posEnd) {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -125,17 +125,17 @@ void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd) {
m_clippingEnable = true; m_clippingEnable = true;
} }
void ewol::Image::setAngle(float _angle) { void ewol::compositing::Image::setAngle(float _angle) {
m_angle = _angle; m_angle = _angle;
} }
void ewol::Image::print(const vec2& _size) { void ewol::compositing::Image::print(const vec2& _size) {
printPart(_size, vec2(0,0), vec2(1,1)); printPart(_size, vec2(0,0), vec2(1,1));
} }
void ewol::Image::printPart(const vec2& _size, void ewol::compositing::Image::printPart(const vec2& _size,
const vec2& _sourcePosStart, const vec2& _sourcePosStart,
const vec2& _sourcePosStop) { const vec2& _sourcePosStop) {
if (m_angle == 0.0f) { if (m_angle == 0.0f) {
vec3 point = m_position; vec3 point = m_position;
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y()); vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
@ -226,7 +226,7 @@ void ewol::Image::printPart(const vec2& _size,
m_coordColor.push_back(m_color); m_coordColor.push_back(m_color);
} }
void ewol::Image::setSource(const std::string& _newFile, const vec2& _size) { void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) {
clear(); clear();
// remove old one // remove old one
ewol::TextureFile::release(m_resource); ewol::TextureFile::release(m_resource);
@ -241,12 +241,12 @@ void ewol::Image::setSource(const std::string& _newFile, const vec2& _size) {
} }
} }
bool ewol::Image::hasSources(void) { bool ewol::compositing::Image::hasSources(void) {
return m_resource!=NULL; return m_resource!=NULL;
} }
vec2 ewol::Image::getRealSize(void) { vec2 ewol::compositing::Image::getRealSize(void) {
if (NULL == m_resource) { if (NULL == m_resource) {
return vec2(0,0); return vec2(0,0);
} }

View File

@ -10,134 +10,160 @@
#define __EWOL_COMPOSITING_IMAGE_H__ #define __EWOL_COMPOSITING_IMAGE_H__
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol { namespace ewol {
class Image : public ewol::Compositing { namespace compositing {
private: class Image : public ewol::compositing::Compose {
vec3 m_position; //!< The current position to draw private:
vec3 m_clippingPosStart; //!< Clipping start position vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStop; //!< Clipping stop position vec3 m_clippingPosStart; //!< Clipping start position
bool m_clippingEnable; //!< true if the clipping must be activated vec3 m_clippingPosStop; //!< Clipping stop position
private: bool m_clippingEnable; //!< true if the clipping must be activated
etk::Color<> m_color; //!< The text foreground color private:
float m_angle; //!< Angle to set at the axes etk::Color<> m_color; //!< The text foreground color
private: float m_angle; //!< Angle to set at the axes
ewol::Program* m_GLprogram; //!< pointer on the opengl display program private:
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) ewol::Program* m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int32_t m_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) int32_t m_GLtexture; //!< openGL id on the element (Texture position)
private: int32_t m_GLtexID; //!< openGL id on the element (texture ID)
ewol::TextureFile* m_resource; //!< texture resources private:
std::vector<vec3 > m_coord; //!< internal coord of the object ewol::TextureFile* m_resource; //!< texture resources
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
private: std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
/** private:
* @brief load the openGL program and get all the ID needed /**
*/ * @brief load the openGL program and get all the ID needed
void loadProgram(void); */
public: void loadProgram(void);
/** public:
* @brief generic constructor /**
* @param[in] _imageName Name of the file that might be loaded * @brief generic constructor
*/ * @param[in] _imageName Name of the file that might be loaded
Image(const std::string& _imageName=""); */
/** Image(const std::string& _imageName="");
* @brief generic destructor /**
*/ * @brief generic destructor
virtual ~Image(void); */
public: virtual ~Image(void);
/** public:
* @brief draw All the refistered text in the current element on openGL /**
* @param[in] _disableDepthTest disable the Depth test for display * @brief draw All the refistered text in the current element on openGL
*/ * @param[in] _disableDepthTest disable the Depth test for display
void draw(bool _disableDepthTest=true); */
/** void draw(bool _disableDepthTest=true);
* @brief clear alll tre registered element in the current element /**
*/ * @brief clear alll tre registered element in the current element
void clear(void); */
/** void clear(void);
* @brief get the current display position (sometime needed in the gui control) /**
* @return the current position. * @brief get the current display position (sometime needed in the gui control)
*/ * @return the current position.
const vec3& getPos(void) { return m_position; }; */
/** const vec3& getPos(void) {
* @brief set position for the next text writen return m_position;
* @param[in] _pos Position of the text (in 3D) };
*/ /**
void setPos(const vec3& _pos) { m_position = _pos; }; * @brief set position for the next text writen
inline void setPos(const vec2& _pos) { setPos(vec3(_pos.x(),_pos.y(),0)); }; * @param[in] _pos Position of the text (in 3D)
/** */
* @brief set relative position for the next text writen void setPos(const vec3& _pos) {
* @param[in] _pos ofset apply of the text (in 3D) m_position = _pos;
*/ };
void setRelPos(const vec3& _pos) { m_position += _pos; }; inline void setPos(const vec2& _pos) {
inline void setRelPos(const vec2& _pos) { setRelPos(vec3(_pos.x(),_pos.y(),0)); }; setPos(vec3(_pos.x(),_pos.y(),0));
/** };
* @brief set the Color of the current foreground font /**
* @param[in] _color Color to set on foreground (for next print) * @brief set relative position for the next text writen
*/ * @param[in] _pos ofset apply of the text (in 3D)
void setColor(const etk::Color<>& _color) { m_color = _color; }; */
/** void setRelPos(const vec3& _pos) {
* @brief Request a clipping area for the text (next draw only) m_position += _pos;
* @param[in] _pos Start position of the clipping };
* @param[in] _width Width size of the clipping inline void setRelPos(const vec2& _pos) {
*/ setRelPos(vec3(_pos.x(),_pos.y(),0));
void setClippingWidth(const vec3& _pos, vec3 _width) { setClipping(_pos, _pos+_width); }; };
inline void setClippingWidth(const vec2& _pos, const vec2& _width) { setClippingWidth(vec3(_pos.x(),_pos.y(),0), vec3(_width.x(),_width.y(),0)); }; /**
/** * @brief set the Color of the current foreground font
* @brief Request a clipping area for the text (next draw only) * @param[in] _color Color to set on foreground (for next print)
* @param[in] _pos Start position of the clipping */
* @param[in] _posEnd End position of the clipping void setColor(const etk::Color<>& _color) {
*/ m_color = _color;
void setClipping(const vec3& _pos, vec3 _posEnd); };
inline void setClipping(const vec2& _pos, const vec2& _posEnd) { setClipping(vec3(_pos.x(),_pos.y(),0), vec3(_posEnd.x(),_posEnd.y(),0)); }; /**
/** * @brief Request a clipping area for the text (next draw only)
* @brief enable/Disable the clipping (without lose the current clipping position) * @param[in] _pos Start position of the clipping
* @brief _newMode The new status of the clipping * @param[in] _width Width size of the clipping
*/ */
void setClippingMode(bool _newMode) { m_clippingEnable = _newMode; }; void setClippingWidth(const vec3& _pos, vec3 _width) {
/** setClipping(_pos, _pos+_width);
* @brief set a unique rotation of this element (not set in the rotate Generic system) };
* @param[in] _angle Angle to set in radiant. inline void setClippingWidth(const vec2& _pos, const vec2& _width) {
*/ setClippingWidth(vec3(_pos.x(),_pos.y(),0), vec3(_width.x(),_width.y(),0));
void setAngle(float _angleRad); };
/** /**
* @brief add a compleate of the image to display with the requested size * @brief Request a clipping area for the text (next draw only)
* @param[in] _size size of the output image * @param[in] _pos Start position of the clipping
*/ * @param[in] _posEnd End position of the clipping
void print(const ivec2& _size) { print(vec2(_size.x(),_size.y())); }; */
void print(const vec2& _size); void setClipping(const vec3& _pos, vec3 _posEnd);
/** inline void setClipping(const vec2& _pos, const vec2& _posEnd) {
* @brief add a part of the image to display with the requested size setClipping(vec3(_pos.x(),_pos.y(),0), vec3(_posEnd.x(),_posEnd.y(),0));
* @param[in] _size size of the output image };
* @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image). /**
* @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image). * @brief enable/Disable the clipping (without lose the current clipping position)
*/ * @brief _newMode The new status of the clipping
void printPart(const vec2& _size, */
const vec2& _sourcePosStart, void setClippingMode(bool _newMode) {
const vec2& _sourcePosStop); m_clippingEnable = _newMode;
/** };
* @brief change the image Source == > can not be done to display 2 images at the same time ... /**
* @param[in] _newFile New file of the Image * @brief set a unique rotation of this element (not set in the rotate Generic system)
* @param[in] _size for the image when Verctorial image loading is requested * @param[in] _angle Angle to set in radiant.
*/ */
void setSource(const std::string& _newFile, int32_t _size=32) { setSource(_newFile, vec2(_size,_size)); }; void setAngle(float _angleRad);
void setSource(const std::string& _newFile, const vec2& _size); /**
/** * @brief add a compleate of the image to display with the requested size
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. * @param[in] _size size of the output image
* @return the validity od the resources. */
*/ void print(const ivec2& _size) {
bool hasSources(void); print(vec2(_size.x(),_size.y()));
/** };
* @brief get the source image registered size in the file (<0 when multiple size image) void print(const vec2& _size);
* @return tre image registered size /**
*/ * @brief add a part of the image to display with the requested size
vec2 getRealSize(void); * @param[in] _size size of the output image
* @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image).
* @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image).
*/
void printPart(const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop);
/**
* @brief change the image Source == > can not be done to display 2 images at the same time ...
* @param[in] _newFile New file of the Image
* @param[in] _size for the image when Verctorial image loading is requested
*/
void setSource(const std::string& _newFile, int32_t _size=32) {
setSource(_newFile, vec2(_size,_size));
};
void setSource(const std::string& _newFile, const vec2& _size);
/**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources.
*/
bool hasSources(void);
/**
* @brief get the source image registered size in the file (<0 when multiple size image)
* @return tre image registered size
*/
vec2 getRealSize(void);
};
}; };
}; };

View File

@ -11,9 +11,9 @@
#include <ewol/compositing/Shaper.h> #include <ewol/compositing/Shaper.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Shaper" #define __class__ "ewol::compositing::Shaper"
ewol::Shaper::Shaper(const std::string& _shaperName) : ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
m_name(_shaperName), m_name(_shaperName),
m_config(NULL), m_config(NULL),
m_confIdPaddingX(-1), m_confIdPaddingX(-1),
@ -42,17 +42,17 @@ ewol::Shaper::Shaper(const std::string& _shaperName) :
updateVertex(); updateVertex();
} }
ewol::Shaper::~Shaper(void) { ewol::compositing::Shaper::~Shaper(void) {
unLoadProgram(); unLoadProgram();
} }
void ewol::Shaper::unLoadProgram(void) { void ewol::compositing::Shaper::unLoadProgram(void) {
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
ewol::TextureFile::release(m_resourceTexture); ewol::TextureFile::release(m_resourceTexture);
ewol::ConfigFile::release(m_config); ewol::ConfigFile::release(m_config);
} }
void ewol::Shaper::loadProgram(void) { void ewol::compositing::Shaper::loadProgram(void) {
if (m_name == "") { if (m_name == "") {
EWOL_DEBUG("no Shaper set for loading resources ..."); EWOL_DEBUG("no Shaper set for loading resources ...");
return; return;
@ -98,7 +98,7 @@ void ewol::Shaper::loadProgram(void) {
} }
} }
void ewol::Shaper::draw(bool _disableDepthTest) { void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
if (m_config == NULL) { if (m_config == NULL) {
// this is a normale case ... the user can choice to have no config basic file ... // this is a normale case ... the user can choice to have no config basic file ...
return; return;
@ -132,11 +132,11 @@ void ewol::Shaper::draw(bool _disableDepthTest) {
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Shaper::clear(void) { void ewol::compositing::Shaper::clear(void) {
// nothing to do ... // nothing to do ...
} }
bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) { bool ewol::compositing::Shaper::changeStatusIn(int32_t _newStatusId) {
if (_newStatusId != m_stateNew) { if (_newStatusId != m_stateNew) {
m_nextStatusRequested = _newStatusId; m_nextStatusRequested = _newStatusId;
return true; return true;
@ -148,7 +148,7 @@ bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) {
return false; return false;
} }
bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) { bool ewol::compositing::Shaper::periodicCall(const ewol::EventTime& _event) {
//EWOL_DEBUG("call=" << _event); //EWOL_DEBUG("call=" << _event);
// start : // start :
if (m_stateTransition >= 1.0) { if (m_stateTransition >= 1.0) {
@ -186,7 +186,7 @@ bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) {
return true; return true;
} }
void ewol::Shaper::updateVertex(void) { void ewol::compositing::Shaper::updateVertex(void) {
// set coord == > must be a static VBO ... // set coord == > must be a static VBO ...
m_coord[0].setValue( m_propertyOrigin.x(), m_coord[0].setValue( m_propertyOrigin.x(),
m_propertyOrigin.y()+m_propertySize.y()); m_propertyOrigin.y()+m_propertySize.y());
@ -203,29 +203,29 @@ void ewol::Shaper::updateVertex(void) {
m_propertyOrigin.y()+m_propertySize.y()); m_propertyOrigin.y()+m_propertySize.y());
} }
void ewol::Shaper::setOrigin(const vec2& _newOri) { void ewol::compositing::Shaper::setOrigin(const vec2& _newOri) {
if (m_propertyOrigin != _newOri) { if (m_propertyOrigin != _newOri) {
m_propertyOrigin = _newOri; m_propertyOrigin = _newOri;
updateVertex(); updateVertex();
} }
} }
void ewol::Shaper::setSize(const vec2& _newSize) { void ewol::compositing::Shaper::setSize(const vec2& _newSize) {
if (m_propertySize != _newSize) { if (m_propertySize != _newSize) {
m_propertySize = _newSize; m_propertySize = _newSize;
updateVertex(); updateVertex();
} }
} }
void ewol::Shaper::setInsideSize(const vec2& _newInsideSize) { void ewol::compositing::Shaper::setInsideSize(const vec2& _newInsideSize) {
m_propertyInsideSize = _newInsideSize; m_propertyInsideSize = _newInsideSize;
} }
void ewol::Shaper::setInsidePos(const vec2& _newInsidePos) { void ewol::compositing::Shaper::setInsidePos(const vec2& _newInsidePos) {
m_propertyInsidePosition = _newInsidePos; m_propertyInsidePosition = _newInsidePos;
} }
vec2 ewol::Shaper::getPadding(void) { vec2 ewol::compositing::Shaper::getPadding(void) {
vec2 padding(0,0); vec2 padding(0,0);
if (m_config!=NULL) { if (m_config!=NULL) {
padding.setValue(m_config->getFloat(m_confIdPaddingX), padding.setValue(m_config->getFloat(m_confIdPaddingX),
@ -234,14 +234,14 @@ vec2 ewol::Shaper::getPadding(void) {
return padding; return padding;
} }
void ewol::Shaper::setSource(const std::string& _newFile) { void ewol::compositing::Shaper::setSource(const std::string& _newFile) {
clear(); clear();
unLoadProgram(); unLoadProgram();
m_name = _newFile; m_name = _newFile;
loadProgram(); loadProgram();
} }
bool ewol::Shaper::hasSources(void) { bool ewol::compositing::Shaper::hasSources(void) {
return m_GLprogram!=NULL; return m_GLprogram!=NULL;
} }

View File

@ -10,152 +10,162 @@
#define __EWOL_COMPOSITING_SHAPER_H__ #define __EWOL_COMPOSITING_SHAPER_H__
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <ewol/renderer/EventTime.h> #include <ewol/renderer/EventTime.h>
namespace ewol { namespace ewol {
/** namespace compositing {
* @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files /**
*/ * @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files
// TODO : load image */
// TODO : Abstaraction between states (call by name and the system greate IDs // TODO : load image
class Shaper : public ewol::Compositing { // TODO : Abstaraction between states (call by name and the system greate IDs
private: class Shaper : public ewol::compositing::Compose {
std::string m_name; //!< Name of the configuration of the shaper. private:
// External theme config: std::string m_name; //!< Name of the configuration of the shaper.
ewol::ConfigFile* m_config; //!< pointer on the config file resources // External theme config:
int32_t m_confIdPaddingX; //!< ConfigFile padding property X ewol::ConfigFile* m_config; //!< pointer on the config file resources
int32_t m_confIdPaddingY; //!< ConfigFile padding property Y int32_t m_confIdPaddingX; //!< ConfigFile padding property X
int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property int32_t m_confIdPaddingY; //!< ConfigFile padding property Y
int32_t m_confProgramFile; //!< ConfigFile opengGl program Name int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property
int32_t m_confImageFile; //!< ConfigFile opengGl program Name int32_t m_confProgramFile; //!< ConfigFile opengGl program Name
// openGL shaders programs: int32_t m_confImageFile; //!< ConfigFile opengGl program Name
ewol::Program* m_GLprogram; //!< pointer on the opengl display program // openGL shaders programs:
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) ewol::Program* m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLPropertySize; //!< openGL id on the element (widget size) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLPropertyOrigin; //!< openGL id on the element (widget origin) int32_t m_GLPropertySize; //!< openGL id on the element (widget size)
int32_t m_GLPropertyInsidePos; //!< openGL id on the element (widget internal element position) int32_t m_GLPropertyOrigin; //!< openGL id on the element (widget origin)
int32_t m_GLPropertyInsideSize; //!< openGL id on the element (widget internal element size) int32_t m_GLPropertyInsidePos; //!< openGL id on the element (widget internal element position)
int32_t m_GLStateOld; //!< openGL id on the element (old state displayed) int32_t m_GLPropertyInsideSize; //!< openGL id on the element (widget internal element size)
int32_t m_GLStateNew; //!< openGL id on the element (new state displayed) int32_t m_GLStateOld; //!< openGL id on the element (old state displayed)
int32_t m_GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] ) int32_t m_GLStateNew; //!< openGL id on the element (new state displayed)
int32_t m_GLtexID; //!< openGL id on the element (texture image) int32_t m_GLStateTransition; //!< openGL id on the element (transition ofset [0.0..1.0] )
// For the Image : int32_t m_GLtexID; //!< openGL id on the element (texture image)
ewol::TextureFile* m_resourceTexture; //!< texture resources (for the image) // For the Image :
// internal needed data : ewol::TextureFile* m_resourceTexture; //!< texture resources (for the image)
int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it // internal needed data :
vec2 m_propertyOrigin; //!< widget origin int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it
vec2 m_propertySize; //!< widget size vec2 m_propertyOrigin; //!< widget origin
vec2 m_propertyInsidePosition; //!< internal subwidget position vec2 m_propertySize; //!< widget size
vec2 m_propertyInsideSize; //!< internal subwidget size vec2 m_propertyInsidePosition; //!< internal subwidget position
int32_t m_stateOld; //!< previous state vec2 m_propertyInsideSize; //!< internal subwidget size
int32_t m_stateNew; //!< destination state int32_t m_stateOld; //!< previous state
float m_stateTransition; //!< working state between 2 states int32_t m_stateNew; //!< destination state
vec2 m_coord[6]; //!< the double triangle coordonates float m_stateTransition; //!< working state between 2 states
private: vec2 m_coord[6]; //!< the double triangle coordonates
/** private:
* @brief load the openGL program and get all the ID needed /**
*/ * @brief load the openGL program and get all the ID needed
void loadProgram(void); */
/** void loadProgram(void);
* @brief Un-Load the openGL program and get all the ID needed /**
*/ * @brief Un-Load the openGL program and get all the ID needed
void unLoadProgram(void); */
public: void unLoadProgram(void);
/** public:
* @brief generic constructor /**
* @param[in] _shaperName Name of the file that might be loaded * @brief generic constructor
*/ * @param[in] _shaperName Name of the file that might be loaded
Shaper(const std::string& _shaperName=""); */
/** Shaper(const std::string& _shaperName="");
* @brief generic destructor /**
*/ * @brief generic destructor
~Shaper(void); */
public: ~Shaper(void);
/** public:
* @brief draw All the refistered text in the current element on openGL /**
*/ * @brief draw All the refistered text in the current element on openGL
void draw(bool _disableDepthTest=true); */
/** void draw(bool _disableDepthTest=true);
* @brief clear alll tre registered element in the current element /**
*/ * @brief clear alll tre registered element in the current element
void clear(void); */
/** void clear(void);
* @brief change the current status in an other /**
* @param[in] _newStatusId the next new status requested * @brief change the current status in an other
* @return true The widget must call this fuction periodicly (and redraw itself) * @param[in] _newStatusId the next new status requested
* @return false No need to request the periodic call. * @return true The widget must call this fuction periodicly (and redraw itself)
*/ * @return false No need to request the periodic call.
bool changeStatusIn(int32_t _newStatusId); */
/** bool changeStatusIn(int32_t _newStatusId);
* @brief get the current displayed status of the shaper /**
* @return The Status Id * @brief get the current displayed status of the shaper
*/ * @return The Status Id
int32_t getCurrentDisplayedStatus(void) { return m_stateNew; }; */
/** int32_t getCurrentDisplayedStatus(void) {
* @brief get the next displayed status of the shaper return m_stateNew;
* @return The next status Id (-1 if no status in next) };
*/ /**
int32_t getNextDisplayedStatus(void) { return m_nextStatusRequested; }; * @brief get the next displayed status of the shaper
/** * @return The next status Id (-1 if no status in next)
* @brief get the current trasion status */
* @return value of the transition status (0.0f when no activity) int32_t getNextDisplayedStatus(void) {
*/ return m_nextStatusRequested;
float getTransitionStatus(void) { return m_stateTransition; }; };
/** /**
* @brief Same as the widfget periodic call (this is for change display) * @brief get the current trasion status
* @param[in] _event The current time of the call. * @return value of the transition status (0.0f when no activity)
* @return true The widget must call this fuction periodicly (and redraw itself) */
* @return false No need to request the periodic call. float getTransitionStatus(void) {
*/ return m_stateTransition;
bool periodicCall(const ewol::EventTime& _event); };
/** /**
* @brief set the widget origin (needed fot the display) * @brief Same as the widfget periodic call (this is for change display)
* @param[in] _newOri : the new widget origin * @param[in] _event The current time of the call.
*/ * @return true The widget must call this fuction periodicly (and redraw itself)
void setOrigin(const vec2& _newOri); * @return false No need to request the periodic call.
/** */
* @brief set the widget size (needed fot the display) bool periodicCall(const ewol::EventTime& _event);
* @param[in] _newSize : the new widget size /**
*/ * @brief set the widget origin (needed fot the display)
void setSize(const vec2& _newSize); * @param[in] _newOri : the new widget origin
/** */
* @brief set the internal widget size void setOrigin(const vec2& _newOri);
* @param[in] _newInsidePos : the subelement size. /**
*/ * @brief set the widget size (needed fot the display)
void setInsideSize(const vec2& _newInsideSize); * @param[in] _newSize : the new widget size
/** */
* @brief set the internal widget position void setSize(const vec2& _newSize);
* @param[in] _newInsidePos : the subelement position /**
*/ * @brief set the internal widget size
void setInsidePos(const vec2& _newInsidePos); * @param[in] _newInsidePos : the subelement size.
/** */
* @brief get the padding declared by the user in the config file void setInsideSize(const vec2& _newInsideSize);
* @return the padding property /**
*/ * @brief set the internal widget position
vec2 getPadding(void); * @param[in] _newInsidePos : the subelement position
/** */
* @brief change the shaper Source void setInsidePos(const vec2& _newInsidePos);
* @param[in] _newFile New file of the shaper /**
*/ * @brief get the padding declared by the user in the config file
void setSource(const std::string& _newFile); * @return the padding property
/** */
* @brief get the shaper file Source vec2 getPadding(void);
* @return the shapper file name /**
*/ * @brief change the shaper Source
const std::string& getSource(void) const { return m_name; }; * @param[in] _newFile New file of the shaper
/** */
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. void setSource(const std::string& _newFile);
* @return the validity od the resources. /**
*/ * @brief get the shaper file Source
bool hasSources(void); * @return the shapper file name
private: */
/** const std::string& getSource(void) const {
* @brief update the internal vertex table. return m_name;
*/ };
void updateVertex(void); /**
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
* @return the validity od the resources.
*/
bool hasSources(void);
private:
/**
* @brief update the internal vertex table.
*/
void updateVertex(void);
};
}; };
}; };

View File

@ -10,9 +10,9 @@
#include <ewol/compositing/Sprite.h> #include <ewol/compositing/Sprite.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Sprite" #define __class__ "ewol::compositing::Sprite"
ewol::Sprite::Sprite(const std::string& _imageName, const ivec2& _nbSprite) : ewol::compositing::Sprite::Sprite(const std::string& _imageName, const ivec2& _nbSprite) :
ewol::Image(_imageName), ewol::Image(_imageName),
m_nbSprite(_nbSprite), m_nbSprite(_nbSprite),
m_unitarySpriteSize(0,0) { m_unitarySpriteSize(0,0) {
@ -26,7 +26,7 @@ ewol::Sprite::Sprite(const std::string& _imageName, const ivec2& _nbSprite) :
} }
void ewol::Sprite::printSprite(const ivec2& _spriteID, const vec3& _size) { void ewol::compositing::Sprite::printSprite(const ivec2& _spriteID, const vec3& _size) {
if( _spriteID.x()<0 if( _spriteID.x()<0
|| _spriteID.y()<0 || _spriteID.y()<0
|| _spriteID.x() >= m_nbSprite.x() || _spriteID.x() >= m_nbSprite.x()

View File

@ -14,15 +14,17 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
namespace ewol { namespace ewol {
class Sprite : public ewol::Image { namespace compositing {
protected: class Sprite : public ewol::compositing::Compose {
ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal protected:
vec2 m_unitarySpriteSize; //!< size of a unique sprite ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal
public: vec2 m_unitarySpriteSize; //!< size of a unique sprite
Sprite(const std::string& _imageName, const ivec2& _nbSprite); public:
virtual ~Sprite() {}; Sprite(const std::string& _imageName, const ivec2& _nbSprite);
void printSprite(const ivec2& _spriteID, const vec2& _size) { printSprite(_spriteID, vec3(_size.x(), _size.y(),0)); }; virtual ~Sprite() {};
void printSprite(const ivec2& _spriteID, const vec3& _size); void printSprite(const ivec2& _spriteID, const vec2& _size) { printSprite(_spriteID, vec3(_size.x(), _size.y(),0)); };
void printSprite(const ivec2& _spriteID, const vec3& _size);
};
}; };
}; };

View File

@ -12,10 +12,10 @@
#include <etk/UString.h> #include <etk/UString.h>
#undef __class__ #undef __class__
#define __class__ "ewol::Text" #define __class__ "ewol::compositing::Text"
ewol::Text::Text(const std::string& _fontName, int32_t _fontSize) : ewol::compositing::Text::Text(const std::string& _fontName, int32_t _fontSize) :
m_position(0.0, 0.0, 0.0), m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0), m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0), m_clippingPosStop(0.0, 0.0, 0.0),
@ -45,12 +45,12 @@ ewol::Text::Text(const std::string& _fontName, int32_t _fontSize) :
} }
ewol::Text::~Text(void) { ewol::compositing::Text::~Text(void) {
ewol::TexturedFont::release(m_font); ewol::TexturedFont::release(m_font);
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Text::loadProgram(void) { void ewol::compositing::Text::loadProgram(void) {
// get the shader resource : // get the shader resource :
m_GLPosition = 0; m_GLPosition = 0;
m_GLprogram = ewol::Program::keep("DATA:text.prog"); m_GLprogram = ewol::Program::keep("DATA:text.prog");
@ -63,7 +63,7 @@ void ewol::Text::loadProgram(void) {
} }
} }
void ewol::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest) { void ewol::compositing::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); m_vectorialDraw.draw();
@ -107,7 +107,7 @@ void ewol::Text::draw(const mat4& _transformationMatrix, bool _enableDepthTest)
} }
void ewol::Text::draw(bool _disableDepthTest) { void ewol::compositing::Text::draw(bool _disableDepthTest) {
// draw BG in any case: // draw BG in any case:
m_vectorialDraw.draw(); m_vectorialDraw.draw();
@ -141,22 +141,22 @@ void ewol::Text::draw(bool _disableDepthTest) {
m_GLprogram->unUse(); m_GLprogram->unUse();
} }
void ewol::Text::translate(const vec3& _vect) { void ewol::compositing::Text::translate(const vec3& _vect) {
ewol::Compositing::translate(_vect); ewol::Compositing::translate(_vect);
m_vectorialDraw.translate(_vect); m_vectorialDraw.translate(_vect);
} }
void ewol::Text::rotate(const vec3& _vect, float _angle) { void ewol::compositing::Text::rotate(const vec3& _vect, float _angle) {
ewol::Compositing::rotate(_vect, _angle); ewol::Compositing::rotate(_vect, _angle);
m_vectorialDraw.rotate(_vect, _angle); m_vectorialDraw.rotate(_vect, _angle);
} }
void ewol::Text::scale(const vec3& _vect) { void ewol::compositing::Text::scale(const vec3& _vect) {
ewol::Compositing::scale(_vect); ewol::Compositing::scale(_vect);
m_vectorialDraw.scale(_vect); m_vectorialDraw.scale(_vect);
} }
void ewol::Text::clear(void) { void ewol::compositing::Text::clear(void) {
// call upper class // call upper class
ewol::Compositing::clear(); ewol::Compositing::clear();
// remove sub draw system // remove sub draw system
@ -169,7 +169,7 @@ void ewol::Text::clear(void) {
reset(); reset();
} }
void ewol::Text::reset(void) { void ewol::compositing::Text::reset(void) {
m_position = vec3(0,0,0); m_position = vec3(0,0,0);
m_clippingPosStart = vec3(0,0,0); m_clippingPosStart = vec3(0,0,0);
m_clippingPosStop = vec3(0,0,0); m_clippingPosStop = vec3(0,0,0);
@ -192,7 +192,7 @@ void ewol::Text::reset(void) {
m_nbCharDisplayed = 0; m_nbCharDisplayed = 0;
} }
void ewol::Text::setPos(const vec3& _pos) { void ewol::compositing::Text::setPos(const vec3& _pos) {
// check min max for display area // check min max for display area
if (m_nbCharDisplayed != 0) { if (m_nbCharDisplayed != 0) {
EWOL_VERBOSE("update size 1 " << m_sizeDisplayStart << " " << m_sizeDisplayStop); EWOL_VERBOSE("update size 1 " << m_sizeDisplayStart << " " << m_sizeDisplayStop);
@ -222,18 +222,18 @@ void ewol::Text::setPos(const vec3& _pos) {
} }
} }
void ewol::Text::setRelPos(const vec3& _pos) { void ewol::compositing::Text::setRelPos(const vec3& _pos) {
m_position += _pos; m_position += _pos;
m_previousCharcode = 0; m_previousCharcode = 0;
m_vectorialDraw.setPos(m_position); m_vectorialDraw.setPos(m_position);
} }
void ewol::Text::setColorBg(const etk::Color<>& _color) { void ewol::compositing::Text::setColorBg(const etk::Color<>& _color) {
m_colorBg = _color; m_colorBg = _color;
m_vectorialDraw.setColor(_color); m_vectorialDraw.setColor(_color);
} }
void ewol::Text::setClipping(const vec3& _pos, const vec3& _posEnd) { void ewol::compositing::Text::setClipping(const vec3& _pos, const vec3& _posEnd) {
// note the internal system all time request to have a bounding all time in the same order // note the internal system all time request to have a bounding all time in the same order
if (_pos.x() <= _posEnd.x()) { if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x()); m_clippingPosStart.setX(_pos.x());
@ -260,12 +260,12 @@ void ewol::Text::setClipping(const vec3& _pos, const vec3& _posEnd) {
//m_vectorialDraw.setClipping(m_clippingPosStart, m_clippingPosStop); //m_vectorialDraw.setClipping(m_clippingPosStart, m_clippingPosStop);
} }
void ewol::Text::setClippingMode(bool _newMode) { void ewol::compositing::Text::setClippingMode(bool _newMode) {
m_clippingEnable = _newMode; m_clippingEnable = _newMode;
//m_vectorialDraw.setClippingMode(m_clippingEnable); //m_vectorialDraw.setClippingMode(m_clippingEnable);
} }
void ewol::Text::setFontSize(int32_t _fontSize) { void ewol::compositing::Text::setFontSize(int32_t _fontSize) {
// get old size // get old size
std::string fontName = ""; std::string fontName = "";
if (m_font != NULL) { if (m_font != NULL) {
@ -277,7 +277,7 @@ void ewol::Text::setFontSize(int32_t _fontSize) {
setFont(fontName, _fontSize); setFont(fontName, _fontSize);
} }
void ewol::Text::setFontName(const std::string& _fontName) { void ewol::compositing::Text::setFontName(const std::string& _fontName) {
// get old size // get old size
int32_t fontSize = -1; int32_t fontSize = -1;
if (m_font != NULL) { if (m_font != NULL) {
@ -286,7 +286,7 @@ void ewol::Text::setFontName(const std::string& _fontName) {
setFont(_fontName, fontSize); setFont(_fontName, fontSize);
} }
void ewol::Text::setFont(std::string _fontName, int32_t _fontSize) { void ewol::compositing::Text::setFont(std::string _fontName, int32_t _fontSize) {
clear(); clear();
// remove old one // remove old one
ewol::TexturedFont * previousFont = m_font; ewol::TexturedFont * previousFont = m_font;
@ -309,7 +309,7 @@ void ewol::Text::setFont(std::string _fontName, int32_t _fontSize) {
} }
} }
void ewol::Text::setFontMode(enum ewol::font::mode _mode) { void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) {
if (m_font != NULL) { if (m_font != NULL) {
m_mode = m_font->getWrappingMode(_mode); m_mode = m_font->getWrappingMode(_mode);
} }
@ -319,7 +319,7 @@ enum ewol::font::mode ewol::Text::getFontMode(void) {
return m_mode; return m_mode;
} }
void ewol::Text::setFontBold(bool _status) { void ewol::compositing::Text::setFontBold(bool _status) {
if (_status == true) { if (_status == true) {
// enable // enable
if (m_mode == ewol::font::Regular) { if (m_mode == ewol::font::Regular) {
@ -337,7 +337,7 @@ void ewol::Text::setFontBold(bool _status) {
} }
} }
void ewol::Text::setFontItalic(bool _status) { void ewol::compositing::Text::setFontItalic(bool _status) {
if (_status == true) { if (_status == true) {
// enable // enable
if (m_mode == ewol::font::Regular) { if (m_mode == ewol::font::Regular) {
@ -355,27 +355,27 @@ void ewol::Text::setFontItalic(bool _status) {
} }
} }
void ewol::Text::setKerningMode(bool _newMode) { void ewol::compositing::Text::setKerningMode(bool _newMode) {
m_kerning = _newMode; m_kerning = _newMode;
} }
void ewol::Text::setDistanceFieldMode(bool _newMode) { void ewol::compositing::Text::setDistanceFieldMode(bool _newMode) {
m_distanceField = _newMode; m_distanceField = _newMode;
EWOL_TODO("The Distance field mode is not availlable for now ..."); EWOL_TODO("The Distance field mode is not availlable for now ...");
} }
void ewol::Text::print(const std::u32string& _text) { void ewol::compositing::Text::print(const std::u32string& _text) {
std::vector<TextDecoration> decorationEmpty; std::vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty); print(_text, decorationEmpty);
} }
void ewol::Text::print(const std::string& _text) { void ewol::compositing::Text::print(const std::string& _text) {
std::vector<TextDecoration> decorationEmpty; std::vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty); print(_text, decorationEmpty);
} }
void ewol::Text::parseHtmlNode(exml::Element* _element) { void ewol::compositing::Text::parseHtmlNode(exml::Element* _element) {
// get the static real pointer // get the static real pointer
if (_element == NULL) { if (_element == NULL) {
EWOL_ERROR( "Error Input node does not existed ..."); EWOL_ERROR( "Error Input node does not existed ...");
@ -470,7 +470,7 @@ void ewol::Text::parseHtmlNode(exml::Element* _element) {
} }
} }
void ewol::Text::printDecorated(const std::string& _text) { void ewol::compositing::Text::printDecorated(const std::string& _text) {
std::string tmpData("<html>\n<body>\n"); std::string tmpData("<html>\n<body>\n");
tmpData+=_text; tmpData+=_text;
tmpData+="\n</body>\n</html>\n"; tmpData+="\n</body>\n</html>\n";
@ -478,7 +478,7 @@ void ewol::Text::printDecorated(const std::string& _text) {
printHTML(tmpData); printHTML(tmpData);
} }
void ewol::Text::printHTML(const std::string& _text) { void ewol::compositing::Text::printHTML(const std::string& _text) {
exml::Document doc; exml::Document doc;
// reset parameter : // reset parameter :
@ -506,7 +506,7 @@ void ewol::Text::printHTML(const std::string& _text) {
htmlFlush(); htmlFlush();
} }
void ewol::Text::print(const std::string& _text, const std::vector<TextDecoration>& _decoration) { void ewol::compositing::Text::print(const std::string& _text, const std::vector<TextDecoration>& _decoration) {
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return; return;
@ -695,7 +695,7 @@ void ewol::Text::print(const std::string& _text, const std::vector<TextDecoratio
} }
} }
void ewol::Text::print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration) { void ewol::compositing::Text::print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration) {
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return; return;
@ -885,7 +885,7 @@ void ewol::Text::print(const std::u32string& _text, const std::vector<TextDecora
} }
void ewol::Text::print(const char32_t& _charcode) { void ewol::compositing::Text::print(const char32_t& _charcode) {
if (NULL == m_font) { if (NULL == m_font) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return; return;
@ -1056,12 +1056,12 @@ void ewol::Text::print(const char32_t& _charcode) {
return; return;
} }
void ewol::Text::forceLineReturn(void) { void ewol::compositing::Text::forceLineReturn(void) {
// reset position : // reset position :
setPos(vec3(m_startTextpos, m_position.y() - m_font->getHeight(m_mode), 0) ); setPos(vec3(m_startTextpos, m_position.y() - m_font->getHeight(m_mode), 0) );
} }
void ewol::Text::setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement) { void ewol::compositing::Text::setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement) {
m_startTextpos = _startTextpos; m_startTextpos = _startTextpos;
m_stopTextPos = _stopTextPos+1; m_stopTextPos = _stopTextPos+1;
m_alignement = _alignement; m_alignement = _alignement;
@ -1070,15 +1070,15 @@ void ewol::Text::setTextAlignement(float _startTextpos, float _stopTextPos, enum
} }
} }
enum ewol::Text::aligneMode ewol::Text::getAlignement(void) { enum ewol::compositing::Text::aligneMode ewol::compositing::Text::getAlignement(void) {
return m_alignement; return m_alignement;
} }
void ewol::Text::disableAlignement(void) { void ewol::compositing::Text::disableAlignement(void) {
m_alignement = ewol::Text::alignDisable; m_alignement = ewol::Text::alignDisable;
} }
vec3 ewol::Text::calculateSizeHTML(const std::string& _text) { vec3 ewol::compositing::Text::calculateSizeHTML(const std::string& _text) {
// remove intermediate result // remove intermediate result
reset(); reset();
//EWOL_DEBUG(" 0 size for=\n" << text); //EWOL_DEBUG(" 0 size for=\n" << text);
@ -1109,7 +1109,7 @@ vec3 ewol::Text::calculateSizeHTML(const std::string& _text) {
m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); m_sizeDisplayStop.z()-m_sizeDisplayStart.z());
} }
vec3 ewol::Text::calculateSizeDecorated(const std::string& _text) { vec3 ewol::compositing::Text::calculateSizeDecorated(const std::string& _text) {
if (_text.size() == 0) { if (_text.size() == 0) {
return vec3(0,0,0); return vec3(0,0,0);
} }
@ -1120,7 +1120,7 @@ vec3 ewol::Text::calculateSizeDecorated(const std::string& _text) {
return tmpVal; return tmpVal;
} }
vec3 ewol::Text::calculateSize(const std::string& _text) { vec3 ewol::compositing::Text::calculateSize(const std::string& _text) {
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0); return vec3(0,0,0);
@ -1136,7 +1136,7 @@ vec3 ewol::Text::calculateSize(const std::string& _text) {
return outputSize; return outputSize;
} }
vec3 ewol::Text::calculateSize(const char32_t& _charcode) { vec3 ewol::compositing::Text::calculateSize(const char32_t& _charcode) {
if (m_font == NULL) { if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined"); EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0); return vec3(0,0,0);
@ -1159,8 +1159,7 @@ vec3 ewol::Text::calculateSize(const char32_t& _charcode) {
return outputSize; return outputSize;
} }
void ewol::compositing::Text::printCursor(bool _isInsertMode, float _cursorSize) {
void ewol::Text::printCursor(bool _isInsertMode, float _cursorSize) {
int32_t fontHeigh = m_font->getHeight(m_mode); int32_t fontHeigh = m_font->getHeight(m_mode);
if (true == _isInsertMode) { if (true == _isInsertMode) {
m_vectorialDraw.rectangleWidth(vec3(_cursorSize, fontHeigh, 0) ); m_vectorialDraw.rectangleWidth(vec3(_cursorSize, fontHeigh, 0) );
@ -1171,12 +1170,11 @@ void ewol::Text::printCursor(bool _isInsertMode, float _cursorSize) {
} }
} }
bool ewol::compositing::Text::extrapolateLastId(const std::string& _text,
bool ewol::Text::extrapolateLastId(const std::string& _text, const int32_t _start,
const int32_t _start, int32_t& _stop,
int32_t& _stop, int32_t& _space,
int32_t& _space, int32_t& _freeSpace) {
int32_t& _freeSpace) {
// store previous : // store previous :
char32_t storePrevious = m_previousCharcode; char32_t storePrevious = m_previousCharcode;
@ -1235,11 +1233,11 @@ bool ewol::Text::extrapolateLastId(const std::string& _text,
} }
} }
bool ewol::Text::extrapolateLastId(const std::u32string& _text, bool ewol::compositing::Text::extrapolateLastId(const std::u32string& _text,
const int32_t _start, const int32_t _start,
int32_t& _stop, int32_t& _stop,
int32_t& _space, int32_t& _space,
int32_t& _freeSpace) { int32_t& _freeSpace) {
// store previous : // store previous :
char32_t storePrevious = m_previousCharcode; char32_t storePrevious = m_previousCharcode;
@ -1298,7 +1296,7 @@ bool ewol::Text::extrapolateLastId(const std::u32string& _text,
} }
} }
void ewol::Text::htmlAddData(const std::string& _data) { void ewol::compositing::Text::htmlAddData(const std::string& _data) {
if( m_htmlCurrrentLine.size()>0 if( m_htmlCurrrentLine.size()>0
&& m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') { && m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') {
m_htmlCurrrentLine+=" "; m_htmlCurrrentLine+=" ";
@ -1315,7 +1313,7 @@ void ewol::Text::htmlAddData(const std::string& _data) {
} }
} }
void ewol::Text::htmlFlush(void) { void ewol::compositing::Text::htmlFlush(void) {
if (m_htmlCurrrentLine.size()>0) { if (m_htmlCurrrentLine.size()>0) {
print(m_htmlCurrrentLine, m_htmlDecoration); print(m_htmlCurrrentLine, m_htmlDecoration);
} }
@ -1323,25 +1321,25 @@ void ewol::Text::htmlFlush(void) {
m_htmlDecoration.clear(); m_htmlDecoration.clear();
} }
void ewol::Text::disableCursor(void) { void ewol::compositing::Text::disableCursor(void) {
m_selectionStartPos = -100; m_selectionStartPos = -100;
m_cursorPos = -100; m_cursorPos = -100;
} }
void ewol::Text::setCursorPos(int32_t _cursorPos) { void ewol::compositing::Text::setCursorPos(int32_t _cursorPos) {
m_selectionStartPos = _cursorPos; m_selectionStartPos = _cursorPos;
m_cursorPos = _cursorPos; m_cursorPos = _cursorPos;
} }
void ewol::Text::setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos) { void ewol::compositing::Text::setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos) {
m_selectionStartPos = _selectionStartPos; m_selectionStartPos = _selectionStartPos;
m_cursorPos = _cursorPos; m_cursorPos = _cursorPos;
} }
void ewol::Text::setSelectionColor(const etk::Color<>& _color) { void ewol::compositing::Text::setSelectionColor(const etk::Color<>& _color) {
m_colorSelection = _color; m_colorSelection = _color;
} }
void ewol::Text::setCursorColor(const etk::Color<>& _color) { void ewol::compositing::Text::setCursorColor(const etk::Color<>& _color) {
m_colorCursor = _color; m_colorCursor = _color;
} }

View File

@ -12,415 +12,413 @@
#include <etk/Color.h> #include <etk/Color.h>
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compose.h>
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <exml/exml.h> #include <exml/exml.h>
#include <string> #include <string>
namespace ewol { namespace ewol {
/** namespace compositing {
* @brief This class represent the specific display for every char in the string ... /**
*/ * @brief This class represent the specific display for every char in the string ...
class TextDecoration { */
public: class TextDecoration {
etk::Color<> m_colorBg; //!< display background color public:
etk::Color<> m_colorFg; //!< display foreground color etk::Color<> m_colorBg; //!< display background color
enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic etk::Color<> m_colorFg; //!< display foreground color
TextDecoration(void) { enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic
m_colorBg = etk::color::blue; TextDecoration(void) {
m_colorBg = etk::color::green; m_colorBg = etk::color::blue;
m_mode = ewol::font::Regular; m_colorBg = etk::color::green;
m_mode = ewol::font::Regular;
} }
}; };
class Text : public ewol::Compositing { class Text : public ewol::compositing::Compose {
public: public:
enum aligneMode { enum aligneMode {
alignDisable, alignDisable,
alignRight, alignRight,
alignLeft, alignLeft,
alignCenter, alignCenter,
alignJustify alignJustify
}; };
private: private:
ewol::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ... ewol::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ...
public: public:
ewol::Drawing& getDrawing(void) { ewol::Drawing& getDrawing(void) {
return m_vectorialDraw; return m_vectorialDraw;
}; };
private: private:
int32_t m_nbCharDisplayed; //!< prevent some error in calculation size. int32_t m_nbCharDisplayed; //!< prevent some error in calculation size.
vec3 m_sizeDisplayStart; //!< The start windows of the display. vec3 m_sizeDisplayStart; //!< The start windows of the display.
vec3 m_sizeDisplayStop; //!< The end windows of the display. vec3 m_sizeDisplayStop; //!< The end windows of the display.
bool m_needDisplay; //!< This just need the display and not the size rendering. bool m_needDisplay; //!< This just need the display and not the size rendering.
vec3 m_position; //!< The current position to draw vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated bool m_clippingEnable; //!< true if the clipping must be activated
private: private:
etk::Color<> m_color; //!< The text foreground color etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color etk::Color<> m_colorBg; //!< The text background color
etk::Color<> m_colorCursor; //!< The text cursor color etk::Color<> m_colorCursor; //!< The text cursor color
etk::Color<> m_colorSelection; //!< The text Selection color etk::Color<> m_colorSelection; //!< The text Selection color
private: private:
enum ewol::font::mode m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic enum ewol::font::mode m_mode; //!< font display property : Regular/Bold/Italic/BoldItalic
bool m_kerning; //!< Kerning enable or disable on the next elements displayed bool m_kerning; //!< Kerning enable or disable on the next elements displayed
bool m_distanceField; //!< Texture in distance Field mode == > maybe move this in the font property. bool m_distanceField; //!< Texture in distance Field mode == > maybe move this in the font property.
char32_t m_previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning char32_t m_previousCharcode; //!< we remember the previous charcode to perform the kerning. @ref Kerning
private: private:
float m_startTextpos; //!< start position of the Alignement (when \n the text return at this position) float m_startTextpos; //!< start position of the Alignement (when \n the text return at this position)
float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one) float m_stopTextPos; //!< end of the alignement (when a string is too hight it cut at the word previously this virtual line and the center is perform with this one)
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...) enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...)
private: private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program ewol::Program* m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix)
int32_t m_GLColor; //!< openGL id on the element (color buffer) int32_t m_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position) int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID) int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private: private:
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection) int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection)
int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100) int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100)
private: private:
ewol::TexturedFont* m_font; //!< Font resources ewol::TexturedFont* m_font; //!< Font resources
private: // Text private: // Text
std::vector<vec2 > m_coord; //!< internal coord of the object std::vector<vec2 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
private: private:
/** /**
* @brief load the openGL program and get all the ID needed * @brief load the openGL program and get all the ID needed
*/ */
void loadProgram(void); void loadProgram(void);
public: public:
/** /**
* @brief generic constructor * @brief generic constructor
* @param[in] _fontName Name of the font that might be loaded * @param[in] _fontName Name of the font that might be loaded
* @param[in] _fontSize size of the font that might be loaded * @param[in] _fontSize size of the font that might be loaded
*/ */
Text(const std::string& _fontName="", int32_t _fontSize=-1); Text(const std::string& _fontName="", int32_t _fontSize=-1);
/** /**
* @brief generic destructor * @brief generic destructor
*/ */
~Text(void); ~Text(void);
public: public: // Derived function
// Derived function virtual void translate(const vec3& _vect);
virtual void translate(const vec3& _vect); virtual void rotate(const vec3& _vect, float _angle);
// Derived function virtual void scale(const vec3& _vect);
virtual void rotate(const vec3& _vect, float _angle); public:
// Derived function /**
virtual void scale(const vec3& _vect); * @brief draw All the refistered text in the current element on openGL
public: */
/** void draw(bool _disableDepthTest=true);
* @brief draw All the refistered text in the current element on openGL void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false);
*/ /**
void draw(bool _disableDepthTest=true); * @brief clear all the registered element in the current element
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false); */
/** void clear(void);
* @brief clear all the registered element in the current element /**
*/ * @brief clear all the intermediate result detween 2 prints
void clear(void); */
/** void reset(void);
* @brief clear all the intermediate result detween 2 prints /**
*/ * @brief get the current display position (sometime needed in the gui control)
void reset(void); * @return the current position.
/** */
* @brief get the current display position (sometime needed in the gui control) const vec3& getPos(void) {
* @return the current position. return m_position;
*/ };
const vec3& getPos(void) { /**
return m_position; * @brief set position for the next text writen
}; * @param[in] _pos Position of the text (in 3D)
/** */
* @brief set position for the next text writen void setPos(const vec3& _pos);
* @param[in] _pos Position of the text (in 3D) inline void setPos(const vec2& _pos) {
*/ setPos(vec3(_pos.x(),_pos.y(),0));
void setPos(const vec3& _pos); };
inline void setPos(const vec2& _pos) { /**
setPos(vec3(_pos.x(),_pos.y(),0)); * @brief set relative position for the next text writen
}; * @param[in] _pos ofset apply of the text (in 3D)
/** */
* @brief set relative position for the next text writen void setRelPos(const vec3& _pos);
* @param[in] _pos ofset apply of the text (in 3D) inline void setRelPos(const vec2& _pos) {
*/ setRelPos(vec3(_pos.x(),_pos.y(),0));
void setRelPos(const vec3& _pos); };
inline void setRelPos(const vec2& _pos) { /**
setRelPos(vec3(_pos.x(),_pos.y(),0)); * @brief set the Color of the current foreground font
}; * @param[in] _color Color to set on foreground (for next print)
/** */
* @brief set the Color of the current foreground font void setColor(const etk::Color<>& _color) { m_color = _color; };
* @param[in] _color Color to set on foreground (for next print) /**
*/ * @brief set the background color of the font (for selected Text (not the global BG))
void setColor(const etk::Color<>& _color) { m_color = _color; }; * @param[in] _color Color to set on background (for next print)
/** */
* @brief set the background color of the font (for selected Text (not the global BG)) void setColorBg(const etk::Color<>& _color);
* @param[in] _color Color to set on background (for next print) /**
*/ * @brief Request a clipping area for the text (next draw only)
void setColorBg(const etk::Color<>& _color); * @param[in] _pos Start position of the clipping
/** * @param[in] _width Width size of the clipping
* @brief Request a clipping area for the text (next draw only) */
* @param[in] _pos Start position of the clipping void setClippingWidth(const vec3& _pos, const vec3& _width) {
* @param[in] _width Width size of the clipping setClipping(_pos, _pos+_width);
*/ }
void setClippingWidth(const vec3& _pos, const vec3& _width) { void setClippingWidth(const vec2& _pos, const vec2& _width) {
setClipping(_pos, _pos+_width); setClipping(_pos, _pos+_width);
} };
void setClippingWidth(const vec2& _pos, const vec2& _width) { /**
setClipping(_pos, _pos+_width); * @brief Request a clipping area for the text (next draw only)
}; * @param[in] _pos Start position of the clipping
/** * @param[in] _posEnd End position of the clipping
* @brief Request a clipping area for the text (next draw only) */
* @param[in] _pos Start position of the clipping void setClipping(const vec3& _pos, const vec3& _posEnd);
* @param[in] _posEnd End position of the clipping void setClipping(const vec2& _pos, const vec2& _posEnd) {
*/ setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(),1) );
void setClipping(const vec3& _pos, const vec3& _posEnd); };
void setClipping(const vec2& _pos, const vec2& _posEnd) { /**
setClipping(vec3(_pos.x(),_pos.y(),-1), vec3(_posEnd.x(),_posEnd.y(),1) ); * @brief enable/Disable the clipping (without lose the current clipping position)
}; * @brief _newMode The new status of the clipping
/** */
* @brief enable/Disable the clipping (without lose the current clipping position) // TODO : Rename setClippingActivity
* @brief _newMode The new status of the clipping void setClippingMode(bool _newMode);
*/ /**
// TODO : Rename setClippingActivity * @brief Specify the font size (this reset the internal element of the current text (system requirement)
void setClippingMode(bool _newMode); * @param[in] _fontSize New font size
/** */
* @brief Specify the font size (this reset the internal element of the current text (system requirement) void setFontSize(int32_t _fontSize);
* @param[in] _fontSize New font size /**
*/ * @brief Specify the font name (this reset the internal element of the current text (system requirement)
void setFontSize(int32_t _fontSize); * @param[in] _fontName Current name of the selected font
/** */
* @brief Specify the font name (this reset the internal element of the current text (system requirement) void setFontName(const std::string& _fontName);
* @param[in] _fontName Current name of the selected font /**
*/ * @brief Specify the font property (this reset the internal element of the current text (system requirement)
void setFontName(const std::string& _fontName); * @param[in] fontName Current name of the selected font
/** * @param[in] fontSize New font size
* @brief Specify the font property (this reset the internal element of the current text (system requirement) */
* @param[in] fontName Current name of the selected font void setFont(std::string _fontName, int32_t _fontSize);
* @param[in] fontSize New font size /**
*/ * @brief Specify the font mode for the next @ref print
void setFont(std::string _fontName, int32_t _fontSize); * @param[in] mode The font mode requested
/** */
* @brief Specify the font mode for the next @ref print void setFontMode(enum ewol::font::mode _mode);
* @param[in] mode The font mode requested /**
*/ * @brief get the current font mode
void setFontMode(enum ewol::font::mode _mode); * @return The font mode applied
/** */
* @brief get the current font mode enum ewol::font::mode getFontMode(void);
* @return The font mode applied /**
*/ * @brief enable or disable the bold mode
enum ewol::font::mode getFontMode(void); * @param[in] _status The new status for this display property
/** */
* @brief enable or disable the bold mode void setFontBold(bool _status);
* @param[in] _status The new status for this display property /**
*/ * @brief enable or disable the italic mode
void setFontBold(bool _status); * @param[in] _status The new status for this display property
/** */
* @brief enable or disable the italic mode void setFontItalic(bool _status);
* @param[in] _status The new status for this display property /**
*/ * @brief set the activation of the Kerning for the display (if it existed)
void setFontItalic(bool _status); * @param[in] _newMode enable/Diasable the kerning on this font.
/** */
* @brief set the activation of the Kerning for the display (if it existed) void setKerningMode(bool _newMode);
* @param[in] _newMode enable/Diasable the kerning on this font. /**
*/ * @brief Request the distance field mode for this text display
void setKerningMode(bool _newMode); * @param[in] _newMode enable/Diasable the Distance Field on this font.
/** * @todo : not implemented for now
* @brief Request the distance field mode for this text display */
* @param[in] _newMode enable/Diasable the Distance Field on this font. void setDistanceFieldMode(bool _newMode);
* @todo : not implemented for now /**
*/ * @brief display a compleat string in the current element.
void setDistanceFieldMode(bool _newMode); * @param[in] _text The string to display.
/** */
* @brief display a compleat string in the current element. void print(const std::string& _text);
* @param[in] _text The string to display. void print(const std::u32string& _text);
*/ /**
void print(const std::string& _text); * @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
void print(const std::u32string& _text); * <pre>
/** * <br/>
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * <br/><br/><br/>
* <pre> * <center>
* <br/> * text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <br/><br/><br/> * <font color=\"#FF0000\">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* <center> * an an other thext
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext * </center>
* <font color=\"#FF0000\">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/> * <br/><br/><br/>
* an an other thext * <left>
* </center> * plop 1
* <br/><br/><br/> * </left>
* <left> * <br/><br/><br/>
* plop 1 * <right>
* </left> * plop 2
* <br/><br/><br/> * </right>
* <right> * <br/><br/><br/>
* plop 2 * <justify>
* </right> * Un exemple de text
* <br/><br/><br/> * </justify>
* <justify> * </pre>
* Un exemple de text * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* </justify> * @param[in] _text The string to display.
* </pre> * @TODO : implementation not done ....
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done */
* @param[in] _text The string to display. void printDecorated(const std::string& _text);
* @TODO : implementation not done .... /**
*/ * @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
void printDecorated(const std::string& _text); * <pre>
/** * <html>
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * <body>
* <pre> * <br/>
* <html> * <br/><br/><br/>
* <body> * <center>
* <br/> * text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <br/><br/><br/> * <font color=\"#FF0000\">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/>
* <center> * an an other thext
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext * </center>
* <font color=\"#FF0000\">colored text <b>bold color text</b> <i>bold italic text</i> normal color text</font> the end of the string<br/> * <br/><br/><br/>
* an an other thext * <left>
* </center> * plop 1
* <br/><br/><br/> * </left>
* <left> * <br/><br/><br/>
* plop 1 * <right>
* </left> * plop 2
* <br/><br/><br/> * </right>
* <right> * <br/><br/><br/>
* plop 2 * <justify>
* </right> * Un exemple de text
* <br/><br/><br/> * </justify>
* <justify> * </body>
* Un exemple de text * </html>
* </justify> * </pre>
* </body> * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done
* </html> * @param[in] _text The string to display.
* </pre> * @TODO : implementation not done ....
* @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done */
* @param[in] _text The string to display. void printHTML(const std::string& _text);
* @TODO : implementation not done .... /**
*/ * @brief display a compleat string in the current element whith specific decorations (advence mode).
void printHTML(const std::string& _text); * @param[in] _text The string to display.
/** * @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get)
* @brief display a compleat string in the current element whith specific decorations (advence mode). */
* @param[in] _text The string to display. void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
* @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get) void print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration);
*/ /**
void print(const std::string& _text, const std::vector<TextDecoration>& _decoration); * @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
void print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration); * @param[in] _charcode Char that might be dispalyed
/** */
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed) void print(const char32_t& _charcode);
* @param[in] _charcode Char that might be dispalyed /**
*/ * @brief This generate the line return == > it return to the alignement position start and at the correct line position ==> it might be use to not know the line height
void print(const char32_t& _charcode); */
/** void forceLineReturn(void);
* @brief This generate the line return == > it return to the alignement position start and at the correct line position ==> it might be use to not know the line height private:
*/ /**
void forceLineReturn(void); * @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
private: * @param[in] _element the exml element.
/** */
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include). void parseHtmlNode(exml::Element* _element);
* @param[in] _element the exml element. public:
*/ /**
void parseHtmlNode(exml::Element* _element); * @brief This generate the possibility to generate the big text property
public: * @param[in] _startTextpos The x text start position of the display.
/** * @param[in] _stopTextPos The x text stop position of the display.
* @brief This generate the possibility to generate the big text property * @param[in] _alignement mode of alignement for the Text.
* @param[in] _startTextpos The x text start position of the display. * @note The text align in center change of line every display done (even if it was just a char)
* @param[in] _stopTextPos The x text stop position of the display. */
* @param[in] _alignement mode of alignement for the Text. void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement=ewol::Text::alignDisable);
* @note The text align in center change of line every display done (even if it was just a char) /**
*/ * @brief disable the alignement system
void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement=ewol::Text::alignDisable); */
/** void disableAlignement(void);
* @brief disable the alignement system /**
*/ * @brief get the current alignement property
void disableAlignement(void); * @return the curent alignement type
/** */
* @brief get the current alignement property enum ewol::Text::aligneMode getAlignement(void);
* @return the curent alignement type /**
*/ * @brief calculate a theoric text size
enum ewol::Text::aligneMode getAlignement(void); * @param[in] _text The string to calculate dimention.
/** * @return The theoric size used.
* @brief calculate a theoric text size */
* @param[in] _text The string to calculate dimention. vec3 calculateSizeHTML(const std::string& _text);
* @return The theoric size used. /**
*/ * @brief calculate a theoric text size
vec3 calculateSizeHTML(const std::string& _text); * @param[in] _text The string to calculate dimention.
/** * @return The theoric size used.
* @brief calculate a theoric text size */
* @param[in] _text The string to calculate dimention. vec3 calculateSizeDecorated(const std::string& _text);
* @return The theoric size used. /**
*/ * @brief calculate a theoric text size
vec3 calculateSizeDecorated(const std::string& _text); * @param[in] _text The string to calculate dimention.
/** * @return The theoric size used.
* @brief calculate a theoric text size */
* @param[in] _text The string to calculate dimention. vec3 calculateSize(const std::string& _text);
* @return The theoric size used. /**
*/ * @brief calculate a theoric charcode size
vec3 calculateSize(const std::string& _text); * @param[in] _charcode The µUnicode value to calculate dimention.
/** * @return The theoric size used.
* @brief calculate a theoric charcode size */
* @param[in] _charcode The µUnicode value to calculate dimention. vec3 calculateSize(const char32_t& _charcode);
* @return The theoric size used. /**
*/ * @brief draw a cursor at the specify position
vec3 calculateSize(const char32_t& _charcode); * @param[in] _isInsertMode True if the insert mode is activated
/** * @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20]
* @brief draw a cursor at the specify position */
* @param[in] _isInsertMode True if the insert mode is activated void printCursor(bool _isInsertMode, float _cursorSize = 20.0f);
* @param[in] _cursorSize The sizae of the cursor that might be set when insert mode is set [default 20] private:
*/ /**
void printCursor(bool _isInsertMode, float _cursorSize = 20.0f); * @brief calculate the element number that is the first out the alignement range
private: * (start at the specify ID, and use start pos with current one)
/** * @param[in] _text The string that might be parsed.
* @brief calculate the element number that is the first out the alignement range * @param[in] _start The first elemnt that might be used to calculate.
* (start at the specify ID, and use start pos with current one) * @param[out] _stop The last Id availlable in the current string.
* @param[in] _text The string that might be parsed. * @param[out] _space Number of space in the string.
* @param[in] _start The first elemnt that might be used to calculate. * @parma[out] _freespace This represent the number of pixel present in the right white space.
* @param[out] _stop The last Id availlable in the current string. * @return true if the rifht has free space that can be use for jystify (return false if we find \n
* @param[out] _space Number of space in the string. */
* @parma[out] _freespace This represent the number of pixel present in the right white space. bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
* @return true if the rifht has free space that can be use for jystify (return false if we find \n bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
*/ private:
bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); // this section is reserved for HTML parsing and display:
bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); std::string m_htmlCurrrentLine; //!< current line for HTML display
private: std::vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display
// this section is reserved for HTML parsing and display: TextDecoration m_htmlDecoTmp; //!< current decoration
std::string m_htmlCurrrentLine; //!< current line for HTML display /**
std::vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display * @brief add a line with the current m_htmlDecoTmp decoration
TextDecoration m_htmlDecoTmp; //!< current decoration * @param[in] _data The cuurent data to add.
/** */
* @brief add a line with the current m_htmlDecoTmp decoration void htmlAddData(const std::string& _data);
* @param[in] _data The cuurent data to add. /**
*/ * @brief draw the current line
void htmlAddData(const std::string& _data); */
/** void htmlFlush(void);
* @brief draw the current line public:
*/ /**
void htmlFlush(void); * @brief remove the cursor display
public: */
/** void disableCursor(void);
* @brief remove the cursor display /**
*/ * @brief set a cursor at a specific position:
void disableCursor(void); * @param[in] _cursorPos id of the cursor position
/** */
* @brief set a cursor at a specific position: void setCursorPos(int32_t _cursorPos);
* @param[in] _cursorPos id of the cursor position /**
*/ * @brief set a cursor at a specific position with his associated selection:
void setCursorPos(int32_t _cursorPos); * @param[in] _cursorPos id of the cursor position
/** * @param[in] _selectionStartPos id of the starting of the selection
* @brief set a cursor at a specific position with his associated selection: */
* @param[in] _cursorPos id of the cursor position void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos);
* @param[in] _selectionStartPos id of the starting of the selection /**
*/ * @brief change the selection color
void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos); * @param[in] _color New color for the Selection
/** */
* @brief change the selection color void setSelectionColor(const etk::Color<>& _color);
* @param[in] _color New color for the Selection /**
*/ * @brief change the cursor color
void setSelectionColor(const etk::Color<>& _color); * @param[in] _color New color for the Selection
/** */
* @brief change the cursor color void setCursorColor(const etk::Color<>& _color);
* @param[in] _color New color for the Selection };
*/
void setCursorColor(const etk::Color<>& _color);
}; };
}; };

View File

View File

@ -67,6 +67,60 @@ void ewol::eContext::unLockContext(void) {
mutexInterface().unLock(); mutexInterface().unLock();
} }
namespace ewol {
class eSystemMessage {
public:
enum theadMessage {
msgNone,
msgInit,
msgRecalculateSize,
msgResize,
msgHide,
msgShow,
msgInputMotion,
msgInputState,
msgKeyboardKey,
msgKeyboardMove,
msgClipboardArrive
};
public :
// specify the message type
enum theadMessage TypeMessage;
// can not set a union ...
enum ewol::clipBoard::clipboardListe clipboardID;
// InputId
enum ewol::keyEvent::type inputType;
int32_t inputId;
// generic dimentions
vec2 dimention;
// keyboard events :
bool repeateKey; //!< special flag for the repeating key on the PC interface
bool stateIsDown;
char32_t keyboardChar;
enum ewol::keyEvent::keyboard keyboardMove;
ewol::SpecialKey keyboardSpecial;
eSystemMessage(void) :
TypeMessage(msgNone),
clipboardID(ewol::clipBoard::clipboardStd),
inputType(ewol::keyEvent::typeUnknow),
inputId(-1),
dimention(0,0),
repeateKey(false),
stateIsDown(false),
keyboardChar(0),
keyboardMove(ewol::keyEvent::keyboardUnknow)
{
}
};
};
void ewol::eContext::inputEventTransfertWidget(ewol::Widget* _source, void ewol::eContext::inputEventTransfertWidget(ewol::Widget* _source,
ewol::Widget* _destination) { ewol::Widget* _destination) {
m_input.transfertEvent(_source, _destination); m_input.transfertEvent(_source, _destination);
@ -84,71 +138,76 @@ void ewol::eContext::inputEventUnGrabPointer(void) {
void ewol::eContext::processEvents(void) { void ewol::eContext::processEvents(void) {
int32_t nbEvent = 0; int32_t nbEvent = 0;
//EWOL_DEBUG(" ******** Event"); //EWOL_DEBUG(" ******** Event");
eSystemMessage data; ewol::eSystemMessage* data = NULL;
while (m_msgSystem.count()>0) { while (m_msgSystem.count()>0) {
nbEvent++; nbEvent++;
if (data != NULL) {
delete(data);
data = NULL;
}
m_msgSystem.wait(data); m_msgSystem.wait(data);
//EWOL_DEBUG("EVENT"); //EWOL_DEBUG("EVENT");
switch (data.TypeMessage) { switch (data->TypeMessage) {
case eSystemMessage::msgInit: case eSystemMessage::msgInit:
// this is due to the openGL context // this is due to the openGL context
/*bool returnVal = */APP_Init(*this); /*bool returnVal = */
APP_Init(*this);
break; break;
case eSystemMessage::msgRecalculateSize: case eSystemMessage::msgRecalculateSize:
forceRedrawAll(); forceRedrawAll();
break; break;
case eSystemMessage::msgResize: case eSystemMessage::msgResize:
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE"); //EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
m_windowsSize = data.dimention; m_windowsSize = data->dimention;
ewol::dimension::setPixelWindowsSize(m_windowsSize); ewol::dimension::setPixelWindowsSize(m_windowsSize);
forceRedrawAll(); forceRedrawAll();
break; break;
case eSystemMessage::msgInputMotion: case eSystemMessage::msgInputMotion:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION"); //EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
m_input.motion(data.inputType, data.inputId, data.dimention); m_input.motion(data->inputType, data->inputId, data->dimention);
break; break;
case eSystemMessage::msgInputState: case eSystemMessage::msgInputState:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE"); //EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
m_input.state(data.inputType, data.inputId, data.stateIsDown, data.dimention); m_input.state(data->inputType, data->inputId, data->stateIsDown, data->dimention);
break; break;
case eSystemMessage::msgKeyboardKey: case eSystemMessage::msgKeyboardKey:
case eSystemMessage::msgKeyboardMove: case eSystemMessage::msgKeyboardMove:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY"); //EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
if (NULL != m_windowsCurrent) { if (NULL != m_windowsCurrent) {
if (false == m_windowsCurrent->onEventShortCut(data.keyboardSpecial, if (false == m_windowsCurrent->onEventShortCut(data->keyboardSpecial,
data.keyboardChar, data->keyboardChar,
data.keyboardMove, data->keyboardMove,
data.stateIsDown) ) { data->stateIsDown) ) {
// get the current focused Widget : // get the current focused Widget :
ewol::Widget * tmpWidget = m_widgetManager.focusGet(); ewol::Widget * tmpWidget = m_widgetManager.focusGet();
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
// check if the widget allow repeating key events. // check if the widget allow repeating key events.
//EWOL_DEBUG("repeating test :" << data.repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data.stateIsDown); //EWOL_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown);
if( false == data.repeateKey if( false == data->repeateKey
|| ( true == data.repeateKey || ( true == data->repeateKey
&& true == tmpWidget->getKeyboardRepeate()) ) { && true == tmpWidget->getKeyboardRepeate()) ) {
// check Widget shortcut // check Widget shortcut
if (false == tmpWidget->onEventShortCut(data.keyboardSpecial, if (false == tmpWidget->onEventShortCut(data->keyboardSpecial,
data.keyboardChar, data->keyboardChar,
data.keyboardMove, data->keyboardMove,
data.stateIsDown) ) { data->stateIsDown) ) {
// generate the direct event ... // generate the direct event ...
if (data.TypeMessage == eSystemMessage::msgKeyboardKey) { if (data->TypeMessage == eSystemMessage::msgKeyboardKey) {
ewol::EventEntrySystem tmpEntryEvent(ewol::keyEvent::keyboardChar, ewol::EventEntrySystem tmpEntryEvent(ewol::keyEvent::keyboardChar,
ewol::keyEvent::statusUp, ewol::keyEvent::statusUp,
data.keyboardSpecial, data->keyboardSpecial,
data.keyboardChar); data->keyboardChar);
if(true == data.stateIsDown) { if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown); tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown);
} }
tmpWidget->systemEventEntry(tmpEntryEvent); tmpWidget->systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE } else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown); EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data->keyboardMove << " " << data->stateIsDown);
ewol::EventEntrySystem tmpEntryEvent(data.keyboardMove, ewol::EventEntrySystem tmpEntryEvent(data->keyboardMove,
ewol::keyEvent::statusUp, ewol::keyEvent::statusUp,
data.keyboardSpecial, data->keyboardSpecial,
0); 0);
if(true == data.stateIsDown) { if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown); tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown);
} }
tmpWidget->systemEventEntry(tmpEntryEvent); tmpWidget->systemEventEntry(tmpEntryEvent);
@ -165,7 +224,7 @@ void ewol::eContext::processEvents(void) {
{ {
ewol::Widget * tmpWidget = m_widgetManager.focusGet(); ewol::Widget * tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != NULL) { if (tmpWidget != NULL) {
tmpWidget->onEventClipboard(data.clipboardID); tmpWidget->onEventClipboard(data->clipboardID);
} }
} }
break; break;
@ -262,9 +321,13 @@ ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
etk::initDefaultFolder("ewolApplNoName"); etk::initDefaultFolder("ewolApplNoName");
// request the init of the application in the main context of openGL ... // request the init of the application in the main context of openGL ...
{ {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgInit; if (data == NULL) {
m_msgSystem.post(data); EWOL_ERROR("allocationerror of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
m_msgSystem.post(data);
}
} }
// force a recalculation // force a recalculation
requestUpdateSize(); requestUpdateSize();
@ -282,6 +345,7 @@ ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
ewol::eContext::~eContext(void) { ewol::eContext::~eContext(void) {
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)"); EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// TODO : Clean the message list ...
// set the curent interface : // set the curent interface :
lockContext(); lockContext();
// call application to uninit // call application to uninit
@ -301,64 +365,88 @@ ewol::eContext::~eContext(void) {
} }
void ewol::eContext::requestUpdateSize(void) { void ewol::eContext::requestUpdateSize(void) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgRecalculateSize; if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgRecalculateSize;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Resize(const vec2& _size) { void ewol::eContext::OS_Resize(const vec2& _size) {
// TODO : Better in the thread ... == > but generate some init error ... // TODO : Better in the thread ... == > but generate some init error ...
ewol::dimension::setPixelWindowsSize(_size); ewol::dimension::setPixelWindowsSize(_size);
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgResize; if (data == NULL) {
data.dimention = _size; EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgResize;
data->dimention = _size;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Move(const vec2& _pos) { void ewol::eContext::OS_Move(const vec2& _pos) {
/* /*
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgResize; data->TypeMessage = eSystemMessage::msgResize;
data.resize.w = w; data->resize.w = w;
data.resize.h = h; data->resize.h = h;
m_msgSystem.Post(data); m_msgSystem.Post(data);
*/ */
} }
void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos ) { void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgInputMotion; if (data == NULL) {
data.inputType = ewol::keyEvent::typeFinger; EWOL_ERROR("allocationerror of message");
data.inputId = _pointerID; return;
data.dimention = _pos; }
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::keyEvent::typeFinger;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) { void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgInputState; if (data == NULL) {
data.inputType = ewol::keyEvent::typeFinger; EWOL_ERROR("allocationerror of message");
data.inputId = _pointerID; return;
data.stateIsDown = _isDown; }
data.dimention = _pos; data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::keyEvent::typeFinger;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) { void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgInputMotion; if (data == NULL) {
data.inputType = ewol::keyEvent::typeMouse; EWOL_ERROR("allocationerror of message");
data.inputId = _pointerID; return;
data.dimention = _pos; }
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::keyEvent::typeMouse;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) { void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgInputState; if (data == NULL) {
data.inputType = ewol::keyEvent::typeMouse; EWOL_ERROR("allocationerror of message");
data.inputId = _pointerID; return;
data.stateIsDown = _isDown; }
data.dimention = _pos; data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::keyEvent::typeMouse;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
@ -366,12 +454,16 @@ void ewol::eContext::OS_SetKeyboard(ewol::SpecialKey& _special,
char32_t _myChar, char32_t _myChar,
bool _isDown, bool _isDown,
bool _isARepeateKey) { bool _isARepeateKey) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgKeyboardKey; if (data == NULL) {
data.stateIsDown = _isDown; EWOL_ERROR("allocationerror of message");
data.keyboardChar = _myChar; return;
data.keyboardSpecial = _special; }
data.repeateKey = _isARepeateKey; data->TypeMessage = eSystemMessage::msgKeyboardKey;
data->stateIsDown = _isDown;
data->keyboardChar = _myChar;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
@ -379,32 +471,48 @@ void ewol::eContext::OS_SetKeyboardMove(ewol::SpecialKey& _special,
enum ewol::keyEvent::keyboard _move, enum ewol::keyEvent::keyboard _move,
bool _isDown, bool _isDown,
bool _isARepeateKey) { bool _isARepeateKey) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgKeyboardMove; if (data == NULL) {
data.stateIsDown = _isDown; EWOL_ERROR("allocationerror of message");
data.keyboardMove = _move; return;
data.keyboardSpecial = _special; }
data.repeateKey = _isARepeateKey; data->TypeMessage = eSystemMessage::msgKeyboardMove;
data->stateIsDown = _isDown;
data->keyboardMove = _move;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Hide(void) { void ewol::eContext::OS_Hide(void) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgHide; if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgHide;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_Show(void) { void ewol::eContext::OS_Show(void) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgShow; if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgShow;
m_msgSystem.post(data); m_msgSystem.post(data);
} }
void ewol::eContext::OS_ClipBoardArrive(enum ewol::clipBoard::clipboardListe _clipboardID) { void ewol::eContext::OS_ClipBoardArrive(enum ewol::clipBoard::clipboardListe _clipboardID) {
eSystemMessage data; ewol::eSystemMessage *data = new ewol::eSystemMessage();
data.TypeMessage = eSystemMessage::msgClipboardArrive; if (data == NULL) {
data.clipboardID = _clipboardID; EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgClipboardArrive;
data->clipboardID = _clipboardID;
m_msgSystem.post(data); m_msgSystem.post(data);
} }

View File

@ -23,58 +23,8 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <ewol/commandLine.h> #include <ewol/commandLine.h>
// TODO : Remove this from here ...
class eSystemMessage {
public:
enum theadMessage {
msgNone,
msgInit,
msgRecalculateSize,
msgResize,
msgHide,
msgShow,
msgInputMotion,
msgInputState,
msgKeyboardKey,
msgKeyboardMove,
msgClipboardArrive
};
public :
// specify the message type
enum theadMessage TypeMessage;
// can not set a union ...
enum ewol::clipBoard::clipboardListe clipboardID;
// InputId
enum ewol::keyEvent::type inputType;
int32_t inputId;
// generic dimentions
vec2 dimention;
// keyboard events :
bool repeateKey; //!< special flag for the repeating key on the PC interface
bool stateIsDown;
char32_t keyboardChar;
enum ewol::keyEvent::keyboard keyboardMove;
ewol::SpecialKey keyboardSpecial;
eSystemMessage(void) :
TypeMessage(msgNone),
clipboardID(ewol::clipBoard::clipboardStd),
inputType(ewol::keyEvent::typeUnknow),
inputId(-1),
dimention(0,0),
repeateKey(false),
stateIsDown(false),
keyboardChar(0),
keyboardMove(ewol::keyEvent::keyboardUnknow)
{
}
};
namespace ewol { namespace ewol {
class eSystemMessage;
enum orientation{ enum orientation{
screenAuto = 0, screenAuto = 0,
screenLandscape, screenLandscape,
@ -129,7 +79,7 @@ namespace ewol {
private: private:
int64_t m_previousDisplayTime; // this is to limit framerate ... in case... int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
ewol::eInput m_input; ewol::eInput m_input;
etk::MessageFifo<eSystemMessage> m_msgSystem; etk::MessageFifo<ewol::eSystemMessage*> m_msgSystem;
bool m_displayFps; bool m_displayFps;
ewol::Fps m_FpsSystemEvent; ewol::Fps m_FpsSystemEvent;
ewol::Fps m_FpsSystemContext; ewol::Fps m_FpsSystemContext;

View File

@ -11,10 +11,10 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "Colored3DObject" #define __class__ "resource::Colored3DObject"
ewol::Colored3DObject::Colored3DObject(void) : ewol::resource::Colored3DObject::Colored3DObject(void) :
m_GLprogram(NULL) { m_GLprogram(NULL) {
addObjectType("ewol::Colored3DObject"); addObjectType("ewol::Colored3DObject");
// get the shader resource : // get the shader resource :
@ -27,16 +27,16 @@ ewol::Colored3DObject::Colored3DObject(void) :
} }
} }
ewol::Colored3DObject::~Colored3DObject(void) { ewol::resource::Colored3DObject::~Colored3DObject(void) {
// remove dynamics dependencies : // remove dynamics dependencies :
ewol::Program::release(m_GLprogram); ewol::Program::release(m_GLprogram);
} }
void ewol::Colored3DObject::draw(std::vector<vec3>& _vertices, void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) { bool _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -75,11 +75,11 @@ void ewol::Colored3DObject::draw(std::vector<vec3>& _vertices,
} }
} }
void ewol::Colored3DObject::draw(std::vector<vec3>& _vertices, void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
mat4& _transformationMatrix, mat4& _transformationMatrix,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) { bool _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -115,11 +115,11 @@ void ewol::Colored3DObject::draw(std::vector<vec3>& _vertices,
} }
} }
void ewol::Colored3DObject::drawLine(std::vector<vec3>& _vertices, void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
const etk::Color<float>& _color, const etk::Color<float>& _color,
mat4& _transformationMatrix, mat4& _transformationMatrix,
bool _updateDepthBuffer, bool _updateDepthBuffer,
bool _depthtest) { bool _depthtest) {
if (_vertices.size() <= 0) { if (_vertices.size() <= 0) {
return; return;
} }
@ -155,10 +155,10 @@ void ewol::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
} }
} }
ewol::Colored3DObject* ewol::Colored3DObject::keep(void) { ewol::resource::Colored3DObject* ewol::Colored3DObject::keep(void) {
EWOL_VERBOSE("KEEP : direct Colored3DObject"); EWOL_VERBOSE("KEEP : direct Colored3DObject");
// need to crate a new one ... // need to crate a new one ...
ewol::Colored3DObject* object = new ewol::Colored3DObject(); ewol::resource::Colored3DObject* object = new ewol::resource::Colored3DObject();
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : Colored3DObject "); EWOL_ERROR("allocation error of a resource : Colored3DObject ");
return NULL; return NULL;
@ -167,11 +167,11 @@ ewol::Colored3DObject* ewol::Colored3DObject::keep(void) {
return object; return object;
} }
void ewol::Colored3DObject::release(ewol::Colored3DObject*& _object) { void ewol::resource::Colored3DObject::release(ewol::resource::Colored3DObject*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -16,43 +16,45 @@
#include <ewol/resources/Program.h> #include <ewol/resources/Program.h>
namespace ewol { namespace ewol {
class Colored3DObject : public ewol::Resource { namespace resource {
protected: class Colored3DObject : public ewol::resource::Resource {
ewol::Program* m_GLprogram; protected:
int32_t m_GLPosition; ewol::Program* m_GLprogram;
int32_t m_GLMatrix; int32_t m_GLPosition;
int32_t m_GLColor; int32_t m_GLMatrix;
protected: int32_t m_GLColor;
Colored3DObject(void); protected:
virtual ~Colored3DObject(void); Colored3DObject(void);
public: virtual ~Colored3DObject(void);
virtual const char* getType(void) { return "ewol::Colored3DObject"; }; public:
virtual void draw(std::vector<vec3>& _vertices, virtual const char* getType(void) { return "ewol::Colored3DObject"; };
const etk::Color<float>& _color, virtual void draw(std::vector<vec3>& _vertices,
bool _updateDepthBuffer=true, const etk::Color<float>& _color,
bool _depthtest=true); bool _updateDepthBuffer=true,
virtual void draw(std::vector<vec3>& _vertices, bool _depthtest=true);
const etk::Color<float>& _color, virtual void draw(std::vector<vec3>& _vertices,
mat4& _transformationMatrix, const etk::Color<float>& _color,
bool _updateDepthBuffer=true, mat4& _transformationMatrix,
bool _depthtest=true); bool _updateDepthBuffer=true,
virtual void drawLine(std::vector<vec3>& _vertices, bool _depthtest=true);
const etk::Color<float>& _color, virtual void drawLine(std::vector<vec3>& _vertices,
mat4& _transformationMatrix, const etk::Color<float>& _color,
bool _updateDepthBuffer=true, mat4& _transformationMatrix,
bool _depthtest=true); bool _updateDepthBuffer=true,
public: bool _depthtest=true);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @return pointer on the resource or NULL if an error occured. * @note Never free this pointer by your own...
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::Colored3DObject* keep(void); */
/** static ewol::Colored3DObject* keep(void);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::Colored3DObject*& _object); */
static void release(ewol::Colored3DObject*& _object);
};
}; };
}; };

View File

@ -13,10 +13,10 @@
#include <stdexcept> #include <stdexcept>
#undef __class__ #undef __class__
#define __class__ "ConfigFile" #define __class__ "resource::ConfigFile"
void ewol::SimpleConfigElement::parse(const std::string& _value) { void ewol::resource::SimpleConfigElement::parse(const std::string& _value) {
m_value = _value; m_value = _value;
#ifdef __EXCEPTIONS #ifdef __EXCEPTIONS
try { try {
@ -36,15 +36,15 @@ void ewol::SimpleConfigElement::parse(const std::string& _value) {
ewol::ConfigFile::ConfigFile(const std::string& _filename) : ewol::resource::ConfigFile::ConfigFile(const std::string& _filename) :
ewol::Resource(_filename) { ewol::resource::Resource(_filename) {
addObjectType("ewol::ConfigFile"); addObjectType("ewol::ConfigFile");
EWOL_DEBUG("SFP : load \"" << _filename << "\""); EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload(); reload();
} }
ewol::ConfigFile::~ConfigFile(void) { ewol::resource::ConfigFile::~ConfigFile(void) {
// remove all element // remove all element
for (size_t iii=0; iii<m_list.size(); iii++){ for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -55,7 +55,7 @@ ewol::ConfigFile::~ConfigFile(void) {
m_list.clear(); m_list.clear();
} }
void ewol::ConfigFile::reload(void) { void ewol::resource::ConfigFile::reload(void) {
// reset all parameters // reset all parameters
for (size_t iii=0; iii<m_list.size(); iii++){ for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -138,7 +138,7 @@ void ewol::ConfigFile::reload(void) {
} }
int32_t ewol::ConfigFile::request(const std::string& _paramName) { int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
// check if the parameters existed : // check if the parameters existed :
for (size_t iii=0; iii<m_list.size(); iii++){ for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -147,7 +147,7 @@ int32_t ewol::ConfigFile::request(const std::string& _paramName) {
} }
} }
} }
ewol::SimpleConfigElement* tmpElement = new ewol::SimpleConfigElement(_paramName); ewol::resource::SimpleConfigElement* tmpElement = new ewol::resource::SimpleConfigElement(_paramName);
if (NULL == tmpElement) { if (NULL == tmpElement) {
EWOL_DEBUG("error while allocation"); EWOL_DEBUG("error while allocation");
} else { } else {
@ -157,14 +157,14 @@ int32_t ewol::ConfigFile::request(const std::string& _paramName) {
} }
ewol::ConfigFile* ewol::ConfigFile::keep(const std::string& _filename) { ewol::resource::ConfigFile* ewol::resource::ConfigFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\""); EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
ewol::ConfigFile* object = static_cast<ewol::ConfigFile*>(getManager().localKeep(_filename)); ewol::resource::ConfigFile* object = static_cast<ewol::resource::ConfigFile*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
// this element create a new one every time .... // this element create a new one every time ....
object = new ewol::ConfigFile(_filename); object = new ewol::resource::ConfigFile(_filename);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??"); EWOL_ERROR("allocation error of a resource : ??Mesh.obj??");
return NULL; return NULL;
@ -173,11 +173,11 @@ ewol::ConfigFile* ewol::ConfigFile::keep(const std::string& _filename) {
return object; return object;
} }
void ewol::ConfigFile::release(ewol::ConfigFile*& _object) { void ewol::resource::ConfigFile::release(ewol::resource::ConfigFile*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -14,70 +14,72 @@
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol { namespace ewol {
class SimpleConfigElement { namespace resource {
public: class SimpleConfigElement {
std::string m_paramName; public:
private: std::string m_paramName;
std::string m_value; private:
int32_t m_valueInt; std::string m_value;
float m_valuefloat; int32_t m_valueInt;
public: float m_valuefloat;
SimpleConfigElement(const std::string& _name) : public:
m_paramName(_name), SimpleConfigElement(const std::string& _name) :
m_value(""), m_paramName(_name),
m_valueInt(0), m_value(""),
m_valuefloat(0.0) { }; m_valueInt(0),
~SimpleConfigElement(void) { }; m_valuefloat(0.0) { };
void parse(const std::string& value); ~SimpleConfigElement(void) { };
int32_t getInteger(void) { return m_valueInt; }; void parse(const std::string& value);
float getFloat(void) { return m_valuefloat; }; int32_t getInteger(void) { return m_valueInt; };
std::string& getString(void) { return m_value; }; float getFloat(void) { return m_valuefloat; };
}; std::string& getString(void) { return m_value; };
};
class ConfigFile : public ewol::Resource {
private: class ConfigFile : public ewol::resource::Resource {
std::vector<ewol::SimpleConfigElement*> m_list; private:
std::string m_errorString; std::vector<ewol::SimpleConfigElement*> m_list;
protected: std::string m_errorString;
ConfigFile(const std::string& _filename); protected:
virtual ~ConfigFile(void); ConfigFile(const std::string& _filename);
public: virtual ~ConfigFile(void);
const char* getType(void) { return "ewol::SimpleConfigFile"; }; public:
void reload(void); const char* getType(void) { return "ewol::SimpleConfigFile"; };
void reload(void);
int32_t request(const std::string& _paramName);
int32_t request(const std::string& _paramName);
int32_t getInteger(int32_t _id) {
if (_id<0) { int32_t getInteger(int32_t _id) {
return 0; if (_id<0) {
} return 0;
return m_list[_id]->getInteger(); }
}; return m_list[_id]->getInteger();
float getFloat(int32_t _id) { };
if (_id<0) { float getFloat(int32_t _id) {
return 0; if (_id<0) {
} return 0;
return m_list[_id]->getFloat(); }
}; return m_list[_id]->getFloat();
std::string& getString(int32_t _id) { };
if (_id<0) { std::string& getString(int32_t _id) {
return m_errorString; if (_id<0) {
} return m_errorString;
return m_list[_id]->getString(); }
}; return m_list[_id]->getString();
public: };
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the configuration file. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the configuration file.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::ConfigFile* keep(const std::string& _filename); */
/** static ewol::ConfigFile* keep(const std::string& _filename);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::ConfigFile*& _object); */
static void release(ewol::ConfigFile*& _object);
};
}; };
}; };

View File

@ -19,13 +19,13 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "FontFreeType" #define __class__ "resource::FontFreeType"
// free Font hnadle of librairies ... entry for acces ... // free Font hnadle of librairies ... entry for acces ...
static int32_t l_countLoaded=0; static int32_t l_countLoaded=0;
static FT_Library library; static FT_Library library;
void ewol::freeTypeInit(void) { void ewol::resource::freeTypeInit(void) {
EWOL_DEBUG(" == > init Font-Manager"); EWOL_DEBUG(" == > init Font-Manager");
l_countLoaded++; l_countLoaded++;
if (l_countLoaded>1) { if (l_countLoaded>1) {
@ -38,7 +38,7 @@ void ewol::freeTypeInit(void) {
} }
} }
void ewol::freeTypeUnInit(void) { void ewol::resource::freeTypeUnInit(void) {
EWOL_DEBUG(" == > Un-Init Font-Manager"); EWOL_DEBUG(" == > Un-Init Font-Manager");
l_countLoaded--; l_countLoaded--;
if (l_countLoaded>0) { if (l_countLoaded>0) {
@ -52,7 +52,7 @@ void ewol::freeTypeUnInit(void) {
} }
} }
ewol::FontFreeType::FontFreeType(const std::string& _fontName) : ewol::resource::FontFreeType::FontFreeType(const std::string& _fontName) :
FontBase(_fontName) { FontBase(_fontName) {
addObjectType("ewol::FontFreeType"); addObjectType("ewol::FontFreeType");
m_init = false; m_init = false;
@ -97,7 +97,7 @@ ewol::FontFreeType::FontFreeType(const std::string& _fontName) :
} }
} }
ewol::FontFreeType::~FontFreeType(void) { ewol::resource::FontFreeType::~FontFreeType(void) {
// clean the tmp memory // clean the tmp memory
if (NULL != m_FileBuffer) { if (NULL != m_FileBuffer) {
delete[] m_FileBuffer; delete[] m_FileBuffer;
@ -107,7 +107,7 @@ ewol::FontFreeType::~FontFreeType(void) {
FT_Done_Face( m_fftFace ); FT_Done_Face( m_fftFace );
} }
vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const std::string& _unicodeString) { vec2 ewol::resource::FontFreeType::getSize(int32_t _fontSize, const std::string& _unicodeString) {
if(false == m_init) { if(false == m_init) {
return vec2(0,0); return vec2(0,0);
} }
@ -116,11 +116,11 @@ vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const std::string& _unicodeS
return outputSize; return outputSize;
} }
int32_t ewol::FontFreeType::getHeight(int32_t _fontSize) { int32_t ewol::resource::FontFreeType::getHeight(int32_t _fontSize) {
return _fontSize*1.43f; // this is a really "magic" number ... return _fontSize*1.43f; // this is a really "magic" number ...
} }
bool ewol::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) { bool ewol::resource::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty& _property) {
if(false == m_init) { if(false == m_init) {
return false; return false;
} }
@ -160,11 +160,11 @@ bool ewol::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty
return true; return true;
} }
bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut, bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut,
int32_t _fontSize, int32_t _fontSize,
ivec2 _glyphPosition, ivec2 _glyphPosition,
ewol::GlyphProperty& _property, ewol::resource::GlyphProperty& _property,
int8_t _posInImage) { int8_t _posInImage) {
if(false == m_init) { if(false == m_init) {
return false; return false;
} }
@ -200,8 +200,7 @@ bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
tlpppp = _imageOut.get(ivec2(_glyphPosition.x()+iii, _glyphPosition.y()+jjj)); tlpppp = _imageOut.get(ivec2(_glyphPosition.x()+iii, _glyphPosition.y()+jjj));
uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj]; uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj];
// set only alpha : // set only alpha :
switch(_posInImage) switch(_posInImage) {
{
default: default:
case 0: case 0:
tlpppp.setA(valueColor); tlpppp.setA(valueColor);
@ -224,7 +223,7 @@ bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
} }
void ewol::FontFreeType::generateKerning(int32_t fontSize, std::vector<ewol::GlyphProperty>& listGlyph) { void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, std::vector<ewol::GlyphProperty>& listGlyph) {
if(false == m_init) { if(false == m_init) {
return; return;
} }
@ -257,7 +256,7 @@ void ewol::FontFreeType::generateKerning(int32_t fontSize, std::vector<ewol::Gly
} }
void ewol::FontFreeType::display(void) { void ewol::resource::FontFreeType::display(void) {
if(false == m_init) { if(false == m_init) {
return; return;
} }
@ -343,14 +342,14 @@ void ewol::FontFreeType::display(void) {
//EWOL_INFO(" Current size = " << (int)m_fftFace->size); //EWOL_INFO(" Current size = " << (int)m_fftFace->size);
} }
ewol::FontBase* ewol::FontFreeType::keep(const std::string& _filename) { ewol::resource::FontBase* ewol::resource::FontFreeType::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\"");
ewol::FontBase* object = static_cast<ewol::FontBase*>(getManager().localKeep(_filename)); ewol::resource::FontBase* object = static_cast<ewol::resource::FontBase*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
// need to crate a new one ... // need to crate a new one ...
object = new ewol::FontFreeType(_filename); object = new ewol::resource::FontFreeType(_filename);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename); EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL; return NULL;
@ -359,11 +358,11 @@ ewol::FontBase* ewol::FontFreeType::keep(const std::string& _filename) {
return object; return object;
} }
void ewol::FontFreeType::release(ewol::FontBase*& _object) { void ewol::resource::FontFreeType::release(ewol::resource::FontBase*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -18,49 +18,51 @@ extern "C" {
#include FT_FREETYPE_H #include FT_FREETYPE_H
namespace ewol { namespace ewol {
// show : http://www.freetype.org/freetype2/docs/tutorial/step2.html namespace resource {
class FontFreeType : public ewol::FontBase { // show : http://www.freetype.org/freetype2/docs/tutorial/step2.html
private: class FontFreeType : public ewol::resource::FontBase {
FT_Byte* m_FileBuffer; private:
int32_t m_FileSize; FT_Byte* m_FileBuffer;
FT_Face m_fftFace; int32_t m_FileSize;
bool m_init; FT_Face m_fftFace;
void display(void); bool m_init;
protected: void display(void);
FontFreeType(const std::string& _fontName); protected:
~FontFreeType(void); FontFreeType(const std::string& _fontName);
public: ~FontFreeType(void);
public:
bool getGlyphProperty(int32_t _fontSize,
ewol::GlyphProperty& _property); bool getGlyphProperty(int32_t _fontSize,
ewol::GlyphProperty& _property);
bool drawGlyph(egami::Image& _imageOut,
int32_t _fontSize, bool drawGlyph(egami::Image& _imageOut,
ivec2 _glyphPosition, int32_t _fontSize,
ewol::GlyphProperty& _property, ivec2 _glyphPosition,
int8_t _posInImage); ewol::GlyphProperty& _property,
int8_t _posInImage);
vec2 getSize(int32_t _fontSize, const std::string& _unicodeString);
vec2 getSize(int32_t _fontSize, const std::string& _unicodeString);
int32_t getHeight(int32_t _fontSize);
int32_t getHeight(int32_t _fontSize);
void generateKerning(int32_t _fontSize, std::vector<ewol::GlyphProperty>& _listGlyph);
public: void generateKerning(int32_t _fontSize, std::vector<ewol::GlyphProperty>& _listGlyph);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the base font. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the base font.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::FontBase* keep(const std::string& _filename); */
/** static ewol::FontBase* keep(const std::string& _filename);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::FontBase*& _object); */
static void release(ewol::FontBase*& _object);
};
void freeTypeInit(void);
void freeTypeUnInit(void);
}; };
void freeTypeInit(void);
void freeTypeUnInit(void);
}; };
#endif #endif

View File

@ -15,16 +15,16 @@
#undef __class__ #undef __class__
#define __class__ "TextureFile" #define __class__ "resource::TextureFile"
ewol::TextureFile::TextureFile(const std::string& _genName) : ewol::resource::TextureFile::TextureFile(const std::string& _genName) :
Texture(_genName) { Texture(_genName) {
} }
ewol::TextureFile::TextureFile(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) : ewol::resource::TextureFile::TextureFile(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) :
Texture(_genName) { ewol::resource::Texture(_genName) {
addObjectType("ewol::TextureFile"); addObjectType("ewol::TextureFile");
if (false == egami::load(m_data, _tmpfileName, _size)) { if (false == egami::load(m_data, _tmpfileName, _size)) {
EWOL_ERROR("ERROR when loading the image : " << _tmpfileName); EWOL_ERROR("ERROR when loading the image : " << _tmpfileName);
@ -56,10 +56,10 @@ static int32_t nextP2(int32_t _value) {
ewol::TextureFile* ewol::TextureFile::keep(const std::string& _filename, ivec2 _size) { ewol::resource::TextureFile* ewol::resource::TextureFile::keep(const std::string& _filename, ivec2 _size) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size); EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size);
if (_filename == "") { if (_filename == "") {
ewol::TextureFile* object = new ewol::TextureFile(""); ewol::resource::TextureFile* object = new ewol::resource::TextureFile("");
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??"); EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL; return NULL;
@ -95,13 +95,13 @@ ewol::TextureFile* ewol::TextureFile::keep(const std::string& _filename, ivec2 _
} }
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
ewol::TextureFile* object = static_cast<ewol::TextureFile*>(getManager().localKeep(TmpFilename)); ewol::resource::TextureFile* object = static_cast<ewol::resource::TextureFile*>(getManager().localKeep(TmpFilename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size); EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size);
// need to crate a new one ... // need to crate a new one ...
object = new ewol::TextureFile(TmpFilename, _filename, _size); object = new ewol::resource::TextureFile(TmpFilename, _filename, _size);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename); EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL; return NULL;
@ -111,11 +111,11 @@ ewol::TextureFile* ewol::TextureFile::keep(const std::string& _filename, ivec2 _
} }
void ewol::TextureFile::release(ewol::TextureFile*& _object) { void ewol::resource::TextureFile::release(ewol::resource::TextureFile*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -16,30 +16,32 @@
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol { namespace ewol {
class TextureFile : public ewol::Texture { namespace resource {
private: class TextureFile : public ewol::resource::Texture {
vec2 m_realImageSize; private:
private: vec2 m_realImageSize;
TextureFile(const std::string& _genName); private:
TextureFile(std::string _genName, const std::string& _fileName, const ivec2& _size); TextureFile(const std::string& _genName);
~TextureFile(void) { }; TextureFile(std::string _genName, const std::string& _fileName, const ivec2& _size);
public: ~TextureFile(void) { };
virtual const char* getType(void) { return "ewol::TextureFile"; }; public:
const vec2& getRealSize(void) { return m_realImageSize; }; virtual const char* getType(void) { return "ewol::TextureFile"; };
public: const vec2& getRealSize(void) { return m_realImageSize; };
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the image file. * @note Never free this pointer by your own...
* @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @param[in] _filename Name of the image file.
* @return pointer on the resource or NULL if an error occured. * @param[in] _requested size of the image (usefull when loading .svg to automatic rescale)
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::TextureFile* keep(const std::string& _filename, ivec2 _size=ivec2(-1,-1)); */
/** static ewol::TextureFile* keep(const std::string& _filename, ivec2 _size=ivec2(-1,-1));
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::TextureFile*& _object); */
static void release(ewol::TextureFile*& _object);
};
}; };
}; };

View File

@ -16,12 +16,12 @@
ewol::ResourceManager::ResourceManager(void) : ewol::resource::Manager::Manager(void) :
m_contextHasBeenRemoved(true) { m_contextHasBeenRemoved(true) {
// nothing to do ... // nothing to do ...
} }
ewol::ResourceManager::~ResourceManager(void) { ewol::resource::Manager::~Manager(void) {
bool hasError = false; bool hasError = false;
if (m_resourceListToUpdate.size()!=0) { if (m_resourceListToUpdate.size()!=0) {
EWOL_ERROR("Must not have anymore resources to update !!!"); EWOL_ERROR("Must not have anymore resources to update !!!");
@ -36,7 +36,7 @@ ewol::ResourceManager::~ResourceManager(void) {
} }
} }
void ewol::ResourceManager::unInit(void) { void ewol::resource::Manager::unInit(void) {
display(); display();
m_resourceListToUpdate.clear(); m_resourceListToUpdate.clear();
// remove all resources ... // remove all resources ...
@ -52,7 +52,7 @@ void ewol::ResourceManager::unInit(void) {
m_resourceList.clear(); m_resourceList.clear();
} }
void ewol::ResourceManager::display(void) { void ewol::resource::Manager::display(void) {
EWOL_INFO("Resources loaded : "); EWOL_INFO("Resources loaded : ");
// remove all resources ... // remove all resources ...
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) { for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
@ -66,7 +66,7 @@ void ewol::ResourceManager::display(void) {
EWOL_INFO("Resources ---"); EWOL_INFO("Resources ---");
} }
void ewol::ResourceManager::reLoadResources(void) { void ewol::resource::Manager::reLoadResources(void) {
EWOL_INFO("------------- Resources re-loaded -------------"); EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ... // remove all resources ...
if (m_resourceList.size() != 0) { if (m_resourceList.size() != 0) {
@ -87,7 +87,7 @@ void ewol::ResourceManager::reLoadResources(void) {
EWOL_INFO("------------- Resources -------------"); EWOL_INFO("------------- Resources -------------");
} }
void ewol::ResourceManager::update(ewol::Resource* _object) { void ewol::resource::Manager::update(ewol::resource::Resource* _object) {
// chek if not added before // chek if not added before
for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) { for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
if (m_resourceListToUpdate[iii] != NULL) { if (m_resourceListToUpdate[iii] != NULL) {
@ -102,7 +102,7 @@ void ewol::ResourceManager::update(ewol::Resource* _object) {
} }
// Specific to load or update the data in the openGl context == > system use only // Specific to load or update the data in the openGl context == > system use only
void ewol::ResourceManager::updateContext(void) { void ewol::resource::Manager::updateContext(void) {
if (true == m_contextHasBeenRemoved) { if (true == m_contextHasBeenRemoved) {
// need to update all ... // need to update all ...
m_contextHasBeenRemoved = false; m_contextHasBeenRemoved = false;
@ -138,7 +138,7 @@ void ewol::ResourceManager::updateContext(void) {
} }
// in this case, it is really too late ... // in this case, it is really too late ...
void ewol::ResourceManager::contextHasBeenDestroyed(void) { void ewol::resource::Manager::contextHasBeenDestroyed(void) {
for (size_t iii=0; iii<m_resourceList.size(); iii++) { for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) { if (m_resourceList[iii] != NULL) {
m_resourceList[iii]->removeContextToLate(); m_resourceList[iii]->removeContextToLate();
@ -149,7 +149,7 @@ void ewol::ResourceManager::contextHasBeenDestroyed(void) {
} }
// internal generic keeper ... // internal generic keeper ...
ewol::Resource* ewol::ResourceManager::localKeep(const std::string& _filename) { ewol::resource::Resource* ewol::resource::Manager::localKeep(const std::string& _filename) {
EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << _filename << "\"");
for (size_t iii=0; iii<m_resourceList.size(); iii++) { for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) { if (m_resourceList[iii] != NULL) {
@ -164,7 +164,7 @@ ewol::Resource* ewol::ResourceManager::localKeep(const std::string& _filename) {
} }
// internal generic keeper ... // internal generic keeper ...
void ewol::ResourceManager::localAdd(ewol::Resource* _object) { void ewol::resource::Manager::localAdd(ewol::resource::Resource* _object) {
//Add ... find empty slot //Add ... find empty slot
for (size_t iii=0; iii<m_resourceList.size(); iii++) { for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] == NULL) { if (m_resourceList[iii] == NULL) {
@ -176,7 +176,7 @@ void ewol::ResourceManager::localAdd(ewol::Resource* _object) {
m_resourceList.push_back(_object); m_resourceList.push_back(_object);
} }
bool ewol::ResourceManager::release(ewol::Resource*& _object) { bool ewol::resource::Manager::release(ewol::resource::Resource*& _object) {
if (NULL == _object) { if (NULL == _object) {
EWOL_ERROR("Try to remove a resource that have null pointer ..."); EWOL_ERROR("Try to remove a resource that have null pointer ...");
return false; return false;

View File

@ -0,0 +1,85 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __RESOURCES_MANAGER_H__
#define __RESOURCES_MANAGER_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resources/Resource.h>
#include <ewol/resources/Shader.h>
#include <ewol/resources/Program.h>
#include <ewol/resources/VirtualBufferObject.h>
#include <ewol/resources/ConfigFile.h>
#include <ewol/resources/TexturedFont.h>
#include <ewol/resources/Texture.h>
#include <ewol/resources/Image.h>
#include <ewol/resources/Mesh.h>
#include <ewol/resources/Colored3DObject.h>
namespace ewol {
namespace resource {
class Manager {
private:
std::vector<ewol::Resource*> m_resourceList;
std::vector<ewol::Resource*> m_resourceListToUpdate;
bool m_contextHasBeenRemoved;
public:
/**
* @brief initialize the internal variable
*/
Manager(void);
/**
* @brief Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after...
*/
~Manager(void);
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit(void);
/**
* @brief display in the log all the resources loaded ...
*/
void display(void);
/**
* @brief Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne
*/
void reLoadResources(void);
/**
* @brief Call by the system to send all the needed data on the graphic card chen they change ...
* @param[in] _object The resources that might be updated
*/
void update(ewol::Resource* _object);
/**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/
void updateContext(void);
/**
* @brief This is to inform the resources manager that we have no more openGl context ...
*/
void contextHasBeenDestroyed(void);
public:
// internal API to extent eResources in extern Soft
ewol::Resource* localKeep(const std::string& _filename);
void localAdd(ewol::Resource* _object);
public:
/**
* @brief release a resources and free it if the Last release is call.
* @param[in,out] _object element to realease == > is return at NULL value.
* @return true, if element is removed, and false for just decreasing counter
*/
bool release(ewol::Resource*& _object);
};
};
};
#endif

View File

@ -12,10 +12,10 @@
#include <etk/os/FSNode.h> #include <etk/os/FSNode.h>
#undef __class__ #undef __class__
#define __class__ "Mesh" #define __class__ "resource::Mesh"
ewol::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) : ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
ewol::Resource(_fileName), ewol::resource::Resource(_fileName),
m_normalMode(normalModeNone), m_normalMode(normalModeNone),
m_checkNormal(false), m_checkNormal(false),
m_pointerShape(NULL), m_pointerShape(NULL),
@ -65,10 +65,10 @@ ewol::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
} }
} }
ewol::Mesh::~Mesh(void) { ewol::resource::Mesh::~Mesh(void) {
// remove dynamics dependencies : // remove dynamics dependencies :
ewol::Program::release(m_GLprogram); ewol::resource::Program::release(m_GLprogram);
ewol::VirtualBufferObject::release(m_verticesVBO); ewol::resource::VirtualBufferObject::release(m_verticesVBO);
if (m_functionFreeShape!=NULL) { if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape); m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL; m_pointerShape = NULL;
@ -77,9 +77,9 @@ ewol::Mesh::~Mesh(void) {
//#define DISPLAY_NB_VERTEX_DISPLAYED //#define DISPLAY_NB_VERTEX_DISPLAYED
void ewol::Mesh::draw(mat4& _positionMatrix, void ewol::resource::Mesh::draw(mat4& _positionMatrix,
bool _enableDepthTest, bool _enableDepthTest,
bool _enableDepthUpdate) { bool _enableDepthUpdate) {
if (m_GLprogram == NULL) { if (m_GLprogram == NULL) {
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
@ -178,7 +178,7 @@ void ewol::Mesh::draw(mat4& _positionMatrix,
} }
// normal calculation of the normal face is really easy : // normal calculation of the normal face is really easy :
void ewol::Mesh::calculateNormaleFace(void) { void ewol::resource::Mesh::calculateNormaleFace(void) {
m_listFacesNormal.clear(); m_listFacesNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeFace) { if (m_normalMode != ewol::Mesh::normalModeFace) {
std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces; std::vector<Face>& tmpFaceList = m_listFaces.getValue(0).m_faces;
@ -192,7 +192,7 @@ void ewol::Mesh::calculateNormaleFace(void) {
} }
} }
void ewol::Mesh::calculateNormaleEdge(void) { void ewol::resource::Mesh::calculateNormaleEdge(void) {
m_listVertexNormal.clear(); m_listVertexNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeVertex) { if (m_normalMode != ewol::Mesh::normalModeVertex) {
for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) { for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) {
@ -221,7 +221,7 @@ void ewol::Mesh::calculateNormaleEdge(void) {
//#define PRINT_HALF (1) //#define PRINT_HALF (1)
//#define TRY_MINIMAL_VBO //#define TRY_MINIMAL_VBO
void ewol::Mesh::generateVBO(void) { void ewol::resource::Mesh::generateVBO(void) {
// calculate the normal of all faces if needed // calculate the normal of all faces if needed
if (m_normalMode == ewol::Mesh::normalModeNone) { if (m_normalMode == ewol::Mesh::normalModeNone) {
// when no normal detected == > auto generate Face normal .... // when no normal detected == > auto generate Face normal ....
@ -284,7 +284,7 @@ void ewol::Mesh::generateVBO(void) {
} }
void ewol::Mesh::createViewBox(const std::string& _materialName,float _size) { void ewol::resource::Mesh::createViewBox(const std::string& _materialName,float _size) {
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
// This is the direct generation basis on the .obj system // This is the direct generation basis on the .obj system
/* /*
@ -377,7 +377,7 @@ void ewol::Mesh::createViewBox(const std::string& _materialName,float _size) {
} }
bool ewol::Mesh::loadOBJ(const std::string& _fileName) { bool ewol::resource::Mesh::loadOBJ(const std::string& _fileName) {
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
#if 0 #if 0
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
@ -626,7 +626,7 @@ enum emfModuleMode {
EMFModuleMaterial_END, EMFModuleMaterial_END,
}; };
bool ewol::Mesh::loadEMF(const std::string& _fileName) { bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
m_checkNormal = true; m_checkNormal = true;
m_normalMode = ewol::Mesh::normalModeNone; m_normalMode = ewol::Mesh::normalModeNone;
etk::FSNode fileName(_fileName); etk::FSNode fileName(_fileName);
@ -992,7 +992,7 @@ bool ewol::Mesh::loadEMF(const std::string& _fileName) {
return true; return true;
} }
void ewol::Mesh::addMaterial(const std::string& _name, ewol::Material* _data) { void ewol::resource::Mesh::addMaterial(const std::string& _name, ewol::Material* _data) {
if (NULL == _data) { if (NULL == _data) {
EWOL_ERROR(" can not add material with null pointer"); EWOL_ERROR(" can not add material with null pointer");
return; return;
@ -1005,7 +1005,7 @@ void ewol::Mesh::addMaterial(const std::string& _name, ewol::Material* _data) {
m_materials.add(_name, _data); m_materials.add(_name, _data);
} }
void ewol::Mesh::setShape(void* _shape) { void ewol::resource::Mesh::setShape(void* _shape) {
if (m_functionFreeShape!=NULL) { if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape); m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL; m_pointerShape = NULL;
@ -1013,13 +1013,13 @@ void ewol::Mesh::setShape(void* _shape) {
m_pointerShape=_shape; m_pointerShape=_shape;
} }
ewol::Mesh* ewol::Mesh::keep(const std::string& _meshName) { ewol::resource::Mesh* ewol::resource::Mesh::keep(const std::string& _meshName) {
ewol::Mesh* object = static_cast<ewol::Mesh*>(getManager().localKeep(_meshName)); ewol::resource::Mesh* object = static_cast<ewol::resource::Mesh*>(getManager().localKeep(_meshName));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
EWOL_DEBUG("CREATE: Mesh: '" << _meshName << "'"); EWOL_DEBUG("CREATE: Mesh: '" << _meshName << "'");
object = new ewol::Mesh(_meshName); object = new ewol::resource::Mesh(_meshName);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName); EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
return NULL; return NULL;
@ -1028,11 +1028,11 @@ ewol::Mesh* ewol::Mesh::keep(const std::string& _meshName) {
return object; return object;
} }
void ewol::Mesh::release(ewol::Mesh*& _object) { void ewol::resource::Mesh::release(ewol::Mesh*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -31,135 +31,137 @@
#define MESH_VBO_COLOR (4) #define MESH_VBO_COLOR (4)
namespace ewol { namespace ewol {
class Face { namespace resource {
public: class Face {
int32_t m_vertex[3]; public:
int32_t m_uv[3]; int32_t m_vertex[3];
int32_t m_normal[3]; int32_t m_uv[3];
public: int32_t m_normal[3];
Face(void) {}; public:
Face(int32_t v1, int32_t t1, Face(void) {};
int32_t v2, int32_t t2, Face(int32_t v1, int32_t t1,
int32_t v3, int32_t t3) { int32_t v2, int32_t t2,
m_vertex[0] = v1; int32_t v3, int32_t t3) {
m_vertex[1] = v2; m_vertex[0] = v1;
m_vertex[2] = v3; m_vertex[1] = v2;
m_uv[0] = t1; m_vertex[2] = v3;
m_uv[1] = t2; m_uv[0] = t1;
m_uv[2] = t3; m_uv[1] = t2;
m_normal[0] = -1; m_uv[2] = t3;
m_normal[1] = -1; m_normal[0] = -1;
m_normal[2] = -1; m_normal[1] = -1;
}; m_normal[2] = -1;
Face(int32_t v1, int32_t t1, int32_t n1, };
int32_t v2, int32_t t2, int32_t n2, Face(int32_t v1, int32_t t1, int32_t n1,
int32_t v3, int32_t t3, int32_t n3) { int32_t v2, int32_t t2, int32_t n2,
m_vertex[0] = v1; int32_t v3, int32_t t3, int32_t n3) {
m_vertex[1] = v2; m_vertex[0] = v1;
m_vertex[2] = v3; m_vertex[1] = v2;
m_uv[0] = t1; m_vertex[2] = v3;
m_uv[1] = t2; m_uv[0] = t1;
m_uv[2] = t3; m_uv[1] = t2;
m_normal[0] = n1; m_uv[2] = t3;
m_normal[1] = n2; m_normal[0] = n1;
m_normal[2] = n3; m_normal[1] = n2;
}; m_normal[2] = n3;
}; };
class FaceIndexing { };
public: class FaceIndexing {
std::vector<Face> m_faces; public:
std::vector<uint32_t> m_index; std::vector<Face> m_faces;
}; std::vector<uint32_t> m_index;
class Mesh : public ewol::Resource { };
public: class Mesh : public ewol::resource::Resource {
enum normalMode { public:
normalModeNone, enum normalMode {
normalModeFace, normalModeNone,
normalModeVertex, normalModeFace,
}; normalModeVertex,
protected: };
enum normalMode m_normalMode; // select the normal mode of display protected:
bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card enum normalMode m_normalMode; // select the normal mode of display
protected: bool m_checkNormal; //!< when enable, this check the normal of the mesh before sending it at the 3d card
ewol::Program* m_GLprogram; protected:
int32_t m_GLPosition; ewol::Program* m_GLprogram;
int32_t m_GLMatrix; int32_t m_GLPosition;
int32_t m_GLMatrixPosition; int32_t m_GLMatrix;
int32_t m_GLNormal; int32_t m_GLMatrixPosition;
int32_t m_GLtexture; int32_t m_GLNormal;
int32_t m_bufferOfset; int32_t m_GLtexture;
int32_t m_numberOfElments; int32_t m_bufferOfset;
MaterialGlId m_GLMaterial; int32_t m_numberOfElments;
ewol::Light m_light; MaterialGlId m_GLMaterial;
protected: ewol::Light m_light;
std::vector<vec3> m_listVertex; //!< List of all vertex in the element protected:
std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture) std::vector<vec3> m_listVertex; //!< List of all vertex in the element
std::vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated std::vector<vec2> m_listUV; //!< List of all UV point in the mesh (for the specify texture)
std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated std::vector<vec3> m_listFacesNormal; //!< List of all Face normal, when calculated
etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh std::vector<vec3> m_listVertexNormal; //!< List of all Face normal, when calculated
etk::Hash<ewol::Material*> m_materials; etk::Hash<FaceIndexing> m_listFaces; //!< List of all Face for the mesh
std::vector<ewol::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib) etk::Hash<ewol::Material*> m_materials;
protected: std::vector<ewol::PhysicsShape*> m_physics; //!< collision shape module ... (independent of bullet lib)
ewol::VirtualBufferObject* m_verticesVBO; protected:
protected: ewol::VirtualBufferObject* m_verticesVBO;
Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog"); protected:
virtual ~Mesh(void); Mesh(const std::string& _fileName, const std::string& _shaderName="DATA:textured3D2.prog");
public: virtual ~Mesh(void);
virtual const char* getType(void) { return "ewol::Mesh"; }; public:
virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true); virtual const char* getType(void) { return "ewol::Mesh"; };
void generateVBO(void); virtual void draw(mat4& _positionMatrix, bool _enableDepthTest=true, bool _enableDepthUpdate=true);
private: void generateVBO(void);
void calculateNormaleFace(void); private:
void calculateNormaleEdge(void); void calculateNormaleFace(void);
public : void calculateNormaleEdge(void);
void createViewBox(const std::string& _materialName,float _size=1.0); public :
private: void createViewBox(const std::string& _materialName,float _size=1.0);
bool loadOBJ(const std::string& _fileName); private:
bool loadEMF(const std::string& _fileName); bool loadOBJ(const std::string& _fileName);
public: bool loadEMF(const std::string& _fileName);
void addMaterial(const std::string& _name, ewol::Material* _data); public:
public: void addMaterial(const std::string& _name, ewol::Material* _data);
/** public:
* @brief set the check of normal position befor sending it to the openGl card /**
* @param[in] _status New state. * @brief set the check of normal position befor sending it to the openGl card
*/ * @param[in] _status New state.
void setCheckNormal(bool _status) { m_checkNormal=_status; }; */
/** void setCheckNormal(bool _status) { m_checkNormal=_status; };
* @brief get the check value of normal position befor sending it to the openGl card /**
* @return get the chcking stus of normal or not * @brief get the check value of normal position befor sending it to the openGl card
*/ * @return get the chcking stus of normal or not
bool getCheckNormal(void) { return m_checkNormal; }; */
const std::vector<ewol::PhysicsShape*>& getPhysicalProperties(void) const { return m_physics; }; bool getCheckNormal(void) { return m_checkNormal; };
private: const std::vector<ewol::PhysicsShape*>& getPhysicalProperties(void) const { return m_physics; };
void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib private:
public: void* m_pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib
/** public:
* @brief set the shape pointer (no type == > user might know it ...) /**
* @param[in] _shape The new shape (this remove the previous one) * @brief set the shape pointer (no type == > user might know it ...)
*/ * @param[in] _shape The new shape (this remove the previous one)
void setShape(void* _shape); */
/** void setShape(void* _shape);
* @brief get the pointer on the shame (no type) /**
* @return Pointer on shape. * @brief get the pointer on the shame (no type)
*/ * @return Pointer on shape.
void* getShape(void) { return m_pointerShape; }; */
private: void* getShape(void) { return m_pointerShape; };
void (*m_functionFreeShape)(void* _pointer); private:
public: void (*m_functionFreeShape)(void* _pointer);
void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) { m_functionFreeShape = _functionFreeShape; }; public:
public: void setFreeShapeFunction(void (*_functionFreeShape)(void* _pointer)) { m_functionFreeShape = _functionFreeShape; };
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the ewol mesh file. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the ewol mesh file.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::Mesh* keep(const std::string& _meshname); */
/** static ewol::Mesh* keep(const std::string& _meshname);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::Mesh*& _object); */
static void release(ewol::Mesh*& _object);
};
}; };
}; };

View File

@ -17,10 +17,10 @@
#define LOCAL_DEBUG EWOL_DEBUG #define LOCAL_DEBUG EWOL_DEBUG
#undef __class__ #undef __class__
#define __class__ "Program" #define __class__ "resource::Program"
ewol::Program::Program(const std::string& _filename) : ewol::resource::resource::Program::Program(const std::string& _filename) :
ewol::Resource(_filename), ewol::resource::Resource(_filename),
m_exist(false), m_exist(false),
m_program(0), m_program(0),
m_hasTexture(false), m_hasTexture(false),
@ -95,7 +95,7 @@ ewol::Program::Program(const std::string& _filename) :
updateContext(); updateContext();
} }
ewol::Program::~Program(void) { ewol::resource::Program::~Program(void) {
for (size_t iii=0; iii<m_shaderList.size(); iii++) { for (size_t iii=0; iii<m_shaderList.size(); iii++) {
ewol::Shader::release(m_shaderList[iii]); ewol::Shader::release(m_shaderList[iii]);
m_shaderList[iii] = 0; m_shaderList[iii] = 0;
@ -116,7 +116,7 @@ static void checkGlError(const char* _op, int32_t _localLine) {
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) #define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
int32_t ewol::Program::getAttribute(std::string _elementName) { int32_t ewol::resource::Program::getAttribute(std::string _elementName) {
// check if it exist previously : // check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) { for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) { if (m_elementList[iii].m_name == _elementName) {
@ -137,7 +137,7 @@ int32_t ewol::Program::getAttribute(std::string _elementName) {
return m_elementList.size()-1; return m_elementList.size()-1;
} }
int32_t ewol::Program::getUniform(std::string _elementName) { int32_t ewol::resource::Program::getUniform(std::string _elementName) {
// check if it exist previously : // check if it exist previously :
for(size_t iii=0; iii<m_elementList.size(); iii++) { for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) { if (m_elementList[iii].m_name == _elementName) {
@ -158,7 +158,7 @@ int32_t ewol::Program::getUniform(std::string _elementName) {
return m_elementList.size()-1; return m_elementList.size()-1;
} }
void ewol::Program::updateContext(void) { void ewol::resource::Program::updateContext(void) {
if (true == m_exist) { if (true == m_exist) {
// Do nothing == > too dangerous ... // Do nothing == > too dangerous ...
} else { } else {
@ -246,7 +246,7 @@ void ewol::Program::updateContext(void) {
} }
} }
void ewol::Program::removeContext(void) { void ewol::resource::Program::removeContext(void) {
if (true == m_exist) { if (true == m_exist) {
glDeleteProgram(m_program); glDeleteProgram(m_program);
m_program = 0; m_program = 0;
@ -257,12 +257,12 @@ void ewol::Program::removeContext(void) {
} }
} }
void ewol::Program::removeContextToLate(void) { void ewol::resource::Program::removeContextToLate(void) {
m_exist = false; m_exist = false;
m_program = 0; m_program = 0;
} }
void ewol::Program::reload(void) { void ewol::resource::Program::reload(void) {
/* TODO : ... /* TODO : ...
etk::file file(m_name, etk::FILE_TYPE_DATA); etk::file file(m_name, etk::FILE_TYPE_DATA);
if (false == file.Exist()) { if (false == file.Exist()) {
@ -303,10 +303,10 @@ void ewol::Program::reload(void) {
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::sendAttribute(int32_t _idElem, void ewol::resource::Program::sendAttribute(int32_t _idElem,
int32_t _nbElement, int32_t _nbElement,
void* _pointer, void* _pointer,
int32_t _jumpBetweenSample) { int32_t _jumpBetweenSample) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -328,12 +328,12 @@ void ewol::Program::sendAttribute(int32_t _idElem,
//checkGlError("glEnableVertexAttribArray", __LINE__); //checkGlError("glEnableVertexAttribArray", __LINE__);
} }
void ewol::Program::sendAttributePointer(int32_t _idElem, void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
int32_t _nbElement, int32_t _nbElement,
ewol::VirtualBufferObject* _vbo, ewol::resource::VirtualBufferObject* _vbo,
int32_t _index, int32_t _index,
int32_t _jumpBetweenSample, int32_t _jumpBetweenSample,
int32_t _offset) { int32_t _offset) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -358,7 +358,7 @@ void ewol::Program::sendAttributePointer(int32_t _idElem,
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _matrix, bool _transpose) { void ewol::resource::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _matrix, bool _transpose) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -379,7 +379,7 @@ void ewol::Program::uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1f(int32_t _idElem, float _value1) { void ewol::resource::Program::uniform1f(int32_t _idElem, float _value1) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -393,7 +393,7 @@ void ewol::Program::uniform1f(int32_t _idElem, float _value1) {
glUniform1f(m_elementList[_idElem].m_elementId, _value1); glUniform1f(m_elementList[_idElem].m_elementId, _value1);
//checkGlError("glUniform1f", __LINE__); //checkGlError("glUniform1f", __LINE__);
} }
void ewol::Program::uniform2f(int32_t _idElem, float _value1, float _value2) { void ewol::resource::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -407,7 +407,7 @@ void ewol::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2); glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2);
//checkGlError("glUniform2f", __LINE__); //checkGlError("glUniform2f", __LINE__);
} }
void ewol::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) { void ewol::resource::Program::uniform3f(int32_t _idElem, float _value1, float _value2, float _value3) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -421,7 +421,7 @@ void ewol::Program::uniform3f(int32_t _idElem, float _value1, float _value2, flo
glUniform3f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3); glUniform3f(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
//checkGlError("glUniform3f", __LINE__); //checkGlError("glUniform3f", __LINE__);
} }
void ewol::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) { void ewol::resource::Program::uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -438,7 +438,7 @@ void ewol::Program::uniform4f(int32_t _idElem, float _value1, float _value2, flo
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1i(int32_t _idElem, int32_t _value1) { void ewol::resource::Program::uniform1i(int32_t _idElem, int32_t _value1) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -452,7 +452,7 @@ void ewol::Program::uniform1i(int32_t _idElem, int32_t _value1) {
glUniform1i(m_elementList[_idElem].m_elementId, _value1); glUniform1i(m_elementList[_idElem].m_elementId, _value1);
//checkGlError("glUniform1i", __LINE__); //checkGlError("glUniform1i", __LINE__);
} }
void ewol::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) { void ewol::resource::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -466,7 +466,7 @@ void ewol::Program::uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2)
glUniform2i(m_elementList[_idElem].m_elementId, _value1, _value2); glUniform2i(m_elementList[_idElem].m_elementId, _value1, _value2);
//checkGlError("glUniform2i", __LINE__); //checkGlError("glUniform2i", __LINE__);
} }
void ewol::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) { void ewol::resource::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -480,7 +480,7 @@ void ewol::Program::uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2,
glUniform3i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3); glUniform3i(m_elementList[_idElem].m_elementId, _value1, _value2, _value3);
//checkGlError("glUniform3i", __LINE__); //checkGlError("glUniform3i", __LINE__);
} }
void ewol::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) { void ewol::resource::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -498,7 +498,7 @@ void ewol::Program::uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2,
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void ewol::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -520,7 +520,7 @@ void ewol::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, const float
glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform1fv", __LINE__); //checkGlError("glUniform1fv", __LINE__);
} }
void ewol::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void ewol::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -542,7 +542,7 @@ void ewol::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, const float
glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform2fv", __LINE__); //checkGlError("glUniform2fv", __LINE__);
} }
void ewol::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void ewol::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -564,7 +564,7 @@ void ewol::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, const float
glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform3fv", __LINE__); //checkGlError("glUniform3fv", __LINE__);
} }
void ewol::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) { void ewol::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -589,7 +589,7 @@ void ewol::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, const float
////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void ewol::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -611,7 +611,7 @@ void ewol::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_
glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform1iv", __LINE__); //checkGlError("glUniform1iv", __LINE__);
} }
void ewol::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void ewol::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -633,7 +633,7 @@ void ewol::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_
glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform2iv", __LINE__); //checkGlError("glUniform2iv", __LINE__);
} }
void ewol::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void ewol::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -655,7 +655,7 @@ void ewol::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_
glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value); glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
//checkGlError("glUniform3iv", __LINE__); //checkGlError("glUniform3iv", __LINE__);
} }
void ewol::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) { void ewol::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -686,7 +686,7 @@ void ewol::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_
#endif #endif
void ewol::Program::use(void) { void ewol::resource::Program::use(void) {
#ifdef PROGRAM_DISPLAY_SPEED #ifdef PROGRAM_DISPLAY_SPEED
g_startTime = ewol::getTime(); g_startTime = ewol::getTime();
#endif #endif
@ -696,7 +696,7 @@ void ewol::Program::use(void) {
} }
void ewol::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) { void ewol::resource::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -721,7 +721,7 @@ void ewol::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) {
m_hasTexture = true; m_hasTexture = true;
} }
void ewol::Program::setTexture1(int32_t _idElem, GLint _textureOpenGlID) { void ewol::resource::Program::setTexture1(int32_t _idElem, GLint _textureOpenGlID) {
if (0 == m_program) { if (0 == m_program) {
return; return;
} }
@ -747,7 +747,7 @@ void ewol::Program::setTexture1(int32_t _idElem, GLint _textureOpenGlID) {
} }
void ewol::Program::unUse(void) { void ewol::resource::Program::unUse(void) {
//EWOL_WARNING("Will use program : " << m_program); //EWOL_WARNING("Will use program : " << m_program);
if (0 == m_program) { if (0 == m_program) {
return; return;
@ -774,9 +774,9 @@ void ewol::Program::unUse(void) {
ewol::Program* ewol::Program::keep(const std::string& _filename) { ewol::resource::Program* ewol::resource::Program::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\"");
ewol::Program* object = static_cast<ewol::Program*>(getManager().localKeep(_filename)); ewol::resource::Program* object = static_cast<ewol::resource::Program*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
@ -791,11 +791,11 @@ ewol::Program* ewol::Program::keep(const std::string& _filename) {
} }
void ewol::Program::release(ewol::Program*& _object) { void ewol::resource::Program::release(ewol::resource::Program*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -18,266 +18,268 @@
#include <ewol/resources/VirtualBufferObject.h> #include <ewol/resources/VirtualBufferObject.h>
namespace ewol { namespace ewol {
/** namespace resource {
* @brief In a openGL program we need some data to communicate with them, we register all the name requested by the user in this structure: /**
* @note Register all requested element permit to abstract the fact that some element does not exist and remove control of existance from upper code. * @brief In a openGL program we need some data to communicate with them, we register all the name requested by the user in this structure:
* This is important to note when the Program is reloaded the elements availlable can change. * @note Register all requested element permit to abstract the fact that some element does not exist and remove control of existance from upper code.
*/ * This is important to note when the Program is reloaded the elements availlable can change.
class progAttributeElement { */
public : class progAttributeElement {
std::string m_name; //!< Name of the element public :
GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked std::string m_name; //!< Name of the element
bool m_isAttribute; //!< true if it was an attribute element, otherwite it was an uniform GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked
bool m_isLinked; //!< if this element does not exist this is false bool m_isAttribute; //!< true if it was an attribute element, otherwite it was an uniform
}; bool m_isLinked; //!< if this element does not exist this is false
/** };
* @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation /**
* The input file must have the form : "myFile.prog" * @brief Program is a compilation of some fragment Shader and vertex Shader. This construct automaticly this assiciation
* The data is simple : * The input file must have the form : "myFile.prog"
* <pre> * The data is simple :
* # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ... * <pre>
* # The folder is automaticly get from the program file basic folder * # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ...
* filename1.vert * # The folder is automaticly get from the program file basic folder
* filename2.frag * filename1.vert
* filename3.vert * filename2.frag
* filename4.frag * filename3.vert
* </pre> * filename4.frag
*/ * </pre>
class Program : public ewol::Resource { */
private : class Program : public ewol::resource::Resource {
bool m_exist; //!< the file existed private :
GLuint m_program; //!< openGL id of the current program bool m_exist; //!< the file existed
std::vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded GLuint m_program; //!< openGL id of the current program
std::vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user std::vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded
bool m_hasTexture; //!< A texture has been set to the current shader std::vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
bool m_hasTexture1; //!< A texture has been set to the current shader bool m_hasTexture; //!< A texture has been set to the current shader
protected: bool m_hasTexture1; //!< A texture has been set to the current shader
/** protected:
* @brief Contructor of an opengl Program. /**
* @param[in] filename Standard file name format. see @ref etk::FSNode * @brief Contructor of an opengl Program.
*/ * @param[in] filename Standard file name format. see @ref etk::FSNode
Program(const std::string& filename); */
/** Program(const std::string& filename);
* @brief Destructor, remove the current Program. /**
*/ * @brief Destructor, remove the current Program.
virtual ~Program(void); */
public: virtual ~Program(void);
/** public:
* @brief Generic function that get the resouces name of his type. /**
* @return The define char of his name. * @brief Generic function that get the resouces name of his type.
*/ * @return The define char of his name.
const char* getType(void) { return "ewol::Program"; }; */
/** const char* getType(void) { return "ewol::Program"; };
* @brief User request an attribute on this program. /**
* @note The attribute is send to the fragment shaders * @brief User request an attribute on this program.
* @param[in] _elementName Name of the requested attribute. * @note The attribute is send to the fragment shaders
* @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded) * @param[in] _elementName Name of the requested attribute.
*/ * @return An abstract ID of the current attribute (this value is all time availlable, even if the program will be reloaded)
int32_t getAttribute(std::string _elementName); */
/** int32_t getAttribute(std::string _elementName);
* @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the openGL program). /**
* @param[in] _idElem Id of the Attribute that might be sended. * @brief Send attribute table to the spefified ID attribure (not send if does not really exist in the openGL program).
* @param[in] _nbElement Specifies the number of elements that are to be modified. * @param[in] _idElem Id of the Attribute that might be sended.
* @param[in] _pointer Pointer on the data that might be sended. * @param[in] _nbElement Specifies the number of elements that are to be modified.
* @param[in] _jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations) * @param[in] _pointer Pointer on the data that might be sended.
*/ * @param[in] _jumpBetweenSample Number of byte to jump between 2 vertex (this permit to enterlace informations)
void sendAttribute(int32_t _idElem, */
int32_t _nbElement, void sendAttribute(int32_t _idElem,
void* _pointer, int32_t _nbElement,
int32_t _jumpBetweenSample=0); void* _pointer,
void sendAttributePointer(int32_t _idElem, int32_t _jumpBetweenSample=0);
int32_t _nbElement, void sendAttributePointer(int32_t _idElem,
ewol::VirtualBufferObject* _vbo, int32_t _nbElement,
int32_t _index, ewol::VirtualBufferObject* _vbo,
int32_t _jumpBetweenSample=0, int32_t _index,
int32_t _offset=0); int32_t _jumpBetweenSample=0,
/** int32_t _offset=0);
* @brief User request an Uniform on this program. /**
* @note uniform value is availlable for all the fragment shader in the program (only one value for all) * @brief User request an Uniform on this program.
* @param[in] _elementName Name of the requested uniform. * @note uniform value is availlable for all the fragment shader in the program (only one value for all)
* @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded) * @param[in] _elementName Name of the requested uniform.
*/ * @return An abstract ID of the current uniform (this value is all time availlable, even if the program will be reloaded)
int32_t getUniform(std::string _elementName); */
/** int32_t getUniform(std::string _elementName);
* @brief Send a uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send a uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array. * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _pointer Pointer on the data that might be sended * @param[in] _nbElement Specifies the number of elements that are to be modified. This should be 1 if the targeted uniform variable is not an array, and 1 or more if it is an array.
* @param[in] _transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself) * @param[in] _pointer Pointer on the data that might be sended
*/ * @param[in] _transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself)
void uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _pointer, bool _transpose=true); */
/** void uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _pointer, bool _transpose=true);
* @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
*/ * @param[in] _value1 Value to send at the Uniform
void uniform1f(int32_t _idElem, float _value1); */
/** void uniform1f(int32_t _idElem, float _value1);
* @brief Send 2 float uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 2 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
*/ * @param[in] _value2 Value to send at the Uniform
void uniform2f(int32_t _idElem, float _value1, float _value2); */
/** void uniform2f(int32_t _idElem, float _value1, float _value2);
* @brief Send 3 float uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 3 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] _value3 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
*/ * @param[in] _value3 Value to send at the Uniform
void uniform3f(int32_t _idElem, float _value1, float _value2, float _value3); */
/** void uniform3f(int32_t _idElem, float _value1, float _value2, float _value3);
* @brief Send 4 float uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 4 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] _value3 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] _value4 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
*/ * @param[in] _value4 Value to send at the Uniform
void uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4); */
void uniform4f(int32_t _idElem, float _value1, float _value2, float _value3, float _value4);
/**
* @brief Send 1 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 1 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
*/ * @param[in] _value1 Value to send at the Uniform
void uniform1i(int32_t _idElem, int32_t _value1); */
/** void uniform1i(int32_t _idElem, int32_t _value1);
* @brief Send 2 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 2 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
*/ * @param[in] _value2 Value to send at the Uniform
void uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2); */
/** void uniform2i(int32_t _idElem, int32_t _value1, int32_t _value2);
* @brief Send 3 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 3 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] _value3 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
*/ * @param[in] _value3 Value to send at the Uniform
void uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3); */
/** void uniform3i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3);
* @brief Send 4 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send 4 signed integer uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _value1 Value to send at the Uniform * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value2 Value to send at the Uniform * @param[in] _value1 Value to send at the Uniform
* @param[in] _value3 Value to send at the Uniform * @param[in] _value2 Value to send at the Uniform
* @param[in] _value4 Value to send at the Uniform * @param[in] _value3 Value to send at the Uniform
*/ * @param[in] _value4 Value to send at the Uniform
void uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4); */
void uniform4i(int32_t _idElem, int32_t _value1, int32_t _value2, int32_t _value3, int32_t _value4);
/**
* @brief Send "vec1" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "vec1" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value); */
/** void uniform1fv(int32_t _idElem, int32_t _nbElement, const float *_value);
* @brief Send "vec2" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "vec2" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value); */
/** void uniform2fv(int32_t _idElem, int32_t _nbElement, const float *_value);
* @brief Send "vec3" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "vec3" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value); */
/** void uniform3fv(int32_t _idElem, int32_t _nbElement, const float *_value);
* @brief Send "vec4" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "vec4" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value); */
void uniform4fv(int32_t _idElem, int32_t _nbElement, const float *_value);
/**
* @brief Send "ivec1" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "ivec1" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value); */
/** void uniform1iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
* @brief Send "ivec2" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the Attribute that might be sended. * @brief Send "ivec2" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the Attribute that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value); */
/** void uniform2iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
* @brief Send "ivec3" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "ivec3" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value); */
/** void uniform3iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
* @brief Send "ivec4" uniform element to the spefified ID (not send if does not really exist in the openGL program) /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief Send "ivec4" uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _nbElement Number of element sended * @param[in] _idElem Id of the uniform that might be sended.
* @param[in] _value Pointer on the data * @param[in] _nbElement Number of element sended
*/ * @param[in] _value Pointer on the data
void uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value); */
void uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_t *_value);
inline void uniform2(int32_t _idElem, const vec2& _value) { uniform2fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform3(int32_t _idElem, const vec3& _value) { uniform3fv(_idElem, 1, &_value.m_floats[0]); }; inline void uniform2(int32_t _idElem, const vec2& _value) { uniform2fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform4(int32_t _idElem, const vec4& _value) { uniform4fv(_idElem, 1, &_value.m_floats[0]); }; inline void uniform3(int32_t _idElem, const vec3& _value) { uniform3fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform2(int32_t _idElem, const ivec2& _value) { uniform2iv(_idElem, 1, &_value.m_floats[0]); }; inline void uniform4(int32_t _idElem, const vec4& _value) { uniform4fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform3(int32_t _idElem, const ivec3& _value) { uniform3iv(_idElem, 1, &_value.m_floats[0]); }; inline void uniform2(int32_t _idElem, const ivec2& _value) { uniform2iv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform4(int32_t _idElem, const ivec4& _value) { uniform4iv(_idElem, 1, &_value.m_floats[0]); }; inline void uniform3(int32_t _idElem, const ivec3& _value) { uniform3iv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform4(int32_t _idElem, const ivec4& _value) { uniform4iv(_idElem, 1, &_value.m_floats[0]); };
/**
* @brief Request the processing of this program /**
*/ * @brief Request the processing of this program
void use(void); */
/** void use(void);
* @brief set the testure Id on the specify uniform element. /**
* @param[in] _idElem Id of the uniform that might be sended. * @brief set the testure Id on the specify uniform element.
* @param[in] _textureOpenGlID Real openGL texture ID * @param[in] _idElem Id of the uniform that might be sended.
*/ * @param[in] _textureOpenGlID Real openGL texture ID
void setTexture0(int32_t _idElem, GLint _textureOpenGlID); */
void setTexture1(int32_t _idElem, GLint _textureOpenGlID); void setTexture0(int32_t _idElem, GLint _textureOpenGlID);
/** void setTexture1(int32_t _idElem, GLint _textureOpenGlID);
* @brief Stop the processing of this program /**
*/ * @brief Stop the processing of this program
void unUse(void); */
/** void unUse(void);
* @brief This load/reload the data in the opengl context, needed when removed previously. /**
*/ * @brief This load/reload the data in the opengl context, needed when removed previously.
void updateContext(void); */
/** void updateContext(void);
* @brief remove the data from the opengl context. /**
*/ * @brief remove the data from the opengl context.
void removeContext(void); */
/** void removeContext(void);
* @brief Special android spec! It inform us that all context is removed and after notify us... /**
*/ * @brief Special android spec! It inform us that all context is removed and after notify us...
void removeContextToLate(void); */
/** void removeContextToLate(void);
* @brief Relode the shader from the file. used when a request of resouces reload is done. /**
* @note this is really usefull when we tested the new themes or shader developpements. * @brief Relode the shader from the file. used when a request of resouces reload is done.
*/ * @note this is really usefull when we tested the new themes or shader developpements.
void reload(void); */
public: void reload(void);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the openGL program. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the openGL program.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::Program* keep(const std::string& _filename); */
/** static ewol::Program* keep(const std::string& _filename);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::Program*& _object); */
static void release(ewol::Program*& _object);
};
}; };
}; };

View File

@ -15,22 +15,22 @@
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>
void ewol::Resource::updateContext(void) { void ewol::resource::Resource::updateContext(void) {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::removeContext(void) { void ewol::resource::Resource::removeContext(void) {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::removeContextToLate(void) { void ewol::resource::Resource::removeContextToLate(void) {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
} }
void ewol::Resource::reload(void) { void ewol::resource::Resource::reload(void) {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)"); EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
} }
ewol::ResourceManager& ewol::Resource::getManager(void) { ewol::resource::Manager& ewol::resource::Resource::getManager(void) {
return ewol::getContext().getResourcesManager(); return ewol::getContext().getResourcesManager();
} }

View File

@ -18,50 +18,52 @@
#define MAX_RESOURCE_LEVEL (5) #define MAX_RESOURCE_LEVEL (5)
namespace ewol { namespace ewol {
class ResourceManager; namespace resource {
// class resources is pure virtual class Manager;
class Resource : public ewol::EObject { // class resources is pure virtual
public: class Resource : public ewol::EObject {
Resource(void) : public:
m_counter(1), Resource(void) :
m_resourceLevel(MAX_RESOURCE_LEVEL-1) { m_counter(1),
addObjectType("ewol::Resource"); m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
setStatusResource(true); addObjectType("ewol::Resource");
}; setStatusResource(true);
Resource(const std::string& _name) : };
ewol::EObject(_name), Resource(const std::string& _name) :
m_counter(1), ewol::EObject(_name),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) { m_counter(1),
addObjectType("ewol::Resource"); m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
setStatusResource(true); addObjectType("ewol::Resource");
}; setStatusResource(true);
virtual ~Resource(void) { };
virtual ~Resource(void) {
};
private: };
uint32_t m_counter; //!< number of time the element was loaded. private:
public: uint32_t m_counter; //!< number of time the element was loaded.
void increment(void) { public:
m_counter++; void increment(void) {
}; m_counter++;
bool decrement(void) { };
m_counter--; bool decrement(void) {
return (m_counter == 0)?true:false; m_counter--;
}; return (m_counter == 0)?true:false;
int32_t getCounter(void) { };
return m_counter; int32_t getCounter(void) {
}; return m_counter;
protected: };
uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first. protected:
public: uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first.
uint8_t getResourceLevel(void) { public:
return m_resourceLevel; uint8_t getResourceLevel(void) {
}; return m_resourceLevel;
virtual void updateContext(void); };
virtual void removeContext(void); virtual void updateContext(void);
virtual void removeContextToLate(void); virtual void removeContext(void);
virtual void reload(void); virtual void removeContextToLate(void);
static ewol::ResourceManager& getManager(void); virtual void reload(void);
static ewol::resource::Manager& getManager(void);
};
}; };
}; };

View File

@ -1,83 +0,0 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __RESOURCES_MANAGER_H__
#define __RESOURCES_MANAGER_H__
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resources/Resource.h>
#include <ewol/resources/Shader.h>
#include <ewol/resources/Program.h>
#include <ewol/resources/VirtualBufferObject.h>
#include <ewol/resources/ConfigFile.h>
#include <ewol/resources/TexturedFont.h>
#include <ewol/resources/Texture.h>
#include <ewol/resources/Image.h>
#include <ewol/resources/Mesh.h>
#include <ewol/resources/Colored3DObject.h>
namespace ewol {
class ResourceManager {
private:
std::vector<ewol::Resource*> m_resourceList;
std::vector<ewol::Resource*> m_resourceListToUpdate;
bool m_contextHasBeenRemoved;
public:
/**
* @brief initialize the internal variable
*/
ResourceManager(void);
/**
* @brief Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after...
*/
~ResourceManager(void);
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit(void);
/**
* @brief display in the log all the resources loaded ...
*/
void display(void);
/**
* @brief Reload all resources from files, and send there in openGL card if needed.
* @note If file is reference at THEME:XXX:filename if the Theme change the file will reload the newOne
*/
void reLoadResources(void);
/**
* @brief Call by the system to send all the needed data on the graphic card chen they change ...
* @param[in] _object The resources that might be updated
*/
void update(ewol::Resource* _object);
/**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/
void updateContext(void);
/**
* @brief This is to inform the resources manager that we have no more openGl context ...
*/
void contextHasBeenDestroyed(void);
public:
// internal API to extent eResources in extern Soft
ewol::Resource* localKeep(const std::string& _filename);
void localAdd(ewol::Resource* _object);
public:
/**
* @brief release a resources and free it if the Last release is call.
* @param[in,out] _object element to realease == > is return at NULL value.
* @return true, if element is removed, and false for just decreasing counter
*/
bool release(ewol::Resource*& _object);
};
};
#endif

View File

@ -13,10 +13,10 @@
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#undef __class__ #undef __class__
#define __class__ "Shader" #define __class__ "resource::Shader"
ewol::Shader::Shader(const std::string& _filename) : ewol::resource::Shader::Shader(const std::string& _filename) :
ewol::Resource(_filename), ewol::resource::Resource(_filename),
m_exist(false), m_exist(false),
m_fileData(NULL), m_fileData(NULL),
m_shader(0), m_shader(0),
@ -37,7 +37,7 @@ ewol::Shader::Shader(const std::string& _filename) :
reload(); reload();
} }
ewol::Shader::~Shader(void) { ewol::resource::Shader::~Shader(void) {
if (NULL != m_fileData) { if (NULL != m_fileData) {
delete [] m_fileData; delete [] m_fileData;
m_fileData = NULL; m_fileData = NULL;
@ -57,7 +57,7 @@ static void checkGlError(const char* _op) {
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192) #define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = ""; static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
void ewol::Shader::updateContext(void) { void ewol::resource::Shader::updateContext(void) {
if (true == m_exist) { if (true == m_exist) {
// Do nothing == > too dangerous ... // Do nothing == > too dangerous ...
} else { } else {
@ -98,7 +98,7 @@ void ewol::Shader::updateContext(void) {
} }
} }
void ewol::Shader::removeContext(void) { void ewol::resource::Shader::removeContext(void) {
if (true == m_exist) { if (true == m_exist) {
glDeleteShader(m_shader); glDeleteShader(m_shader);
m_exist = false; m_exist = false;
@ -106,12 +106,12 @@ void ewol::Shader::removeContext(void) {
} }
} }
void ewol::Shader::removeContextToLate(void) { void ewol::resource::Shader::removeContextToLate(void) {
m_exist = false; m_exist = false;
m_shader = 0; m_shader = 0;
} }
void ewol::Shader::reload(void) { void ewol::resource::Shader::reload(void) {
etk::FSNode file(m_name); etk::FSNode file(m_name);
if (false == file.exist()) { if (false == file.exist()) {
EWOL_ERROR("File does not Exist : \"" << file << "\""); EWOL_ERROR("File does not Exist : \"" << file << "\"");
@ -149,14 +149,14 @@ void ewol::Shader::reload(void) {
updateContext(); updateContext();
} }
ewol::Shader* ewol::Shader::keep(const std::string& _filename) { ewol::resource::Shader* ewol::resource::Shader::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\""); EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\"");
ewol::Shader* object = static_cast<ewol::Shader*>(getManager().localKeep(_filename)); ewol::resource::Shader* object = static_cast<ewol::resource::Shader*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
// need to crate a new one ... // need to crate a new one ...
object = new ewol::Shader(_filename); object = new ewol::resource::Shader(_filename);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename); EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL; return NULL;
@ -165,11 +165,11 @@ ewol::Shader* ewol::Shader::keep(const std::string& _filename) {
return object; return object;
} }
void ewol::Shader::release(ewol::Shader*& _object) { void ewol::resource::Shader::release(ewol::resource::Shader*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -15,71 +15,73 @@
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol { namespace ewol {
/** namespace resource {
* @brief Shader is a specific resources for opengl, used only in @ref Program. This are components of the renderer pipe-line /**
*/ * @brief Shader is a specific resources for opengl, used only in @ref Program. This are components of the renderer pipe-line
class Shader : public ewol::Resource { */
private : class Shader : public ewol::resource::Resource {
bool m_exist; //!< The shader file existed and has been loaded private :
char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed) bool m_exist; //!< The shader file existed and has been loaded
GLuint m_shader; //!< opengl id of this element char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
GLenum m_type; //!< Type of the current shader(vertex/fragment) GLuint m_shader; //!< opengl id of this element
protected: GLenum m_type; //!< Type of the current shader(vertex/fragment)
/** protected:
* @brief Contructor of an opengl Shader /**
* @param[in] filename Standard file name format. see @ref etk::FSNode * @brief Contructor of an opengl Shader
*/ * @param[in] filename Standard file name format. see @ref etk::FSNode
Shader(const std::string& _filename); */
/** Shader(const std::string& _filename);
* @brief Destructor, remove the current Shader /**
*/ * @brief Destructor, remove the current Shader
virtual ~Shader(void); */
public: virtual ~Shader(void);
/** public:
* @brief Generic function that get the resouces name of his type. /**
* @return The define char of his name. * @brief Generic function that get the resouces name of his type.
*/ * @return The define char of his name.
const char* getType(void) { return "ewol::Shader"; }; */
/** const char* getType(void) { return "ewol::Shader"; };
* @brief get the opengl reference id of this shader. /**
* @return The opengl id. * @brief get the opengl reference id of this shader.
*/ * @return The opengl id.
GLuint getGL_ID(void) { return m_shader; }; */
/** GLuint getGL_ID(void) { return m_shader; };
* @brief get the opengl type of this shader. /**
* @return The type of this loaded shader. * @brief get the opengl type of this shader.
*/ * @return The type of this loaded shader.
GLenum getShaderType(void) { return m_type; }; */
/** GLenum getShaderType(void) { return m_type; };
* @brief This load/reload the data in the opengl context, needed when removed previously. /**
*/ * @brief This load/reload the data in the opengl context, needed when removed previously.
void updateContext(void); */
/** void updateContext(void);
* @brief remove the data from the opengl context. /**
*/ * @brief remove the data from the opengl context.
void removeContext(void); */
/** void removeContext(void);
* @brief Special android spec! It inform us that all context is removed and after notify us... /**
*/ * @brief Special android spec! It inform us that all context is removed and after notify us...
void removeContextToLate(void); */
/** void removeContextToLate(void);
* @brief Relode the shader from the file. used when a request of resouces reload is done. /**
* @note this is really usefull when we tested the new themes or shader developpements. * @brief Relode the shader from the file. used when a request of resouces reload is done.
*/ * @note this is really usefull when we tested the new themes or shader developpements.
void reload(void); */
public: void reload(void);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the openGL Shader. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the openGL Shader.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::Shader* keep(const std::string& _filename); */
/** static ewol::Shader* keep(const std::string& _filename);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::Shader*& _object); */
static void release(ewol::Shader*& _object);
};
}; };
}; };

View File

@ -14,7 +14,7 @@
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>
#undef __class__ #undef __class__
#define __class__ "Texture" #define __class__ "resource::Texture"
/** /**
* @brief get the next power 2 if the input * @brief get the next power 2 if the input
@ -34,26 +34,26 @@ static int32_t nextP2(int32_t _value) {
} }
ewol::Texture::Texture(const std::string& _filename) : ewol::resource::Texture::Texture(const std::string& _filename) :
ewol::Resource(_filename) { ewol::resource::Resource(_filename) {
addObjectType("ewol::Texture"); addObjectType("ewol::Texture");
m_loaded = false; m_loaded = false;
m_texId = 0; m_texId = 0;
m_endPointSize.setValue(1.0,1.0); m_endPointSize.setValue(1.0,1.0);
} }
ewol::Texture::Texture(void) { ewol::resource::Texture::Texture(void) {
addObjectType("ewol::Texture"); addObjectType("ewol::Texture");
m_loaded = false; m_loaded = false;
m_texId = 0; m_texId = 0;
m_endPointSize.setValue(1.0,1.0); m_endPointSize.setValue(1.0,1.0);
} }
ewol::Texture::~Texture(void) { ewol::resource::Texture::~Texture(void) {
removeContext(); removeContext();
} }
void ewol::Texture::updateContext(void) { void ewol::resource::Texture::updateContext(void) {
if (false == m_loaded) { if (false == m_loaded) {
// Request a new texture at openGl : // Request a new texture at openGl :
glGenTextures(1, &m_texId); glGenTextures(1, &m_texId);
@ -84,7 +84,7 @@ void ewol::Texture::updateContext(void) {
m_loaded = true; m_loaded = true;
} }
void ewol::Texture::removeContext(void) { void ewol::resource::Texture::removeContext(void) {
if (true == m_loaded) { if (true == m_loaded) {
// Request remove texture ... // Request remove texture ...
EWOL_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId); EWOL_INFO("TEXTURE: Rm [" << getId() << "] texId=" << m_texId);
@ -93,24 +93,24 @@ void ewol::Texture::removeContext(void) {
} }
} }
void ewol::Texture::removeContextToLate(void) { void ewol::resource::Texture::removeContextToLate(void) {
m_loaded = false; m_loaded = false;
m_texId=0; m_texId=0;
} }
void ewol::Texture::flush(void) { void ewol::resource::Texture::flush(void) {
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
getManager().update(this); getManager().update(this);
} }
void ewol::Texture::setImageSize(ivec2 _newSize) { void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) ); _newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
m_data.resize(_newSize); m_data.resize(_newSize);
} }
ewol::Texture* ewol::Texture::keep(void) { ewol::resource::Texture* ewol::resource::Texture::keep(void) {
// this element create a new one every time .... // this element create a new one every time ....
ewol::Texture* object = new ewol::Texture(); ewol::resource::Texture* object = new ewol::resource::Texture();
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??"); EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL; return NULL;
@ -119,11 +119,11 @@ ewol::Texture* ewol::Texture::keep(void) {
return object; return object;
} }
void ewol::Texture::release(ewol::Texture*& _object) { void ewol::resource::Texture::release(ewol::resource::Texture*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -16,52 +16,53 @@
#include <ewol/resources/Resource.h> #include <ewol/resources/Resource.h>
namespace ewol { namespace ewol {
class Texture : public ewol::Resource { namespace resource {
protected: class Texture : public ewol::resource::Resource {
// openGl Context propoerties : protected:
egami::Image m_data; // openGl Context propoerties :
// openGl textureID : egami::Image m_data;
GLuint m_texId; // openGl textureID :
// some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0 GLuint m_texId;
vec2 m_endPointSize; // some image are not square == > we need to sqared it to prevent some openGl api error the the displayable size is not all the time 0.0 -> 1.0
// internal state of the openGl system : vec2 m_endPointSize;
bool m_loaded; // internal state of the openGl system :
// Ewol internal API: bool m_loaded;
public: // Ewol internal API:
void updateContext(void); public:
void removeContext(void); void updateContext(void);
void removeContextToLate(void); void removeContext(void);
// middleware interface: void removeContextToLate(void);
public: // middleware interface:
GLuint getId(void) { return m_texId; }; public:
vec2 getUsableSize(void) { return m_endPointSize; }; GLuint getId(void) { return m_texId; };
// Public API: vec2 getUsableSize(void) { return m_endPointSize; };
protected: // Public API:
Texture(const std::string& _filename); protected:
Texture(void); Texture(const std::string& _filename);
~Texture(void); Texture(void);
public: ~Texture(void);
virtual const char* getType(void) { return "ewol::Texture"; }; public:
// you must set the size here, because it will be set in multiple of pow(2) virtual const char* getType(void) { return "ewol::Texture"; };
void setImageSize(ivec2 newSize); // you must set the size here, because it will be set in multiple of pow(2)
// get the reference on this image to draw nomething on it ... void setImageSize(ivec2 newSize);
inline egami::Image& get(void) { return m_data; }; // get the reference on this image to draw nomething on it ...
// flush the data to send it at the openGl system inline egami::Image& get(void) { return m_data; };
void flush(void); // flush the data to send it at the openGl system
public: void flush(void);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @return pointer on the resource or NULL if an error occured. * @note Never free this pointer by your own...
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::Texture* keep(void); */
/** static ewol::Texture* keep(void);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::Texture*& _object); */
static void release(ewol::Texture*& _object);
};
}; };
}; };
#endif #endif

View File

@ -40,10 +40,10 @@ etk::CCout& ewol::operator <<(etk::CCout& _os, enum ewol::font::mode _obj) {
} }
#undef __class__ #undef __class__
#define __class__ "TexturedFont" #define __class__ "resource::TexturedFont"
ewol::TexturedFont::TexturedFont(const std::string& _fontName) : ewol::resource::TexturedFont::TexturedFont(const std::string& _fontName) :
ewol::Texture(_fontName) { ewol::resource::Texture(_fontName) {
addObjectType("ewol::TexturedFont"); addObjectType("ewol::TexturedFont");
m_font[0] = NULL; m_font[0] = NULL;
m_font[1] = NULL; m_font[1] = NULL;
@ -217,13 +217,13 @@ ewol::TexturedFont::TexturedFont(const std::string& _fontName) :
EWOL_DEBUG(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic)); EWOL_DEBUG(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic));
} }
ewol::TexturedFont::~TexturedFont(void) { ewol::resource::TexturedFont::~TexturedFont(void) {
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) { for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
ewol::FontFreeType::release(m_font[iiiFontId]); ewol::FontFreeType::release(m_font[iiiFontId]);
} }
} }
bool ewol::TexturedFont::addGlyph(const char32_t& _val) { bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) {
bool hasChange = false; bool hasChange = false;
// for each font : // for each font :
for (int32_t iii=0; iii<4 ; iii++) { for (int32_t iii=0; iii<4 ; iii++) {
@ -291,7 +291,7 @@ bool ewol::TexturedFont::addGlyph(const char32_t& _val) {
return hasChange; return hasChange;
} }
int32_t ewol::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) { int32_t ewol::resource::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode) {
if (_charcode < 0x20) { if (_charcode < 0x20) {
return 0; return 0;
} else if (_charcode < 0x80) { } else if (_charcode < 0x80) {
@ -317,7 +317,7 @@ int32_t ewol::TexturedFont::getIndex(char32_t _charcode, const enum ewol::font::
return 0; return 0;
} }
ewol::GlyphProperty* ewol::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) { ewol::resource::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) {
//EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); //EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]);
int32_t index = getIndex(_charcode, _displayMode); int32_t index = getIndex(_charcode, _displayMode);
if( index < 0 if( index < 0
@ -336,15 +336,15 @@ ewol::GlyphProperty* ewol::TexturedFont::getGlyphPointer(const char32_t& _charco
return &((m_listElement[_displayMode])[index]); return &((m_listElement[_displayMode])[index]);
} }
ewol::TexturedFont* ewol::TexturedFont::keep(const std::string& _filename) { ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'"); EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'");
ewol::TexturedFont* object = static_cast<ewol::TexturedFont*>(getManager().localKeep(_filename)); ewol::resource::TexturedFont* object = static_cast<ewol::resource::TexturedFont*>(getManager().localKeep(_filename));
if (NULL != object) { if (NULL != object) {
return object; return object;
} }
// need to crate a new one ... // need to crate a new one ...
EWOL_DEBUG("CREATE: TexturedFont : file : '" << _filename << "'"); EWOL_DEBUG("CREATE: TexturedFont : file : '" << _filename << "'");
object = new ewol::TexturedFont(_filename); object = new ewol::resource::TexturedFont(_filename);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename); EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL; return NULL;
@ -353,13 +353,13 @@ ewol::TexturedFont* ewol::TexturedFont::keep(const std::string& _filename) {
return object; return object;
} }
void ewol::TexturedFont::release(ewol::TexturedFont*& _object) { void ewol::resource::TexturedFont::release(ewol::resource::TexturedFont*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
std::string name = _object->getName(); std::string name = _object->getName();
int32_t count = _object->getCounter() - 1; int32_t count = _object->getCounter() - 1;
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
if (getManager().release(object2) == true) { if (getManager().release(object2) == true) {
EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "' count=" << count); EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "' count=" << count);
//etk::displayBacktrace(false); //etk::displayBacktrace(false);

View File

@ -24,90 +24,90 @@ namespace ewol {
}; };
etk::CCout& operator <<(etk::CCout& _os, enum ewol::font::mode _obj); etk::CCout& operator <<(etk::CCout& _os, enum ewol::font::mode _obj);
class TexturedFont : public ewol::Texture { namespace resource {
private: class TexturedFont : public ewol::resource::Texture {
std::string m_fileName[4]; private:
int32_t m_size; std::string m_fileName[4];
int32_t m_height[4]; int32_t m_size;
// specific element to have the the know if the specify element is known... int32_t m_height[4];
// == > otherwise I can just generate italic ... // specific element to have the the know if the specify element is known...
// == > Bold is a little more complicated (maybe with the bordersize) // == > otherwise I can just generate italic ...
ewol::FontBase* m_font[4]; // == > Bold is a little more complicated (maybe with the bordersize)
enum ewol::font::mode m_modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode ewol::FontBase* m_font[4];
public: enum ewol::font::mode m_modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode
std::vector<GlyphProperty> m_listElement[4]; public:
private: std::vector<GlyphProperty> m_listElement[4];
// for the texture generation : private:
ivec2 m_lastGlyphPos[4]; // for the texture generation :
int32_t m_lastRawHeigh[4]; ivec2 m_lastGlyphPos[4];
protected: int32_t m_lastRawHeigh[4];
TexturedFont(const std::string& _fontName); protected:
~TexturedFont(void); TexturedFont(const std::string& _fontName);
public: ~TexturedFont(void);
const char* getType(void) { public:
return "ewol::TexturedFont"; const char* getType(void) {
}; return "ewol::TexturedFont";
/** };
* @brief get the display height of this font /**
* @param[in] _displayMode Mode to display the currrent font * @brief get the display height of this font
* @return Dimention of the font need between 2 lines * @param[in] _displayMode Mode to display the currrent font
*/ * @return Dimention of the font need between 2 lines
int32_t getHeight(const enum ewol::font::mode _displayMode = ewol::font::Regular) { */
return m_height[_displayMode]; int32_t getHeight(const enum ewol::font::mode _displayMode = ewol::font::Regular) {
}; return m_height[_displayMode];
/** };
* @brief get the font height (user friendly) /**
* @return Dimention of the font the user requested * @brief get the font height (user friendly)
*/ * @return Dimention of the font the user requested
int32_t getFontSize(void) { */
return m_size; int32_t getFontSize(void) {
}; return m_size;
/** };
* @brief get the ID of a unicode charcode /**
* @param[in] _charcode The unicodeValue * @brief get the ID of a unicode charcode
* @param[in] _displayMode Mode to display the currrent font * @param[in] _charcode The unicodeValue
* @return The ID in the table (if it does not exist : return 0) * @param[in] _displayMode Mode to display the currrent font
*/ * @return The ID in the table (if it does not exist : return 0)
int32_t getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode); */
/** int32_t getIndex(char32_t _charcode, const enum ewol::font::mode _displayMode);
* @brief get the pointer on the coresponding glyph /**
* @param[in] _charcode The unicodeValue * @brief get the pointer on the coresponding glyph
* @param[in] _displayMode Mode to display the currrent font * @param[in] _charcode The unicodeValue
* @return The pointer on the glyph == > never NULL * @param[in] _displayMode Mode to display the currrent font
*/ * @return The pointer on the glyph == > never NULL
ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode); */
/** ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode);
* @brief The wrapping mode is used to prevent the non existance of a specific mode. /**
* For exemple when a blod mode does not exist, this resend a regular mode. * @brief The wrapping mode is used to prevent the non existance of a specific mode.
* @param[in] _source The requested mode. * For exemple when a blod mode does not exist, this resend a regular mode.
* @return the best mode we have in stock. * @param[in] _source The requested mode.
*/ * @return the best mode we have in stock.
enum ewol::font::mode getWrappingMode(const enum ewol::font::mode _source) { */
return m_modeWraping[_source]; enum ewol::font::mode getWrappingMode(const enum ewol::font::mode _source) {
}; return m_modeWraping[_source];
public: };
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _filename Name of the texture font. * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _filename Name of the texture font.
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::TexturedFont* keep(const std::string& _filename); */
/** static ewol::TexturedFont* keep(const std::string& _filename);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::TexturedFont*& _object); */
private: static void release(ewol::TexturedFont*& _object);
/** private:
* @brief add a glyph in a texture font. /**
* @param[in] _val Char value to add. * @brief add a glyph in a texture font.
* @return true if the image size have change, false otherwise * @param[in] _val Char value to add.
*/ * @return true if the image size have change, false otherwise
bool addGlyph(const char32_t& _val); */
bool addGlyph(const char32_t& _val);
};
}; };
}; };
#endif #endif

View File

@ -13,9 +13,9 @@
#include <ewol/renderer/eContext.h> #include <ewol/renderer/eContext.h>
#undef __class__ #undef __class__
#define __class__ "VirtualBufferObject" #define __class__ "resource::VirtualBufferObject"
ewol::VirtualBufferObject::VirtualBufferObject(int32_t _number) : ewol::resource::VirtualBufferObject::VirtualBufferObject(int32_t _number) :
m_exist(false) { m_exist(false) {
addObjectType("ewol::VirtualBufferObject"); addObjectType("ewol::VirtualBufferObject");
m_nbVBO = etk_avg(1, _number, NB_VBO_MAX); m_nbVBO = etk_avg(1, _number, NB_VBO_MAX);
@ -27,15 +27,15 @@ ewol::VirtualBufferObject::VirtualBufferObject(int32_t _number) :
EWOL_DEBUG("OGL : load VBO count=\"" << _number << "\""); EWOL_DEBUG("OGL : load VBO count=\"" << _number << "\"");
} }
ewol::VirtualBufferObject::~VirtualBufferObject(void) { ewol::resource::VirtualBufferObject::~VirtualBufferObject(void) {
removeContext(); removeContext();
} }
void ewol::VirtualBufferObject::retreiveData(void) { void ewol::resource::VirtualBufferObject::retreiveData(void) {
EWOL_ERROR("TODO ... "); EWOL_ERROR("TODO ... ");
} }
void ewol::VirtualBufferObject::updateContext(void) { void ewol::resource::VirtualBufferObject::updateContext(void) {
if (false == m_exist) { if (false == m_exist) {
// Allocate and assign a Vertex Array Object to our handle // Allocate and assign a Vertex Array Object to our handle
glGenBuffers(m_nbVBO, m_vbo); glGenBuffers(m_nbVBO, m_vbo);
@ -55,7 +55,7 @@ void ewol::VirtualBufferObject::updateContext(void) {
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
} }
void ewol::VirtualBufferObject::removeContext(void) { void ewol::resource::VirtualBufferObject::removeContext(void) {
if (true == m_exist) { if (true == m_exist) {
EWOL_INFO("VBO: remove [" << getId() << "] OGl_Id=" << m_vbo[0] EWOL_INFO("VBO: remove [" << getId() << "] OGl_Id=" << m_vbo[0]
<< "/" << m_vbo[1] << "/" << m_vbo[1]
@ -69,31 +69,31 @@ void ewol::VirtualBufferObject::removeContext(void) {
} }
} }
void ewol::VirtualBufferObject::removeContextToLate(void) { void ewol::resource::VirtualBufferObject::removeContextToLate(void) {
m_exist = false; m_exist = false;
for (size_t iii=0; iii<NB_VBO_MAX; iii++) { for (size_t iii=0; iii<NB_VBO_MAX; iii++) {
m_vbo[iii] = 0; m_vbo[iii] = 0;
} }
} }
void ewol::VirtualBufferObject::reload(void) { void ewol::resource::VirtualBufferObject::reload(void) {
removeContext(); removeContext();
updateContext(); updateContext();
} }
void ewol::VirtualBufferObject::flush(void) { void ewol::resource::VirtualBufferObject::flush(void) {
// request to the manager to be call at the next update ... // request to the manager to be call at the next update ...
ewol::getContext().getResourcesManager().update(this); ewol::getContext().getResourcesManager().update(this);
} }
void ewol::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) { void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec3& _data) {
m_vboUsed[_id] = true; m_vboUsed[_id] = true;
m_buffer[_id].push_back(_data.x()); m_buffer[_id].push_back(_data.x());
m_buffer[_id].push_back(_data.y()); m_buffer[_id].push_back(_data.y());
m_buffer[_id].push_back(_data.z()); m_buffer[_id].push_back(_data.z());
} }
vec3 ewol::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) { vec3 ewol::resource::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID) {
if ((size_t)_elementID*3 > m_buffer[_id].size()) { if ((size_t)_elementID*3 > m_buffer[_id].size()) {
return vec3(0,0,0); return vec3(0,0,0);
} }
@ -102,17 +102,17 @@ vec3 ewol::VirtualBufferObject::getOnBufferVec3(int32_t _id, int32_t _elementID)
m_buffer[_id][3*_elementID+2]); m_buffer[_id][3*_elementID+2]);
} }
int32_t ewol::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) { int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) {
return m_buffer[_id].size()/3; return m_buffer[_id].size()/3;
} }
void ewol::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) { void ewol::resource::VirtualBufferObject::pushOnBuffer(int32_t _id, const vec2& _data) {
m_vboUsed[_id] = true; m_vboUsed[_id] = true;
m_buffer[_id].push_back(_data.x()); m_buffer[_id].push_back(_data.x());
m_buffer[_id].push_back(_data.y()); m_buffer[_id].push_back(_data.y());
} }
vec2 ewol::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) { vec2 ewol::resource::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID) {
if ((size_t)_elementID*2 > m_buffer[_id].size()) { if ((size_t)_elementID*2 > m_buffer[_id].size()) {
return vec2(0,0); return vec2(0,0);
} }
@ -120,13 +120,13 @@ vec2 ewol::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID)
m_buffer[_id][2*_elementID+1]); m_buffer[_id][2*_elementID+1]);
} }
int32_t ewol::VirtualBufferObject::sizeOnBufferVec2(int32_t _id) { int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec2(int32_t _id) {
return m_buffer[_id].size()/2; return m_buffer[_id].size()/2;
} }
ewol::VirtualBufferObject* ewol::VirtualBufferObject::keep(int32_t _number) { ewol::resource::VirtualBufferObject* ewol::resource::VirtualBufferObject::keep(int32_t _number) {
// this element create a new one every time .... // this element create a new one every time ....
ewol::VirtualBufferObject* object = new ewol::VirtualBufferObject(_number); ewol::resource::VirtualBufferObject* object = new ewol::resource::VirtualBufferObject(_number);
if (NULL == object) { if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??VBO??"); EWOL_ERROR("allocation error of a resource : ??VBO??");
return NULL; return NULL;
@ -135,11 +135,11 @@ ewol::VirtualBufferObject* ewol::VirtualBufferObject::keep(int32_t _number) {
return object; return object;
} }
void ewol::VirtualBufferObject::release(ewol::VirtualBufferObject*& _object) { void ewol::resource::VirtualBufferObject::release(ewol::resource::VirtualBufferObject*& _object) {
if (NULL == _object) { if (NULL == _object) {
return; return;
} }
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object); ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2); getManager().release(object2);
_object = NULL; _object = NULL;
} }

View File

@ -18,97 +18,99 @@
#define NB_VBO_MAX (20) #define NB_VBO_MAX (20)
namespace ewol { namespace ewol {
/** namespace resource {
* @brief VirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside /**
*/ * @brief VirtualBufferObject is a specific resources for opengl, this load the data directly in the graphic card ad keep these inside
class VirtualBufferObject : public ewol::Resource { */
private : class VirtualBufferObject : public ewol::resource::Resource {
size_t m_nbVBO; private :
bool m_exist; //!< This data is availlable in the Graphic card size_t m_nbVBO;
GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO bool m_exist; //!< This data is availlable in the Graphic card
bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ... GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO
std::vector<float> m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ... bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ...
protected: std::vector<float> m_buffer[NB_VBO_MAX]; //!< data that is availlable in the VBO system ...
/** protected:
* @brief Constructor of this VBO. /**
* @param[in] accesMode Acces mode : ??? * @brief Constructor of this VBO.
*/ * @param[in] accesMode Acces mode : ???
VirtualBufferObject(int32_t _number); */
/** VirtualBufferObject(int32_t _number);
* @brief Destructor of this VBO. /**
*/ * @brief Destructor of this VBO.
virtual ~VirtualBufferObject(void); */
public: virtual ~VirtualBufferObject(void);
/** public:
* @brief Generic function that get the resouces name of his type. /**
* @return The define char of his name. * @brief Generic function that get the resouces name of his type.
*/ * @return The define char of his name.
const char* getType(void) { return "ewol::VirtualBufferObject"; }; */
/** const char* getType(void) { return "ewol::VirtualBufferObject"; };
* @brief get the real openGL ID. /**
* @return the Ogl id reference of this VBO. * @brief get the real openGL ID.
*/ * @return the Ogl id reference of this VBO.
GLuint getGL_ID(int32_t id) { return m_vbo[id]; }; */
/** GLuint getGL_ID(int32_t id) { return m_vbo[id]; };
* @brief get a reference on hte buffer data for this VBO. /**
* @param[in] id Id of the buffer requested * @brief get a reference on hte buffer data for this VBO.
* @return A reference on the data. * @param[in] id Id of the buffer requested
*/ * @return A reference on the data.
std::vector<float>& getRefBuffer(int32_t id) { m_vboUsed[id] = true; return m_buffer[id]; }; */
/** std::vector<float>& getRefBuffer(int32_t id) { m_vboUsed[id] = true; return m_buffer[id]; };
* @brief push data on a buffer with a custum type : /**
* @param[in] id Id of the buffer requested. * @brief push data on a buffer with a custum type :
* @param[in] data Direct data that might be set. * @param[in] id Id of the buffer requested.
*/ * @param[in] data Direct data that might be set.
void pushOnBuffer(int32_t id, const vec3& data); */
vec3 getOnBufferVec3(int32_t id, int32_t elementID); void pushOnBuffer(int32_t id, const vec3& data);
int32_t sizeOnBufferVec3(int32_t id); vec3 getOnBufferVec3(int32_t id, int32_t elementID);
/** int32_t sizeOnBufferVec3(int32_t id);
* @brief push data on a buffer with a custum type : /**
* @param[in] id Id of the buffer requested. * @brief push data on a buffer with a custum type :
* @param[in] data Direct data that might be set. * @param[in] id Id of the buffer requested.
*/ * @param[in] data Direct data that might be set.
void pushOnBuffer(int32_t id, const vec2& data); */
vec2 getOnBufferVec2(int32_t id, int32_t elementID); void pushOnBuffer(int32_t id, const vec2& data);
int32_t sizeOnBufferVec2(int32_t id); vec2 getOnBufferVec2(int32_t id, int32_t elementID);
/** int32_t sizeOnBufferVec2(int32_t id);
* @brief get the data from the graphic card. /**
*/ * @brief get the data from the graphic card.
void retreiveData(void); */
/** void retreiveData(void);
* @brief Send the data to the graphic card. /**
*/ * @brief Send the data to the graphic card.
void flush(void); */
/** void flush(void);
* @brief This load/reload the data in the opengl context, needed when removed previously. /**
*/ * @brief This load/reload the data in the opengl context, needed when removed previously.
void updateContext(void); */
/** void updateContext(void);
* @brief remove the data from the opengl context. /**
*/ * @brief remove the data from the opengl context.
void removeContext(void); */
/** void removeContext(void);
* @brief Special android spec! It inform us that all context is removed and after notify us... /**
*/ * @brief Special android spec! It inform us that all context is removed and after notify us...
void removeContextToLate(void); */
/** void removeContextToLate(void);
* @brief Relode the shader from the file. used when a request of resouces reload is done. /**
* @note this is really usefull when we tested the new themes or shader developpements. * @brief Relode the shader from the file. used when a request of resouces reload is done.
*/ * @note this is really usefull when we tested the new themes or shader developpements.
void reload(void); */
public: void reload(void);
/** public:
* @brief keep the resource pointer. /**
* @note Never free this pointer by your own... * @brief keep the resource pointer.
* @param[in] _number Number of VBO needed * @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured. * @param[in] _number Number of VBO needed
*/ * @return pointer on the resource or NULL if an error occured.
static ewol::VirtualBufferObject* keep(int32_t _number); */
/** static ewol::VirtualBufferObject* keep(int32_t _number);
* @brief release the keeped resources /**
* @param[in,out] reference on the object pointer * @brief release the keeped resources
*/ * @param[in,out] reference on the object pointer
static void release(ewol::VirtualBufferObject*& _object); */
static void release(ewol::VirtualBufferObject*& _object);
};
}; };
}; };
#endif #endif

View File

@ -18,30 +18,32 @@
namespace ewol { namespace ewol {
class FontBase : public ewol::Resource { namespace resource {
public: class FontBase : public ewol::resource::Resource {
FontBase(const std::string& _fontName) : ewol::Resource(_fontName) {}; public:
FontBase(const std::string& _fontName) : ewol::Resource(_fontName) {};
virtual ~FontBase(void) { };
virtual ~FontBase(void) { };
const char* getType(void) { return "ewol::Font"; };
const char* getType(void) { return "ewol::Font"; };
virtual bool getGlyphProperty(int32_t _fontSize,
ewol::GlyphProperty& _property) = 0; virtual bool getGlyphProperty(int32_t _fontSize,
ewol::GlyphProperty& _property) = 0;
virtual bool drawGlyph(egami::Image& _imageOut,
int32_t _fontSize, virtual bool drawGlyph(egami::Image& _imageOut,
ivec2 _glyphPosition, int32_t _fontSize,
ewol::GlyphProperty& _property, ivec2 _glyphPosition,
int8_t _posInImage) = 0; ewol::GlyphProperty& _property,
int8_t _posInImage) = 0;
virtual vec2 getSize(int32_t _fontSize, const std::string& _unicodeString) = 0;
virtual vec2 getSize(int32_t _fontSize, const std::string& _unicodeString) = 0;
virtual int32_t getHeight(int32_t _fontSize) = 0;
virtual int32_t getHeight(int32_t _fontSize) = 0;
virtual void generateKerning(int32_t _fontSize, std::vector<ewol::GlyphProperty>& _listGlyph) { };
virtual void generateKerning(int32_t _fontSize, std::vector<ewol::GlyphProperty>& _listGlyph) { };
virtual void display(void) {};
virtual void display(void) {};
};
}; };
}; };

View File

@ -13,92 +13,94 @@
namespace ewol { namespace ewol {
/* namespace resource {
| | | | /*
| | | | | | | |
| | | | | | | |
Y | | | | | | | |
^ |------------| |------------| Y | | | |
| ^ |------------| |------------|
m_advance.y:/-> | |
| | m_advance.y:/-> |
| | | |
m_sizeTex.x/-> | | |------------| |------------| | |
| | | | | | | m_sizeTex.x/-> | | |------------| |------------|
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | A | | G | | | | | | | |
| | | | | | | | | | | A | | G |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
| | | | | | | | | | | | | |
\-> | | |------------| |------------| | | | | | | |
/--> | | \-> | | |------------| |------------|
\--> \-> | /--> | |
m_bearing.y | \--> \-> |
|____*________________________*____________>> X m_bearing.y |
|____*________________________*____________>> X
<------------------------> : m_advance.x
<------------------------> : m_advance.x
<------------> : m_sizeTexture.x
<------------> : m_sizeTexture.x
<---> : m_bearing.x
<---> : m_bearing.x
*/
*/
class GlyphProperty {
public: class GlyphProperty {
char32_t m_UVal; //!< Unicode value public:
private: char32_t m_UVal; //!< Unicode value
bool m_exist; private:
public: bool m_exist;
int32_t m_glyphIndex; //!< Glyph index in the system public:
ivec2 m_sizeTexture; //!< size of the element to display int32_t m_glyphIndex; //!< Glyph index in the system
ivec2 m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string) ivec2 m_sizeTexture; //!< size of the element to display
ivec2 m_advance; //!< space use in the display for this specific char ivec2 m_bearing; //!< offset to display the data (can be negatif id the texture sise is bigger than the theoric places in the string)
vec2 m_texturePosStart; //!< Texture normalised position (START) ivec2 m_advance; //!< space use in the display for this specific char
vec2 m_texturePosSize; //!< Texture normalised position (SIZE) vec2 m_texturePosStart; //!< Texture normalised position (START)
private: vec2 m_texturePosSize; //!< Texture normalised position (SIZE)
std::vector<ewol::Kerning> m_kerning; //!< kerning values of link of all elements private:
public: std::vector<ewol::Kerning> m_kerning; //!< kerning values of link of all elements
GlyphProperty(void) : public:
m_UVal(0), GlyphProperty(void) :
m_exist(true), m_UVal(0),
m_glyphIndex(0), m_exist(true),
m_sizeTexture(0,0), m_glyphIndex(0),
m_bearing(0,0), m_sizeTexture(0,0),
m_advance(0,0), m_bearing(0,0),
m_texturePosStart(0,0), m_advance(0,0),
m_texturePosSize(0,0) { m_texturePosStart(0,0),
m_texturePosSize(0,0) {
};
float kerningGet(const char32_t _charcode) { };
for(size_t iii=0; iii<m_kerning.size(); iii++ ) { float kerningGet(const char32_t _charcode) {
if (m_kerning[iii].m_UVal == _charcode) { for(size_t iii=0; iii<m_kerning.size(); iii++ ) {
return m_kerning[iii].m_value; if (m_kerning[iii].m_UVal == _charcode) {
return m_kerning[iii].m_value;
}
} }
} return 0;
return 0; };
}; void kerningAdd(const char32_t _charcode, float _value)
void kerningAdd(const char32_t _charcode, float _value) {
{ m_kerning.push_back(ewol::Kerning(_charcode, _value));
m_kerning.push_back(ewol::Kerning(_charcode, _value)); };
}; void kerningClear(void)
void kerningClear(void) {
{ m_kerning.clear();
m_kerning.clear(); };
}; /**
/** * @brief get the status of the char, if it exist or not in the FONT
* @brief get the status of the char, if it exist or not in the FONT * @return true if the char is availlable, false otherwise
* @return true if the char is availlable, false otherwise */
*/ bool exist(void) const { return m_exist; };
bool exist(void) const { return m_exist; }; /**
/** * @brief set the element doen not exist !!!
* @brief set the element doen not exist !!! */
*/ void setNotExist(void) { m_exist = false; };
void setNotExist(void) { m_exist = false; }; };
}; };
}; };

View File

@ -10,59 +10,61 @@
#define __EWOL_FONT_KERNING_H__ #define __EWOL_FONT_KERNING_H__
namespace ewol { namespace ewol {
/** namespace resource {
* @brief Kerning properties of one specific Glyph with an other /**
* @note The "Kerning" is the methode to provide a better display for some string like * @brief Kerning properties of one specific Glyph with an other
* the "VA" has 2 letter that overlap themself. This name Kerning * @note The "Kerning" is the methode to provide a better display for some string like
* * the "VA" has 2 letter that overlap themself. This name Kerning
* Without Kerning : *
* * Without Kerning :
* \ / /\ *
* \ / / \ * \ / /\
* \ / / \ * \ / / \
* \ / /______\ * \ / / \
* \ / / \ * \ / /______\
* \/ / \ * \ / / \
* v v a a * \/ / \
* * v v a a
* With Kerning : *
* * With Kerning :
* \ / /\ *
* \ / / \ * \ / /\
* \ / / \ * \ / / \
* \ / /______\ * \ / / \
* \ / / \ * \ / /______\
* \/ / \ * \ / / \
* v a v a * \/ / \
* * v a v a
*/ *
class Kerning { */
public: class Kerning {
char32_t m_UVal; //!< unicode value (the previous character that must be before) public:
float m_value; //!< kerning real offset char32_t m_UVal; //!< unicode value (the previous character that must be before)
public: float m_value; //!< kerning real offset
/** public:
* @brief Simple constructor that allow to allocate the std::vector element /**
*/ * @brief Simple constructor that allow to allocate the std::vector element
Kerning(void) : */
m_UVal(0), Kerning(void) :
m_value(0) { m_UVal(0),
m_value(0) {
};
/** };
* @brief Normal constructor /**
* @param[in] _charcode The Unicode value of the coresponding character that might be before * @brief Normal constructor
* @param[in] _value The Kerning value of the offset (nb pixel number) * @param[in] _charcode The Unicode value of the coresponding character that might be before
*/ * @param[in] _value The Kerning value of the offset (nb pixel number)
Kerning(const char32_t _charcode, const float _value) : */
m_UVal(_charcode), Kerning(const char32_t _charcode, const float _value) :
m_value(_value) { m_UVal(_charcode),
m_value(_value) {
};
/** };
* @brief normal destructor /**
*/ * @brief normal destructor
~Kerning(void) { }; */
~Kerning(void) { };
};
}; };
}; };

View File

@ -14,17 +14,17 @@
#define __class__ "Button" #define __class__ "Button"
const char* const widget::Button::eventPressed = "pressed"; const char* const ewol::widget::Button::eventPressed = "pressed";
const char* const widget::Button::eventDown = "down"; const char* const ewol::widget::Button::eventDown = "down";
const char* const widget::Button::eventUp = "up"; const char* const ewol::widget::Button::eventUp = "up";
const char* const widget::Button::eventEnter = "enter"; const char* const ewol::widget::Button::eventEnter = "enter";
const char* const widget::Button::eventLeave = "leave"; const char* const ewol::widget::Button::eventLeave = "leave";
const char* const widget::Button::eventValue = "value"; const char* const ewol::widget::Button::eventValue = "value";
const char* const widget::Button::configToggle = "toggle"; const char* const ewol::widget::Button::configToggle = "toggle";
const char* const widget::Button::configLock = "lock"; const char* const ewol::widget::Button::configLock = "lock";
const char* const widget::Button::configValue = "value"; const char* const ewol::widget::Button::configValue = "value";
const char* const widget::Button::configShaper = "shaper"; const char* const ewol::widget::Button::configShaper = "shaper";
// DEFINE for the shader display system : // DEFINE for the shader display system :
@ -35,23 +35,23 @@ const char* const widget::Button::configShaper = "shaper";
static ewol::Widget* Create(void) { static ewol::Widget* Create(void) {
return new widget::Button(); return new ewol::widget::Button();
} }
void widget::Button::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Button::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create); _widgetManager.addWidgetCreator(__class__,&Create);
} }
widget::Button::Button(const std::string& _shaperName) : ewol::widget::Button::Button(const std::string& _shaperName) :
m_shaper(_shaperName), m_shaper(_shaperName),
m_value(false), m_value(false),
m_lock(widget::Button::lockNone), m_lock(ewol::widget::Button::lockNone),
m_toggleMode(false), m_toggleMode(false),
m_mouseHover(false), m_mouseHover(false),
m_buttonPressed(false), m_buttonPressed(false),
m_selectableAreaPos(0,0), m_selectableAreaPos(0,0),
m_selectableAreaSize(0,0) { m_selectableAreaSize(0,0) {
addObjectType("widget::Button"); addObjectType("ewol::widget::Button");
// by default set no widget : // by default set no widget :
m_subWidget[0] = NULL; m_subWidget[0] = NULL;
m_subWidget[1] = NULL; m_subWidget[1] = NULL;
@ -77,17 +77,17 @@ widget::Button::Button(const std::string& _shaperName) :
} }
widget::Button::~Button(void) { ewol::widget::Button::~Button(void) {
} }
void widget::Button::setShaperName(const std::string& _shaperName) { void ewol::widget::Button::setShaperName(const std::string& _shaperName) {
m_shaper.setSource(_shaperName); m_shaper.setSource(_shaperName);
markToRedraw(); markToRedraw();
} }
void widget::Button::setSubWidget(ewol::Widget* _subWidget) { void ewol::widget::Button::setSubWidget(ewol::Widget* _subWidget) {
int32_t idWidget=0; int32_t idWidget=0;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
m_subWidget[idWidget]->removeObject(); m_subWidget[idWidget]->removeObject();
@ -100,7 +100,7 @@ void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
markToRedraw(); markToRedraw();
} }
void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) { void ewol::widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
int32_t idWidget=1; int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
m_subWidget[idWidget]->removeObject(); m_subWidget[idWidget]->removeObject();
@ -112,7 +112,7 @@ void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
requestUpdateSize(); requestUpdateSize();
} }
void widget::Button::calculateSize(const vec2& _availlable) { void ewol::widget::Button::calculateSize(const vec2& _availlable) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
// set minimal size // set minimal size
m_size = m_minSize; m_size = m_minSize;
@ -158,7 +158,7 @@ void widget::Button::calculateSize(const vec2& _availlable) {
} }
void widget::Button::calculateMinMaxSize(void) { void ewol::widget::Button::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
vec2 minimumSizeBase(0,0); vec2 minimumSizeBase(0,0);
vec2 minimumSizeToggle(0,0); vec2 minimumSizeToggle(0,0);
@ -182,7 +182,7 @@ void widget::Button::calculateMinMaxSize(void) {
markToRedraw(); markToRedraw();
} }
void widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){ if (true == m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
@ -201,12 +201,12 @@ void widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
} }
void widget::Button::onDraw(void) { void ewol::widget::Button::onDraw(void) {
// draw the shaaper (if needed indeed) // draw the shaaper (if needed indeed)
m_shaper.draw(); m_shaper.draw();
} }
void widget::Button::onRegenerateDisplay(void) { void ewol::widget::Button::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
m_shaper.clear(); m_shaper.clear();
@ -228,10 +228,10 @@ void widget::Button::onRegenerateDisplay(void) {
} }
} }
void widget::Button::setLock(enum buttonLock _lock) { void ewol::widget::Button::setLock(enum buttonLock _lock) {
if (m_lock != _lock) { if (m_lock != _lock) {
m_lock = _lock; m_lock = _lock;
if(widget::Button::lockAccess == _lock) { if(ewol::widget::Button::lockAccess == _lock) {
m_buttonPressed = false; m_buttonPressed = false;
m_mouseHover = false; m_mouseHover = false;
} }
@ -240,7 +240,7 @@ void widget::Button::setLock(enum buttonLock _lock) {
} }
} }
void widget::Button::setValue(bool _val) { void ewol::widget::Button::setValue(bool _val) {
if (m_value != _val) { if (m_value != _val) {
m_value = _val; m_value = _val;
CheckStatus(); CheckStatus();
@ -248,7 +248,7 @@ void widget::Button::setValue(bool _val) {
} }
} }
void widget::Button::setToggleMode(bool _togg) { void ewol::widget::Button::setToggleMode(bool _togg) {
if (m_toggleMode != _togg) { if (m_toggleMode != _togg) {
m_toggleMode = _togg; m_toggleMode = _togg;
if (m_value == true) { if (m_value == true) {
@ -260,9 +260,9 @@ void widget::Button::setToggleMode(bool _togg) {
} }
} }
bool widget::Button::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Button::onEventInput(const ewol::EventInput& _event) {
// disable event in the lock access mode : // disable event in the lock access mode :
if(widget::Button::lockAccess == m_lock) { if(ewol::widget::Button::lockAccess == m_lock) {
return false; return false;
} }
bool previousHoverState = m_mouseHover; bool previousHoverState = m_mouseHover;
@ -301,9 +301,9 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
} }
if(ewol::keyEvent::statusSingle == _event.getStatus()) { if(ewol::keyEvent::statusSingle == _event.getStatus()) {
if( ( m_value == true if( ( m_value == true
&& widget::Button::lockWhenPressed == m_lock) && ewol::widget::Button::lockWhenPressed == m_lock)
|| ( m_value == false || ( m_value == false
&& widget::Button::lockWhenReleased == m_lock) ) { && ewol::widget::Button::lockWhenReleased == m_lock) ) {
// nothing to do : Lock mode ... // nothing to do : Lock mode ...
// user might set himself the new correct value with @ref setValue(xxx) // user might set himself the new correct value with @ref setValue(xxx)
} else { } else {
@ -316,7 +316,7 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
if( false == m_toggleMode if( false == m_toggleMode
&& true == m_value) { && true == m_value) {
m_value = false; m_value = false;
//EWOL_DEBUG("Generate event : " << widget::Button::eventValue << " val=" << m_value); //EWOL_DEBUG("Generate event : " << ewol::widget::Button::eventValue << " val=" << m_value);
generateEventId(eventValue, std::to_string(m_value)); generateEventId(eventValue, std::to_string(m_value));
} }
} }
@ -332,7 +332,7 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
} }
bool widget::Button::onEventEntry(const ewol::EventEntry& _event) { bool ewol::widget::Button::onEventEntry(const ewol::EventEntry& _event) {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( _event.getType() == ewol::keyEvent::keyboardChar if( _event.getType() == ewol::keyEvent::keyboardChar
&& _event.getStatus() == ewol::keyEvent::statusDown && _event.getStatus() == ewol::keyEvent::statusDown
@ -343,7 +343,7 @@ bool widget::Button::onEventEntry(const ewol::EventEntry& _event) {
return false; return false;
} }
void widget::Button::CheckStatus(void) { void ewol::widget::Button::CheckStatus(void) {
if (true == m_buttonPressed) { if (true == m_buttonPressed) {
changeStatusIn(STATUS_PRESSED); changeStatusIn(STATUS_PRESSED);
} else { } else {
@ -359,7 +359,7 @@ void widget::Button::CheckStatus(void) {
} }
} }
void widget::Button::changeStatusIn(int32_t _newStatusId) { void ewol::widget::Button::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) { if (true == m_shaper.changeStatusIn(_newStatusId) ) {
periodicCallEnable(); periodicCallEnable();
markToRedraw(); markToRedraw();
@ -367,7 +367,7 @@ void widget::Button::changeStatusIn(int32_t _newStatusId) {
} }
void widget::Button::periodicCall(const ewol::EventTime& _event) { void ewol::widget::Button::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) { if (false == m_shaper.periodicCall(_event) ) {
periodicCallDisable(); periodicCallDisable();
} }
@ -375,7 +375,7 @@ void widget::Button::periodicCall(const ewol::EventTime& _event) {
} }
ewol::Widget* widget::Button::getWidgetNamed(const std::string& _widgetName) { ewol::Widget* ewol::widget::Button::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) { if (NULL!=tmpUpperWidget) {
return tmpUpperWidget; return tmpUpperWidget;
@ -396,7 +396,7 @@ ewol::Widget* widget::Button::getWidgetNamed(const std::string& _widgetName) {
} }
bool widget::Button::loadXML(exml::Element* _element) { bool ewol::widget::Button::loadXML(exml::Element* _element) {
if (NULL == _element) { if (NULL == _element) {
return false; return false;
} }
@ -447,7 +447,7 @@ bool widget::Button::loadXML(exml::Element* _element) {
return true; return true;
} }
bool widget::Button::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::Button::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) { if (true == ewol::Widget::onSetConfig(_conf)) {
return true; return true;
} }
@ -481,7 +481,7 @@ bool widget::Button::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::Button::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::Button::onGetConfig(const char* _config, std::string& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) { if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -19,155 +19,156 @@
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
* @brief a composed button is a button with an inside composed with the specify XML element == > this permit to generate standard element simple * @ingroup ewolWidgetGroup
*/ * @brief a composed button is a button with an inside composed with the specify XML element == > this permit to generate standard element simple
class Button : public ewol::Widget { */
public: class Button : public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
// Event list of properties static void init(ewol::WidgetManager& _widgetManager);
static const char* const eventPressed; // Event list of properties
static const char* const eventDown; static const char* const eventPressed;
static const char* const eventUp; static const char* const eventDown;
static const char* const eventEnter; static const char* const eventUp;
static const char* const eventLeave; static const char* const eventEnter;
static const char* const eventValue; static const char* const eventLeave;
// Config list of properties static const char* const eventValue;
static const char* const configToggle; // Config list of properties
static const char* const configLock; static const char* const configToggle;
static const char* const configValue; static const char* const configLock;
static const char* const configShaper; static const char* const configValue;
enum buttonLock{ static const char* const configShaper;
lockNone, //!< normal status of the button enum buttonLock{
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one lockNone, //!< normal status of the button
lockWhenReleased, //!< When the state is set in not pressed, the status stay in this one lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
lockAccess, //!< all event are trashed == > acctivity of the button is disable lockWhenReleased, //!< When the state is set in not pressed, the status stay in this one
}; lockAccess, //!< all event are trashed == > acctivity of the button is disable
private: };
ewol::Shaper m_shaper; //!< Compositing theme. private:
public: ewol::Shaper m_shaper; //!< Compositing theme.
/** public:
* @brief Constructor /**
* @param[in] _shaperName Shaper file properties * @brief Constructor
*/ * @param[in] _shaperName Shaper file properties
Button(const std::string& _shaperName="THEME:GUI:widgetButton.conf"); */
/** Button(const std::string& _shaperName="THEME:GUI:widgetButton.conf");
* @brief Destructor /**
*/ * @brief Destructor
virtual ~Button(void); */
/** virtual ~Button(void);
* @brief set the shaper name (use the contructer one this permit to not noad unused shaper) /**
* @param[in] _shaperName The new shaper filename * @brief set the shaper name (use the contructer one this permit to not noad unused shaper)
*/ * @param[in] _shaperName The new shaper filename
void setShaperName(const std::string& _shaperName); */
protected: void setShaperName(const std::string& _shaperName);
ewol::Widget* m_subWidget[2]; //!< subwidget of the button protected:
public: ewol::Widget* m_subWidget[2]; //!< subwidget of the button
/** public:
* @brief Specify the current widget /**
* @param[in] _subWidget Widget to add normal * @brief Specify the current widget
*/ * @param[in] _subWidget Widget to add normal
void setSubWidget(ewol::Widget* _subWidget); */
/** void setSubWidget(ewol::Widget* _subWidget);
* @brief Specify the current widget /**
* @param[in] _subWidget Widget to add Toggle * @brief Specify the current widget
*/ * @param[in] _subWidget Widget to add Toggle
void setSubWidgetToggle(ewol::Widget* _subWidget); */
/** void setSubWidgetToggle(ewol::Widget* _subWidget);
* @brief get the current displayed composition /**
* @return The base widget * @brief get the current displayed composition
*/ * @return The base widget
ewol::Widget* getSubWidget(void) const { */
return m_subWidget[0]; ewol::Widget* getSubWidget(void) const {
}; return m_subWidget[0];
/** };
* @brief get the current displayed composition /**
* @return The toggle widget * @brief get the current displayed composition
*/ * @return The toggle widget
ewol::Widget* getSubWidgetToggle(void) const { */
return m_subWidget[1]; ewol::Widget* getSubWidgetToggle(void) const {
}; return m_subWidget[1];
protected: };
bool m_value; //!< Current state of the button. protected:
public: bool m_value; //!< Current state of the button.
/** public:
* @brief set the currentValue of the Button (pressed or not) /**
* @note Work only in toggle mode * @brief set the currentValue of the Button (pressed or not)
* @param[in] _val New value of the button * @note Work only in toggle mode
*/ * @param[in] _val New value of the button
void setValue(bool _val); */
/** void setValue(bool _val);
* @brief get the current button value. /**
* @return True : The button is pressed. * @brief get the current button value.
* @return false : The button is released. * @return True : The button is pressed.
*/ * @return false : The button is released.
bool getValue(void) const { */
return m_value; bool getValue(void) const {
}; return m_value;
protected: };
enum buttonLock m_lock; //!< Current lock state of the button. protected:
public: enum buttonLock m_lock; //!< Current lock state of the button.
/** public:
* @brief set the button lock state. /**
* @param[in] _lock New lock mode of the button * @brief set the button lock state.
*/ * @param[in] _lock New lock mode of the button
void setLock(enum buttonLock _lock); */
/** void setLock(enum buttonLock _lock);
* @brief get the current button lock value. /**
* @return The requested lock mode * @brief get the current button lock value.
*/ * @return The requested lock mode
enum buttonLock getLock(void) const { */
return m_lock; enum buttonLock getLock(void) const {
}; return m_lock;
protected: };
bool m_toggleMode; //!< The button is able to toggle. protected:
public: bool m_toggleMode; //!< The button is able to toggle.
/** public:
* @brief change the toggle mode. /**
* @param[in] _togg New toggle mode * @brief change the toggle mode.
*/ * @param[in] _togg New toggle mode
void setToggleMode(bool _togg); */
/** void setToggleMode(bool _togg);
* @brief get the current toggle mode. /**
* @return the current toggle mode. * @brief get the current toggle mode.
*/ * @return the current toggle mode.
bool getToggleMode(void) const { */
return m_toggleMode; bool getToggleMode(void) const {
}; return m_toggleMode;
private: };
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). private:
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
// hover area : bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
vec2 m_selectableAreaPos; //!< Start position of the events // hover area :
vec2 m_selectableAreaSize; //!< size of the event positions vec2 m_selectableAreaPos; //!< Start position of the events
private: vec2 m_selectableAreaSize; //!< size of the event positions
/** private:
* @brief internal system to change the property of the current status /**
* @param[in] _newStatusId new state * @brief internal system to change the property of the current status
*/ * @param[in] _newStatusId new state
void changeStatusIn(int32_t _newStatusId); */
/** void changeStatusIn(int32_t _newStatusId);
* @brief update the status with the internal satte of the button ... /**
*/ * @brief update the status with the internal satte of the button ...
void CheckStatus(void); */
protected: // Derived function void CheckStatus(void);
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
public: // Derived function virtual bool onGetConfig(const char* _config, std::string& _result) const;
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void calculateSize(const vec2& _availlable); virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void); virtual void calculateSize(const vec2& _availlable);
virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual bool onEventEntry(const ewol::EventEntry& _event); virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool loadXML(exml::Element* _node); virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName); virtual bool loadXML(exml::Element* _node);
private: // derived function virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual void periodicCall(const ewol::EventTime& _event); private: // derived function
}; virtual void periodicCall(const ewol::EventTime& _event);
};
}; };
#endif #endif

View File

@ -31,18 +31,18 @@ extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Cha
static ewol::Widget* Create(void) { static ewol::Widget* Create(void) {
return new widget::ButtonColor(); return new ewol::widget::ButtonColor();
} }
void widget::ButtonColor::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::ButtonColor::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create); _widgetManager.addWidgetCreator(__class__,&Create);
} }
widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperName) : ewol::widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperName) :
m_shaper(_shaperName), m_shaper(_shaperName),
m_textColorFg(_baseColor), m_textColorFg(_baseColor),
m_widgetContextMenu(NULL) { m_widgetContextMenu(NULL) {
addObjectType("widget::ButtonColor"); addObjectType("ewol::widget::ButtonColor");
addEventId(ewolEventButtonColorChange); addEventId(ewolEventButtonColorChange);
changeStatusIn(STATUS_UP); changeStatusIn(STATUS_UP);
setCanHaveFocus(true); setCanHaveFocus(true);
@ -51,17 +51,17 @@ widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperNam
} }
widget::ButtonColor::~ButtonColor(void) { ewol::widget::ButtonColor::~ButtonColor(void) {
} }
void widget::ButtonColor::setShaperName(std::string _shaperName) { void ewol::widget::ButtonColor::setShaperName(std::string _shaperName) {
m_shaper.setSource(_shaperName); m_shaper.setSource(_shaperName);
} }
void widget::ButtonColor::calculateMinMaxSize(void) { void ewol::widget::ButtonColor::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString(); std::string label = m_textColorFg.getString();
vec3 minSize = m_text.calculateSize(label); vec3 minSize = m_text.calculateSize(label);
@ -72,13 +72,13 @@ void widget::ButtonColor::calculateMinMaxSize(void) {
void widget::ButtonColor::onDraw(void) { void ewol::widget::ButtonColor::onDraw(void) {
m_shaper.draw(); m_shaper.draw();
m_text.draw(); m_text.draw();
} }
void widget::ButtonColor::onRegenerateDisplay(void) { void ewol::widget::ButtonColor::onRegenerateDisplay(void) {
if (needRedraw() == false) { if (needRedraw() == false) {
return; return;
} }
@ -143,7 +143,7 @@ void widget::ButtonColor::onRegenerateDisplay(void) {
} }
bool widget::ButtonColor::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::ButtonColor::onEventInput(const ewol::EventInput& _event) {
bool previousHoverState = m_mouseHover; bool previousHoverState = m_mouseHover;
if(ewol::keyEvent::statusLeave == _event.getStatus()) { if(ewol::keyEvent::statusLeave == _event.getStatus()) {
m_mouseHover = false; m_mouseHover = false;
@ -219,17 +219,17 @@ bool widget::ButtonColor::onEventInput(const ewol::EventInput& _event) {
} }
void widget::ButtonColor::setValue(etk::Color<> _color) { void ewol::widget::ButtonColor::setValue(etk::Color<> _color) {
m_textColorFg = _color; m_textColorFg = _color;
markToRedraw(); markToRedraw();
} }
etk::Color<> widget::ButtonColor::getValue(void) { etk::Color<> ewol::widget::ButtonColor::getValue(void) {
return m_textColorFg; return m_textColorFg;
} }
void widget::ButtonColor::onReceiveMessage(const ewol::EMessage& _msg) { void ewol::widget::ButtonColor::onReceiveMessage(const ewol::EMessage& _msg) {
EWOL_INFO("Receive MSG : " << _msg.getData()); EWOL_INFO("Receive MSG : " << _msg.getData());
if (_msg.getMessage() == ewolEventColorChooserChange) { if (_msg.getMessage() == ewolEventColorChooserChange) {
m_textColorFg = _msg.getData(); m_textColorFg = _msg.getData();
@ -239,7 +239,7 @@ void widget::ButtonColor::onReceiveMessage(const ewol::EMessage& _msg) {
} }
void widget::ButtonColor::changeStatusIn(int32_t _newStatusId) { void ewol::widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) { if (true == m_shaper.changeStatusIn(_newStatusId) ) {
periodicCallEnable(); periodicCallEnable();
markToRedraw(); markToRedraw();
@ -248,7 +248,7 @@ void widget::ButtonColor::changeStatusIn(int32_t _newStatusId) {
void widget::ButtonColor::periodicCall(const ewol::EventTime& _event) { void ewol::widget::ButtonColor::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) { if (false == m_shaper.periodicCall(_event) ) {
periodicCallDisable(); periodicCallDisable();
} }

View File

@ -20,64 +20,66 @@
extern const char * const ewolEventButtonColorChange; extern const char * const ewolEventButtonColorChange;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class ButtonColor : public ewol::Widget { */
public: class ButtonColor : public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
private: static void init(ewol::WidgetManager& _widgetManager);
ewol::Shaper m_shaper; //!< Compositing theme. private:
ewol::Text m_text; //!< Compositing Test display. ewol::Shaper m_shaper; //!< Compositing theme.
etk::Color<> m_textColorFg; //!< Current color. ewol::Text m_text; //!< Compositing Test display.
widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu. etk::Color<> m_textColorFg; //!< Current color.
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)). widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu.
bool m_buttonPressed; //!< Flag to know if the button is curently pressed. bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
// hover area : bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
vec2 m_selectableAreaPos; //!< Start position of the events // hover area :
vec2 m_selectableAreaSize; //!< size of the event positions vec2 m_selectableAreaPos; //!< Start position of the events
public: vec2 m_selectableAreaSize; //!< size of the event positions
/** public:
* @brief Main constructor. /**
* @param[in] _baseColor basic displayed color. * @brief Main constructor.
* @param[in] _shaperName The new shaper filename. * @param[in] _baseColor basic displayed color.
*/ * @param[in] _shaperName The new shaper filename.
ButtonColor(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="THEME:GUI:widgetButton.conf"); */
/** ButtonColor(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="THEME:GUI:widgetButton.conf");
* @brief Main destructor. /**
*/ * @brief Main destructor.
virtual ~ButtonColor(void); */
/** virtual ~ButtonColor(void);
* @brief set the shaper name (use the contructer one this permit to not noad unused shaper). /**
* @param[in] _shaperName The new shaper filename. * @brief set the shaper name (use the contructer one this permit to not noad unused shaper).
*/ * @param[in] _shaperName The new shaper filename.
void setShaperName(std::string _shaperName); */
/** void setShaperName(std::string _shaperName);
* @brief get the current color of the color selection widget /**
* @return The current color * @brief get the current color of the color selection widget
*/ * @return The current color
etk::Color<> getValue(void); */
/** etk::Color<> getValue(void);
* @brief Specify the current color. /**
* @param[in] _color The new display color. * @brief Specify the current color.
*/ * @param[in] _color The new display color.
void setValue(etk::Color<> _color); */
protected: // Derived function void setValue(etk::Color<> _color);
virtual void onDraw(void); protected: // Derived function
public: // Derived function virtual void onDraw(void);
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual void onReceiveMessage(const ewol::EMessage& _msg); virtual bool onEventInput(const ewol::EventInput& _event);
private: virtual void onReceiveMessage(const ewol::EMessage& _msg);
/** private:
* @brief internal system to change the property of the current status /**
* @param[in] _newStatusId new state * @brief internal system to change the property of the current status
*/ * @param[in] _newStatusId new state
void changeStatusIn(int32_t _newStatusId); */
// Derived function void changeStatusIn(int32_t _newStatusId);
virtual void periodicCall(const ewol::EventTime& _event); // Derived function
virtual void periodicCall(const ewol::EventTime& _event);
};
}; };
}; };

View File

@ -16,15 +16,15 @@ extern const char * const ewolEventCheckBoxClicked = "ewol CheckBox Clicked";
#define __class__ "CheckBox" #define __class__ "CheckBox"
static ewol::Widget* Create(void) { static ewol::Widget* Create(void) {
return new widget::CheckBox(); return new ewol::widget::CheckBox();
} }
void widget::CheckBox::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::CheckBox::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create); _widgetManager.addWidgetCreator(__class__,&Create);
} }
widget::CheckBox::CheckBox(const std::string& _newLabel) { ewol::widget::CheckBox::CheckBox(const std::string& _newLabel) {
addObjectType("widget::CheckBox"); addObjectType("ewol::widget::CheckBox");
m_label = _newLabel; m_label = _newLabel;
addEventId(ewolEventCheckBoxClicked); addEventId(ewolEventCheckBoxClicked);
m_textColorFg = etk::color::black; m_textColorFg = etk::color::black;
@ -35,12 +35,12 @@ widget::CheckBox::CheckBox(const std::string& _newLabel) {
} }
widget::CheckBox::~CheckBox(void) { ewol::widget::CheckBox::~CheckBox(void) {
} }
void widget::CheckBox::calculateMinMaxSize(void) { void ewol::widget::CheckBox::calculateMinMaxSize(void) {
vec3 minSize = m_oObjectText.calculateSize(m_label); vec3 minSize = m_oObjectText.calculateSize(m_label);
float boxSize = etk_max(20, minSize.y()) + 5; float boxSize = etk_max(20, minSize.y()) + 5;
m_minSize.setX(boxSize+minSize.x()); m_minSize.setX(boxSize+minSize.x());
@ -49,12 +49,12 @@ void widget::CheckBox::calculateMinMaxSize(void) {
} }
void widget::CheckBox::setLabel(std::string _newLabel) { void ewol::widget::CheckBox::setLabel(std::string _newLabel) {
m_label = _newLabel; m_label = _newLabel;
markToRedraw(); markToRedraw();
} }
void widget::CheckBox::setValue(bool _val) { void ewol::widget::CheckBox::setValue(bool _val) {
if (m_value == _val) { if (m_value == _val) {
return; return;
} }
@ -62,16 +62,16 @@ void widget::CheckBox::setValue(bool _val) {
markToRedraw(); markToRedraw();
} }
bool widget::CheckBox::getValue(void) { bool ewol::widget::CheckBox::getValue(void) {
return m_value; return m_value;
} }
void widget::CheckBox::onDraw(void) { void ewol::widget::CheckBox::onDraw(void) {
m_oObjectDecoration.draw(); m_oObjectDecoration.draw();
m_oObjectText.draw(); m_oObjectText.draw();
} }
void widget::CheckBox::onRegenerateDisplay(void) { void ewol::widget::CheckBox::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
m_oObjectDecoration.clear(); m_oObjectDecoration.clear();
m_oObjectText.clear(); m_oObjectText.clear();
@ -99,7 +99,7 @@ void widget::CheckBox::onRegenerateDisplay(void) {
} }
} }
bool widget::CheckBox::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::CheckBox::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on checkbox ..."); //EWOL_DEBUG("Event on checkbox ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) { if (ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -118,7 +118,7 @@ bool widget::CheckBox::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
bool widget::CheckBox::onEventEntry(const ewol::EventEntry& _event) { bool ewol::widget::CheckBox::onEventEntry(const ewol::EventEntry& _event) {
//EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data)); //EWOL_DEBUG("BT PRESSED : \"" << UTF8_data << "\" size=" << strlen(UTF8_data));
if( _event.getType() == ewol::keyEvent::keyboardChar if( _event.getType() == ewol::keyEvent::keyboardChar
&& _event.getStatus() == ewol::keyEvent::statusDown && _event.getStatus() == ewol::keyEvent::statusDown

View File

@ -18,35 +18,36 @@
extern const char* const ewolEventCheckBoxClicked; extern const char* const ewolEventCheckBoxClicked;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class CheckBox : public ewol::Widget { */
public: class CheckBox : public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
public: static void init(ewol::WidgetManager& _widgetManager);
CheckBox(const std::string& newLabel = "No Label"); public:
virtual ~CheckBox(void); CheckBox(const std::string& newLabel = "No Label");
void setLabel(std::string newLabel); virtual ~CheckBox(void);
void setValue(bool val); void setLabel(std::string newLabel);
bool getValue(void); void setValue(bool val);
private: bool getValue(void);
ewol::Text m_oObjectText; private:
ewol::Drawing m_oObjectDecoration; ewol::Text m_oObjectText;
std::string m_label; ewol::Drawing m_oObjectDecoration;
bool m_value; std::string m_label;
etk::Color<> m_textColorFg; //!< Text color bool m_value;
etk::Color<> m_textColorBg; //!< Background color etk::Color<> m_textColorFg; //!< Text color
protected: // Derived function etk::Color<> m_textColorBg; //!< Background color
virtual void onDraw(void); protected: // Derived function
public: // Derived function virtual void onDraw(void);
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool onEventEntry(const ewol::EventEntry& _event); virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
};
}; };
}; };
#endif #endif

View File

@ -20,8 +20,8 @@ extern const char * const ewolEventColorBarChange = "ewol-color-bar-change";
#undef __class__ #undef __class__
#define __class__ "ColorBar" #define __class__ "ColorBar"
widget::ColorBar::ColorBar(void) { ewol::widget::ColorBar::ColorBar(void) {
addObjectType("widget::ColorBar"); addObjectType("ewol::widget::ColorBar");
addEventId(ewolEventColorBarChange); addEventId(ewolEventColorBarChange);
m_currentUserPos.setValue(0,0); m_currentUserPos.setValue(0,0);
m_currentColor = etk::color::black; m_currentColor = etk::color::black;
@ -29,12 +29,12 @@ widget::ColorBar::ColorBar(void) {
setMouseLimit(1); setMouseLimit(1);
} }
widget::ColorBar::~ColorBar(void) { ewol::widget::ColorBar::~ColorBar(void) {
} }
void widget::ColorBar::calculateMinMaxSize(void) { void ewol::widget::ColorBar::calculateMinMaxSize(void) {
m_minSize.setValue(160, 80); m_minSize.setValue(160, 80);
markToRedraw(); markToRedraw();
} }
@ -52,22 +52,22 @@ static etk::Color<> s_listColor[NB_BAND_COLOR+1] = {
0xFF0000FF 0xFF0000FF
}; };
etk::Color<> widget::ColorBar::getCurrentColor(void) { etk::Color<> ewol::widget::ColorBar::getCurrentColor(void) {
return m_currentColor; return m_currentColor;
} }
void widget::ColorBar::setCurrentColor(etk::Color<> newOne) { void ewol::widget::ColorBar::setCurrentColor(etk::Color<> newOne) {
m_currentColor = newOne; m_currentColor = newOne;
m_currentColor.setA(0xFF); m_currentColor.setA(0xFF);
// estimate the cursor position : // estimate the cursor position :
// TODO : Later when really needed ... // TODO : Later when really needed ...
} }
void widget::ColorBar::onDraw(void) { void ewol::widget::ColorBar::onDraw(void) {
m_draw.draw(); m_draw.draw();
} }
void widget::ColorBar::onRegenerateDisplay(void) { void ewol::widget::ColorBar::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
// clean the object list ... // clean the object list ...
m_draw.clear(); m_draw.clear();
@ -165,7 +165,7 @@ void widget::ColorBar::onRegenerateDisplay(void) {
} }
bool widget::ColorBar::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::ColorBar::onEventInput(const ewol::EventInput& _event) {
vec2 relativePos = relativePosition(_event.getPos()); vec2 relativePos = relativePosition(_event.getPos());
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {

View File

@ -17,28 +17,29 @@
extern const char * const ewolEventColorBarChange; extern const char * const ewolEventColorBarChange;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class ColorBar :public ewol::Widget { */
public: class ColorBar :public ewol::Widget {
ColorBar(void); public:
virtual ~ColorBar(void); ColorBar(void);
etk::Color<> getCurrentColor(void); virtual ~ColorBar(void);
void setCurrentColor(etk::Color<> _newOne); etk::Color<> getCurrentColor(void);
private: void setCurrentColor(etk::Color<> _newOne);
ewol::Drawing m_draw; //!< Compositing drawing element private:
etk::Color<> m_currentColor; ewol::Drawing m_draw; //!< Compositing drawing element
vec2 m_currentUserPos; etk::Color<> m_currentColor;
protected: // Derived function vec2 m_currentUserPos;
virtual void onDraw(void); protected: // Derived function
public: // Derived function virtual void onDraw(void);
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
};
}; };
}; };
#endif #endif

View File

@ -13,32 +13,32 @@
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
#undef __class__ #undef __class__
#define __class__ "widget::Composer" #define __class__ "ewol::widget::Composer"
widget::Composer::Composer(void) { ewol::widget::Composer::Composer(void) {
// nothing to do ... // nothing to do ...
} }
widget::Composer::Composer(enum composerMode _mode, const std::string& _fileName) { ewol::widget::Composer::Composer(enum composerMode _mode, const std::string& _fileName) {
addObjectType("widget::Composer"); addObjectType("ewol::widget::Composer");
switch(_mode) { switch(_mode) {
case widget::Composer::None: case ewol::widget::Composer::None:
// nothing to do ... // nothing to do ...
break; break;
case widget::Composer::String: case ewol::widget::Composer::String:
loadFromString(_fileName); loadFromString(_fileName);
break; break;
case widget::Composer::file: case ewol::widget::Composer::file:
loadFromFile(_fileName); loadFromFile(_fileName);
break; break;
} }
} }
widget::Composer::~Composer(void) { ewol::widget::Composer::~Composer(void) {
} }
bool widget::Composer::loadFromFile(const std::string& _fileName) { bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) {
exml::Document doc; exml::Document doc;
if (doc.load(_fileName) == false) { if (doc.load(_fileName) == false) {
EWOL_ERROR(" can not load file XML : " << _fileName); EWOL_ERROR(" can not load file XML : " << _fileName);
@ -63,7 +63,7 @@ bool widget::Composer::loadFromFile(const std::string& _fileName) {
return true; return true;
} }
bool widget::Composer::loadFromString(const std::string& _composerXmlString) { bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) {
exml::Document doc; exml::Document doc;
if (doc.parse(_composerXmlString) == false) { if (doc.parse(_composerXmlString) == false) {
EWOL_ERROR(" can not load file XML string..."); EWOL_ERROR(" can not load file XML string...");
@ -89,18 +89,18 @@ bool widget::Composer::loadFromString(const std::string& _composerXmlString) {
} }
void widget::Composer::registerOnEventNameWidget(const std::string& _subWidgetName, void ewol::widget::Composer::registerOnEventNameWidget(const std::string& _subWidgetName,
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated, const char * _eventIdgenerated,
const std::string& _overloadData) { const std::string& _overloadData) {
registerOnEventNameWidget(this, _subWidgetName, _eventId, _eventIdgenerated, _overloadData); registerOnEventNameWidget(this, _subWidgetName, _eventId, _eventIdgenerated, _overloadData);
} }
void widget::Composer::registerOnEventNameWidget(ewol::EObject * _destinationObject, void ewol::widget::Composer::registerOnEventNameWidget(ewol::EObject * _destinationObject,
const std::string& _subWidgetName, const std::string& _subWidgetName,
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated, const char * _eventIdgenerated,
const std::string& _overloadData) { const std::string& _overloadData) {
ewol::Widget* tmpWidget = getWidgetNamed(_subWidgetName); ewol::Widget* tmpWidget = getWidgetNamed(_subWidgetName);
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
//EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\""); //EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\"");

View File

@ -13,74 +13,75 @@
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/widget/Container.h> #include <ewol/widget/Container.h>
namespace widget namespace ewol {
{ namespace widget {
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
* @brief the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree * @brief the composer widget is a widget that create a link on a string.file to parse the data and generate some widget tree
*/ */
class Composer : public widget::Container { class Composer : public widget::Container {
public: public:
enum composerMode { enum composerMode {
None, None,
String, String,
file file
}; };
public: public:
/** /**
* @brief Constructor * @brief Constructor
*/ */
Composer(void); Composer(void);
/** /**
* @brief Constructor * @brief Constructor
* @param[in] _mode mode of parsing the string * @param[in] _mode mode of parsing the string
* @param[in] _data file/directString data to generate compositing of the widget.. * @param[in] _data file/directString data to generate compositing of the widget..
*/ */
Composer(enum composerMode _mode, const std::string& _data); Composer(enum composerMode _mode, const std::string& _data);
/** /**
* @brief Destructor * @brief Destructor
*/ */
~Composer(void); ~Composer(void);
/** /**
* @brief load a composition with a file * @brief load a composition with a file
* @param[in] _fileName Name of the file * @param[in] _fileName Name of the file
* @return true == > all done OK * @return true == > all done OK
* @return false == > some error occured * @return false == > some error occured
*/ */
bool loadFromFile(const std::string& _fileName); bool loadFromFile(const std::string& _fileName);
/** /**
* @brief load a composition with a file * @brief load a composition with a file
* @param[in] _composerXmlString xml to parse directly * @param[in] _composerXmlString xml to parse directly
* @return true == > all done OK * @return true == > all done OK
* @return false == > some error occured * @return false == > some error occured
*/ */
bool loadFromString(const std::string& _composerXmlString); bool loadFromString(const std::string& _composerXmlString);
/** /**
* @brief Register an Event an named widget. @see registerOnEvent * @brief Register an Event an named widget. @see registerOnEvent
* @param[in] _subWidgetName Name of the subWidget. * @param[in] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object. * @param[in] _eventId Event generate inside the object.
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
* @param[in] _overloadData When the user prever to receive a data specificly for this event ... * @param[in] _overloadData When the user prever to receive a data specificly for this event ...
* @note : To used when herited from this object. * @note : To used when herited from this object.
*/ */
void registerOnEventNameWidget(const std::string& _subWidgetName, void registerOnEventNameWidget(const std::string& _subWidgetName,
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated = NULL, const char * _eventIdgenerated = NULL,
const std::string& _overloadData=""); const std::string& _overloadData="");
/** /**
* @brief Register an Event an named widget. @see registerOnEvent * @brief Register an Event an named widget. @see registerOnEvent
* @param[in] _destinationObject pointer on the object that might be call when an event is generated * @param[in] _destinationObject pointer on the object that might be call when an event is generated
* @param[in] _subWidgetName Name of the subWidget. * @param[in] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object. * @param[in] _eventId Event generate inside the object.
* @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...) * @param[in] _eventIdgenerated event generated when call the distant EObject.onReceiveMessage(...)
* @param[in] _overloadData When the user prever to receive a data specificly for this event ... * @param[in] _overloadData When the user prever to receive a data specificly for this event ...
* @note : To used when NOT herited from this object. * @note : To used when NOT herited from this object.
*/ */
void registerOnEventNameWidget(ewol::EObject * _destinationObject, void registerOnEventNameWidget(ewol::EObject * _destinationObject,
const std::string& _subWidgetName, const std::string& _subWidgetName,
const char * _eventId, const char * _eventId,
const char * _eventIdgenerated = NULL, const char * _eventIdgenerated = NULL,
const std::string& _overloadData=""); const std::string& _overloadData="");
};
}; };
}; };

View File

@ -16,21 +16,21 @@
#define __class__ "Container" #define __class__ "Container"
widget::Container::Container(ewol::Widget* _subElement) : ewol::widget::Container::Container(ewol::Widget* _subElement) :
m_subWidget(_subElement) { m_subWidget(_subElement) {
addObjectType("widget::Container"); addObjectType("ewol::widget::Container");
// nothing to do ... // nothing to do ...
} }
widget::Container::~Container(void) { ewol::widget::Container::~Container(void) {
subWidgetRemove(); subWidgetRemove();
} }
ewol::Widget* widget::Container::getSubWidget(void) { ewol::Widget* ewol::widget::Container::getSubWidget(void) {
return m_subWidget; return m_subWidget;
} }
void widget::Container::setSubWidget(ewol::Widget* _newWidget) { void ewol::widget::Container::setSubWidget(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
} }
@ -43,7 +43,7 @@ void widget::Container::setSubWidget(ewol::Widget* _newWidget) {
requestUpdateSize(); requestUpdateSize();
} }
void widget::Container::subWidgetRemove(void) { void ewol::widget::Container::subWidgetRemove(void) {
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
m_subWidget->removeUpperWidget(); m_subWidget->removeUpperWidget();
delete(m_subWidget); delete(m_subWidget);
@ -56,7 +56,7 @@ void widget::Container::subWidgetRemove(void) {
} }
} }
void widget::Container::subWidgetRemoveDelayed(void) { void ewol::widget::Container::subWidgetRemoveDelayed(void) {
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
m_subWidget->removeUpperWidget(); m_subWidget->removeUpperWidget();
m_subWidget->removeObject(); m_subWidget->removeObject();
@ -66,7 +66,7 @@ void widget::Container::subWidgetRemoveDelayed(void) {
} }
} }
ewol::Widget* widget::Container::getWidgetNamed(const std::string& _widgetName) { ewol::Widget* ewol::widget::Container::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) { if (NULL!=tmpUpperWidget) {
return tmpUpperWidget; return tmpUpperWidget;
@ -77,7 +77,7 @@ ewol::Widget* widget::Container::getWidgetNamed(const std::string& _widgetName)
return NULL; return NULL;
} }
void widget::Container::onObjectRemove(ewol::EObject* _removeObject) { void ewol::widget::Container::onObjectRemove(ewol::EObject* _removeObject) {
if (m_subWidget == _removeObject) { if (m_subWidget == _removeObject) {
m_subWidget=NULL; m_subWidget=NULL;
markToRedraw(); markToRedraw();
@ -85,7 +85,7 @@ void widget::Container::onObjectRemove(ewol::EObject* _removeObject) {
} }
} }
void widget::Container::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::Container::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){ if (true == m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
@ -98,7 +98,7 @@ void widget::Container::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
void widget::Container::calculateSize(const vec2& _availlable) { void ewol::widget::Container::calculateSize(const vec2& _availlable) {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
vec2 origin = m_origin+m_offset; vec2 origin = m_origin+m_offset;
vec2 minSize = m_subWidget->getCalculateMinSize(); vec2 minSize = m_subWidget->getCalculateMinSize();
@ -125,7 +125,7 @@ void widget::Container::calculateSize(const vec2& _availlable) {
ewol::Widget::calculateSize(_availlable); ewol::Widget::calculateSize(_availlable);
} }
void widget::Container::calculateMinMaxSize(void) { void ewol::widget::Container::calculateMinMaxSize(void) {
// call main class // call main class
ewol::Widget::calculateMinMaxSize(); ewol::Widget::calculateMinMaxSize();
// call sub classes // call sub classes
@ -137,13 +137,13 @@ void widget::Container::calculateMinMaxSize(void) {
//EWOL_ERROR("[" << getId() << "] Result min size : " << m_minSize); //EWOL_ERROR("[" << getId() << "] Result min size : " << m_minSize);
} }
void widget::Container::onRegenerateDisplay(void) { void ewol::widget::Container::onRegenerateDisplay(void) {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
m_subWidget->onRegenerateDisplay(); m_subWidget->onRegenerateDisplay();
} }
} }
ewol::Widget* widget::Container::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::Container::getWidgetAtPos(const vec2& _pos) {
if (false == isHide()) { if (false == isHide()) {
if (NULL!=m_subWidget) { if (NULL!=m_subWidget) {
return m_subWidget->getWidgetAtPos(_pos); return m_subWidget->getWidgetAtPos(_pos);
@ -153,7 +153,7 @@ ewol::Widget* widget::Container::getWidgetAtPos(const vec2& _pos) {
}; };
bool widget::Container::loadXML(exml::Element* _node) { bool ewol::widget::Container::loadXML(exml::Element* _node) {
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -194,7 +194,7 @@ bool widget::Container::loadXML(exml::Element* _node) {
return true; return true;
} }
void widget::Container::setOffset(const vec2& _newVal) { void ewol::widget::Container::setOffset(const vec2& _newVal) {
if (m_offset != _newVal) { if (m_offset != _newVal) {
ewol::Widget::setOffset(_newVal); ewol::Widget::setOffset(_newVal);
// recalculate the new sise and position of sub widget ... // recalculate the new sise and position of sub widget ...

View File

@ -13,53 +13,55 @@
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
* @brief the Cotainer widget is a widget that have an only one subWidget * @ingroup ewolWidgetGroup
*/ * @brief the Cotainer widget is a widget that have an only one subWidget
class Container : public ewol::Widget { */
protected: class Container : public ewol::Widget {
ewol::Widget* m_subWidget; protected:
public: ewol::Widget* m_subWidget;
/** public:
* @brief Constructor /**
*/ * @brief Constructor
Container(ewol::Widget* _subElement=NULL); */
/** Container(ewol::Widget* _subElement=NULL);
* @brief Destructor /**
*/ * @brief Destructor
~Container(void); */
public: ~Container(void);
/** public:
* @brief get the main node widget /**
* @return the requested pointer on the node * @brief get the main node widget
*/ * @return the requested pointer on the node
ewol::Widget* getSubWidget(void); */
/** ewol::Widget* getSubWidget(void);
* @brief set the subWidget node widget. /**
* @param[in] _newWidget The widget to add. * @brief set the subWidget node widget.
*/ * @param[in] _newWidget The widget to add.
void setSubWidget(ewol::Widget* _newWidget); */
/** void setSubWidget(ewol::Widget* _newWidget);
* @brief remove the subWidget node. /**
*/ * @brief remove the subWidget node.
void subWidgetRemove(void); */
/** void subWidgetRemove(void);
* @brief remove the subWidget node (delayed to prevent remove in the callbback). /**
*/ * @brief remove the subWidget node (delayed to prevent remove in the callbback).
virtual void subWidgetRemoveDelayed(void); */
virtual void subWidgetRemoveDelayed(void);
public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onObjectRemove(ewol::EObject* _removeObject); virtual void onRegenerateDisplay(void);
virtual void calculateSize(const vec2& _availlable); virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateMinMaxSize(void); virtual void calculateSize(const vec2& _availlable);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos); virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName); virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual bool loadXML(exml::Element* _node); virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual void setOffset(const vec2& _newVal); virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};
}; };
}; };

View File

@ -15,19 +15,19 @@
#define __class__ "ContainerN" #define __class__ "ContainerN"
widget::ContainerN::ContainerN(void) : ewol::widget::ContainerN::ContainerN(void) :
m_lockExpand(false,false), m_lockExpand(false,false),
m_subExpend(false,false) { m_subExpend(false,false) {
addObjectType("widget::ContainerN"); addObjectType("ewol::widget::ContainerN");
// nothing to do ... // nothing to do ...
} }
widget::ContainerN::~ContainerN(void) { ewol::widget::ContainerN::~ContainerN(void) {
subWidgetRemoveAll(); subWidgetRemoveAll();
} }
bvec2 widget::ContainerN::canExpand(void) { bvec2 ewol::widget::ContainerN::canExpand(void) {
bvec2 res = m_userExpand; bvec2 res = m_userExpand;
if (false == m_lockExpand.x()) { if (false == m_lockExpand.x()) {
if (true == m_subExpend.x()) { if (true == m_subExpend.x()) {
@ -43,7 +43,7 @@ bvec2 widget::ContainerN::canExpand(void) {
return res; return res;
} }
void widget::ContainerN::lockExpand(const bvec2& _lockExpand) { void ewol::widget::ContainerN::lockExpand(const bvec2& _lockExpand) {
if (_lockExpand != m_lockExpand) { if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand; m_lockExpand = _lockExpand;
markToRedraw(); markToRedraw();
@ -52,7 +52,7 @@ void widget::ContainerN::lockExpand(const bvec2& _lockExpand) {
} }
int32_t widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) { int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... "); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... ");
return -1; return -1;
@ -67,7 +67,7 @@ int32_t widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) {
return _newWidget->getId(); return _newWidget->getId();
} }
int32_t widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) { int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... "); EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... ");
return -1; return -1;
@ -81,7 +81,7 @@ int32_t widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
return _newWidget->getId(); return _newWidget->getId();
} }
void widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) { void ewol::widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
} }
@ -103,7 +103,7 @@ void widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
} }
} }
void widget::ContainerN::subWidgetUnLink(ewol::Widget* _newWidget) { void ewol::widget::ContainerN::subWidgetUnLink(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
} }
@ -119,7 +119,7 @@ void widget::ContainerN::subWidgetUnLink(ewol::Widget* _newWidget) {
} }
} }
void widget::ContainerN::subWidgetRemoveAll(void) { void ewol::widget::ContainerN::subWidgetRemoveAll(void) {
size_t errorControl = m_subWidget.size(); size_t errorControl = m_subWidget.size();
// the size automaticly decrement with the auto call of the onObjectRemove function // the size automaticly decrement with the auto call of the onObjectRemove function
while (m_subWidget.size() > 0 ) { while (m_subWidget.size() > 0 ) {
@ -140,7 +140,7 @@ void widget::ContainerN::subWidgetRemoveAll(void) {
m_subWidget.clear(); m_subWidget.clear();
} }
void widget::ContainerN::subWidgetRemoveAllDelayed(void) { void ewol::widget::ContainerN::subWidgetRemoveAllDelayed(void) {
// the size automaticly decrement with the auto call of the onObjectRemove function // the size automaticly decrement with the auto call of the onObjectRemove function
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
@ -154,7 +154,7 @@ void widget::ContainerN::subWidgetRemoveAllDelayed(void) {
m_subWidget.clear(); m_subWidget.clear();
} }
ewol::Widget* widget::ContainerN::getWidgetNamed(const std::string& _widgetName) { ewol::Widget* ewol::widget::ContainerN::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName); ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) { if (NULL!=tmpUpperWidget) {
return tmpUpperWidget; return tmpUpperWidget;
@ -170,7 +170,7 @@ ewol::Widget* widget::ContainerN::getWidgetNamed(const std::string& _widgetName)
return NULL; return NULL;
} }
void widget::ContainerN::onObjectRemove(ewol::EObject* _removeObject) { void ewol::widget::ContainerN::onObjectRemove(ewol::EObject* _removeObject) {
// First step call parrent : // First step call parrent :
ewol::Widget::onObjectRemove(_removeObject); ewol::Widget::onObjectRemove(_removeObject);
// second step find if in all the elements ... // second step find if in all the elements ...
@ -183,7 +183,7 @@ void widget::ContainerN::onObjectRemove(ewol::EObject* _removeObject) {
} }
} }
void widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){ if (true == m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
@ -200,7 +200,7 @@ void widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
void widget::ContainerN::calculateSize(const vec2& _availlable) { void ewol::widget::ContainerN::calculateSize(const vec2& _availlable) {
m_size = _availlable; m_size = _availlable;
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
@ -211,7 +211,7 @@ void widget::ContainerN::calculateSize(const vec2& _availlable) {
markToRedraw(); markToRedraw();
} }
void widget::ContainerN::calculateMinMaxSize(void) { void ewol::widget::ContainerN::calculateMinMaxSize(void) {
m_subExpend.setValue(false, false); m_subExpend.setValue(false, false);
m_minSize.setValue(0,0); m_minSize.setValue(0,0);
m_maxSize.setValue(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE); m_maxSize.setValue(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE);
@ -234,7 +234,7 @@ void widget::ContainerN::calculateMinMaxSize(void) {
//EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); //EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize);
} }
void widget::ContainerN::onRegenerateDisplay(void) { void ewol::widget::ContainerN::onRegenerateDisplay(void) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->onRegenerateDisplay(); m_subWidget[iii]->onRegenerateDisplay();
@ -242,7 +242,7 @@ void widget::ContainerN::onRegenerateDisplay(void) {
} }
} }
ewol::Widget* widget::ContainerN::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) { if (true == isHide()) {
return NULL; return NULL;
} }
@ -267,7 +267,7 @@ ewol::Widget* widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
}; };
bool widget::ContainerN::loadXML(exml::Element* _node) { bool ewol::widget::ContainerN::loadXML(exml::Element* _node) {
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -318,7 +318,7 @@ bool widget::ContainerN::loadXML(exml::Element* _node) {
} }
void widget::ContainerN::setOffset(const vec2& _newVal) { void ewol::widget::ContainerN::setOffset(const vec2& _newVal) {
if (m_offset != _newVal) { if (m_offset != _newVal) {
ewol::Widget::setOffset(_newVal); ewol::Widget::setOffset(_newVal);
// recalculate the new sise and position of sub widget ... // recalculate the new sise and position of sub widget ...

View File

@ -13,84 +13,86 @@
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
* @brief the Cotainer widget is a widget that have an only one subWidget * @ingroup ewolWidgetGroup
*/ * @brief the Cotainer widget is a widget that have an only one subWidget
class ContainerN : public ewol::Widget { */
protected: class ContainerN : public ewol::Widget {
std::vector<ewol::Widget*> m_subWidget; protected:
public: std::vector<ewol::Widget*> m_subWidget;
/** public:
* @brief Constructor /**
*/ * @brief Constructor
ContainerN(void); */
/** ContainerN(void);
* @brief Destructor /**
*/ * @brief Destructor
~ContainerN(void); */
protected: ~ContainerN(void);
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected:
bvec2 m_subExpend; //!< reference of the sub element expention requested. bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
public: bvec2 m_subExpend; //!< reference of the sub element expention requested.
/** public:
* @brief Limit the expend properties to the current widget (no contamination) /**
* @param[in] _lockExpend Lock mode of the expend properties * @brief Limit the expend properties to the current widget (no contamination)
*/ * @param[in] _lockExpend Lock mode of the expend properties
void lockExpand(const bvec2& _lockExpand); */
// herited function void lockExpand(const bvec2& _lockExpand);
virtual bvec2 canExpand(void); // herited function
public: virtual bvec2 canExpand(void);
/** public:
* @brief remove all sub element from the widget. /**
*/ * @brief remove all sub element from the widget.
virtual void subWidgetRemoveAll(void); */
/** virtual void subWidgetRemoveAll(void);
* @brief remove all sub element from the widget (delayed to prevent remove in the callbback). /**
*/ * @brief remove all sub element from the widget (delayed to prevent remove in the callbback).
virtual void subWidgetRemoveAllDelayed(void); */
/** virtual void subWidgetRemoveAllDelayed(void);
* @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) /**
* @param[in] _newWidget the element pointer * @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @return the ID of the set element * @param[in] _newWidget the element pointer
*/ * @return the ID of the set element
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget); */
inline int32_t subWidgetAddBack(ewol::Widget* _newWidget) { virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
return subWidgetAdd(_newWidget); inline int32_t subWidgetAddBack(ewol::Widget* _newWidget) {
}; return subWidgetAdd(_newWidget);
inline int32_t subWidgetAddEnd(ewol::Widget* _newWidget) { };
return subWidgetAdd(_newWidget); inline int32_t subWidgetAddEnd(ewol::Widget* _newWidget) {
}; return subWidgetAdd(_newWidget);
/** };
* @brief add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) /**
* @param[in] _newWidget the element pointer * @brief add at start position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @return the ID of the set element * @param[in] _newWidget the element pointer
*/ * @return the ID of the set element
virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget); */
inline int32_t subWidgetAddFront(ewol::Widget* _newWidget) { virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget);
return subWidgetAddStart(_newWidget); inline int32_t subWidgetAddFront(ewol::Widget* _newWidget) {
}; return subWidgetAddStart(_newWidget);
/** };
* @brief remove definitly a widget from the system and this layer. /**
* @param[in] _newWidget the element pointer. * @brief remove definitly a widget from the system and this layer.
*/ * @param[in] _newWidget the element pointer.
virtual void subWidgetRemove(ewol::Widget* _newWidget); */
/** virtual void subWidgetRemove(ewol::Widget* _newWidget);
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...) /**
* @param[in] _newWidget the element pointer. * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...)
*/ * @param[in] _newWidget the element pointer.
virtual void subWidgetUnLink(ewol::Widget* _newWidget); */
public:// Derived function virtual void subWidgetUnLink(ewol::Widget* _newWidget);
virtual void systemDraw(const ewol::DrawProperty& _displayProp); public:// Derived function
virtual void onRegenerateDisplay(void); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onObjectRemove(ewol::EObject* _removeObject); virtual void onRegenerateDisplay(void);
virtual void calculateSize(const vec2& _availlable); virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateMinMaxSize(void); virtual void calculateSize(const vec2& _availlable);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos); virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName); virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual bool loadXML(exml::Element* _node); virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual void setOffset(const vec2& _newVal); virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};
}; };
}; };

View File

@ -16,23 +16,23 @@
#define __class__ "ContextMenu" #define __class__ "ContextMenu"
const char* const widget::ContextMenu::configArrowPosition = "arrow-position"; const char* const ewol::widget::ContextMenu::configArrowPosition = "arrow-position";
const char* const widget::ContextMenu::configArrowMode = "arrow-mode"; const char* const ewol::widget::ContextMenu::configArrowMode = "arrow-mode";
const char* const widget::ContextMenu::configShaper = "shaper"; const char* const ewol::widget::ContextMenu::configShaper = "shaper";
static ewol::Widget* Create(void) { static ewol::Widget* Create(void) {
return new widget::ContextMenu(); return new ewol::widget::ContextMenu();
} }
void widget::ContextMenu::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::ContextMenu::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create); _widgetManager.addWidgetCreator(__class__,&Create);
} }
widget::ContextMenu::ContextMenu(const std::string& _shaperName) : ewol::widget::ContextMenu::ContextMenu(const std::string& _shaperName) :
m_shaper(_shaperName) { m_shaper(_shaperName) {
addObjectType("widget::ContextMenu"); addObjectType("ewol::widget::ContextMenu");
// add basic configurations : // add basic configurations :
registerConfig(configArrowPosition, "vec2", NULL, "position of the arrow"); registerConfig(configArrowPosition, "vec2", NULL, "position of the arrow");
registerConfig(configArrowMode, "list", "none;left;buttom;right;top", "Position of the arrow in the pop-up"); registerConfig(configArrowMode, "list", "none;left;buttom;right;top", "Position of the arrow in the pop-up");
@ -52,17 +52,17 @@ widget::ContextMenu::ContextMenu(const std::string& _shaperName) :
setMouseLimit(1); setMouseLimit(1);
} }
widget::ContextMenu::~ContextMenu(void) { ewol::widget::ContextMenu::~ContextMenu(void) {
} }
void widget::ContextMenu::setShaperName(const std::string& _shaperName) { void ewol::widget::ContextMenu::setShaperName(const std::string& _shaperName) {
m_shaper.setSource(_shaperName); m_shaper.setSource(_shaperName);
markToRedraw(); markToRedraw();
} }
void widget::ContextMenu::calculateSize(const vec2& _availlable) { void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("CalculateSize=" << availlable); //EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display : // pop-up fill all the display :
m_size = _availlable; m_size = _availlable;
@ -130,7 +130,7 @@ void widget::ContextMenu::calculateSize(const vec2& _availlable) {
} }
void widget::ContextMenu::calculateMinMaxSize(void) { void ewol::widget::ContextMenu::calculateMinMaxSize(void) {
// call main class to calculate the min size... // call main class to calculate the min size...
widget::Container::calculateMinMaxSize(); widget::Container::calculateMinMaxSize();
// add padding of the display // add padding of the display
@ -140,13 +140,13 @@ void widget::ContextMenu::calculateMinMaxSize(void) {
} }
void widget::ContextMenu::onDraw(void) { void ewol::widget::ContextMenu::onDraw(void) {
m_compositing.draw(); m_compositing.draw();
m_shaper.draw(); m_shaper.draw();
} }
void widget::ContextMenu::onRegenerateDisplay(void) { void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
// call upper class : // call upper class :
widget::Container::onRegenerateDisplay(); widget::Container::onRegenerateDisplay();
if (needRedraw() == false) { if (needRedraw() == false) {
@ -214,7 +214,7 @@ void widget::ContextMenu::onRegenerateDisplay(void) {
m_shaper.setInsideSize(vec2ClipInt32(shaperSize-padding*2.0f)); m_shaper.setInsideSize(vec2ClipInt32(shaperSize-padding*2.0f));
} }
bool widget::ContextMenu::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::ContextMenu::onEventInput(const ewol::EventInput& _event) {
if (_event.getId() > 0) { if (_event.getId() > 0) {
if (NULL != widget::Container::getWidgetAtPos(_event.getPos())) { if (NULL != widget::Container::getWidgetAtPos(_event.getPos())) {
return false; return false;
@ -234,14 +234,14 @@ bool widget::ContextMenu::onEventInput(const ewol::EventInput& _event) {
} }
void widget::ContextMenu::setPositionMark(enum markPosition _position, vec2 _arrowPos) { void ewol::widget::ContextMenu::setPositionMark(enum markPosition _position, vec2 _arrowPos) {
EWOL_DEBUG("set context menu at the position : " << _arrowPos); EWOL_DEBUG("set context menu at the position : " << _arrowPos);
m_arrawBorder = _position; m_arrawBorder = _position;
m_arrowPos = _arrowPos; m_arrowPos = _arrowPos;
markToRedraw(); markToRedraw();
} }
ewol::Widget* widget::ContextMenu::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) {
ewol::Widget* val = widget::Container::getWidgetAtPos(_pos); ewol::Widget* val = widget::Container::getWidgetAtPos(_pos);
if (NULL != val) { if (NULL != val) {
return val; return val;
@ -250,7 +250,7 @@ ewol::Widget* widget::ContextMenu::getWidgetAtPos(const vec2& _pos) {
} }
bool widget::ContextMenu::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::ContextMenu::onSetConfig(const ewol::EConfig& _conf) {
if (true == widget::Container::onSetConfig(_conf)) { if (true == widget::Container::onSetConfig(_conf)) {
return true; return true;
} }
@ -279,7 +279,7 @@ bool widget::ContextMenu::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::ContextMenu::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::ContextMenu::onGetConfig(const char* _config, std::string& _result) const {
if (true == widget::Container::onGetConfig(_config, _result)) { if (true == widget::Container::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -17,58 +17,60 @@
#include <ewol/compositing/Shaper.h> #include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class ContextMenu : public widget::Container { */
public: class ContextMenu : public ewol::widget::Container {
enum markPosition { public:
markTop, enum markPosition {
markRight, markTop,
markButtom, markRight,
markLeft, markButtom,
markNone markLeft,
}; markNone
public: };
static void init(ewol::WidgetManager& _widgetManager); public:
// Config list of properties static void init(ewol::WidgetManager& _widgetManager);
static const char* const configArrowPosition; // Config list of properties
static const char* const configArrowMode; static const char* const configArrowPosition;
static const char* const configShaper; static const char* const configArrowMode;
public: static const char* const configShaper;
ContextMenu(const std::string& _shaperName="THEME:GUI:widgetContextMenu.conf"); public:
virtual ~ContextMenu(void); ContextMenu(const std::string& _shaperName="THEME:GUI:widgetContextMenu.conf");
private: virtual ~ContextMenu(void);
ewol::Shaper m_shaper; //!< Compositing theme. private:
public: ewol::Shaper m_shaper; //!< Compositing theme.
/** public:
* @brief set the shaper name (use the contructer one this permit to not noad unused shaper) /**
* @param[in] _shaperName The new shaper filename * @brief set the shaper name (use the contructer one this permit to not noad unused shaper)
*/ * @param[in] _shaperName The new shaper filename
void setShaperName(const std::string& _shaperName); */
private: void setShaperName(const std::string& _shaperName);
// TODO : Rework the displayer .... private:
ewol::Drawing m_compositing; // TODO : Rework the displayer ....
etk::Color<> m_colorBackGroung; ewol::Drawing m_compositing;
etk::Color<> m_colorBorder; etk::Color<> m_colorBackGroung;
etk::Color<> m_colorBorder;
float m_offset;
private: float m_offset;
vec2 m_arrowPos; private:
enum markPosition m_arrawBorder; vec2 m_arrowPos;
public: enum markPosition m_arrawBorder;
void setPositionMark(enum markPosition position, vec2 arrowPos); public:
protected: // Derived function void setPositionMark(enum markPosition position, vec2 arrowPos);
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
public: // Derived function virtual bool onGetConfig(const char* _config, std::string& _result) const;
virtual void onRegenerateDisplay(void); public: // Derived function
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual void calculateSize(const vec2& availlable); virtual bool onEventInput(const ewol::EventInput& _event);
virtual void calculateMinMaxSize(void); virtual void calculateSize(const vec2& availlable);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos); virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
};
}; };
}; };

View File

@ -29,24 +29,24 @@ const char * const ewolEventEntrySelect = "ewol-widget-entry-event-internal-sele
#define STATUS_SELECTED (2) #define STATUS_SELECTED (2)
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Entry(); return new ewol::widget::Entry();
} }
void widget::Entry::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Entry::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
const char * const widget::Entry::eventClick = "click"; const char * const ewol::widget::Entry::eventClick = "click";
const char * const widget::Entry::eventEnter = "enter"; const char * const ewol::widget::Entry::eventEnter = "enter";
const char * const widget::Entry::eventModify = "modify"; const char * const ewol::widget::Entry::eventModify = "modify";
const char* const widget::Entry::configMaxChar = "max"; const char* const ewol::widget::Entry::configMaxChar = "max";
const char* const widget::Entry::configRegExp = "regExp"; const char* const ewol::widget::Entry::configRegExp = "regExp";
const char* const widget::Entry::configColorFg = "color"; const char* const ewol::widget::Entry::configColorFg = "color";
const char* const widget::Entry::configColorBg = "background"; const char* const ewol::widget::Entry::configColorBg = "background";
const char* const widget::Entry::configEmptyMessage = "emptytext"; const char* const ewol::widget::Entry::configEmptyMessage = "emptytext";
widget::Entry::Entry(std::string _newData) : ewol::widget::Entry::Entry(std::string _newData) :
m_shaper("THEME:GUI:widgetEntry.conf"), m_shaper("THEME:GUI:widgetEntry.conf"),
m_data(""), m_data(""),
m_maxCharacter(0x7FFFFFFF), m_maxCharacter(0x7FFFFFFF),
@ -59,7 +59,7 @@ widget::Entry::Entry(std::string _newData) :
m_textColorFg(etk::color::black), m_textColorFg(etk::color::black),
m_textColorBg(etk::color::white), m_textColorBg(etk::color::white),
m_textWhenNothing("") { m_textWhenNothing("") {
addObjectType("widget::Entry"); addObjectType("ewol::widget::Entry");
m_textColorBg.setA(0xAF); m_textColorBg.setA(0xAF);
setCanHaveFocus(true); setCanHaveFocus(true);
addEventId(eventClick); addEventId(eventClick);
@ -83,12 +83,12 @@ widget::Entry::Entry(std::string _newData) :
} }
widget::Entry::~Entry(void) { ewol::widget::Entry::~Entry(void) {
} }
void widget::Entry::setMaxChar(int32_t _nbMax) { void ewol::widget::Entry::setMaxChar(int32_t _nbMax) {
if (_nbMax <= 0) { if (_nbMax <= 0) {
m_maxCharacter = 0x7FFFFFFF; m_maxCharacter = 0x7FFFFFFF;
} else { } else {
@ -97,7 +97,7 @@ void widget::Entry::setMaxChar(int32_t _nbMax) {
} }
void widget::Entry::calculateMinMaxSize(void) { void ewol::widget::Entry::calculateMinMaxSize(void) {
// call main class // call main class
ewol::Widget::calculateMinMaxSize(); ewol::Widget::calculateMinMaxSize();
// get generic padding // get generic padding
@ -112,7 +112,7 @@ void widget::Entry::calculateMinMaxSize(void) {
} }
void widget::Entry::setValue(const std::string& _newData) { void ewol::widget::Entry::setValue(const std::string& _newData) {
std::string newData = _newData; std::string newData = _newData;
if ((int64_t)newData.size() > m_maxCharacter) { if ((int64_t)newData.size() > m_maxCharacter) {
newData = std::string(_newData, 0, m_maxCharacter); newData = std::string(_newData, 0, m_maxCharacter);
@ -129,13 +129,13 @@ void widget::Entry::setValue(const std::string& _newData) {
} }
void widget::Entry::onDraw(void) { void ewol::widget::Entry::onDraw(void) {
m_shaper.draw(); m_shaper.draw();
m_oObjectText.draw(); m_oObjectText.draw();
} }
void widget::Entry::onRegenerateDisplay(void) { void ewol::widget::Entry::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
m_shaper.clear(); m_shaper.clear();
m_oObjectText.clear(); m_oObjectText.clear();
@ -186,7 +186,7 @@ void widget::Entry::onRegenerateDisplay(void) {
} }
void widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection) { void ewol::widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
vec2 relPos = relativePosition(_pos); vec2 relPos = relativePosition(_pos);
@ -223,7 +223,7 @@ void widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection) {
} }
void widget::Entry::removeSelected(void) { void ewol::widget::Entry::removeSelected(void) {
if (m_displayCursorPosSelection == m_displayCursorPos) { if (m_displayCursorPosSelection == m_displayCursorPos) {
// nothing to cut ... // nothing to cut ...
return; return;
@ -242,7 +242,7 @@ void widget::Entry::removeSelected(void) {
} }
void widget::Entry::copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID) { void ewol::widget::Entry::copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID) {
if (m_displayCursorPosSelection == m_displayCursorPos) { if (m_displayCursorPosSelection == m_displayCursorPos) {
// nothing to cut ... // nothing to cut ...
return; return;
@ -259,7 +259,7 @@ void widget::Entry::copySelectionToClipBoard(enum ewol::clipBoard::clipboardList
} }
bool widget::Entry::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Entry::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput); //EWOL_DEBUG("Event on Entry ... type=" << (int32_t)type << " id=" << IdInput);
if (1 == _event.getId()) { if (1 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) { if (ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -352,7 +352,7 @@ bool widget::Entry::onEventInput(const ewol::EventInput& _event) {
} }
bool widget::Entry::onEventEntry(const ewol::EventEntry& _event) { bool ewol::widget::Entry::onEventEntry(const ewol::EventEntry& _event) {
if (_event.getType() == ewol::keyEvent::keyboardChar) { if (_event.getType() == ewol::keyEvent::keyboardChar) {
if(_event.getStatus() == ewol::keyEvent::statusDown) { if(_event.getStatus() == ewol::keyEvent::statusDown) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " ); //EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
@ -424,7 +424,7 @@ bool widget::Entry::onEventEntry(const ewol::EventEntry& _event) {
return false; return false;
} }
void widget::Entry::setInternalValue(const std::string& _newData) { void ewol::widget::Entry::setInternalValue(const std::string& _newData) {
std::string previous = m_data; std::string previous = m_data;
// check the RegExp : // check the RegExp :
if (_newData.size()>0) { if (_newData.size()>0) {
@ -442,7 +442,7 @@ void widget::Entry::setInternalValue(const std::string& _newData) {
m_data = _newData; m_data = _newData;
} }
void widget::Entry::onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID) { void ewol::widget::Entry::onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID) {
// remove curent selected data ... // remove curent selected data ...
removeSelected(); removeSelected();
// get current selection / Copy : // get current selection / Copy :
@ -466,7 +466,7 @@ void widget::Entry::onEventClipboard(enum ewol::clipBoard::clipboardListe _clipb
} }
void widget::Entry::onReceiveMessage(const ewol::EMessage& _msg) { void ewol::widget::Entry::onReceiveMessage(const ewol::EMessage& _msg) {
ewol::Widget::onReceiveMessage(_msg); ewol::Widget::onReceiveMessage(_msg);
if(_msg.getMessage() == ewolEventEntryClean) { if(_msg.getMessage() == ewolEventEntryClean) {
m_data = ""; m_data = "";
@ -493,11 +493,11 @@ void widget::Entry::onReceiveMessage(const ewol::EMessage& _msg) {
} }
} }
void widget::Entry::markToUpdateTextPosition(void) { void ewol::widget::Entry::markToUpdateTextPosition(void) {
m_needUpdateTextPos=true; m_needUpdateTextPos=true;
} }
void widget::Entry::updateTextPosition(void) { void ewol::widget::Entry::updateTextPosition(void) {
if (false == m_needUpdateTextPos) { if (false == m_needUpdateTextPos) {
return; return;
} }
@ -532,35 +532,35 @@ void widget::Entry::updateTextPosition(void) {
} }
} }
void widget::Entry::onGetFocus(void) { void ewol::widget::Entry::onGetFocus(void) {
m_displayCursor = true; m_displayCursor = true;
changeStatusIn(STATUS_SELECTED); changeStatusIn(STATUS_SELECTED);
showKeyboard(); showKeyboard();
markToRedraw(); markToRedraw();
} }
void widget::Entry::onLostFocus(void) { void ewol::widget::Entry::onLostFocus(void) {
m_displayCursor = false; m_displayCursor = false;
changeStatusIn(STATUS_NORMAL); changeStatusIn(STATUS_NORMAL);
hideKeyboard(); hideKeyboard();
markToRedraw(); markToRedraw();
} }
void widget::Entry::changeStatusIn(int32_t _newStatusId) { void ewol::widget::Entry::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) { if (true == m_shaper.changeStatusIn(_newStatusId) ) {
periodicCallEnable(); periodicCallEnable();
markToRedraw(); markToRedraw();
} }
} }
void widget::Entry::periodicCall(const ewol::EventTime& _event) { void ewol::widget::Entry::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) { if (false == m_shaper.periodicCall(_event) ) {
periodicCallDisable(); periodicCallDisable();
} }
markToRedraw(); markToRedraw();
} }
void widget::Entry::setRegExp(const std::string& _expression) { void ewol::widget::Entry::setRegExp(const std::string& _expression) {
std::string previousRegExp = m_regExp.getRegExp(); std::string previousRegExp = m_regExp.getRegExp();
EWOL_DEBUG("change input regExp \"" << previousRegExp << "\" == > \"" << _expression << "\""); EWOL_DEBUG("change input regExp \"" << previousRegExp << "\" == > \"" << _expression << "\"");
m_regExp.setRegExp(_expression); m_regExp.setRegExp(_expression);
@ -570,22 +570,22 @@ void widget::Entry::setRegExp(const std::string& _expression) {
} }
} }
void widget::Entry::setColorText(const etk::Color<>& _color) { void ewol::widget::Entry::setColorText(const etk::Color<>& _color) {
m_textColorFg = _color; m_textColorFg = _color;
markToRedraw(); markToRedraw();
} }
void widget::Entry::setColorTextSelected(const etk::Color<>& _color) { void ewol::widget::Entry::setColorTextSelected(const etk::Color<>& _color) {
m_textColorBg = _color; m_textColorBg = _color;
markToRedraw(); markToRedraw();
} }
void widget::Entry::setEmptyText(const std::string& _text) { void ewol::widget::Entry::setEmptyText(const std::string& _text) {
m_textWhenNothing = _text; m_textWhenNothing = _text;
markToRedraw(); markToRedraw();
} }
bool widget::Entry::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::Entry::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) { if (true == ewol::Widget::onSetConfig(_conf)) {
return true; return true;
} }
@ -612,7 +612,7 @@ bool widget::Entry::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::Entry::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::Entry::onGetConfig(const char* _config, std::string& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) { if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -19,196 +19,197 @@
#include <etk/Color.h> #include <etk/Color.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
* @brief Entry box display : * @ingroup ewolWidgetGroup
* * @brief Entry box display :
* ~~~~~~~~~~~~~~~~~~~~~~ *
* ---------------------------------------------- * ~~~~~~~~~~~~~~~~~~~~~~
* | Editable Text | * ----------------------------------------------
* ---------------------------------------------- * | Editable Text |
* ~~~~~~~~~~~~~~~~~~~~~~ * ----------------------------------------------
*/ * ~~~~~~~~~~~~~~~~~~~~~~
class Entry : public ewol::Widget { */
public: class Entry : public ewol::Widget {
// Event list of properties public:
static const char * const eventClick; // Event list of properties
static const char * const eventEnter; static const char * const eventClick;
static const char * const eventModify; // return in the data the new string inside it ... static const char * const eventEnter;
// Config list of properties static const char * const eventModify; // return in the data the new string inside it ...
static const char* const configMaxChar; // Config list of properties
static const char* const configRegExp; static const char* const configMaxChar;
static const char* const configColorFg; static const char* const configRegExp;
static const char* const configColorBg; static const char* const configColorFg;
static const char* const configEmptyMessage; static const char* const configColorBg;
public: static const char* const configEmptyMessage;
static void init(ewol::WidgetManager& _widgetManager); public:
private: static void init(ewol::WidgetManager& _widgetManager);
ewol::Shaper m_shaper; private:
ewol::Text m_oObjectText; //!< text display m_text ewol::Shaper m_shaper;
public: ewol::Text m_oObjectText; //!< text display m_text
/** public:
* @brief Contuctor /**
* @param[in] _newData The USting that might be set in the Entry box (no event generation!!) * @brief Contuctor
*/ * @param[in] _newData The USting that might be set in the Entry box (no event generation!!)
Entry(std::string _newData = ""); */
/** Entry(std::string _newData = "");
* @brief Destuctor /**
*/ * @brief Destuctor
virtual ~Entry(void); */
virtual ~Entry(void);
private:
std::string m_data; //!< sting that must be displayed private:
protected: std::string m_data; //!< sting that must be displayed
/** protected:
* @brief internal check the value with RegExp checking /**
* @param[in] _newData The new string to display * @brief internal check the value with RegExp checking
*/ * @param[in] _newData The new string to display
void setInternalValue(const std::string& _newData); */
public: void setInternalValue(const std::string& _newData);
/** public:
* @brief set a new value on the entry. /**
* @param[in] _newData the new string to display. * @brief set a new value on the entry.
*/ * @param[in] _newData the new string to display.
void setValue(const std::string& _newData); */
/** void setValue(const std::string& _newData);
* @brief get the current value in the entry /**
* @return The current display value * @brief get the current value in the entry
*/ * @return The current display value
std::string getValue(void) const { */
return m_data; std::string getValue(void) const {
}; return m_data;
};
private:
int32_t m_maxCharacter; //!< number max of xharacter in the list private:
public: int32_t m_maxCharacter; //!< number max of xharacter in the list
/** public:
* @brief Limit the number of Unicode character in the entry /**
* @param[in] _nbMax Number of max character set in the List (0x7FFFFFFF for no limit) * @brief Limit the number of Unicode character in the entry
*/ * @param[in] _nbMax Number of max character set in the List (0x7FFFFFFF for no limit)
void setMaxChar(int32_t _nbMax); */
/** void setMaxChar(int32_t _nbMax);
* @brief Limit the number of Unicode character in the entry /**
* @return Number of max character set in the List. * @brief Limit the number of Unicode character in the entry
*/ * @return Number of max character set in the List.
int32_t getMaxChar(void) const { */
return m_maxCharacter; int32_t getMaxChar(void) const {
}; return m_maxCharacter;
private: };
etk::RegExp<std::string> m_regExp; //!< regular expression to limit the input of an entry private:
public: etk::RegExp<std::string> m_regExp; //!< regular expression to limit the input of an entry
/** public:
* @brief Limit the input entry at a regular expression... (by default it is "*") /**
* @param _expression New regular expression * @brief Limit the input entry at a regular expression... (by default it is "*")
*/ * @param _expression New regular expression
void setRegExp(const std::string& _expression); */
/** void setRegExp(const std::string& _expression);
* @brief get the regualar expression limitation /**
* @param The regExp string * @brief get the regualar expression limitation
*/ * @param The regExp string
std::string getRegExp(void) const { */
return m_regExp.getRegExp(); std::string getRegExp(void) const {
}; return m_regExp.getRegExp();
private: };
bool m_needUpdateTextPos; //!< text position can have change private:
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString bool m_needUpdateTextPos; //!< text position can have change
bool m_displayCursor; //!< Cursor must be display only when the widget has the focus int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
int32_t m_displayCursorPos; //!< Cursor position in number of Char bool m_displayCursor; //!< Cursor must be display only when the widget has the focus
int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable int32_t m_displayCursorPos; //!< Cursor position in number of Char
protected: int32_t m_displayCursorPosSelection; //!< Selection position end (can be befor or after cursor and == m_displayCursorPos chan no selection availlable
/** protected:
* @brief informe the system thet the text change and the start position change /**
*/ * @brief informe the system thet the text change and the start position change
virtual void markToUpdateTextPosition(void); */
/** virtual void markToUpdateTextPosition(void);
* @brief update the display position start == > depending of the position of the Cursor and the size of the Data inside /**
* @change m_displayStartPosition < == updated * @brief update the display position start == > depending of the position of the Cursor and the size of the Data inside
*/ * @change m_displayStartPosition < == updated
virtual void updateTextPosition(void); */
/** virtual void updateTextPosition(void);
* @brief change the cursor position with the curent position requested on the display /**
* @param[in] _pos Absolute position of the event * @brief change the cursor position with the curent position requested on the display
* @note The display is automaticly requested when change apear. * @param[in] _pos Absolute position of the event
*/ * @note The display is automaticly requested when change apear.
virtual void updateCursorPosition(const vec2& _pos, bool _Selection=false); */
virtual void updateCursorPosition(const vec2& _pos, bool _Selection=false);
public:
/** public:
* @brief Copy the selected data on the specify clipboard /**
* @param[in] _clipboardID Selected clipboard * @brief Copy the selected data on the specify clipboard
*/ * @param[in] _clipboardID Selected clipboard
virtual void copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID); */
/** virtual void copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID);
* @brief remove the selected area /**
* @note This request a regeneration of the display * @brief remove the selected area
*/ * @note This request a regeneration of the display
virtual void removeSelected(void); */
virtual void removeSelected(void);
private:
etk::Color<> m_textColorFg; //!< Text color. private:
public: etk::Color<> m_textColorFg; //!< Text color.
/** public:
* @brief set text color. /**
* @param _color Color that is selected. * @brief set text color.
*/ * @param _color Color that is selected.
void setColorText(const etk::Color<>& _color); */
/** void setColorText(const etk::Color<>& _color);
* @brief get the color for the text. /**
* @return The color requested. * @brief get the color for the text.
*/ * @return The color requested.
const etk::Color<>& getColorText(void) const { */
return m_textColorFg; const etk::Color<>& getColorText(void) const {
}; return m_textColorFg;
};
private:
etk::Color<> m_textColorBg; //!< Background color. private:
public: etk::Color<> m_textColorBg; //!< Background color.
/** public:
* @brief set text backgroung color when selected. /**
* @param _color Color that is selected. * @brief set text backgroung color when selected.
*/ * @param _color Color that is selected.
void setColorTextSelected(const etk::Color<>& _color); */
/** void setColorTextSelected(const etk::Color<>& _color);
* @brief get the selected color for the text in selection mode. /**
* @return The color requested. * @brief get the selected color for the text in selection mode.
*/ * @return The color requested.
const etk::Color<>& getColorTextSelected(void) const { */
return m_textColorBg; const etk::Color<>& getColorTextSelected(void) const {
}; return m_textColorBg;
};
private:
std::string m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...) private:
public: std::string m_textWhenNothing; //!< Text to display when nothing in in the entry (decorated text...)
/** public:
* @brief set The text displayed when nothing is in the entry. /**
* @param _text Text to display when the entry box is empty (this text can be decorated). * @brief set The text displayed when nothing is in the entry.
*/ * @param _text Text to display when the entry box is empty (this text can be decorated).
void setEmptyText(const std::string& _text); */
/** void setEmptyText(const std::string& _text);
* @brief get The text displayed when nothing is in the entry. /**
* @return Text display when nothing * @brief get The text displayed when nothing is in the entry.
*/ * @return Text display when nothing
const std::string& getEmptyText(void) const { */
return m_textWhenNothing; const std::string& getEmptyText(void) const {
}; return m_textWhenNothing;
public: // Derived function };
virtual void onRegenerateDisplay(void); public: // Derived function
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool onEventEntry(const ewol::EventEntry& _event); virtual bool onEventInput(const ewol::EventInput& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg); virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID); virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void calculateMinMaxSize(void); virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID);
protected: // Derived function virtual void calculateMinMaxSize(void);
virtual void onDraw(void); protected: // Derived function
virtual void onGetFocus(void); virtual void onDraw(void);
virtual void onLostFocus(void); virtual void onGetFocus(void);
virtual void changeStatusIn(int32_t _newStatusId); virtual void onLostFocus(void);
virtual void periodicCall(const ewol::EventTime& _event); virtual void changeStatusIn(int32_t _newStatusId);
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void periodicCall(const ewol::EventTime& _event);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
}; };
}; };
#endif #endif

View File

@ -16,30 +16,30 @@
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Gird(); return new ewol::widget::Gird();
} }
void widget::Gird::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Gird::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::Gird::Gird(int32_t _colNumber) : ewol::widget::Gird::Gird(int32_t _colNumber) :
m_sizeRow(0), m_sizeRow(0),
m_tmpWidget(NULL), m_tmpWidget(NULL),
m_gavityButtom(true), m_gavityButtom(true),
m_borderSize(0,0) { m_borderSize(0,0) {
addObjectType("widget::Gird"); addObjectType("ewol::widget::Gird");
setColNumber(_colNumber); setColNumber(_colNumber);
requestUpdateSize(); requestUpdateSize();
} }
widget::Gird::~Gird(void) { ewol::widget::Gird::~Gird(void) {
EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} Gird : destroy"); EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} Gird : destroy");
subWidgetRemoveAll(); subWidgetRemoveAll();
} }
void widget::Gird::setBorderSize(const ivec2& _newBorderSize) { void ewol::widget::Gird::setBorderSize(const ivec2& _newBorderSize) {
m_borderSize = _newBorderSize; m_borderSize = _newBorderSize;
if (m_borderSize.x() < 0) { if (m_borderSize.x() < 0) {
EWOL_ERROR("Try to set a border size <0 on x : " << m_borderSize.x() << " == > restore to 0"); EWOL_ERROR("Try to set a border size <0 on x : " << m_borderSize.x() << " == > restore to 0");
@ -53,7 +53,7 @@ void widget::Gird::setBorderSize(const ivec2& _newBorderSize) {
requestUpdateSize(); requestUpdateSize();
} }
void widget::Gird::calculateSize(const vec2& _availlable) { void ewol::widget::Gird::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("Update size"); //EWOL_DEBUG("Update size");
m_size = _availlable; m_size = _availlable;
m_size -= m_borderSize*2; m_size -= m_borderSize*2;
@ -91,7 +91,7 @@ void widget::Gird::calculateSize(const vec2& _availlable) {
markToRedraw(); markToRedraw();
} }
void widget::Gird::calculateMinMaxSize(void) { void ewol::widget::Gird::calculateMinMaxSize(void) {
for (size_t iii=0; iii<m_sizeCol.size(); iii++ ){ for (size_t iii=0; iii<m_sizeCol.size(); iii++ ){
if (m_sizeCol[iii] <= 0) { if (m_sizeCol[iii] <= 0) {
m_sizeCol[iii] = 0; m_sizeCol[iii] = 0;
@ -137,7 +137,7 @@ void widget::Gird::calculateMinMaxSize(void) {
//EWOL_DEBUG("Vert Result : expand="<< m_userExpand << " minSize="<< m_minSize); //EWOL_DEBUG("Vert Result : expand="<< m_userExpand << " minSize="<< m_minSize);
} }
void widget::Gird::setColNumber(int32_t _colNumber) { void ewol::widget::Gird::setColNumber(int32_t _colNumber) {
if ((int64_t)m_sizeCol.size() > _colNumber) { if ((int64_t)m_sizeCol.size() > _colNumber) {
size_t errorControl = m_subWidget.size(); size_t errorControl = m_subWidget.size();
// remove subWidget : // remove subWidget :
@ -168,7 +168,7 @@ void widget::Gird::setColNumber(int32_t _colNumber) {
} }
} }
void widget::Gird::setColSize(int32_t _colId, int32_t _size) { void ewol::widget::Gird::setColSize(int32_t _colId, int32_t _size) {
if ((int64_t)m_sizeCol.size() > _colId) { if ((int64_t)m_sizeCol.size() > _colId) {
m_sizeCol[_colId] = _size; m_sizeCol[_colId] = _size;
} else { } else {
@ -178,11 +178,11 @@ void widget::Gird::setColSize(int32_t _colId, int32_t _size) {
} }
} }
void widget::Gird::setRowSize(int32_t _size) { void ewol::widget::Gird::setRowSize(int32_t _size) {
m_sizeRow = _size; m_sizeRow = _size;
} }
int32_t widget::Gird::getColSize(int32_t _colId) { int32_t ewol::widget::Gird::getColSize(int32_t _colId) {
if ((int64_t)m_sizeCol.size() > _colId) { if ((int64_t)m_sizeCol.size() > _colId) {
if (m_sizeCol[_colId] <= 0) { if (m_sizeCol[_colId] <= 0) {
return 0; return 0;
@ -193,11 +193,11 @@ int32_t widget::Gird::getColSize(int32_t _colId) {
return 0; return 0;
} }
int32_t widget::Gird::getRowSize(void) { int32_t ewol::widget::Gird::getRowSize(void) {
return m_sizeRow; return m_sizeRow;
} }
void widget::Gird::subWidgetRemoveAll(void) { void ewol::widget::Gird::subWidgetRemoveAll(void) {
size_t errorControl = m_subWidget.size(); size_t errorControl = m_subWidget.size();
// the size automaticly decrement with the auto call of the onObjectRemove function // the size automaticly decrement with the auto call of the onObjectRemove function
while (m_subWidget.size() > 0 ) { while (m_subWidget.size() > 0 ) {
@ -218,7 +218,7 @@ void widget::Gird::subWidgetRemoveAll(void) {
} }
void widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget) { void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
} }
@ -260,7 +260,7 @@ void widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _n
m_subWidget.push_back(prop); m_subWidget.push_back(prop);
} }
void widget::Gird::subWidgetRemove(ewol::Widget* _newWidget) void ewol::widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
{ {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
@ -281,7 +281,7 @@ void widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
EWOL_WARNING("[" << getId() << "] Can not remove unExistant widget"); EWOL_WARNING("[" << getId() << "] Can not remove unExistant widget");
} }
void widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) { void ewol::widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) {
if (_colId<0 || _rowId<0) { if (_colId<0 || _rowId<0) {
EWOL_WARNING("[" << getId() << "] try to remove widget with id < 0 col=" << _colId << " row=" << _rowId); EWOL_WARNING("[" << getId() << "] try to remove widget with id < 0 col=" << _colId << " row=" << _rowId);
return; return;
@ -311,7 +311,7 @@ void widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) {
EWOL_WARNING("[" << getId() << "] Can not remove unExistant widget"); EWOL_WARNING("[" << getId() << "] Can not remove unExistant widget");
} }
void widget::Gird::subWidgetUnLink(ewol::Widget* _newWidget) { void ewol::widget::Gird::subWidgetUnLink(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
return; return;
} }
@ -324,7 +324,7 @@ void widget::Gird::subWidgetUnLink(ewol::Widget* _newWidget) {
} }
} }
void widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) { void ewol::widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) {
if (_colId<0 || _rowId<0) { if (_colId<0 || _rowId<0) {
EWOL_WARNING("[" << getId() << "] try to Unlink widget with id < 0 col=" << _colId << " row=" << _rowId); EWOL_WARNING("[" << getId() << "] try to Unlink widget with id < 0 col=" << _colId << " row=" << _rowId);
return; return;
@ -341,7 +341,7 @@ void widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) {
EWOL_WARNING("[" << getId() << "] Can not unLink unExistant widget"); EWOL_WARNING("[" << getId() << "] Can not unLink unExistant widget");
} }
void widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::Widget::systemDraw(_displayProp); ewol::Widget::systemDraw(_displayProp);
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) { if (NULL != m_subWidget[iii].widget) {
@ -350,7 +350,7 @@ void widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
void widget::Gird::onRegenerateDisplay(void) { void ewol::widget::Gird::onRegenerateDisplay(void) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) { if (NULL != m_subWidget[iii].widget) {
m_subWidget[iii].widget->onRegenerateDisplay(); m_subWidget[iii].widget->onRegenerateDisplay();
@ -358,7 +358,7 @@ void widget::Gird::onRegenerateDisplay(void) {
} }
} }
ewol::Widget * widget::Gird::getWidgetAtPos(const vec2& _pos) { ewol::Widget * ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) { if (true == isHide()) {
return NULL; return NULL;
} }
@ -382,7 +382,7 @@ ewol::Widget * widget::Gird::getWidgetAtPos(const vec2& _pos) {
return NULL; return NULL;
} }
void widget::Gird::onObjectRemove(ewol::EObject * _removeObject) { void ewol::widget::Gird::onObjectRemove(ewol::EObject * _removeObject) {
// First step call parrent : // First step call parrent :
ewol::Widget::onObjectRemove(_removeObject); ewol::Widget::onObjectRemove(_removeObject);
// second step find if in all the elements ... // second step find if in all the elements ...

View File

@ -15,132 +15,133 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Gird :public ewol::Widget { */
public: class Gird :public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
private: static void init(ewol::WidgetManager& _widgetManager);
class GirdProperties { private:
public: class GirdProperties {
ewol::Widget* widget; public:
int32_t row; ewol::Widget* widget;
int32_t col; int32_t row;
}; int32_t col;
int32_t m_sizeRow; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ... };
int32_t m_uniformSizeRow; int32_t m_sizeRow; //!< size of all lines (row) (if set (otherwise 0)) == > we have a only one size ==> multiple size will have no use ...
std::vector<int32_t> m_sizeCol; //!< size of all colomn (if set (otherwise 0)) int32_t m_uniformSizeRow;
std::vector<GirdProperties> m_subWidget; //!< all sub widget are contained in this element std::vector<int32_t> m_sizeCol; //!< size of all colomn (if set (otherwise 0))
ewol::Widget* m_tmpWidget; //!< use when replace a widget ... std::vector<GirdProperties> m_subWidget; //!< all sub widget are contained in this element
bool m_gavityButtom; ewol::Widget* m_tmpWidget; //!< use when replace a widget ...
public: bool m_gavityButtom;
/** public:
* @brief Constructor /**
*/ * @brief Constructor
Gird(int32_t _colNumber=1); */
/** Gird(int32_t _colNumber=1);
* @brief Desstructor /**
*/ * @brief Desstructor
virtual ~Gird(void); */
/** virtual ~Gird(void);
* @brief set the number of colomn /**
* @param[in] colNumber Nuber of colomn * @brief set the number of colomn
*/ * @param[in] colNumber Nuber of colomn
void setColNumber(int32_t _colNumber); */
/** void setColNumber(int32_t _colNumber);
* @brief change a size view of a colomn. /**
* @param[in] colId Id of the colomn [0..x]. * @brief change a size view of a colomn.
* @param[in] size size of the colomn. * @param[in] colId Id of the colomn [0..x].
*/ * @param[in] size size of the colomn.
void setColSize(int32_t _colId, int32_t _size); */
/** void setColSize(int32_t _colId, int32_t _size);
* @brief change a size view of a line. /**
* @param[in] size size of the line. * @brief change a size view of a line.
*/ * @param[in] size size of the line.
void setRowSize(int32_t _size); */
/** void setRowSize(int32_t _size);
* @brief get the size view of a colomn. /**
* @param[in] colId Id of the colomn [0..x]. * @brief get the size view of a colomn.
* @return The size of the colomn. * @param[in] colId Id of the colomn [0..x].
*/ * @return The size of the colomn.
int32_t getColSize(int32_t _colId); */
/** int32_t getColSize(int32_t _colId);
* @brief get the size view of the lines. /**
* @return The size of the lines. * @brief get the size view of the lines.
*/ * @return The size of the lines.
int32_t getRowSize(void); */
/** int32_t getRowSize(void);
* @brief set the gravity of the widget on the Button (index 0 is on buttom) /**
*/ * @brief set the gravity of the widget on the Button (index 0 is on buttom)
void setGravityButtom(void) { */
m_gavityButtom = true; void setGravityButtom(void) {
markToRedraw(); m_gavityButtom = true;
} markToRedraw();
/** }
* @brief set the gravity of the widget on the Top (index 0 is on top) /**
*/ * @brief set the gravity of the widget on the Top (index 0 is on top)
void setGravityTop(void) { */
m_gavityButtom = false; void setGravityTop(void) {
markToRedraw(); m_gavityButtom = false;
} markToRedraw();
public: }
/** public:
* @brief remove all sub element from the widget. /**
*/ * @brief remove all sub element from the widget.
virtual void subWidgetRemoveAll(void); */
/** virtual void subWidgetRemoveAll(void);
* @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right) /**
* @param[in] _colId Id of the colomn [0..x]. * @brief add at end position a Widget (note : This system use an inverted phylisophie (button to top, and left to right)
* @param[in] _rowId Id of the row [0..y]. * @param[in] _colId Id of the colomn [0..x].
* @param[in] _newWidget the element pointer * @param[in] _rowId Id of the row [0..y].
*/ * @param[in] _newWidget the element pointer
virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget); */
/** virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget);
* @brief remove definitly a widget from the system and this Gird. /**
* @param[in] _newWidget the element pointer. * @brief remove definitly a widget from the system and this Gird.
*/ * @param[in] _newWidget the element pointer.
virtual void subWidgetRemove(ewol::Widget* _newWidget); */
/** virtual void subWidgetRemove(ewol::Widget* _newWidget);
* @brief remove definitly a widget from the system and this Gird. /**
* @param[in] _colId Id of the colomn [0..x]. * @brief remove definitly a widget from the system and this Gird.
* @param[in] _rowId Id of the row [0..y]. * @param[in] _colId Id of the colomn [0..x].
*/ * @param[in] _rowId Id of the row [0..y].
virtual void subWidgetRemove(int32_t _colId, int32_t _rowId); */
/** virtual void subWidgetRemove(int32_t _colId, int32_t _rowId);
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). /**
* @param[in] _newWidget the element pointer. * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
*/ * @param[in] _newWidget the element pointer.
virtual void subWidgetUnLink(ewol::Widget* _newWidget); */
/** virtual void subWidgetUnLink(ewol::Widget* _newWidget);
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...). /**
* @param[in] _colId Id of the colomn [0..x]. * @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
* @param[in] _rowId Id of the row [0..y]. * @param[in] _colId Id of the colomn [0..x].
*/ * @param[in] _rowId Id of the row [0..y].
virtual void subWidgetUnLink(int32_t _colId, int32_t _rowId); */
private: virtual void subWidgetUnLink(int32_t _colId, int32_t _rowId);
ivec2 m_borderSize; //!< Border size needed for all the display private:
public: ivec2 m_borderSize; //!< Border size needed for all the display
/** public:
* @brief set the current border size of the current element: /**
* @param[in] _newBorderSize The border size to set (0 if not used) * @brief set the current border size of the current element:
*/ * @param[in] _newBorderSize The border size to set (0 if not used)
void setBorderSize(const ivec2& _newBorderSize); */
/** void setBorderSize(const ivec2& _newBorderSize);
* @brief get the current border size of the current element: /**
* @return the border size (0 if not used) * @brief get the current border size of the current element:
*/ * @return the border size (0 if not used)
const ivec2& getBorderSize(void) { return m_borderSize; }; */
public: // Derived function const ivec2& getBorderSize(void) { return m_borderSize; };
virtual void systemDraw(const ewol::DrawProperty& _displayProp); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos); virtual void onRegenerateDisplay(void);
virtual void onObjectRemove(ewol::EObject* _removeObject); virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual void calculateSize(const vec2& _availlable); virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateMinMaxSize(void); virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
};
}; };
}; };
#endif #endif

View File

@ -17,25 +17,25 @@
#define __class__ "Image" #define __class__ "Image"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Image(); return new ewol::widget::Image();
} }
void widget::Image::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Image::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
const char * const widget::Image::eventPressed = "ewol-widget-image-event-pressed"; const char * const ewol::widget::Image::eventPressed = "ewol-widget-image-event-pressed";
const char * const widget::Image::configRatio = "ratio"; const char * const ewol::widget::Image::configRatio = "ratio";
const char * const widget::Image::configSize = "size"; const char * const ewol::widget::Image::configSize = "size";
const char * const widget::Image::configBorder = "border"; const char * const ewol::widget::Image::configBorder = "border";
const char * const widget::Image::configSource = "src"; const char * const ewol::widget::Image::configSource = "src";
widget::Image::Image(const std::string& _file, const ewol::Dimension& _border) : ewol::widget::Image::Image(const std::string& _file, const ewol::Dimension& _border) :
m_imageSize(vec2(0,0)), m_imageSize(vec2(0,0)),
m_keepRatio(true) { m_keepRatio(true) {
addObjectType("widget::Image"); addObjectType("ewol::widget::Image");
addEventId(eventPressed); addEventId(eventPressed);
registerConfig(configRatio, "bool", NULL, "Keep ratio of the image"); registerConfig(configRatio, "bool", NULL, "Keep ratio of the image");
registerConfig(configSize, "Dimension", NULL, "Basic display size of the image"); registerConfig(configSize, "Dimension", NULL, "Basic display size of the image");
@ -45,7 +45,7 @@ widget::Image::Image(const std::string& _file, const ewol::Dimension& _border) :
} }
void widget::Image::setFile(const std::string& _file) { void ewol::widget::Image::setFile(const std::string& _file) {
EWOL_VERBOSE("Set Image : " << _file); EWOL_VERBOSE("Set Image : " << _file);
if (m_fileName != _file) { if (m_fileName != _file) {
// copy data : // copy data :
@ -57,7 +57,7 @@ void widget::Image::setFile(const std::string& _file) {
} }
} }
void widget::Image::setBorder(const ewol::Dimension& _border) { void ewol::widget::Image::setBorder(const ewol::Dimension& _border) {
EWOL_VERBOSE("Set border=" << _border); EWOL_VERBOSE("Set border=" << _border);
// copy data : // copy data :
m_border = _border; m_border = _border;
@ -67,7 +67,7 @@ void widget::Image::setBorder(const ewol::Dimension& _border) {
requestUpdateSize(); requestUpdateSize();
} }
void widget::Image::setKeepRatio(bool _keep) { void ewol::widget::Image::setKeepRatio(bool _keep) {
if (m_keepRatio != _keep) { if (m_keepRatio != _keep) {
// copy data : // copy data :
m_keepRatio = _keep; m_keepRatio = _keep;
@ -77,7 +77,7 @@ void widget::Image::setKeepRatio(bool _keep) {
} }
} }
void widget::Image::setImageSize(const ewol::Dimension& _size) { void ewol::widget::Image::setImageSize(const ewol::Dimension& _size) {
EWOL_VERBOSE("Set Image size : " << _size); EWOL_VERBOSE("Set Image size : " << _size);
if (_size != m_imageSize) { if (_size != m_imageSize) {
m_imageSize = _size; m_imageSize = _size;
@ -88,7 +88,7 @@ void widget::Image::setImageSize(const ewol::Dimension& _size) {
} }
} }
void widget::Image::set(const std::string& _file, const ewol::Dimension& _border) { void ewol::widget::Image::set(const std::string& _file, const ewol::Dimension& _border) {
EWOL_VERBOSE("Set Image : " << _file << " border=" << _border); EWOL_VERBOSE("Set Image : " << _file << " border=" << _border);
// copy data : // copy data :
if (m_border != _border) { if (m_border != _border) {
@ -99,11 +99,11 @@ void widget::Image::set(const std::string& _file, const ewol::Dimension& _border
setFile(_file); setFile(_file);
} }
void widget::Image::onDraw(void) { void ewol::widget::Image::onDraw(void) {
m_compositing.draw(); m_compositing.draw();
} }
void widget::Image::onRegenerateDisplay(void) { void ewol::widget::Image::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
// remove data of the previous composition : // remove data of the previous composition :
m_compositing.clear(); m_compositing.clear();
@ -149,7 +149,7 @@ void widget::Image::onRegenerateDisplay(void) {
} }
} }
void widget::Image::calculateMinMaxSize(void) { void ewol::widget::Image::calculateMinMaxSize(void) {
vec2 imageBoder = m_border.getPixel()*2.0f; vec2 imageBoder = m_border.getPixel()*2.0f;
vec2 imageSize = m_imageSize.getPixel(); vec2 imageSize = m_imageSize.getPixel();
if (imageSize!=vec2(0,0)) { if (imageSize!=vec2(0,0)) {
@ -170,7 +170,7 @@ void widget::Image::calculateMinMaxSize(void) {
} }
bool widget::Image::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Image::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
if(ewol::keyEvent::statusSingle == _event.getStatus()) { if(ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -181,7 +181,7 @@ bool widget::Image::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
bool widget::Image::loadXML(exml::Element* _node) { bool ewol::widget::Image::loadXML(exml::Element* _node) {
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -220,7 +220,7 @@ bool widget::Image::loadXML(exml::Element* _node) {
return true; return true;
} }
bool widget::Image::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::Image::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) { if (true == ewol::Widget::onSetConfig(_conf)) {
return true; return true;
} }
@ -243,7 +243,7 @@ bool widget::Image::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::Image::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::Image::onGetConfig(const char* _config, std::string& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) { if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -18,111 +18,113 @@
extern const char * const ewolEventImagePressed; extern const char * const ewolEventImagePressed;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Image :public ewol::Widget { */
public: class Image :public ewol::Widget {
// Event list of properties public:
static const char * const eventPressed; // Event list of properties
// Config list of properties static const char * const eventPressed;
static const char * const configRatio; // Config list of properties
static const char * const configSize; static const char * const configRatio;
static const char * const configBorder; static const char * const configSize;
static const char * const configSource; static const char * const configBorder;
public: static const char * const configSource;
/** public:
* @brief Main call of recording the widget on the List of "widget named creator" /**
*/ * @brief Main call of recording the widget on the List of "widget named creator"
static void init(ewol::WidgetManager& _widgetManager); */
protected: static void init(ewol::WidgetManager& _widgetManager);
ewol::Image m_compositing; //!< compositing element of the image. protected:
public: ewol::Image m_compositing; //!< compositing element of the image.
/** public:
* @brief /**
*/ * @brief
Image(const std::string& _file="", */
const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter)); Image(const std::string& _file="",
/** const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
* @brief /**
*/ * @brief
virtual ~Image(void) { }; */
/** virtual ~Image(void) { };
* @brief set All the configuration of the current image /**
* @param[in] _file Filaneme of the new image * @brief set All the configuration of the current image
* @param[in] _border New border size to set * @param[in] _file Filaneme of the new image
*/ * @param[in] _border New border size to set
void set(const std::string& _file, const ewol::Dimension& _border); */
protected: void set(const std::string& _file, const ewol::Dimension& _border);
std::string m_fileName; //!< file name of the image. protected:
public: std::string m_fileName; //!< file name of the image.
/** public:
* @brief set the new filename /**
* @param[in] _file Filaneme of the new image * @brief set the new filename
*/ * @param[in] _file Filaneme of the new image
void setFile(const std::string& _file); */
/** void setFile(const std::string& _file);
* @brief get the file displayed /**
* @return the filename of the image * @brief get the file displayed
*/ * @return the filename of the image
const std::string& getFile(void) const { */
return m_fileName; const std::string& getFile(void) const {
}; return m_fileName;
protected: };
ewol::Dimension m_border; //!< border to add at the image. protected:
public: ewol::Dimension m_border; //!< border to add at the image.
/** public:
* @brief set tge Border size around the image /**
* @param[in] _border New border size to set * @brief set tge Border size around the image
*/ * @param[in] _border New border size to set
void setBorder(const ewol::Dimension& _border); */
/** void setBorder(const ewol::Dimension& _border);
* @brief get the current border request at the image /**
* @return the border size * @brief get the current border request at the image
*/ * @return the border size
const ewol::Dimension& getBorder(void) const { */
return m_border; const ewol::Dimension& getBorder(void) const {
}; return m_border;
protected: };
ewol::Dimension m_imageSize; //!< border to add at the image. protected:
public: ewol::Dimension m_imageSize; //!< border to add at the image.
/** public:
* @brief set tge Border size around the image /**
* @param[in] _size New border size to set * @brief set tge Border size around the image
*/ * @param[in] _size New border size to set
void setImageSize(const ewol::Dimension& _size); */
/** void setImageSize(const ewol::Dimension& _size);
* @brief get the current border request at the image /**
* @return the border size * @brief get the current border request at the image
*/ * @return the border size
const ewol::Dimension& getImageSize(void) const { */
return m_imageSize; const ewol::Dimension& getImageSize(void) const {
}; return m_imageSize;
protected: };
bool m_keepRatio; //!< keep the image ratio between width and hight protected:
public: bool m_keepRatio; //!< keep the image ratio between width and hight
/** public:
* @brief set the current status of keeping ratio. /**
* @param[in] _keep The new status of keeping the ratio of this image. * @brief set the current status of keeping ratio.
*/ * @param[in] _keep The new status of keeping the ratio of this image.
void setKeepRatio(bool _keep); */
/** void setKeepRatio(bool _keep);
* @brief get the current status of keeping ratio. /**
* @return The status of keeping the ratio of this image. * @brief get the current status of keeping ratio.
*/ * @return The status of keeping the ratio of this image.
bool getKeepRatio(void) const { */
return m_keepRatio; bool getKeepRatio(void) const {
}; return m_keepRatio;
protected: // Derived function };
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
public: // Derived function virtual bool onGetConfig(const char* _config, std::string& _result) const;
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool loadXML(exml::Element* _node); virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool loadXML(exml::Element* _node);
};
}; };
}; };

View File

@ -24,8 +24,8 @@ static float l_ratio(1.0/7.0);
#undef __class__ #undef __class__
#define __class__ "Joystick" #define __class__ "Joystick"
widget::Joystick::Joystick(void) { ewol::widget::Joystick::Joystick(void) {
addObjectType("widget::Joystick"); addObjectType("ewol::widget::Joystick");
addEventId(ewolEventJoystickEnable); addEventId(ewolEventJoystickEnable);
addEventId(ewolEventJoystickDisable); addEventId(ewolEventJoystickDisable);
addEventId(ewolEventJoystickMove); addEventId(ewolEventJoystickMove);
@ -51,18 +51,18 @@ widget::Joystick::Joystick(void) {
} }
widget::Joystick::~Joystick(void) { ewol::widget::Joystick::~Joystick(void) {
} }
void widget::Joystick::calculateSize(const vec2& availlable) { void ewol::widget::Joystick::calculateSize(const vec2& availlable) {
float minimumSize = etk_min(availlable.x(), availlable.y()); float minimumSize = etk_min(availlable.x(), availlable.y());
m_size.setValue(minimumSize, minimumSize); m_size.setValue(minimumSize, minimumSize);
markToRedraw(); markToRedraw();
} }
void widget::Joystick::onRegenerateDisplay(void) { void ewol::widget::Joystick::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
// clean the object list ... // clean the object list ...
@ -114,7 +114,7 @@ Sine Function: sin(teta) = Opposite / Hypotenuse
Cosine Function: cos(teta) = Adjacent / Hypotenuse Cosine Function: cos(teta) = Adjacent / Hypotenuse
Tangent Function: tan(teta) = Opposite / Adjacent Tangent Function: tan(teta) = Opposite / Adjacent
*/ */
bool widget::Joystick::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Joystick::onEventInput(const ewol::EventInput& _event) {
/* /*
if (1 == IdInput) { if (1 == IdInput) {
if( ewol::keyEvent::statusDown == typeEvent if( ewol::keyEvent::statusDown == typeEvent
@ -173,7 +173,7 @@ bool widget::Joystick::onEventInput(const ewol::EventInput& _event) {
} }
void widget::Joystick::ratio(float newRatio) { void ewol::widget::Joystick::ratio(float newRatio) {
if (newRatio > 1) { if (newRatio > 1) {
newRatio = 1; newRatio = 1;
} }
@ -182,7 +182,7 @@ void widget::Joystick::ratio(float newRatio) {
} }
void widget::Joystick::background(std::string imageNameInData, bool display) { void ewol::widget::Joystick::background(std::string imageNameInData, bool display) {
// TODO : check if it existed // TODO : check if it existed
m_background = imageNameInData; m_background = imageNameInData;
m_displayBackground = display; m_displayBackground = display;
@ -190,14 +190,14 @@ void widget::Joystick::background(std::string imageNameInData, bool display) {
} }
void widget::Joystick::foreground(std::string imageNameInData) { void ewol::widget::Joystick::foreground(std::string imageNameInData) {
// TODO : check if it existed // TODO : check if it existed
m_foreground = imageNameInData; m_foreground = imageNameInData;
EWOL_INFO("Set default Joystick Foreground at " << m_foreground); EWOL_INFO("Set default Joystick Foreground at " << m_foreground);
} }
void widget::Joystick::getProperty(float& distance, float& angle) { void ewol::widget::Joystick::getProperty(float& distance, float& angle) {
distance = m_distance; distance = m_distance;
angle = m_angle+M_PI/2; angle = m_angle+M_PI/2;
} }

View File

@ -18,67 +18,69 @@ extern const char * const ewolEventJoystickEnable;
extern const char * const ewolEventJoystickDisable; extern const char * const ewolEventJoystickDisable;
extern const char * const ewolEventJoystickMove; extern const char * const ewolEventJoystickMove;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Joystick :public ewol::Widget { */
public: class Joystick :public ewol::Widget {
enum joystickMode { public:
modeNormal, enum joystickMode {
modeArrow, modeNormal,
}; modeArrow,
private: };
draw::Color m_colorFg; //!< Forground color private:
draw::Color m_colorBg; //!< Background color draw::Color m_colorFg; //!< Forground color
vec2 m_displayPos; //!< direction of the cursor ... draw::Color m_colorBg; //!< Background color
float m_distance; //!< dintance from the center vec2 m_displayPos; //!< direction of the cursor ...
float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ... float m_distance; //!< dintance from the center
bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ...
enum joystickMode m_displayMode; //!< Type of fonctionnal mode of the joystick bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle
private: enum joystickMode m_displayMode; //!< Type of fonctionnal mode of the joystick
// generic property of the joystick: private:
bool m_displayBackground; // generic property of the joystick:
std::string m_background; bool m_displayBackground;
std::string m_foreground; std::string m_background;
float m_ratio; std::string m_foreground;
public: float m_ratio;
Joystick(void); public:
virtual ~Joystick(void); Joystick(void);
public: virtual ~Joystick(void);
void setLockMode(bool _lockWhenOut) { public:
m_lock = _lockWhenOut; void setLockMode(bool _lockWhenOut) {
}; m_lock = _lockWhenOut;
void setDisplayMode(enum joystickMode _newMode) { };
m_displayMode = _newMode; void setDisplayMode(enum joystickMode _newMode) {
}; m_displayMode = _newMode;
/** };
* @brief set the ratio of the widget joystick /**
* @param[in] _newRatio the new ratio that might be set * @brief set the ratio of the widget joystick
*/ * @param[in] _newRatio the new ratio that might be set
void ratio(float _newRatio); */
/** void ratio(float _newRatio);
* @brief set the Background of the widget joystick /**
* @param[in] _imageNameInData the new rbackground that might be set * @brief set the Background of the widget joystick
* @param[in] _display * @param[in] _imageNameInData the new rbackground that might be set
*/ * @param[in] _display
void background(std::string _imageNameInData, bool _display=true); */
/** void background(std::string _imageNameInData, bool _display=true);
* @brief set the Foreground of the widget joystick /**
* @param[in] _imageNameInData the new Foreground that might be set * @brief set the Foreground of the widget joystick
*/ * @param[in] _imageNameInData the new Foreground that might be set
void foreground(std::string _imageNameInData); */
/** void foreground(std::string _imageNameInData);
* @brief get the property of the joystick /**
* @param[out] _distance distance to the center * @brief get the property of the joystick
* @param[out] _angle angle of the joy * @param[out] _distance distance to the center
*/ * @param[out] _angle angle of the joy
void getProperty(float& _distance, float& _angle); */
void getProperty(float& _distance, float& _angle);
public: // Derived function
virtual void calculateSize(const vec2& _availlable); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateSize(const vec2& _availlable);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
};
}; };
}; };

View File

@ -15,24 +15,24 @@
#undef __class__ #undef __class__
#define __class__ "Label" #define __class__ "Label"
const char * const widget::Label::eventPressed = "ewol-widget-label-event-pressed"; const char * const ewol::widget::Label::eventPressed = "ewol-widget-label-event-pressed";
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Label(); return new ewol::widget::Label();
} }
void widget::Label::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Label::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::Label::Label(std::string _newLabel) { ewol::widget::Label::Label(std::string _newLabel) {
addObjectType("widget::Label"); addObjectType("ewol::widget::Label");
m_label = _newLabel; m_label = _newLabel;
addEventId(eventPressed); addEventId(eventPressed);
setCanHaveFocus(false); setCanHaveFocus(false);
} }
void widget::Label::calculateMinMaxSize(void) { void ewol::widget::Label::calculateMinMaxSize(void) {
vec2 tmpMax = m_userMaxSize.getPixel(); vec2 tmpMax = m_userMaxSize.getPixel();
//EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} tmpMax : " << tmpMax); //EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} tmpMax : " << tmpMax);
if (tmpMax.x() <= 999999) { if (tmpMax.x() <= 999999) {
@ -47,21 +47,21 @@ void widget::Label::calculateMinMaxSize(void) {
//EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); //EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize);
} }
void widget::Label::setLabel(const std::string& _newLabel) { void ewol::widget::Label::setLabel(const std::string& _newLabel) {
m_label = _newLabel; m_label = _newLabel;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
std::string widget::Label::getLabel(void) { std::string ewol::widget::Label::getLabel(void) {
return m_label; return m_label;
} }
void widget::Label::onDraw(void) { void ewol::widget::Label::onDraw(void) {
m_text.draw(); m_text.draw();
} }
void widget::Label::onRegenerateDisplay(void) { void ewol::widget::Label::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
m_text.clear(); m_text.clear();
int32_t paddingSize = 2; int32_t paddingSize = 2;
@ -110,7 +110,7 @@ void widget::Label::onRegenerateDisplay(void) {
} }
} }
bool widget::Label::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Label::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on Label ..."); //EWOL_DEBUG("Event on Label ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) { if (ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -122,7 +122,7 @@ bool widget::Label::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
bool widget::Label::loadXML(exml::Element* _node) { bool ewol::widget::Label::loadXML(exml::Element* _node) {
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }

View File

@ -15,56 +15,58 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Label : public ewol::Widget { */
public: class Label : public ewol::Widget {
// Event list of properties public:
static const char * const eventPressed; // Event list of properties
/** static const char * const eventPressed;
* @brief Main call of recording the widget on the List of "widget named creator" /**
*/ * @brief Main call of recording the widget on the List of "widget named creator"
static void init(ewol::WidgetManager& _widgetManager); */
private: static void init(ewol::WidgetManager& _widgetManager);
ewol::Text m_text; //!< Compositing text element. private:
std::string m_label; //!< decorated text to display. ewol::Text m_text; //!< Compositing text element.
public: std::string m_label; //!< decorated text to display.
/** public:
* @brief Constructor /**
* @param[in] _newLabel The displayed decorated text. * @brief Constructor
*/ * @param[in] _newLabel The displayed decorated text.
Label(std::string _newLabel="---"); */
/** Label(std::string _newLabel="---");
* @brief destructor /**
*/ * @brief destructor
virtual ~Label(void) { */
virtual ~Label(void) {
};
/** };
* @brief change the label displayed /**
* @param[in] _newLabel The displayed decorated text. * @brief change the label displayed
*/ * @param[in] _newLabel The displayed decorated text.
void setLabel(const std::string& _newLabel); */
inline void setValue(const std::string& _newLabel) { void setLabel(const std::string& _newLabel);
setLabel(_newLabel); inline void setValue(const std::string& _newLabel) {
}; setLabel(_newLabel);
/** };
* @brief get the current displayed label /**
* @return The displayed decorated text. * @brief get the current displayed label
*/ * @return The displayed decorated text.
std::string getLabel(void); */
inline std::string getValue(void) { std::string getLabel(void);
return getLabel(); inline std::string getValue(void) {
}; return getLabel();
protected: // Derived function };
virtual void onDraw(void); protected: // Derived function
public: // Derived function virtual void onDraw(void);
virtual void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool loadXML(exml::Element* _node); virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool loadXML(exml::Element* _node);
};
}; };
}; };

View File

@ -14,22 +14,22 @@
#define __class__ "Layer" #define __class__ "Layer"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Layer(); return new ewol::widget::Layer();
} }
void widget::Layer::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Layer::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::Layer::Layer(void) { ewol::widget::Layer::Layer(void) {
addObjectType("widget::Layer"); addObjectType("ewol::widget::Layer");
} }
widget::Layer::~Layer(void) { ewol::widget::Layer::~Layer(void) {
EWOL_DEBUG("[" << getId() << "] Layer : destroy"); EWOL_DEBUG("[" << getId() << "] Layer : destroy");
} }
ewol::Widget* widget::Layer::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) { if (true == isHide()) {
return NULL; return NULL;
} }

View File

@ -14,29 +14,30 @@
#include <ewol/widget/ContainerN.h> #include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Layer : public widget::ContainerN { */
public: class Layer : public widget::ContainerN {
/** public:
* @brief Main call of recording the widget on the List of "widget named creator" /**
*/ * @brief Main call of recording the widget on the List of "widget named creator"
static void init(ewol::WidgetManager& _widgetManager); */
public: static void init(ewol::WidgetManager& _widgetManager);
/** public:
* @brief Constructor /**
*/ * @brief Constructor
Layer(void); */
/** Layer(void);
* @brief Desstructor /**
*/ * @brief Desstructor
virtual ~Layer(void); */
public: // Derived function virtual ~Layer(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos); public: // Derived function
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
};
}; };
}; };
#endif #endif

View File

@ -16,8 +16,8 @@
#define __class__ "List" #define __class__ "List"
widget::List::List(void) { ewol::widget::List::List(void) {
addObjectType("widget::List"); addObjectType("ewol::widget::List");
m_paddingSizeX = 2; m_paddingSizeX = 2;
#ifdef __TARGET_OS__Android #ifdef __TARGET_OS__Android
m_paddingSizeY = 10; m_paddingSizeY = 10;
@ -28,7 +28,7 @@ widget::List::List(void) {
setCanHaveFocus(true); setCanHaveFocus(true);
} }
widget::List::~List(void) { ewol::widget::List::~List(void) {
//clean all the object //clean all the object
for (size_t iii=0; iii<m_listOObject.size(); iii++) { for (size_t iii=0; iii<m_listOObject.size(); iii++) {
delete(m_listOObject[iii]); delete(m_listOObject[iii]);
@ -37,7 +37,7 @@ widget::List::~List(void) {
m_listOObject.clear(); m_listOObject.clear();
} }
void widget::List::setRawVisible(int32_t _id) { void ewol::widget::List::setRawVisible(int32_t _id) {
EWOL_DEBUG("Set Raw visible : " << _id); EWOL_DEBUG("Set Raw visible : " << _id);
if (_id<0) { if (_id<0) {
return; return;
@ -63,7 +63,7 @@ void widget::List::setRawVisible(int32_t _id) {
markToRedraw(); markToRedraw();
} }
void widget::List::calculateMinMaxSize(void) { void ewol::widget::List::calculateMinMaxSize(void) {
/*int32_t fontId = getDefaultFontId(); /*int32_t fontId = getDefaultFontId();
int32_t minWidth = ewol::getWidth(fontId, m_label); int32_t minWidth = ewol::getWidth(fontId, m_label);
int32_t minHeight = ewol::getHeight(fontId); int32_t minHeight = ewol::getHeight(fontId);
@ -73,7 +73,7 @@ void widget::List::calculateMinMaxSize(void) {
m_minSize.setValue(200, 150); m_minSize.setValue(200, 150);
} }
void widget::List::addOObject(ewol::Compositing* _newObject, int32_t _pos) { void ewol::widget::List::addOObject(ewol::Compositing* _newObject, int32_t _pos) {
if (NULL == _newObject) { if (NULL == _newObject) {
EWOL_ERROR("Try to add an empty object in the Widget generic display system"); EWOL_ERROR("Try to add an empty object in the Widget generic display system");
return; return;
@ -85,7 +85,7 @@ void widget::List::addOObject(ewol::Compositing* _newObject, int32_t _pos) {
} }
} }
void widget::List::clearOObjectList(void) { void ewol::widget::List::clearOObjectList(void) {
for (size_t iii=0; iii<m_listOObject.size(); iii++) { for (size_t iii=0; iii<m_listOObject.size(); iii++) {
delete(m_listOObject[iii]); delete(m_listOObject[iii]);
m_listOObject[iii] = NULL; m_listOObject[iii] = NULL;
@ -93,7 +93,7 @@ void widget::List::clearOObjectList(void) {
m_listOObject.clear(); m_listOObject.clear();
} }
void widget::List::onDraw(void) { void ewol::widget::List::onDraw(void) {
for (size_t iii=0; iii<m_listOObject.size(); iii++) { for (size_t iii=0; iii<m_listOObject.size(); iii++) {
if (NULL != m_listOObject[iii]) { if (NULL != m_listOObject[iii]) {
m_listOObject[iii]->draw(); m_listOObject[iii]->draw();
@ -102,7 +102,7 @@ void widget::List::onDraw(void) {
WidgetScrooled::onDraw(); WidgetScrooled::onDraw();
} }
void widget::List::onRegenerateDisplay(void) { void ewol::widget::List::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
// clean the object list ... // clean the object list ...
@ -212,7 +212,7 @@ void widget::List::onRegenerateDisplay(void) {
} }
} }
bool widget::List::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::List::onEventInput(const ewol::EventInput& _event) {
vec2 relativePos = relativePosition(_event.getPos()); vec2 relativePos = relativePosition(_event.getPos());
if (true == WidgetScrooled::onEventInput(_event)) { if (true == WidgetScrooled::onEventInput(_event)) {
@ -240,10 +240,10 @@ bool widget::List::onEventInput(const ewol::EventInput& _event) {
return isUsed; return isUsed;
} }
void widget::List::onGetFocus(void) { void ewol::widget::List::onGetFocus(void) {
EWOL_DEBUG("Ewol::List get focus"); EWOL_DEBUG("Ewol::List get focus");
} }
void widget::List::onLostFocus(void) { void ewol::widget::List::onLostFocus(void) {
EWOL_DEBUG("Ewol::List Lost focus"); EWOL_DEBUG("Ewol::List Lost focus");
} }

View File

@ -15,71 +15,73 @@
#include <ewol/widget/WidgetScrolled.h> #include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Compositing.h> #include <ewol/compositing/Compositing.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class List : public widget::WidgetScrooled { */
public: class List : public widget::WidgetScrooled {
List(void); public:
virtual ~List(void); List(void);
virtual void calculateMinMaxSize(void); virtual ~List(void);
void setLabel(std::string _newLabel); virtual void calculateMinMaxSize(void);
// drawing capabilities .... void setLabel(std::string _newLabel);
private: // drawing capabilities ....
std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display... private:
std::vector<ivec2 > m_lineSize; std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
public: std::vector<ivec2 > m_lineSize;
void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1); public:
void clearOObjectList(void); void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
// list properties ... void clearOObjectList(void);
private: // list properties ...
int32_t m_paddingSizeX; private:
int32_t m_paddingSizeY; int32_t m_paddingSizeX;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw int32_t m_paddingSizeY;
int32_t m_displayCurrentNbLine; //!< Number of line in the display int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display) int32_t m_displayCurrentNbLine; //!< Number of line in the display
protected: int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display)
// function call to display the list : protected:
virtual etk::Color<> getBasicBG(void) { // function call to display the list :
return etk::Color<>(0xFFFFFFFF); virtual etk::Color<> getBasicBG(void) {
} return etk::Color<>(0xFFFFFFFF);
virtual uint32_t getNuberOfColomn(void) {
return 1;
};
virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<> &_fg, etk::Color<> &_bg) {
_myTitle = "";
return false;
};
virtual uint32_t getNuberOfRaw(void) {
return 0;
};
virtual bool getElement(int32_t _colomn, int32_t _raw, std::string &_myTextToWrite, etk::Color<> &_fg, etk::Color<> &_bg) {
_myTextToWrite = "";
_bg = 0xFFFFFFFF;
_fg = 0x000000FF;
if (_raw % 2) {
_bg = 0xFFFFFFFF;
} else {
_bg = 0x7F7F7FFF;
} }
return false; virtual uint32_t getNuberOfColomn(void) {
}; return 1;
virtual bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) { };
return false; virtual bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<> &_fg, etk::Color<> &_bg) {
} _myTitle = "";
/** return false;
* @brief set a raw visible in the main display };
* @param[in] _id Id of the raw that might be visible. virtual uint32_t getNuberOfRaw(void) {
*/ return 0;
void setRawVisible(int32_t _id); };
protected: // Derived function virtual bool getElement(int32_t _colomn, int32_t _raw, std::string &_myTextToWrite, etk::Color<> &_fg, etk::Color<> &_bg) {
virtual void onGetFocus(void); _myTextToWrite = "";
virtual void onLostFocus(void); _bg = 0xFFFFFFFF;
virtual void onDraw(void); _fg = 0x000000FF;
public: // Derived function if (_raw % 2) {
virtual void onRegenerateDisplay(void); _bg = 0xFFFFFFFF;
virtual bool onEventInput(const ewol::EventInput& _event); } else {
_bg = 0x7F7F7FFF;
}
return false;
};
virtual bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) {
return false;
}
/**
* @brief set a raw visible in the main display
* @param[in] _id Id of the raw that might be visible.
*/
void setRawVisible(int32_t _id);
protected: // Derived function
virtual void onGetFocus(void);
virtual void onLostFocus(void);
virtual void onDraw(void);
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
};
}; };
}; };

View File

@ -21,8 +21,8 @@ extern const char * const ewolEventFSFolderSelect = "ewol-event-file-system-fo
extern const char * const ewolEventFSFolderValidate = "ewol-event-file-system-folder-validate"; extern const char * const ewolEventFSFolderValidate = "ewol-event-file-system-folder-validate";
widget::ListFileSystem::ListFileSystem(void) { ewol::widget::ListFileSystem::ListFileSystem(void) {
addObjectType("widget::ListFileSystem"); addObjectType("ewol::widget::ListFileSystem");
m_selectedLine = -1; m_selectedLine = -1;
m_showFile = true; m_showFile = true;
m_showTemporaryFile = true; m_showTemporaryFile = true;
@ -40,7 +40,7 @@ widget::ListFileSystem::ListFileSystem(void) {
setMouseLimit(1); setMouseLimit(1);
}; };
widget::ListFileSystem::~ListFileSystem(void) { ewol::widget::ListFileSystem::~ListFileSystem(void) {
for (size_t iii=0; iii<m_list.size(); iii++) { for (size_t iii=0; iii<m_list.size(); iii++) {
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
delete(m_list[iii]); delete(m_list[iii]);
@ -49,12 +49,12 @@ widget::ListFileSystem::~ListFileSystem(void) {
} }
}; };
etk::Color<> widget::ListFileSystem::getBasicBG(void) { etk::Color<> ewol::widget::ListFileSystem::getBasicBG(void) {
return etk::Color<>(0x00000010); return etk::Color<>(0x00000010);
} }
void widget::ListFileSystem::regenerateView(void) { void ewol::widget::ListFileSystem::regenerateView(void) {
// clean the list of files : // clean the list of files :
for (size_t iii=0; iii<m_list.size(); iii++) { for (size_t iii=0; iii<m_list.size(); iii++) {
if (NULL != m_list[iii]) { if (NULL != m_list[iii]) {
@ -73,36 +73,36 @@ void widget::ListFileSystem::regenerateView(void) {
markToRedraw(); markToRedraw();
} }
void widget::ListFileSystem::setShowHiddenFiles(bool _state) { void ewol::widget::ListFileSystem::setShowHiddenFiles(bool _state) {
m_showHidden = _state; m_showHidden = _state;
regenerateView(); regenerateView();
} }
void widget::ListFileSystem::setShowTemporaryFiles(bool _state) { void ewol::widget::ListFileSystem::setShowTemporaryFiles(bool _state) {
m_showTemporaryFile = _state; m_showTemporaryFile = _state;
regenerateView(); regenerateView();
} }
void widget::ListFileSystem::setShowFiles(bool _state) { void ewol::widget::ListFileSystem::setShowFiles(bool _state) {
m_showFile = _state; m_showFile = _state;
regenerateView(); regenerateView();
} }
void widget::ListFileSystem::setShowFolder(bool _state) { void ewol::widget::ListFileSystem::setShowFolder(bool _state) {
m_showFolder = _state; m_showFolder = _state;
regenerateView(); regenerateView();
} }
void widget::ListFileSystem::setFolder(std::string _newFolder) { void ewol::widget::ListFileSystem::setFolder(std::string _newFolder) {
m_folder = _newFolder; m_folder = _newFolder;
regenerateView(); regenerateView();
} }
std::string widget::ListFileSystem::getFolder(void) { std::string ewol::widget::ListFileSystem::getFolder(void) {
return m_folder; return m_folder;
} }
std::string widget::ListFileSystem::getSelect(void) { std::string ewol::widget::ListFileSystem::getSelect(void) {
std::string tmpVal = ""; std::string tmpVal = "";
if (m_selectedLine >= 0) { if (m_selectedLine >= 0) {
if (m_list[m_selectedLine] != NULL) { if (m_list[m_selectedLine] != NULL) {
@ -113,7 +113,7 @@ std::string widget::ListFileSystem::getSelect(void) {
} }
// select the specific file // select the specific file
void widget::ListFileSystem::setSelect( std::string _data) { void ewol::widget::ListFileSystem::setSelect( std::string _data) {
// remove selected line // remove selected line
m_selectedLine = -1; m_selectedLine = -1;
// search the coresponding file : // search the coresponding file :
@ -129,16 +129,16 @@ void widget::ListFileSystem::setSelect( std::string _data) {
markToRedraw(); markToRedraw();
} }
uint32_t widget::ListFileSystem::getNuberOfColomn(void) { uint32_t ewol::widget::ListFileSystem::getNuberOfColomn(void) {
return 1; return 1;
} }
bool widget::ListFileSystem::getTitle(int32_t _colomn, std::string &_myTitle, etk::Color<>& _fg, etk::Color<>& _bg) { bool ewol::widget::ListFileSystem::getTitle(int32_t _colomn, std::string &_myTitle, etk::Color<>& _fg, etk::Color<>& _bg) {
_myTitle = "title"; _myTitle = "title";
return true; return true;
} }
uint32_t widget::ListFileSystem::getNuberOfRaw(void) { uint32_t ewol::widget::ListFileSystem::getNuberOfRaw(void) {
int32_t offset = 0; int32_t offset = 0;
if (true == m_showFolder) { if (true == m_showFolder) {
offset = 2; offset = 2;
@ -146,7 +146,7 @@ uint32_t widget::ListFileSystem::getNuberOfRaw(void) {
return m_list.size() + offset; return m_list.size() + offset;
} }
bool widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) { bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) {
int32_t offset = 0; int32_t offset = 0;
if (true == m_showFolder) { if (true == m_showFolder) {
offset = 2; offset = 2;
@ -180,12 +180,12 @@ bool widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std::stri
}; };
bool widget::ListFileSystem::onItemEvent(int32_t _IdInput, bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
enum ewol::keyEvent::status _typeEvent, enum ewol::keyEvent::status _typeEvent,
int32_t _colomn, int32_t _colomn,
int32_t _raw, int32_t _raw,
float _x, float _x,
float _y) { float _y) {
int32_t offset = 0; int32_t offset = 0;
if (true == m_showFolder) { if (true == m_showFolder) {
offset = 2; offset = 2;

View File

@ -17,42 +17,44 @@ extern const char * const ewolEventFSFileValidate;
extern const char * const ewolEventFSFolderSelect; extern const char * const ewolEventFSFolderSelect;
extern const char * const ewolEventFSFolderValidate; extern const char * const ewolEventFSFolderValidate;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class ListFileSystem : public widget::List { */
private: class ListFileSystem : public widget::List {
std::vector<etk::FSNode *> m_list; private:
std::string m_folder; std::vector<etk::FSNode *> m_list;
int32_t m_selectedLine; std::string m_folder;
bool m_showFile; int32_t m_selectedLine;
bool m_showTemporaryFile; bool m_showFile;
bool m_showFolder; bool m_showTemporaryFile;
bool m_showHidden; bool m_showFolder;
public: bool m_showHidden;
ListFileSystem(void); public:
~ListFileSystem(void); ListFileSystem(void);
// Derived function ~ListFileSystem(void);
virtual etk::Color<> getBasicBG(void); // Derived function
uint32_t getNuberOfColomn(void); virtual etk::Color<> getBasicBG(void);
bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg); uint32_t getNuberOfColomn(void);
uint32_t getNuberOfRaw(void); bool getTitle(int32_t _colomn, std::string& _myTitle, etk::Color<>& _fg, etk::Color<>& _bg);
bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg); uint32_t getNuberOfRaw(void);
bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y); bool getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg);
public: bool onItemEvent(int32_t _IdInput, enum ewol::keyEvent::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y);
// extern API : public:
void setFolder(std::string _newFolder); // extern API :
std::string getFolder(void); void setFolder(std::string _newFolder);
// select the specific file std::string getFolder(void);
void setSelect(std::string _data); // select the specific file
std::string getSelect(void); void setSelect(std::string _data);
// regenerate the view .... std::string getSelect(void);
void regenerateView(void); // regenerate the view ....
void setShowFiles(bool _state); void regenerateView(void);
void setShowFolder(bool _state); void setShowFiles(bool _state);
void setShowHiddenFiles(bool _state); void setShowFolder(bool _state);
void setShowTemporaryFiles(bool _state); void setShowHiddenFiles(bool _state);
void setShowTemporaryFiles(bool _state);
};
}; };
}; };

View File

@ -18,35 +18,35 @@
#undef __class__ #undef __class__
#define __class__ "Menu" #define __class__ "Menu"
widget::Menu::Menu(void) { ewol::widget::Menu::Menu(void) {
addObjectType("widget::Menu"); addObjectType("ewol::widget::Menu");
m_staticId = 0; m_staticId = 0;
m_widgetContextMenu = NULL; m_widgetContextMenu = NULL;
} }
widget::Menu::~Menu(void) { ewol::widget::Menu::~Menu(void) {
clear(); clear();
} }
void widget::Menu::subWidgetRemoveAll(void) { void ewol::widget::Menu::subWidgetRemoveAll(void) {
clear(); clear();
widget::Sizer::subWidgetRemoveAll(); widget::Sizer::subWidgetRemoveAll();
} }
int32_t widget::Menu::subWidgetAdd(ewol::Widget* _newWidget) { int32_t ewol::widget::Menu::subWidgetAdd(ewol::Widget* _newWidget) {
EWOL_ERROR("Not availlable"); EWOL_ERROR("Not availlable");
return -1; return -1;
} }
void widget::Menu::subWidgetRemove(ewol::Widget* _newWidget) { void ewol::widget::Menu::subWidgetRemove(ewol::Widget* _newWidget) {
EWOL_ERROR("Not availlable"); EWOL_ERROR("Not availlable");
} }
void widget::Menu::subWidgetUnLink(ewol::Widget* _newWidget) { void ewol::widget::Menu::subWidgetUnLink(ewol::Widget* _newWidget) {
EWOL_ERROR("Not availlable"); EWOL_ERROR("Not availlable");
} }
void widget::Menu::clear(void) { void ewol::widget::Menu::clear(void) {
for (size_t iii=0; iii < m_listElement.size(); iii++) { for (size_t iii=0; iii < m_listElement.size(); iii++) {
if (m_listElement[iii] != NULL) { if (m_listElement[iii] != NULL) {
delete(m_listElement[iii]); delete(m_listElement[iii]);
@ -56,19 +56,19 @@ void widget::Menu::clear(void) {
m_listElement.clear(); m_listElement.clear();
} }
int32_t widget::Menu::addTitle(std::string _label, int32_t ewol::widget::Menu::addTitle(std::string _label,
std::string _image, std::string _image,
const char * _generateEvent, const char * _generateEvent,
const std::string _message) { const std::string _message) {
return add(-1, _label, _image, _generateEvent, _message); return add(-1, _label, _image, _generateEvent, _message);
} }
int32_t widget::Menu::add(int32_t _parent, int32_t ewol::widget::Menu::add(int32_t _parent,
std::string _label, std::string _label,
std::string _image, std::string _image,
const char *_generateEvent, const char *_generateEvent,
const std::string _message) { const std::string _message) {
widget::MenuElement *tmpObject = new widget::MenuElement(); ewol::widget::MenuElement *tmpObject = new ewol::widget::MenuElement();
if (NULL == tmpObject) { if (NULL == tmpObject) {
EWOL_ERROR("Allocation problem"); EWOL_ERROR("Allocation problem");
return -1; return -1;
@ -110,12 +110,12 @@ int32_t widget::Menu::add(int32_t _parent,
return tmpObject->m_localId; return tmpObject->m_localId;
} }
void widget::Menu::addSpacer(void) { void ewol::widget::Menu::addSpacer(void) {
EWOL_TODO("NOT now..."); EWOL_TODO("NOT now...");
} }
void widget::Menu::onReceiveMessage(const ewol::EMessage& _msg) { void ewol::widget::Menu::onReceiveMessage(const ewol::EMessage& _msg) {
/* /*
if (true == ewol::sizer::onReceiveMessage(_msg) { if (true == ewol::sizer::onReceiveMessage(_msg) {
return true; return true;
@ -251,7 +251,7 @@ void widget::Menu::onReceiveMessage(const ewol::EMessage& _msg) {
} }
void widget::Menu::onObjectRemove(ewol::EObject * _removeObject) { void ewol::widget::Menu::onObjectRemove(ewol::EObject * _removeObject) {
widget::Sizer::onObjectRemove(_removeObject); widget::Sizer::onObjectRemove(_removeObject);
if (m_widgetContextMenu == _removeObject) { if (m_widgetContextMenu == _removeObject) {
m_widgetContextMenu = NULL; m_widgetContextMenu = NULL;

View File

@ -16,42 +16,44 @@
#include <ewol/widget/Sizer.h> #include <ewol/widget/Sizer.h>
#include <ewol/widget/ContextMenu.h> #include <ewol/widget/ContextMenu.h>
namespace widget { namespace ewol {
class MenuElement { namespace widget {
public : class MenuElement {
MenuElement(void) : m_widgetPointer(NULL) { }; public :
int32_t m_localId; MenuElement(void) : m_widgetPointer(NULL) { };
int32_t m_parentId; int32_t m_localId;
ewol::EObject* m_widgetPointer; int32_t m_parentId;
std::string m_label; ewol::EObject* m_widgetPointer;
std::string m_image; std::string m_label;
const char *m_generateEvent; std::string m_image;
std::string m_message; const char *m_generateEvent;
}; std::string m_message;
/** };
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Menu :public widget::Sizer { */
public: class Menu :public widget::Sizer {
Menu(void); public:
virtual ~Menu(void); Menu(void);
private: virtual ~Menu(void);
virtual void subWidgetRemoveAll(void); private:
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget); virtual void subWidgetRemoveAll(void);
virtual void subWidgetRemove(ewol::Widget* _newWidget); virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::Widget* _newWidget); virtual void subWidgetRemove(ewol::Widget* _newWidget);
private: virtual void subWidgetUnLink(ewol::Widget* _newWidget);
std::vector<widget::MenuElement*> m_listElement; private:
int32_t m_staticId; // unique ID for every element of the menu ... std::vector<widget::MenuElement*> m_listElement;
widget::ContextMenu* m_widgetContextMenu; int32_t m_staticId; // unique ID for every element of the menu ...
public: widget::ContextMenu* m_widgetContextMenu;
void clear(void); public:
int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = ""); void clear(void);
int32_t add(int32_t parent, std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = ""); int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
void addSpacer(void); int32_t add(int32_t parent, std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
// Derived function void addSpacer(void);
virtual void onReceiveMessage(const ewol::EMessage& _msg); // Derived function
virtual void onObjectRemove(ewol::EObject * _removeObject); virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
};
}; };
}; };

View File

@ -18,14 +18,14 @@ extern const char * const ewolEventMeshPressed = "ewol-mesh-Pressed";
widget::Mesh::Mesh(const std::string& _filename) : ewol::widget::Mesh::Mesh(const std::string& _filename) :
m_meshName(_filename), m_meshName(_filename),
m_object(NULL), m_object(NULL),
m_position(0,0,0), m_position(0,0,0),
m_angle(0,0,0), m_angle(0,0,0),
m_angleSpeed(0,0,0), m_angleSpeed(0,0,0),
m_cameraDistance(10.0) { m_cameraDistance(10.0) {
addObjectType("widget::Mesh"); addObjectType("ewol::widget::Mesh");
addEventId(ewolEventMeshPressed); addEventId(ewolEventMeshPressed);
// Limit event at 1: // Limit event at 1:
setMouseLimit(1); setMouseLimit(1);
@ -37,11 +37,11 @@ widget::Mesh::Mesh(const std::string& _filename) :
} }
} }
widget::Mesh::~Mesh(void) { ewol::widget::Mesh::~Mesh(void) {
ewol::Mesh::release(m_object); ewol::Mesh::release(m_object);
} }
void widget::Mesh::onDraw(void) { void ewol::widget::Mesh::onDraw(void) {
mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance)) mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance))
* etk::matTranslate(m_position) * etk::matTranslate(m_position)
* etk::matRotate(vec3(1,0,0),m_angle.x()) * etk::matRotate(vec3(1,0,0),m_angle.x())
@ -52,7 +52,7 @@ void widget::Mesh::onDraw(void) {
} }
} }
void widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::openGL::push(); ewol::openGL::push();
// here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left // here we invert the reference of the standard openGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x(), glViewport( m_origin.x(),
@ -71,18 +71,18 @@ void widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::openGL::pop(); ewol::openGL::pop();
} }
void widget::Mesh::onRegenerateDisplay(void) { void ewol::widget::Mesh::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
} }
} }
void widget::Mesh::periodicCall(const ewol::EventTime& _event) { void ewol::widget::Mesh::periodicCall(const ewol::EventTime& _event) {
m_angle += m_angleSpeed*_event.getDeltaCall(); m_angle += m_angleSpeed*_event.getDeltaCall();
markToRedraw(); markToRedraw();
} }
bool widget::Mesh::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on BT ..."); //EWOL_DEBUG("Event on BT ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {
if(ewol::keyEvent::statusSingle == _event.getStatus()) { if(ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -93,7 +93,7 @@ bool widget::Mesh::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
void widget::Mesh::setFile(const std::string& _filename) { void ewol::widget::Mesh::setFile(const std::string& _filename) {
if( _filename!="" if( _filename!=""
&& m_meshName != _filename ) { && m_meshName != _filename ) {
ewol::Mesh::release(m_object); ewol::Mesh::release(m_object);
@ -106,17 +106,17 @@ void widget::Mesh::setFile(const std::string& _filename) {
markToRedraw(); markToRedraw();
} }
void widget::Mesh::setPosition(const vec3& _pos) { void ewol::widget::Mesh::setPosition(const vec3& _pos) {
m_position = _pos; m_position = _pos;
markToRedraw(); markToRedraw();
} }
void widget::Mesh::setAngle(const vec3& _angle) { void ewol::widget::Mesh::setAngle(const vec3& _angle) {
m_angle = _angle; m_angle = _angle;
markToRedraw(); markToRedraw();
} }
void widget::Mesh::setAngleSpeed(const vec3& _speed) { void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
if (_speed!=vec3(0,0,0)) { if (_speed!=vec3(0,0,0)) {
periodicCallEnable(); periodicCallEnable();
} else { } else {
@ -126,7 +126,7 @@ void widget::Mesh::setAngleSpeed(const vec3& _speed) {
markToRedraw(); markToRedraw();
} }
void widget::Mesh::setDistance(float _distance) void ewol::widget::Mesh::setDistance(float _distance)
{ {
m_cameraDistance = _distance; m_cameraDistance = _distance;
markToRedraw(); markToRedraw();

View File

@ -16,55 +16,57 @@
extern const char * const ewolEventMeshPressed; extern const char * const ewolEventMeshPressed;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Mesh :public ewol::Widget { */
private: class Mesh :public ewol::Widget {
// mesh name : private:
std::string m_meshName; // mesh name :
ewol::Mesh* m_object; std::string m_meshName;
// mesh display properties: ewol::Mesh* m_object;
vec3 m_position; // mesh display properties:
vec3 m_angle; vec3 m_position;
vec3 m_angleSpeed; vec3 m_angle;
float m_cameraDistance; vec3 m_angleSpeed;
public: float m_cameraDistance;
Mesh(const std::string& filename); // automatic considering in the appl Data older public:
virtual ~Mesh(void); Mesh(const std::string& filename); // automatic considering in the appl Data older
public: // Derived function virtual ~Mesh(void);
virtual void onRegenerateDisplay(void); public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& displayProp); virtual void onRegenerateDisplay(void);
virtual void onDraw(void); virtual void systemDraw(const ewol::DrawProperty& displayProp);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onDraw(void);
virtual void periodicCall(const ewol::EventTime& _event); virtual bool onEventInput(const ewol::EventInput& _event);
public: virtual void periodicCall(const ewol::EventTime& _event);
/** public:
* @brief set a mesh name file /**
* @param[in] filename Name of the new mesh * @brief set a mesh name file
*/ * @param[in] filename Name of the new mesh
void setFile(const std::string& filename); */
/** void setFile(const std::string& filename);
* @brief set the mesh position /**
* @param[in] pos The new position of the mesh * @brief set the mesh position
*/ * @param[in] pos The new position of the mesh
void setPosition(const vec3& pos); */
/** void setPosition(const vec3& pos);
* @brief set the mesh angle of view /**
* @param[in] angle view angle of the mesh * @brief set the mesh angle of view
*/ * @param[in] angle view angle of the mesh
void setAngle(const vec3& angle); */
/** void setAngle(const vec3& angle);
* @brief set the mesh angle speed /**
* @param[in] spped radian speed of the mesh * @brief set the mesh angle speed
*/ * @param[in] spped radian speed of the mesh
void setAngleSpeed(const vec3& speed); */
/** void setAngleSpeed(const vec3& speed);
* @brief set the camera distance of the mesh /**
* @param[in] dist Diatance of the mesh * @brief set the camera distance of the mesh
*/ * @param[in] dist Diatance of the mesh
void setDistance(float distance); */
void setDistance(float distance);
};
}; };
}; };

View File

@ -15,26 +15,26 @@
#undef __class__ #undef __class__
#define __class__ "PopUp" #define __class__ "PopUp"
const char* const widget::PopUp::configShaper="shaper"; const char* const ewol::widget::PopUp::configShaper="shaper";
const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove"; const char* const ewol::widget::PopUp::configRemoveOnExternClick="out-click-remove";
const char* const widget::PopUp::configAnimation="animation"; const char* const ewol::widget::PopUp::configAnimation="animation";
const char* const widget::PopUp::configLockExpand="lock"; const char* const ewol::widget::PopUp::configLockExpand="lock";
static const char* annimationIncrease = "increase"; static const char* annimationIncrease = "increase";
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::PopUp(); return new ewol::widget::PopUp();
} }
void widget::PopUp::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::PopUp::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::PopUp::PopUp(const std::string& _shaperName) : ewol::widget::PopUp::PopUp(const std::string& _shaperName) :
m_shaper(_shaperName), m_shaper(_shaperName),
m_lockExpand(true,true), m_lockExpand(true,true),
m_closeOutEvent(false) { m_closeOutEvent(false) {
addObjectType("widget::PopUp"); addObjectType("ewol::widget::PopUp");
m_userExpand.setValue(false, false); m_userExpand.setValue(false, false);
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent)); setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
registerConfig(configShaper, "string", NULL, "The shaper properties"); registerConfig(configShaper, "string", NULL, "The shaper properties");
@ -46,11 +46,11 @@ widget::PopUp::PopUp(const std::string& _shaperName) :
addAnnimationType(ewol::Widget::annimationModeEnableAdd, annimationIncrease); addAnnimationType(ewol::Widget::annimationModeEnableAdd, annimationIncrease);
} }
widget::PopUp::~PopUp(void) { ewol::widget::PopUp::~PopUp(void) {
} }
void widget::PopUp::lockExpand(const bvec2& _lockExpand) { void ewol::widget::PopUp::lockExpand(const bvec2& _lockExpand) {
if (_lockExpand != m_lockExpand) { if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand; m_lockExpand = _lockExpand;
markToRedraw(); markToRedraw();
@ -58,12 +58,12 @@ void widget::PopUp::lockExpand(const bvec2& _lockExpand) {
} }
} }
void widget::PopUp::setShaperName(const std::string& _shaperName) { void ewol::widget::PopUp::setShaperName(const std::string& _shaperName) {
m_shaper.setSource(_shaperName); m_shaper.setSource(_shaperName);
markToRedraw(); markToRedraw();
} }
void widget::PopUp::calculateSize(const vec2& _available) { void ewol::widget::PopUp::calculateSize(const vec2& _available) {
ewol::Widget::calculateSize(_available); ewol::Widget::calculateSize(_available);
if (NULL != m_subWidget) { if (NULL != m_subWidget) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
@ -97,7 +97,7 @@ void widget::PopUp::calculateSize(const vec2& _available) {
markToRedraw(); markToRedraw();
} }
void widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){ if (true == m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
@ -113,11 +113,11 @@ void widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
void widget::PopUp::onDraw(void) { void ewol::widget::PopUp::onDraw(void) {
m_shaper.draw(); m_shaper.draw();
} }
void widget::PopUp::onRegenerateDisplay(void) { void ewol::widget::PopUp::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
m_shaper.clear(); m_shaper.clear();
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
@ -147,7 +147,7 @@ void widget::PopUp::onRegenerateDisplay(void) {
} }
} }
ewol::Widget* widget::PopUp::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::PopUp::getWidgetAtPos(const vec2& _pos) {
ewol::Widget* val = widget::Container::getWidgetAtPos(_pos); ewol::Widget* val = widget::Container::getWidgetAtPos(_pos);
if (NULL != val) { if (NULL != val) {
return val; return val;
@ -155,7 +155,7 @@ ewol::Widget* widget::PopUp::getWidgetAtPos(const vec2& _pos) {
return this; return this;
} }
bool widget::PopUp::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::PopUp::onSetConfig(const ewol::EConfig& _conf) {
if (true == widget::Container::onSetConfig(_conf)) { if (true == widget::Container::onSetConfig(_conf)) {
return true; return true;
} }
@ -174,7 +174,7 @@ bool widget::PopUp::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::PopUp::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::PopUp::onGetConfig(const char* _config, std::string& _result) const {
if (true == widget::Container::onGetConfig(_config, _result)) { if (true == widget::Container::onGetConfig(_config, _result)) {
return true; return true;
} }
@ -197,7 +197,7 @@ bool widget::PopUp::onGetConfig(const char* _config, std::string& _result) const
return false; return false;
} }
bool widget::PopUp::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::PopUp::onEventInput(const ewol::EventInput& _event) {
if (0 != _event.getId()) { if (0 != _event.getId()) {
if (true == m_closeOutEvent) { if (true == m_closeOutEvent) {
vec2 padding = m_shaper.getPadding(); vec2 padding = m_shaper.getPadding();
@ -224,7 +224,7 @@ bool widget::PopUp::onEventInput(const ewol::EventInput& _event) {
} }
bool widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _mode) { bool ewol::widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _mode) {
if (m_annimationType[_mode] != annimationIncrease) { if (m_annimationType[_mode] != annimationIncrease) {
return false; return false;
} }
@ -235,11 +235,11 @@ bool widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _mode) {
return false; return false;
} }
void widget::PopUp::onStopAnnimation(void) { void ewol::widget::PopUp::onStopAnnimation(void) {
periodicCallDisable(); periodicCallDisable();
} }
void widget::PopUp::periodicCall(const ewol::EventTime& _event) { void ewol::widget::PopUp::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) { if (false == m_shaper.periodicCall(_event) ) {
stopAnnimation(); stopAnnimation();
} }

View File

@ -17,76 +17,77 @@
#include <ewol/compositing/Shaper.h> #include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class PopUp : public widget::Container { */
public: class PopUp : public widget::Container {
static void init(ewol::WidgetManager& _widgetManager); public:
// Config list of properties static void init(ewol::WidgetManager& _widgetManager);
static const char* const configShaper; // Config list of properties
static const char* const configRemoveOnExternClick; static const char* const configShaper;
static const char* const configAnimation; static const char* const configRemoveOnExternClick;
static const char* const configLockExpand; static const char* const configAnimation;
private: static const char* const configLockExpand;
ewol::Shaper m_shaper; //!< Compositing theme. private:
public: ewol::Shaper m_shaper; //!< Compositing theme.
/** public:
* @brief Constructor /**
* @param[in] _shaperName Shaper file properties * @brief Constructor
*/ * @param[in] _shaperName Shaper file properties
PopUp(const std::string& _shaperName="THEME:GUI:widgetPopUp.conf"); */
/** PopUp(const std::string& _shaperName="THEME:GUI:widgetPopUp.conf");
* @brief Destructor /**
*/ * @brief Destructor
virtual ~PopUp(void); */
/** virtual ~PopUp(void);
* @brief set the shaper name (use the contructer one this permit to not noad unused shaper) /**
* @param[in] _shaperName The new shaper filename * @brief set the shaper name (use the contructer one this permit to not noad unused shaper)
*/ * @param[in] _shaperName The new shaper filename
void setShaperName(const std::string& _shaperName); */
protected: void setShaperName(const std::string& _shaperName);
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget protected:
public: bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
/** public:
* @brief Limit the expend properties to the current widget (no contamination) /**
* @param[in] _lockExpend Lock mode of the expend properties * @brief Limit the expend properties to the current widget (no contamination)
*/ * @param[in] _lockExpend Lock mode of the expend properties
void lockExpand(const bvec2& _lockExpand); */
private: void lockExpand(const bvec2& _lockExpand);
bool m_closeOutEvent; //!< ratio progression of a sliding private:
public: bool m_closeOutEvent; //!< ratio progression of a sliding
/** public:
* @brief Request the Auto-remove when the event input is set outside the widget /**
* @param[in] _state New status * @brief Request the Auto-remove when the event input is set outside the widget
*/ * @param[in] _state New status
void setRemoveOnExternClick(bool _state) { */
m_closeOutEvent = _state; void setRemoveOnExternClick(bool _state) {
}; m_closeOutEvent = _state;
/** };
* @brief get the status of the request the Auto-remove when the event input is set outside the widget. /**
* @return the status of the removing * @brief get the status of the request the Auto-remove when the event input is set outside the widget.
*/ * @return the status of the removing
bool getRemoveOnExternClick(void) const { */
return m_closeOutEvent; bool getRemoveOnExternClick(void) const {
}; return m_closeOutEvent;
protected: // Derived function };
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
public: // Derived function virtual bool onGetConfig(const char* _config, std::string& _result) const;
virtual void periodicCall(const ewol::EventTime& _event); public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void periodicCall(const ewol::EventTime& _event);
virtual void onRegenerateDisplay(void); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void calculateSize(const vec2& _available); virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void calculateSize(const vec2& _available);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos); virtual bool onEventInput(const ewol::EventInput& _event);
protected: virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual bool onStartAnnimation(enum ewol::Widget::annimationMode _mode); protected:
virtual void onStopAnnimation(void); virtual bool onStartAnnimation(enum ewol::Widget::annimationMode _mode);
virtual void onStopAnnimation(void);
};
}; };
}; };
#endif #endif

View File

@ -15,22 +15,22 @@
#define __class__ "ProgressBar" #define __class__ "ProgressBar"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::ProgressBar(); return new ewol::widget::ProgressBar();
} }
void widget::ProgressBar::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::ProgressBar::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
const char* const widget::ProgressBar::configColorBg = "color-bg"; const char* const ewol::widget::ProgressBar::configColorBg = "color-bg";
const char* const widget::ProgressBar::configColorFgOn = "color-on"; const char* const ewol::widget::ProgressBar::configColorFgOn = "color-on";
const char* const widget::ProgressBar::configColorFgOff = "color-off"; const char* const ewol::widget::ProgressBar::configColorFgOff = "color-off";
const char* const widget::ProgressBar::configValue = "value"; const char* const ewol::widget::ProgressBar::configValue = "value";
const int32_t dotRadius = 6; const int32_t dotRadius = 6;
widget::ProgressBar::ProgressBar(void) { ewol::widget::ProgressBar::ProgressBar(void) {
addObjectType("widget::ProgressBar"); addObjectType("ewol::widget::ProgressBar");
m_value = 0.0; m_value = 0.0;
m_textColorFg = etk::color::black; m_textColorFg = etk::color::black;
@ -47,27 +47,27 @@ widget::ProgressBar::ProgressBar(void) {
} }
widget::ProgressBar::~ProgressBar(void) { ewol::widget::ProgressBar::~ProgressBar(void) {
} }
void widget::ProgressBar::calculateMinMaxSize(void) { void ewol::widget::ProgressBar::calculateMinMaxSize(void) {
vec2 tmpMin = m_userMinSize.getPixel(); vec2 tmpMin = m_userMinSize.getPixel();
m_minSize.setValue( etk_max(tmpMin.x(), 40), m_minSize.setValue( etk_max(tmpMin.x(), 40),
etk_max(tmpMin.y(), dotRadius*2) ); etk_max(tmpMin.y(), dotRadius*2) );
markToRedraw(); markToRedraw();
} }
void widget::ProgressBar::setValue(float _val) { void ewol::widget::ProgressBar::setValue(float _val) {
m_value = etk_avg(0, _val, 1); m_value = etk_avg(0, _val, 1);
markToRedraw(); markToRedraw();
} }
void widget::ProgressBar::onDraw(void) { void ewol::widget::ProgressBar::onDraw(void) {
m_draw.draw(); m_draw.draw();
} }
void widget::ProgressBar::onRegenerateDisplay(void) { void ewol::widget::ProgressBar::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (true == needRedraw()) {
// clean the object list ... // clean the object list ...
m_draw.clear(); m_draw.clear();
@ -93,7 +93,7 @@ void widget::ProgressBar::onRegenerateDisplay(void) {
bool widget::ProgressBar::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::ProgressBar::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) { if (true == ewol::Widget::onSetConfig(_conf)) {
return true; return true;
} }
@ -116,7 +116,7 @@ bool widget::ProgressBar::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::ProgressBar::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::ProgressBar::onGetConfig(const char* _config, std::string& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) { if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -16,44 +16,45 @@
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class ProgressBar : public ewol::Widget { */
public: class ProgressBar : public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
// Config list of properties static void init(ewol::WidgetManager& _widgetManager);
static const char* const configColorBg; // Config list of properties
static const char* const configColorFgOn; static const char* const configColorBg;
static const char* const configColorFgOff; static const char* const configColorFgOn;
static const char* const configValue; static const char* const configColorFgOff;
private: static const char* const configValue;
ewol::Drawing m_draw; // basic drawing element private:
public: ewol::Drawing m_draw; // basic drawing element
ProgressBar(void); public:
virtual ~ProgressBar(void); ProgressBar(void);
void setValue(float _val); virtual ~ProgressBar(void);
float getValue(void) const { void setValue(float _val);
return m_value; float getValue(void) const {
}; return m_value;
void setColor(etk::Color<> _newColor) { };
m_textColorFg = _newColor; void setColor(etk::Color<> _newColor) {
}; m_textColorFg = _newColor;
private: };
float m_value; //!< % used private:
etk::Color<> m_textColorFg; //!< forder bar color float m_value; //!< % used
etk::Color<> m_textColorBgOn; //!< bar color enable etk::Color<> m_textColorFg; //!< forder bar color
etk::Color<> m_textColorBgOff; //!< bar color disable etk::Color<> m_textColorBgOn; //!< bar color enable
protected: // Derived function etk::Color<> m_textColorBgOff; //!< bar color disable
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
public: // Derived function virtual bool onGetConfig(const char* _config, std::string& _result) const;
virtual void onRegenerateDisplay(void); public: // Derived function
virtual void calculateMinMaxSize(void); virtual void onRegenerateDisplay(void);
virtual void calculateMinMaxSize(void);
};
}; };
}; };
#endif #endif

View File

@ -15,38 +15,38 @@
#define __class__ "Scroll" #define __class__ "Scroll"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Scroll(); return new ewol::widget::Scroll();
} }
void widget::Scroll::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Scroll::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
const char* const widget::Scroll::configLimit = "limit"; const char* const ewol::widget::Scroll::configLimit = "limit";
widget::Scroll::Scroll(void) : ewol::widget::Scroll::Scroll(void) :
m_limit(0.15,0.5), m_limit(0.15,0.5),
m_pixelScrolling(20), m_pixelScrolling(20),
m_highSpeedStartPos(0,0), m_highSpeedStartPos(0,0),
m_highSpeedMode(speedModeDisable), m_highSpeedMode(speedModeDisable),
m_highSpeedButton(-1), m_highSpeedButton(-1),
m_highSpeedType(ewol::keyEvent::typeUnknow) { m_highSpeedType(ewol::keyEvent::typeUnknow) {
addObjectType("widget::Scroll"); addObjectType("ewol::widget::Scroll");
registerConfig(configLimit, "vec2", NULL, "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end"); registerConfig(configLimit, "vec2", NULL, "Limit the scroll maximum position [0..1]% represent the free space in the scoll when arrive at the end");
} }
widget::Scroll::~Scroll(void) { ewol::widget::Scroll::~Scroll(void) {
} }
void widget::Scroll::setLimit(const vec2& _limit) { void ewol::widget::Scroll::setLimit(const vec2& _limit) {
m_limit = _limit; m_limit = _limit;
markToRedraw(); markToRedraw();
} }
#define SCROLL_BAR_SPACE (15) #define SCROLL_BAR_SPACE (15)
void widget::Scroll::calculateMinMaxSize(void) { void ewol::widget::Scroll::calculateMinMaxSize(void) {
// call main class !! and not containter class ... // call main class !! and not containter class ...
ewol::Widget::calculateMinMaxSize(); ewol::Widget::calculateMinMaxSize();
// call sub classes // call sub classes
@ -55,7 +55,7 @@ void widget::Scroll::calculateMinMaxSize(void) {
} }
} }
void widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) {
if (m_hide == true) { if (m_hide == true) {
return; return;
} }
@ -67,11 +67,11 @@ void widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::Widget::systemDraw(_displayProp); ewol::Widget::systemDraw(_displayProp);
} }
void widget::Scroll::onDraw(void) { void ewol::widget::Scroll::onDraw(void) {
m_draw.draw(); m_draw.draw();
} }
void widget::Scroll::onRegenerateDisplay(void) { void ewol::widget::Scroll::onRegenerateDisplay(void) {
// call upper class // call upper class
widget::Container::onRegenerateDisplay(); widget::Container::onRegenerateDisplay();
if (true == needRedraw()) { if (true == needRedraw()) {
@ -115,7 +115,7 @@ void widget::Scroll::onRegenerateDisplay(void) {
} }
} }
bool widget::Scroll::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Scroll::onEventInput(const ewol::EventInput& _event) {
vec2 relativePos = relativePosition(_event.getPos()); vec2 relativePos = relativePosition(_event.getPos());
vec2 scrollOffset(0,0); vec2 scrollOffset(0,0);
vec2 scrollSize(0,0); vec2 scrollSize(0,0);
@ -332,7 +332,7 @@ bool widget::Scroll::onEventInput(const ewol::EventInput& _event) {
return false; return false;
} }
ewol::Widget* widget::Scroll::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::Scroll::getWidgetAtPos(const vec2& _pos) {
ewol::Widget* tmpWidget = widget::Container::getWidgetAtPos(_pos); ewol::Widget* tmpWidget = widget::Container::getWidgetAtPos(_pos);
if (NULL != tmpWidget) { if (NULL != tmpWidget) {
return tmpWidget; return tmpWidget;
@ -340,7 +340,7 @@ ewol::Widget* widget::Scroll::getWidgetAtPos(const vec2& _pos) {
return this; return this;
} }
bool widget::Scroll::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::Scroll::onSetConfig(const ewol::EConfig& _conf) {
if (true == widget::Container::onSetConfig(_conf)) { if (true == widget::Container::onSetConfig(_conf)) {
return true; return true;
} }
@ -351,7 +351,7 @@ bool widget::Scroll::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::Scroll::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::Scroll::onGetConfig(const char* _config, std::string& _result) const {
if (true == widget::Container::onGetConfig(_config, _result)) { if (true == widget::Container::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -16,60 +16,62 @@
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Scroll : public widget::Container { */
public: class Scroll : public widget::Container {
enum highSpeedMode { public:
speedModeDisable, enum highSpeedMode {
speedModeInit, speedModeDisable,
speedModeEnableFinger, // Specific for touchpad speedModeInit,
speedModeEnableHorizontal, // Specific for mouse speedModeEnableFinger, // Specific for touchpad
speedModeEnableVertical, // Specific for mouse speedModeEnableHorizontal, // Specific for mouse
speedModeGrepEndEvent speedModeEnableVertical, // Specific for mouse
}; speedModeGrepEndEvent
public: };
// Cinfig parameter list: public:
static const char* const configLimit; // Cinfig parameter list:
public: static const char* const configLimit;
static void init(ewol::WidgetManager& _widgetManager); public:
private: static void init(ewol::WidgetManager& _widgetManager);
ewol::Drawing m_draw; // TODO : change in shaper ... == > better for annimation and dynamic display ... private:
protected: ewol::Drawing m_draw; // TODO : change in shaper ... == > better for annimation and dynamic display ...
vec2 m_limit; protected:
private: vec2 m_limit;
float m_pixelScrolling; private:
vec2 m_highSpeedStartPos; float m_pixelScrolling;
enum highSpeedMode m_highSpeedMode; vec2 m_highSpeedStartPos;
int32_t m_highSpeedButton; enum highSpeedMode m_highSpeedMode;
enum ewol::keyEvent::type m_highSpeedType; int32_t m_highSpeedButton;
public: enum ewol::keyEvent::type m_highSpeedType;
Scroll(void); public:
virtual ~Scroll(void); Scroll(void);
/** virtual ~Scroll(void);
* @brief set the limit of scrolling /**
* @note This permit to scoll element upper the end of the display * @brief set the limit of scrolling
* @param[in] _limit scrolling limit [0..1] (represent a pourcent) * @note This permit to scoll element upper the end of the display
*/ * @param[in] _limit scrolling limit [0..1] (represent a pourcent)
void setLimit(const vec2& _limit); */
/** void setLimit(const vec2& _limit);
* @brief get the limit of scrolling /**
* @return scrolling limit * @brief get the limit of scrolling
*/ * @return scrolling limit
const vec2& getLimit(void) const { return m_limit; }; */
const vec2& getLimit(void) const { return m_limit; };
public: // Derived function
void calculateMinMaxSize(void); public: // Derived function
virtual void onRegenerateDisplay(void); void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual bool onEventInput(const ewol::EventInput& _event);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
protected: // Derived function virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual void onDraw(void); protected: // Derived function
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
}; };
}; };

View File

@ -14,48 +14,48 @@
#define __class__ "Sizer" #define __class__ "Sizer"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Sizer(); return new ewol::widget::Sizer();
} }
void widget::Sizer::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Sizer::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::Sizer::Sizer(enum displayMode _mode): ewol::widget::Sizer::Sizer(enum displayMode _mode):
m_mode(_mode), m_mode(_mode),
m_borderSize(), m_borderSize(),
m_animation(animationNone), m_animation(animationNone),
m_animationTime(0) { m_animationTime(0) {
addObjectType("widget::Sizer"); addObjectType("ewol::widget::Sizer");
} }
widget::Sizer::~Sizer(void) { ewol::widget::Sizer::~Sizer(void) {
// disable annimation to remore "remove" error // disable annimation to remore "remove" error
m_animation = animationNone; m_animation = animationNone;
m_animationTime = 0; m_animationTime = 0;
//EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} sizer : destroy (mode=" << (m_mode == widget::sizer::modeVert?"Vert":"Hori") << ")"); //EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} sizer : destroy (mode=" << (m_mode == ewol::widget::Sizer::modeVert?"Vert":"Hori") << ")");
} }
void widget::Sizer::setBorderSize(const ewol::Dimension& _newBorderSize) { void ewol::widget::Sizer::setBorderSize(const ewol::Dimension& _newBorderSize) {
m_borderSize = _newBorderSize; m_borderSize = _newBorderSize;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
void widget::Sizer::setMode(enum displayMode _mode) { void ewol::widget::Sizer::setMode(enum displayMode _mode) {
m_mode = _mode; m_mode = _mode;
markToRedraw(); markToRedraw();
requestUpdateSize(); requestUpdateSize();
} }
enum widget::Sizer::displayMode widget::Sizer::getMode(void) { enum ewol::widget::Sizer::displayMode ewol::widget::Sizer::getMode(void) {
return m_mode; return m_mode;
} }
void widget::Sizer::calculateSize(const vec2& _availlable) { void ewol::widget::Sizer::calculateSize(const vec2& _availlable) {
ewol::Widget::calculateSize(_availlable); ewol::Widget::calculateSize(_availlable);
vec2 tmpBorderSize = m_borderSize.getPixel(); vec2 tmpBorderSize = m_borderSize.getPixel();
//EWOL_DEBUG("[" << getId() << "] update size : " << _availlable << " nbElement : " << m_subWidget.size() << " borderSize=" << tmpBorderSize << " from border=" << m_borderSize); //EWOL_DEBUG("[" << getId() << "] update size : " << _availlable << " nbElement : " << m_subWidget.size() << " borderSize=" << tmpBorderSize << " from border=" << m_borderSize);
@ -67,7 +67,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) { for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) { if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize(); vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize();
if (m_mode == widget::Sizer::modeVert) { if (m_mode == ewol::widget::Sizer::modeVert) {
unexpandableSize += tmpSize.y(); unexpandableSize += tmpSize.y();
if (false == m_subWidget[iii]->canExpand().y()) { if (false == m_subWidget[iii]->canExpand().y()) {
nbWidgetFixedSize++; nbWidgetFixedSize++;
@ -88,7 +88,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
float sizeToAddAtEveryOne = 0; float sizeToAddAtEveryOne = 0;
// 2 cases : 1 or more can Expand, or all is done ... // 2 cases : 1 or more can Expand, or all is done ...
if (0 != nbWidgetNotFixedSize) { if (0 != nbWidgetNotFixedSize) {
if (m_mode == widget::Sizer::modeVert) { if (m_mode == ewol::widget::Sizer::modeVert) {
sizeToAddAtEveryOne = (m_size.y() - unexpandableSize) / nbWidgetNotFixedSize; sizeToAddAtEveryOne = (m_size.y() - unexpandableSize) / nbWidgetNotFixedSize;
} else { } else {
sizeToAddAtEveryOne = (m_size.x() - unexpandableSize) / nbWidgetNotFixedSize; sizeToAddAtEveryOne = (m_size.x() - unexpandableSize) / nbWidgetNotFixedSize;
@ -105,7 +105,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("[" << getId() << "] set iii=" << iii << " ORIGIN : " << tmpOrigin << " & offset=" << m_offset); //EWOL_DEBUG("[" << getId() << "] set iii=" << iii << " ORIGIN : " << tmpOrigin << " & offset=" << m_offset);
m_subWidget[iii]->setOrigin(vec2ClipInt32(tmpOrigin+m_offset)); m_subWidget[iii]->setOrigin(vec2ClipInt32(tmpOrigin+m_offset));
// Now update his size his size in X and the curent sizer size in Y: // Now update his size his size in X and the curent sizer size in Y:
if (m_mode == widget::Sizer::modeVert) { if (m_mode == ewol::widget::Sizer::modeVert) {
if (true == m_subWidget[iii]->canExpand().y()) { if (true == m_subWidget[iii]->canExpand().y()) {
m_subWidget[iii]->calculateSize(vec2ClipInt32(vec2(m_size.x(), tmpSize.y()+sizeToAddAtEveryOne))); m_subWidget[iii]->calculateSize(vec2ClipInt32(vec2(m_size.x(), tmpSize.y()+sizeToAddAtEveryOne)));
tmpOrigin.setY(tmpOrigin.y() + tmpSize.y()+sizeToAddAtEveryOne); tmpOrigin.setY(tmpOrigin.y() + tmpSize.y()+sizeToAddAtEveryOne);
@ -128,7 +128,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
markToRedraw(); markToRedraw();
} }
void widget::Sizer::calculateMinMaxSize(void) { void ewol::widget::Sizer::calculateMinMaxSize(void) {
//EWOL_DEBUG("[" << getId() << "] update minimum size"); //EWOL_DEBUG("[" << getId() << "] update minimum size");
m_subExpend.setValue(false, false); m_subExpend.setValue(false, false);
m_minSize = m_userMinSize.getPixel(); m_minSize = m_userMinSize.getPixel();
@ -147,7 +147,7 @@ void widget::Sizer::calculateMinMaxSize(void) {
vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize(); vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize();
//EWOL_DEBUG("[" << getId() << "] NewMinSize=" << tmpSize); //EWOL_DEBUG("[" << getId() << "] NewMinSize=" << tmpSize);
//EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} Get minSize[" << iii << "] "<< tmpSize); //EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} Get minSize[" << iii << "] "<< tmpSize);
if (m_mode == widget::Sizer::modeVert) { if (m_mode == ewol::widget::Sizer::modeVert) {
m_minSize.setY(m_minSize.y() + tmpSize.y()); m_minSize.setY(m_minSize.y() + tmpSize.y());
if (tmpSize.x()>m_minSize.x()) { if (tmpSize.x()>m_minSize.x()) {
m_minSize.setX(tmpSize.x()); m_minSize.setX(tmpSize.x());
@ -163,7 +163,7 @@ void widget::Sizer::calculateMinMaxSize(void) {
//EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize); //EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Result min size : " << m_minSize);
} }
bool widget::Sizer::loadXML(exml::Element* _node) { bool ewol::widget::Sizer::loadXML(exml::Element* _node) {
if (NULL == _node) { if (NULL == _node) {
return false; return false;
} }
@ -178,15 +178,15 @@ bool widget::Sizer::loadXML(exml::Element* _node) {
if (tmpAttributeValue.size()!=0) { if (tmpAttributeValue.size()!=0) {
if( compare_no_case(tmpAttributeValue, "vert") == true if( compare_no_case(tmpAttributeValue, "vert") == true
|| compare_no_case(tmpAttributeValue, "vertical") == true) { || compare_no_case(tmpAttributeValue, "vertical") == true) {
m_mode = widget::Sizer::modeVert; m_mode = ewol::widget::Sizer::modeVert;
} else { } else {
m_mode = widget::Sizer::modeHori; m_mode = ewol::widget::Sizer::modeHori;
} }
} }
return true; return true;
} }
int32_t widget::Sizer::subWidgetAdd(ewol::Widget* _newWidget) { int32_t ewol::widget::Sizer::subWidgetAdd(ewol::Widget* _newWidget) {
if (m_animation == animationNone) { if (m_animation == animationNone) {
return widget::ContainerN::subWidgetAdd(_newWidget); return widget::ContainerN::subWidgetAdd(_newWidget);
} }
@ -194,7 +194,7 @@ int32_t widget::Sizer::subWidgetAdd(ewol::Widget* _newWidget) {
return widget::ContainerN::subWidgetAdd(_newWidget); return widget::ContainerN::subWidgetAdd(_newWidget);
} }
int32_t widget::Sizer::subWidgetAddStart(ewol::Widget* _newWidget) { int32_t ewol::widget::Sizer::subWidgetAddStart(ewol::Widget* _newWidget) {
if (m_animation == animationNone) { if (m_animation == animationNone) {
return widget::ContainerN::subWidgetAddStart(_newWidget); return widget::ContainerN::subWidgetAddStart(_newWidget);
} }
@ -202,7 +202,7 @@ int32_t widget::Sizer::subWidgetAddStart(ewol::Widget* _newWidget) {
return widget::ContainerN::subWidgetAddStart(_newWidget); return widget::ContainerN::subWidgetAddStart(_newWidget);
} }
void widget::Sizer::subWidgetRemove(ewol::Widget* _newWidget) { void ewol::widget::Sizer::subWidgetRemove(ewol::Widget* _newWidget) {
if (m_animation == animationNone) { if (m_animation == animationNone) {
widget::ContainerN::subWidgetRemove(_newWidget); widget::ContainerN::subWidgetRemove(_newWidget);
return; return;
@ -211,7 +211,7 @@ void widget::Sizer::subWidgetRemove(ewol::Widget* _newWidget) {
widget::ContainerN::subWidgetRemove(_newWidget); widget::ContainerN::subWidgetRemove(_newWidget);
} }
void widget::Sizer::subWidgetUnLink(ewol::Widget* _newWidget) { void ewol::widget::Sizer::subWidgetUnLink(ewol::Widget* _newWidget) {
if (m_animation == animationNone) { if (m_animation == animationNone) {
widget::ContainerN::subWidgetUnLink(_newWidget); widget::ContainerN::subWidgetUnLink(_newWidget);
return; return;

View File

@ -14,112 +14,113 @@
#include <ewol/widget/ContainerN.h> #include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Sizer : public widget::ContainerN { */
public: class Sizer : public widget::ContainerN {
/** public:
* @brief Main call of recording the widget on the List of "widget named creator" /**
*/ * @brief Main call of recording the widget on the List of "widget named creator"
static void init(ewol::WidgetManager& _widgetManager); */
public: static void init(ewol::WidgetManager& _widgetManager);
enum displayMode { public:
modeVert, //!< Vertical mode enum displayMode {
modeHori, //!< Horizontal mode modeVert, //!< Vertical mode
}; modeHori, //!< Horizontal mode
private: };
enum displayMode m_mode; //!< Methode to display the widget list (vert/hory ...) private:
public: enum displayMode m_mode; //!< Methode to display the widget list (vert/hory ...)
/** public:
* @brief Constructor /**
* @param[in] _mode The mode to display the elements * @brief Constructor
*/ * @param[in] _mode The mode to display the elements
Sizer(enum displayMode _mode=widget::Sizer::modeHori); */
/** Sizer(enum displayMode _mode=widget::Sizer::modeHori);
* @brief Desstructor /**
*/ * @brief Desstructor
virtual ~Sizer(void); */
/** virtual ~Sizer(void);
* @brief set the mode to display elements. /**
* @param[in] _mode The mode to display the elements. * @brief set the mode to display elements.
*/ * @param[in] _mode The mode to display the elements.
void setMode(enum displayMode _mode); */
/** void setMode(enum displayMode _mode);
* @brief get the mode to display elements. /**
* @return The current mode to display the elements. * @brief get the mode to display elements.
*/ * @return The current mode to display the elements.
enum displayMode getMode(void); */
private: enum displayMode getMode(void);
ewol::Dimension m_borderSize; //!< Border size needed for all the display private:
public: ewol::Dimension m_borderSize; //!< Border size needed for all the display
/** public:
* @brief set the current border size of the current element: /**
* @param[in] _newBorderSize The border size to set (0 if not used) * @brief set the current border size of the current element:
*/ * @param[in] _newBorderSize The border size to set (0 if not used)
void setBorderSize(const ewol::Dimension& _newBorderSize); */
/** void setBorderSize(const ewol::Dimension& _newBorderSize);
* @brief get the current border size of the current element: /**
* @return the border size (0 if not used) * @brief get the current border size of the current element:
*/ * @return the border size (0 if not used)
const ewol::Dimension& getBorderSize(void) { */
return m_borderSize; const ewol::Dimension& getBorderSize(void) {
}; return m_borderSize;
public: };
enum animation { public:
animationNone, //!< No annimation enum animation {
animationTop, //!< element came from the top animationNone, //!< No annimation
animationbuttom, //!< element came from the buttom animationTop, //!< element came from the top
animationLeft, //!< element came from the Left animationbuttom, //!< element came from the buttom
animationRight //!< element came from the right animationLeft, //!< element came from the Left
//animationZoom //!< element came from zooming animationRight //!< element came from the right
}; //animationZoom //!< element came from zooming
private: };
enum animation m_animation; //!< Methode add and remove element (animation) private:
public: enum animation m_animation; //!< Methode add and remove element (animation)
/** public:
* @brief set an animation mode for the new element set in the Widget container. /**
* @param[in] _animation The new animation mode. * @brief set an animation mode for the new element set in the Widget container.
*/ * @param[in] _animation The new animation mode.
void setAnimationMode(enum animation _animation) { */
m_animation = _animation; void setAnimationMode(enum animation _animation) {
}; m_animation = _animation;
/** };
* @brief get the current animation mode. /**
* @return The animation mode. * @brief get the current animation mode.
*/ * @return The animation mode.
enum animation getAnimationMode(void) { */
return m_animation; enum animation getAnimationMode(void) {
}; return m_animation;
private: };
float m_animationTime; //!< Time in second to generate animation private:
public: float m_animationTime; //!< Time in second to generate animation
/** public:
* @brief set the time to produce animation. /**
* @param[in] _time The new animation time. * @brief set the time to produce animation.
*/ * @param[in] _time The new animation time.
void setAnimationTime(float _time) { */
m_animationTime = _time; void setAnimationTime(float _time) {
}; m_animationTime = _time;
/** };
* @brief get the current animation time. /**
* @return The time to produce the animation. * @brief get the current animation time.
*/ * @return The time to produce the animation.
float getAnimationTime(void) { */
return m_animationTime; float getAnimationTime(void) {
}; return m_animationTime;
public: // Derived function };
virtual void calculateSize(const vec2& _availlable); public: // Derived function
virtual void calculateMinMaxSize(void); virtual void calculateSize(const vec2& _availlable);
virtual bool loadXML(exml::Element* _node); virtual void calculateMinMaxSize(void);
// overwrite the set fuction to start annimations ... virtual bool loadXML(exml::Element* _node);
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget); // overwrite the set fuction to start annimations ...
virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget); virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
virtual void subWidgetRemove(ewol::Widget* _newWidget); virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::Widget* _newWidget); virtual void subWidgetRemove(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
};
}; };
}; };
#endif #endif

View File

@ -16,17 +16,17 @@ extern const char * const ewolEventSliderChange = "ewol-event-slider-change";
#define __class__ "Slider" #define __class__ "Slider"
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Slider(); return new ewol::widget::Slider();
} }
void widget::Slider::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Slider::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
const int32_t dotRadius = 6; const int32_t dotRadius = 6;
widget::Slider::Slider(void) { ewol::widget::Slider::Slider(void) {
addObjectType("widget::Slider"); addObjectType("ewol::widget::Slider");
addEventId(ewolEventSliderChange); addEventId(ewolEventSliderChange);
m_value = 0; m_value = 0;
@ -42,43 +42,43 @@ widget::Slider::Slider(void) {
setMouseLimit(1); setMouseLimit(1);
} }
widget::Slider::~Slider(void) { ewol::widget::Slider::~Slider(void) {
} }
void widget::Slider::calculateMinMaxSize(void) { void ewol::widget::Slider::calculateMinMaxSize(void) {
vec2 minTmp = m_userMinSize.getPixel(); vec2 minTmp = m_userMinSize.getPixel();
m_minSize.setValue(etk_max(minTmp.x(), 40), m_minSize.setValue(etk_max(minTmp.x(), 40),
etk_max(minTmp.y(), dotRadius*2) ); etk_max(minTmp.y(), dotRadius*2) );
markToRedraw(); markToRedraw();
} }
void widget::Slider::setValue(int32_t _val) { void ewol::widget::Slider::setValue(int32_t _val) {
m_value = etk_max(etk_min(_val, m_max), m_min); m_value = etk_max(etk_min(_val, m_max), m_min);
markToRedraw(); markToRedraw();
} }
int32_t widget::Slider::getValue(void) { int32_t ewol::widget::Slider::getValue(void) {
return m_value; return m_value;
} }
void widget::Slider::setMin(int32_t _val) { void ewol::widget::Slider::setMin(int32_t _val) {
m_min = _val; m_min = _val;
m_value = etk_max(etk_min(m_value, m_max), m_min); m_value = etk_max(etk_min(m_value, m_max), m_min);
markToRedraw(); markToRedraw();
} }
void widget::Slider::setMax(int32_t _val) { void ewol::widget::Slider::setMax(int32_t _val) {
m_max = _val; m_max = _val;
m_value = etk_max(etk_min(m_value, m_max), m_min); m_value = etk_max(etk_min(m_value, m_max), m_min);
markToRedraw(); markToRedraw();
} }
void widget::Slider::onDraw(void) { void ewol::widget::Slider::onDraw(void) {
m_draw.draw(); m_draw.draw();
} }
void widget::Slider::onRegenerateDisplay(void) { void ewol::widget::Slider::onRegenerateDisplay(void) {
if (needRedraw() == false) { if (needRedraw() == false) {
return; return;
} }
@ -100,7 +100,7 @@ void widget::Slider::onRegenerateDisplay(void) {
m_draw.circle(dotRadius/1.6); m_draw.circle(dotRadius/1.6);
} }
bool widget::Slider::onEventInput(const ewol::EventInput& _event) { bool ewol::widget::Slider::onEventInput(const ewol::EventInput& _event) {
vec2 relativePos = relativePosition(_event.getPos()); vec2 relativePos = relativePosition(_event.getPos());
//EWOL_DEBUG("Event on Slider ..."); //EWOL_DEBUG("Event on Slider ...");
if (1 == _event.getId()) { if (1 == _event.getId()) {

View File

@ -17,37 +17,38 @@
extern const char * const ewolEventSliderChange; extern const char * const ewolEventSliderChange;
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Slider :public ewol::Widget { */
public: class Slider :public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
public: static void init(ewol::WidgetManager& _widgetManager);
Slider(void); public:
virtual ~Slider(void); Slider(void);
void setValue(int32_t _val); virtual ~Slider(void);
int32_t getValue(void); void setValue(int32_t _val);
void setMin(int32_t _val); int32_t getValue(void);
void setMax(int32_t _val); void setMin(int32_t _val);
void setColor(etk::Color<> _newColor) { void setMax(int32_t _val);
m_textColorFg = _newColor; void setColor(etk::Color<> _newColor) {
}; m_textColorFg = _newColor;
protected: };
ewol::Drawing m_draw; //!< drawing tool. protected:
int32_t m_value; ewol::Drawing m_draw; //!< drawing tool.
int32_t m_min; int32_t m_value;
int32_t m_max; int32_t m_min;
etk::Color<> m_textColorFg; //!< Text color int32_t m_max;
etk::Color<> m_textColorBg; //!< Background color etk::Color<> m_textColorFg; //!< Text color
public: // Derived function etk::Color<> m_textColorBg; //!< Background color
virtual void onDraw(void); public: // Derived function
virtual void calculateMinMaxSize(void); virtual void onDraw(void);
virtual void onRegenerateDisplay(void); virtual void calculateMinMaxSize(void);
virtual bool onEventInput(const ewol::EventInput& _event); virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
};
}; };
}; };
#endif #endif

View File

@ -14,18 +14,18 @@
#undef __class__ #undef __class__
#define __class__ "Spacer" #define __class__ "Spacer"
const char* const widget::Spacer::configColor = "color"; const char* const ewol::widget::Spacer::configColor = "color";
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::Spacer(); return new ewol::widget::Spacer();
} }
void widget::Spacer::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::Spacer::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::Spacer::Spacer(void) { ewol::widget::Spacer::Spacer(void) {
addObjectType("widget::Spacer"); addObjectType("ewol::widget::Spacer");
m_userMinSize = ewol::Dimension(vec2(10,10)); m_userMinSize = ewol::Dimension(vec2(10,10));
setCanHaveFocus(false); setCanHaveFocus(false);
m_color = etk::color::black; m_color = etk::color::black;
@ -33,16 +33,16 @@ widget::Spacer::Spacer(void) {
registerConfig(configColor, "color", NULL, "background of the spacer"); registerConfig(configColor, "color", NULL, "background of the spacer");
} }
widget::Spacer::~Spacer(void) { ewol::widget::Spacer::~Spacer(void) {
} }
void widget::Spacer::onDraw(void) { void ewol::widget::Spacer::onDraw(void) {
m_draw.draw(); m_draw.draw();
} }
#define BORDER_SIZE_TMP (4) #define BORDER_SIZE_TMP (4)
void widget::Spacer::onRegenerateDisplay(void) { void ewol::widget::Spacer::onRegenerateDisplay(void) {
if (false == needRedraw()) { if (false == needRedraw()) {
return; return;
} }
@ -56,7 +56,7 @@ void widget::Spacer::onRegenerateDisplay(void) {
m_draw.rectangleWidth(vec3(m_size.x(), m_size.y(),0) ); m_draw.rectangleWidth(vec3(m_size.x(), m_size.y(),0) );
} }
bool widget::Spacer::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::Spacer::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) { if (true == ewol::Widget::onSetConfig(_conf)) {
return true; return true;
} }
@ -68,7 +68,7 @@ bool widget::Spacer::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::Spacer::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::Spacer::onGetConfig(const char* _config, std::string& _result) const {
if (true == ewol::Widget::onGetConfig(_config, _result)) { if (true == ewol::Widget::onGetConfig(_config, _result)) {
return true; return true;
} }

View File

@ -16,42 +16,43 @@
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace widget { namespace ewol {
/** namespace widget {
* @ingroup ewolWidgetGroup /**
*/ * @ingroup ewolWidgetGroup
class Spacer :public ewol::Widget { */
public: class Spacer :public ewol::Widget {
static void init(ewol::WidgetManager& _widgetManager); public:
// Config list of properties static void init(ewol::WidgetManager& _widgetManager);
static const char* const configColor; // Config list of properties
private: static const char* const configColor;
ewol::Drawing m_draw; //!< Compositing drawing element private:
public: ewol::Drawing m_draw; //!< Compositing drawing element
/** public:
* @brief Main constructer /**
*/ * @brief Main constructer
Spacer(void); */
/** Spacer(void);
* @brief Main destructer /**
*/ * @brief Main destructer
virtual ~Spacer(void); */
protected: virtual ~Spacer(void);
etk::Color<> m_color; //!< Background color protected:
public: etk::Color<> m_color; //!< Background color
/** public:
* @brief Spziby the background color (basicly transparent) /**
* @param[in] newColor the display background color * @brief Spziby the background color (basicly transparent)
*/ * @param[in] newColor the display background color
void setColor(etk::Color<> _newColor) { m_color = _newColor; markToRedraw(); }; */
public: // Derived function void setColor(etk::Color<> _newColor) { m_color = _newColor; markToRedraw(); };
virtual ewol::Widget * getWidgetAtPos(const vec2& _pos) { return NULL; }; public: // Derived function
virtual void onRegenerateDisplay(void); virtual ewol::Widget * getWidgetAtPos(const vec2& _pos) { return NULL; };
virtual void onDraw(void); virtual void onRegenerateDisplay(void);
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual void onDraw(void);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
}; };
}; };
#endif #endif

View File

@ -10,12 +10,12 @@
#include <ewol/ewol.h> #include <ewol/ewol.h>
static const char* l_listsladingMode[widget::WSlider::sladingTransition_count] = { static const char* l_listsladingMode[ewol::widget::WSlider::sladingTransition_count] = {
"transition vertical", "transition vertical",
"transition horisantal" "transition horisantal"
}; };
etk::CCout& operator <<(etk::CCout& _os, const enum widget::WSlider::sladingMode _obj) { etk::CCout& operator <<(etk::CCout& _os, const enum ewol::widget::WSlider::sladingMode _obj) {
_os << l_listsladingMode[_obj]; _os << l_listsladingMode[_obj];
return _os; return _os;
} }
@ -24,39 +24,39 @@ etk::CCout& operator <<(etk::CCout& _os, const enum widget::WSlider::sladingMode
#define __class__ "WSlider" #define __class__ "WSlider"
// Event list of properties // Event list of properties
const char* const widget::WSlider::eventStartSlide = "ewol-widget-wslider-event-start-slide"; const char* const ewol::widget::WSlider::eventStartSlide = "ewol-widget-wslider-event-start-slide";
const char* const widget::WSlider::eventStopSlide = "ewol-widget-wslider-event-stop-slide"; const char* const ewol::widget::WSlider::eventStopSlide = "ewol-widget-wslider-event-stop-slide";
// Config list of properties // Config list of properties
const char* const widget::WSlider::configMode = "mode"; const char* const ewol::widget::WSlider::configMode = "mode";
static ewol::Widget* create(void) { static ewol::Widget* create(void) {
return new widget::WSlider(); return new ewol::widget::WSlider();
} }
void widget::WSlider::init(ewol::WidgetManager& _widgetManager) { void ewol::widget::WSlider::init(ewol::WidgetManager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create); _widgetManager.addWidgetCreator(__class__,&create);
} }
widget::WSlider::WSlider(void) : ewol::widget::WSlider::WSlider(void) :
m_windowsSources(0), m_windowsSources(0),
m_windowsDestination(0), m_windowsDestination(0),
m_windowsRequested(-1), m_windowsRequested(-1),
m_slidingProgress(1.0f), m_slidingProgress(1.0f),
m_transitionSpeed(1.0f), m_transitionSpeed(1.0f),
m_transitionSlide(sladingTransitionHori) { m_transitionSlide(sladingTransitionHori) {
addObjectType("widget::WSlider"); addObjectType("ewol::widget::WSlider");
addEventId(eventStartSlide); addEventId(eventStartSlide);
addEventId(eventStopSlide); addEventId(eventStopSlide);
// add configuration // add configuration
registerConfig(configMode, "list", "vert;hori", "Transition mode of the slider"); registerConfig(configMode, "list", "vert;hori", "Transition mode of the slider");
} }
widget::WSlider::~WSlider(void) { ewol::widget::WSlider::~WSlider(void) {
} }
void widget::WSlider::calculateSize(const vec2& _availlable) { void ewol::widget::WSlider::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("Update size"); //EWOL_DEBUG("Update size");
widget::ContainerN::calculateSize(_availlable); widget::ContainerN::calculateSize(_availlable);
@ -107,7 +107,7 @@ void widget::WSlider::calculateSize(const vec2& _availlable) {
markToRedraw(); markToRedraw();
} }
void widget::WSlider::subWidgetSelectSet(int32_t _id) { void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) {
int32_t elementID = -1; int32_t elementID = -1;
// search element in the list : // search element in the list :
for (size_t iii=0 ; iii<m_subWidget.size() ; iii++) { for (size_t iii=0 ; iii<m_subWidget.size() ; iii++) {
@ -130,7 +130,7 @@ void widget::WSlider::subWidgetSelectSet(int32_t _id) {
} }
} }
void widget::WSlider::subWidgetSelectSet(ewol::Widget* _widgetPointer) { void ewol::widget::WSlider::subWidgetSelectSet(ewol::Widget* _widgetPointer) {
if (_widgetPointer == NULL) { if (_widgetPointer == NULL) {
EWOL_ERROR("Can not change to a widget NULL"); EWOL_ERROR("Can not change to a widget NULL");
return; return;
@ -146,7 +146,7 @@ void widget::WSlider::subWidgetSelectSet(ewol::Widget* _widgetPointer) {
EWOL_ERROR("Can not change to a widget not present"); EWOL_ERROR("Can not change to a widget not present");
} }
void widget::WSlider::subWidgetSelectSet(const std::string& _widgetName) { void ewol::widget::WSlider::subWidgetSelectSet(const std::string& _widgetName) {
if (_widgetName == "") { if (_widgetName == "") {
EWOL_ERROR("Can not change to a widget with no name (input)"); EWOL_ERROR("Can not change to a widget with no name (input)");
return; return;
@ -162,14 +162,14 @@ void widget::WSlider::subWidgetSelectSet(const std::string& _widgetName) {
EWOL_ERROR("Can not change to a widget not present"); EWOL_ERROR("Can not change to a widget not present");
} }
void widget::WSlider::setTransitionMode(enum sladingMode _mode) { void ewol::widget::WSlider::setTransitionMode(enum sladingMode _mode) {
if (m_transitionSlide != _mode) { if (m_transitionSlide != _mode) {
m_transitionSlide = _mode; m_transitionSlide = _mode;
markToRedraw(); markToRedraw();
} }
} }
void widget::WSlider::periodicCall(const ewol::EventTime& _event) { void ewol::widget::WSlider::periodicCall(const ewol::EventTime& _event) {
if (m_slidingProgress >= 1.0) { if (m_slidingProgress >= 1.0) {
m_windowsSources = m_windowsDestination; m_windowsSources = m_windowsDestination;
if( m_windowsRequested != -1 if( m_windowsRequested != -1
@ -202,7 +202,7 @@ void widget::WSlider::periodicCall(const ewol::EventTime& _event) {
markToRedraw(); markToRedraw();
} }
void widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) { void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){ if (true == m_hide){
// widget is hidden ... // widget is hidden ...
return; return;
@ -241,7 +241,7 @@ void widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
} }
} }
void widget::WSlider::onRegenerateDisplay(void) { void ewol::widget::WSlider::onRegenerateDisplay(void) {
if (m_windowsDestination == m_windowsSources) { if (m_windowsDestination == m_windowsSources) {
int32_t iii = m_windowsDestination; int32_t iii = m_windowsDestination;
if (iii >= 0 || (size_t)iii < m_subWidget.size()) { if (iii >= 0 || (size_t)iii < m_subWidget.size()) {
@ -265,7 +265,7 @@ void widget::WSlider::onRegenerateDisplay(void) {
} }
} }
bool widget::WSlider::onSetConfig(const ewol::EConfig& _conf) { bool ewol::widget::WSlider::onSetConfig(const ewol::EConfig& _conf) {
if (true == widget::ContainerN::onSetConfig(_conf)) { if (true == widget::ContainerN::onSetConfig(_conf)) {
return true; return true;
} }
@ -282,7 +282,7 @@ bool widget::WSlider::onSetConfig(const ewol::EConfig& _conf) {
return false; return false;
} }
bool widget::WSlider::onGetConfig(const char* _config, std::string& _result) const { bool ewol::widget::WSlider::onGetConfig(const char* _config, std::string& _result) const {
if (true == widget::ContainerN::onGetConfig(_config, _result)) { if (true == widget::ContainerN::onGetConfig(_config, _result)) {
return true; return true;
} }
@ -301,7 +301,7 @@ bool widget::WSlider::onGetConfig(const char* _config, std::string& _result) con
return false; return false;
} }
ewol::Widget* widget::WSlider::getWidgetAtPos(const vec2& _pos) { ewol::Widget* ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) { if (true == isHide()) {
return NULL; return NULL;
} }

View File

@ -14,91 +14,91 @@
#include <ewol/widget/ContainerN.h> #include <ewol/widget/ContainerN.h>
#include <ewol/widget/WidgetManager.h> #include <ewol/widget/WidgetManager.h>
namespace ewol {
namespace widget { namespace widget {
/** /**
* @ingroup ewolWidgetGroup * @ingroup ewolWidgetGroup
*/ */
class WSlider :public widget::ContainerN { class WSlider :public widget::ContainerN {
public: public:
static void init(ewol::WidgetManager& _widgetManager); static void init(ewol::WidgetManager& _widgetManager);
// Event list of properties // Event list of properties
static const char* const eventStartSlide; static const char* const eventStartSlide;
static const char* const eventStopSlide; static const char* const eventStopSlide;
// Config list of properties // Config list of properties
static const char* const configMode; static const char* const configMode;
enum sladingMode { enum sladingMode {
sladingTransitionVert, sladingTransitionVert,
sladingTransitionHori, sladingTransitionHori,
sladingTransition_count, sladingTransition_count,
}; };
public: public:
WSlider(void); WSlider(void);
virtual ~WSlider(void); virtual ~WSlider(void);
private: private:
int32_t m_windowsSources; //!< widget source viewed int32_t m_windowsSources; //!< widget source viewed
int32_t m_windowsDestination; //!< widget destinated viewed int32_t m_windowsDestination; //!< widget destinated viewed
int32_t m_windowsRequested; //!< widget destination requested when change in modification in progress int32_t m_windowsRequested; //!< widget destination requested when change in modification in progress
float m_slidingProgress; //!< ratio progression of a sliding float m_slidingProgress; //!< ratio progression of a sliding
public: public:
/** /**
* @brief Select a new subwidget to display * @brief Select a new subwidget to display
* @param[in] _id Id of the subwidget requested * @param[in] _id Id of the subwidget requested
*/ */
void subWidgetSelectSet(int32_t _id); void subWidgetSelectSet(int32_t _id);
/** /**
* @brief Select a new subwidget to display * @brief Select a new subwidget to display
* @param[in] _widgetPointer Pointer on the widget selected (must be added before) * @param[in] _widgetPointer Pointer on the widget selected (must be added before)
*/ */
void subWidgetSelectSet(ewol::Widget* _widgetPointer); void subWidgetSelectSet(ewol::Widget* _widgetPointer);
/** /**
* @brief Select a new subwidget to display * @brief Select a new subwidget to display
* @param[in] _widgetName Name of the subwidget name * @param[in] _widgetName Name of the subwidget name
*/ */
void subWidgetSelectSet(const std::string& _widgetName); void subWidgetSelectSet(const std::string& _widgetName);
private: private:
float m_transitionSpeed; //!< speed of the transition (default 1 == > 1s) float m_transitionSpeed; //!< speed of the transition (default 1 == > 1s)
public: public:
/** /**
* @brief set transition speed element. * @brief set transition speed element.
* @param[in] _timeSecond number of second needed to do the transition. * @param[in] _timeSecond number of second needed to do the transition.
*/ */
void setTransitionSpeed(float _timeSecond) { void setTransitionSpeed(float _timeSecond) {
m_transitionSpeed = _timeSecond; m_transitionSpeed = _timeSecond;
}; };
/** /**
* @brief get transition speed element. * @brief get transition speed element.
* @return number of second needed to do the transition. * @return number of second needed to do the transition.
*/ */
float getTransitionSpeed(void) { float getTransitionSpeed(void) {
return m_transitionSpeed; return m_transitionSpeed;
}; };
private: private:
enum sladingMode m_transitionSlide; //!< mode to slide the widgets enum sladingMode m_transitionSlide; //!< mode to slide the widgets
public: public:
/** /**
* @brief set a new mode of sliding element * @brief set a new mode of sliding element
* @param[in] _mode new display mode * @param[in] _mode new display mode
*/ */
void setTransitionMode(enum sladingMode _mode); void setTransitionMode(enum sladingMode _mode);
/** /**
* @brief get a new mode of sliding element * @brief get a new mode of sliding element
* @return The current sliding mode * @return The current sliding mode
*/ */
enum sladingMode getTransitionMode(void) { enum sladingMode getTransitionMode(void) {
return m_transitionSlide; return m_transitionSlide;
}; };
public: // Derived function public: // Derived function
virtual void calculateSize(const vec2& _availlable); virtual void calculateSize(const vec2& _availlable);
virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void); virtual void onRegenerateDisplay(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos); virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual void periodicCall(const ewol::EventTime& _event); virtual void periodicCall(const ewol::EventTime& _event);
virtual bool onSetConfig(const ewol::EConfig& _conf); virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const; virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
}; };
etk::CCout& operator <<(etk::CCout& _os, const enum ewol::widget::WSlider::sladingMode _obj);
etk::CCout& operator <<(etk::CCout& _os, const enum widget::WSlider::sladingMode _obj);
}; };
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -27,9 +27,9 @@
#include <vector> #include <vector>
#undef __class__ #undef __class__
#define __class__ "WidgetManager" #define __class__ "ewol::widget::Manager"
ewol::WidgetManager::WidgetManager(void) : ewol::widget::Manager::Manager(void) :
m_focusWidgetDefault(NULL), m_focusWidgetDefault(NULL),
m_focusWidgetCurrent(NULL), m_focusWidgetCurrent(NULL),
m_havePeriodic(false), m_havePeriodic(false),
@ -58,7 +58,7 @@ ewol::WidgetManager::WidgetManager(void) :
widget::PopUp::init(*this); widget::PopUp::init(*this);
} }
ewol::WidgetManager::~WidgetManager(void) { ewol::widget::Manager::~Manager(void) {
EWOL_DEBUG(" == > Un-Init Widget-Manager"); EWOL_DEBUG(" == > Un-Init Widget-Manager");
EWOL_INFO("Realease all FOCUS"); EWOL_INFO("Realease all FOCUS");
focusSetDefault(NULL); focusSetDefault(NULL);
@ -68,7 +68,7 @@ ewol::WidgetManager::~WidgetManager(void) {
m_creatorList.clear(); m_creatorList.clear();
} }
void ewol::WidgetManager::rm(ewol::Widget* _newWidget) { void ewol::widget::Manager::rm(ewol::Widget* _newWidget) {
periodicCallRm(_newWidget); periodicCallRm(_newWidget);
focusRemoveIfRemove(_newWidget); focusRemoveIfRemove(_newWidget);
} }
@ -77,7 +77,7 @@ void ewol::WidgetManager::rm(ewol::Widget* _newWidget) {
* focus Area : * focus Area :
* *************************************************************************/ * *************************************************************************/
void ewol::WidgetManager::focusKeep(ewol::Widget* _newWidget) { void ewol::widget::Manager::focusKeep(ewol::Widget* _newWidget) {
if (NULL == _newWidget) { if (NULL == _newWidget) {
// nothing to do ... // nothing to do ...
return; return;
@ -101,7 +101,7 @@ void ewol::WidgetManager::focusKeep(ewol::Widget* _newWidget) {
} }
} }
void ewol::WidgetManager::focusSetDefault(ewol::Widget * _newWidget) { void ewol::widget::Manager::focusSetDefault(ewol::Widget * _newWidget) {
if( NULL != _newWidget if( NULL != _newWidget
&& false == _newWidget->canHaveFocus() ) { && false == _newWidget->canHaveFocus() ) {
EWOL_VERBOSE("Widget can not have focus, id=" << _newWidget->getId() ); EWOL_VERBOSE("Widget can not have focus, id=" << _newWidget->getId() );
@ -121,7 +121,7 @@ void ewol::WidgetManager::focusSetDefault(ewol::Widget * _newWidget) {
m_focusWidgetDefault = _newWidget; m_focusWidgetDefault = _newWidget;
} }
void ewol::WidgetManager::focusRelease(void) { void ewol::widget::Manager::focusRelease(void) {
if (m_focusWidgetDefault == m_focusWidgetCurrent) { if (m_focusWidgetDefault == m_focusWidgetCurrent) {
// nothink to do ... // nothink to do ...
return; return;
@ -138,11 +138,11 @@ void ewol::WidgetManager::focusRelease(void) {
} }
ewol::Widget * ewol::WidgetManager::focusGet(void) { ewol::Widget * ewol::widget::Manager::focusGet(void) {
return m_focusWidgetCurrent; return m_focusWidgetCurrent;
} }
void ewol::WidgetManager::focusRemoveIfRemove(ewol::Widget* _newWidget) { void ewol::widget::Manager::focusRemoveIfRemove(ewol::Widget* _newWidget) {
if (m_focusWidgetCurrent == _newWidget) { if (m_focusWidgetCurrent == _newWidget) {
EWOL_WARNING("Release focus when remove widget"); EWOL_WARNING("Release focus when remove widget");
focusRelease(); focusRelease();
@ -153,7 +153,7 @@ void ewol::WidgetManager::focusRemoveIfRemove(ewol::Widget* _newWidget) {
} }
} }
void ewol::WidgetManager::periodicCallAdd(ewol::Widget* _pWidget) { void ewol::widget::Manager::periodicCallAdd(ewol::Widget* _pWidget) {
for (size_t iii=0; iii < m_listOfPeriodicWidget.size(); iii++) { for (size_t iii=0; iii < m_listOfPeriodicWidget.size(); iii++) {
if (m_listOfPeriodicWidget[iii] == _pWidget) { if (m_listOfPeriodicWidget[iii] == _pWidget) {
return; return;
@ -169,7 +169,7 @@ void ewol::WidgetManager::periodicCallAdd(ewol::Widget* _pWidget) {
m_havePeriodic = true; m_havePeriodic = true;
} }
void ewol::WidgetManager::periodicCallRm(ewol::Widget * _pWidget) { void ewol::widget::Manager::periodicCallRm(ewol::Widget * _pWidget) {
int32_t nbElement = 0; int32_t nbElement = 0;
for (int32_t iii=m_listOfPeriodicWidget.size()-1; iii >= 0 ; iii--) { for (int32_t iii=m_listOfPeriodicWidget.size()-1; iii >= 0 ; iii--) {
if (m_listOfPeriodicWidget[iii] == _pWidget) { if (m_listOfPeriodicWidget[iii] == _pWidget) {
@ -183,11 +183,11 @@ void ewol::WidgetManager::periodicCallRm(ewol::Widget * _pWidget) {
} }
} }
void ewol::WidgetManager::periodicCallResume(int64_t _localTime) { void ewol::widget::Manager::periodicCallResume(int64_t _localTime) {
m_lastPeriodicCallTime = _localTime; m_lastPeriodicCallTime = _localTime;
} }
void ewol::WidgetManager::periodicCall(int64_t _localTime) { void ewol::widget::Manager::periodicCall(int64_t _localTime) {
int64_t previousTime = m_lastPeriodicCallTime; int64_t previousTime = m_lastPeriodicCallTime;
m_lastPeriodicCallTime = _localTime; m_lastPeriodicCallTime = _localTime;
if (m_listOfPeriodicWidget.size() <= 0) { if (m_listOfPeriodicWidget.size() <= 0) {
@ -223,23 +223,23 @@ void ewol::WidgetManager::periodicCall(int64_t _localTime) {
} }
} }
bool ewol::WidgetManager::periodicCallHave(void) { bool ewol::widget::Manager::periodicCallHave(void) {
return m_havePeriodic; return m_havePeriodic;
} }
void ewol::WidgetManager::markDrawingIsNeeded(void) { void ewol::widget::Manager::markDrawingIsNeeded(void) {
m_haveRedraw = true; m_haveRedraw = true;
} }
bool ewol::WidgetManager::isDrawingNeeded(void) { bool ewol::widget::Manager::isDrawingNeeded(void) {
bool tmp = m_haveRedraw; bool tmp = m_haveRedraw;
m_haveRedraw = false; m_haveRedraw = false;
return tmp; return tmp;
} }
// element that generate the list of elements // element that generate the list of elements
void ewol::WidgetManager::addWidgetCreator(const std::string& _name, void ewol::widget::Manager::addWidgetCreator(const std::string& _name,
ewol::WidgetManager::creator_tf _pointer) { ewol::widget::Manager::creator_tf _pointer) {
if (NULL == _pointer) { if (NULL == _pointer) {
return; return;
} }
@ -254,10 +254,10 @@ void ewol::WidgetManager::addWidgetCreator(const std::string& _name,
m_creatorList.add(nameLower, _pointer); m_creatorList.add(nameLower, _pointer);
} }
ewol::Widget* ewol::WidgetManager::create(const std::string& _name) { ewol::Widget* ewol::widget::Manager::create(const std::string& _name) {
std::string nameLower = to_lower(_name); std::string nameLower = to_lower(_name);
if (true == m_creatorList.exist(nameLower)) { if (true == m_creatorList.exist(nameLower)) {
ewol::WidgetManager::creator_tf pointerFunction = m_creatorList[nameLower]; ewol::widget::Manager::creator_tf pointerFunction = m_creatorList[nameLower];
if (NULL != pointerFunction) { if (NULL != pointerFunction) {
return pointerFunction(); return pointerFunction();
} }
@ -266,12 +266,12 @@ ewol::Widget* ewol::WidgetManager::create(const std::string& _name) {
return NULL; return NULL;
} }
bool ewol::WidgetManager::exist(const std::string& _name) { bool ewol::widget::Manager::exist(const std::string& _name) {
std::string nameLower = to_lower(_name); std::string nameLower = to_lower(_name);
return m_creatorList.exist(nameLower); return m_creatorList.exist(nameLower);
} }
std::string ewol::WidgetManager::list(void) { std::string ewol::widget::Manager::list(void) {
std::string tmpVal; std::string tmpVal;
for (int32_t iii=0; iii<m_creatorList.size() ; iii++) { for (int32_t iii=0; iii<m_creatorList.size() ; iii++) {
tmpVal += m_creatorList.getKey(iii); tmpVal += m_creatorList.getKey(iii);

View File

@ -16,45 +16,47 @@
#include <ewol/widget/Widget.h> #include <ewol/widget/Widget.h>
namespace ewol { namespace ewol {
class WidgetManager { namespace widget {
public: class Manager {
typedef ewol::Widget* (*creator_tf)(void); public:
private: typedef ewol::Widget* (*creator_tf)(void);
// For the focus Management private:
ewol::Widget* m_focusWidgetDefault; // For the focus Management
ewol::Widget* m_focusWidgetCurrent; ewol::Widget* m_focusWidgetDefault;
std::vector<ewol::Widget*> m_listOfPeriodicWidget; ewol::Widget* m_focusWidgetCurrent;
bool m_havePeriodic; std::vector<ewol::Widget*> m_listOfPeriodicWidget;
bool m_haveRedraw; bool m_havePeriodic;
etk::Hash<creator_tf> m_creatorList; bool m_haveRedraw;
int64_t m_applWakeUpTime; //!< Time of the application initialize etk::Hash<creator_tf> m_creatorList;
int64_t m_lastPeriodicCallTime; //!< last call time ... int64_t m_applWakeUpTime; //!< Time of the application initialize
public: int64_t m_lastPeriodicCallTime; //!< last call time ...
WidgetManager(void); public:
~WidgetManager(void); Manager(void);
// need to call when remove a widget to clear all dependency of the focus system ~Manager(void);
void rm(ewol::Widget* _newWidget); // need to call when remove a widget to clear all dependency of the focus system
void rm(ewol::Widget* _newWidget);
void focusKeep(ewol::Widget* _newWidget); // set the focus at the specific widget
void focusSetDefault(ewol::Widget* _newWidget); // select the default focus getter void focusKeep(ewol::Widget* _newWidget); // set the focus at the specific widget
void focusRelease(void); // release focus from the current widget to the default void focusSetDefault(ewol::Widget* _newWidget); // select the default focus getter
ewol::Widget* focusGet(void); void focusRelease(void); // release focus from the current widget to the default
void focusRemoveIfRemove(ewol::Widget* _newWidget); ewol::Widget* focusGet(void);
void focusRemoveIfRemove(ewol::Widget* _newWidget);
void periodicCallAdd(ewol::Widget* _pWidget);
void periodicCallRm(ewol::Widget* _pWidget); void periodicCallAdd(ewol::Widget* _pWidget);
void periodicCall(int64_t _localTime); void periodicCallRm(ewol::Widget* _pWidget);
void periodicCallResume(int64_t _localTime); void periodicCall(int64_t _localTime);
bool periodicCallHave(void); void periodicCallResume(int64_t _localTime);
bool periodicCallHave(void);
void markDrawingIsNeeded(void);
bool isDrawingNeeded(void); void markDrawingIsNeeded(void);
bool isDrawingNeeded(void);
// element that generate the list of elements
void addWidgetCreator(const std::string& _name, creator_tf _pointer); // element that generate the list of elements
ewol::Widget* create(const std::string& _name); void addWidgetCreator(const std::string& _name, creator_tf _pointer);
bool exist(const std::string& _name); ewol::Widget* create(const std::string& _name);
std::string list(void); bool exist(const std::string& _name);
std::string list(void);
};
}; };
}; };

Some files were not shown because too many files have changed in this diff Show More