diff --git a/build b/build index b02c8b52..5ea83bfd 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit b02c8b5221d94dd8446319ea224ff25f801a2924 +Subproject commit 5ea83bfddea9a0c93f65170b73d3be07f8a100e0 diff --git a/sources/ewol/compositing/Area.cpp b/sources/ewol/compositing/Area.cpp index 73044c4e..7839adab 100644 --- a/sources/ewol/compositing/Area.cpp +++ b/sources/ewol/compositing/Area.cpp @@ -10,9 +10,9 @@ #include #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()); diff --git a/sources/ewol/compositing/Area.h b/sources/ewol/compositing/Area.h index 1f89e5c2..9e698d65 100644 --- a/sources/ewol/compositing/Area.h +++ b/sources/ewol/compositing/Area.h @@ -10,78 +10,91 @@ #define __EWOL_COMPOSITING_AREA_H__ #include -#include +#include #include -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 m_coord; //!< internal coord of the object - std::vector m_coordTex; //!< internal texture coordinate for every point - std::vector > 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 m_coord; //!< internal coord of the object + std::vector m_coordTex; //!< internal texture coordinate for every point + std::vector > 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(); + }; + }; }; }; diff --git a/sources/ewol/compositing/Compositing.cpp b/sources/ewol/compositing/Compose.cpp similarity index 54% rename from sources/ewol/compositing/Compositing.cpp rename to sources/ewol/compositing/Compose.cpp index 0ee3cebe..0d1ee833 100644 --- a/sources/ewol/compositing/Compositing.cpp +++ b/sources/ewol/compositing/Compose.cpp @@ -13,41 +13,41 @@ #include -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; } diff --git a/sources/ewol/compositing/Compose.h b/sources/ewol/compositing/Compose.h new file mode 100644 index 00000000..123b7f2d --- /dev/null +++ b/sources/ewol/compositing/Compose.h @@ -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 +#include +#include + +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 diff --git a/sources/ewol/compositing/Compositing.h b/sources/ewol/compositing/Compositing.h deleted file mode 100644 index 756c0c63..00000000 --- a/sources/ewol/compositing/Compositing.h +++ /dev/null @@ -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 -#include -#include - -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 diff --git a/sources/ewol/compositing/Drawing.cpp b/sources/ewol/compositing/Drawing.cpp index 30eed6c6..57227552 100644 --- a/sources/ewol/compositing/Drawing.cpp +++ b/sources/ewol/compositing/Drawing.cpp @@ -217,7 +217,7 @@ static void SutherlandHodgman(std::vector & input, std::vector & 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) { diff --git a/sources/ewol/compositing/Drawing.h b/sources/ewol/compositing/Drawing.h index 49e78517..3d7f4115 100644 --- a/sources/ewol/compositing/Drawing.h +++ b/sources/ewol/compositing/Drawing.h @@ -12,170 +12,206 @@ #include #include -#include +#include #include 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 m_coord; //!< internal position for the text display - std::vector > 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 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 m_coord; //!< internal position for the text display + std::vector > 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 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); + }; }; }; diff --git a/sources/ewol/compositing/Image.cpp b/sources/ewol/compositing/Image.cpp index 829cff13..ba194ba3 100644 --- a/sources/ewol/compositing/Image.cpp +++ b/sources/ewol/compositing/Image.cpp @@ -10,9 +10,9 @@ #include #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); } diff --git a/sources/ewol/compositing/Image.h b/sources/ewol/compositing/Image.h index 3867b64c..1ef7c43a 100644 --- a/sources/ewol/compositing/Image.h +++ b/sources/ewol/compositing/Image.h @@ -10,134 +10,160 @@ #define __EWOL_COMPOSITING_IMAGE_H__ #include -#include +#include #include 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 m_coord; //!< internal coord of the object - std::vector m_coordTex; //!< internal texture coordinate for every point - std::vector > 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 m_coord; //!< internal coord of the object + std::vector m_coordTex; //!< internal texture coordinate for every point + std::vector > 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); + }; }; }; diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 05ce8e40..b42f7f65 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -11,9 +11,9 @@ #include #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; } diff --git a/sources/ewol/compositing/Shaper.h b/sources/ewol/compositing/Shaper.h index 4ccbff04..3f90eb3a 100644 --- a/sources/ewol/compositing/Shaper.h +++ b/sources/ewol/compositing/Shaper.h @@ -10,152 +10,162 @@ #define __EWOL_COMPOSITING_SHAPER_H__ #include -#include +#include #include #include 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); + }; }; }; diff --git a/sources/ewol/compositing/Sprite.cpp b/sources/ewol/compositing/Sprite.cpp index 8925f012..f882318c 100644 --- a/sources/ewol/compositing/Sprite.cpp +++ b/sources/ewol/compositing/Sprite.cpp @@ -10,9 +10,9 @@ #include #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() diff --git a/sources/ewol/compositing/Sprite.h b/sources/ewol/compositing/Sprite.h index d8d7645a..a32e842c 100644 --- a/sources/ewol/compositing/Sprite.h +++ b/sources/ewol/compositing/Sprite.h @@ -14,15 +14,17 @@ #include 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); + }; }; }; diff --git a/sources/ewol/compositing/Text.cpp b/sources/ewol/compositing/Text.cpp index ce1c137f..6cd3ea28 100644 --- a/sources/ewol/compositing/Text.cpp +++ b/sources/ewol/compositing/Text.cpp @@ -12,10 +12,10 @@ #include #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 decorationEmpty; print(_text, decorationEmpty); } -void ewol::Text::print(const std::string& _text) { +void ewol::compositing::Text::print(const std::string& _text) { std::vector 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("\n\n"); tmpData+=_text; tmpData+="\n\n\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& _decoration) { +void ewol::compositing::Text::print(const std::string& _text, const std::vector& _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& _decoration) { +void ewol::compositing::Text::print(const std::u32string& _text, const std::vector& _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::vectorgetHeight(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; } diff --git a/sources/ewol/compositing/Text.h b/sources/ewol/compositing/Text.h index b11f6a9c..f24585f7 100644 --- a/sources/ewol/compositing/Text.h +++ b/sources/ewol/compositing/Text.h @@ -12,415 +12,413 @@ #include #include -#include +#include #include #include #include #include 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 m_coord; //!< internal coord of the object - std::vector m_coordTex; //!< internal texture coordinate for every point - std::vector > 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) - *
-			 *	
- *


