[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>
#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_color(etk::color::white),
m_GLprogram(NULL),
@ -28,12 +28,12 @@ ewol::Area::Area(const ivec2& _size) :
loadProgram();
}
ewol::Area::~Area(void) {
ewol::compositing::Area::~Area(void) {
ewol::Texture::release(m_resource);
ewol::Program::release(m_GLprogram);
}
void ewol::Area::loadProgram(void) {
void ewol::compositing::Area::loadProgram(void) {
// get the shader resource :
m_GLPosition = 0;
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) {
//EWOL_WARNING("Nothink to draw...");
return;
@ -76,7 +76,7 @@ void ewol::Area::draw(bool _disableDepthTest) {
m_GLprogram->unUse();
}
void ewol::Area::clear(void) {
void ewol::compositing::Area::clear(void) {
// call upper class
ewol::Compositing::clear();
// reset Buffer :
@ -87,7 +87,7 @@ void ewol::Area::clear(void) {
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);
vec2 tex(0,1);
point.setX(m_position.x());

View File

@ -10,78 +10,91 @@
#define __EWOL_COMPOSITING_AREA_H__
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h>
namespace ewol
{
class Area : public ewol::Compositing
{
private:
vec3 m_position; //!< The current position to draw
etk::Color<> m_color; //!< The text foreground color
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
ewol::Texture* m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _size Basic size of the area.
*/
Area(const ivec2& _size);
/**
* @brief generic destructor
*/
~Area(void);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll the registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) { m_position = _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)
*/
void setRelPos(const vec3& _pos) { m_position += _pos; };
inline void setRelPos(const vec2& _pos) { 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(); };
namespace ewol {
namespace compositing {
class Area : public ewol::compositing::Compose {
private:
vec3 m_position; //!< The current position to draw
etk::Color<> m_color; //!< The text foreground color
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
ewol::Texture* m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _size Basic size of the area.
*/
Area(const ivec2& _size);
/**
* @brief generic destructor
*/
~Area(void);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll the registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) {
m_position = _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)
*/
void setRelPos(const vec3& _pos) {
m_position += _pos;
};
inline void setRelPos(const vec2& _pos) {
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>
ewol::Compositing::Compositing(void) {
ewol::compositing::Compose::Compose(void) {
// nothing to do
}
ewol::Compositing::~Compositing(void) {
ewol::compositing::Compose::~Compose(void) {
// nothing to do
}
void ewol::Compositing::resetMatrix(void) {
void ewol::compositing::Compose::resetMatrix(void) {
m_matrixApply.identity();
}
void ewol::Compositing::translate(const vec3& _vect) {
void ewol::compositing::Compose::translate(const vec3& _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);
}
void ewol::Compositing::scale(const vec3& _vect) {
void ewol::compositing::Compose::scale(const vec3& _vect) {
m_matrixApply *= etk::matScale(_vect);
}
void ewol::Compositing::clear(void) {
void ewol::compositing::Compose::clear(void) {
m_matrixApply.identity();
}
void ewol::Compositing::setMatrix(const mat4& _mat) {
void ewol::compositing::Compose::setMatrix(const mat4& _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
ewol::Drawing::Drawing(void) :
ewol::compositing::Drawing::Drawing(void) :
m_position(0.0, 0.0, 0.0),
m_clippingPosStart(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();
}
void ewol::Drawing::generateTriangle(void) {
void ewol::compositing::Drawing::generateTriangle(void) {
m_triElement = 0;
m_coord.push_back(m_triangle[0]);
@ -252,7 +252,7 @@ void ewol::Drawing::generateTriangle(void) {
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) {
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_triElement++;
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;
}
void ewol::Drawing::unLoadProgram(void) {
void ewol::compositing::Drawing::unLoadProgram(void) {
ewol::Program::release(m_GLprogram);
}
void ewol::Drawing::loadProgram(void) {
void ewol::compositing::Drawing::loadProgram(void) {
// remove previous loading ... in case
unLoadProgram();
// 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) {
// TODO : a remÚtre ...
//EWOL_WARNING("Nothink to draw...");
@ -316,7 +316,7 @@ void ewol::Drawing::draw(bool _disableDepthTest) {
m_GLprogram->unUse();
}
void ewol::Drawing::clear(void) {
void ewol::compositing::Drawing::clear(void) {
// call upper class
ewol::Compositing::clear();
// 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
if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x());
@ -364,7 +364,7 @@ void ewol::Drawing::setClipping(const vec3& _pos, const vec3& _posEnd) {
m_clippingEnable = true;
}
void ewol::Drawing::setThickness(float _thickness) {
void ewol::compositing::Drawing::setThickness(float _thickness) {
m_thickness = _thickness;
// thickness must be positive
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);
setPoint(m_position);
}
void ewol::Drawing::lineTo(const vec3& _dest) {
void ewol::compositing::Drawing::lineTo(const vec3& _dest) {
resetCount();
internalSetColor(m_color);
EWOL_VERBOSE("DrawLine : " << m_position << " to " << _dest);
@ -411,7 +411,7 @@ void ewol::Drawing::lineTo(const vec3& _dest) {
m_position = _dest;
}
void ewol::Drawing::rectangle(const vec3& _dest) {
void ewol::compositing::Drawing::rectangle(const vec3& _dest) {
resetCount();
internalSetColor(m_color);
/* Bitmap position
@ -464,11 +464,11 @@ void ewol::Drawing::rectangle(const vec3& _dest) {
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();
if (_radius<0) {

View File

@ -12,170 +12,206 @@
#include <etk/Color.h>
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h>
namespace ewol {
class Drawing : public ewol::Compositing {
private:
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
private: // Background Color (display only when needed)
std::vector<vec3 > m_coord; //!< internal position for the text display
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background
public:
/**
* @brief Basic constructor
*/
Drawing(void);
/**
* @brief Basic destructor
*/
~Drawing(void);
private:
/**
* @brief load the openGL program and get all the ID needed
*/
void loadProgram(void);
/**
* @brief Un-Load the openGL program and get all the ID needed
*/
void unLoadProgram(void);
float m_thickness; //!< when drawing line and other things
int32_t m_triElement; //!< special counter of the single dot generated
vec3 m_triangle[3]; //!< Register every system with a combinaison of tiangle
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
*/
void generateTriangle(void);
/**
* @brief in case of some error the count can be reset
*/
void resetCount(void);
/**
* @brief set the Color of the current triangle drawing
* @param[in] _color Color to current dots generated
*/
void internalSetColor(const etk::Color<>& _color);
/**
* @brief internal add of the specific point
* @param[in] _point The requeste dpoint to add
*/
void setPoint(const vec3& point);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) { m_position = _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)
*/
void setRelPos(const vec3& _pos) { m_position += _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)
*/
void setColor(const etk::Color<>& _color) { m_color = _color; };
/**
* @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print)
*/
void setColorBg(const etk::Color<>& _color) { m_colorBg = _color; };
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in]_ pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth(const vec3& _pos, const vec3& _width) { setClipping(_pos, _pos+_width); };
inline void setClippingWidth(const vec2& _pos, const vec2& _width) { setClippingWidth(vec3(_pos.x(),_pos.y(),-1), vec3(_width.x(),_width.y(), 2)); };
/**
* @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
*/
void setClipping(const vec3& _pos, const vec3& _posEnd);
inline 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
*/
void setClippingMode(bool _newMode) { m_clippingEnable = _newMode; };
/**
* @brief Specify the line thickness for the next elements
* @param[in] _thickness The thickness disired for the next print
*/
void setThickness(float _thickness);
/**
* @brief add a point reference at the current position (this is a vertex reference at the current position
*/
void addVertex(void);
/**
* @brief draw a line to a specific position
* @param[in] _dest Position of the end of the line.
*/
void lineTo(const vec3& _dest);
inline void lineTo(const vec2& _dest) { lineTo(vec3(_dest.x(), _dest.y(), 0)); };
/**
* @brief Relative drawing a line (spacial vector)
* @param[in] _vect Vector of the curent line.
*/
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);
namespace compositing {
class Drawing : public ewol::compositing::Compose {
private:
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
private: // Background Color (display only when needed)
std::vector<vec3 > m_coord; //!< internal position for the text display
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the background
public:
/**
* @brief Basic constructor
*/
Drawing(void);
/**
* @brief Basic destructor
*/
~Drawing(void);
private:
/**
* @brief load the openGL program and get all the ID needed
*/
void loadProgram(void);
/**
* @brief Un-Load the openGL program and get all the ID needed
*/
void unLoadProgram(void);
float m_thickness; //!< when drawing line and other things
int32_t m_triElement; //!< special counter of the single dot generated
vec3 m_triangle[3]; //!< Register every system with a combinaison of tiangle
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
*/
void generateTriangle(void);
/**
* @brief in case of some error the count can be reset
*/
void resetCount(void);
/**
* @brief set the Color of the current triangle drawing
* @param[in] _color Color to current dots generated
*/
void internalSetColor(const etk::Color<>& _color);
/**
* @brief internal add of the specific point
* @param[in] _point The requeste dpoint to add
*/
void setPoint(const vec3& point);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) {
m_position = _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)
*/
void setRelPos(const vec3& _pos) {
m_position += _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)
*/
void setColor(const etk::Color<>& _color) {
m_color = _color;
};
/**
* @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print)
*/
void setColorBg(const etk::Color<>& _color) {
m_colorBg = _color;
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in]_ pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth(const vec3& _pos, const vec3& _width) {
setClipping(_pos, _pos+_width);
};
inline void setClippingWidth(const vec2& _pos, const vec2& _width) {
setClippingWidth(vec3(_pos.x(),_pos.y(),-1), vec3(_width.x(),_width.y(), 2));
};
/**
* @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
*/
void setClipping(const vec3& _pos, const vec3& _posEnd);
inline 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
*/
void setClippingMode(bool _newMode) {
m_clippingEnable = _newMode;
};
/**
* @brief Specify the line thickness for the next elements
* @param[in] _thickness The thickness disired for the next print
*/
void setThickness(float _thickness);
/**
* @brief add a point reference at the current position (this is a vertex reference at the current position
*/
void addVertex(void);
/**
* @brief draw a line to a specific position
* @param[in] _dest Position of the end of the line.
*/
void lineTo(const vec3& _dest);
inline void lineTo(const vec2& _dest) {
lineTo(vec3(_dest.x(), _dest.y(), 0));
};
/**
* @brief Relative drawing a line (spacial vector)
* @param[in] _vect Vector of the curent line.
*/
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>
#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_clippingPosStart(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();
}
ewol::Image::~Image(void) {
ewol::compositing::Image::~Image(void) {
ewol::TextureFile::release(m_resource);
ewol::Program::release(m_GLprogram);
}
void ewol::Image::loadProgram(void) {
void ewol::compositing::Image::loadProgram(void) {
// get the shader resource :
m_GLPosition = 0;
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) {
//EWOL_WARNING("Nothink to draw...");
return;
@ -83,9 +83,9 @@ void ewol::Image::draw(bool _disableDepthTest) {
m_GLprogram->unUse();
}
void ewol::Image::clear(void) {
void ewol::compositing::Image::clear(void) {
// call upper class
ewol::Compositing::clear();
ewol::compositing::Compose::clear();
// reset Buffer :
m_coord.clear();
m_coordTex.clear();
@ -99,7 +99,7 @@ void ewol::Image::clear(void) {
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
if (_pos.x() <= _posEnd.x()) {
m_clippingPosStart.setX(_pos.x());
@ -125,17 +125,17 @@ void ewol::Image::setClipping(const vec3& _pos, vec3 _posEnd) {
m_clippingEnable = true;
}
void ewol::Image::setAngle(float _angle) {
void ewol::compositing::Image::setAngle(float _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));
}
void ewol::Image::printPart(const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop) {
void ewol::compositing::Image::printPart(const vec2& _size,
const vec2& _sourcePosStart,
const vec2& _sourcePosStop) {
if (m_angle == 0.0f) {
vec3 point = m_position;
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
@ -226,7 +226,7 @@ void ewol::Image::printPart(const vec2& _size,
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();
// remove old one
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;
}
vec2 ewol::Image::getRealSize(void) {
vec2 ewol::compositing::Image::getRealSize(void) {
if (NULL == m_resource) {
return vec2(0,0);
}

View File

@ -10,134 +10,160 @@
#define __EWOL_COMPOSITING_IMAGE_H__
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Compose.h>
#include <ewol/resources/ResourceManager.h>
namespace ewol {
class Image : public ewol::Compositing {
private:
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
float m_angle; //!< Angle to set at the axes
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
ewol::TextureFile* m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _imageName Name of the file that might be loaded
*/
Image(const std::string& _imageName="");
/**
* @brief generic destructor
*/
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
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) { m_position = _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)
*/
void setRelPos(const vec3& _pos) { m_position += _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)
*/
void setColor(const etk::Color<>& _color) { m_color = _color; };
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
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 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
*/
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 enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping
*/
void setClippingMode(bool _newMode) { m_clippingEnable = _newMode; };
/**
* @brief set a unique rotation of this element (not set in the rotate Generic system)
* @param[in] _angle Angle to set in radiant.
*/
void setAngle(float _angleRad);
/**
* @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) { print(vec2(_size.x(),_size.y())); };
void print(const vec2& _size);
/**
* @brief add a part of the image to display with the requested size
* @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);
namespace compositing {
class Image : public ewol::compositing::Compose {
private:
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
float m_angle; //!< Angle to set at the axes
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
ewol::TextureFile* m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _imageName Name of the file that might be loaded
*/
Image(const std::string& _imageName="");
/**
* @brief generic destructor
*/
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
*/
void draw(bool _disableDepthTest=true);
/**
* @brief clear alll tre registered element in the current element
*/
void clear(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
void setPos(const vec3& _pos) {
m_position = _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)
*/
void setRelPos(const vec3& _pos) {
m_position += _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)
*/
void setColor(const etk::Color<>& _color) {
m_color = _color;
};
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
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 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
*/
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 enable/Disable the clipping (without lose the current clipping position)
* @brief _newMode The new status of the clipping
*/
void setClippingMode(bool _newMode) {
m_clippingEnable = _newMode;
};
/**
* @brief set a unique rotation of this element (not set in the rotate Generic system)
* @param[in] _angle Angle to set in radiant.
*/
void setAngle(float _angleRad);
/**
* @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) {
print(vec2(_size.x(),_size.y()));
};
void print(const vec2& _size);
/**
* @brief add a part of the image to display with the requested size
* @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>
#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_config(NULL),
m_confIdPaddingX(-1),
@ -42,17 +42,17 @@ ewol::Shaper::Shaper(const std::string& _shaperName) :
updateVertex();
}
ewol::Shaper::~Shaper(void) {
ewol::compositing::Shaper::~Shaper(void) {
unLoadProgram();
}
void ewol::Shaper::unLoadProgram(void) {
void ewol::compositing::Shaper::unLoadProgram(void) {
ewol::Program::release(m_GLprogram);
ewol::TextureFile::release(m_resourceTexture);
ewol::ConfigFile::release(m_config);
}
void ewol::Shaper::loadProgram(void) {
void ewol::compositing::Shaper::loadProgram(void) {
if (m_name == "") {
EWOL_DEBUG("no Shaper set for loading resources ...");
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) {
// this is a normale case ... the user can choice to have no config basic file ...
return;
@ -132,11 +132,11 @@ void ewol::Shaper::draw(bool _disableDepthTest) {
m_GLprogram->unUse();
}
void ewol::Shaper::clear(void) {
void ewol::compositing::Shaper::clear(void) {
// nothing to do ...
}
bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) {
bool ewol::compositing::Shaper::changeStatusIn(int32_t _newStatusId) {
if (_newStatusId != m_stateNew) {
m_nextStatusRequested = _newStatusId;
return true;
@ -148,7 +148,7 @@ bool ewol::Shaper::changeStatusIn(int32_t _newStatusId) {
return false;
}
bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) {
bool ewol::compositing::Shaper::periodicCall(const ewol::EventTime& _event) {
//EWOL_DEBUG("call=" << _event);
// start :
if (m_stateTransition >= 1.0) {
@ -186,7 +186,7 @@ bool ewol::Shaper::periodicCall(const ewol::EventTime& _event) {
return true;
}
void ewol::Shaper::updateVertex(void) {
void ewol::compositing::Shaper::updateVertex(void) {
// set coord == > must be a static VBO ...
m_coord[0].setValue( m_propertyOrigin.x(),
m_propertyOrigin.y()+m_propertySize.y());
@ -203,29 +203,29 @@ void ewol::Shaper::updateVertex(void) {
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) {
m_propertyOrigin = _newOri;
updateVertex();
}
}
void ewol::Shaper::setSize(const vec2& _newSize) {
void ewol::compositing::Shaper::setSize(const vec2& _newSize) {
if (m_propertySize != _newSize) {
m_propertySize = _newSize;
updateVertex();
}
}
void ewol::Shaper::setInsideSize(const vec2& _newInsideSize) {
void ewol::compositing::Shaper::setInsideSize(const vec2& _newInsideSize) {
m_propertyInsideSize = _newInsideSize;
}
void ewol::Shaper::setInsidePos(const vec2& _newInsidePos) {
void ewol::compositing::Shaper::setInsidePos(const vec2& _newInsidePos) {
m_propertyInsidePosition = _newInsidePos;
}
vec2 ewol::Shaper::getPadding(void) {
vec2 ewol::compositing::Shaper::getPadding(void) {
vec2 padding(0,0);
if (m_config!=NULL) {
padding.setValue(m_config->getFloat(m_confIdPaddingX),
@ -234,14 +234,14 @@ vec2 ewol::Shaper::getPadding(void) {
return padding;
}
void ewol::Shaper::setSource(const std::string& _newFile) {
void ewol::compositing::Shaper::setSource(const std::string& _newFile) {
clear();
unLoadProgram();
m_name = _newFile;
loadProgram();
}
bool ewol::Shaper::hasSources(void) {
bool ewol::compositing::Shaper::hasSources(void) {
return m_GLprogram!=NULL;
}

View File

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

View File

@ -14,15 +14,17 @@
#include <ewol/resources/ResourceManager.h>
namespace ewol {
class Sprite : public ewol::Image {
protected:
ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal
vec2 m_unitarySpriteSize; //!< size of a unique sprite
public:
Sprite(const std::string& _imageName, const ivec2& _nbSprite);
virtual ~Sprite() {};
void printSprite(const ivec2& _spriteID, const vec2& _size) { printSprite(_spriteID, vec3(_size.x(), _size.y(),0)); };
void printSprite(const ivec2& _spriteID, const vec3& _size);
namespace compositing {
class Sprite : public ewol::compositing::Compose {
protected:
ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal
vec2 m_unitarySpriteSize; //!< size of a unique sprite
public:
Sprite(const std::string& _imageName, const ivec2& _nbSprite);
virtual ~Sprite() {};
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>
#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_clippingPosStart(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::Program::release(m_GLprogram);
}
void ewol::Text::loadProgram(void) {
void ewol::compositing::Text::loadProgram(void) {
// get the shader resource :
m_GLPosition = 0;
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:
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:
m_vectorialDraw.draw();
@ -141,22 +141,22 @@ void ewol::Text::draw(bool _disableDepthTest) {
m_GLprogram->unUse();
}
void ewol::Text::translate(const vec3& _vect) {
void ewol::compositing::Text::translate(const vec3& _vect) {
ewol::Compositing::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);
m_vectorialDraw.rotate(_vect, _angle);
}
void ewol::Text::scale(const vec3& _vect) {
void ewol::compositing::Text::scale(const vec3& _vect) {
ewol::Compositing::scale(_vect);
m_vectorialDraw.scale(_vect);
}
void ewol::Text::clear(void) {
void ewol::compositing::Text::clear(void) {
// call upper class
ewol::Compositing::clear();
// remove sub draw system
@ -169,7 +169,7 @@ void ewol::Text::clear(void) {
reset();
}
void ewol::Text::reset(void) {
void ewol::compositing::Text::reset(void) {
m_position = vec3(0,0,0);
m_clippingPosStart = vec3(0,0,0);
m_clippingPosStop = vec3(0,0,0);
@ -192,7 +192,7 @@ void ewol::Text::reset(void) {
m_nbCharDisplayed = 0;
}
void ewol::Text::setPos(const vec3& _pos) {
void ewol::compositing::Text::setPos(const vec3& _pos) {
// check min max for display area
if (m_nbCharDisplayed != 0) {
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_previousCharcode = 0;
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_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
if (_pos.x() <= _posEnd.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);
}
void ewol::Text::setClippingMode(bool _newMode) {
void ewol::compositing::Text::setClippingMode(bool _newMode) {
m_clippingEnable = _newMode;
//m_vectorialDraw.setClippingMode(m_clippingEnable);
}
void ewol::Text::setFontSize(int32_t _fontSize) {
void ewol::compositing::Text::setFontSize(int32_t _fontSize) {
// get old size
std::string fontName = "";
if (m_font != NULL) {
@ -277,7 +277,7 @@ void ewol::Text::setFontSize(int32_t _fontSize) {
setFont(fontName, _fontSize);
}
void ewol::Text::setFontName(const std::string& _fontName) {
void ewol::compositing::Text::setFontName(const std::string& _fontName) {
// get old size
int32_t fontSize = -1;
if (m_font != NULL) {
@ -286,7 +286,7 @@ void ewol::Text::setFontName(const std::string& _fontName) {
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();
// remove old one
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) {
m_mode = m_font->getWrappingMode(_mode);
}
@ -319,7 +319,7 @@ enum ewol::font::mode ewol::Text::getFontMode(void) {
return m_mode;
}
void ewol::Text::setFontBold(bool _status) {
void ewol::compositing::Text::setFontBold(bool _status) {
if (_status == true) {
// enable
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) {
// enable
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;
}
void ewol::Text::setDistanceFieldMode(bool _newMode) {
void ewol::compositing::Text::setDistanceFieldMode(bool _newMode) {
m_distanceField = _newMode;
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;
print(_text, decorationEmpty);
}
void ewol::Text::print(const std::string& _text) {
void ewol::compositing::Text::print(const std::string& _text) {
std::vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty);
}
void ewol::Text::parseHtmlNode(exml::Element* _element) {
void ewol::compositing::Text::parseHtmlNode(exml::Element* _element) {
// get the static real pointer
if (_element == NULL) {
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");
tmpData+=_text;
tmpData+="\n</body>\n</html>\n";
@ -478,7 +478,7 @@ void ewol::Text::printDecorated(const std::string& _text) {
printHTML(tmpData);
}
void ewol::Text::printHTML(const std::string& _text) {
void ewol::compositing::Text::printHTML(const std::string& _text) {
exml::Document doc;
// reset parameter :
@ -506,7 +506,7 @@ void ewol::Text::printHTML(const std::string& _text) {
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) {
EWOL_ERROR("Font Id is not corectly defined");
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) {
EWOL_ERROR("Font Id is not corectly defined");
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) {
EWOL_ERROR("Font Id is not corectly defined");
return;
@ -1056,12 +1056,12 @@ void ewol::Text::print(const char32_t& _charcode) {
return;
}
void ewol::Text::forceLineReturn(void) {
void ewol::compositing::Text::forceLineReturn(void) {
// reset position :
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_stopTextPos = _stopTextPos+1;
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;
}
void ewol::Text::disableAlignement(void) {
void ewol::compositing::Text::disableAlignement(void) {
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
reset();
//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());
}
vec3 ewol::Text::calculateSizeDecorated(const std::string& _text) {
vec3 ewol::compositing::Text::calculateSizeDecorated(const std::string& _text) {
if (_text.size() == 0) {
return vec3(0,0,0);
}
@ -1120,7 +1120,7 @@ vec3 ewol::Text::calculateSizeDecorated(const std::string& _text) {
return tmpVal;
}
vec3 ewol::Text::calculateSize(const std::string& _text) {
vec3 ewol::compositing::Text::calculateSize(const std::string& _text) {
if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0);
@ -1136,7 +1136,7 @@ vec3 ewol::Text::calculateSize(const std::string& _text) {
return outputSize;
}
vec3 ewol::Text::calculateSize(const char32_t& _charcode) {
vec3 ewol::compositing::Text::calculateSize(const char32_t& _charcode) {
if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined");
return vec3(0,0,0);
@ -1159,8 +1159,7 @@ vec3 ewol::Text::calculateSize(const char32_t& _charcode) {
return outputSize;
}
void ewol::Text::printCursor(bool _isInsertMode, float _cursorSize) {
void ewol::compositing::Text::printCursor(bool _isInsertMode, float _cursorSize) {
int32_t fontHeigh = m_font->getHeight(m_mode);
if (true == _isInsertMode) {
m_vectorialDraw.rectangleWidth(vec3(_cursorSize, fontHeigh, 0) );
@ -1171,12 +1170,11 @@ void ewol::Text::printCursor(bool _isInsertMode, float _cursorSize) {
}
}
bool ewol::Text::extrapolateLastId(const std::string& _text,
const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
bool ewol::compositing::Text::extrapolateLastId(const std::string& _text,
const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
// store previous :
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,
const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
bool ewol::compositing::Text::extrapolateLastId(const std::u32string& _text,
const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
// store previous :
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
&& m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') {
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) {
print(m_htmlCurrrentLine, m_htmlDecoration);
}
@ -1323,25 +1321,25 @@ void ewol::Text::htmlFlush(void) {
m_htmlDecoration.clear();
}
void ewol::Text::disableCursor(void) {
void ewol::compositing::Text::disableCursor(void) {
m_selectionStartPos = -100;
m_cursorPos = -100;
}
void ewol::Text::setCursorPos(int32_t _cursorPos) {
void ewol::compositing::Text::setCursorPos(int32_t _cursorPos) {
m_selectionStartPos = _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_cursorPos = _cursorPos;
}
void ewol::Text::setSelectionColor(const etk::Color<>& _color) {
void ewol::compositing::Text::setSelectionColor(const etk::Color<>& _color) {
m_colorSelection = _color;
}
void ewol::Text::setCursorColor(const etk::Color<>& _color) {
void ewol::compositing::Text::setCursorColor(const etk::Color<>& _color) {
m_colorCursor = _color;
}

View File

@ -12,415 +12,413 @@
#include <etk/Color.h>
#include <ewol/debug.h>
#include <ewol/compositing/Compositing.h>
#include <ewol/compositing/Compose.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/resources/ResourceManager.h>
#include <exml/exml.h>
#include <string>
namespace ewol {
/**
* @brief This class represent the specific display for every char in the string ...
*/
class TextDecoration {
public:
etk::Color<> m_colorBg; //!< display background color
etk::Color<> m_colorFg; //!< display foreground color
enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic
TextDecoration(void) {
m_colorBg = etk::color::blue;
m_colorBg = etk::color::green;
m_mode = ewol::font::Regular;
}
};
class Text : public ewol::Compositing {
public:
enum aligneMode {
alignDisable,
alignRight,
alignLeft,
alignCenter,
alignJustify
};
private:
ewol::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ...
public:
ewol::Drawing& getDrawing(void) {
return m_vectorialDraw;
};
private:
int32_t m_nbCharDisplayed; //!< prevent some error in calculation size.
vec3 m_sizeDisplayStart; //!< The start 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.
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
etk::Color<> m_colorCursor; //!< The text cursor color
etk::Color<> m_colorSelection; //!< The text Selection color
private:
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_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
private:
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)
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...)
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection)
int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100)
private:
ewol::TexturedFont* m_font; //!< Font resources
private: // Text
std::vector<vec2 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _fontName Name 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);
/**
* @brief generic destructor
*/
~Text(void);
public:
// Derived function
virtual void translate(const vec3& _vect);
// Derived function
virtual void rotate(const vec3& _vect, float _angle);
// Derived function
virtual void scale(const vec3& _vect);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false);
/**
* @brief clear all the registered element in the current element
*/
void clear(void);
/**
* @brief clear all the intermediate result detween 2 prints
*/
void reset(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
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)
*/
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)
*/
void setColor(const etk::Color<>& _color) { m_color = _color; };
/**
* @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print)
*/
void setColorBg(const etk::Color<>& _color);
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth(const vec3& _pos, const vec3& _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
*/
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
*/
// TODO : Rename setClippingActivity
void setClippingMode(bool _newMode);
/**
* @brief Specify the font size (this reset the internal element of the current text (system requirement)
* @param[in] _fontSize New font size
*/
void setFontSize(int32_t _fontSize);
/**
* @brief Specify the font name (this reset the internal element of the current text (system requirement)
* @param[in] _fontName Current name of the selected font
*/
void setFontName(const std::string& _fontName);
/**
* @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
* @param[in] fontSize New font size
*/
void setFont(std::string _fontName, int32_t _fontSize);
/**
* @brief Specify the font mode for the next @ref print
* @param[in] mode The font mode requested
*/
void setFontMode(enum ewol::font::mode _mode);
/**
* @brief get the current font mode
* @return The font mode applied
*/
enum ewol::font::mode getFontMode(void);
/**
* @brief enable or disable the bold mode
* @param[in] _status The new status for this display property
*/
void setFontBold(bool _status);
/**
* @brief enable or disable the italic mode
* @param[in] _status The new status for this display property
*/
void setFontItalic(bool _status);
/**
* @brief set the activation of the Kerning for the display (if it existed)
* @param[in] _newMode enable/Diasable the kerning on this font.
*/
void setKerningMode(bool _newMode);
/**
* @brief Request the distance field mode for this text display
* @param[in] _newMode enable/Diasable the Distance Field on this font.
* @todo : not implemented for now
*/
void setDistanceFieldMode(bool _newMode);
/**
* @brief display a compleat string in the current element.
* @param[in] _text The string to display.
*/
void print(const std::string& _text);
void print(const std::u32string& _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* <pre>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <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/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </pre>
* @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.
* @TODO : implementation not done ....
*/
void printDecorated(const std::string& _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* <pre>
* <html>
* <body>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <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/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </body>
* </html>
* </pre>
* @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.
* @TODO : implementation not done ....
*/
void printHTML(const std::string& _text);
/**
* @brief display a compleat string in the current element whith specific decorations (advence mode).
* @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)
*/
void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
void print(const std::u32string& _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)
* @param[in] _charcode Char that might be dispalyed
*/
void print(const char32_t& _charcode);
/**
* @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 forceLineReturn(void);
private:
/**
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element.
*/
void parseHtmlNode(exml::Element* _element);
public:
/**
* @brief This generate the possibility to generate the big text property
* @param[in] _startTextpos The x text start position of the display.
* @param[in] _stopTextPos The x text stop position of the display.
* @param[in] _alignement mode of alignement for the Text.
* @note The text align in center change of line every display done (even if it was just a char)
*/
void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement=ewol::Text::alignDisable);
/**
* @brief disable the alignement system
*/
void disableAlignement(void);
/**
* @brief get the current alignement property
* @return the curent alignement type
*/
enum ewol::Text::aligneMode getAlignement(void);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSizeHTML(const std::string& _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSizeDecorated(const std::string& _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSize(const std::string& _text);
/**
* @brief calculate a theoric charcode size
* @param[in] _charcode The µUnicode value to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSize(const char32_t& _charcode);
/**
* @brief draw a cursor at the specify position
* @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]
*/
void printCursor(bool _isInsertMode, float _cursorSize = 20.0f);
private:
/**
* @brief calculate the element number that is the first out the alignement range
* (start at the specify ID, and use start pos with current one)
* @param[in] _text The string that might be parsed.
* @param[in] _start The first elemnt that might be used to calculate.
* @param[out] _stop The last Id availlable in the current string.
* @param[out] _space Number of space in the string.
* @parma[out] _freespace This represent the number of pixel present in the right white space.
* @return true if the rifht has free space that can be use for jystify (return false if we find \n
*/
bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
private:
// this section is reserved for HTML parsing and display:
std::string m_htmlCurrrentLine; //!< current line for HTML display
std::vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display
TextDecoration m_htmlDecoTmp; //!< current decoration
/**
* @brief add a line with the current m_htmlDecoTmp decoration
* @param[in] _data The cuurent data to add.
*/
void htmlAddData(const std::string& _data);
/**
* @brief draw the current line
*/
void htmlFlush(void);
public:
/**
* @brief remove the cursor display
*/
void disableCursor(void);
/**
* @brief set a cursor at a specific position:
* @param[in] _cursorPos id of the cursor position
*/
void setCursorPos(int32_t _cursorPos);
/**
* @brief set a cursor at a specific position with his associated selection:
* @param[in] _cursorPos id of the cursor position
* @param[in] _selectionStartPos id of the starting of the selection
*/
void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos);
/**
* @brief change the selection color
* @param[in] _color New color for the Selection
*/
void setSelectionColor(const etk::Color<>& _color);
/**
* @brief change the cursor color
* @param[in] _color New color for the Selection
*/
void setCursorColor(const etk::Color<>& _color);
namespace compositing {
/**
* @brief This class represent the specific display for every char in the string ...
*/
class TextDecoration {
public:
etk::Color<> m_colorBg; //!< display background color
etk::Color<> m_colorFg; //!< display foreground color
enum ewol::font::mode m_mode; //!< display mode Regular/Bold/Italic/BoldItalic
TextDecoration(void) {
m_colorBg = etk::color::blue;
m_colorBg = etk::color::green;
m_mode = ewol::font::Regular;
}
};
class Text : public ewol::compositing::Compose {
public:
enum aligneMode {
alignDisable,
alignRight,
alignLeft,
alignCenter,
alignJustify
};
private:
ewol::Drawing m_vectorialDraw; //!< This is used to draw background selection and other things ...
public:
ewol::Drawing& getDrawing(void) {
return m_vectorialDraw;
};
private:
int32_t m_nbCharDisplayed; //!< prevent some error in calculation size.
vec3 m_sizeDisplayStart; //!< The start 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.
vec3 m_position; //!< The current position to draw
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
private:
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
etk::Color<> m_colorCursor; //!< The text cursor color
etk::Color<> m_colorSelection; //!< The text Selection color
private:
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_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
private:
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)
enum aligneMode m_alignement; //!< Current Alignement mode (justify/left/right ...)
private:
ewol::Program* m_GLprogram; //!< pointer on the opengl display program
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_GLColor; //!< openGL id on the element (color buffer)
int32_t m_GLtexture; //!< openGL id on the element (Texture position)
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
int32_t m_selectionStartPos; //!< start position of the Selection (if == m_cursorPos ==> no selection)
int32_t m_cursorPos; //!< Cursor position (default no cursor == > -100)
private:
ewol::TexturedFont* m_font; //!< Font resources
private: // Text
std::vector<vec2 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
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
*/
void loadProgram(void);
public:
/**
* @brief generic constructor
* @param[in] _fontName Name 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);
/**
* @brief generic destructor
*/
~Text(void);
public: // Derived function
virtual void translate(const vec3& _vect);
virtual void rotate(const vec3& _vect, float _angle);
virtual void scale(const vec3& _vect);
public:
/**
* @brief draw All the refistered text in the current element on openGL
*/
void draw(bool _disableDepthTest=true);
void draw(const mat4& _transformationMatrix, bool _enableDepthTest=false);
/**
* @brief clear all the registered element in the current element
*/
void clear(void);
/**
* @brief clear all the intermediate result detween 2 prints
*/
void reset(void);
/**
* @brief get the current display position (sometime needed in the gui control)
* @return the current 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)
*/
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)
*/
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)
*/
void setColor(const etk::Color<>& _color) { m_color = _color; };
/**
* @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print)
*/
void setColorBg(const etk::Color<>& _color);
/**
* @brief Request a clipping area for the text (next draw only)
* @param[in] _pos Start position of the clipping
* @param[in] _width Width size of the clipping
*/
void setClippingWidth(const vec3& _pos, const vec3& _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
*/
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
*/
// TODO : Rename setClippingActivity
void setClippingMode(bool _newMode);
/**
* @brief Specify the font size (this reset the internal element of the current text (system requirement)
* @param[in] _fontSize New font size
*/
void setFontSize(int32_t _fontSize);
/**
* @brief Specify the font name (this reset the internal element of the current text (system requirement)
* @param[in] _fontName Current name of the selected font
*/
void setFontName(const std::string& _fontName);
/**
* @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
* @param[in] fontSize New font size
*/
void setFont(std::string _fontName, int32_t _fontSize);
/**
* @brief Specify the font mode for the next @ref print
* @param[in] mode The font mode requested
*/
void setFontMode(enum ewol::font::mode _mode);
/**
* @brief get the current font mode
* @return The font mode applied
*/
enum ewol::font::mode getFontMode(void);
/**
* @brief enable or disable the bold mode
* @param[in] _status The new status for this display property
*/
void setFontBold(bool _status);
/**
* @brief enable or disable the italic mode
* @param[in] _status The new status for this display property
*/
void setFontItalic(bool _status);
/**
* @brief set the activation of the Kerning for the display (if it existed)
* @param[in] _newMode enable/Diasable the kerning on this font.
*/
void setKerningMode(bool _newMode);
/**
* @brief Request the distance field mode for this text display
* @param[in] _newMode enable/Diasable the Distance Field on this font.
* @todo : not implemented for now
*/
void setDistanceFieldMode(bool _newMode);
/**
* @brief display a compleat string in the current element.
* @param[in] _text The string to display.
*/
void print(const std::string& _text);
void print(const std::u32string& _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* <pre>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <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/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </pre>
* @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.
* @TODO : implementation not done ....
*/
void printDecorated(const std::string& _text);
/**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* <pre>
* <html>
* <body>
* <br/>
* <br/><br/><br/>
* <center>
* text exemple <b>in bold</b> other text <b>bold part <i>boldItalic part</i></b> an other thext
* <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/>
* an an other thext
* </center>
* <br/><br/><br/>
* <left>
* plop 1
* </left>
* <br/><br/><br/>
* <right>
* plop 2
* </right>
* <br/><br/><br/>
* <justify>
* Un exemple de text
* </justify>
* </body>
* </html>
* </pre>
* @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.
* @TODO : implementation not done ....
*/
void printHTML(const std::string& _text);
/**
* @brief display a compleat string in the current element whith specific decorations (advence mode).
* @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)
*/
void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
void print(const std::u32string& _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)
* @param[in] _charcode Char that might be dispalyed
*/
void print(const char32_t& _charcode);
/**
* @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 forceLineReturn(void);
private:
/**
* @brief This parse a tinyXML node (void pointer to permit to hide tiny XML in include).
* @param[in] _element the exml element.
*/
void parseHtmlNode(exml::Element* _element);
public:
/**
* @brief This generate the possibility to generate the big text property
* @param[in] _startTextpos The x text start position of the display.
* @param[in] _stopTextPos The x text stop position of the display.
* @param[in] _alignement mode of alignement for the Text.
* @note The text align in center change of line every display done (even if it was just a char)
*/
void setTextAlignement(float _startTextpos, float _stopTextPos, enum ewol::Text::aligneMode _alignement=ewol::Text::alignDisable);
/**
* @brief disable the alignement system
*/
void disableAlignement(void);
/**
* @brief get the current alignement property
* @return the curent alignement type
*/
enum ewol::Text::aligneMode getAlignement(void);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSizeHTML(const std::string& _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSizeDecorated(const std::string& _text);
/**
* @brief calculate a theoric text size
* @param[in] _text The string to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSize(const std::string& _text);
/**
* @brief calculate a theoric charcode size
* @param[in] _charcode The µUnicode value to calculate dimention.
* @return The theoric size used.
*/
vec3 calculateSize(const char32_t& _charcode);
/**
* @brief draw a cursor at the specify position
* @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]
*/
void printCursor(bool _isInsertMode, float _cursorSize = 20.0f);
private:
/**
* @brief calculate the element number that is the first out the alignement range
* (start at the specify ID, and use start pos with current one)
* @param[in] _text The string that might be parsed.
* @param[in] _start The first elemnt that might be used to calculate.
* @param[out] _stop The last Id availlable in the current string.
* @param[out] _space Number of space in the string.
* @parma[out] _freespace This represent the number of pixel present in the right white space.
* @return true if the rifht has free space that can be use for jystify (return false if we find \n
*/
bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
private:
// this section is reserved for HTML parsing and display:
std::string m_htmlCurrrentLine; //!< current line for HTML display
std::vector<TextDecoration> m_htmlDecoration; //!< current decoration for the HTML display
TextDecoration m_htmlDecoTmp; //!< current decoration
/**
* @brief add a line with the current m_htmlDecoTmp decoration
* @param[in] _data The cuurent data to add.
*/
void htmlAddData(const std::string& _data);
/**
* @brief draw the current line
*/
void htmlFlush(void);
public:
/**
* @brief remove the cursor display
*/
void disableCursor(void);
/**
* @brief set a cursor at a specific position:
* @param[in] _cursorPos id of the cursor position
*/
void setCursorPos(int32_t _cursorPos);
/**
* @brief set a cursor at a specific position with his associated selection:
* @param[in] _cursorPos id of the cursor position
* @param[in] _selectionStartPos id of the starting of the selection
*/
void setCursorSelection(int32_t _cursorPos, int32_t _selectionStartPos);
/**
* @brief change the selection color
* @param[in] _color New color for the Selection
*/
void setSelectionColor(const etk::Color<>& _color);
/**
* @brief change the cursor 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();
}
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,
ewol::Widget* _destination) {
m_input.transfertEvent(_source, _destination);
@ -84,71 +138,76 @@ void ewol::eContext::inputEventUnGrabPointer(void) {
void ewol::eContext::processEvents(void) {
int32_t nbEvent = 0;
//EWOL_DEBUG(" ******** Event");
eSystemMessage data;
ewol::eSystemMessage* data = NULL;
while (m_msgSystem.count()>0) {
nbEvent++;
if (data != NULL) {
delete(data);
data = NULL;
}
m_msgSystem.wait(data);
//EWOL_DEBUG("EVENT");
switch (data.TypeMessage) {
switch (data->TypeMessage) {
case eSystemMessage::msgInit:
// this is due to the openGL context
/*bool returnVal = */APP_Init(*this);
/*bool returnVal = */
APP_Init(*this);
break;
case eSystemMessage::msgRecalculateSize:
forceRedrawAll();
break;
case eSystemMessage::msgResize:
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
m_windowsSize = data.dimention;
m_windowsSize = data->dimention;
ewol::dimension::setPixelWindowsSize(m_windowsSize);
forceRedrawAll();
break;
case eSystemMessage::msgInputMotion:
//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;
case eSystemMessage::msgInputState:
//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;
case eSystemMessage::msgKeyboardKey:
case eSystemMessage::msgKeyboardMove:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
if (NULL != m_windowsCurrent) {
if (false == m_windowsCurrent->onEventShortCut(data.keyboardSpecial,
data.keyboardChar,
data.keyboardMove,
data.stateIsDown) ) {
if (false == m_windowsCurrent->onEventShortCut(data->keyboardSpecial,
data->keyboardChar,
data->keyboardMove,
data->stateIsDown) ) {
// get the current focused Widget :
ewol::Widget * tmpWidget = m_widgetManager.focusGet();
if (NULL != tmpWidget) {
// check if the widget allow repeating key events.
//EWOL_DEBUG("repeating test :" << data.repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data.stateIsDown);
if( false == data.repeateKey
|| ( true == data.repeateKey
//EWOL_DEBUG("repeating test :" << data->repeateKey << " widget=" << tmpWidget->getKeyboardRepeate() << " state=" << data->stateIsDown);
if( false == data->repeateKey
|| ( true == data->repeateKey
&& true == tmpWidget->getKeyboardRepeate()) ) {
// check Widget shortcut
if (false == tmpWidget->onEventShortCut(data.keyboardSpecial,
data.keyboardChar,
data.keyboardMove,
data.stateIsDown) ) {
if (false == tmpWidget->onEventShortCut(data->keyboardSpecial,
data->keyboardChar,
data->keyboardMove,
data->stateIsDown) ) {
// generate the direct event ...
if (data.TypeMessage == eSystemMessage::msgKeyboardKey) {
if (data->TypeMessage == eSystemMessage::msgKeyboardKey) {
ewol::EventEntrySystem tmpEntryEvent(ewol::keyEvent::keyboardChar,
ewol::keyEvent::statusUp,
data.keyboardSpecial,
data.keyboardChar);
if(true == data.stateIsDown) {
data->keyboardSpecial,
data->keyboardChar);
if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
} else { // THREAD_KEYBORAD_MOVE
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data.keyboardMove << " " << data.stateIsDown);
ewol::EventEntrySystem tmpEntryEvent(data.keyboardMove,
EWOL_DEBUG("THREAD_KEYBORAD_MOVE" << data->keyboardMove << " " << data->stateIsDown);
ewol::EventEntrySystem tmpEntryEvent(data->keyboardMove,
ewol::keyEvent::statusUp,
data.keyboardSpecial,
data->keyboardSpecial,
0);
if(true == data.stateIsDown) {
if(true == data->stateIsDown) {
tmpEntryEvent.m_event.setStatus(ewol::keyEvent::statusDown);
}
tmpWidget->systemEventEntry(tmpEntryEvent);
@ -165,7 +224,7 @@ void ewol::eContext::processEvents(void) {
{
ewol::Widget * tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != NULL) {
tmpWidget->onEventClipboard(data.clipboardID);
tmpWidget->onEventClipboard(data->clipboardID);
}
}
break;
@ -262,9 +321,13 @@ ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
etk::initDefaultFolder("ewolApplNoName");
// request the init of the application in the main context of openGL ...
{
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgInit;
m_msgSystem.post(data);
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
m_msgSystem.post(data);
}
}
// force a recalculation
requestUpdateSize();
@ -282,6 +345,7 @@ ewol::eContext::eContext(int32_t _argc, const char* _argv[]) :
ewol::eContext::~eContext(void) {
EWOL_INFO(" == > Ewol system Un-Init (BEGIN)");
// TODO : Clean the message list ...
// set the curent interface :
lockContext();
// call application to uninit
@ -301,64 +365,88 @@ ewol::eContext::~eContext(void) {
}
void ewol::eContext::requestUpdateSize(void) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgRecalculateSize;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgRecalculateSize;
m_msgSystem.post(data);
}
void ewol::eContext::OS_Resize(const vec2& _size) {
// TODO : Better in the thread ... == > but generate some init error ...
ewol::dimension::setPixelWindowsSize(_size);
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgResize;
data.dimention = _size;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgResize;
data->dimention = _size;
m_msgSystem.post(data);
}
void ewol::eContext::OS_Move(const vec2& _pos) {
/*
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgResize;
data.resize.w = w;
data.resize.h = h;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
data->TypeMessage = eSystemMessage::msgResize;
data->resize.w = w;
data->resize.h = h;
m_msgSystem.Post(data);
*/
}
void ewol::eContext::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgInputMotion;
data.inputType = ewol::keyEvent::typeFinger;
data.inputId = _pointerID;
data.dimention = _pos;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::keyEvent::typeFinger;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data);
}
void ewol::eContext::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgInputState;
data.inputType = ewol::keyEvent::typeFinger;
data.inputId = _pointerID;
data.stateIsDown = _isDown;
data.dimention = _pos;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::keyEvent::typeFinger;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data);
}
void ewol::eContext::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgInputMotion;
data.inputType = ewol::keyEvent::typeMouse;
data.inputId = _pointerID;
data.dimention = _pos;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgInputMotion;
data->inputType = ewol::keyEvent::typeMouse;
data->inputId = _pointerID;
data->dimention = _pos;
m_msgSystem.post(data);
}
void ewol::eContext::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgInputState;
data.inputType = ewol::keyEvent::typeMouse;
data.inputId = _pointerID;
data.stateIsDown = _isDown;
data.dimention = _pos;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgInputState;
data->inputType = ewol::keyEvent::typeMouse;
data->inputId = _pointerID;
data->stateIsDown = _isDown;
data->dimention = _pos;
m_msgSystem.post(data);
}
@ -366,12 +454,16 @@ void ewol::eContext::OS_SetKeyboard(ewol::SpecialKey& _special,
char32_t _myChar,
bool _isDown,
bool _isARepeateKey) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgKeyboardKey;
data.stateIsDown = _isDown;
data.keyboardChar = _myChar;
data.keyboardSpecial = _special;
data.repeateKey = _isARepeateKey;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgKeyboardKey;
data->stateIsDown = _isDown;
data->keyboardChar = _myChar;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data);
}
@ -379,32 +471,48 @@ void ewol::eContext::OS_SetKeyboardMove(ewol::SpecialKey& _special,
enum ewol::keyEvent::keyboard _move,
bool _isDown,
bool _isARepeateKey) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgKeyboardMove;
data.stateIsDown = _isDown;
data.keyboardMove = _move;
data.keyboardSpecial = _special;
data.repeateKey = _isARepeateKey;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgKeyboardMove;
data->stateIsDown = _isDown;
data->keyboardMove = _move;
data->keyboardSpecial = _special;
data->repeateKey = _isARepeateKey;
m_msgSystem.post(data);
}
void ewol::eContext::OS_Hide(void) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgHide;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgHide;
m_msgSystem.post(data);
}
void ewol::eContext::OS_Show(void) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgShow;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgShow;
m_msgSystem.post(data);
}
void ewol::eContext::OS_ClipBoardArrive(enum ewol::clipBoard::clipboardListe _clipboardID) {
eSystemMessage data;
data.TypeMessage = eSystemMessage::msgClipboardArrive;
data.clipboardID = _clipboardID;
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
EWOL_ERROR("allocationerror of message");
return;
}
data->TypeMessage = eSystemMessage::msgClipboardArrive;
data->clipboardID = _clipboardID;
m_msgSystem.post(data);
}

View File

@ -23,58 +23,8 @@
#include <ewol/resources/ResourceManager.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 {
class eSystemMessage;
enum orientation{
screenAuto = 0,
screenLandscape,
@ -129,7 +79,7 @@ namespace ewol {
private:
int64_t m_previousDisplayTime; // this is to limit framerate ... in case...
ewol::eInput m_input;
etk::MessageFifo<eSystemMessage> m_msgSystem;
etk::MessageFifo<ewol::eSystemMessage*> m_msgSystem;
bool m_displayFps;
ewol::Fps m_FpsSystemEvent;
ewol::Fps m_FpsSystemContext;

View File

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

View File

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

View File

@ -13,10 +13,10 @@
#include <stdexcept>
#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;
#ifdef __EXCEPTIONS
try {
@ -36,15 +36,15 @@ void ewol::SimpleConfigElement::parse(const std::string& _value) {
ewol::ConfigFile::ConfigFile(const std::string& _filename) :
ewol::Resource(_filename) {
ewol::resource::ConfigFile::ConfigFile(const std::string& _filename) :
ewol::resource::Resource(_filename) {
addObjectType("ewol::ConfigFile");
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
reload();
}
ewol::ConfigFile::~ConfigFile(void) {
ewol::resource::ConfigFile::~ConfigFile(void) {
// remove all element
for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) {
@ -55,7 +55,7 @@ ewol::ConfigFile::~ConfigFile(void) {
m_list.clear();
}
void ewol::ConfigFile::reload(void) {
void ewol::resource::ConfigFile::reload(void) {
// reset all parameters
for (size_t iii=0; iii<m_list.size(); 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 :
for (size_t iii=0; iii<m_list.size(); 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) {
EWOL_DEBUG("error while allocation");
} 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::ConfigFile* object = static_cast<ewol::ConfigFile*>(getManager().localKeep(_filename));
ewol::resource::ConfigFile* object = static_cast<ewol::resource::ConfigFile*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
// this element create a new one every time ....
object = new ewol::ConfigFile(_filename);
object = new ewol::resource::ConfigFile(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??");
return NULL;
@ -173,11 +173,11 @@ ewol::ConfigFile* ewol::ConfigFile::keep(const std::string& _filename) {
return object;
}
void ewol::ConfigFile::release(ewol::ConfigFile*& _object) {
void ewol::resource::ConfigFile::release(ewol::resource::ConfigFile*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

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

View File

@ -19,13 +19,13 @@
#include <ewol/resources/ResourceManager.h>
#undef __class__
#define __class__ "FontFreeType"
#define __class__ "resource::FontFreeType"
// free Font hnadle of librairies ... entry for acces ...
static int32_t l_countLoaded=0;
static FT_Library library;
void ewol::freeTypeInit(void) {
void ewol::resource::freeTypeInit(void) {
EWOL_DEBUG(" == > init Font-Manager");
l_countLoaded++;
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");
l_countLoaded--;
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) {
addObjectType("ewol::FontFreeType");
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
if (NULL != m_FileBuffer) {
delete[] m_FileBuffer;
@ -107,7 +107,7 @@ ewol::FontFreeType::~FontFreeType(void) {
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) {
return vec2(0,0);
}
@ -116,11 +116,11 @@ vec2 ewol::FontFreeType::getSize(int32_t _fontSize, const std::string& _unicodeS
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 ...
}
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) {
return false;
}
@ -160,11 +160,11 @@ bool ewol::FontFreeType::getGlyphProperty(int32_t _fontSize, ewol::GlyphProperty
return true;
}
bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
int32_t _fontSize,
ivec2 _glyphPosition,
ewol::GlyphProperty& _property,
int8_t _posInImage) {
bool ewol::resource::FontFreeType::drawGlyph(egami::Image& _imageOut,
int32_t _fontSize,
ivec2 _glyphPosition,
ewol::resource::GlyphProperty& _property,
int8_t _posInImage) {
if(false == m_init) {
return false;
}
@ -200,8 +200,7 @@ bool ewol::FontFreeType::drawGlyph(egami::Image& _imageOut,
tlpppp = _imageOut.get(ivec2(_glyphPosition.x()+iii, _glyphPosition.y()+jjj));
uint8_t valueColor = slot->bitmap.buffer[iii + slot->bitmap.width*jjj];
// set only alpha :
switch(_posInImage)
{
switch(_posInImage) {
default:
case 0:
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) {
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) {
return;
}
@ -343,14 +342,14 @@ void ewol::FontFreeType::display(void) {
//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::FontBase* object = static_cast<ewol::FontBase*>(getManager().localKeep(_filename));
ewol::resource::FontBase* object = static_cast<ewol::resource::FontBase*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
// need to crate a new one ...
object = new ewol::FontFreeType(_filename);
object = new ewol::resource::FontFreeType(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
@ -359,11 +358,11 @@ ewol::FontBase* ewol::FontFreeType::keep(const std::string& _filename) {
return object;
}
void ewol::FontFreeType::release(ewol::FontBase*& _object) {
void ewol::resource::FontFreeType::release(ewol::resource::FontBase*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

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

View File

@ -15,16 +15,16 @@
#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) {
}
ewol::TextureFile::TextureFile(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) :
Texture(_genName) {
ewol::resource::TextureFile::TextureFile(std::string _genName, const std::string& _tmpfileName, const ivec2& _size) :
ewol::resource::Texture(_genName) {
addObjectType("ewol::TextureFile");
if (false == egami::load(m_data, _tmpfileName, _size)) {
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);
if (_filename == "") {
ewol::TextureFile* object = new ewol::TextureFile("");
ewol::resource::TextureFile* object = new ewol::resource::TextureFile("");
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??");
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::TextureFile* object = static_cast<ewol::TextureFile*>(getManager().localKeep(TmpFilename));
ewol::resource::TextureFile* object = static_cast<ewol::resource::TextureFile*>(getManager().localKeep(TmpFilename));
if (NULL != object) {
return object;
}
EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size);
// need to crate a new one ...
object = new ewol::TextureFile(TmpFilename, _filename, _size);
object = new ewol::resource::TextureFile(TmpFilename, _filename, _size);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
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) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -16,30 +16,32 @@
#include <ewol/resources/Resource.h>
namespace ewol {
class TextureFile : public ewol::Texture {
private:
vec2 m_realImageSize;
private:
TextureFile(const std::string& _genName);
TextureFile(std::string _genName, const std::string& _fileName, const ivec2& _size);
~TextureFile(void) { };
public:
virtual const char* getType(void) { return "ewol::TextureFile"; };
const vec2& getRealSize(void) { return m_realImageSize; };
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the image file.
* @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));
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::TextureFile*& _object);
namespace resource {
class TextureFile : public ewol::resource::Texture {
private:
vec2 m_realImageSize;
private:
TextureFile(const std::string& _genName);
TextureFile(std::string _genName, const std::string& _fileName, const ivec2& _size);
~TextureFile(void) { };
public:
virtual const char* getType(void) { return "ewol::TextureFile"; };
const vec2& getRealSize(void) { return m_realImageSize; };
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the image file.
* @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));
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::TextureFile*& _object);
};
};
};

View File

@ -16,12 +16,12 @@
ewol::ResourceManager::ResourceManager(void) :
ewol::resource::Manager::Manager(void) :
m_contextHasBeenRemoved(true) {
// nothing to do ...
}
ewol::ResourceManager::~ResourceManager(void) {
ewol::resource::Manager::~Manager(void) {
bool hasError = false;
if (m_resourceListToUpdate.size()!=0) {
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();
m_resourceListToUpdate.clear();
// remove all resources ...
@ -52,7 +52,7 @@ void ewol::ResourceManager::unInit(void) {
m_resourceList.clear();
}
void ewol::ResourceManager::display(void) {
void ewol::resource::Manager::display(void) {
EWOL_INFO("Resources loaded : ");
// remove all resources ...
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
@ -66,7 +66,7 @@ void ewol::ResourceManager::display(void) {
EWOL_INFO("Resources ---");
}
void ewol::ResourceManager::reLoadResources(void) {
void ewol::resource::Manager::reLoadResources(void) {
EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ...
if (m_resourceList.size() != 0) {
@ -87,7 +87,7 @@ void ewol::ResourceManager::reLoadResources(void) {
EWOL_INFO("------------- Resources -------------");
}
void ewol::ResourceManager::update(ewol::Resource* _object) {
void ewol::resource::Manager::update(ewol::resource::Resource* _object) {
// chek if not added before
for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
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
void ewol::ResourceManager::updateContext(void) {
void ewol::resource::Manager::updateContext(void) {
if (true == m_contextHasBeenRemoved) {
// need to update all ...
m_contextHasBeenRemoved = false;
@ -138,7 +138,7 @@ void ewol::ResourceManager::updateContext(void) {
}
// 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++) {
if (m_resourceList[iii] != NULL) {
m_resourceList[iii]->removeContextToLate();
@ -149,7 +149,7 @@ void ewol::ResourceManager::contextHasBeenDestroyed(void) {
}
// 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 << "\"");
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) {
@ -164,7 +164,7 @@ ewol::Resource* ewol::ResourceManager::localKeep(const std::string& _filename) {
}
// internal generic keeper ...
void ewol::ResourceManager::localAdd(ewol::Resource* _object) {
void ewol::resource::Manager::localAdd(ewol::resource::Resource* _object) {
//Add ... find empty slot
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] == NULL) {
@ -176,7 +176,7 @@ void ewol::ResourceManager::localAdd(ewol::Resource* _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) {
EWOL_ERROR("Try to remove a resource that have null pointer ...");
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>
#undef __class__
#define __class__ "Mesh"
#define __class__ "resource::Mesh"
ewol::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
ewol::Resource(_fileName),
ewol::resource::Mesh::Mesh(const std::string& _fileName, const std::string& _shaderName) :
ewol::resource::Resource(_fileName),
m_normalMode(normalModeNone),
m_checkNormal(false),
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 :
ewol::Program::release(m_GLprogram);
ewol::VirtualBufferObject::release(m_verticesVBO);
ewol::resource::Program::release(m_GLprogram);
ewol::resource::VirtualBufferObject::release(m_verticesVBO);
if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL;
@ -77,9 +77,9 @@ ewol::Mesh::~Mesh(void) {
//#define DISPLAY_NB_VERTEX_DISPLAYED
void ewol::Mesh::draw(mat4& _positionMatrix,
bool _enableDepthTest,
bool _enableDepthUpdate) {
void ewol::resource::Mesh::draw(mat4& _positionMatrix,
bool _enableDepthTest,
bool _enableDepthUpdate) {
if (m_GLprogram == NULL) {
EWOL_ERROR("No shader ...");
return;
@ -178,7 +178,7 @@ void ewol::Mesh::draw(mat4& _positionMatrix,
}
// normal calculation of the normal face is really easy :
void ewol::Mesh::calculateNormaleFace(void) {
void ewol::resource::Mesh::calculateNormaleFace(void) {
m_listFacesNormal.clear();
if (m_normalMode != ewol::Mesh::normalModeFace) {
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();
if (m_normalMode != ewol::Mesh::normalModeVertex) {
for(size_t iii=0 ; iii<m_listVertex.size() ; iii++) {
@ -221,7 +221,7 @@ void ewol::Mesh::calculateNormaleEdge(void) {
//#define PRINT_HALF (1)
//#define TRY_MINIMAL_VBO
void ewol::Mesh::generateVBO(void) {
void ewol::resource::Mesh::generateVBO(void) {
// calculate the normal of all faces if needed
if (m_normalMode == ewol::Mesh::normalModeNone) {
// 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;
// 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;
#if 0
etk::FSNode fileName(_fileName);
@ -626,7 +626,7 @@ enum emfModuleMode {
EMFModuleMaterial_END,
};
bool ewol::Mesh::loadEMF(const std::string& _fileName) {
bool ewol::resource::Mesh::loadEMF(const std::string& _fileName) {
m_checkNormal = true;
m_normalMode = ewol::Mesh::normalModeNone;
etk::FSNode fileName(_fileName);
@ -992,7 +992,7 @@ bool ewol::Mesh::loadEMF(const std::string& _fileName) {
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) {
EWOL_ERROR(" can not add material with null pointer");
return;
@ -1005,7 +1005,7 @@ void ewol::Mesh::addMaterial(const std::string& _name, ewol::Material* _data) {
m_materials.add(_name, _data);
}
void ewol::Mesh::setShape(void* _shape) {
void ewol::resource::Mesh::setShape(void* _shape) {
if (m_functionFreeShape!=NULL) {
m_functionFreeShape(m_pointerShape);
m_pointerShape = NULL;
@ -1013,13 +1013,13 @@ void ewol::Mesh::setShape(void* _shape) {
m_pointerShape=_shape;
}
ewol::Mesh* ewol::Mesh::keep(const std::string& _meshName) {
ewol::Mesh* object = static_cast<ewol::Mesh*>(getManager().localKeep(_meshName));
ewol::resource::Mesh* ewol::resource::Mesh::keep(const std::string& _meshName) {
ewol::resource::Mesh* object = static_cast<ewol::resource::Mesh*>(getManager().localKeep(_meshName));
if (NULL != object) {
return object;
}
EWOL_DEBUG("CREATE: Mesh: '" << _meshName << "'");
object = new ewol::Mesh(_meshName);
object = new ewol::resource::Mesh(_meshName);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh??" << _meshName);
return NULL;
@ -1028,11 +1028,11 @@ ewol::Mesh* ewol::Mesh::keep(const std::string& _meshName) {
return object;
}
void ewol::Mesh::release(ewol::Mesh*& _object) {
void ewol::resource::Mesh::release(ewol::Mesh*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

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

View File

@ -17,10 +17,10 @@
#define LOCAL_DEBUG EWOL_DEBUG
#undef __class__
#define __class__ "Program"
#define __class__ "resource::Program"
ewol::Program::Program(const std::string& _filename) :
ewol::Resource(_filename),
ewol::resource::resource::Program::Program(const std::string& _filename) :
ewol::resource::Resource(_filename),
m_exist(false),
m_program(0),
m_hasTexture(false),
@ -95,7 +95,7 @@ ewol::Program::Program(const std::string& _filename) :
updateContext();
}
ewol::Program::~Program(void) {
ewol::resource::Program::~Program(void) {
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
ewol::Shader::release(m_shaderList[iii]);
m_shaderList[iii] = 0;
@ -116,7 +116,7 @@ static void checkGlError(const char* _op, int32_t _localLine) {
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
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 :
for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) {
@ -137,7 +137,7 @@ int32_t ewol::Program::getAttribute(std::string _elementName) {
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 :
for(size_t iii=0; iii<m_elementList.size(); iii++) {
if (m_elementList[iii].m_name == _elementName) {
@ -158,7 +158,7 @@ int32_t ewol::Program::getUniform(std::string _elementName) {
return m_elementList.size()-1;
}
void ewol::Program::updateContext(void) {
void ewol::resource::Program::updateContext(void) {
if (true == m_exist) {
// Do nothing == > too dangerous ...
} 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) {
glDeleteProgram(m_program);
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_program = 0;
}
void ewol::Program::reload(void) {
void ewol::resource::Program::reload(void) {
/* TODO : ...
etk::file file(m_name, etk::FILE_TYPE_DATA);
if (false == file.Exist()) {
@ -303,10 +303,10 @@ void ewol::Program::reload(void) {
//////////////////////////////////////////////////////////////////////////////////////////////
void ewol::Program::sendAttribute(int32_t _idElem,
int32_t _nbElement,
void* _pointer,
int32_t _jumpBetweenSample) {
void ewol::resource::Program::sendAttribute(int32_t _idElem,
int32_t _nbElement,
void* _pointer,
int32_t _jumpBetweenSample) {
if (0 == m_program) {
return;
}
@ -328,12 +328,12 @@ void ewol::Program::sendAttribute(int32_t _idElem,
//checkGlError("glEnableVertexAttribArray", __LINE__);
}
void ewol::Program::sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::VirtualBufferObject* _vbo,
int32_t _index,
int32_t _jumpBetweenSample,
int32_t _offset) {
void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::resource::VirtualBufferObject* _vbo,
int32_t _index,
int32_t _jumpBetweenSample,
int32_t _offset) {
if (0 == m_program) {
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) {
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) {
return;
}
@ -393,7 +393,7 @@ void ewol::Program::uniform1f(int32_t _idElem, float _value1) {
glUniform1f(m_elementList[_idElem].m_elementId, _value1);
//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) {
return;
}
@ -407,7 +407,7 @@ void ewol::Program::uniform2f(int32_t _idElem, float _value1, float _value2) {
glUniform2f(m_elementList[_idElem].m_elementId, _value1, _value2);
//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) {
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);
//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) {
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) {
return;
}
@ -452,7 +452,7 @@ void ewol::Program::uniform1i(int32_t _idElem, int32_t _value1) {
glUniform1i(m_elementList[_idElem].m_elementId, _value1);
//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) {
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);
//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) {
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);
//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) {
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) {
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);
//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) {
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);
//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) {
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);
//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) {
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) {
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);
//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) {
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);
//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) {
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);
//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) {
return;
}
@ -686,7 +686,7 @@ void ewol::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, const int32_
#endif
void ewol::Program::use(void) {
void ewol::resource::Program::use(void) {
#ifdef PROGRAM_DISPLAY_SPEED
g_startTime = ewol::getTime();
#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) {
return;
}
@ -721,7 +721,7 @@ void ewol::Program::setTexture0(int32_t _idElem, GLint _textureOpenGlID) {
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) {
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);
if (0 == m_program) {
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::Program* object = static_cast<ewol::Program*>(getManager().localKeep(_filename));
ewol::resource::Program* object = static_cast<ewol::resource::Program*>(getManager().localKeep(_filename));
if (NULL != 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) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -18,266 +18,268 @@
#include <ewol/resources/VirtualBufferObject.h>
namespace ewol {
/**
* @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.
* This is important to note when the Program is reloaded the elements availlable can change.
*/
class progAttributeElement {
public :
std::string m_name; //!< Name of the element
GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked
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"
* The data is simple :
* <pre>
* # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ...
* # The folder is automaticly get from the program file basic folder
* filename1.vert
* filename2.frag
* filename3.vert
* filename4.frag
* </pre>
*/
class Program : public ewol::Resource {
private :
bool m_exist; //!< the file existed
GLuint m_program; //!< openGL id of the current program
std::vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded
std::vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
bool m_hasTexture; //!< A texture has been set to the current shader
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
*/
Program(const std::string& filename);
/**
* @brief Destructor, remove the current Program.
*/
virtual ~Program(void);
public:
/**
* @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"; };
/**
* @brief User request an attribute on this program.
* @note The attribute is send to the fragment shaders
* @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);
/**
* @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.
* @param[in] _nbElement Specifies the number of elements that are to be modified.
* @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* _pointer,
int32_t _jumpBetweenSample=0);
void sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::VirtualBufferObject* _vbo,
int32_t _index,
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)
* @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);
/**
* @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.
* @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] _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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
*/
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.
* @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);
/**
* @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.
* @param[in] _value1 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
* @param[in] _value2 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
*/
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.
* @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);
/**
* @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.
* @param[in] _value1 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
* @param[in] _value2 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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
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 uniform4(int32_t _idElem, const vec4& _value) { uniform4fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform2(int32_t _idElem, const ivec2& _value) { uniform2iv(_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
*/
void use(void);
/**
* @brief set the testure Id on the specify uniform element.
* @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);
/**
* @brief Stop the processing of this program
*/
void unUse(void);
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::Program*& _object);
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.
* This is important to note when the Program is reloaded the elements availlable can change.
*/
class progAttributeElement {
public :
std::string m_name; //!< Name of the element
GLint m_elementId; //!< openGl Id if this element == > can not exist ==> @ref m_isLinked
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"
* The data is simple :
* <pre>
* # Comment line ... paid attention at the space at the end of lines, they are considered like a part of the file ...
* # The folder is automaticly get from the program file basic folder
* filename1.vert
* filename2.frag
* filename3.vert
* filename4.frag
* </pre>
*/
class Program : public ewol::resource::Resource {
private :
bool m_exist; //!< the file existed
GLuint m_program; //!< openGL id of the current program
std::vector<ewol::Shader*> m_shaderList; //!< List of all the shader loaded
std::vector<ewol::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
bool m_hasTexture; //!< A texture has been set to the current shader
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
*/
Program(const std::string& filename);
/**
* @brief Destructor, remove the current Program.
*/
virtual ~Program(void);
public:
/**
* @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"; };
/**
* @brief User request an attribute on this program.
* @note The attribute is send to the fragment shaders
* @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);
/**
* @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.
* @param[in] _nbElement Specifies the number of elements that are to be modified.
* @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* _pointer,
int32_t _jumpBetweenSample=0);
void sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::VirtualBufferObject* _vbo,
int32_t _index,
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)
* @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);
/**
* @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.
* @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] _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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
*/
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.
* @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);
/**
* @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.
* @param[in] _value1 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
* @param[in] _value2 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
*/
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.
* @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);
/**
* @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.
* @param[in] _value1 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);
/**
* @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.
* @param[in] _value1 Value to send at the Uniform
* @param[in] _value2 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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
/**
* @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.
* @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);
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 uniform4(int32_t _idElem, const vec4& _value) { uniform4fv(_idElem, 1, &_value.m_floats[0]); };
inline void uniform2(int32_t _idElem, const ivec2& _value) { uniform2iv(_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
*/
void use(void);
/**
* @brief set the testure Id on the specify uniform element.
* @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);
/**
* @brief Stop the processing of this program
*/
void unUse(void);
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::Program*& _object);
};
};
};

View File

@ -15,22 +15,22 @@
#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)");
}
void ewol::Resource::removeContext(void) {
void ewol::resource::Resource::removeContext(void) {
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)");
}
void ewol::Resource::reload(void) {
void ewol::resource::Resource::reload(void) {
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();
}

View File

@ -18,50 +18,52 @@
#define MAX_RESOURCE_LEVEL (5)
namespace ewol {
class ResourceManager;
// class resources is pure virtual
class Resource : public ewol::EObject {
public:
Resource(void) :
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
Resource(const std::string& _name) :
ewol::EObject(_name),
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
virtual ~Resource(void) {
};
private:
uint32_t m_counter; //!< number of time the element was loaded.
public:
void increment(void) {
m_counter++;
};
bool decrement(void) {
m_counter--;
return (m_counter == 0)?true:false;
};
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.
public:
uint8_t getResourceLevel(void) {
return m_resourceLevel;
};
virtual void updateContext(void);
virtual void removeContext(void);
virtual void removeContextToLate(void);
virtual void reload(void);
static ewol::ResourceManager& getManager(void);
namespace resource {
class Manager;
// class resources is pure virtual
class Resource : public ewol::EObject {
public:
Resource(void) :
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
Resource(const std::string& _name) :
ewol::EObject(_name),
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
virtual ~Resource(void) {
};
private:
uint32_t m_counter; //!< number of time the element was loaded.
public:
void increment(void) {
m_counter++;
};
bool decrement(void) {
m_counter--;
return (m_counter == 0)?true:false;
};
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.
public:
uint8_t getResourceLevel(void) {
return m_resourceLevel;
};
virtual void updateContext(void);
virtual void removeContext(void);
virtual void removeContextToLate(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>
#undef __class__
#define __class__ "Shader"
#define __class__ "resource::Shader"
ewol::Shader::Shader(const std::string& _filename) :
ewol::Resource(_filename),
ewol::resource::Shader::Shader(const std::string& _filename) :
ewol::resource::Resource(_filename),
m_exist(false),
m_fileData(NULL),
m_shader(0),
@ -37,7 +37,7 @@ ewol::Shader::Shader(const std::string& _filename) :
reload();
}
ewol::Shader::~Shader(void) {
ewol::resource::Shader::~Shader(void) {
if (NULL != m_fileData) {
delete [] m_fileData;
m_fileData = NULL;
@ -57,7 +57,7 @@ static void checkGlError(const char* _op) {
#define LOG_OGL_INTERNAL_BUFFER_LEN (8192)
static char l_bufferDisplayError[LOG_OGL_INTERNAL_BUFFER_LEN] = "";
void ewol::Shader::updateContext(void) {
void ewol::resource::Shader::updateContext(void) {
if (true == m_exist) {
// Do nothing == > too dangerous ...
} 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) {
glDeleteShader(m_shader);
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_shader = 0;
}
void ewol::Shader::reload(void) {
void ewol::resource::Shader::reload(void) {
etk::FSNode file(m_name);
if (false == file.exist()) {
EWOL_ERROR("File does not Exist : \"" << file << "\"");
@ -149,14 +149,14 @@ void ewol::Shader::reload(void) {
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::Shader* object = static_cast<ewol::Shader*>(getManager().localKeep(_filename));
ewol::resource::Shader* object = static_cast<ewol::resource::Shader*>(getManager().localKeep(_filename));
if (NULL != object) {
return object;
}
// need to crate a new one ...
object = new ewol::Shader(_filename);
object = new ewol::resource::Shader(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
@ -165,11 +165,11 @@ ewol::Shader* ewol::Shader::keep(const std::string& _filename) {
return object;
}
void ewol::Shader::release(ewol::Shader*& _object) {
void ewol::resource::Shader::release(ewol::resource::Shader*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -15,71 +15,73 @@
#include <ewol/resources/Resource.h>
namespace ewol {
/**
* @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 :
bool m_exist; //!< The shader file existed and has been loaded
char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
GLuint m_shader; //!< opengl id of this element
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
*/
Shader(const std::string& _filename);
/**
* @brief Destructor, remove the current Shader
*/
virtual ~Shader(void);
public:
/**
* @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"; };
/**
* @brief get the opengl reference id of this shader.
* @return The opengl id.
*/
GLuint getGL_ID(void) { return m_shader; };
/**
* @brief get the opengl type of this shader.
* @return The type of this loaded shader.
*/
GLenum getShaderType(void) { return m_type; };
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::Shader*& _object);
namespace resource {
/**
* @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::Resource {
private :
bool m_exist; //!< The shader file existed and has been loaded
char* m_fileData; //!< A copy of the data loaded from the file (usefull only when opengl context is removed)
GLuint m_shader; //!< opengl id of this element
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
*/
Shader(const std::string& _filename);
/**
* @brief Destructor, remove the current Shader
*/
virtual ~Shader(void);
public:
/**
* @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"; };
/**
* @brief get the opengl reference id of this shader.
* @return The opengl id.
*/
GLuint getGL_ID(void) { return m_shader; };
/**
* @brief get the opengl type of this shader.
* @return The type of this loaded shader.
*/
GLenum getShaderType(void) { return m_type; };
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::Shader*& _object);
};
};
};

View File

@ -14,7 +14,7 @@
#include <ewol/renderer/eContext.h>
#undef __class__
#define __class__ "Texture"
#define __class__ "resource::Texture"
/**
* @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(_filename) {
ewol::resource::Texture::Texture(const std::string& _filename) :
ewol::resource::Resource(_filename) {
addObjectType("ewol::Texture");
m_loaded = false;
m_texId = 0;
m_endPointSize.setValue(1.0,1.0);
}
ewol::Texture::Texture(void) {
ewol::resource::Texture::Texture(void) {
addObjectType("ewol::Texture");
m_loaded = false;
m_texId = 0;
m_endPointSize.setValue(1.0,1.0);
}
ewol::Texture::~Texture(void) {
ewol::resource::Texture::~Texture(void) {
removeContext();
}
void ewol::Texture::updateContext(void) {
void ewol::resource::Texture::updateContext(void) {
if (false == m_loaded) {
// Request a new texture at openGl :
glGenTextures(1, &m_texId);
@ -84,7 +84,7 @@ void ewol::Texture::updateContext(void) {
m_loaded = true;
}
void ewol::Texture::removeContext(void) {
void ewol::resource::Texture::removeContext(void) {
if (true == m_loaded) {
// Request remove texture ...
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_texId=0;
}
void ewol::Texture::flush(void) {
void ewol::resource::Texture::flush(void) {
// request to the manager to be call at the next update ...
getManager().update(this);
}
void ewol::Texture::setImageSize(ivec2 _newSize) {
void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
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 ....
ewol::Texture* object = new ewol::Texture();
ewol::resource::Texture* object = new ewol::resource::Texture();
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL;
@ -119,11 +119,11 @@ ewol::Texture* ewol::Texture::keep(void) {
return object;
}
void ewol::Texture::release(ewol::Texture*& _object) {
void ewol::resource::Texture::release(ewol::resource::Texture*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

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

View File

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

View File

@ -24,90 +24,90 @@ namespace ewol {
};
etk::CCout& operator <<(etk::CCout& _os, enum ewol::font::mode _obj);
class TexturedFont : public ewol::Texture {
private:
std::string m_fileName[4];
int32_t m_size;
int32_t m_height[4];
// specific element to have the the know if the specify element is known...
// == > otherwise I can just generate italic ...
// == > Bold is a little more complicated (maybe with the bordersize)
ewol::FontBase* m_font[4];
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
public:
std::vector<GlyphProperty> m_listElement[4];
private:
// for the texture generation :
ivec2 m_lastGlyphPos[4];
int32_t m_lastRawHeigh[4];
protected:
TexturedFont(const std::string& _fontName);
~TexturedFont(void);
public:
const char* getType(void) {
return "ewol::TexturedFont";
};
/**
* @brief get the display height of this font
* @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];
};
/**
* @brief get the font height (user friendly)
* @return Dimention of the font the user requested
*/
int32_t getFontSize(void) {
return m_size;
};
/**
* @brief get the ID of a unicode charcode
* @param[in] _charcode The unicodeValue
* @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);
/**
* @brief get the pointer on the coresponding glyph
* @param[in] _charcode The unicodeValue
* @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);
/**
* @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.
* @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];
};
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::TexturedFont*& _object);
private:
/**
* @brief add a glyph in a texture font.
* @param[in] _val Char value to add.
* @return true if the image size have change, false otherwise
*/
bool addGlyph(const char32_t& _val);
namespace resource {
class TexturedFont : public ewol::resource::Texture {
private:
std::string m_fileName[4];
int32_t m_size;
int32_t m_height[4];
// specific element to have the the know if the specify element is known...
// == > otherwise I can just generate italic ...
// == > Bold is a little more complicated (maybe with the bordersize)
ewol::FontBase* m_font[4];
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
public:
std::vector<GlyphProperty> m_listElement[4];
private:
// for the texture generation :
ivec2 m_lastGlyphPos[4];
int32_t m_lastRawHeigh[4];
protected:
TexturedFont(const std::string& _fontName);
~TexturedFont(void);
public:
const char* getType(void) {
return "ewol::TexturedFont";
};
/**
* @brief get the display height of this font
* @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];
};
/**
* @brief get the font height (user friendly)
* @return Dimention of the font the user requested
*/
int32_t getFontSize(void) {
return m_size;
};
/**
* @brief get the ID of a unicode charcode
* @param[in] _charcode The unicodeValue
* @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);
/**
* @brief get the pointer on the coresponding glyph
* @param[in] _charcode The unicodeValue
* @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);
/**
* @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.
* @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];
};
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::TexturedFont*& _object);
private:
/**
* @brief add a glyph in a texture font.
* @param[in] _val Char value to add.
* @return true if the image size have change, false otherwise
*/
bool addGlyph(const char32_t& _val);
};
};
};
#endif

View File

@ -13,9 +13,9 @@
#include <ewol/renderer/eContext.h>
#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) {
addObjectType("ewol::VirtualBufferObject");
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::VirtualBufferObject::~VirtualBufferObject(void) {
ewol::resource::VirtualBufferObject::~VirtualBufferObject(void) {
removeContext();
}
void ewol::VirtualBufferObject::retreiveData(void) {
void ewol::resource::VirtualBufferObject::retreiveData(void) {
EWOL_ERROR("TODO ... ");
}
void ewol::VirtualBufferObject::updateContext(void) {
void ewol::resource::VirtualBufferObject::updateContext(void) {
if (false == m_exist) {
// Allocate and assign a Vertex Array Object to our handle
glGenBuffers(m_nbVBO, m_vbo);
@ -55,7 +55,7 @@ void ewol::VirtualBufferObject::updateContext(void) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
void ewol::VirtualBufferObject::removeContext(void) {
void ewol::resource::VirtualBufferObject::removeContext(void) {
if (true == m_exist) {
EWOL_INFO("VBO: remove [" << getId() << "] OGl_Id=" << m_vbo[0]
<< "/" << 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;
for (size_t iii=0; iii<NB_VBO_MAX; iii++) {
m_vbo[iii] = 0;
}
}
void ewol::VirtualBufferObject::reload(void) {
void ewol::resource::VirtualBufferObject::reload(void) {
removeContext();
updateContext();
}
void ewol::VirtualBufferObject::flush(void) {
void ewol::resource::VirtualBufferObject::flush(void) {
// request to the manager to be call at the next update ...
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_buffer[_id].push_back(_data.x());
m_buffer[_id].push_back(_data.y());
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()) {
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]);
}
int32_t ewol::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) {
int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec3(int32_t _id) {
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_buffer[_id].push_back(_data.x());
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()) {
return vec2(0,0);
}
@ -120,13 +120,13 @@ vec2 ewol::VirtualBufferObject::getOnBufferVec2(int32_t _id, int32_t _elementID)
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;
}
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 ....
ewol::VirtualBufferObject* object = new ewol::VirtualBufferObject(_number);
ewol::resource::VirtualBufferObject* object = new ewol::resource::VirtualBufferObject(_number);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??VBO??");
return NULL;
@ -135,11 +135,11 @@ ewol::VirtualBufferObject* ewol::VirtualBufferObject::keep(int32_t _number) {
return object;
}
void ewol::VirtualBufferObject::release(ewol::VirtualBufferObject*& _object) {
void ewol::resource::VirtualBufferObject::release(ewol::resource::VirtualBufferObject*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
ewol::resource::Resource* object2 = static_cast<ewol::resource::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -18,97 +18,99 @@
#define NB_VBO_MAX (20)
namespace ewol {
/**
* @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 :
size_t m_nbVBO;
bool m_exist; //!< This data is availlable in the Graphic card
GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO
bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ...
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 : ???
*/
VirtualBufferObject(int32_t _number);
/**
* @brief Destructor of this VBO.
*/
virtual ~VirtualBufferObject(void);
public:
/**
* @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"; };
/**
* @brief get the real openGL ID.
* @return the Ogl id reference of this VBO.
*/
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
* @return A reference on the data.
*/
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.
* @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);
int32_t sizeOnBufferVec3(int32_t id);
/**
* @brief push data on a buffer with a custum type :
* @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);
int32_t sizeOnBufferVec2(int32_t id);
/**
* @brief get the data from the graphic card.
*/
void retreiveData(void);
/**
* @brief Send the data to the graphic card.
*/
void flush(void);
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::VirtualBufferObject*& _object);
namespace resource {
/**
* @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::Resource {
private :
size_t m_nbVBO;
bool m_exist; //!< This data is availlable in the Graphic card
GLuint m_vbo[NB_VBO_MAX]; //!< openGl ID of this VBO
bool m_vboUsed[NB_VBO_MAX]; //!< true if the VBO is allocated or used ...
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 : ???
*/
VirtualBufferObject(int32_t _number);
/**
* @brief Destructor of this VBO.
*/
virtual ~VirtualBufferObject(void);
public:
/**
* @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"; };
/**
* @brief get the real openGL ID.
* @return the Ogl id reference of this VBO.
*/
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
* @return A reference on the data.
*/
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.
* @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);
int32_t sizeOnBufferVec3(int32_t id);
/**
* @brief push data on a buffer with a custum type :
* @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);
int32_t sizeOnBufferVec2(int32_t id);
/**
* @brief get the data from the graphic card.
*/
void retreiveData(void);
/**
* @brief Send the data to the graphic card.
*/
void flush(void);
/**
* @brief This load/reload the data in the opengl context, needed when removed previously.
*/
void updateContext(void);
/**
* @brief remove the data from the opengl context.
*/
void removeContext(void);
/**
* @brief Special android spec! It inform us that all context is removed and after notify us...
*/
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.
*/
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @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);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::VirtualBufferObject*& _object);
};
};
};
#endif

View File

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

View File

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

View File

@ -10,59 +10,61 @@
#define __EWOL_FONT_KERNING_H__
namespace ewol {
/**
* @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
* the "VA" has 2 letter that overlap themself. This name Kerning
*
* Without Kerning :
*
* \ / /\
* \ / / \
* \ / / \
* \ / /______\
* \ / / \
* \/ / \
* v v a a
*
* With Kerning :
*
* \ / /\
* \ / / \
* \ / / \
* \ / /______\
* \ / / \
* \/ / \
* v a v a
*
*/
class Kerning {
public:
char32_t m_UVal; //!< unicode value (the previous character that must be before)
float m_value; //!< kerning real offset
public:
/**
* @brief Simple constructor that allow to allocate the std::vector element
*/
Kerning(void) :
m_UVal(0),
m_value(0) {
};
/**
* @brief Normal constructor
* @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),
m_value(_value) {
};
/**
* @brief normal destructor
*/
~Kerning(void) { };
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
* the "VA" has 2 letter that overlap themself. This name Kerning
*
* Without Kerning :
*
* \ / /\
* \ / / \
* \ / / \
* \ / /______\
* \ / / \
* \/ / \
* v v a a
*
* With Kerning :
*
* \ / /\
* \ / / \
* \ / / \
* \ / /______\
* \ / / \
* \/ / \
* v a v a
*
*/
class Kerning {
public:
char32_t m_UVal; //!< unicode value (the previous character that must be before)
float m_value; //!< kerning real offset
public:
/**
* @brief Simple constructor that allow to allocate the std::vector element
*/
Kerning(void) :
m_UVal(0),
m_value(0) {
};
/**
* @brief Normal constructor
* @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),
m_value(_value) {
};
/**
* @brief normal destructor
*/
~Kerning(void) { };
};
};
};

View File

@ -14,17 +14,17 @@
#define __class__ "Button"
const char* const widget::Button::eventPressed = "pressed";
const char* const widget::Button::eventDown = "down";
const char* const widget::Button::eventUp = "up";
const char* const widget::Button::eventEnter = "enter";
const char* const widget::Button::eventLeave = "leave";
const char* const widget::Button::eventValue = "value";
const char* const ewol::widget::Button::eventPressed = "pressed";
const char* const ewol::widget::Button::eventDown = "down";
const char* const ewol::widget::Button::eventUp = "up";
const char* const ewol::widget::Button::eventEnter = "enter";
const char* const ewol::widget::Button::eventLeave = "leave";
const char* const ewol::widget::Button::eventValue = "value";
const char* const widget::Button::configToggle = "toggle";
const char* const widget::Button::configLock = "lock";
const char* const widget::Button::configValue = "value";
const char* const widget::Button::configShaper = "shaper";
const char* const ewol::widget::Button::configToggle = "toggle";
const char* const ewol::widget::Button::configLock = "lock";
const char* const ewol::widget::Button::configValue = "value";
const char* const ewol::widget::Button::configShaper = "shaper";
// DEFINE for the shader display system :
@ -35,23 +35,23 @@ const char* const widget::Button::configShaper = "shaper";
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);
}
widget::Button::Button(const std::string& _shaperName) :
ewol::widget::Button::Button(const std::string& _shaperName) :
m_shaper(_shaperName),
m_value(false),
m_lock(widget::Button::lockNone),
m_lock(ewol::widget::Button::lockNone),
m_toggleMode(false),
m_mouseHover(false),
m_buttonPressed(false),
m_selectableAreaPos(0,0),
m_selectableAreaSize(0,0) {
addObjectType("widget::Button");
addObjectType("ewol::widget::Button");
// by default set no widget :
m_subWidget[0] = 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);
markToRedraw();
}
void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
void ewol::widget::Button::setSubWidget(ewol::Widget* _subWidget) {
int32_t idWidget=0;
if (NULL!=m_subWidget[idWidget]) {
m_subWidget[idWidget]->removeObject();
@ -100,7 +100,7 @@ void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
markToRedraw();
}
void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
void ewol::widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) {
m_subWidget[idWidget]->removeObject();
@ -112,7 +112,7 @@ void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
requestUpdateSize();
}
void widget::Button::calculateSize(const vec2& _availlable) {
void ewol::widget::Button::calculateSize(const vec2& _availlable) {
vec2 padding = m_shaper.getPadding();
// set minimal size
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 minimumSizeBase(0,0);
vec2 minimumSizeToggle(0,0);
@ -182,7 +182,7 @@ void widget::Button::calculateMinMaxSize(void) {
markToRedraw();
}
void widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) {
void ewol::widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){
// widget is hidden ...
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)
m_shaper.draw();
}
void widget::Button::onRegenerateDisplay(void) {
void ewol::widget::Button::onRegenerateDisplay(void) {
if (true == needRedraw()) {
vec2 padding = m_shaper.getPadding();
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) {
m_lock = _lock;
if(widget::Button::lockAccess == _lock) {
if(ewol::widget::Button::lockAccess == _lock) {
m_buttonPressed = 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) {
m_value = _val;
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) {
m_toggleMode = _togg;
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 :
if(widget::Button::lockAccess == m_lock) {
if(ewol::widget::Button::lockAccess == m_lock) {
return false;
}
bool previousHoverState = m_mouseHover;
@ -301,9 +301,9 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
}
if(ewol::keyEvent::statusSingle == _event.getStatus()) {
if( ( m_value == true
&& widget::Button::lockWhenPressed == m_lock)
&& ewol::widget::Button::lockWhenPressed == m_lock)
|| ( m_value == false
&& widget::Button::lockWhenReleased == m_lock) ) {
&& ewol::widget::Button::lockWhenReleased == m_lock) ) {
// nothing to do : Lock mode ...
// user might set himself the new correct value with @ref setValue(xxx)
} else {
@ -316,7 +316,7 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
if( false == m_toggleMode
&& true == m_value) {
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));
}
}
@ -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));
if( _event.getType() == ewol::keyEvent::keyboardChar
&& _event.getStatus() == ewol::keyEvent::statusDown
@ -343,7 +343,7 @@ bool widget::Button::onEventEntry(const ewol::EventEntry& _event) {
return false;
}
void widget::Button::CheckStatus(void) {
void ewol::widget::Button::CheckStatus(void) {
if (true == m_buttonPressed) {
changeStatusIn(STATUS_PRESSED);
} 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) ) {
periodicCallEnable();
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) ) {
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);
if (NULL!=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) {
return false;
}
@ -447,7 +447,7 @@ bool widget::Button::loadXML(exml::Element* _element) {
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)) {
return true;
}
@ -481,7 +481,7 @@ bool widget::Button::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -19,155 +19,156 @@
#include <ewol/widget/WidgetManager.h>
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
*/
class Button : public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Event list of properties
static const char* const eventPressed;
static const char* const eventDown;
static const char* const eventUp;
static const char* const eventEnter;
static const char* const eventLeave;
static const char* const eventValue;
// Config list of properties
static const char* const configToggle;
static const char* const configLock;
static const char* const configValue;
static const char* const configShaper;
enum buttonLock{
lockNone, //!< normal status of the button
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
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.
public:
/**
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
Button(const std::string& _shaperName="THEME:GUI:widgetButton.conf");
/**
* @brief Destructor
*/
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
*/
void setShaperName(const std::string& _shaperName);
protected:
ewol::Widget* m_subWidget[2]; //!< subwidget of the button
public:
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add normal
*/
void setSubWidget(ewol::Widget* _subWidget);
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add Toggle
*/
void setSubWidgetToggle(ewol::Widget* _subWidget);
/**
* @brief get the current displayed composition
* @return The base widget
*/
ewol::Widget* getSubWidget(void) const {
return m_subWidget[0];
};
/**
* @brief get the current displayed composition
* @return The toggle widget
*/
ewol::Widget* getSubWidgetToggle(void) const {
return m_subWidget[1];
};
protected:
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
* @param[in] _val New value of the button
*/
void setValue(bool _val);
/**
* @brief get the current button value.
* @return True : The button is pressed.
* @return false : The button is released.
*/
bool getValue(void) const {
return m_value;
};
protected:
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
*/
void setLock(enum buttonLock _lock);
/**
* @brief get the current button lock value.
* @return The requested lock mode
*/
enum buttonLock getLock(void) const {
return m_lock;
};
protected:
bool m_toggleMode; //!< The button is able to toggle.
public:
/**
* @brief change the toggle mode.
* @param[in] _togg New toggle mode
*/
void setToggleMode(bool _togg);
/**
* @brief get the current toggle mode.
* @return the current toggle mode.
*/
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)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
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
*/
void changeStatusIn(int32_t _newStatusId);
/**
* @brief update the status with the internal satte of the button ...
*/
void CheckStatus(void);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void calculateSize(const vec2& _availlable);
virtual void onRegenerateDisplay(void);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual bool loadXML(exml::Element* _node);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
private: // derived function
virtual void periodicCall(const ewol::EventTime& _event);
};
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
*/
class Button : public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Event list of properties
static const char* const eventPressed;
static const char* const eventDown;
static const char* const eventUp;
static const char* const eventEnter;
static const char* const eventLeave;
static const char* const eventValue;
// Config list of properties
static const char* const configToggle;
static const char* const configLock;
static const char* const configValue;
static const char* const configShaper;
enum buttonLock{
lockNone, //!< normal status of the button
lockWhenPressed, //!< When the state is set in pressed, the status stay in this one
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.
public:
/**
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
Button(const std::string& _shaperName="THEME:GUI:widgetButton.conf");
/**
* @brief Destructor
*/
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
*/
void setShaperName(const std::string& _shaperName);
protected:
ewol::Widget* m_subWidget[2]; //!< subwidget of the button
public:
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add normal
*/
void setSubWidget(ewol::Widget* _subWidget);
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add Toggle
*/
void setSubWidgetToggle(ewol::Widget* _subWidget);
/**
* @brief get the current displayed composition
* @return The base widget
*/
ewol::Widget* getSubWidget(void) const {
return m_subWidget[0];
};
/**
* @brief get the current displayed composition
* @return The toggle widget
*/
ewol::Widget* getSubWidgetToggle(void) const {
return m_subWidget[1];
};
protected:
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
* @param[in] _val New value of the button
*/
void setValue(bool _val);
/**
* @brief get the current button value.
* @return True : The button is pressed.
* @return false : The button is released.
*/
bool getValue(void) const {
return m_value;
};
protected:
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
*/
void setLock(enum buttonLock _lock);
/**
* @brief get the current button lock value.
* @return The requested lock mode
*/
enum buttonLock getLock(void) const {
return m_lock;
};
protected:
bool m_toggleMode; //!< The button is able to toggle.
public:
/**
* @brief change the toggle mode.
* @param[in] _togg New toggle mode
*/
void setToggleMode(bool _togg);
/**
* @brief get the current toggle mode.
* @return the current toggle mode.
*/
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)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
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
*/
void changeStatusIn(int32_t _newStatusId);
/**
* @brief update the status with the internal satte of the button ...
*/
void CheckStatus(void);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void calculateSize(const vec2& _availlable);
virtual void onRegenerateDisplay(void);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual bool loadXML(exml::Element* _node);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
private: // derived function
virtual void periodicCall(const ewol::EventTime& _event);
};
};
#endif

View File

@ -31,18 +31,18 @@ extern const char * const ewolEventButtonColorChange = "ewol-Button-Color-Cha
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);
}
widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperName) :
ewol::widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperName) :
m_shaper(_shaperName),
m_textColorFg(_baseColor),
m_widgetContextMenu(NULL) {
addObjectType("widget::ButtonColor");
addObjectType("ewol::widget::ButtonColor");
addEventId(ewolEventButtonColorChange);
changeStatusIn(STATUS_UP);
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);
}
void widget::ButtonColor::calculateMinMaxSize(void) {
void ewol::widget::ButtonColor::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString();
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_text.draw();
}
void widget::ButtonColor::onRegenerateDisplay(void) {
void ewol::widget::ButtonColor::onRegenerateDisplay(void) {
if (needRedraw() == false) {
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;
if(ewol::keyEvent::statusLeave == _event.getStatus()) {
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;
markToRedraw();
}
etk::Color<> widget::ButtonColor::getValue(void) {
etk::Color<> ewol::widget::ButtonColor::getValue(void) {
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());
if (_msg.getMessage() == ewolEventColorChooserChange) {
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) ) {
periodicCallEnable();
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) ) {
periodicCallDisable();
}

View File

@ -20,64 +20,66 @@
extern const char * const ewolEventButtonColorChange;
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class ButtonColor : public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Text m_text; //!< Compositing Test display.
etk::Color<> m_textColorFg; //!< Current color.
widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu.
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
vec2 m_selectableAreaSize; //!< size of the event positions
public:
/**
* @brief Main constructor.
* @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");
/**
* @brief Main destructor.
*/
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.
*/
void setShaperName(std::string _shaperName);
/**
* @brief get the current color of the color selection widget
* @return The current color
*/
etk::Color<> getValue(void);
/**
* @brief Specify the current color.
* @param[in] _color The new display color.
*/
void setValue(etk::Color<> _color);
protected: // Derived function
virtual void onDraw(void);
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
private:
/**
* @brief internal system to change the property of the current status
* @param[in] _newStatusId new state
*/
void changeStatusIn(int32_t _newStatusId);
// Derived function
virtual void periodicCall(const ewol::EventTime& _event);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class ButtonColor : public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper; //!< Compositing theme.
ewol::Text m_text; //!< Compositing Test display.
etk::Color<> m_textColorFg; //!< Current color.
widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu.
bool m_mouseHover; //!< Flag to know where the mouse is (inside the displayed widget (if not fill)).
bool m_buttonPressed; //!< Flag to know if the button is curently pressed.
// hover area :
vec2 m_selectableAreaPos; //!< Start position of the events
vec2 m_selectableAreaSize; //!< size of the event positions
public:
/**
* @brief Main constructor.
* @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");
/**
* @brief Main destructor.
*/
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.
*/
void setShaperName(std::string _shaperName);
/**
* @brief get the current color of the color selection widget
* @return The current color
*/
etk::Color<> getValue(void);
/**
* @brief Specify the current color.
* @param[in] _color The new display color.
*/
void setValue(etk::Color<> _color);
protected: // Derived function
virtual void onDraw(void);
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
private:
/**
* @brief internal system to change the property of the current status
* @param[in] _newStatusId new state
*/
void changeStatusIn(int32_t _newStatusId);
// 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"
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);
}
widget::CheckBox::CheckBox(const std::string& _newLabel) {
addObjectType("widget::CheckBox");
ewol::widget::CheckBox::CheckBox(const std::string& _newLabel) {
addObjectType("ewol::widget::CheckBox");
m_label = _newLabel;
addEventId(ewolEventCheckBoxClicked);
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);
float boxSize = etk_max(20, minSize.y()) + 5;
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;
markToRedraw();
}
void widget::CheckBox::setValue(bool _val) {
void ewol::widget::CheckBox::setValue(bool _val) {
if (m_value == _val) {
return;
}
@ -62,16 +62,16 @@ void widget::CheckBox::setValue(bool _val) {
markToRedraw();
}
bool widget::CheckBox::getValue(void) {
bool ewol::widget::CheckBox::getValue(void) {
return m_value;
}
void widget::CheckBox::onDraw(void) {
void ewol::widget::CheckBox::onDraw(void) {
m_oObjectDecoration.draw();
m_oObjectText.draw();
}
void widget::CheckBox::onRegenerateDisplay(void) {
void ewol::widget::CheckBox::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_oObjectDecoration.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 ...");
if (1 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -118,7 +118,7 @@ bool widget::CheckBox::onEventInput(const ewol::EventInput& _event) {
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));
if( _event.getType() == ewol::keyEvent::keyboardChar
&& _event.getStatus() == ewol::keyEvent::statusDown

View File

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

View File

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

View File

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

View File

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

View File

@ -13,74 +13,75 @@
#include <ewol/debug.h>
#include <ewol/widget/Container.h>
namespace widget
{
/**
* @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
*/
class Composer : public widget::Container {
public:
enum composerMode {
None,
String,
file
};
public:
/**
* @brief Constructor
*/
Composer(void);
/**
* @brief Constructor
* @param[in] _mode mode of parsing the string
* @param[in] _data file/directString data to generate compositing of the widget..
*/
Composer(enum composerMode _mode, const std::string& _data);
/**
* @brief Destructor
*/
~Composer(void);
/**
* @brief load a composition with a file
* @param[in] _fileName Name of the file
* @return true == > all done OK
* @return false == > some error occured
*/
bool loadFromFile(const std::string& _fileName);
/**
* @brief load a composition with a file
* @param[in] _composerXmlString xml to parse directly
* @return true == > all done OK
* @return false == > some error occured
*/
bool loadFromString(const std::string& _composerXmlString);
/**
* @brief Register an Event an named widget. @see registerOnEvent
* @param[in] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object.
* @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 ...
* @note : To used when herited from this object.
*/
void registerOnEventNameWidget(const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const std::string& _overloadData="");
/**
* @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] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object.
* @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 ...
* @note : To used when NOT herited from this object.
*/
void registerOnEventNameWidget(ewol::EObject * _destinationObject,
const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const std::string& _overloadData="");
namespace ewol {
namespace widget {
/**
* @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
*/
class Composer : public widget::Container {
public:
enum composerMode {
None,
String,
file
};
public:
/**
* @brief Constructor
*/
Composer(void);
/**
* @brief Constructor
* @param[in] _mode mode of parsing the string
* @param[in] _data file/directString data to generate compositing of the widget..
*/
Composer(enum composerMode _mode, const std::string& _data);
/**
* @brief Destructor
*/
~Composer(void);
/**
* @brief load a composition with a file
* @param[in] _fileName Name of the file
* @return true == > all done OK
* @return false == > some error occured
*/
bool loadFromFile(const std::string& _fileName);
/**
* @brief load a composition with a file
* @param[in] _composerXmlString xml to parse directly
* @return true == > all done OK
* @return false == > some error occured
*/
bool loadFromString(const std::string& _composerXmlString);
/**
* @brief Register an Event an named widget. @see registerOnEvent
* @param[in] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object.
* @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 ...
* @note : To used when herited from this object.
*/
void registerOnEventNameWidget(const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const std::string& _overloadData="");
/**
* @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] _subWidgetName Name of the subWidget.
* @param[in] _eventId Event generate inside the object.
* @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 ...
* @note : To used when NOT herited from this object.
*/
void registerOnEventNameWidget(ewol::EObject * _destinationObject,
const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const std::string& _overloadData="");
};
};
};

View File

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

View File

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

View File

@ -15,19 +15,19 @@
#define __class__ "ContainerN"
widget::ContainerN::ContainerN(void) :
ewol::widget::ContainerN::ContainerN(void) :
m_lockExpand(false,false),
m_subExpend(false,false) {
addObjectType("widget::ContainerN");
addObjectType("ewol::widget::ContainerN");
// nothing to do ...
}
widget::ContainerN::~ContainerN(void) {
ewol::widget::ContainerN::~ContainerN(void) {
subWidgetRemoveAll();
}
bvec2 widget::ContainerN::canExpand(void) {
bvec2 ewol::widget::ContainerN::canExpand(void) {
bvec2 res = m_userExpand;
if (false == m_lockExpand.x()) {
if (true == m_subExpend.x()) {
@ -43,7 +43,7 @@ bvec2 widget::ContainerN::canExpand(void) {
return res;
}
void widget::ContainerN::lockExpand(const bvec2& _lockExpand) {
void ewol::widget::ContainerN::lockExpand(const bvec2& _lockExpand) {
if (_lockExpand != m_lockExpand) {
m_lockExpand = _lockExpand;
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) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... ");
return -1;
@ -67,7 +67,7 @@ int32_t widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) {
return _newWidget->getId();
}
int32_t widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... ");
return -1;
@ -81,7 +81,7 @@ int32_t widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
return _newWidget->getId();
}
void widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
void ewol::widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
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) {
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();
// the size automaticly decrement with the auto call of the onObjectRemove function
while (m_subWidget.size() > 0 ) {
@ -140,7 +140,7 @@ void widget::ContainerN::subWidgetRemoveAll(void) {
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
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
@ -154,7 +154,7 @@ void widget::ContainerN::subWidgetRemoveAllDelayed(void) {
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);
if (NULL!=tmpUpperWidget) {
return tmpUpperWidget;
@ -170,7 +170,7 @@ ewol::Widget* widget::ContainerN::getWidgetNamed(const std::string& _widgetName)
return NULL;
}
void widget::ContainerN::onObjectRemove(ewol::EObject* _removeObject) {
void ewol::widget::ContainerN::onObjectRemove(ewol::EObject* _removeObject) {
// First step call parrent :
ewol::Widget::onObjectRemove(_removeObject);
// 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){
// widget is hidden ...
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;
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
@ -211,7 +211,7 @@ void widget::ContainerN::calculateSize(const vec2& _availlable) {
markToRedraw();
}
void widget::ContainerN::calculateMinMaxSize(void) {
void ewol::widget::ContainerN::calculateMinMaxSize(void) {
m_subExpend.setValue(false, false);
m_minSize.setValue(0,0);
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);
}
void widget::ContainerN::onRegenerateDisplay(void) {
void ewol::widget::ContainerN::onRegenerateDisplay(void) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
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()) {
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) {
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) {
ewol::Widget::setOffset(_newVal);
// recalculate the new sise and position of sub widget ...

View File

@ -13,84 +13,86 @@
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
* @brief the Cotainer widget is a widget that have an only one subWidget
*/
class ContainerN : public ewol::Widget {
protected:
std::vector<ewol::Widget*> m_subWidget;
public:
/**
* @brief Constructor
*/
ContainerN(void);
/**
* @brief Destructor
*/
~ContainerN(void);
protected:
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
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
*/
void lockExpand(const bvec2& _lockExpand);
// herited function
virtual bvec2 canExpand(void);
public:
/**
* @brief remove all sub element from the widget.
*/
virtual void subWidgetRemoveAll(void);
/**
* @brief remove all sub element from the widget (delayed to prevent remove in the callbback).
*/
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
* @return the ID of the set element
*/
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
inline int32_t subWidgetAddBack(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
* @return the ID of the set element
*/
virtual int32_t subWidgetAddStart(ewol::Widget* _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.
*/
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.
*/
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
public:// Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
* @brief the Cotainer widget is a widget that have an only one subWidget
*/
class ContainerN : public ewol::Widget {
protected:
std::vector<ewol::Widget*> m_subWidget;
public:
/**
* @brief Constructor
*/
ContainerN(void);
/**
* @brief Destructor
*/
~ContainerN(void);
protected:
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
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
*/
void lockExpand(const bvec2& _lockExpand);
// herited function
virtual bvec2 canExpand(void);
public:
/**
* @brief remove all sub element from the widget.
*/
virtual void subWidgetRemoveAll(void);
/**
* @brief remove all sub element from the widget (delayed to prevent remove in the callbback).
*/
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
* @return the ID of the set element
*/
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
inline int32_t subWidgetAddBack(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
* @return the ID of the set element
*/
virtual int32_t subWidgetAddStart(ewol::Widget* _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.
*/
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.
*/
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
public:// Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};
};
};

View File

@ -16,23 +16,23 @@
#define __class__ "ContextMenu"
const char* const widget::ContextMenu::configArrowPosition = "arrow-position";
const char* const widget::ContextMenu::configArrowMode = "arrow-mode";
const char* const widget::ContextMenu::configShaper = "shaper";
const char* const ewol::widget::ContextMenu::configArrowPosition = "arrow-position";
const char* const ewol::widget::ContextMenu::configArrowMode = "arrow-mode";
const char* const ewol::widget::ContextMenu::configShaper = "shaper";
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);
}
widget::ContextMenu::ContextMenu(const std::string& _shaperName) :
ewol::widget::ContextMenu::ContextMenu(const std::string& _shaperName) :
m_shaper(_shaperName) {
addObjectType("widget::ContextMenu");
addObjectType("ewol::widget::ContextMenu");
// add basic configurations :
registerConfig(configArrowPosition, "vec2", NULL, "position of the arrow");
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);
}
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);
markToRedraw();
}
void widget::ContextMenu::calculateSize(const vec2& _availlable) {
void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display :
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...
widget::Container::calculateMinMaxSize();
// 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_shaper.draw();
}
void widget::ContextMenu::onRegenerateDisplay(void) {
void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
// call upper class :
widget::Container::onRegenerateDisplay();
if (needRedraw() == false) {
@ -214,7 +214,7 @@ void widget::ContextMenu::onRegenerateDisplay(void) {
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 (NULL != widget::Container::getWidgetAtPos(_event.getPos())) {
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);
m_arrawBorder = _position;
m_arrowPos = _arrowPos;
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);
if (NULL != 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)) {
return true;
}
@ -279,7 +279,7 @@ bool widget::ContextMenu::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -17,58 +17,60 @@
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class ContextMenu : public widget::Container {
public:
enum markPosition {
markTop,
markRight,
markButtom,
markLeft,
markNone
};
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configArrowPosition;
static const char* const configArrowMode;
static const char* const configShaper;
public:
ContextMenu(const std::string& _shaperName="THEME:GUI:widgetContextMenu.conf");
virtual ~ContextMenu(void);
private:
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
*/
void setShaperName(const std::string& _shaperName);
private:
// TODO : Rework the displayer ....
ewol::Drawing m_compositing;
etk::Color<> m_colorBackGroung;
etk::Color<> m_colorBorder;
float m_offset;
private:
vec2 m_arrowPos;
enum markPosition m_arrawBorder;
public:
void setPositionMark(enum markPosition position, vec2 arrowPos);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void calculateSize(const vec2& availlable);
virtual void calculateMinMaxSize(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class ContextMenu : public ewol::widget::Container {
public:
enum markPosition {
markTop,
markRight,
markButtom,
markLeft,
markNone
};
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configArrowPosition;
static const char* const configArrowMode;
static const char* const configShaper;
public:
ContextMenu(const std::string& _shaperName="THEME:GUI:widgetContextMenu.conf");
virtual ~ContextMenu(void);
private:
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
*/
void setShaperName(const std::string& _shaperName);
private:
// TODO : Rework the displayer ....
ewol::Drawing m_compositing;
etk::Color<> m_colorBackGroung;
etk::Color<> m_colorBorder;
float m_offset;
private:
vec2 m_arrowPos;
enum markPosition m_arrawBorder;
public:
void setPositionMark(enum markPosition position, vec2 arrowPos);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void calculateSize(const vec2& availlable);
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)
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);
}
const char * const widget::Entry::eventClick = "click";
const char * const widget::Entry::eventEnter = "enter";
const char * const widget::Entry::eventModify = "modify";
const char * const ewol::widget::Entry::eventClick = "click";
const char * const ewol::widget::Entry::eventEnter = "enter";
const char * const ewol::widget::Entry::eventModify = "modify";
const char* const widget::Entry::configMaxChar = "max";
const char* const widget::Entry::configRegExp = "regExp";
const char* const widget::Entry::configColorFg = "color";
const char* const widget::Entry::configColorBg = "background";
const char* const widget::Entry::configEmptyMessage = "emptytext";
const char* const ewol::widget::Entry::configMaxChar = "max";
const char* const ewol::widget::Entry::configRegExp = "regExp";
const char* const ewol::widget::Entry::configColorFg = "color";
const char* const ewol::widget::Entry::configColorBg = "background";
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_data(""),
m_maxCharacter(0x7FFFFFFF),
@ -59,7 +59,7 @@ widget::Entry::Entry(std::string _newData) :
m_textColorFg(etk::color::black),
m_textColorBg(etk::color::white),
m_textWhenNothing("") {
addObjectType("widget::Entry");
addObjectType("ewol::widget::Entry");
m_textColorBg.setA(0xAF);
setCanHaveFocus(true);
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) {
m_maxCharacter = 0x7FFFFFFF;
} 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
ewol::Widget::calculateMinMaxSize();
// 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;
if ((int64_t)newData.size() > 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_oObjectText.draw();
}
void widget::Entry::onRegenerateDisplay(void) {
void ewol::widget::Entry::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_shaper.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 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) {
// nothing to cut ...
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) {
// nothing to cut ...
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);
if (1 == _event.getId()) {
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.getStatus() == ewol::keyEvent::statusDown) {
//EWOL_DEBUG("Entry input data ... : \"" << unicodeData << "\" " );
@ -424,7 +424,7 @@ bool widget::Entry::onEventEntry(const ewol::EventEntry& _event) {
return false;
}
void widget::Entry::setInternalValue(const std::string& _newData) {
void ewol::widget::Entry::setInternalValue(const std::string& _newData) {
std::string previous = m_data;
// check the RegExp :
if (_newData.size()>0) {
@ -442,7 +442,7 @@ void widget::Entry::setInternalValue(const std::string& _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 ...
removeSelected();
// 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);
if(_msg.getMessage() == ewolEventEntryClean) {
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;
}
void widget::Entry::updateTextPosition(void) {
void ewol::widget::Entry::updateTextPosition(void) {
if (false == m_needUpdateTextPos) {
return;
}
@ -532,35 +532,35 @@ void widget::Entry::updateTextPosition(void) {
}
}
void widget::Entry::onGetFocus(void) {
void ewol::widget::Entry::onGetFocus(void) {
m_displayCursor = true;
changeStatusIn(STATUS_SELECTED);
showKeyboard();
markToRedraw();
}
void widget::Entry::onLostFocus(void) {
void ewol::widget::Entry::onLostFocus(void) {
m_displayCursor = false;
changeStatusIn(STATUS_NORMAL);
hideKeyboard();
markToRedraw();
}
void widget::Entry::changeStatusIn(int32_t _newStatusId) {
void ewol::widget::Entry::changeStatusIn(int32_t _newStatusId) {
if (true == m_shaper.changeStatusIn(_newStatusId) ) {
periodicCallEnable();
markToRedraw();
}
}
void widget::Entry::periodicCall(const ewol::EventTime& _event) {
void ewol::widget::Entry::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) {
periodicCallDisable();
}
markToRedraw();
}
void widget::Entry::setRegExp(const std::string& _expression) {
void ewol::widget::Entry::setRegExp(const std::string& _expression) {
std::string previousRegExp = m_regExp.getRegExp();
EWOL_DEBUG("change input regExp \"" << previousRegExp << "\" == > \"" << _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;
markToRedraw();
}
void widget::Entry::setColorTextSelected(const etk::Color<>& _color) {
void ewol::widget::Entry::setColorTextSelected(const etk::Color<>& _color) {
m_textColorBg = _color;
markToRedraw();
}
void widget::Entry::setEmptyText(const std::string& _text) {
void ewol::widget::Entry::setEmptyText(const std::string& _text) {
m_textWhenNothing = _text;
markToRedraw();
}
bool widget::Entry::onSetConfig(const ewol::EConfig& _conf) {
bool ewol::widget::Entry::onSetConfig(const ewol::EConfig& _conf) {
if (true == ewol::Widget::onSetConfig(_conf)) {
return true;
}
@ -612,7 +612,7 @@ bool widget::Entry::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -19,196 +19,197 @@
#include <etk/Color.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
* @brief Entry box display :
*
* ~~~~~~~~~~~~~~~~~~~~~~
* ----------------------------------------------
* | Editable Text |
* ----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~
*/
class Entry : public ewol::Widget {
public:
// Event list of properties
static const char * const eventClick;
static const char * const eventEnter;
static const char * const eventModify; // return in the data the new string inside it ...
// Config list of properties
static const char* const configMaxChar;
static const char* const configRegExp;
static const char* const configColorFg;
static const char* const configColorBg;
static const char* const configEmptyMessage;
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper;
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!!)
*/
Entry(std::string _newData = "");
/**
* @brief Destuctor
*/
virtual ~Entry(void);
private:
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
*/
void setInternalValue(const std::string& _newData);
public:
/**
* @brief set a new value on the entry.
* @param[in] _newData the new string to display.
*/
void setValue(const std::string& _newData);
/**
* @brief get the current value in the entry
* @return The current display value
*/
std::string getValue(void) const {
return m_data;
};
private:
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)
*/
void setMaxChar(int32_t _nbMax);
/**
* @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;
};
private:
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
*/
void setRegExp(const std::string& _expression);
/**
* @brief get the regualar expression limitation
* @param The regExp string
*/
std::string getRegExp(void) const {
return m_regExp.getRegExp();
};
private:
bool m_needUpdateTextPos; //!< text position can have change
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
bool m_displayCursor; //!< Cursor must be display only when the widget has the focus
int32_t m_displayCursorPos; //!< Cursor position in number of Char
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
*/
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
*/
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
* @note The display is automaticly requested when change apear.
*/
virtual void updateCursorPosition(const vec2& _pos, bool _Selection=false);
public:
/**
* @brief Copy the selected data on the specify clipboard
* @param[in] _clipboardID Selected clipboard
*/
virtual void copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID);
/**
* @brief remove the selected area
* @note This request a regeneration of the display
*/
virtual void removeSelected(void);
private:
etk::Color<> m_textColorFg; //!< Text color.
public:
/**
* @brief set text color.
* @param _color Color that is selected.
*/
void setColorText(const etk::Color<>& _color);
/**
* @brief get the color for the text.
* @return The color requested.
*/
const etk::Color<>& getColorText(void) const {
return m_textColorFg;
};
private:
etk::Color<> m_textColorBg; //!< Background color.
public:
/**
* @brief set text backgroung color when selected.
* @param _color Color that is selected.
*/
void setColorTextSelected(const etk::Color<>& _color);
/**
* @brief get the selected color for the text in selection mode.
* @return The color requested.
*/
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...)
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).
*/
void setEmptyText(const std::string& _text);
/**
* @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;
};
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID);
virtual void calculateMinMaxSize(void);
protected: // Derived function
virtual void onDraw(void);
virtual void onGetFocus(void);
virtual void onLostFocus(void);
virtual void changeStatusIn(int32_t _newStatusId);
virtual void periodicCall(const ewol::EventTime& _event);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
* @brief Entry box display :
*
* ~~~~~~~~~~~~~~~~~~~~~~
* ----------------------------------------------
* | Editable Text |
* ----------------------------------------------
* ~~~~~~~~~~~~~~~~~~~~~~
*/
class Entry : public ewol::Widget {
public:
// Event list of properties
static const char * const eventClick;
static const char * const eventEnter;
static const char * const eventModify; // return in the data the new string inside it ...
// Config list of properties
static const char* const configMaxChar;
static const char* const configRegExp;
static const char* const configColorFg;
static const char* const configColorBg;
static const char* const configEmptyMessage;
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Shaper m_shaper;
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!!)
*/
Entry(std::string _newData = "");
/**
* @brief Destuctor
*/
virtual ~Entry(void);
private:
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
*/
void setInternalValue(const std::string& _newData);
public:
/**
* @brief set a new value on the entry.
* @param[in] _newData the new string to display.
*/
void setValue(const std::string& _newData);
/**
* @brief get the current value in the entry
* @return The current display value
*/
std::string getValue(void) const {
return m_data;
};
private:
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)
*/
void setMaxChar(int32_t _nbMax);
/**
* @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;
};
private:
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
*/
void setRegExp(const std::string& _expression);
/**
* @brief get the regualar expression limitation
* @param The regExp string
*/
std::string getRegExp(void) const {
return m_regExp.getRegExp();
};
private:
bool m_needUpdateTextPos; //!< text position can have change
int32_t m_displayStartPosition; //!< ofset in pixel of the display of the UString
bool m_displayCursor; //!< Cursor must be display only when the widget has the focus
int32_t m_displayCursorPos; //!< Cursor position in number of Char
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
*/
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
*/
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
* @note The display is automaticly requested when change apear.
*/
virtual void updateCursorPosition(const vec2& _pos, bool _Selection=false);
public:
/**
* @brief Copy the selected data on the specify clipboard
* @param[in] _clipboardID Selected clipboard
*/
virtual void copySelectionToClipBoard(enum ewol::clipBoard::clipboardListe _clipboardID);
/**
* @brief remove the selected area
* @note This request a regeneration of the display
*/
virtual void removeSelected(void);
private:
etk::Color<> m_textColorFg; //!< Text color.
public:
/**
* @brief set text color.
* @param _color Color that is selected.
*/
void setColorText(const etk::Color<>& _color);
/**
* @brief get the color for the text.
* @return The color requested.
*/
const etk::Color<>& getColorText(void) const {
return m_textColorFg;
};
private:
etk::Color<> m_textColorBg; //!< Background color.
public:
/**
* @brief set text backgroung color when selected.
* @param _color Color that is selected.
*/
void setColorTextSelected(const etk::Color<>& _color);
/**
* @brief get the selected color for the text in selection mode.
* @return The color requested.
*/
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...)
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).
*/
void setEmptyText(const std::string& _text);
/**
* @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;
};
public: // Derived function
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool onEventEntry(const ewol::EventEntry& _event);
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onEventClipboard(enum ewol::clipBoard::clipboardListe _clipboardID);
virtual void calculateMinMaxSize(void);
protected: // Derived function
virtual void onDraw(void);
virtual void onGetFocus(void);
virtual void onLostFocus(void);
virtual void changeStatusIn(int32_t _newStatusId);
virtual void periodicCall(const ewol::EventTime& _event);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
};
};
#endif

View File

@ -16,30 +16,30 @@
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);
}
widget::Gird::Gird(int32_t _colNumber) :
ewol::widget::Gird::Gird(int32_t _colNumber) :
m_sizeRow(0),
m_tmpWidget(NULL),
m_gavityButtom(true),
m_borderSize(0,0) {
addObjectType("widget::Gird");
addObjectType("ewol::widget::Gird");
setColNumber(_colNumber);
requestUpdateSize();
}
widget::Gird::~Gird(void) {
ewol::widget::Gird::~Gird(void) {
EWOL_DEBUG("[" << getId() << "]={" << getObjectType() << "} Gird : destroy");
subWidgetRemoveAll();
}
void widget::Gird::setBorderSize(const ivec2& _newBorderSize) {
void ewol::widget::Gird::setBorderSize(const ivec2& _newBorderSize) {
m_borderSize = _newBorderSize;
if (m_borderSize.x() < 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();
}
void widget::Gird::calculateSize(const vec2& _availlable) {
void ewol::widget::Gird::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("Update size");
m_size = _availlable;
m_size -= m_borderSize*2;
@ -91,7 +91,7 @@ void widget::Gird::calculateSize(const vec2& _availlable) {
markToRedraw();
}
void widget::Gird::calculateMinMaxSize(void) {
void ewol::widget::Gird::calculateMinMaxSize(void) {
for (size_t iii=0; iii<m_sizeCol.size(); iii++ ){
if (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);
}
void widget::Gird::setColNumber(int32_t _colNumber) {
void ewol::widget::Gird::setColNumber(int32_t _colNumber) {
if ((int64_t)m_sizeCol.size() > _colNumber) {
size_t errorControl = m_subWidget.size();
// 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) {
m_sizeCol[_colId] = _size;
} 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;
}
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 (m_sizeCol[_colId] <= 0) {
return 0;
@ -193,11 +193,11 @@ int32_t widget::Gird::getColSize(int32_t _colId) {
return 0;
}
int32_t widget::Gird::getRowSize(void) {
int32_t ewol::widget::Gird::getRowSize(void) {
return m_sizeRow;
}
void widget::Gird::subWidgetRemoveAll(void) {
void ewol::widget::Gird::subWidgetRemoveAll(void) {
size_t errorControl = m_subWidget.size();
// the size automaticly decrement with the auto call of the onObjectRemove function
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) {
return;
}
@ -260,7 +260,7 @@ void widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _n
m_subWidget.push_back(prop);
}
void widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
void ewol::widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
{
if (NULL == _newWidget) {
return;
@ -281,7 +281,7 @@ void widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
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) {
EWOL_WARNING("[" << getId() << "] try to remove widget with id < 0 col=" << _colId << " row=" << _rowId);
return;
@ -311,7 +311,7 @@ void widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) {
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) {
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) {
EWOL_WARNING("[" << getId() << "] try to Unlink widget with id < 0 col=" << _colId << " row=" << _rowId);
return;
@ -341,7 +341,7 @@ void widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) {
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);
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
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++) {
if (NULL != m_subWidget[iii].widget) {
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()) {
return NULL;
}
@ -382,7 +382,7 @@ ewol::Widget * widget::Gird::getWidgetAtPos(const vec2& _pos) {
return NULL;
}
void widget::Gird::onObjectRemove(ewol::EObject * _removeObject) {
void ewol::widget::Gird::onObjectRemove(ewol::EObject * _removeObject) {
// First step call parrent :
ewol::Widget::onObjectRemove(_removeObject);
// second step find if in all the elements ...

View File

@ -15,132 +15,133 @@
#include <ewol/widget/Widget.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Gird :public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
class GirdProperties {
public:
ewol::Widget* widget;
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;
std::vector<int32_t> m_sizeCol; //!< size of all colomn (if set (otherwise 0))
std::vector<GirdProperties> m_subWidget; //!< all sub widget are contained in this element
ewol::Widget* m_tmpWidget; //!< use when replace a widget ...
bool m_gavityButtom;
public:
/**
* @brief Constructor
*/
Gird(int32_t _colNumber=1);
/**
* @brief Desstructor
*/
virtual ~Gird(void);
/**
* @brief set the number of colomn
* @param[in] colNumber Nuber of colomn
*/
void setColNumber(int32_t _colNumber);
/**
* @brief change a size view of a 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);
/**
* @brief change a size view of a line.
* @param[in] size size of the line.
*/
void setRowSize(int32_t _size);
/**
* @brief get the size view of a colomn.
* @param[in] colId Id of the colomn [0..x].
* @return The size of the colomn.
*/
int32_t getColSize(int32_t _colId);
/**
* @brief get the size view of the lines.
* @return The size of the lines.
*/
int32_t getRowSize(void);
/**
* @brief set the gravity of the widget on the Button (index 0 is on buttom)
*/
void setGravityButtom(void) {
m_gavityButtom = true;
markToRedraw();
}
/**
* @brief set the gravity of the widget on the Top (index 0 is on top)
*/
void setGravityTop(void) {
m_gavityButtom = false;
markToRedraw();
}
public:
/**
* @brief remove all sub element from the widget.
*/
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].
* @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);
/**
* @brief remove definitly a widget from the system and this Gird.
* @param[in] _newWidget the element pointer.
*/
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].
* @param[in] _rowId Id of the row [0..y].
*/
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.
*/
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].
* @param[in] _rowId Id of the row [0..y].
*/
virtual void subWidgetUnLink(int32_t _colId, int32_t _rowId);
private:
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)
*/
void setBorderSize(const ivec2& _newBorderSize);
/**
* @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
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Gird :public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
class GirdProperties {
public:
ewol::Widget* widget;
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;
std::vector<int32_t> m_sizeCol; //!< size of all colomn (if set (otherwise 0))
std::vector<GirdProperties> m_subWidget; //!< all sub widget are contained in this element
ewol::Widget* m_tmpWidget; //!< use when replace a widget ...
bool m_gavityButtom;
public:
/**
* @brief Constructor
*/
Gird(int32_t _colNumber=1);
/**
* @brief Desstructor
*/
virtual ~Gird(void);
/**
* @brief set the number of colomn
* @param[in] colNumber Nuber of colomn
*/
void setColNumber(int32_t _colNumber);
/**
* @brief change a size view of a 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);
/**
* @brief change a size view of a line.
* @param[in] size size of the line.
*/
void setRowSize(int32_t _size);
/**
* @brief get the size view of a colomn.
* @param[in] colId Id of the colomn [0..x].
* @return The size of the colomn.
*/
int32_t getColSize(int32_t _colId);
/**
* @brief get the size view of the lines.
* @return The size of the lines.
*/
int32_t getRowSize(void);
/**
* @brief set the gravity of the widget on the Button (index 0 is on buttom)
*/
void setGravityButtom(void) {
m_gavityButtom = true;
markToRedraw();
}
/**
* @brief set the gravity of the widget on the Top (index 0 is on top)
*/
void setGravityTop(void) {
m_gavityButtom = false;
markToRedraw();
}
public:
/**
* @brief remove all sub element from the widget.
*/
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].
* @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);
/**
* @brief remove definitly a widget from the system and this Gird.
* @param[in] _newWidget the element pointer.
*/
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].
* @param[in] _rowId Id of the row [0..y].
*/
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.
*/
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].
* @param[in] _rowId Id of the row [0..y].
*/
virtual void subWidgetUnLink(int32_t _colId, int32_t _rowId);
private:
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)
*/
void setBorderSize(const ivec2& _newBorderSize);
/**
* @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
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual void onObjectRemove(ewol::EObject* _removeObject);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize(void);
};
};
};
#endif

View File

@ -17,25 +17,25 @@
#define __class__ "Image"
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);
}
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 widget::Image::configSize = "size";
const char * const widget::Image::configBorder = "border";
const char * const widget::Image::configSource = "src";
const char * const ewol::widget::Image::configRatio = "ratio";
const char * const ewol::widget::Image::configSize = "size";
const char * const ewol::widget::Image::configBorder = "border";
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_keepRatio(true) {
addObjectType("widget::Image");
addObjectType("ewol::widget::Image");
addEventId(eventPressed);
registerConfig(configRatio, "bool", NULL, "Keep ratio 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);
if (m_fileName != _file) {
// 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);
// copy data :
m_border = _border;
@ -67,7 +67,7 @@ void widget::Image::setBorder(const ewol::Dimension& _border) {
requestUpdateSize();
}
void widget::Image::setKeepRatio(bool _keep) {
void ewol::widget::Image::setKeepRatio(bool _keep) {
if (m_keepRatio != _keep) {
// copy data :
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);
if (_size != m_imageSize) {
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);
// copy data :
if (m_border != _border) {
@ -99,11 +99,11 @@ void widget::Image::set(const std::string& _file, const ewol::Dimension& _border
setFile(_file);
}
void widget::Image::onDraw(void) {
void ewol::widget::Image::onDraw(void) {
m_compositing.draw();
}
void widget::Image::onRegenerateDisplay(void) {
void ewol::widget::Image::onRegenerateDisplay(void) {
if (true == needRedraw()) {
// remove data of the previous composition :
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 imageSize = m_imageSize.getPixel();
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 ...");
if (1 == _event.getId()) {
if(ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -181,7 +181,7 @@ bool widget::Image::onEventInput(const ewol::EventInput& _event) {
return false;
}
bool widget::Image::loadXML(exml::Element* _node) {
bool ewol::widget::Image::loadXML(exml::Element* _node) {
if (NULL == _node) {
return false;
}
@ -220,7 +220,7 @@ bool widget::Image::loadXML(exml::Element* _node) {
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)) {
return true;
}
@ -243,7 +243,7 @@ bool widget::Image::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -18,111 +18,113 @@
extern const char * const ewolEventImagePressed;
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Image :public ewol::Widget {
public:
// Event list of properties
static const char * const eventPressed;
// Config list of properties
static const char * const configRatio;
static const char * const configSize;
static const char * const configBorder;
static const char * const configSource;
public:
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void init(ewol::WidgetManager& _widgetManager);
protected:
ewol::Image m_compositing; //!< compositing element of the image.
public:
/**
* @brief
*/
Image(const std::string& _file="",
const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
/**
* @brief
*/
virtual ~Image(void) { };
/**
* @brief set All the configuration of the current image
* @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:
std::string m_fileName; //!< file name of the image.
public:
/**
* @brief set the new filename
* @param[in] _file Filaneme of the new image
*/
void setFile(const std::string& _file);
/**
* @brief get the file displayed
* @return the filename of the image
*/
const std::string& getFile(void) const {
return m_fileName;
};
protected:
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
*/
void setBorder(const ewol::Dimension& _border);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getBorder(void) const {
return m_border;
};
protected:
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
*/
void setImageSize(const ewol::Dimension& _size);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getImageSize(void) const {
return m_imageSize;
};
protected:
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.
*/
void setKeepRatio(bool _keep);
/**
* @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;
};
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual bool loadXML(exml::Element* _node);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Image :public ewol::Widget {
public:
// Event list of properties
static const char * const eventPressed;
// Config list of properties
static const char * const configRatio;
static const char * const configSize;
static const char * const configBorder;
static const char * const configSource;
public:
/**
* @brief Main call of recording the widget on the List of "widget named creator"
*/
static void init(ewol::WidgetManager& _widgetManager);
protected:
ewol::Image m_compositing; //!< compositing element of the image.
public:
/**
* @brief
*/
Image(const std::string& _file="",
const ewol::Dimension& _border=ewol::Dimension(vec2(0,0),ewol::Dimension::Millimeter));
/**
* @brief
*/
virtual ~Image(void) { };
/**
* @brief set All the configuration of the current image
* @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:
std::string m_fileName; //!< file name of the image.
public:
/**
* @brief set the new filename
* @param[in] _file Filaneme of the new image
*/
void setFile(const std::string& _file);
/**
* @brief get the file displayed
* @return the filename of the image
*/
const std::string& getFile(void) const {
return m_fileName;
};
protected:
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
*/
void setBorder(const ewol::Dimension& _border);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getBorder(void) const {
return m_border;
};
protected:
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
*/
void setImageSize(const ewol::Dimension& _size);
/**
* @brief get the current border request at the image
* @return the border size
*/
const ewol::Dimension& getImageSize(void) const {
return m_imageSize;
};
protected:
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.
*/
void setKeepRatio(bool _keep);
/**
* @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;
};
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
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__
#define __class__ "Joystick"
widget::Joystick::Joystick(void) {
addObjectType("widget::Joystick");
ewol::widget::Joystick::Joystick(void) {
addObjectType("ewol::widget::Joystick");
addEventId(ewolEventJoystickEnable);
addEventId(ewolEventJoystickDisable);
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());
m_size.setValue(minimumSize, minimumSize);
markToRedraw();
}
void widget::Joystick::onRegenerateDisplay(void) {
void ewol::widget::Joystick::onRegenerateDisplay(void) {
if (true == needRedraw()) {
// clean the object list ...
@ -114,7 +114,7 @@ Sine Function: sin(teta) = Opposite / Hypotenuse
Cosine Function: cos(teta) = Adjacent / Hypotenuse
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( 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) {
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
m_background = imageNameInData;
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
m_foreground = imageNameInData;
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;
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 ewolEventJoystickMove;
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Joystick :public ewol::Widget {
public:
enum joystickMode {
modeNormal,
modeArrow,
};
private:
draw::Color m_colorFg; //!< Forground color
draw::Color m_colorBg; //!< Background color
vec2 m_displayPos; //!< direction of the cursor ...
float m_distance; //!< dintance from the center
float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ...
bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle
enum joystickMode m_displayMode; //!< Type of fonctionnal mode of the joystick
private:
// generic property of the joystick:
bool m_displayBackground;
std::string m_background;
std::string m_foreground;
float m_ratio;
public:
Joystick(void);
virtual ~Joystick(void);
public:
void setLockMode(bool _lockWhenOut) {
m_lock = _lockWhenOut;
};
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
*/
void ratio(float _newRatio);
/**
* @brief set the Background of the widget joystick
* @param[in] _imageNameInData the new rbackground that might be set
* @param[in] _display
*/
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
*/
void foreground(std::string _imageNameInData);
/**
* @brief get the property of the joystick
* @param[out] _distance distance to the center
* @param[out] _angle angle of the joy
*/
void getProperty(float& _distance, float& _angle);
public: // Derived function
virtual void calculateSize(const vec2& _availlable);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Joystick :public ewol::Widget {
public:
enum joystickMode {
modeNormal,
modeArrow,
};
private:
draw::Color m_colorFg; //!< Forground color
draw::Color m_colorBg; //!< Background color
vec2 m_displayPos; //!< direction of the cursor ...
float m_distance; //!< dintance from the center
float m_angle; //!< angle of the arraw (if < 0 : No arraw...) 0 is the TOP ...
bool m_lock; //!< flag to mark the lock when the cursor is free when we are outside the circle
enum joystickMode m_displayMode; //!< Type of fonctionnal mode of the joystick
private:
// generic property of the joystick:
bool m_displayBackground;
std::string m_background;
std::string m_foreground;
float m_ratio;
public:
Joystick(void);
virtual ~Joystick(void);
public:
void setLockMode(bool _lockWhenOut) {
m_lock = _lockWhenOut;
};
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
*/
void ratio(float _newRatio);
/**
* @brief set the Background of the widget joystick
* @param[in] _imageNameInData the new rbackground that might be set
* @param[in] _display
*/
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
*/
void foreground(std::string _imageNameInData);
/**
* @brief get the property of the joystick
* @param[out] _distance distance to the center
* @param[out] _angle angle of the joy
*/
void getProperty(float& _distance, float& _angle);
public: // Derived function
virtual void calculateSize(const vec2& _availlable);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
};
};
};

View File

@ -15,24 +15,24 @@
#undef __class__
#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) {
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);
}
widget::Label::Label(std::string _newLabel) {
addObjectType("widget::Label");
ewol::widget::Label::Label(std::string _newLabel) {
addObjectType("ewol::widget::Label");
m_label = _newLabel;
addEventId(eventPressed);
setCanHaveFocus(false);
}
void widget::Label::calculateMinMaxSize(void) {
void ewol::widget::Label::calculateMinMaxSize(void) {
vec2 tmpMax = m_userMaxSize.getPixel();
//EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} tmpMax : " << tmpMax);
if (tmpMax.x() <= 999999) {
@ -47,21 +47,21 @@ void widget::Label::calculateMinMaxSize(void) {
//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;
markToRedraw();
requestUpdateSize();
}
std::string widget::Label::getLabel(void) {
std::string ewol::widget::Label::getLabel(void) {
return m_label;
}
void widget::Label::onDraw(void) {
void ewol::widget::Label::onDraw(void) {
m_text.draw();
}
void widget::Label::onRegenerateDisplay(void) {
void ewol::widget::Label::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_text.clear();
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 ...");
if (1 == _event.getId()) {
if (ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -122,7 +122,7 @@ bool widget::Label::onEventInput(const ewol::EventInput& _event) {
return false;
}
bool widget::Label::loadXML(exml::Element* _node) {
bool ewol::widget::Label::loadXML(exml::Element* _node) {
if (NULL == _node) {
return false;
}

View File

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

View File

@ -14,22 +14,22 @@
#define __class__ "Layer"
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);
}
widget::Layer::Layer(void) {
addObjectType("widget::Layer");
ewol::widget::Layer::Layer(void) {
addObjectType("ewol::widget::Layer");
}
widget::Layer::~Layer(void) {
ewol::widget::Layer::~Layer(void) {
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()) {
return NULL;
}

View File

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

View File

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

View File

@ -15,71 +15,73 @@
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/compositing/Compositing.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class List : public widget::WidgetScrooled {
public:
List(void);
virtual ~List(void);
virtual void calculateMinMaxSize(void);
void setLabel(std::string _newLabel);
// drawing capabilities ....
private:
std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
std::vector<ivec2 > m_lineSize;
public:
void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
void clearOObjectList(void);
// list properties ...
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_displayCurrentNbLine; //!< Number of line in the display
int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display)
protected:
// function call to display the list :
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;
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class List : public widget::WidgetScrooled {
public:
List(void);
virtual ~List(void);
virtual void calculateMinMaxSize(void);
void setLabel(std::string _newLabel);
// drawing capabilities ....
private:
std::vector<ewol::Compositing*> m_listOObject; //!< generic element to display...
std::vector<ivec2 > m_lineSize;
public:
void addOObject(ewol::Compositing* _newObject, int32_t _pos=-1);
void clearOObjectList(void);
// list properties ...
private:
int32_t m_paddingSizeX;
int32_t m_paddingSizeY;
int32_t m_displayStartRaw; //!< Current starting diaplayed raw
int32_t m_displayCurrentNbLine; //!< Number of line in the display
int32_t m_nbVisibleRaw; // set the number of visible raw (calculate don display)
protected:
// function call to display the list :
virtual etk::Color<> getBasicBG(void) {
return etk::Color<>(0xFFFFFFFF);
}
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);
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 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";
widget::ListFileSystem::ListFileSystem(void) {
addObjectType("widget::ListFileSystem");
ewol::widget::ListFileSystem::ListFileSystem(void) {
addObjectType("ewol::widget::ListFileSystem");
m_selectedLine = -1;
m_showFile = true;
m_showTemporaryFile = true;
@ -40,7 +40,7 @@ widget::ListFileSystem::ListFileSystem(void) {
setMouseLimit(1);
};
widget::ListFileSystem::~ListFileSystem(void) {
ewol::widget::ListFileSystem::~ListFileSystem(void) {
for (size_t iii=0; iii<m_list.size(); iii++) {
if (NULL != 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);
}
void widget::ListFileSystem::regenerateView(void) {
void ewol::widget::ListFileSystem::regenerateView(void) {
// clean the list of files :
for (size_t iii=0; iii<m_list.size(); iii++) {
if (NULL != m_list[iii]) {
@ -73,36 +73,36 @@ void widget::ListFileSystem::regenerateView(void) {
markToRedraw();
}
void widget::ListFileSystem::setShowHiddenFiles(bool _state) {
void ewol::widget::ListFileSystem::setShowHiddenFiles(bool _state) {
m_showHidden = _state;
regenerateView();
}
void widget::ListFileSystem::setShowTemporaryFiles(bool _state) {
void ewol::widget::ListFileSystem::setShowTemporaryFiles(bool _state) {
m_showTemporaryFile = _state;
regenerateView();
}
void widget::ListFileSystem::setShowFiles(bool _state) {
void ewol::widget::ListFileSystem::setShowFiles(bool _state) {
m_showFile = _state;
regenerateView();
}
void widget::ListFileSystem::setShowFolder(bool _state) {
void ewol::widget::ListFileSystem::setShowFolder(bool _state) {
m_showFolder = _state;
regenerateView();
}
void widget::ListFileSystem::setFolder(std::string _newFolder) {
void ewol::widget::ListFileSystem::setFolder(std::string _newFolder) {
m_folder = _newFolder;
regenerateView();
}
std::string widget::ListFileSystem::getFolder(void) {
std::string ewol::widget::ListFileSystem::getFolder(void) {
return m_folder;
}
std::string widget::ListFileSystem::getSelect(void) {
std::string ewol::widget::ListFileSystem::getSelect(void) {
std::string tmpVal = "";
if (m_selectedLine >= 0) {
if (m_list[m_selectedLine] != NULL) {
@ -113,7 +113,7 @@ std::string widget::ListFileSystem::getSelect(void) {
}
// select the specific file
void widget::ListFileSystem::setSelect( std::string _data) {
void ewol::widget::ListFileSystem::setSelect( std::string _data) {
// remove selected line
m_selectedLine = -1;
// search the coresponding file :
@ -129,16 +129,16 @@ void widget::ListFileSystem::setSelect( std::string _data) {
markToRedraw();
}
uint32_t widget::ListFileSystem::getNuberOfColomn(void) {
uint32_t ewol::widget::ListFileSystem::getNuberOfColomn(void) {
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";
return true;
}
uint32_t widget::ListFileSystem::getNuberOfRaw(void) {
uint32_t ewol::widget::ListFileSystem::getNuberOfRaw(void) {
int32_t offset = 0;
if (true == m_showFolder) {
offset = 2;
@ -146,7 +146,7 @@ uint32_t widget::ListFileSystem::getNuberOfRaw(void) {
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;
if (true == m_showFolder) {
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,
enum ewol::keyEvent::status _typeEvent,
int32_t _colomn,
int32_t _raw,
float _x,
float _y) {
bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput,
enum ewol::keyEvent::status _typeEvent,
int32_t _colomn,
int32_t _raw,
float _x,
float _y) {
int32_t offset = 0;
if (true == m_showFolder) {
offset = 2;

View File

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

View File

@ -18,35 +18,35 @@
#undef __class__
#define __class__ "Menu"
widget::Menu::Menu(void) {
addObjectType("widget::Menu");
ewol::widget::Menu::Menu(void) {
addObjectType("ewol::widget::Menu");
m_staticId = 0;
m_widgetContextMenu = NULL;
}
widget::Menu::~Menu(void) {
ewol::widget::Menu::~Menu(void) {
clear();
}
void widget::Menu::subWidgetRemoveAll(void) {
void ewol::widget::Menu::subWidgetRemoveAll(void) {
clear();
widget::Sizer::subWidgetRemoveAll();
}
int32_t widget::Menu::subWidgetAdd(ewol::Widget* _newWidget) {
int32_t ewol::widget::Menu::subWidgetAdd(ewol::Widget* _newWidget) {
EWOL_ERROR("Not availlable");
return -1;
}
void widget::Menu::subWidgetRemove(ewol::Widget* _newWidget) {
void ewol::widget::Menu::subWidgetRemove(ewol::Widget* _newWidget) {
EWOL_ERROR("Not availlable");
}
void widget::Menu::subWidgetUnLink(ewol::Widget* _newWidget) {
void ewol::widget::Menu::subWidgetUnLink(ewol::Widget* _newWidget) {
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++) {
if (m_listElement[iii] != NULL) {
delete(m_listElement[iii]);
@ -56,19 +56,19 @@ void widget::Menu::clear(void) {
m_listElement.clear();
}
int32_t widget::Menu::addTitle(std::string _label,
int32_t ewol::widget::Menu::addTitle(std::string _label,
std::string _image,
const char * _generateEvent,
const std::string _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 _image,
const char *_generateEvent,
const std::string _message) {
widget::MenuElement *tmpObject = new widget::MenuElement();
ewol::widget::MenuElement *tmpObject = new ewol::widget::MenuElement();
if (NULL == tmpObject) {
EWOL_ERROR("Allocation problem");
return -1;
@ -110,12 +110,12 @@ int32_t widget::Menu::add(int32_t _parent,
return tmpObject->m_localId;
}
void widget::Menu::addSpacer(void) {
void ewol::widget::Menu::addSpacer(void) {
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) {
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);
if (m_widgetContextMenu == _removeObject) {
m_widgetContextMenu = NULL;

View File

@ -16,42 +16,44 @@
#include <ewol/widget/Sizer.h>
#include <ewol/widget/ContextMenu.h>
namespace widget {
class MenuElement {
public :
MenuElement(void) : m_widgetPointer(NULL) { };
int32_t m_localId;
int32_t m_parentId;
ewol::EObject* m_widgetPointer;
std::string m_label;
std::string m_image;
const char *m_generateEvent;
std::string m_message;
};
/**
* @ingroup ewolWidgetGroup
*/
class Menu :public widget::Sizer {
public:
Menu(void);
virtual ~Menu(void);
private:
virtual void subWidgetRemoveAll(void);
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
virtual void subWidgetRemove(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
private:
std::vector<widget::MenuElement*> m_listElement;
int32_t m_staticId; // unique ID for every element of the menu ...
widget::ContextMenu* m_widgetContextMenu;
public:
void clear(void);
int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
int32_t add(int32_t parent, std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
void addSpacer(void);
// Derived function
virtual void onReceiveMessage(const ewol::EMessage& _msg);
virtual void onObjectRemove(ewol::EObject * _removeObject);
namespace ewol {
namespace widget {
class MenuElement {
public :
MenuElement(void) : m_widgetPointer(NULL) { };
int32_t m_localId;
int32_t m_parentId;
ewol::EObject* m_widgetPointer;
std::string m_label;
std::string m_image;
const char *m_generateEvent;
std::string m_message;
};
/**
* @ingroup ewolWidgetGroup
*/
class Menu :public widget::Sizer {
public:
Menu(void);
virtual ~Menu(void);
private:
virtual void subWidgetRemoveAll(void);
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
virtual void subWidgetRemove(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
private:
std::vector<widget::MenuElement*> m_listElement;
int32_t m_staticId; // unique ID for every element of the menu ...
widget::ContextMenu* m_widgetContextMenu;
public:
void clear(void);
int32_t addTitle(std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
int32_t add(int32_t parent, std::string _label, std::string _image="", const char * _generateEvent = NULL, const std::string _message = "");
void addSpacer(void);
// Derived function
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_object(NULL),
m_position(0,0,0),
m_angle(0,0,0),
m_angleSpeed(0,0,0),
m_cameraDistance(10.0) {
addObjectType("widget::Mesh");
addObjectType("ewol::widget::Mesh");
addEventId(ewolEventMeshPressed);
// Limit event at 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);
}
void widget::Mesh::onDraw(void) {
void ewol::widget::Mesh::onDraw(void) {
mat4 transformationMatrix = etk::matTranslate(vec3(0,0,-m_cameraDistance))
* etk::matTranslate(m_position)
* 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();
// 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(),
@ -71,18 +71,18 @@ void widget::Mesh::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::openGL::pop();
}
void widget::Mesh::onRegenerateDisplay(void) {
void ewol::widget::Mesh::onRegenerateDisplay(void) {
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();
markToRedraw();
}
bool widget::Mesh::onEventInput(const ewol::EventInput& _event) {
bool ewol::widget::Mesh::onEventInput(const ewol::EventInput& _event) {
//EWOL_DEBUG("Event on BT ...");
if (1 == _event.getId()) {
if(ewol::keyEvent::statusSingle == _event.getStatus()) {
@ -93,7 +93,7 @@ bool widget::Mesh::onEventInput(const ewol::EventInput& _event) {
return false;
}
void widget::Mesh::setFile(const std::string& _filename) {
void ewol::widget::Mesh::setFile(const std::string& _filename) {
if( _filename!=""
&& m_meshName != _filename ) {
ewol::Mesh::release(m_object);
@ -106,17 +106,17 @@ void widget::Mesh::setFile(const std::string& _filename) {
markToRedraw();
}
void widget::Mesh::setPosition(const vec3& _pos) {
void ewol::widget::Mesh::setPosition(const vec3& _pos) {
m_position = _pos;
markToRedraw();
}
void widget::Mesh::setAngle(const vec3& _angle) {
void ewol::widget::Mesh::setAngle(const vec3& _angle) {
m_angle = _angle;
markToRedraw();
}
void widget::Mesh::setAngleSpeed(const vec3& _speed) {
void ewol::widget::Mesh::setAngleSpeed(const vec3& _speed) {
if (_speed!=vec3(0,0,0)) {
periodicCallEnable();
} else {
@ -126,7 +126,7 @@ void widget::Mesh::setAngleSpeed(const vec3& _speed) {
markToRedraw();
}
void widget::Mesh::setDistance(float _distance)
void ewol::widget::Mesh::setDistance(float _distance)
{
m_cameraDistance = _distance;
markToRedraw();

View File

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

View File

@ -15,26 +15,26 @@
#undef __class__
#define __class__ "PopUp"
const char* const widget::PopUp::configShaper="shaper";
const char* const widget::PopUp::configRemoveOnExternClick="out-click-remove";
const char* const widget::PopUp::configAnimation="animation";
const char* const widget::PopUp::configLockExpand="lock";
const char* const ewol::widget::PopUp::configShaper="shaper";
const char* const ewol::widget::PopUp::configRemoveOnExternClick="out-click-remove";
const char* const ewol::widget::PopUp::configAnimation="animation";
const char* const ewol::widget::PopUp::configLockExpand="lock";
static const char* annimationIncrease = "increase";
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);
}
widget::PopUp::PopUp(const std::string& _shaperName) :
ewol::widget::PopUp::PopUp(const std::string& _shaperName) :
m_shaper(_shaperName),
m_lockExpand(true,true),
m_closeOutEvent(false) {
addObjectType("widget::PopUp");
addObjectType("ewol::widget::PopUp");
m_userExpand.setValue(false, false);
setMinSize(ewol::Dimension(vec2(80,80),ewol::Dimension::Pourcent));
registerConfig(configShaper, "string", NULL, "The shaper properties");
@ -46,11 +46,11 @@ widget::PopUp::PopUp(const std::string& _shaperName) :
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) {
m_lockExpand = _lockExpand;
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);
markToRedraw();
}
void widget::PopUp::calculateSize(const vec2& _available) {
void ewol::widget::PopUp::calculateSize(const vec2& _available) {
ewol::Widget::calculateSize(_available);
if (NULL != m_subWidget) {
vec2 padding = m_shaper.getPadding();
@ -97,7 +97,7 @@ void widget::PopUp::calculateSize(const vec2& _available) {
markToRedraw();
}
void widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) {
void ewol::widget::PopUp::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){
// widget is hidden ...
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();
}
void widget::PopUp::onRegenerateDisplay(void) {
void ewol::widget::PopUp::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_shaper.clear();
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);
if (NULL != val) {
return val;
@ -155,7 +155,7 @@ ewol::Widget* widget::PopUp::getWidgetAtPos(const vec2& _pos) {
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)) {
return true;
}
@ -174,7 +174,7 @@ bool widget::PopUp::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}
@ -197,7 +197,7 @@ bool widget::PopUp::onGetConfig(const char* _config, std::string& _result) const
return false;
}
bool widget::PopUp::onEventInput(const ewol::EventInput& _event) {
bool ewol::widget::PopUp::onEventInput(const ewol::EventInput& _event) {
if (0 != _event.getId()) {
if (true == m_closeOutEvent) {
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) {
return false;
}
@ -235,11 +235,11 @@ bool widget::PopUp::onStartAnnimation(enum ewol::Widget::annimationMode _mode) {
return false;
}
void widget::PopUp::onStopAnnimation(void) {
void ewol::widget::PopUp::onStopAnnimation(void) {
periodicCallDisable();
}
void widget::PopUp::periodicCall(const ewol::EventTime& _event) {
void ewol::widget::PopUp::periodicCall(const ewol::EventTime& _event) {
if (false == m_shaper.periodicCall(_event) ) {
stopAnnimation();
}

View File

@ -17,76 +17,77 @@
#include <ewol/compositing/Shaper.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class PopUp : public widget::Container {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configShaper;
static const char* const configRemoveOnExternClick;
static const char* const configAnimation;
static const char* const configLockExpand;
private:
ewol::Shaper m_shaper; //!< Compositing theme.
public:
/**
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
PopUp(const std::string& _shaperName="THEME:GUI:widgetPopUp.conf");
/**
* @brief Destructor
*/
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
*/
void setShaperName(const std::string& _shaperName);
protected:
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
*/
void lockExpand(const bvec2& _lockExpand);
private:
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
*/
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
*/
bool getRemoveOnExternClick(void) const {
return m_closeOutEvent;
};
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void periodicCall(const ewol::EventTime& _event);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void calculateSize(const vec2& _available);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
protected:
virtual bool onStartAnnimation(enum ewol::Widget::annimationMode _mode);
virtual void onStopAnnimation(void);
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class PopUp : public widget::Container {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configShaper;
static const char* const configRemoveOnExternClick;
static const char* const configAnimation;
static const char* const configLockExpand;
private:
ewol::Shaper m_shaper; //!< Compositing theme.
public:
/**
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
PopUp(const std::string& _shaperName="THEME:GUI:widgetPopUp.conf");
/**
* @brief Destructor
*/
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
*/
void setShaperName(const std::string& _shaperName);
protected:
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
*/
void lockExpand(const bvec2& _lockExpand);
private:
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
*/
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
*/
bool getRemoveOnExternClick(void) const {
return m_closeOutEvent;
};
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void periodicCall(const ewol::EventTime& _event);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(void);
virtual void calculateSize(const vec2& _available);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
protected:
virtual bool onStartAnnimation(enum ewol::Widget::annimationMode _mode);
virtual void onStopAnnimation(void);
};
};
};
#endif

View File

@ -15,22 +15,22 @@
#define __class__ "ProgressBar"
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);
}
const char* const widget::ProgressBar::configColorBg = "color-bg";
const char* const widget::ProgressBar::configColorFgOn = "color-on";
const char* const widget::ProgressBar::configColorFgOff = "color-off";
const char* const widget::ProgressBar::configValue = "value";
const char* const ewol::widget::ProgressBar::configColorBg = "color-bg";
const char* const ewol::widget::ProgressBar::configColorFgOn = "color-on";
const char* const ewol::widget::ProgressBar::configColorFgOff = "color-off";
const char* const ewol::widget::ProgressBar::configValue = "value";
const int32_t dotRadius = 6;
widget::ProgressBar::ProgressBar(void) {
addObjectType("widget::ProgressBar");
ewol::widget::ProgressBar::ProgressBar(void) {
addObjectType("ewol::widget::ProgressBar");
m_value = 0.0;
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();
m_minSize.setValue( etk_max(tmpMin.x(), 40),
etk_max(tmpMin.y(), dotRadius*2) );
markToRedraw();
}
void widget::ProgressBar::setValue(float _val) {
void ewol::widget::ProgressBar::setValue(float _val) {
m_value = etk_avg(0, _val, 1);
markToRedraw();
}
void widget::ProgressBar::onDraw(void) {
void ewol::widget::ProgressBar::onDraw(void) {
m_draw.draw();
}
void widget::ProgressBar::onRegenerateDisplay(void) {
void ewol::widget::ProgressBar::onRegenerateDisplay(void) {
if (true == needRedraw()) {
// clean the object list ...
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)) {
return true;
}
@ -116,7 +116,7 @@ bool widget::ProgressBar::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

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

View File

@ -15,38 +15,38 @@
#define __class__ "Scroll"
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);
}
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_pixelScrolling(20),
m_highSpeedStartPos(0,0),
m_highSpeedMode(speedModeDisable),
m_highSpeedButton(-1),
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");
}
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;
markToRedraw();
}
#define SCROLL_BAR_SPACE (15)
void widget::Scroll::calculateMinMaxSize(void) {
void ewol::widget::Scroll::calculateMinMaxSize(void) {
// call main class !! and not containter class ...
ewol::Widget::calculateMinMaxSize();
// 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) {
return;
}
@ -67,11 +67,11 @@ void widget::Scroll::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::Widget::systemDraw(_displayProp);
}
void widget::Scroll::onDraw(void) {
void ewol::widget::Scroll::onDraw(void) {
m_draw.draw();
}
void widget::Scroll::onRegenerateDisplay(void) {
void ewol::widget::Scroll::onRegenerateDisplay(void) {
// call upper class
widget::Container::onRegenerateDisplay();
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 scrollOffset(0,0);
vec2 scrollSize(0,0);
@ -332,7 +332,7 @@ bool widget::Scroll::onEventInput(const ewol::EventInput& _event) {
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);
if (NULL != tmpWidget) {
return tmpWidget;
@ -340,7 +340,7 @@ ewol::Widget* widget::Scroll::getWidgetAtPos(const vec2& _pos) {
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)) {
return true;
}
@ -351,7 +351,7 @@ bool widget::Scroll::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -16,60 +16,62 @@
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Scroll : public widget::Container {
public:
enum highSpeedMode {
speedModeDisable,
speedModeInit,
speedModeEnableFinger, // Specific for touchpad
speedModeEnableHorizontal, // Specific for mouse
speedModeEnableVertical, // Specific for mouse
speedModeGrepEndEvent
};
public:
// Cinfig parameter list:
static const char* const configLimit;
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Drawing m_draw; // TODO : change in shaper ... == > better for annimation and dynamic display ...
protected:
vec2 m_limit;
private:
float m_pixelScrolling;
vec2 m_highSpeedStartPos;
enum highSpeedMode m_highSpeedMode;
int32_t m_highSpeedButton;
enum ewol::keyEvent::type m_highSpeedType;
public:
Scroll(void);
virtual ~Scroll(void);
/**
* @brief set the limit of scrolling
* @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);
/**
* @brief get the limit of scrolling
* @return scrolling limit
*/
const vec2& getLimit(void) const { return m_limit; };
public: // Derived function
void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Scroll : public widget::Container {
public:
enum highSpeedMode {
speedModeDisable,
speedModeInit,
speedModeEnableFinger, // Specific for touchpad
speedModeEnableHorizontal, // Specific for mouse
speedModeEnableVertical, // Specific for mouse
speedModeGrepEndEvent
};
public:
// Cinfig parameter list:
static const char* const configLimit;
public:
static void init(ewol::WidgetManager& _widgetManager);
private:
ewol::Drawing m_draw; // TODO : change in shaper ... == > better for annimation and dynamic display ...
protected:
vec2 m_limit;
private:
float m_pixelScrolling;
vec2 m_highSpeedStartPos;
enum highSpeedMode m_highSpeedMode;
int32_t m_highSpeedButton;
enum ewol::keyEvent::type m_highSpeedType;
public:
Scroll(void);
virtual ~Scroll(void);
/**
* @brief set the limit of scrolling
* @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);
/**
* @brief get the limit of scrolling
* @return scrolling limit
*/
const vec2& getLimit(void) const { return m_limit; };
public: // Derived function
void calculateMinMaxSize(void);
virtual void onRegenerateDisplay(void);
virtual bool onEventInput(const ewol::EventInput& _event);
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
protected: // Derived function
virtual void onDraw(void);
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"
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);
}
widget::Sizer::Sizer(enum displayMode _mode):
ewol::widget::Sizer::Sizer(enum displayMode _mode):
m_mode(_mode),
m_borderSize(),
m_animation(animationNone),
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
m_animation = animationNone;
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;
markToRedraw();
requestUpdateSize();
}
void widget::Sizer::setMode(enum displayMode _mode) {
void ewol::widget::Sizer::setMode(enum displayMode _mode) {
m_mode = _mode;
markToRedraw();
requestUpdateSize();
}
enum widget::Sizer::displayMode widget::Sizer::getMode(void) {
enum ewol::widget::Sizer::displayMode ewol::widget::Sizer::getMode(void) {
return m_mode;
}
void widget::Sizer::calculateSize(const vec2& _availlable) {
void ewol::widget::Sizer::calculateSize(const vec2& _availlable) {
ewol::Widget::calculateSize(_availlable);
vec2 tmpBorderSize = m_borderSize.getPixel();
//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++) {
if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize();
if (m_mode == widget::Sizer::modeVert) {
if (m_mode == ewol::widget::Sizer::modeVert) {
unexpandableSize += tmpSize.y();
if (false == m_subWidget[iii]->canExpand().y()) {
nbWidgetFixedSize++;
@ -88,7 +88,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
float sizeToAddAtEveryOne = 0;
// 2 cases : 1 or more can Expand, or all is done ...
if (0 != nbWidgetNotFixedSize) {
if (m_mode == widget::Sizer::modeVert) {
if (m_mode == ewol::widget::Sizer::modeVert) {
sizeToAddAtEveryOne = (m_size.y() - unexpandableSize) / nbWidgetNotFixedSize;
} else {
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);
m_subWidget[iii]->setOrigin(vec2ClipInt32(tmpOrigin+m_offset));
// 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()) {
m_subWidget[iii]->calculateSize(vec2ClipInt32(vec2(m_size.x(), tmpSize.y()+sizeToAddAtEveryOne)));
tmpOrigin.setY(tmpOrigin.y() + tmpSize.y()+sizeToAddAtEveryOne);
@ -128,7 +128,7 @@ void widget::Sizer::calculateSize(const vec2& _availlable) {
markToRedraw();
}
void widget::Sizer::calculateMinMaxSize(void) {
void ewol::widget::Sizer::calculateMinMaxSize(void) {
//EWOL_DEBUG("[" << getId() << "] update minimum size");
m_subExpend.setValue(false, false);
m_minSize = m_userMinSize.getPixel();
@ -147,7 +147,7 @@ void widget::Sizer::calculateMinMaxSize(void) {
vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize();
//EWOL_DEBUG("[" << getId() << "] NewMinSize=" << 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());
if (tmpSize.x()>m_minSize.x()) {
m_minSize.setX(tmpSize.x());
@ -163,7 +163,7 @@ void widget::Sizer::calculateMinMaxSize(void) {
//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) {
return false;
}
@ -178,15 +178,15 @@ bool widget::Sizer::loadXML(exml::Element* _node) {
if (tmpAttributeValue.size()!=0) {
if( compare_no_case(tmpAttributeValue, "vert") == true
|| compare_no_case(tmpAttributeValue, "vertical") == true) {
m_mode = widget::Sizer::modeVert;
m_mode = ewol::widget::Sizer::modeVert;
} else {
m_mode = widget::Sizer::modeHori;
m_mode = ewol::widget::Sizer::modeHori;
}
}
return true;
}
int32_t widget::Sizer::subWidgetAdd(ewol::Widget* _newWidget) {
int32_t ewol::widget::Sizer::subWidgetAdd(ewol::Widget* _newWidget) {
if (m_animation == animationNone) {
return widget::ContainerN::subWidgetAdd(_newWidget);
}
@ -194,7 +194,7 @@ int32_t widget::Sizer::subWidgetAdd(ewol::Widget* _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) {
return widget::ContainerN::subWidgetAddStart(_newWidget);
}
@ -202,7 +202,7 @@ int32_t widget::Sizer::subWidgetAddStart(ewol::Widget* _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) {
widget::ContainerN::subWidgetRemove(_newWidget);
return;
@ -211,7 +211,7 @@ void widget::Sizer::subWidgetRemove(ewol::Widget* _newWidget) {
widget::ContainerN::subWidgetRemove(_newWidget);
}
void widget::Sizer::subWidgetUnLink(ewol::Widget* _newWidget) {
void ewol::widget::Sizer::subWidgetUnLink(ewol::Widget* _newWidget) {
if (m_animation == animationNone) {
widget::ContainerN::subWidgetUnLink(_newWidget);
return;

View File

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

View File

@ -16,17 +16,17 @@ extern const char * const ewolEventSliderChange = "ewol-event-slider-change";
#define __class__ "Slider"
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);
}
const int32_t dotRadius = 6;
widget::Slider::Slider(void) {
addObjectType("widget::Slider");
ewol::widget::Slider::Slider(void) {
addObjectType("ewol::widget::Slider");
addEventId(ewolEventSliderChange);
m_value = 0;
@ -42,43 +42,43 @@ widget::Slider::Slider(void) {
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();
m_minSize.setValue(etk_max(minTmp.x(), 40),
etk_max(minTmp.y(), dotRadius*2) );
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);
markToRedraw();
}
int32_t widget::Slider::getValue(void) {
int32_t ewol::widget::Slider::getValue(void) {
return m_value;
}
void widget::Slider::setMin(int32_t _val) {
void ewol::widget::Slider::setMin(int32_t _val) {
m_min = _val;
m_value = etk_max(etk_min(m_value, m_max), m_min);
markToRedraw();
}
void widget::Slider::setMax(int32_t _val) {
void ewol::widget::Slider::setMax(int32_t _val) {
m_max = _val;
m_value = etk_max(etk_min(m_value, m_max), m_min);
markToRedraw();
}
void widget::Slider::onDraw(void) {
void ewol::widget::Slider::onDraw(void) {
m_draw.draw();
}
void widget::Slider::onRegenerateDisplay(void) {
void ewol::widget::Slider::onRegenerateDisplay(void) {
if (needRedraw() == false) {
return;
}
@ -100,7 +100,7 @@ void widget::Slider::onRegenerateDisplay(void) {
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());
//EWOL_DEBUG("Event on Slider ...");
if (1 == _event.getId()) {

View File

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

View File

@ -14,18 +14,18 @@
#undef __class__
#define __class__ "Spacer"
const char* const widget::Spacer::configColor = "color";
const char* const ewol::widget::Spacer::configColor = "color";
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);
}
widget::Spacer::Spacer(void) {
addObjectType("widget::Spacer");
ewol::widget::Spacer::Spacer(void) {
addObjectType("ewol::widget::Spacer");
m_userMinSize = ewol::Dimension(vec2(10,10));
setCanHaveFocus(false);
m_color = etk::color::black;
@ -33,16 +33,16 @@ widget::Spacer::Spacer(void) {
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();
}
#define BORDER_SIZE_TMP (4)
void widget::Spacer::onRegenerateDisplay(void) {
void ewol::widget::Spacer::onRegenerateDisplay(void) {
if (false == needRedraw()) {
return;
}
@ -56,7 +56,7 @@ void widget::Spacer::onRegenerateDisplay(void) {
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)) {
return true;
}
@ -68,7 +68,7 @@ bool widget::Spacer::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}

View File

@ -16,42 +16,43 @@
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/WidgetManager.h>
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Spacer :public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configColor;
private:
ewol::Drawing m_draw; //!< Compositing drawing element
public:
/**
* @brief Main constructer
*/
Spacer(void);
/**
* @brief Main destructer
*/
virtual ~Spacer(void);
protected:
etk::Color<> m_color; //!< Background color
public:
/**
* @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
virtual ewol::Widget * getWidgetAtPos(const vec2& _pos) { return NULL; };
virtual void onRegenerateDisplay(void);
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
namespace ewol {
namespace widget {
/**
* @ingroup ewolWidgetGroup
*/
class Spacer :public ewol::Widget {
public:
static void init(ewol::WidgetManager& _widgetManager);
// Config list of properties
static const char* const configColor;
private:
ewol::Drawing m_draw; //!< Compositing drawing element
public:
/**
* @brief Main constructer
*/
Spacer(void);
/**
* @brief Main destructer
*/
virtual ~Spacer(void);
protected:
etk::Color<> m_color; //!< Background color
public:
/**
* @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
virtual ewol::Widget * getWidgetAtPos(const vec2& _pos) { return NULL; };
virtual void onRegenerateDisplay(void);
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::EConfig& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
};
};
};
#endif

View File

@ -10,12 +10,12 @@
#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 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];
return _os;
}
@ -24,39 +24,39 @@ etk::CCout& operator <<(etk::CCout& _os, const enum widget::WSlider::sladingMode
#define __class__ "WSlider"
// Event list of properties
const char* const 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::eventStartSlide = "ewol-widget-wslider-event-start-slide";
const char* const ewol::widget::WSlider::eventStopSlide = "ewol-widget-wslider-event-stop-slide";
// Config list of properties
const char* const widget::WSlider::configMode = "mode";
const char* const ewol::widget::WSlider::configMode = "mode";
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);
}
widget::WSlider::WSlider(void) :
ewol::widget::WSlider::WSlider(void) :
m_windowsSources(0),
m_windowsDestination(0),
m_windowsRequested(-1),
m_slidingProgress(1.0f),
m_transitionSpeed(1.0f),
m_transitionSlide(sladingTransitionHori) {
addObjectType("widget::WSlider");
addObjectType("ewol::widget::WSlider");
addEventId(eventStartSlide);
addEventId(eventStopSlide);
// add configuration
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");
widget::ContainerN::calculateSize(_availlable);
@ -107,7 +107,7 @@ void widget::WSlider::calculateSize(const vec2& _availlable) {
markToRedraw();
}
void widget::WSlider::subWidgetSelectSet(int32_t _id) {
void ewol::widget::WSlider::subWidgetSelectSet(int32_t _id) {
int32_t elementID = -1;
// search element in the list :
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) {
EWOL_ERROR("Can not change to a widget NULL");
return;
@ -146,7 +146,7 @@ void widget::WSlider::subWidgetSelectSet(ewol::Widget* _widgetPointer) {
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 == "") {
EWOL_ERROR("Can not change to a widget with no name (input)");
return;
@ -162,14 +162,14 @@ void widget::WSlider::subWidgetSelectSet(const std::string& _widgetName) {
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) {
m_transitionSlide = _mode;
markToRedraw();
}
}
void widget::WSlider::periodicCall(const ewol::EventTime& _event) {
void ewol::widget::WSlider::periodicCall(const ewol::EventTime& _event) {
if (m_slidingProgress >= 1.0) {
m_windowsSources = m_windowsDestination;
if( m_windowsRequested != -1
@ -202,7 +202,7 @@ void widget::WSlider::periodicCall(const ewol::EventTime& _event) {
markToRedraw();
}
void widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
void ewol::widget::WSlider::systemDraw(const ewol::DrawProperty& _displayProp) {
if (true == m_hide){
// widget is hidden ...
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) {
int32_t iii = m_windowsDestination;
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)) {
return true;
}
@ -282,7 +282,7 @@ bool widget::WSlider::onSetConfig(const ewol::EConfig& _conf) {
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)) {
return true;
}
@ -301,7 +301,7 @@ bool widget::WSlider::onGetConfig(const char* _config, std::string& _result) con
return false;
}
ewol::Widget* widget::WSlider::getWidgetAtPos(const vec2& _pos) {
ewol::Widget* ewol::widget::WSlider::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) {
return NULL;
}

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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