- *
- * text exemple in bold other text bold part boldItalic part an other thext - * colored text bold color text bold italic text normal color text the end of the string
- * an an other thext - *
- *


- * - * plop 1 - * - *


- * - * plop 2 - * - *


- * - * Un exemple de text - * - *
- * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done - * @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) - *
-			 *	
-			 *		
-			 *			
- *


- *
- * text exemple in bold other text bold part boldItalic part an other thext - * colored text bold color text bold italic text normal color text the end of the string
- * an an other thext - *
- *


- * - * plop 1 - * - *


- * - * plop 2 - * - *


- * - * Un exemple de text - * - * - * - *
- * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done - * @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& _decoration); - void print(const std::u32string& _text, const std::vector& _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 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 m_coord; //!< internal coord of the object + std::vector m_coordTex; //!< internal texture coordinate for every point + std::vector > 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) + *
+				 *	
+ *


+ *
+ * text exemple in bold other text bold part boldItalic part an other thext + * colored text bold color text bold italic text normal color text the end of the string
+ * an an other thext + *
+ *


+ * + * plop 1 + * + *


+ * + * plop 2 + * + *


+ * + * Un exemple de text + * + *
+ * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done + * @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) + *
+				 *	
+				 *		
+				 *			
+ *


+ *
+ * text exemple in bold other text bold part boldItalic part an other thext + * colored text bold color text bold italic text normal color text the end of the string
+ * an an other thext + *
+ *


+ * + * plop 1 + * + *


+ * + * plop 2 + * + *


+ * + * Un exemple de text + * + * + * + *
+ * @note This is parsed with tiny xml, then be carfull that the XML is correct, and all balises are closed ... otherwite the display can not be done + * @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& _decoration); + void print(const std::u32string& _text, const std::vector& _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 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); + }; }; }; diff --git a/sources/ewol/docBook.h b/sources/ewol/docBook.h deleted file mode 100644 index e69de29b..00000000 diff --git a/sources/ewol/renderer/eContext.cpp b/sources/ewol/renderer/eContext.cpp index 6c31ac50..d72f7b4d 100644 --- a/sources/ewol/renderer/eContext.cpp +++ b/sources/ewol/renderer/eContext.cpp @@ -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); } diff --git a/sources/ewol/renderer/eContext.h b/sources/ewol/renderer/eContext.h index 1af4d179..fe635c8b 100644 --- a/sources/ewol/renderer/eContext.h +++ b/sources/ewol/renderer/eContext.h @@ -23,58 +23,8 @@ #include #include -// 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 m_msgSystem; + etk::MessageFifo m_msgSystem; bool m_displayFps; ewol::Fps m_FpsSystemEvent; ewol::Fps m_FpsSystemContext; diff --git a/sources/ewol/resources/Colored3DObject.cpp b/sources/ewol/resources/Colored3DObject.cpp index 20298de6..edd139bf 100644 --- a/sources/ewol/resources/Colored3DObject.cpp +++ b/sources/ewol/resources/Colored3DObject.cpp @@ -11,10 +11,10 @@ #include #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& _vertices, - const etk::Color& _color, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::draw(std::vector& _vertices, + const etk::Color& _color, + bool _updateDepthBuffer, + bool _depthtest) { if (_vertices.size() <= 0) { return; } @@ -75,11 +75,11 @@ void ewol::Colored3DObject::draw(std::vector& _vertices, } } -void ewol::Colored3DObject::draw(std::vector& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::draw(std::vector& _vertices, + const etk::Color& _color, + mat4& _transformationMatrix, + bool _updateDepthBuffer, + bool _depthtest) { if (_vertices.size() <= 0) { return; } @@ -115,11 +115,11 @@ void ewol::Colored3DObject::draw(std::vector& _vertices, } } -void ewol::Colored3DObject::drawLine(std::vector& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer, - bool _depthtest) { +void ewol::resource::Colored3DObject::drawLine(std::vector& _vertices, + const etk::Color& _color, + mat4& _transformationMatrix, + bool _updateDepthBuffer, + bool _depthtest) { if (_vertices.size() <= 0) { return; } @@ -155,10 +155,10 @@ void ewol::Colored3DObject::drawLine(std::vector& _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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/Colored3DObject.h b/sources/ewol/resources/Colored3DObject.h index 051007a2..d1c4c015 100644 --- a/sources/ewol/resources/Colored3DObject.h +++ b/sources/ewol/resources/Colored3DObject.h @@ -16,43 +16,45 @@ #include 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& _vertices, - const etk::Color& _color, - bool _updateDepthBuffer=true, - bool _depthtest=true); - virtual void draw(std::vector& _vertices, - const etk::Color& _color, - mat4& _transformationMatrix, - bool _updateDepthBuffer=true, - bool _depthtest=true); - virtual void drawLine(std::vector& _vertices, - const etk::Color& _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& _vertices, + const etk::Color& _color, + bool _updateDepthBuffer=true, + bool _depthtest=true); + virtual void draw(std::vector& _vertices, + const etk::Color& _color, + mat4& _transformationMatrix, + bool _updateDepthBuffer=true, + bool _depthtest=true); + virtual void drawLine(std::vector& _vertices, + const etk::Color& _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); + }; }; }; diff --git a/sources/ewol/resources/ConfigFile.cpp b/sources/ewol/resources/ConfigFile.cpp index 3993ca1e..dd2b375e 100644 --- a/sources/ewol/resources/ConfigFile.cpp +++ b/sources/ewol/resources/ConfigFile.cpp @@ -13,10 +13,10 @@ #include #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(getManager().localKeep(_filename)); + ewol::resource::ConfigFile* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/ConfigFile.h b/sources/ewol/resources/ConfigFile.h index 2de35b1c..a33398d0 100644 --- a/sources/ewol/resources/ConfigFile.h +++ b/sources/ewol/resources/ConfigFile.h @@ -14,70 +14,72 @@ #include 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 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 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); + }; }; }; diff --git a/sources/ewol/resources/FontFreeType.cpp b/sources/ewol/resources/FontFreeType.cpp index 30f40c15..b4f3dc3c 100644 --- a/sources/ewol/resources/FontFreeType.cpp +++ b/sources/ewol/resources/FontFreeType.cpp @@ -19,13 +19,13 @@ #include #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& listGlyph) { +void ewol::resource::FontFreeType::generateKerning(int32_t fontSize, std::vector& listGlyph) { if(false == m_init) { return; } @@ -257,7 +256,7 @@ void ewol::FontFreeType::generateKerning(int32_t fontSize, std::vector(getManager().localKeep(_filename)); + ewol::resource::FontBase* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/FontFreeType.h b/sources/ewol/resources/FontFreeType.h index 540e03d4..e7fef67f 100644 --- a/sources/ewol/resources/FontFreeType.h +++ b/sources/ewol/resources/FontFreeType.h @@ -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& _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& _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 diff --git a/sources/ewol/resources/Image.cpp b/sources/ewol/resources/Image.cpp index f847c3ca..505d1c5f 100644 --- a/sources/ewol/resources/Image.cpp +++ b/sources/ewol/resources/Image.cpp @@ -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(getManager().localKeep(TmpFilename)); + ewol::resource::TextureFile* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/Image.h b/sources/ewol/resources/Image.h index 44171484..3e56ad81 100644 --- a/sources/ewol/resources/Image.h +++ b/sources/ewol/resources/Image.h @@ -16,30 +16,32 @@ #include 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); + }; }; }; diff --git a/sources/ewol/resources/ResourceManager.cpp b/sources/ewol/resources/Manager.cpp similarity index 90% rename from sources/ewol/resources/ResourceManager.cpp rename to sources/ewol/resources/Manager.cpp index fcdf916c..9a388e7c 100644 --- a/sources/ewol/resources/ResourceManager.cpp +++ b/sources/ewol/resources/Manager.cpp @@ -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 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; iiiremoveContextToLate(); @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace ewol { + namespace resource { + class Manager { + private: + std::vector m_resourceList; + std::vector 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 + diff --git a/sources/ewol/resources/Mesh.cpp b/sources/ewol/resources/Mesh.cpp index d8663a5c..d891dceb 100644 --- a/sources/ewol/resources/Mesh.cpp +++ b/sources/ewol/resources/Mesh.cpp @@ -12,10 +12,10 @@ #include #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& 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 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(getManager().localKeep(_meshName)); +ewol::resource::Mesh* ewol::resource::Mesh::keep(const std::string& _meshName) { + ewol::resource::Mesh* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/Mesh.h b/sources/ewol/resources/Mesh.h index 96f23f88..0268556a 100644 --- a/sources/ewol/resources/Mesh.h +++ b/sources/ewol/resources/Mesh.h @@ -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 m_faces; - std::vector 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 m_listVertex; //!< List of all vertex in the element - std::vector m_listUV; //!< List of all UV point in the mesh (for the specify texture) - std::vector m_listFacesNormal; //!< List of all Face normal, when calculated - std::vector m_listVertexNormal; //!< List of all Face normal, when calculated - etk::Hash m_listFaces; //!< List of all Face for the mesh - etk::Hash m_materials; - std::vector 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& 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 m_faces; + std::vector 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 m_listVertex; //!< List of all vertex in the element + std::vector m_listUV; //!< List of all UV point in the mesh (for the specify texture) + std::vector m_listFacesNormal; //!< List of all Face normal, when calculated + std::vector m_listVertexNormal; //!< List of all Face normal, when calculated + etk::Hash m_listFaces; //!< List of all Face for the mesh + etk::Hash m_materials; + std::vector 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& 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); + }; }; }; diff --git a/sources/ewol/resources/Program.cpp b/sources/ewol/resources/Program.cpp index e8bbe6ad..675194ff 100644 --- a/sources/ewol/resources/Program.cpp +++ b/sources/ewol/resources/Program.cpp @@ -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 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(getManager().localKeep(_filename)); + ewol::resource::Program* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } \ No newline at end of file diff --git a/sources/ewol/resources/Program.h b/sources/ewol/resources/Program.h index 829bd94a..b3e903e2 100644 --- a/sources/ewol/resources/Program.h +++ b/sources/ewol/resources/Program.h @@ -18,266 +18,268 @@ #include 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 : - *
-	 * # 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
-	 * 
- */ - class Program : public ewol::Resource { - private : - bool m_exist; //!< the file existed - GLuint m_program; //!< openGL id of the current program - std::vector m_shaderList; //!< List of all the shader loaded - std::vector 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 : + *
+		 * # 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
+		 * 
+ */ + class Program : public ewol::resource::Resource { + private : + bool m_exist; //!< the file existed + GLuint m_program; //!< openGL id of the current program + std::vector m_shaderList; //!< List of all the shader loaded + std::vector 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); + }; }; }; diff --git a/sources/ewol/resources/Resource.cpp b/sources/ewol/resources/Resource.cpp index 10532868..085a3de2 100644 --- a/sources/ewol/resources/Resource.cpp +++ b/sources/ewol/resources/Resource.cpp @@ -15,22 +15,22 @@ #include -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(); } \ No newline at end of file diff --git a/sources/ewol/resources/Resource.h b/sources/ewol/resources/Resource.h index 91bd57d2..48cadeea 100644 --- a/sources/ewol/resources/Resource.h +++ b/sources/ewol/resources/Resource.h @@ -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); + }; }; }; diff --git a/sources/ewol/resources/ResourceManager.h b/sources/ewol/resources/ResourceManager.h deleted file mode 100644 index 991ed2f4..00000000 --- a/sources/ewol/resources/ResourceManager.h +++ /dev/null @@ -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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace ewol { - class ResourceManager { - private: - std::vector m_resourceList; - std::vector 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 - diff --git a/sources/ewol/resources/Shader.cpp b/sources/ewol/resources/Shader.cpp index 0d2f7741..6832a959 100644 --- a/sources/ewol/resources/Shader.cpp +++ b/sources/ewol/resources/Shader.cpp @@ -13,10 +13,10 @@ #include #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(getManager().localKeep(_filename)); + ewol::resource::Shader* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/Shader.h b/sources/ewol/resources/Shader.h index a8eca2f3..5632cbfc 100644 --- a/sources/ewol/resources/Shader.h +++ b/sources/ewol/resources/Shader.h @@ -15,71 +15,73 @@ #include 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); + }; }; }; diff --git a/sources/ewol/resources/Texture.cpp b/sources/ewol/resources/Texture.cpp index 9c9dd3ca..80c827ea 100644 --- a/sources/ewol/resources/Texture.cpp +++ b/sources/ewol/resources/Texture.cpp @@ -14,7 +14,7 @@ #include #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(_object); + ewol::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/Texture.h b/sources/ewol/resources/Texture.h index 90cc0601..01de3965 100644 --- a/sources/ewol/resources/Texture.h +++ b/sources/ewol/resources/Texture.h @@ -16,52 +16,53 @@ #include 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 diff --git a/sources/ewol/resources/TexturedFont.cpp b/sources/ewol/resources/TexturedFont.cpp index b27ab447..99427710 100644 --- a/sources/ewol/resources/TexturedFont.cpp +++ b/sources/ewol/resources/TexturedFont.cpp @@ -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(getManager().localKeep(_filename)); + ewol::resource::TexturedFont* object = static_cast(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(_object); + ewol::resource::Resource* object2 = static_cast(_object); if (getManager().release(object2) == true) { EWOL_DEBUG("REMOVE: TexturedFont : file : '" << name << "' count=" << count); //etk::displayBacktrace(false); diff --git a/sources/ewol/resources/TexturedFont.h b/sources/ewol/resources/TexturedFont.h index a35a0807..bb2aadac 100644 --- a/sources/ewol/resources/TexturedFont.h +++ b/sources/ewol/resources/TexturedFont.h @@ -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 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 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 diff --git a/sources/ewol/resources/VirtualBufferObject.cpp b/sources/ewol/resources/VirtualBufferObject.cpp index 71460fc7..360c6739 100644 --- a/sources/ewol/resources/VirtualBufferObject.cpp +++ b/sources/ewol/resources/VirtualBufferObject.cpp @@ -13,9 +13,9 @@ #include #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 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(_object); + ewol::resource::Resource* object2 = static_cast(_object); getManager().release(object2); _object = NULL; } diff --git a/sources/ewol/resources/VirtualBufferObject.h b/sources/ewol/resources/VirtualBufferObject.h index ccb243c1..6f30a578 100644 --- a/sources/ewol/resources/VirtualBufferObject.h +++ b/sources/ewol/resources/VirtualBufferObject.h @@ -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 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& 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 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& 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 diff --git a/sources/ewol/resources/font/FontBase.h b/sources/ewol/resources/font/FontBase.h index 5959c291..7dddb94f 100644 --- a/sources/ewol/resources/font/FontBase.h +++ b/sources/ewol/resources/font/FontBase.h @@ -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& _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& _listGlyph) { }; + + virtual void display(void) {}; + }; }; }; diff --git a/sources/ewol/resources/font/GlyphProperty.h b/sources/ewol/resources/font/GlyphProperty.h index cb94e93f..cf8b762c 100644 --- a/sources/ewol/resources/font/GlyphProperty.h +++ b/sources/ewol/resources/font/GlyphProperty.h @@ -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 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_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 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; iiiremoveObject(); @@ -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; } diff --git a/sources/ewol/widget/Button.h b/sources/ewol/widget/Button.h index 5f492de0..a0f37108 100644 --- a/sources/ewol/widget/Button.h +++ b/sources/ewol/widget/Button.h @@ -19,155 +19,156 @@ #include -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 diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index bb3d0fcf..931fa3bc 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -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(); } diff --git a/sources/ewol/widget/ButtonColor.h b/sources/ewol/widget/ButtonColor.h index a159e016..52c09ce9 100644 --- a/sources/ewol/widget/ButtonColor.h +++ b/sources/ewol/widget/ButtonColor.h @@ -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); + }; }; }; diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index 247689f3..69ac9d2a 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -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 diff --git a/sources/ewol/widget/CheckBox.h b/sources/ewol/widget/CheckBox.h index 2b8fbceb..a05aa1c6 100644 --- a/sources/ewol/widget/CheckBox.h +++ b/sources/ewol/widget/CheckBox.h @@ -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 diff --git a/sources/ewol/widget/ColorBar.cpp b/sources/ewol/widget/ColorBar.cpp index e60699fe..8cfe19de 100644 --- a/sources/ewol/widget/ColorBar.cpp +++ b/sources/ewol/widget/ColorBar.cpp @@ -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()) { diff --git a/sources/ewol/widget/ColorBar.h b/sources/ewol/widget/ColorBar.h index 33b69f5b..b088d543 100644 --- a/sources/ewol/widget/ColorBar.h +++ b/sources/ewol/widget/ColorBar.h @@ -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 diff --git a/sources/ewol/widget/Composer.cpp b/sources/ewol/widget/Composer.cpp index 9098e102..10f61129 100644 --- a/sources/ewol/widget/Composer.cpp +++ b/sources/ewol/widget/Composer.cpp @@ -13,32 +13,32 @@ #include #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 << "\""); diff --git a/sources/ewol/widget/Composer.h b/sources/ewol/widget/Composer.h index fee09cc5..1ca0caa4 100644 --- a/sources/ewol/widget/Composer.h +++ b/sources/ewol/widget/Composer.h @@ -13,74 +13,75 @@ #include #include -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=""); + }; }; }; diff --git a/sources/ewol/widget/Container.cpp b/sources/ewol/widget/Container.cpp index 688aac13..6b24e5d5 100644 --- a/sources/ewol/widget/Container.cpp +++ b/sources/ewol/widget/Container.cpp @@ -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 ... diff --git a/sources/ewol/widget/Container.h b/sources/ewol/widget/Container.h index 90a5f61b..6c75058e 100644 --- a/sources/ewol/widget/Container.h +++ b/sources/ewol/widget/Container.h @@ -13,53 +13,55 @@ #include #include -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); + }; }; }; diff --git a/sources/ewol/widget/ContainerN.cpp b/sources/ewol/widget/ContainerN.cpp index e2d2599f..e692fa1a 100644 --- a/sources/ewol/widget/ContainerN.cpp +++ b/sources/ewol/widget/ContainerN.cpp @@ -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