change version 0.9.0

This commit is contained in:
Edouard DUPIN 2014-06-03 21:42:17 +02:00
commit 46b5eca2cb
136 changed files with 2617 additions and 2390 deletions

2
build

@ -1 +1 @@
Subproject commit 2985efea70b5bff3bda00e948a072a63e1bc3d96
Subproject commit c73da6c4aca375ba3d9ed391d7052e119daa9a90

2
external/airtaudio vendored

@ -1 +1 @@
Subproject commit bb547a72d99802ac5d9a99c843549f175c856826
Subproject commit b0eb151df0802a1d63a5cb6b6812a4460ddd09a1

View File

@ -39,6 +39,8 @@ def create(target):
'bullet/src/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp',
'bullet/src/BulletCollision/NarrowPhaseCollision/btGjkEpa2.cpp',
'bullet/src/BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.cpp',
'bullet/src/BulletCollision/CollisionDispatch/btCompoundCompoundCollisionAlgorithm.cpp',
'bullet/src/BulletCollision/CollisionDispatch/btHashedSimplePairCache.cpp',
'bullet/src/BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.cpp',
'bullet/src/BulletCollision/CollisionDispatch/btCollisionObject.cpp',
'bullet/src/BulletCollision/CollisionDispatch/btEmptyCollisionAlgorithm.cpp',

2
external/egami vendored

@ -1 +1 @@
Subproject commit bb58a8c06e30cf141a59f8a09a544919c1f695ed
Subproject commit 34eac48f5114151bab137e9cb177513c7cf42d96

2
external/ege vendored

@ -1 +1 @@
Subproject commit ba20ab59f74866367fb8efa260fc6eb26889422b
Subproject commit 73455cc61be78fd2a76466fb8c6a1aaabe68bf61

2
external/etk vendored

@ -1 +1 @@
Subproject commit b60324928a7d69d2abc7afe4ab726676f560d317
Subproject commit cfc4d435b433fba9414330815b29e26cfe82927d

View File

@ -15,13 +15,13 @@
ewol::compositing::Area::Area(const ivec2& _size) :
m_position(0.0, 0.0, 0.0),
m_color(etk::color::white),
m_GLprogram(NULL),
m_GLprogram(nullptr),
m_GLPosition(-1),
m_GLMatrix(-1),
m_GLColor(-1),
m_GLtexture(-1),
m_GLtexID(-1),
m_resource(NULL) {
m_resource(nullptr) {
m_resource = ewol::resource::Texture::keep();
m_resource->setImageSize(_size);
m_resource->flush();
@ -29,15 +29,14 @@ ewol::compositing::Area::Area(const ivec2& _size) :
}
ewol::compositing::Area::~Area() {
ewol::resource::Texture::release(m_resource);
ewol::resource::Program::release(m_GLprogram);
}
void ewol::compositing::Area::loadProgram() {
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = ewol::resource::Program::keep("DATA:textured3D.prog");
if (NULL != m_GLprogram) {
if (nullptr != m_GLprogram) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
@ -51,11 +50,11 @@ void ewol::compositing::Area::draw(bool _disableDepthTest) {
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_resource == NULL) {
if (m_resource == nullptr) {
// this is a normale case ... the user can choice to have no image ...
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}

View File

@ -22,14 +22,14 @@ namespace ewol {
vec3 m_position; //!< The current position to draw
etk::Color<> m_color; //!< The text foreground color
private:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::object::Shared<ewol::resource::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::resource::Texture* m_resource; //!< texture resources
ewol::object::Shared<ewol::resource::Texture> m_resource; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point
@ -47,7 +47,7 @@ namespace ewol {
/**
* @brief generic destructor
*/
~Area();
virtual ~Area();
public:
/**
* @brief draw All the refistered text in the current element on openGL

View File

@ -224,7 +224,7 @@ ewol::compositing::Drawing::Drawing() :
m_clippingEnable(false),
m_color(etk::color::black),
m_colorBg(etk::color::none),
m_GLprogram(NULL),
m_GLprogram(nullptr),
m_GLPosition(-1),
m_GLMatrix(-1),
m_GLColor(-1),
@ -277,7 +277,7 @@ void ewol::compositing::Drawing::resetCount() {
}
void ewol::compositing::Drawing::unLoadProgram() {
ewol::resource::Program::release(m_GLprogram);
m_GLprogram.reset();
}
void ewol::compositing::Drawing::loadProgram() {
@ -286,7 +286,7 @@ void ewol::compositing::Drawing::loadProgram() {
// oad the new ...
m_GLprogram = ewol::resource::Program::keep("DATA:color3.prog");
// get the shader resource :
if (NULL != m_GLprogram ) {
if (nullptr != m_GLprogram ) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
@ -299,7 +299,7 @@ void ewol::compositing::Drawing::draw(bool _disableDepthTest) {
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}

View File

@ -28,7 +28,7 @@ namespace ewol {
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
private:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::object::Shared<ewol::resource::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)
@ -43,7 +43,7 @@ namespace ewol {
/**
* @brief Basic destructor
*/
~Drawing();
virtual ~Drawing();
private:
/**
* @brief load the openGL program and get all the ID needed

View File

@ -21,35 +21,33 @@ ewol::compositing::Image::Image(const std::string& _imageName, bool _df) :
m_clippingEnable(false),
m_color(etk::color::white),
m_angle(0.0),
m_GLprogram(NULL),
m_GLprogram(nullptr),
m_GLPosition(-1),
m_GLMatrix(-1),
m_GLColor(-1),
m_GLtexture(-1),
m_GLtexID(-1),
m_distanceFieldMode(_df),
m_resource(NULL),
m_resourceDF(NULL) {
m_resource(nullptr),
m_resourceDF(nullptr) {
setSource(_imageName);
loadProgram();
}
ewol::compositing::Image::~Image() {
ewol::resource::TextureFile::release(m_resource);
ewol::resource::ImageDF::release(m_resourceDF);
ewol::resource::Program::release(m_GLprogram);
}
void ewol::compositing::Image::loadProgram() {
// get the shader resource :
m_GLPosition = 0;
ewol::resource::Program::release(m_GLprogram);
m_GLprogram.reset();
if (m_distanceFieldMode == true) {
m_GLprogram = ewol::resource::Program::keep("DATA:texturedDF.prog");
} else {
m_GLprogram = ewol::resource::Program::keep("DATA:textured3D.prog");
}
if (m_GLprogram != NULL) {
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
@ -63,12 +61,12 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
//EWOL_WARNING("Nothink to draw...");
return;
}
if ( m_resource == NULL
&& m_resourceDF == NULL) {
if ( m_resource == nullptr
&& m_resourceDF == nullptr) {
// this is a normale case ... the user can choice to have no image ...
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -82,7 +80,7 @@ void ewol::compositing::Image::draw(bool _disableDepthTest) {
m_GLprogram->use();
m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
if (m_resource != NULL) {
if (m_resource != nullptr) {
if (m_distanceFieldMode == true) {
EWOL_ERROR("FONT type error Request distance field and display normal ...");
}
@ -249,58 +247,55 @@ void ewol::compositing::Image::printPart(const vec2& _size,
void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) {
clear();
ewol::resource::TextureFile* resource = m_resource;
ewol::resource::ImageDF* resourceDF = m_resourceDF;
ewol::object::Shared<ewol::resource::TextureFile> resource(m_resource);
ewol::object::Shared<ewol::resource::ImageDF> resourceDF(m_resourceDF);
m_filename = _newFile;
m_requestSize = _size;
m_resource = NULL;
m_resourceDF = NULL;
m_resource.reset();
m_resourceDF.reset();
ivec2 tmpSize(_size.x(),_size.y());
// note that no image can be loaded...
if (_newFile != "") {
// link to new one
if (m_distanceFieldMode == false) {
m_resource = ewol::resource::TextureFile::keep(m_filename, tmpSize);
if (NULL == m_resource) {
if (m_resource == nullptr) {
EWOL_ERROR("Can not get Image resource");
}
} else {
m_resourceDF = ewol::resource::ImageDF::keep(m_filename, tmpSize);
if (NULL == m_resourceDF) {
if (m_resourceDF == nullptr) {
EWOL_ERROR("Can not get Image resource DF");
}
}
}
if ( m_resource == NULL
&& m_resourceDF == NULL) {
if (resource != NULL) {
if ( m_resource == nullptr
&& m_resourceDF == nullptr) {
if (resource != nullptr) {
EWOL_WARNING("Retrive previous resource");
m_resource = resource;
}
if (resourceDF != NULL) {
if (resourceDF != nullptr) {
EWOL_WARNING("Retrive previous resource (DF)");
m_resourceDF = resourceDF;
}
} else {
ewol::resource::TextureFile::release(resource);
ewol::resource::ImageDF::release(resourceDF);
}
}
bool ewol::compositing::Image::hasSources() {
return (m_resource != NULL || m_resourceDF != NULL);
return (m_resource != nullptr || m_resourceDF != nullptr);
}
vec2 ewol::compositing::Image::getRealSize() {
if ( m_resource == NULL
&& m_resourceDF == NULL) {
if ( m_resource == nullptr
&& m_resourceDF == nullptr) {
return vec2(0,0);
}
if (m_resource != NULL) {
if (m_resource != nullptr) {
return m_resource->getRealSize();
}
if (m_resourceDF != NULL) {
if (m_resourceDF != nullptr) {
return m_resourceDF->getRealSize();
}
return vec2(0,0);

View File

@ -29,7 +29,7 @@ namespace ewol {
etk::Color<> m_color; //!< The text foreground color
float m_angle; //!< Angle to set at the axes
private:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::object::Shared<ewol::resource::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)
@ -37,8 +37,8 @@ namespace ewol {
int32_t m_GLtexID; //!< openGL id on the element (texture ID)
private:
bool m_distanceFieldMode; //!< select distance field mode
ewol::resource::TextureFile* m_resource; //!< texture resources
ewol::resource::ImageDF* m_resourceDF; //!< texture resources
ewol::object::Shared<ewol::resource::TextureFile> m_resource; //!< texture resources
ewol::object::Shared<ewol::resource::ImageDF> m_resourceDF; //!< texture resources
std::vector<vec3 > m_coord; //!< internal coord of the object
std::vector<vec2 > m_coordTex; //!< internal texture coordinate for every point
std::vector<etk::Color<float> > m_coordColor; //!< internal color of the different point

View File

@ -15,21 +15,21 @@
ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
m_name(_shaperName),
m_config(NULL),
m_config(nullptr),
m_confIdMode(-1),
m_confIdDisplayOutside(-1),
m_confIdChangeTime(-1),
m_confProgramFile(-1),
m_confColorFile(-1),
m_confImageFile(-1),
m_GLprogram(NULL),
m_GLprogram(nullptr),
m_GLPosition(-1),
m_GLMatrix(-1),
m_GLStateActivate(-1),
m_GLStateOld(-1),
m_GLStateNew(-1),
m_GLStateTransition(-1),
m_resourceTexture(NULL),
m_resourceTexture(nullptr),
m_nextStatusRequested(-1),
m_propertyOrigin(0,0),
m_propertySize(0,0),
@ -57,10 +57,10 @@ ewol::compositing::Shaper::~Shaper() {
}
void ewol::compositing::Shaper::unLoadProgram() {
ewol::resource::Program::release(m_GLprogram);
ewol::resource::TextureFile::release(m_resourceTexture);
ewol::resource::ConfigFile::release(m_config);
ewol::resource::ColorFile::release(m_colorProperty);
m_GLprogram.reset();
m_resourceTexture.reset();
m_config.reset();
m_colorProperty.reset();
for (size_t iii=0; iii<shaperPosCount; ++iii) {
m_confIdPaddingOut[iii] = -1;
m_confIdBorder[iii] = -1;
@ -85,7 +85,7 @@ void ewol::compositing::Shaper::loadProgram() {
return;
}
m_config = ewol::resource::ConfigFile::keep(m_name);
if (NULL != m_config) {
if (nullptr != m_config) {
m_confIdMode = m_config->request("mode");
m_confIdDisplayOutside = m_config->request("display-outside");
m_confIdPaddingOut[shaperPosLeft] = m_config->request("padding-out-left");
@ -119,7 +119,7 @@ void ewol::compositing::Shaper::loadProgram() {
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = ewol::resource::Program::keep(tmpFilename);
if (m_GLprogram != NULL) {
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
// Widget property == > for the Vertex shader
@ -159,8 +159,8 @@ void ewol::compositing::Shaper::loadProgram() {
EWOL_DEBUG("Shaper try load colorFile : '" << tmpFilename << "'");
}
m_colorProperty = ewol::resource::ColorFile::keep(tmpFilename);
if ( m_GLprogram != NULL
&& m_colorProperty != NULL) {
if ( m_GLprogram != nullptr
&& m_colorProperty != nullptr) {
std::vector<std::string> listColor = m_colorProperty->getColors();
for (auto tmpColor : listColor) {
int32_t glId = m_GLprogram->getUniform(tmpColor);
@ -172,11 +172,11 @@ void ewol::compositing::Shaper::loadProgram() {
}
void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
if (m_config == NULL) {
if (m_config == nullptr) {
// this is a normale case ... the user can choice to have no config basic file ...
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -197,7 +197,7 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
for (auto element : m_listAssiciatedId) {
m_GLprogram->uniform(element.x(), m_colorProperty->get(element.y()));
}
if (NULL!=m_resourceTexture) {
if (nullptr!=m_resourceTexture) {
// TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId());
}
@ -471,7 +471,7 @@ void ewol::compositing::Shaper::setShape(const vec2& _origin, const vec2& _size,
EWOL_ERROR(" inside = " << inside);
*/
int32_t mode = 0;
if (m_config != NULL) {
if (m_config != nullptr) {
mode = m_config->getNumber(m_confIdMode);
}
bool displayOutside = m_config->getBoolean(m_confIdDisplayOutside);
@ -572,7 +572,7 @@ ewol::Padding ewol::compositing::Shaper::getPadding() {
ewol::Padding ewol::compositing::Shaper::getPaddingIn() {
ewol::Padding padding(0,0,0,0);
if (m_config != NULL) {
if (m_config != nullptr) {
padding.setValue(m_config->getNumber(m_confIdPaddingIn[shaperPosLeft]),
m_config->getNumber(m_confIdPaddingIn[shaperPosTop]),
m_config->getNumber(m_confIdPaddingIn[shaperPosRight]),
@ -583,7 +583,7 @@ ewol::Padding ewol::compositing::Shaper::getPaddingIn() {
ewol::Padding ewol::compositing::Shaper::getPaddingOut() {
ewol::Padding padding(0,0,0,0);
if (m_config != NULL) {
if (m_config != nullptr) {
padding.setValue(m_config->getNumber(m_confIdPaddingOut[shaperPosLeft]),
m_config->getNumber(m_confIdPaddingOut[shaperPosTop]),
m_config->getNumber(m_confIdPaddingOut[shaperPosRight]),
@ -594,7 +594,7 @@ ewol::Padding ewol::compositing::Shaper::getPaddingOut() {
ewol::Padding ewol::compositing::Shaper::getBorder() {
ewol::Padding padding(0,0,0,0);
if (m_config != NULL) {
if (m_config != nullptr) {
padding.setValue(m_config->getNumber(m_confIdBorder[shaperPosLeft]),
m_config->getNumber(m_confIdBorder[shaperPosTop]),
m_config->getNumber(m_confIdBorder[shaperPosRight]),
@ -611,13 +611,13 @@ void ewol::compositing::Shaper::setSource(const std::string& _newFile) {
}
bool ewol::compositing::Shaper::hasSources() {
return m_GLprogram!=NULL;
return m_GLprogram!=nullptr;
}
const etk::Color<float>& ewol::compositing::Shaper::getColor(int32_t _id) {
static const etk::Color<float> errorValue(0,0,0,0);
if (m_colorProperty == NULL) {
if (m_colorProperty == nullptr) {
return errorValue;
}
return m_colorProperty->get(_id);

View File

@ -44,7 +44,7 @@ namespace ewol {
private:
std::string m_name; //!< Name of the configuration of the shaper.
// External theme config:
ewol::resource::ConfigFile* m_config; //!< pointer on the config file resources
ewol::object::Shared<ewol::resource::ConfigFile> m_config; //!< pointer on the config file resources
int32_t m_confIdDisplayExternal; //!< Display external border
int32_t m_confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom
int32_t m_confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom
@ -56,7 +56,7 @@ namespace ewol {
int32_t m_confColorFile; //!< ConfigFile opengGl color file Name
int32_t m_confImageFile; //!< ConfigFile opengGl program Name
// openGL shaders programs:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::object::Shared<ewol::resource::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_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on vec2(X,Y))
@ -66,7 +66,7 @@ namespace ewol {
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::resource::TextureFile* m_resourceTexture; //!< texture resources (for the image)
ewol::object::Shared<ewol::resource::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
@ -81,7 +81,7 @@ namespace ewol {
vec2 m_pos[SHAPER_NB_MAX_VERTEX]; //!< podition to display property
int32_t m_nbVertexToDisplay;
// color management theme:
ewol::resource::ColorFile* m_colorProperty; //!< input resource for color management
ewol::object::Shared<ewol::resource::ColorFile> m_colorProperty; //!< input resource for color management
std::vector<ivec2> m_listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X)
private:
/**
@ -101,7 +101,7 @@ namespace ewol {
/**
* @brief generic destructor
*/
~Shaper();
virtual ~Shaper();
public:
/**
* @brief draw All the refistered text in the current element on openGL
@ -233,7 +233,7 @@ namespace ewol {
* @return The Id of the color
*/
int32_t requestColor(const std::string& _name) {
if (m_colorProperty == NULL) {
if (m_colorProperty == nullptr) {
return -1;
}
return m_colorProperty->request(_name);
@ -251,7 +251,7 @@ namespace ewol {
* @return The Id of the element
*/
int32_t requestConfig(const std::string& _name) {
if (m_config == NULL) {
if (m_config == nullptr) {
return -1;
}
return m_config->request(_name);
@ -263,7 +263,7 @@ namespace ewol {
*/
double getConfigNumber(int32_t _id) {
if ( _id == -1
|| m_config == NULL) {
|| m_config == nullptr) {
return 0.0;
}
return m_config->getNumber(_id);

View File

@ -16,13 +16,13 @@
ewol::compositing::Text::Text(const std::string& _fontName, int32_t _fontSize) :
m_font(NULL) {
m_font(nullptr) {
setFont(_fontName, _fontSize);
}
ewol::compositing::Text::~Text() {
ewol::resource::TexturedFont::release(m_font);
}
void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) {
@ -30,16 +30,16 @@ void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _en
// draw BG in any case:
m_vectorialDraw.draw();
if (m_coord.size() <= 0 || m_font == NULL) {
if (m_coord.size() <= 0 || m_font == nullptr) {
// TODO : a remÃtre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_WARNING("no font...");
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -74,16 +74,16 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) {
// draw BG in any case:
m_vectorialDraw.draw();
if (m_coord.size() <= 0 || m_font == NULL) {
if (m_coord.size() <= 0 || m_font == nullptr) {
// TODO : a remèe ...
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_WARNING("no font...");
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -107,23 +107,23 @@ void ewol::compositing::Text::drawD(bool _disableDepthTest) {
}
float ewol::compositing::Text::getSize() {
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_WARNING("no font...");
return 1.0f;
}
return m_font->getFontSize();
}
float ewol::compositing::Text::getHeight() {
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_WARNING("no font...");
return 10.0f;
}
return m_font->getHeight(m_mode);
}
ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(char32_t _charcode) {
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_WARNING("no font...");
return NULL;
return nullptr;
}
return m_font->getGlyphPointer(_charcode, m_mode);
}
@ -131,7 +131,7 @@ ewol::GlyphProperty * ewol::compositing::Text::getGlyphPointer(char32_t _charcod
void ewol::compositing::Text::setFontSize(int32_t _fontSize) {
// get old size
std::string fontName = "";
if (m_font != NULL) {
if (m_font != nullptr) {
fontName = m_font->getName();
// Remove the :XX for the size ...
size_t pos = fontName.rfind(':');
@ -143,7 +143,7 @@ void ewol::compositing::Text::setFontSize(int32_t _fontSize) {
void ewol::compositing::Text::setFontName(const std::string& _fontName) {
// get old size
int32_t fontSize = -1;
if (m_font != NULL) {
if (m_font != nullptr) {
fontSize = m_font->getFontSize();
}
setFont(_fontName, fontSize);
@ -152,7 +152,7 @@ void ewol::compositing::Text::setFontName(const std::string& _fontName) {
void ewol::compositing::Text::setFont(std::string _fontName, int32_t _fontSize) {
clear();
// remove old one
ewol::resource::TexturedFont * previousFont = m_font;
ewol::object::Shared<ewol::resource::TexturedFont> previousFont = m_font;
if (_fontSize <= 0) {
_fontSize = ewol::getContext().getFontDefault().getSize();
}
@ -164,16 +164,14 @@ void ewol::compositing::Text::setFont(std::string _fontName, int32_t _fontSize)
EWOL_VERBOSE("plop : " << _fontName << " size=" << _fontSize << " result :" << _fontName);
// link to new one
m_font = ewol::resource::TexturedFont::keep(_fontName);
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_ERROR("Can not get font resource");
m_font = previousFont;
} else {
ewol::resource::TexturedFont::release(previousFont);
}
}
void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) {
if (m_font != NULL) {
if (m_font != nullptr) {
m_mode = m_font->getWrappingMode(_mode);
}
}
@ -181,7 +179,7 @@ void ewol::compositing::Text::setFontMode(enum ewol::font::mode _mode) {
void ewol::compositing::Text::printChar(const char32_t& _charcode) {
// get a pointer on the glyph property :
ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode);
if (NULL == myGlyph) {
if (nullptr == myGlyph) {
EWOL_ERROR(" font does not really existed ...");
return;
}

View File

@ -25,7 +25,7 @@ namespace ewol {
namespace compositing {
class Text : public ewol::compositing::TextBase {
protected:
ewol::resource::TexturedFont* m_font; //!< Font resources
ewol::object::Shared<ewol::resource::TexturedFont> m_font; //!< Font resources
public:
/**
* @brief generic constructor

View File

@ -32,7 +32,7 @@ ewol::compositing::TextBase::TextBase(const std::string& _shaderName, bool _load
m_startTextpos(0),
m_stopTextPos(0),
m_alignement(alignDisable),
m_GLprogram(NULL),
m_GLprogram(nullptr),
m_GLPosition(-1),
m_GLMatrix(-1),
m_GLColor(-1),
@ -47,15 +47,15 @@ ewol::compositing::TextBase::TextBase(const std::string& _shaderName, bool _load
ewol::compositing::TextBase::~TextBase() {
ewol::resource::Program::release(m_GLprogram);
}
void ewol::compositing::TextBase::loadProgram(const std::string& _shaderName) {
// get the shader resource :
m_GLPosition = 0;
ewol::resource::Program* old = m_GLprogram;
ewol::object::Shared<ewol::resource::Program> old = m_GLprogram;
m_GLprogram = ewol::resource::Program::keep(_shaderName);
if (m_GLprogram != NULL) {
if (m_GLprogram != nullptr) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getAttribute("EW_color");
m_GLtexture = m_GLprogram->getAttribute("EW_texture2d");
@ -66,10 +66,8 @@ void ewol::compositing::TextBase::loadProgram(const std::string& _shaderName) {
} else {
EWOL_ERROR("Can not load the program => keep previous one...");
m_GLprogram = old;
old = NULL;
old = nullptr;
}
// Release old program if needed ...
ewol::resource::Program::release(old);
}
void ewol::compositing::TextBase::translate(const vec3& _vect) {
@ -249,7 +247,7 @@ void ewol::compositing::TextBase::print(const std::string& _text) {
void ewol::compositing::TextBase::parseHtmlNode(exml::Element* _element) {
// get the static real pointer
if (_element == NULL) {
if (_element == nullptr) {
EWOL_ERROR( "Error Input node does not existed ...");
}
for(size_t iii=0; iii< _element->size(); iii++) {
@ -265,7 +263,7 @@ void ewol::compositing::TextBase::parseHtmlNode(exml::Element* _element) {
continue;
}
exml::Element* elem = _element->getElement(iii);
if (elem == NULL) {
if (elem == nullptr) {
EWOL_ERROR("Cast error ...");
continue;
}
@ -372,13 +370,13 @@ void ewol::compositing::TextBase::printHTML(const std::string& _text) {
}
exml::Element* root = (exml::Element*)doc.getNamed( "html" );
if (root == NULL) {
if (root == nullptr) {
EWOL_ERROR( "can not load XML: main node not find: \"html\"");
doc.display();
return;
}
exml::Element* bodyNode = (exml::Element*)root->getNamed( "body" );
if (root == NULL) {
if (root == nullptr) {
EWOL_ERROR( "can not load XML: main node not find: \"body\"");
return;
}
@ -400,13 +398,13 @@ void ewol::compositing::TextBase::printHTML(const std::u32string& _text) {
}
exml::Element* root = (exml::Element*)doc.getNamed( "html" );
if (root == NULL) {
if (root == nullptr) {
EWOL_ERROR( "can not load XML: main node not find: \"html\"");
doc.display();
return;
}
exml::Element* bodyNode = (exml::Element*)root->getNamed( "body" );
if (root == NULL) {
if (root == nullptr) {
EWOL_ERROR( "can not load XML: main node not find: \"body\"");
return;
}

View File

@ -77,7 +77,7 @@ namespace ewol {
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 ...)
protected:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
ewol::object::Shared<ewol::resource::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)

View File

@ -17,7 +17,7 @@
ewol::compositing::TextDF::TextDF(const std::string& _fontName, int32_t _fontSize) :
ewol::compositing::TextBase("", false),
m_fontDF(NULL),
m_fontDF(nullptr),
m_GLglyphLevel(-1),
m_size(12.0) {
setFont(_fontName, _fontSize);
@ -26,12 +26,12 @@ ewol::compositing::TextDF::TextDF(const std::string& _fontName, int32_t _fontSiz
ewol::compositing::TextDF::~TextDF() {
ewol::resource::DistanceFieldFont::release(m_fontDF);
}
void ewol::compositing::TextDF::updateSizeToRender(const vec2& _size) {
float minSize = etk_min(_size.x(), _size.y());
if (m_fontDF != NULL) {
if (m_fontDF != nullptr) {
setFontSize(m_fontDF->getSize(minSize));
}
}
@ -42,15 +42,15 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
// draw BG in any case:
m_vectorialDraw.draw();
if (m_coord.size() <= 0 || m_fontDF == NULL) {
if (m_coord.size() <= 0 || m_fontDF == nullptr) {
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_fontDF == NULL) {
if (m_fontDF == nullptr) {
EWOL_WARNING("no font...");
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -84,16 +84,16 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
// draw BG in any case:
m_vectorialDraw.draw();
if (m_coord.size() <= 0 || m_fontDF == NULL) {
if (m_coord.size() <= 0 || m_fontDF == nullptr) {
// TODO : a remètre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
if (m_fontDF == NULL) {
if (m_fontDF == nullptr) {
EWOL_WARNING("no font...");
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -120,14 +120,14 @@ void ewol::compositing::TextDF::clear() {
}
void ewol::compositing::TextDF::loadProgram(const std::string& _shaderName) {
ewol::compositing::TextBase::loadProgram(_shaderName);
if (m_GLprogram != NULL) {
if (m_GLprogram != nullptr) {
m_GLglyphLevel = m_GLprogram->getAttribute("EW_glyphLevel");
}
}
float ewol::compositing::TextDF::getHeight() {
if (m_fontDF == NULL) {
if (m_fontDF == nullptr) {
EWOL_WARNING("no font...");
return 1;
}
@ -135,9 +135,9 @@ float ewol::compositing::TextDF::getHeight() {
}
ewol::GlyphProperty * ewol::compositing::TextDF::getGlyphPointer(char32_t _charcode) {
if (m_fontDF == NULL) {
if (m_fontDF == nullptr) {
EWOL_WARNING("no font...");
return NULL;
return nullptr;
}
return m_fontDF->getGlyphPointer(_charcode);
}
@ -155,7 +155,7 @@ void ewol::compositing::TextDF::setFontSize(int32_t _fontSize) {
void ewol::compositing::TextDF::setFontName(const std::string& _fontName) {
clear();
// remove old one
ewol::resource::DistanceFieldFont* previousFont = m_fontDF;
ewol::object::Shared<ewol::resource::DistanceFieldFont> previousFont = m_fontDF;
std::string fontName;
if (_fontName == "") {
fontName = ewol::getContext().getFontDefault().getName();
@ -165,11 +165,9 @@ void ewol::compositing::TextDF::setFontName(const std::string& _fontName) {
EWOL_VERBOSE("Set font name: '" << fontName << "'");
// link to new one
m_fontDF = ewol::resource::DistanceFieldFont::keep(fontName);
if (m_fontDF == NULL) {
if (m_fontDF == nullptr) {
EWOL_ERROR("Can not get find resource");
m_fontDF = previousFont;
} else {
ewol::resource::DistanceFieldFont::release(previousFont);
}
}
@ -189,7 +187,7 @@ void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) {
void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
// get a pointer on the glyph property :
ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode);
if (NULL == myGlyph) {
if (nullptr == myGlyph) {
EWOL_ERROR(" font does not really existed ...");
return;
}

View File

@ -23,7 +23,7 @@ namespace ewol {
namespace compositing {
class TextDF : public ewol::compositing::TextBase {
protected:
ewol::resource::DistanceFieldFont* m_fontDF; //!< Font resources
ewol::object::Shared<ewol::resource::DistanceFieldFont> m_fontDF; //!< Font resources
std::vector<float> m_glyphLevel; //!< Level of display of the glyph (notmal : 0.50, bold : 0.40, super bold : 0.30 ...)
protected:
int32_t m_GLglyphLevel; //!< openGL Id on the glyph level display

View File

@ -23,7 +23,7 @@
int64_t ewol::getTime() {
struct timeval now;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
}
@ -31,7 +31,7 @@ int64_t ewol::getTime() {
// jni doc : /usr/lib/jvm/java-1.6.0-openjdk/include
static JavaVM* g_JavaVM=NULL; // global acces on the unique JVM !!!
static JavaVM* g_JavaVM=nullptr; // global acces on the unique JVM !!!
etk::Mutex g_interfaceMutex;
etk::Mutex g_interfaceAudioMutex;
@ -78,10 +78,10 @@ class AndroidContext : public ewol::Context {
private:
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
_mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign);
if(_mid == NULL) {
if(_mid == nullptr) {
EWOL_ERROR("C->java : Can't find the method " << _name);
/* remove access on the virtual machine : */
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
return false;
}
return true;
@ -89,7 +89,7 @@ class AndroidContext : public ewol::Context {
public:
AndroidContext(JNIEnv* _env, jclass _classBase, jobject _objCallback, enum application _typeAPPL) :
m_javaApplicationType(_typeAPPL),
m_JavaVirtualMachinePointer(NULL),
m_JavaVirtualMachinePointer(nullptr),
m_javaClassEwol(0),
m_javaClassEwolCallback(0),
m_javaObjectEwolCallback(0),
@ -108,8 +108,8 @@ class AndroidContext : public ewol::Context {
m_javaDefaultClassString(0),
m_currentHeight(0),
m_clipBoardOwnerStd(false),
m_audioCallBack(NULL),
m_audioCallBackUserData(NULL) {
m_audioCallBack(nullptr),
m_audioCallBackUserData(nullptr) {
EWOL_DEBUG("*******************************************");
if (m_javaApplicationType == appl_application) {
EWOL_DEBUG("** set JVM Pointer (application) **");
@ -119,21 +119,21 @@ class AndroidContext : public ewol::Context {
EWOL_DEBUG("*******************************************");
m_JavaVirtualMachinePointer = _env;
// get default needed all time elements :
if (NULL != m_JavaVirtualMachinePointer) {
if (nullptr != m_JavaVirtualMachinePointer) {
EWOL_DEBUG("C->java : try load org/ewol/Ewol class");
m_javaClassEwol = m_JavaVirtualMachinePointer->FindClass("org/ewol/Ewol" );
if (m_javaClassEwol == 0) {
EWOL_ERROR("C->java : Can't find org/ewol/Ewol class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
return;
}
/* The object field extends Activity and implement EwolCallback */
m_javaClassEwolCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback);
if(m_javaClassEwolCallback == NULL) {
if(m_javaClassEwolCallback == nullptr) {
EWOL_ERROR("C->java : Can't find org/ewol/EwolCallback class");
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
return;
}
bool functionCallbackIsMissing = false;
@ -258,7 +258,7 @@ class AndroidContext : public ewol::Context {
m_javaObjectEwolCallback = _env->NewGlobalRef(_objCallback);
//javaObjectEwolCallbackAndActivity = objCallback;
if (m_javaObjectEwolCallback == NULL) {
if (m_javaObjectEwolCallback == nullptr) {
functionCallbackIsMissing = true;
}
@ -266,7 +266,7 @@ class AndroidContext : public ewol::Context {
if (m_javaDefaultClassString == 0) {
EWOL_ERROR("C->java : Can't find java/lang/String" );
// remove access on the virtual machine :
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
functionCallbackIsMissing = true;
}
if (functionCallbackIsMissing == true) {
@ -281,7 +281,7 @@ class AndroidContext : public ewol::Context {
void unInit(JNIEnv* _env) {
_env->DeleteGlobalRef(m_javaObjectEwolCallback);
m_javaObjectEwolCallback = NULL;
m_javaObjectEwolCallback = nullptr;
}
int32_t run() {
@ -387,7 +387,7 @@ class AndroidContext : public ewol::Context {
}
//Call java ...
jstring returnString = (jstring) m_JavaVirtualMachinePointer->CallObjectMethod(m_javaObjectEwolCallback, m_javaMethodEwolActivityAudioGetDeviceProperty, _idDevice);
const char *js = m_JavaVirtualMachinePointer->GetStringUTFChars(returnString, NULL);
const char *js = m_JavaVirtualMachinePointer->GetStringUTFChars(returnString, nullptr);
std::string retString(js);
m_JavaVirtualMachinePointer->ReleaseStringUTFChars(returnString, js);
//m_JavaVirtualMachinePointer->DeleteLocalRef(returnString);
@ -410,7 +410,7 @@ class AndroidContext : public ewol::Context {
int32_t _format,
AndroidAudioCallback _callback,
void* _userData) {
if (m_audioCallBack != NULL) {
if (m_audioCallBack != nullptr) {
EWOL_ERROR("AudioCallback already started ...");
return false;
}
@ -437,7 +437,7 @@ class AndroidContext : public ewol::Context {
return false;
}
bool audioCloseDevice(int32_t _idDevice) {
if (m_audioCallBack == NULL) {
if (m_audioCallBack == nullptr) {
EWOL_ERROR("AudioCallback Not started ...");
return false;
}
@ -453,8 +453,8 @@ class AndroidContext : public ewol::Context {
// manage execption :
java_check_exception(m_JavaVirtualMachinePointer);
java_detach_current_thread(status);
m_audioCallBack = NULL;
m_audioCallBackUserData = NULL;
m_audioCallBack = nullptr;
m_audioCallBackUserData = nullptr;
return (bool)ret;
} else {
EWOL_ERROR("C->java : can not get audio device count");
@ -464,9 +464,9 @@ class AndroidContext : public ewol::Context {
private:
bool java_attach_current_thread(int *_rstatus) {
EWOL_DEBUG("C->java : call java");
if (g_JavaVM == NULL) {
if (g_JavaVM == nullptr) {
EWOL_ERROR("C->java : JVM not initialised");
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
return false;
}
*_rstatus = g_JavaVM->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6);
@ -474,12 +474,12 @@ class AndroidContext : public ewol::Context {
JavaVMAttachArgs lJavaVMAttachArgs;
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
lJavaVMAttachArgs.name = "EwolNativeThread";
lJavaVMAttachArgs.group = NULL;
lJavaVMAttachArgs.group = nullptr;
int status = g_JavaVM->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs);
java_check_exception(m_JavaVirtualMachinePointer);
if (status != JNI_OK) {
EWOL_ERROR("C->java : AttachCurrentThread failed : " << status);
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
return false;
}
}
@ -489,7 +489,7 @@ class AndroidContext : public ewol::Context {
void java_detach_current_thread(int _status) {
if(_status == JNI_EDETACHED) {
g_JavaVM->DetachCurrentThread();
m_JavaVirtualMachinePointer = NULL;
m_JavaVirtualMachinePointer = nullptr;
}
}
@ -568,7 +568,7 @@ class AndroidContext : public ewol::Context {
return;
}
EWOL_DEBUG("C->java : 222");
if (NULL == _dataString) {
if (nullptr == _dataString) {
EWOL_ERROR("C->java : No data to send ...");
return;
}
@ -631,7 +631,7 @@ class AndroidContext : public ewol::Context {
}
void audioPlayback(void* _dataOutput, int32_t _frameRate) {
if (m_audioCallBack != NULL) {
if (m_audioCallBack != nullptr) {
//EWOL_DEBUG("IO Audio event request: Frames=" << _frameRate);
m_audioCallBack(_dataOutput, _frameRate, m_audioCallBackUserData);
}
@ -654,7 +654,7 @@ extern "C" {
JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* _vm, void *_reserved) {
etk::AutoLockMutex myLock(g_interfaceMutex);
etk::AutoLockMutex myLock2(g_interfaceAudioMutex);
g_JavaVM = NULL;
g_JavaVM = nullptr;
EWOL_DEBUG("JNI-> Un-load the jvm ..." );
}
@ -665,9 +665,9 @@ extern "C" {
jint _mode,
jstring _myString) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -680,7 +680,7 @@ extern "C" {
if (isCopy == JNI_TRUE) {
// from here str is reset ...
_env->ReleaseStringUTFChars(_myString, str);
str = NULL;
str = nullptr;
}
}
@ -692,7 +692,7 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Creating EWOL context **");
EWOL_DEBUG("*******************************************");
AndroidContext* tmpContext = NULL;
AndroidContext* tmpContext = nullptr;
if (org_ewol_EwolConstants_EWOL_APPL_TYPE_ACTIVITY == _typeApplication) {
tmpContext = new AndroidContext(_env, _classBase, _objCallback, AndroidContext::appl_application);
} else if (org_ewol_EwolConstants_EWOL_APPL_TYPE_WALLPAPER == _typeApplication) {
@ -701,7 +701,7 @@ extern "C" {
EWOL_CRITICAL(" try to create an instance with no apply type: " << _typeApplication);
return -1;
}
if (NULL == tmpContext) {
if (nullptr == tmpContext) {
EWOL_ERROR("Can not allocate the main context instance _id=" << (s_listInstance.size()-1));
return -1;
}
@ -716,25 +716,25 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** remove JVM Pointer **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
return;
}
if (NULL == s_listInstance[_id]) {
if (nullptr == s_listInstance[_id]) {
EWOL_ERROR("the requested instance _id=" << (int32_t)_id << " is already removed ...");
return;
}
s_listInstance[_id]->unInit(_env);
delete(s_listInstance[_id]);
s_listInstance[_id]=NULL;
s_listInstance[_id]=nullptr;
}
void Java_org_ewol_Ewol_EWtouchEvent(JNIEnv* _env, jobject _thiz, jint _id) {
etk::AutoLockMutex myLock(g_interfaceMutex);
EWOL_DEBUG(" == > Touch Event");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -747,9 +747,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Create **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -762,9 +762,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Start **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -776,9 +776,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Re-Start **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -789,9 +789,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on resume **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -803,9 +803,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on pause **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -819,9 +819,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Stop **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -833,9 +833,9 @@ extern "C" {
EWOL_DEBUG("*******************************************");
EWOL_DEBUG("** Activity on Destroy **");
EWOL_DEBUG("*******************************************");
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -855,9 +855,9 @@ extern "C" {
jfloat _x,
jfloat _y) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -873,9 +873,9 @@ extern "C" {
jfloat _x,
jfloat _y) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -890,9 +890,9 @@ extern "C" {
jfloat _x,
jfloat _y) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -908,9 +908,9 @@ extern "C" {
jfloat _x,
jfloat _y) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -923,9 +923,9 @@ extern "C" {
jint _id,
jint _pointerID) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -939,9 +939,9 @@ extern "C" {
jint _type,
jboolean _isdown) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -956,9 +956,9 @@ extern "C" {
jint _uniChar,
jboolean _isdown) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -973,9 +973,9 @@ extern "C" {
jfloat _ratioX,
jfloat _ratioY) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -991,9 +991,9 @@ extern "C" {
jint _keyVal,
jboolean _isdown) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return false;
@ -1035,9 +1035,9 @@ extern "C" {
jobject _thiz,
jint _id) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -1050,9 +1050,9 @@ extern "C" {
jint _w,
jint _h) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -1065,9 +1065,9 @@ extern "C" {
jobject _thiz,
jint _id) {
etk::AutoLockMutex myLock(g_interfaceMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -1082,9 +1082,9 @@ extern "C" {
jint _frameRate,
jint _nbChannels) {
etk::AutoLockMutex myLock(g_interfaceAudioMutex);
if( _id >= s_listInstance.size()
if( _id >= (int32_t)s_listInstance.size()
|| _id<0
|| NULL == s_listInstance[_id] ) {
|| nullptr == s_listInstance[_id] ) {
EWOL_ERROR("Call C With an incorrect instance _id=" << (int32_t)_id);
// TODO : generate error in java to stop the current instance
return;
@ -1092,7 +1092,7 @@ extern "C" {
// get the short* pointer from the Java array
jboolean isCopy;
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
if (NULL != dst) {
if (nullptr != dst) {
memset(dst, sizeof(jshort), _frameRate*_nbChannels);
//EWOL_DEBUG("IO Audio event request: Frames=" << _frameRate << " channels=" << _nbChannels);
s_listInstance[_id]->audioPlayback(dst, _frameRate);

View File

@ -19,7 +19,7 @@ namespace ewol {
* Constructor / destructor
*/
ConfigFont();
~ConfigFont();
virtual ~ConfigFont();
private:
std::string m_folder;
public:

View File

@ -20,15 +20,17 @@
#include <ewol/Dimension.h>
#include <ewol/debug.h>
#include <ewol/translate.h>
#include <ewol/openGL/openGL.h>
#include <ewol/object/Object.h>
#include <ewol/object/Manager.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Windows.h>
#include <ewol/widget/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/resource/Manager.h>
#include <ewol/openGL/openGL.h>
#include <ewol/widget/Manager.h>
#include <ewol/translate.h>
@ -43,10 +45,10 @@ static etk::Mutex& mutexInterface() {
}
static ewol::Context* l_curentInterface=NULL;
static ewol::Context* l_curentInterface=nullptr;
ewol::Context& ewol::getContext() {
#if DEBUG_LEVEL > 2
if(NULL == l_curentInterface){
if(nullptr == l_curentInterface){
EWOL_CRITICAL("[CRITICAL] try acces at an empty interface");
}
#endif
@ -71,11 +73,11 @@ void ewol::Context::lockContext() {
}
/**
* @brief set the curent interface at NULL.
* @brief set the curent interface at nullptr.
* @note this un-lock the main mutex
*/
void ewol::Context::unLockContext() {
l_curentInterface = NULL;
l_curentInterface = nullptr;
mutexInterface().unLock();
}
@ -133,13 +135,13 @@ namespace ewol {
};
void ewol::Context::inputEventTransfertWidget(ewol::Widget* _source,
ewol::Widget* _destination) {
void ewol::Context::inputEventTransfertWidget(ewol::object::Shared<ewol::Widget> _source,
ewol::object::Shared<ewol::Widget> _destination) {
m_input.transfertEvent(_source, _destination);
}
void ewol::Context::inputEventGrabPointer(ewol::Widget* _widget) {
void ewol::Context::inputEventGrabPointer(ewol::object::Shared<ewol::Widget> _widget) {
m_input.grabPointer(_widget);
}
@ -150,12 +152,12 @@ void ewol::Context::inputEventUnGrabPointer() {
void ewol::Context::processEvents() {
int32_t nbEvent = 0;
//EWOL_DEBUG(" ******** Event");
ewol::eSystemMessage* data = NULL;
ewol::eSystemMessage* data = nullptr;
while (m_msgSystem.count()>0) {
nbEvent++;
if (data != NULL) {
if (data != nullptr) {
delete(data);
data = NULL;
data = nullptr;
}
m_msgSystem.wait(data);
//EWOL_DEBUG("EVENT");
@ -188,14 +190,14 @@ void ewol::Context::processEvents() {
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
// store the keyboard special key status for mouse event...
m_input.setLastKeyboardSpecial(data->keyboardSpecial);
if (NULL != m_windowsCurrent) {
if (nullptr != m_windowsCurrent) {
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) {
ewol::object::Shared<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (nullptr != 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
@ -237,8 +239,8 @@ void ewol::Context::processEvents() {
break;
case eSystemMessage::msgClipboardArrive:
{
ewol::Widget * tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != NULL) {
ewol::object::Shared<ewol::Widget> tmpWidget = m_widgetManager.focusGet();
if (tmpWidget != nullptr) {
tmpWidget->onEventClipboard(data->clipboardID);
}
}
@ -286,6 +288,7 @@ void ewol::Context::setArchiveDir(int _mode, const char* _str) {
ewol::Context::Context(int32_t _argc, const char* _argv[]) :
m_objectManager(*this),
m_previousDisplayTime(0),
m_input(*this),
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs))
@ -297,7 +300,7 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
m_FpsSystemContext("Context ", false),
m_FpsSystem( "Draw ", true),
m_FpsFlush( "Flush ", false),
m_windowsCurrent(NULL),
m_windowsCurrent(nullptr),
m_windowsSize(320,480),
m_initStepId(0),
m_initTotalStep(1) {
@ -352,7 +355,7 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
// request the init of the application in the main context of openGL ...
{
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
@ -378,18 +381,27 @@ ewol::Context::~Context() {
// TODO : Clean the message list ...
// set the curent interface :
lockContext();
// Remove current windows
m_windowsCurrent.reset();
// clean all widget and sub widget with their resources:
do {
m_objectManager.removeAllRemovedObject();
} while (m_resourceManager.checkResourceToRemove() == true);
// call application to uninit
APP_UnInit(*this);
if (m_windowsCurrent != NULL) {
EWOL_DEBUG("Main windows has not been auto-removed...");
m_windowsCurrent->removeObject();
m_windowsCurrent = NULL;
}
// unset all windows
// clean all messages
m_msgSystem.clean();
// an other cycle of removing ...
do {
m_objectManager.removeAllRemovedObject();
} while (m_resourceManager.checkResourceToRemove() == true);
m_objectManager.unInit();
EWOL_INFO("List of all widget of this context must be equal at 0 ==> otherwise some remove is missing");
m_objectManager.displayListObject();
// Resource is an lower element as objects ...
m_resourceManager.unInit();
// now All must be removed !!!
m_objectManager.unInit();
// release the curent interface :
unLockContext();
EWOL_INFO(" == > Ewol system Un-Init (END)");
@ -397,7 +409,7 @@ ewol::Context::~Context() {
void ewol::Context::requestUpdateSize() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -409,7 +421,7 @@ void ewol::Context::OS_Resize(const vec2& _size) {
// TODO : Better in the thread ... == > but generate some init error ...
ewol::Dimension::setPixelWindowsSize(_size);
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -429,7 +441,7 @@ void ewol::Context::OS_Move(const vec2& _pos) {
void ewol::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -442,7 +454,7 @@ void ewol::Context::OS_SetInputMotion(int _pointerID, const vec2& _pos ) {
void ewol::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -456,7 +468,7 @@ void ewol::Context::OS_SetInputState(int _pointerID, bool _isDown, const vec2& _
void ewol::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -469,7 +481,7 @@ void ewol::Context::OS_SetMouseMotion(int _pointerID, const vec2& _pos ) {
void ewol::Context::OS_SetMouseState(int _pointerID, bool _isDown, const vec2& _pos ) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -486,7 +498,7 @@ void ewol::Context::OS_SetKeyboard(ewol::key::Special& _special,
bool _isDown,
bool _isARepeateKey) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -503,7 +515,7 @@ void ewol::Context::OS_SetKeyboardMove(ewol::key::Special& _special,
bool _isDown,
bool _isARepeateKey) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -517,7 +529,7 @@ void ewol::Context::OS_SetKeyboardMove(ewol::key::Special& _special,
void ewol::Context::OS_Hide() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -527,7 +539,7 @@ void ewol::Context::OS_Hide() {
void ewol::Context::OS_Show() {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -538,7 +550,7 @@ void ewol::Context::OS_Show() {
void ewol::Context::OS_ClipBoardArrive(enum ewol::context::clipBoard::clipboardListe _clipboardID) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocationerror of message");
return;
}
@ -570,7 +582,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
processEvents();
if (m_initStepId < m_initTotalStep) {
ewol::eSystemMessage *data = new ewol::eSystemMessage();
if (data == NULL) {
if (data == nullptr) {
EWOL_ERROR("allocation error of message");
} else {
data->TypeMessage = eSystemMessage::msgInit;
@ -578,13 +590,9 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
}
}
// call all the widget that neded to do something periodicly
//! ewol::widgetManager::periodicCall(currentTime);
m_widgetManager.periodicCall(currentTime);
// remove all widget that they are no more usefull (these who decided to destroy themself)
//! ewol::ObjectManager::removeAllAutoRemove();
m_objectManager.removeAllAutoRemove();
// check if the user selected a windows
if (NULL != m_windowsCurrent) {
if (nullptr != m_windowsCurrent) {
// Redraw all needed elements
m_windowsCurrent->onRegenerateDisplay();
}
@ -605,7 +613,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
if (m_displayFps == true) {
m_FpsSystemContext.tic();
}
if (NULL != m_windowsCurrent) {
if (nullptr != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_resourceManager.updateContext();
@ -618,7 +626,7 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
m_FpsSystemContext.toc();
m_FpsSystem.tic();
}
if (NULL != m_windowsCurrent) {
if (nullptr != m_windowsCurrent) {
if( true == needRedraw
|| true == _displayEveryTime) {
m_FpsSystem.incrementCounter();
@ -645,12 +653,33 @@ bool ewol::Context::OS_Draw(bool _displayEveryTime) {
m_FpsSystem.draw();
m_FpsFlush.draw();
}
{
// set the curent interface :
lockContext();
// release open GL Context
ewol::openGL::lock();
// while The Gui is drawing in OpenGl, we do some not realTime things
m_resourceManager.updateContext();
// release open GL Context
ewol::openGL::unLock();
do {
m_objectManager.removeAllRemovedObject();
} while (m_resourceManager.checkResourceToRemove() == true);
// release the curent interface :
unLockContext();
}
return hasDisplayDone;
}
void ewol::Context::onObjectRemove(ewol::Object * _removeObject) {
void ewol::Context::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
//EWOL_CRITICAL("element removed");
m_input.onObjectRemove(_removeObject);
if (m_windowsCurrent == _object) {
m_windowsCurrent.reset(); // This might never arrived, the owner is the current element (expected when the widget auto remove itself)
}
// inform all manager that can not be directly linked with the object manager
m_input.onObjectRemove(_object);
m_widgetManager.onObjectRemove(_object);
m_resourceManager.checkResourceToRemove();
}
void ewol::Context::resetIOEvent() {
@ -661,9 +690,9 @@ void ewol::Context::OS_OpenGlContextDestroy() {
m_resourceManager.contextHasBeenDestroyed();
}
void ewol::Context::setWindows(ewol::widget::Windows* _windows) {
void ewol::Context::setWindows(const ewol::object::Shared<ewol::widget::Windows>& _windows) {
// remove current focus :
m_widgetManager.focusSetDefault(NULL);
m_widgetManager.focusSetDefault(nullptr);
m_widgetManager.focusRelease();
// set the new pointer as windows system
m_windowsCurrent = _windows;
@ -673,8 +702,12 @@ void ewol::Context::setWindows(ewol::widget::Windows* _windows) {
forceRedrawAll();
}
ewol::object::Shared<ewol::widget::Windows> ewol::Context::getWindows() {
return m_windowsCurrent;
};
void ewol::Context::forceRedrawAll() {
if (m_windowsCurrent == NULL) {
if (m_windowsCurrent == nullptr) {
return;
}
m_windowsCurrent->calculateSize(vec2(m_windowsSize.x(), m_windowsSize.y()));
@ -684,7 +717,7 @@ void ewol::Context::OS_Stop() {
// set the curent interface :
lockContext();
EWOL_INFO("OS_Stop...");
if (m_windowsCurrent != NULL) {
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->sysOnKill();
}
// release the curent interface :
@ -696,7 +729,7 @@ void ewol::Context::OS_Suspend() {
lockContext();
EWOL_INFO("OS_Suspend...");
m_previousDisplayTime = -1;
if (m_windowsCurrent != NULL) {
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateSuspend();
}
// release the curent interface :
@ -709,7 +742,7 @@ void ewol::Context::OS_Resume() {
EWOL_INFO("OS_Resume...");
m_previousDisplayTime = ewol::getTime();
m_widgetManager.periodicCallResume(m_previousDisplayTime);
if (m_windowsCurrent != NULL) {
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateResume();
}
// release the curent interface :
@ -719,7 +752,7 @@ void ewol::Context::OS_Foreground() {
// set the curent interface :
lockContext();
EWOL_INFO("OS_Foreground...");
if (m_windowsCurrent != NULL) {
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateForeground();
}
// release the curent interface :
@ -730,7 +763,7 @@ void ewol::Context::OS_Background() {
// set the curent interface :
lockContext();
EWOL_INFO("OS_Background...");
if (m_windowsCurrent != NULL) {
if (m_windowsCurrent != nullptr) {
m_windowsCurrent->onStateBackground();
}
// release the curent interface :
@ -773,7 +806,7 @@ void ewol::Context::keyboardHide() {
bool ewol::Context::systemKeyboradEvent(enum ewol::key::keyboardSystem _key, bool _down) {
if (m_windowsCurrent == NULL) {
if (m_windowsCurrent == nullptr) {
return false;
}
lockContext();

View File

@ -22,6 +22,7 @@
#include <ewol/context/commandLine.h>
#include <ewol/context/InputManager.h>
#include <ewol/context/Fps.h>
#include <ewol/object/RemoveEvent.h>
namespace ewol {
/**
@ -37,7 +38,7 @@ namespace ewol {
screenPortrait
};
class Context {
class Context/* : private ewol::object::RemoveEvent */{
private:
ewol::context::CommandLine m_commandLine; //!< Start command line information
public:
@ -50,18 +51,18 @@ namespace ewol {
ewol::context::ConfigFont& getFontDefault() {
return m_configFont;
};
private:
ewol::widget::Manager m_widgetManager; //!< global widget manager
public:
ewol::widget::Manager& getWidgetManager() {
return m_widgetManager;
};
private:
ewol::object::Manager m_objectManager; //!< Object Manager main instance
public:
ewol::object::Manager& getEObjectManager() {
return m_objectManager;
};
private:
ewol::widget::Manager m_widgetManager; //!< global widget manager
public:
ewol::widget::Manager& getWidgetManager() {
return m_widgetManager;
};
private:
ewol::resource::Manager m_resourceManager; //!< global resources Manager
public:
@ -69,7 +70,7 @@ namespace ewol {
return m_resourceManager;
};
public:
Context(int32_t _argc=0, const char* _argv[]=NULL);
Context(int32_t _argc=0, const char* _argv[]=nullptr);
virtual ~Context();
protected:
/**
@ -78,7 +79,7 @@ namespace ewol {
*/
void lockContext();
/**
* @brief set the curent interface at NULL.
* @brief set the curent interface at nullptr.
* @note this un-lock the main mutex
*/
void unLockContext();
@ -121,7 +122,7 @@ namespace ewol {
* @brief The current context is resumed
*/
virtual void OS_Resume();
/**
* @brief The current context is set in foreground (framerate is maximum speed)
*/
@ -135,12 +136,9 @@ namespace ewol {
// return true if a flush is needed
bool OS_Draw(bool _displayEveryTime);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject removed == > the user must remove all reference on this EObject
* @note : Sub classes must call this class
*/
void onObjectRemove(ewol::Object* _removeObject);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject);
public:
/**
* @brief reset event management for the IO like Input ou Mouse or keyborad
*/
@ -158,20 +156,18 @@ namespace ewol {
*/
virtual void stop();
private:
ewol::widget::Windows* m_windowsCurrent; //!< curent displayed windows
ewol::object::Owner<ewol::widget::Windows> m_windowsCurrent; //!< curent displayed windows
public:
/**
* @brief set the current windows to display :
* @param _windows Windows that might be displayed
*/
void setWindows(ewol::widget::Windows* _windows);
void setWindows(const ewol::object::Shared<ewol::widget::Windows>& _windows);
/**
* @brief get the current windows that is displayed
* @return the current handle on the windows (can be null)
*/
ewol::widget::Windows* getWindows() {
return m_windowsCurrent;
};
ewol::object::Shared<ewol::widget::Windows> getWindows();
private:
vec2 m_windowsSize; //!< current size of the system
public:
@ -229,12 +225,12 @@ namespace ewol {
* @param source the widget where the event came from
* @param destination the widget where the event mitgh be generated now
*/
void inputEventTransfertWidget(ewol::Widget* _source, ewol::Widget* _destination);
void inputEventTransfertWidget(ewol::object::Shared<ewol::Widget> _source, ewol::object::Shared<ewol::Widget> _destination);
/**
* @brief This fonction lock the pointer properties to move in relative instead of absolute
* @param[in] widget The widget that lock the pointer events
*/
void inputEventGrabPointer(ewol::Widget* _widget);
void inputEventGrabPointer(ewol::object::Shared<ewol::Widget> _widget);
/**
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/

View File

@ -128,19 +128,19 @@ public:
};
MacOSInterface* interface = NULL;
MacOSInterface* interface = nullptr;
bool IOs::draw(bool _displayEveryTime) {
if (interface == NULL) {
if (interface == nullptr) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void IOs::resize(float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_Resize(_x, _y);
@ -148,82 +148,82 @@ void IOs::resize(float _x, float _y) {
void IOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void IOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void IOs::setInputState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetInputState(_id, _isDown, _x, _y);
}
void IOs::setInputMotion(int32_t _id, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetInputMotion(_id, _x, _y);
}
void IOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void IOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown);
}
void IOs::start() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
//interface->OS_Start();
}
void IOs::resume() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->OS_Resume();
}
void IOs::suspend() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->OS_Suspend();
}
void IOs::stop() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->OS_Stop();
}
void IOs::background() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->OS_Background();
}
void IOs::foreground() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->OS_Foreground();
@ -231,7 +231,7 @@ void IOs::foreground() {
static int l_argc = 0;
static const char **l_argv = NULL;
static const char **l_argv = nullptr;
/**
* @brief Main of the program
* @param std IO
@ -248,19 +248,19 @@ void IOs::createInterface() {
etk::setArgZero(l_argv[0]);
EWOL_INFO("Create new interface");
interface = new MacOSInterface(l_argc, l_argv);
if (NULL == interface) {
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return;
}
}
void IOs::releaseInterface() {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
EWOL_INFO("Remove interface");
delete(interface);
interface = NULL;
interface = nullptr;
}

View File

@ -17,13 +17,12 @@
Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel.
*/
@interface OpenglView : UIView {
@private
CAEAGLLayer* _eaglLayer;
CAEAGLLayer* _eaglLayer;
EAGLContext *_context;
GLuint _colorRenderBuffer;
GLuint _depthRenderBuffer;
GLuint _colorRenderBuffer;
GLuint _depthRenderBuffer;
/* OpenGL names for the renderbuffer and framebuffers used to render to this view */
GLuint viewRenderbuffer, viewFramebuffer;

View File

@ -42,11 +42,11 @@ void ewol::context::InputManager::setDpi(int32_t newDPI) {
}
bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type,
ewol::Widget* _destWidget,
ewol::object::Shared<ewol::Widget> _destWidget,
int32_t _IdInput,
enum ewol::key::status _status,
vec2 _pos) {
if (NULL != _destWidget) {
if (nullptr != _destWidget) {
if (_type == ewol::key::typeMouse || _type == ewol::key::typeFinger) {
// create the system Event :
ewol::event::InputSystem tmpEventSystem(_type, _status, _IdInput, _pos, _destWidget, 0, m_specialKey); // TODO : set the real ID ...
@ -62,7 +62,7 @@ bool ewol::context::InputManager::localEventInput(enum ewol::key::type _type,
void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
int32_t _idInput,
enum ewol::key::type _type) {
if (NULL == _eventTable) {
if (nullptr == _eventTable) {
return;
}
if (_eventTable[_idInput].isUsed == true) {
@ -76,14 +76,14 @@ void ewol::context::InputManager::abortElement(InputPoperty *_eventTable,
void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable,
int32_t _idInput) {
if (NULL == _eventTable) {
if (nullptr == _eventTable) {
return;
}
//EWOL_INFO("CleanElement[" << idInput << "] = @" << (int64_t)eventTable);
_eventTable[_idInput].isUsed = false;
_eventTable[_idInput].destinationInputId = 0;
_eventTable[_idInput].lastTimeEvent = 0;
_eventTable[_idInput].curentWidgetEvent = NULL;
_eventTable[_idInput].curentWidgetEvent.reset();
_eventTable[_idInput].origin.setValue(0,0);
_eventTable[_idInput].size.setValue(99999999,99999999);
_eventTable[_idInput].downStart.setValue(0,0);
@ -93,9 +93,9 @@ void ewol::context::InputManager::cleanElement(InputPoperty *_eventTable,
_eventTable[_idInput].posEvent.setValue(0,0);
}
void ewol::context::InputManager::transfertEvent(ewol::Widget* _source, ewol::Widget* _destination) {
if( NULL == _source
|| NULL == _destination) {
void ewol::context::InputManager::transfertEvent(ewol::object::Shared<ewol::Widget> _source, ewol::object::Shared<ewol::Widget> _destination) {
if( _source == nullptr
|| _destination == nullptr) {
// prevent errors ...
return;
}
@ -123,8 +123,8 @@ void ewol::context::InputManager::transfertEvent(ewol::Widget* _source, ewol::Wi
}
}
void ewol::context::InputManager::grabPointer(ewol::Widget* _widget) {
if(NULL == _widget) {
void ewol::context::InputManager::grabPointer(ewol::object::Shared<ewol::Widget> _widget) {
if(nullptr == _widget) {
return;
}
m_grabWidget = _widget;
@ -134,21 +134,27 @@ void ewol::context::InputManager::grabPointer(ewol::Widget* _widget) {
}
void ewol::context::InputManager::unGrabPointer() {
m_grabWidget = NULL;
m_grabWidget = nullptr;
m_context.grabPointerEvents(false, vec2(0,0));
}
void ewol::context::InputManager::onObjectRemove(ewol::Object * removeObject) {
void ewol::context::InputManager::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (m_eventInputSaved[iii].curentWidgetEvent == removeObject) {
if (m_eventInputSaved[iii].curentWidgetEvent == _object) {
// remove the property of this input ...
EWOL_VERBOSE("Remove object ==> rm Input Event !!!");
cleanElement(m_eventInputSaved, iii);
}
if (m_eventMouseSaved[iii].curentWidgetEvent == removeObject) {
if (m_eventMouseSaved[iii].curentWidgetEvent == _object) {
// remove the property of this input ...
EWOL_VERBOSE("Remove object ==> rm Mouse Event !!!");
cleanElement(m_eventMouseSaved, iii);
}
}
if (m_grabWidget == _object) {
EWOL_VERBOSE("Remove object ==> rm Grab widget !!!");
m_grabWidget.reset();
}
}
void ewol::context::InputManager::newLayerSet() {
@ -162,7 +168,7 @@ void ewol::context::InputManager::newLayerSet() {
}
ewol::context::InputManager::InputManager(ewol::Context& _context) :
m_grabWidget(NULL),
m_grabWidget(nullptr),
m_context(_context) {
setDpi(200);
EWOL_INFO("Init (start)");
@ -180,7 +186,7 @@ ewol::context::InputManager::~InputManager() {
}
int32_t ewol::context::InputManager::localGetDestinationId(enum ewol::key::type _type,
ewol::Widget* _destWidget,
ewol::object::Shared<ewol::Widget> _destWidget,
int32_t _realInputId) {
if (_type == ewol::key::typeFinger) {
int32_t lastMinimum = 0;
@ -207,7 +213,7 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
// reject pointer == > out of IDs...
return;
}
InputPoperty *eventTable = NULL;
InputPoperty *eventTable = nullptr;
if (_type == ewol::key::typeMouse) {
eventTable = m_eventMouseSaved;
} else if (_type == ewol::key::typeFinger) {
@ -221,17 +227,17 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
// not manage input
return;
}
ewol::widget::Windows* tmpWindows = m_context.getWindows();
ewol::object::Shared<ewol::widget::Windows> tmpWindows = m_context.getWindows();
// special case for the mouse event 0 that represent the hover event of the system :
if (_type == ewol::key::typeMouse && _pointerID == 0) {
// this event is all time on the good widget ... and manage the enter and leave ...
// NOTE : the "layer widget" force us to get the widget at the specific position all the time :
ewol::Widget* tmpWidget = NULL;
if (m_grabWidget != NULL) {
ewol::object::Shared<ewol::Widget> tmpWidget = nullptr;
if (m_grabWidget != nullptr) {
// grab all events ...
tmpWidget = m_grabWidget;
} else {
if (NULL != tmpWindows) {
if (nullptr != tmpWindows) {
tmpWidget = tmpWindows->getWidgetAtPos(_pos);
}
}
@ -255,10 +261,10 @@ void ewol::context::InputManager::motion(enum ewol::key::type _type,
eventTable[_pointerID].isInside = true;
// get destination widget :
eventTable[_pointerID].curentWidgetEvent = tmpWidget;
if (NULL == eventTable[_pointerID].curentWidgetEvent) {
if (nullptr == eventTable[_pointerID].curentWidgetEvent) {
eventTable[_pointerID].isInside = false;
}
if (NULL != eventTable[_pointerID].curentWidgetEvent) {
if (nullptr != eventTable[_pointerID].curentWidgetEvent) {
eventTable[_pointerID].origin = eventTable[_pointerID].curentWidgetEvent->getOrigin();
eventTable[_pointerID].size = eventTable[_pointerID].curentWidgetEvent->getSize();
}
@ -339,7 +345,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
}
EVENT_DEBUG("event pointerId=" << _pointerID);
// convert position in open-GL coordonates ...
InputPoperty *eventTable = NULL;
InputPoperty *eventTable = nullptr;
InputLimit localLimit;
if (_type == ewol::key::typeMouse) {
eventTable = m_eventMouseSaved;
@ -358,7 +364,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
}
// get the curent time ...
int64_t currentTime = ewol::getTime();
ewol::widget::Windows* tmpWindows = m_context.getWindows();
ewol::object::Shared<ewol::widget::Windows> tmpWindows = m_context.getWindows();
if (true == _isDown) {
EVENT_DEBUG("GUI : Input ID=" << _pointerID
@ -396,16 +402,16 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
// set the element inside ...
eventTable[_pointerID].isInside = true;
// get destination widget :
if(NULL != tmpWindows) {
if (m_grabWidget != NULL && _type == ewol::key::typeMouse) {
if(nullptr != tmpWindows) {
if (m_grabWidget != nullptr && _type == ewol::key::typeMouse) {
eventTable[_pointerID].curentWidgetEvent = m_grabWidget;
} else {
eventTable[_pointerID].curentWidgetEvent = tmpWindows->getWidgetAtPos(_pos);
}
} else {
eventTable[_pointerID].curentWidgetEvent = NULL;
eventTable[_pointerID].curentWidgetEvent = nullptr;
}
if (NULL != eventTable[_pointerID].curentWidgetEvent) {
if (nullptr != eventTable[_pointerID].curentWidgetEvent) {
eventTable[_pointerID].origin = eventTable[_pointerID].curentWidgetEvent->getOrigin();
eventTable[_pointerID].size = eventTable[_pointerID].curentWidgetEvent->getSize();
eventTable[_pointerID].destinationInputId = localGetDestinationId(_type, eventTable[_pointerID].curentWidgetEvent, _pointerID);
@ -433,7 +439,7 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
// Mark it un-used :
eventTable[_pointerID].isUsed = false;
// revove the widget ...
eventTable[_pointerID].curentWidgetEvent = NULL;
eventTable[_pointerID].curentWidgetEvent = nullptr;
} else {
// generate UP Event
EVENT_DEBUG("GUI : Input ID=" << _pointerID
@ -454,14 +460,14 @@ void ewol::context::InputManager::state(enum ewol::key::type _type,
// save start time
eventTable[_pointerID].lastTimeEvent = currentTime;
int32_t nbClickMax = 0;
if(eventTable[_pointerID].curentWidgetEvent != NULL) {
if(eventTable[_pointerID].curentWidgetEvent != nullptr) {
nbClickMax = eventTable[_pointerID].curentWidgetEvent->getMouseLimit();
if (nbClickMax>5) {
nbClickMax = 5;
}
}
// in grab mode the single to quinte event are not generated ....
if( ( m_grabWidget == NULL
if( ( m_grabWidget == nullptr
|| _type != ewol::key::typeMouse )
&& eventTable[_pointerID].nbClickEvent < nbClickMax) {
// generate event SINGLE :

View File

@ -10,6 +10,7 @@
#define __EWOL_SYSTEM_INPUT_H__
#include <ewol/widget/Widget.h>
#include <ewol/object/RemoveEvent.h>
#define MAX_MANAGE_INPUT (15)
@ -24,7 +25,7 @@ namespace ewol {
bool isUsed;
int32_t destinationInputId;
int64_t lastTimeEvent;
ewol::Widget* curentWidgetEvent;
ewol::object::Shared<ewol::Widget> curentWidgetEvent;
vec2 origin;
vec2 size;
vec2 downStart;
@ -44,10 +45,10 @@ namespace ewol {
int32_t DpiOffset;
};
class Context;
class InputManager {
class InputManager{
// special grab pointer mode :
private:
ewol::Widget* m_grabWidget; //!< widget that grab the curent pointer.
ewol::object::Shared<ewol::Widget> m_grabWidget; //!< widget that grab the curent pointer.
private:
int32_t m_dpi;
InputLimit m_eventInputLimit;
@ -67,7 +68,7 @@ namespace ewol {
* @return true if event has been greped
*/
bool localEventInput(enum ewol::key::type _type,
ewol::Widget* _destWidget,
ewol::object::Shared<ewol::Widget> _destWidget,
int32_t _IdInput,
enum ewol::key::status _typeEvent,
vec2 _pos);
@ -81,7 +82,7 @@ namespace ewol {
* @return the ewol input id
*/
int32_t localGetDestinationId(enum ewol::key::type _type,
ewol::Widget* _destWidget,
ewol::object::Shared<ewol::Widget> _destWidget,
int32_t _realInputId);
private:
ewol::Context& m_context;
@ -94,12 +95,8 @@ namespace ewol {
void motion(enum ewol::key::type _type, int _pointerID, vec2 _pos );
void state(enum ewol::key::type _type, int _pointerID, bool _isDown, vec2 _pos);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the Object remeved == > the user must remove all reference on this Object
* @note : Sub classes must call this class
*/
void onObjectRemove(ewol::Object* _removeObject);
void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
public:
/**
* @brief a new layer on the windows is set == > might remove all the property of the current element ...
*/
@ -109,12 +106,12 @@ namespace ewol {
* @param _source the widget where the event came from
* @param _destination the widget where the event mitgh be generated now
*/
void transfertEvent(ewol::Widget* _source, ewol::Widget* _destination);
void transfertEvent(ewol::object::Shared<ewol::Widget> _source, ewol::object::Shared<ewol::Widget> _destination);
/**
* @brief This fonction lock the pointer properties to move in relative instead of absolute
* @param[in] _widget The widget that lock the pointer events
*/
void grabPointer(ewol::Widget* _widget);
void grabPointer(ewol::object::Shared<ewol::Widget> _widget);
/**
* @brief This fonction un-lock the pointer properties to move in relative instead of absolute
*/

View File

@ -119,19 +119,19 @@ class MacOSInterface : public ewol::Context {
};
MacOSInterface* interface = NULL;
MacOSInterface* interface = nullptr;
bool MacOs::draw(bool _displayEveryTime) {
if (interface == NULL) {
if (interface == nullptr) {
return false;
}
return interface->MAC_Draw(_displayEveryTime);
}
void MacOs::resize(float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_Resize(_x, _y);
@ -139,28 +139,28 @@ void MacOs::resize(float _x, float _y) {
void MacOs::setMouseState(int32_t _id, bool _isDown, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseState(_id, _isDown, _x, _y);
}
void MacOs::setMouseMotion(int32_t _id, float _x, float _y) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetMouseMotion(_id, _x, _y);
}
void MacOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboard(_keyboardMode, _unichar, _isDown, _isAReapeateKey);
}
void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown) {
if (interface == NULL) {
if (interface == nullptr) {
return;
}
interface->MAC_SetKeyboardMove(_keyboardMode, _move, _isDown);
@ -175,14 +175,14 @@ void MacOs::setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::k
int ewol::run(int _argc, const char *_argv[]) {
etk::setArgZero(_argv[0]);
interface = new MacOSInterface(_argc, _argv);
if (NULL == interface) {
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
}
int32_t retValue = interface->Run();
delete(interface);
interface = NULL;
interface = nullptr;
return retValue;
}

View File

@ -29,7 +29,7 @@
int64_t ewol::getTime() {
struct timeval now;
gettimeofday(&now, NULL);
gettimeofday(&now, nullptr);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
}
@ -72,10 +72,10 @@ class WindowsContext : public ewol::eContext {
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = loadIcon( NULL, IDI_APPLICATION );
wc.hCursor = loadCursor( NULL, IDC_ARROW );
wc.hIcon = loadIcon( nullptr, IDI_APPLICATION );
wc.hCursor = loadCursor( nullptr, IDC_ARROW );
wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
wc.lpszMenuName = NULL;
wc.lpszMenuName = nullptr;
wc.lpszClassName = "EwolMainWindows";
RegisterClass( &wc );
@ -83,7 +83,7 @@ class WindowsContext : public ewol::eContext {
hWnd = CreateWindow( "EwolMainWindows", "Ewol ... TODO Title",
WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE | WS_SIZEBOX,
0, 0, 800, 600,
NULL, NULL, hInstance, NULL );
nullptr, NULL, hInstance, NULL );
int border_thickness = getSystemMetrics(SM_CXSIZEFRAME);
int title_size = getSystemMetrics(SM_CYCAPTION);
m_currentHeight = 600-2*border_thickness -title_size;
@ -95,7 +95,7 @@ class WindowsContext : public ewol::eContext {
// program main loop
while(true == m_run) {
// check for messages
if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) {
if ( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE )) {
// handle or dispatch messages
if ( msg.message == WM_QUIT ) {
m_run = false;
@ -204,7 +204,7 @@ class WindowsContext : public ewol::eContext {
// disable openGL
void disableOpenGL(HWND _hWnd, HDC _hDC, HGLRC _hRC) {
wglMakeCurrent( NULL, NULL );
wglMakeCurrent( nullptr, NULL );
wglDeleteContext( _hRC );
releaseDC( _hWnd, _hDC );
}
@ -256,7 +256,7 @@ class WindowsContext : public ewol::eContext {
*/
case WM_WINDOWPOSCHANGING: {
WINDOWPOS* tmpVal = (WINDOWPOS*)_lParam;
if (NULL != tmpVal) {
if (nullptr != tmpVal) {
//EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")");
// in windows system, we need to remove the size of the border elements :
int border_thickness = getSystemMetrics(SM_CXSIZEFRAME);
@ -465,14 +465,14 @@ int ewol::Run(int _argc, const char *_argv[]) {
//return 1;
}
WindowsContext* interface = new WindowsContext(_argc, _argv);
if (NULL == interface) {
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
}
int32_t retValue = interface->Run();
delete(interface);
interface = NULL;
interface = nullptr;
return retValue;
}

View File

@ -58,7 +58,7 @@ int64_t ewol::getTime() {
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(NULL);
now.tv_sec = time(nullptr);
now.tv_nsec = 0;
}
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
@ -144,14 +144,14 @@ class X11Interface : public ewol::Context {
public:
X11Interface(int32_t _argc, const char* _argv[]) :
ewol::Context(_argc, _argv),
m_display(NULL),
m_display(nullptr),
m_originX(0),
m_originY(0),
m_cursorEventX(0),
m_cursorEventY(0),
m_currentHeight(0),
m_currentWidth(0),
m_visual(NULL),
m_visual(nullptr),
m_doubleBuffered(0),
m_run(false),
m_grabAllEvent(false),
@ -225,21 +225,21 @@ class X11Interface : public ewol::Context {
{
XSelectionRequestEvent *req=&(event.xselectionrequest);
if (req->property == 0) {
EWOL_ERROR("Get NULL ATOM ... property");
EWOL_ERROR("Get nullptr ATOM ... property");
break;
}
if (req->target == 0) {
EWOL_ERROR("Get NULL ATOM ... target");
EWOL_ERROR("Get nullptr ATOM ... target");
break;
}
char * atomNameProperty = XGetAtomName(m_display, req->property);
char * atomNameTarget = XGetAtomName(m_display, req->target);
EWOL_INFO("X11 property: \"" << atomNameProperty << "\"");
EWOL_INFO("X11 target: \"" << atomNameTarget << "\"");
if (atomNameProperty != NULL) {
if (atomNameProperty != nullptr) {
XFree(atomNameProperty);
}
if (atomNameTarget != NULL) {
if (atomNameTarget != nullptr) {
XFree(atomNameTarget);
}
}
@ -294,24 +294,24 @@ class X11Interface : public ewol::Context {
#ifdef DEBUG_X11_EVENT
{
if (req->property == 0) {
EWOL_ERROR("Get NULL ATOM ... property");
EWOL_ERROR("Get nullptr ATOM ... property");
break;
}
if (req->selection == 0) {
EWOL_ERROR("Get NULL ATOM ... selection");
EWOL_ERROR("Get nullptr ATOM ... selection");
break;
}
if (req->target == 0) {
EWOL_ERROR("Get NULL ATOM ... target");
EWOL_ERROR("Get nullptr ATOM ... target");
break;
}
char * atomNameProperty = XGetAtomName(m_display, req->property);
char * atomNameSelection = XGetAtomName(m_display, req->selection);
char * atomNameTarget = XGetAtomName(m_display, req->target);
EWOL_INFO(" from: " << atomNameProperty << " request=" << atomNameSelection << " in " << atomNameTarget);
if (NULL != atomNameProperty) { XFree(atomNameProperty); }
if (NULL != atomNameSelection) { XFree(atomNameSelection); }
if (NULL != atomNameTarget) { XFree(atomNameTarget); }
if (nullptr != atomNameProperty) { XFree(atomNameProperty); }
if (nullptr != atomNameSelection) { XFree(atomNameSelection); }
if (nullptr != atomNameTarget) { XFree(atomNameTarget); }
}
#endif
@ -920,8 +920,8 @@ class X11Interface : public ewol::Context {
static char *title = (char*)"Ewol";
// Connect to the X server
m_display = XOpenDisplay(NULL);
if(NULL == m_display) {
m_display = XOpenDisplay(nullptr);
if(nullptr == m_display) {
EWOL_CRITICAL("Could not open display X.");
exit(-1);
} else {
@ -934,7 +934,7 @@ class X11Interface : public ewol::Context {
ewol::Dimension::Millimeter);
// get an appropriate visual
m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl);
if (NULL == m_visual) {
if (nullptr == m_visual) {
m_visual = glXChooseVisual(m_display, Xscreen, attrListSgl);
m_doubleBuffered = false;
EWOL_INFO("GL-X singlebuffered rendering will be used, no doublebuffering available");
@ -1012,10 +1012,10 @@ class X11Interface : public ewol::Context {
StartupState->flags = StateHint;
XSetWMProperties(m_display, m_WindowHandle,&textprop, &textprop,/* Window title/icon title*/
NULL, 0,/* Argv[], argc for program*/
nullptr, 0,/* Argv[], argc for program*/
&hints, /* Start position/size*/
StartupState,/* Iconised/not flag */
NULL);
nullptr);
XFree(StartupState);
@ -1024,15 +1024,15 @@ class X11Interface : public ewol::Context {
//XIfEvent(m_display, &event, WaitForMapNotify, (char*)&m_WindowHandle);
m_xim = XOpenIM(m_display, NULL, NULL, NULL);
if (m_xim == NULL) {
m_xim = XOpenIM(m_display, nullptr, NULL, NULL);
if (m_xim == nullptr) {
EWOL_ERROR("Could not open input method");
return false;
}
/*
XIMStyles *styles=NULL;
char* failed_arg = XGetIMValues(m_xim, XNQueryInputStyle, &styles, NULL);
if (failed_arg != NULL) {
XIMStyles *styles=nullptr;
char* failed_arg = XGetIMValues(m_xim, XNQueryInputStyle, &styles, nullptr);
if (failed_arg != nullptr) {
EWOL_ERROR("XIM Can't get styles");
return false;
}
@ -1040,8 +1040,8 @@ class X11Interface : public ewol::Context {
EWOL_INFO("style " << styles->supported_styles[iii]);
}
*/
m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_WindowHandle, NULL);
if (m_xic == NULL) {
m_xic = XCreateIC(m_xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing, XNClientWindow, m_WindowHandle, nullptr);
if (m_xic == nullptr) {
EWOL_ERROR("Could not open IC");
return false;
}
@ -1083,7 +1083,7 @@ class X11Interface : public ewol::Context {
return;
}
char* tmpVal = new char[4*dataImage.getWidth()*dataImage.getHeight()];
if (NULL == tmpVal) {
if (nullptr == tmpVal) {
EWOL_CRITICAL("Allocation error ...");
return;
}
@ -1191,7 +1191,7 @@ class X11Interface : public ewol::Context {
// Note when we free the pixmap ... the icon is removed ... == > this is a real memory leek ...
//XFreePixmap(m_display, tmpPixmap);
myImage->data = NULL;
myImage->data = nullptr;
XDestroyImage(myImage);
delete[] tmpVal;
@ -1346,12 +1346,12 @@ class X11Interface : public ewol::Context {
int ewol::run(int _argc, const char *_argv[]) {
etk::setArgZero(_argv[0]);
X11Interface* interface = new X11Interface(_argc, _argv);
if (NULL == interface) {
if (nullptr == interface) {
EWOL_CRITICAL("Can not create the X11 interface ... MEMORY allocation error");
return -2;
}
int32_t retValue = interface->run();
delete(interface);
interface = NULL;
interface = nullptr;
return retValue;
}

View File

@ -52,7 +52,7 @@ int64_t guiInterface::getTime() {
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(NULL);
now.tv_sec = time(nullptr);
now.tv_nsec = 0;
}
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
@ -71,16 +71,16 @@ bool m_grabAllEvent = false;
// the super interface
IDirectFB *dfb = NULL;
IDirectFB *dfb = nullptr;
// the primary surface (surface of primary layer)
IDirectFBSurface *primary = NULL;
IDirectFBSurface *primary = nullptr;
// the GL context
IDirectFBGL *primary_gl = NULL;
IDirectFBGL *primary_gl = nullptr;
// event buffer
IDirectFBEventBuffer *events = NULL;
IDirectFBEventBuffer *events = nullptr;
static int screen_width =800;
static int screen_height = 600;
@ -152,7 +152,7 @@ void DirectFB_Init(int argc, const char *argv[]) {
primary->setDstBlendFunction(primary, DSBF_SRCALPHA);
primary->setDrawingFlags(primary, DSDRAW_BLEND);
primary->Blit(primary, primary, NULL, 0, 0);
primary->Blit(primary, primary, nullptr, 0, 0);
EWOL_INFO("call getSize");
@ -175,7 +175,7 @@ void DirectFB_Init(int argc, const char *argv[]) {
}
EWOL_INFO("call Flip");
primary->Flip(primary, NULL, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
// NOTE : we need to force it on X11 display ...
EWOL_INFO("call getGL");
@ -212,7 +212,7 @@ void DirectFB_Run() {
primary->FillRectangle(primary, 0, 0, screen_width, screen_height);
primary->setColor (primary, 0xFF, (uint8_t)position, 0x00, 0xFF);
primary->FillRectangle(primary, position, position, 300, 300);
primary->Flip(primary, NULL, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
position++;
if (position>600) {
position = 0;
@ -234,7 +234,7 @@ void DirectFB_Run() {
EWOL_ERROR("primary_gl->Unlock");
DirectFBErrorFatal("primary_gl->Unlock", err);
}
primary->Flip(primary, NULL, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
primary->Flip(primary, nullptr, (DFBSurfaceFlipFlags)0);//DSFLIP_ONSYNC);
}
while (events->getEvent(events, DFB_EVENT(&evt)) == DFB_OK) {

View File

@ -78,7 +78,7 @@ namespace ewol {
enum ewol::key::status _status,
uint8_t _id,
const vec2& _pos,
ewol::Widget* _dest,
ewol::object::Shared<ewol::Widget> _dest,
int32_t _realIdEvent,
ewol::key::Special _specialKey) :
m_event(_type, _status, _id, _pos, _specialKey),
@ -86,13 +86,13 @@ namespace ewol {
m_realIdEvent(_realIdEvent) { };
ewol::event::Input m_event;
private:
ewol::Widget* m_dest;
ewol::object::Shared<ewol::Widget> m_dest;
int32_t m_realIdEvent;
public:
void setDestWidget(ewol::Widget* _dest) {
void setDestWidget(ewol::object::Shared<ewol::Widget> _dest) {
m_dest = _dest;
};
inline ewol::Widget* getDestWidget() const {
inline ewol::object::Shared<ewol::Widget> getDestWidget() const {
return m_dest;
};
void setRealId(int32_t _realIdEvent) {

View File

@ -13,19 +13,19 @@
std::ostream& ewol::operator <<(std::ostream& _os, const ewol::object::ConfigElement& _obj) {
_os << "{";
if (NULL != _obj.getConfig()) {
if (nullptr != _obj.getConfig()) {
_os << "config=\"" << _obj.getConfig() << "\"";
}
if (NULL != _obj.getType()) {
if (nullptr != _obj.getType()) {
_os << " type=\"" << _obj.getType() << "\"";
}
if (NULL != _obj.getControl()) {
if (nullptr != _obj.getControl()) {
_os << " ctrl=\"" << _obj.getControl() << "\"";
}
if (NULL != _obj.getDescription()) {
if (nullptr != _obj.getDescription()) {
_os << " desc=\"" << _obj.getDescription() << "\"";
}
if (NULL != _obj.getDefault()) {
if (nullptr != _obj.getDefault()) {
_os << " default=\"" << _obj.getDefault() << "\"";
}
_os << "}";

View File

@ -22,11 +22,11 @@ namespace ewol {
const char* m_default; //!< default value ...
public:
// note : no parameter capability is needed to create element in case of vector stoarage.
ConfigElement(const char* _config = NULL,
const char* _type = NULL,
const char* _control = NULL,
const char* _description = NULL,
const char* _default = NULL) :
ConfigElement(const char* _config = nullptr,
const char* _type = nullptr,
const char* _control = nullptr,
const char* _description = nullptr,
const char* _default = nullptr) :
m_config(_config),
m_type(_type),
m_control(_control),

View File

@ -9,21 +9,20 @@
#include <ewol/object/Manager.h>
#include <ewol/context/Context.h>
#include <ewol/ewol.h>
#include <etk/stdTools.h>
#include <unistd.h>
#undef __class__
#define __class__ "ewol::object::Manager"
ewol::object::Manager::Manager() {
ewol::object::Manager::Manager(ewol::Context& _context) :
m_context(_context) {
EWOL_DEBUG(" == > init Object-Manager");
// Can create mlemory leak ... == > but not predictable comportement otherwise ...
m_eObjectAutoRemoveList.clear();
m_eObjectList.clear();
}
ewol::object::Manager::~Manager() {
bool hasError = false;
if (m_eObjectAutoRemoveList.size()!=0) {
if (m_eObjectListActive.size()!=0) {
EWOL_ERROR("Must not have anymore eObject to auto-remove !!!");
hasError = true;
}
@ -34,168 +33,148 @@ ewol::object::Manager::~Manager() {
if (true == hasError) {
EWOL_ERROR("Check if the function UnInit has been called !!!");
}
displayListObject();
}
void ewol::object::Manager::displayListObject() {
EWOL_INFO("List loaded object : ");
for (auto &it : m_eObjectList) {
EWOL_INFO(" Ref=" << it->getRefCount() << " remove=" << it->isDestroyed() << " name='" << it->getName() << "' type=" << it->getObjectType());
}
}
void ewol::object::Manager::unInit() {
EWOL_DEBUG(" == > Un-Init Object-Manager");
removeAllAutoRemove();
EWOL_INFO(" remove missing user widget");
size_t iii=0;
while(iii < m_eObjectList.size()) {
if (m_eObjectList[iii] != NULL) {
if ( m_eObjectList[iii]->getStatic() == true
|| m_eObjectList[iii]->getStatusResource() == true) {
iii++;
} else {
EWOL_WARNING("Un-INIT : remove Object type=\"" << m_eObjectList[iii]->getObjectType() << "\"");
m_eObjectList[iii].reset();
m_eObjectList[iii] = NULL;
}
} else {
m_eObjectList.erase(m_eObjectList.begin()+iii);
for (auto &it : m_eObjectList) {
if (it != nullptr) {
//it->removeObject();
}
}
removeAllAutoRemove();
EWOL_INFO(" remove resources user widgets");
while(iii < m_eObjectList.size()) {
if (m_eObjectList[iii] != NULL) {
if (m_eObjectList[iii]->getStatic() == true) {
iii++;
} else {
EWOL_WARNING("Un-INIT : remove Object type=\"" << m_eObjectList[iii]->getObjectType() << "\"");
m_eObjectList[iii].reset();
}
} else {
m_eObjectList.erase(m_eObjectList.begin()+iii);
}
}
removeAllAutoRemove();
EWOL_INFO(" remove static user widgets");
while(iii < m_eObjectList.size()) {
if (m_eObjectList[iii] != NULL) {
EWOL_WARNING("Un-INIT : remove Object type=\"" << m_eObjectList[iii]->getObjectType() << "\"");
m_eObjectList[iii].reset();
} else {
m_eObjectList.erase(m_eObjectList.begin()+iii);
}
removeAllRemovedObject();
EWOL_INFO(" remove missing user object");
if (m_eObjectListActive.size() != 0) {
EWOL_ERROR("Have " << m_eObjectListActive.size() << " active Object");
}
m_multiCast.clear();
m_eObjectListActive.clear();
m_eObjectList.clear();
removeAllRemovedObject();
}
void ewol::object::Manager::add(ewol::Object* _object) {
if (_object == NULL) {
void ewol::object::Manager::add(const ewol::object::Shared<ewol::Object>& _object) {
if (_object == nullptr) {
EWOL_ERROR("try to add an inexistant Object in manager");
}
// ! < it might benerate a shared object !!!
m_eObjectList.push_back(_object);
m_eObjectListActive.push_back(_object);
}
int32_t ewol::object::Manager::getNumberObject() {
return m_eObjectList.size() + m_eObjectAutoRemoveList.size();
return m_eObjectList.size();
}
void ewol::object::Manager::informOneObjectIsRemoved(ewol::Object* _object) {
size_t mbElement = m_eObjectList.size();
for (int64_t iii=0; iii<(int64_t)m_eObjectList.size(); ++iii) {
if ( m_eObjectList[iii] != NULL
&& m_eObjectList[iii] != _object) {
//EWOL_DEBUG("inform " << iii+1 << "/" << m_eObjectList.size());
//EWOL_DEBUG(" id=" << m_eObjectList[iii]->getId() << " named '" << m_eObjectList[iii]->getName() << "' type=" << m_eObjectList[iii]->getObjectType());
m_eObjectList[iii]->onObjectRemove(_object);
if (mbElement != m_eObjectList.size()) {
iii = -1;
mbElement = m_eObjectList.size();
}
void ewol::object::Manager::informOneObjectIsRemoved(const ewol::object::Shared<ewol::Object>& _object) {
for (auto &it : m_eObjectList) {
if ( it != nullptr
&& it != _object) {
EWOL_VERBOSE("[" << _object->getId() << "] onObjectRemove() : " << it->getId() << " type=" << it->getObjectType() << " name='" << it->getName() << "'");
it->onObjectRemove(_object);
}
}
//EWOL_DEBUG("inform active done");
mbElement = m_eObjectAutoRemoveList.size();
for (size_t iii=0; iii<m_eObjectAutoRemoveList.size(); iii++) {
if( m_eObjectAutoRemoveList[iii] != NULL
&& m_eObjectAutoRemoveList[iii] != _object) {
//EWOL_DEBUG("inform2 " << iii+1 << "/" << m_eObjectAutoRemoveList.size());
m_eObjectAutoRemoveList[iii]->onObjectRemove(_object);
if (mbElement != m_eObjectAutoRemoveList.size()) {
iii = -1;
mbElement = m_eObjectAutoRemoveList.size();
}
}
// inform context that n object is removed ...
m_context.onObjectRemove(_object);
m_multiCast.onObjectRemove(_object);
EWOL_VERBOSE("m_removeEventList.size() = " << m_removeEventList.size());
for (auto &it : m_removeEventList) {
EWOL_VERBOSE("[" << _object->getId() << "] Inform Event Remove Object List : ...");
it->onObjectRemove(_object);
}
//EWOL_DEBUG("inform in-active done");
// call input event manager to remove linked widget ...
ewol::getContext().onObjectRemove(_object);
}
void ewol::object::Manager::rm(ewol::Object* _object) {
if (NULL == _object) {
EWOL_ERROR("Try to remove (NULL) Object");
void ewol::object::Manager::respown(const ewol::object::Shared<ewol::Object>& _object){
if (_object == nullptr) {
EWOL_ERROR("Try to respown nullptr Object");
return;
}
for (size_t iii=0; iii<m_eObjectList.size(); iii++) {
if (m_eObjectList[iii] == _object) {
for (auto it : m_eObjectListActive) {
if (it == _object) {
EWOL_ERROR("try to respawn an existing active Object : [" << _object->getId() << "] type='" << _object->getObjectType() << "'");
return;
}
}
m_eObjectListActive.push_back(_object);
}
void ewol::object::Manager::remove(const ewol::object::Shared<ewol::Object>& _object) {
if (_object == nullptr) {
EWOL_ERROR("Try to Auto-Remove (nullptr) Object");
return;
}
int32_t count = 0;
auto it(m_eObjectListActive.begin());
while (it != m_eObjectListActive.end()) {
if (*it == _object) {
m_eObjectListActive.erase(it);
// remove Element
m_eObjectList[iii] = NULL;
m_eObjectList.erase(m_eObjectList.begin()+iii);
EWOL_DEBUG("Auto-Remove Object : [" << _object->getId() << "] type='" << _object->getObjectType() << "' name=" << _object->getName());
informOneObjectIsRemoved(_object);
return;
}
}
// check if the object has not been auto removed ... or remove in defered time ...
for (size_t iii=0; iii<m_eObjectAutoRemoveList.size(); iii++) {
if( m_eObjectAutoRemoveList[iii] != NULL
&& m_eObjectAutoRemoveList[iii] == _object) {
return;
}
}
// in this case, we have an error ...
EWOL_ERROR("Try to remove Object that is not referenced ...");
}
void ewol::object::Manager::autoRemove(ewol::Object* _object) {
if (NULL == _object) {
EWOL_ERROR("Try to Auto-Remove (NULL) Object");
return;
}
for (size_t iii=0; iii<m_eObjectList.size(); iii++) {
if (m_eObjectList[iii] == _object) {
// remove Element
m_eObjectList[iii] = NULL;
m_eObjectList.erase(m_eObjectList.begin()+iii);
EWOL_DEBUG("Auto-Remove Object : [" << _object->getId() << "] type='" << _object->getObjectType() << "'");
if (_object->getStatusResource() == false) {
informOneObjectIsRemoved(_object);
}
m_eObjectAutoRemoveList.push_back(_object);
ewol::getContext().forceRedrawAll();
EWOL_DEBUG("Auto-Remove Object ... done");
return;
EWOL_VERBOSE("Auto-Remove Object ... done (have " << _object->getRefCount() << " references)");
it = m_eObjectListActive.begin();
count++;
} else {
++it;
}
}
EWOL_ERROR("Try to Auto-Remove Object that is not referenced ...");
if (count == 0) {
EWOL_ERROR("Try to Auto-Remove Object that is not referenced ...");
} else if ( count>1
|| count<0) {
EWOL_ERROR("Remove more than one object in the system list ==> this is a real problem ...");
}
}
// clean all Object that request an autoRemove ...
void ewol::object::Manager::removeAllAutoRemove() {
//EWOL_DEBUG("Auto-Remove Object section : " << m_eObjectAutoRemoveList.size() << " elemeents");
while(0<m_eObjectAutoRemoveList.size()) {
if (m_eObjectAutoRemoveList[0] != NULL) {
EWOL_DEBUG("Real Auto-Remove Object [" << m_eObjectAutoRemoveList[0]->getId() << "]type='" << m_eObjectAutoRemoveList[0]->getObjectType() << "'");
void ewol::object::Manager::removeAllRemovedObject() {
EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectListActive.size() << "/" << m_eObjectList.size() << " elemeents");
auto it(m_eObjectList.begin());
while (it != m_eObjectList.end()) {
if ( *it != nullptr
&& (*it)->getRefCount() <= 1) {
EWOL_DEBUG("remove definitly : [" << (*it)->getId() << "] type='" << (*it)->getObjectType() << "'");
m_eObjectList.erase(it);
it = m_eObjectList.begin();
} else {
++it;
}
m_eObjectAutoRemoveList.erase(m_eObjectAutoRemoveList.begin());
}
m_eObjectAutoRemoveList.clear();
}
ewol::Object* ewol::object::Manager::get(const std::string& _name) {
ewol::object::Shared<ewol::Object> ewol::object::Manager::get(const std::string& _name) {
if (_name == "") {
return NULL;
return nullptr;
}
for (size_t iii=0; iii<m_eObjectList.size(); iii++) {
if (m_eObjectList[iii] != NULL) {
if (m_eObjectList[iii]->getName() == _name) {
return m_eObjectList[iii].get();
}
for (auto &it : m_eObjectList) {
if ( it != nullptr
&& it->getName() == _name) {
return it;
}
}
return nullptr;
}
void ewol::object::Manager::add(ewol::object::RemoveEvent* _class) {
m_removeEventList.push_back(_class);
}
void ewol::object::Manager::rm(ewol::object::RemoveEvent* _class) {
for (size_t iii=0; iii<m_removeEventList.size(); ++iii) {
if (m_removeEventList[iii] == _class) {
m_removeEventList.erase(m_removeEventList.begin() + iii);
return;
}
}
return NULL;
}

View File

@ -12,37 +12,63 @@
#include <etk/types.h>
#include <ewol/object/Object.h>
#include <ewol/object/MultiCast.h>
#include <ewol/object/RemoveEvent.h>
namespace ewol {
class Context;
namespace object {
class Manager {
private:
std::vector<ewol::Object::Shared<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
std::vector<ewol::Object::Shared<ewol::Object>> m_eObjectAutoRemoveList; // all widget allocated
std::vector<ewol::object::RemoveEvent*> m_removeEventList;
std::vector<ewol::object::Shared<ewol::Object>> m_eObjectList; // all widget allocated == > all time increment ... never removed ...
std::vector<ewol::object::Shared<ewol::Object>> m_eObjectListActive; // all active widget
Context& m_context;
public:
Manager();
~Manager();
Manager(Context& _context);
virtual ~Manager();
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
void unInit();
void add(ewol::Object* _object);
void rm(ewol::Object* _object);
/**
* @brief Get the number of loaded object in the system
* @return number of Object
*/
int32_t getNumberObject();
void autoRemove(ewol::Object* _object);
void removeAllAutoRemove();
ewol::Object* get(const std::string& _name);
void displayListObject();
private:
void informOneObjectIsRemoved(ewol::Object* _object);
friend class ewol::Object;
/**
* @brief Internal API that used only with Object toi reference itself in the manager.
* @note The manager remove the object when the refecence Low down 1 (last keeper)
* @param[in] _object Reference shared pointer on the object
*/
void add(const ewol::object::Shared<ewol::Object>& _object);
/**
* @brief Called when an object request to be removed
* @param[in] _object Reference shared pointer on the object
*/
void remove(const ewol::object::Shared<ewol::Object>& _object);
/**
* @brief Called when a user want to reuse an object that have been removed previously
* @param[in] _object Reference shared pointer on the object
*/
void respown(const ewol::object::Shared<ewol::Object>& _object);
public:
void removeAllRemovedObject();
ewol::object::Shared<ewol::Object> get(const std::string& _name);
private:
void informOneObjectIsRemoved(const ewol::object::Shared<ewol::Object>& _object);
private:
ewol::object::MultiCast m_multiCast; //!< muticast manager
public:
ewol::object::MultiCast& multiCast() {
return m_multiCast;
};
void add(ewol::object::RemoveEvent* _class);
void rm(ewol::object::RemoveEvent* _class);
};
};
};

View File

@ -13,10 +13,10 @@
std::ostream& ewol::object::operator <<(std::ostream& _os, const ewol::object::Message& _obj) {
_os << "{";
if (NULL != _obj.getMessage()) {
if (nullptr != _obj.getMessage()) {
_os << "msg=\"" << _obj.getMessage() << "\"";
} else {
_os << "msg={NULL}";
_os << "msg={nullptr}";
}
_os << " data=\"" << _obj.getData() << "\"}";
return _os;

View File

@ -15,11 +15,11 @@ namespace ewol {
namespace object {
class Message {
private:
ewol::Object* m_callerObject; //!< Caller class.
ewol::object::Shared<ewol::Object> m_callerObject; //!< Caller class.
const char* m_event; //!< Event pointer == > unique Id define by the system ...
std::string m_data; //!< compositing additionnal message Value.
public:
Message(ewol::Object* _caller,
Message(const ewol::object::Shared<ewol::Object>& _caller,
const char* _message,
const std::string& _data) :
m_callerObject(_caller),
@ -27,10 +27,10 @@ namespace ewol {
m_data(_data) {
};
void setCaller(ewol::Object* _caller) {
void setCaller(const ewol::object::Shared<ewol::Object>& _caller) {
m_callerObject = _caller;
};
inline ewol::Object* getCaller() const {
inline ewol::object::Shared<ewol::Object> getCaller() const {
return m_callerObject;
};
void setMessage(const char* _message) {

View File

@ -23,14 +23,30 @@ ewol::object::MultiCast::~MultiCast() {
m_messageList.clear();
}
void ewol::object::MultiCast::clear() {
EWOL_INFO("EObject message Multi-Cast");
m_messageList.clear();
}
void ewol::object::MultiCast::add(ewol::Object* _object, const char* const _message) {
if (NULL == _object) {
EWOL_ERROR("Add with NULL object");
void ewol::object::MultiCast::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
auto it(m_messageList.begin());
while (it != m_messageList.end()) {
if (it->m_object == _object) {
m_messageList.erase(it);
it = m_messageList.begin();
} else {
++it;
}
}
}
void ewol::object::MultiCast::add(const ewol::object::Shared<ewol::Object>& _object, const char* const _message) {
if (nullptr == _object) {
EWOL_ERROR("Add with nullptr object");
return;
}
if (NULL == _message) {
EWOL_ERROR("Add with NULL Message");
if (nullptr == _message) {
EWOL_ERROR("Add with nullptr Message");
return;
}
m_messageList.push_back(MessageList(_message, _object));
@ -38,35 +54,36 @@ void ewol::object::MultiCast::add(ewol::Object* _object, const char* const _mess
}
void ewol::object::MultiCast::rm(ewol::Object* _object) {
if (NULL == _object) {
EWOL_ERROR("Rm with NULL object");
void ewol::object::MultiCast::rm(const ewol::object::Shared<ewol::Object>& _object) {
if (nullptr == _object) {
EWOL_ERROR("Rm with nullptr object");
return;
}
// send the message at all registered widget ...
for (int32_t iii=m_messageList.size()-1; iii >= 0; iii--) {
if(m_messageList[iii].m_object == _object) {
auto it(m_messageList.begin());
while (it != m_messageList.end()) {
if(it->m_object == _object) {
EWOL_DEBUG("SendMulticast RM listener :" << _object->getId());
m_messageList[iii].m_message = NULL;
m_messageList[iii].m_object = NULL;
m_messageList.erase(m_messageList.begin()+iii);
m_messageList.erase(it);
it = m_messageList.begin();
} else {
++it;
}
}
}
void ewol::object::MultiCast::send(ewol::Object* _object, const char* const _message, const std::string& _data) {
void ewol::object::MultiCast::send(const ewol::object::Shared<ewol::Object>& _object, const char* const _message, const std::string& _data) {
EWOL_VERBOSE("SendMulticast message \"" << _message << "\" data=\"" << _data << "\" to :");
// send the message at all registered widget ...
for (size_t iii=0; iii<m_messageList.size(); iii++) {
if( m_messageList[iii].m_message == _message
&& m_messageList[iii].m_object != _object)
{
if (NULL != m_messageList[iii].m_object) {
EWOL_VERBOSE(" id = " << m_messageList[iii].m_object->getId() << " type=" << m_messageList[iii].m_object->getObjectType());
for (auto &it : m_messageList) {
if( it.m_message == _message
&& it.m_object != _object) {
if (it.m_object != nullptr) {
EWOL_VERBOSE(" id = " << it.m_object->getId() << " type=" << it.m_object->getObjectType());
// generate event ... (create message before ...
ewol::object::Message tmpMsg(_object, m_messageList[iii].m_message, _data);
m_messageList[iii].m_object->onReceiveMessage(tmpMsg);
ewol::object::Message tmpMsg(_object, it.m_message, _data);
it.m_object->onReceiveMessage(tmpMsg);
}
}
}

View File

@ -22,23 +22,25 @@ namespace ewol {
private:
class MessageList {
public:
MessageList(const char* _message=NULL, ewol::Object* _object=NULL) :
MessageList(const char* _message=nullptr, ewol::object::Shared<ewol::Object> _object=nullptr) :
m_message(_message), m_object(_object) {
}
const char* m_message;
ewol::Object* m_object;
ewol::object::Shared<ewol::Object> m_object;
};
std::vector<MessageList> m_messageList; //!< List of all message ...
public:
MultiCast();
~MultiCast();
virtual ~MultiCast();
void clear();
void anonymousSend(const char* const _messageId, const std::string& _data) {
send(NULL, _messageId, _data);
send(nullptr, _messageId, _data);
};
void send(ewol::Object* _object, const char* const _message, const std::string& _data);
void rm(ewol::Object* _object);
void add(ewol::Object* _object, const char* const _message);
void send(const ewol::object::Shared<ewol::Object>& _object, const char* const _message, const std::string& _data);
void rm(const ewol::object::Shared<ewol::Object>& _object);
void add(const ewol::object::Shared<ewol::Object>& _object, const char* const _message);
void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
};
};
};

View File

@ -13,7 +13,7 @@
#include <ewol/object/MultiCast.h>
#undef __class__
#define __class__ "ewol::Object"
#define __class__ "Object"
const char* const ewol::Object::configName = "name";
@ -21,22 +21,37 @@ size_t ewol::Object::m_valUID = 0;
void ewol::Object::objRefCountIncrement() {
std::unique_lock<std::mutex> lock(m_lockRefCount);
/*
if (std::string("ewol::widget::Windows") == getObjectType()) {
EWOL_ERROR("increment Windows count ++" << m_objRefCount);
//etk::log::displayBacktrace();
}
*/
m_objRefCount++;
}
void ewol::Object::objRefCountDecrement() {
std::unique_lock<std::mutex> lock(m_lockRefCount);
/*
if (std::string("ewol::widget::Windows") == getObjectType()) {
EWOL_ERROR("Decrement Windows count --" << m_objRefCount);
//etk::log::displayBacktrace();
}
*/
m_objRefCount--;
}
void ewol::Object::operator delete(void* _ptr, std::size_t _sz) {
EWOL_DEBUG("custom delete for size " << _sz);
EWOL_VERBOSE("custom delete for size " << _sz);
ewol::Object* obj = (ewol::Object*)_ptr;
obj->objRefCountDecrement();
if (obj->m_objRefCount <= 0) {
EWOL_DEBUG(" ==> real remove");
EWOL_VERBOSE(" ==> real remove");
::operator delete(_ptr);
} else {
EWOL_DEBUG(" ==> Some user is link on it ...");
EWOL_ERROR(" ==> Some user is link on it : " << obj->m_objRefCount);
etk::log::displayBacktrace();
}
}
@ -44,21 +59,76 @@ void ewol::Object::operator delete[](void* _ptr, std::size_t _sz) {
EWOL_CRITICAL("custom delete for size ==> not implemented ..." << _sz);
::operator delete(_ptr);
}
#ifdef DEBUG
void ewol::Object::incOwnerCount() {
std::unique_lock<std::mutex> lock(m_lockRefCount);
m_ownerCount++;
if (m_ownerCount>1) {
EWOL_CRITICAL("Multiple Owner on one Object ==> very bad ... " << m_ownerCount);
}
}
void ewol::Object::decOwnerCount() {
std::unique_lock<std::mutex> lock(m_lockRefCount);
m_ownerCount--;
if (m_ownerCount<0) {
EWOL_CRITICAL("Owner remove the owner counter under 1 ==> very bad ... " << m_ownerCount);
}
}
#endif
void ewol::Object::autoDestroy() {
EWOL_VERBOSE("Destroy object : [" << getId() << "] type:" << getObjectType());
bool needRemove = false;
{
std::unique_lock<std::mutex> lock(m_lockRefCount);
if (m_isDestroyed == true) {
EWOL_WARNING("Request remove of a removed object");
return;
} else {
m_isDestroyed = true;
needRemove = true;
}
}
if (needRemove == true) {
getObjectManager().remove(this);
}
}
void ewol::Object::removeObject() {
autoDestroy();
}
void ewol::Object::respownObject() {
std::unique_lock<std::mutex> lock(m_lockRefCount);
if (m_isDestroyed == false) {
EWOL_WARNING("Respawn an alive object");
return;
}
m_isDestroyed = false;
getObjectManager().respown(this);
}
ewol::Object::Object() :
m_objRefCount(1),
#ifdef DEBUG
m_ownerCount(0),
#endif
m_isDestroyed(false),
m_static(false),
m_isResource(false) {
// note this is nearly atomic ... (but it is enough)
m_uniqueId = m_valUID++;
EWOL_DEBUG("new Object : [" << m_uniqueId << "]");
getObjectManager().add(this);
registerConfig(configName, "string", NULL, "Object name, might be a unique reference in all the program");
registerConfig(configName, "string", nullptr, "Object name, might be a unique reference in all the program");
}
ewol::Object::Object(const std::string& _name) :
m_objRefCount(1),
#ifdef DEBUG
m_ownerCount(0),
#endif
m_isDestroyed(false),
m_static(false),
m_name(_name),
m_isResource(false) {
@ -66,19 +136,12 @@ ewol::Object::Object(const std::string& _name) :
m_uniqueId = m_valUID++;
EWOL_DEBUG("new Object : [" << m_uniqueId << "]");
getObjectManager().add(this);
registerConfig(configName, "string", NULL, "Object name, might be a unique reference in all the program");
registerConfig(configName, "string", nullptr, "Object name, might be a unique reference in all the program");
}
ewol::Object::~Object() {
EWOL_DEBUG("delete Object : [" << m_uniqueId << "] : " << getTypeDescription());
getObjectManager().rm(this);
EWOL_DEBUG("delete Object : [" << m_uniqueId << "] : " << getTypeDescription() << " refcount=" << m_objRefCount);
getMultiCast().rm(this);
for (size_t iii=0; iii<m_externEvent.size(); iii++) {
if (NULL!=m_externEvent[iii]) {
delete(m_externEvent[iii]);
m_externEvent[iii] = NULL;
}
}
m_externEvent.clear();
m_availlableEventId.clear();
m_uniqueId = -1;
@ -92,7 +155,7 @@ const char * const ewol::Object::getObjectType() {
}
void ewol::Object::addObjectType(const char* _type) {
if (_type == NULL) {
if (_type == nullptr) {
EWOL_ERROR(" try to add a type with no value...");
return;
}
@ -119,16 +182,14 @@ bool ewol::Object::isTypeCompatible(const std::string& _type) {
return false;
}
void ewol::Object::autoDestroy() {
getObjectManager().autoRemove(this);
}
void ewol::Object::removeObject() {
getObjectManager().autoRemove(this);
}
void ewol::Object::addEventId(const char * _generateEventId) {
if (NULL != _generateEventId) {
for (auto &it : m_availlableEventId) {
if (std::string(it) == _generateEventId) {
EWOL_WARNING("Event already existed : '" << it << "' == '" << _generateEventId << "'");
return;
}
}
if (_generateEventId != nullptr) {
m_availlableEventId.push_back(_generateEventId);
}
}
@ -137,29 +198,25 @@ void ewol::Object::generateEventId(const char * _generateEventId, const std::str
int32_t nbObject = getObjectManager().getNumberObject();
EWOL_VERBOSE("try send message '" << _generateEventId << "'");
// for every element registered ...
for (size_t iii=0; iii<m_externEvent.size(); iii++) {
if (NULL==m_externEvent[iii]) {
EWOL_VERBOSE(" Null pointer");
continue;
}
for (auto &it : m_externEvent) {
// if we find the event ...
if (m_externEvent[iii]->localEventId != _generateEventId) {
EWOL_VERBOSE(" wrong event '" << m_externEvent[iii]->localEventId << "' != '" << _generateEventId << "'");
if (it.localEventId != _generateEventId) {
EWOL_VERBOSE(" wrong event '" << it.localEventId << "' != '" << _generateEventId << "'");
continue;
}
if (m_externEvent[iii]->destObject == NULL) {
EWOL_VERBOSE(" NULL dest");
if (it.destObject == nullptr) {
EWOL_VERBOSE(" nullptr dest");
continue;
}
if (m_externEvent[iii]->overloadData.size() <= 0){
ewol::object::Message tmpMsg(this, m_externEvent[iii]->destEventId, _data);
if (it.overloadData.size() <= 0){
ewol::object::Message tmpMsg(this, it.destEventId, _data);
EWOL_VERBOSE("send message " << tmpMsg);
m_externEvent[iii]->destObject->onReceiveMessage(tmpMsg);
it.destObject->onReceiveMessage(tmpMsg);
} else {
// set the user requested data ...
ewol::object::Message tmpMsg(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
ewol::object::Message tmpMsg(this, it.destEventId, it.overloadData);
EWOL_VERBOSE("send message " << tmpMsg);
m_externEvent[iii]->destObject->onReceiveMessage(tmpMsg);
it.destObject->onReceiveMessage(tmpMsg);
}
}
if (nbObject > getObjectManager().getNumberObject()) {
@ -179,34 +236,30 @@ void ewol::Object::registerMultiCast(const char* const _messageId) {
getMultiCast().add(this, _messageId);
}
void ewol::Object::registerOnEvent(ewol::Object * _destinationObject,
void ewol::Object::registerOnEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const char * _eventId,
const char * _eventIdgenerated,
const std::string& _overloadData) {
if (NULL == _destinationObject) {
EWOL_ERROR("Input ERROR NULL pointer Object ...");
if (nullptr == _destinationObject) {
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
return;
}
if (NULL == _eventId) {
EWOL_ERROR("Input ERROR NULL pointer Event Id...");
if (nullptr == _eventId) {
EWOL_ERROR("Input ERROR nullptr pointer Event Id...");
return;
}
if ( _eventId[0] == '*'
&& _eventId[1] == '\0') {
EWOL_VERBOSE("Register on all event ...");
for(size_t iii=0; iii<m_availlableEventId.size(); iii++) {
ewol::object::EventExtGen * tmpEvent = new ewol::object::EventExtGen();
if (NULL == tmpEvent) {
EWOL_ERROR("Allocation error in Register Event...");
continue;
}
tmpEvent->localEventId = m_availlableEventId[iii];
tmpEvent->destObject = _destinationObject;
tmpEvent->overloadData = _overloadData;
if (NULL != _eventIdgenerated) {
tmpEvent->destEventId = _eventIdgenerated;
for(auto &it : m_availlableEventId) {
ewol::object::EventExtGen tmpEvent;
tmpEvent.localEventId = it;
tmpEvent.destObject = _destinationObject;
tmpEvent.overloadData = _overloadData;
if (nullptr != _eventIdgenerated) {
tmpEvent.destEventId = _eventIdgenerated;
} else {
tmpEvent->destEventId = m_availlableEventId[iii];
tmpEvent.destEventId = it;
}
m_externEvent.push_back(tmpEvent);
}
@ -214,18 +267,18 @@ void ewol::Object::registerOnEvent(ewol::Object * _destinationObject,
}
// check if event existed :
bool findIt = false;
for(size_t iii=0; iii<m_availlableEventId.size(); iii++) {
if (m_availlableEventId[iii] == _eventId) {
for(auto &it : m_availlableEventId) {
if (it == _eventId) {
findIt = true;
break;
}
}
if (false == findIt) {
EWOL_VERBOSE("Try to register with a NON direct string name");
for(size_t iii=0; iii<m_availlableEventId.size(); iii++) {
if (0 == strncmp(m_availlableEventId[iii], _eventId, 1024)) {
for(auto &it : m_availlableEventId) {
if (0 == strncmp(it, _eventId, 1024)) {
findIt = true;
_eventId = m_availlableEventId[iii];
_eventId = it;
EWOL_VERBOSE("find event ID : '" << _eventId << "' ==> '" << _eventIdgenerated << "'");
break;
}
@ -235,66 +288,70 @@ void ewol::Object::registerOnEvent(ewol::Object * _destinationObject,
EWOL_ERROR("Can not register event on this Type=" << getObjectType() << " event=\"" << _eventId << "\" == > unknow event");
return;
}
ewol::object::EventExtGen * tmpEvent = new ewol::object::EventExtGen();
if (NULL == tmpEvent) {
EWOL_ERROR("Allocation error in Register Event...");
return;
}
tmpEvent->localEventId = _eventId;
tmpEvent->destObject = _destinationObject;
tmpEvent->overloadData = _overloadData;
if (NULL != _eventIdgenerated) {
tmpEvent->destEventId = _eventIdgenerated;
ewol::object::EventExtGen tmpEvent;
tmpEvent.localEventId = _eventId;
tmpEvent.destObject = _destinationObject;
tmpEvent.overloadData = _overloadData;
if (nullptr != _eventIdgenerated) {
tmpEvent.destEventId = _eventIdgenerated;
} else {
tmpEvent->destEventId = _eventId;
tmpEvent.destEventId = _eventId;
}
m_externEvent.push_back(tmpEvent);
}
void ewol::Object::unRegisterOnEvent(ewol::Object * _destinationObject,
const char * _eventId) {
if (NULL == _destinationObject) {
EWOL_ERROR("Input ERROR NULL pointer Object ...");
void ewol::Object::unRegisterOnEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const char * _eventId) {
if (_destinationObject == nullptr) {
EWOL_ERROR("Input ERROR nullptr pointer Object ...");
return;
}
// check if event existed :
for(int64_t iii = m_externEvent.size()-1; iii >= 0; --iii) {
if (m_externEvent[iii] == NULL) {
continue;
}
if (m_externEvent[iii]->destObject != _destinationObject) {
continue;
}
if (_eventId == NULL) {
m_externEvent.erase(m_externEvent.begin()+iii);
} else if (m_externEvent[iii]->localEventId == _eventId) {
m_externEvent.erase(m_externEvent.begin()+iii);
auto it(m_externEvent.begin());
while(it != m_externEvent.end()) {
if (it->destObject == nullptr) {
m_externEvent.erase(it);
it = m_externEvent.begin();
} else if ( it->destObject == _destinationObject
&& it->localEventId == _eventId) {
m_externEvent.erase(it);
it = m_externEvent.begin();
EWOL_INFO("[" << getId() << "] Remove extern event : to object id=" << _destinationObject->getId() << " event=" << _eventId);
} else {
++it;
}
}
}
void ewol::Object::onObjectRemove(ewol::Object * _removObject) {
for(int32_t iii=m_externEvent.size()-1; iii >= 0; iii--) {
if (NULL == m_externEvent[iii]) {
m_externEvent.erase(m_externEvent.begin()+iii);
} else if (m_externEvent[iii]->destObject == _removObject) {
m_externEvent.erase(m_externEvent.begin()+iii);
void ewol::Object::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
EWOL_VERBOSE("[" << getId() << "] onObjectRemove(" << _object->getId() << ")");
auto it(m_externEvent.begin());
while(it != m_externEvent.end()) {
if (it->destObject == nullptr) {
m_externEvent.erase(it);
it = m_externEvent.begin();
} else if (it->destObject == _object) {
m_externEvent.erase(it);
it = m_externEvent.begin();
EWOL_INFO("[" << getId() << "] Remove extern event : to object id=" << _object->getId());
} else {
++it;
}
}
}
void ewol::Object::registerConfig(const char* _config,
const char* _type,
const char* _control,
const char* _description,
const char* _default) {
if (NULL == _config) {
EWOL_ERROR("Try to add NULL config");
const char* _type,
const char* _control,
const char* _description,
const char* _default) {
if (nullptr == _config) {
EWOL_ERROR("Try to add nullptr config");
return;
}
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (NULL != m_listConfig[iii].getConfig()) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (0 == strcmp(m_listConfig[iii].getConfig(), _config) ) {
EWOL_ERROR("Try to add config already added : " << _config << " at pos=" << iii);
}
@ -305,12 +362,12 @@ void ewol::Object::registerConfig(const char* _config,
bool ewol::Object::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
bool errorOccured = true;
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (m_listConfig[iii].getConfig() == NULL) {
if (m_listConfig[iii].getConfig() == nullptr) {
continue;
}
if (_node->existAttribute(m_listConfig[iii].getConfig()) == false) {
@ -325,16 +382,16 @@ bool ewol::Object::loadXML(exml::Element* _node) {
}
bool ewol::Object::storeXML(exml::Element* _node) const {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
bool errorOccured = true;
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (m_listConfig[iii].getConfig() == NULL) {
if (m_listConfig[iii].getConfig() == nullptr) {
continue;
}
std::string value = getConfig(m_listConfig[iii].getConfig());
if (NULL != m_listConfig[iii].getDefault() ) {
if (nullptr != m_listConfig[iii].getDefault() ) {
if (value == m_listConfig[iii].getDefault() ) {
// nothing to add on the XML :
continue;
@ -367,7 +424,7 @@ bool ewol::Object::onGetConfig(const char* _config, std::string& _result) const
bool ewol::Object::setConfig(const std::string& _config, const std::string& _value) {
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (NULL != m_listConfig[iii].getConfig()) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) {
// call config with standard parameter
return setConfig(ewol::object::Config(m_listConfig[iii].getConfig(), _value));
@ -380,7 +437,7 @@ bool ewol::Object::setConfig(const std::string& _config, const std::string& _val
std::string ewol::Object::getConfig(const char* _config) const {
std::string res="";
if (NULL != _config) {
if (nullptr != _config) {
onGetConfig(_config, res);
}
return res;
@ -388,7 +445,7 @@ std::string ewol::Object::getConfig(const char* _config) const {
std::string ewol::Object::getConfig(const std::string& _config) const {
for(size_t iii=0 ; iii<m_listConfig.size() ; iii++) {
if (NULL != m_listConfig[iii].getConfig()) {
if (nullptr != m_listConfig[iii].getConfig()) {
if (_config == m_listConfig[iii].getConfig() ) {
// call config with standard parameter
return getConfig(m_listConfig[iii].getConfig());
@ -400,16 +457,16 @@ std::string ewol::Object::getConfig(const std::string& _config) const {
}
bool ewol::Object::setConfigNamed(const std::string& _objectName, const ewol::object::Config& _conf) {
ewol::Object* object = getObjectManager().get(_objectName);
if (object == NULL) {
ewol::object::Shared<ewol::Object> object = getObjectManager().get(_objectName);
if (object == nullptr) {
return false;
}
return object->setConfig(_conf);
}
bool ewol::Object::setConfigNamed(const std::string& _objectName, const std::string& _config, const std::string& _value) {
ewol::Object* object = getObjectManager().get(_objectName);
if (object == NULL) {
ewol::object::Shared<ewol::Object> object = getObjectManager().get(_objectName);
if (object == nullptr) {
return false;
}
return object->setConfig(_config, _value);

View File

@ -13,7 +13,10 @@
#include <etk/types.h>
#include <vector>
#include <exml/exml.h>
#include <vector>
#include <mutex>
#include <ewol/object/Shared.h>
#include <ewol/object/Owner.h>
namespace ewol {
// some class need to define element befor other ...
class Object;
@ -37,7 +40,7 @@ namespace ewol {
class EventExtGen {
public:
const char* localEventId; //!< local event Id generation
ewol::Object* destObject; //!< destination widget that might be call
ewol::object::Shared<ewol::Object> destObject; //!< destination widget that might be call
const char* destEventId; //!< generated event ID on the distant widget
std::string overloadData; //!< sometimes the user prefer to receive some specific data on an event (instead of the one sed by the widget)
};
@ -47,92 +50,31 @@ namespace ewol {
* this class mermit at every Object to communicate between them.
*/
class Object {
public:
template<typename T, typename = typename std::enable_if<std::is_convertible<T*, Object*>::value>::type>
class Shared {
private:
T* m_pointer;
public:
Shared() :
m_pointer(nullptr) {
// nothing to do ...
}
Shared(T* _pointer) :
m_pointer(_pointer) {
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
}
~Shared() {
reset();
}
// copy constructor
Shared(const Shared& _obj) :
m_pointer(nullptr) {
m_pointer = _obj.get();
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
}
// Move Constructor
Shared(Shared&& _obj) :
m_pointer(nullptr) {
// transfert pointer
m_pointer = _obj.m_pointer;
_obj.m_pointer = nullptr;
}
Shared& operator=(const Shared<T>& _obj) noexcept {
if(this == &_obj) {
return *this;
}
reset();
m_pointer = _obj.get();
if (m_pointer != nullptr) {
m_pointer->objRefCountIncrement();
}
return *this;
}
void reset() {
if (m_pointer == nullptr) {
return;
}
if (m_pointer->m_objRefCount <= 0) {
TK_ERROR("Object is already removed");
} else if (m_pointer->m_objRefCount == 1) {
TK_ERROR("Remove object (in shared)");
delete m_pointer;
} else {
m_pointer->objRefCountDecrement();
}
m_pointer = nullptr;
}
T* get() noexcept {
return m_pointer;
}
T* get() const noexcept {
return m_pointer;
}
T& operator*() const noexcept {
return *m_pointer;
}
T* operator->() const noexcept {
return m_pointer;
}
};
template<typename T> Shared<T> makeShared(T* _pointer) {
return Shared<T>(_pointer);
}
template<typename T> friend class ewol::object::Shared;
template<typename T> friend class ewol::object::Owner;
private:
// TODO : Lock Refcounting ...
//! @not-in-doc
std::mutex m_lockRefCount;
//! @not-in-doc
int32_t m_objRefCount;
public:
//! @not-in-doc
void objRefCountIncrement();
//! @not-in-doc
void objRefCountDecrement();
int32_t getRefCount() {
return m_objRefCount;
}
//! @not-in-doc
static void operator delete(void* _ptr, std::size_t _sz);
//! @not-in-doc
static void operator delete[](void* _ptr, std::size_t _sz);
#ifdef DEBUG
public:
int32_t m_ownerCount;
void incOwnerCount();
void decOwnerCount();
#endif
private:
static size_t m_valUID; //!< stic used for the unique ID definition
public:
@ -152,6 +94,8 @@ namespace ewol {
* @brief Destructor
*/
virtual ~Object();
private:
bool m_isDestroyed;
protected:
/**
* @brief Auto-destroy the object
@ -162,6 +106,17 @@ namespace ewol {
* @brief Asynchronous removing the object
*/
void removeObject();
/**
* @brief Respown a removed object
*/
void respownObject();
/**
* @brief Get if the element is destroyed or not
* @return true The element in destroyed
*/
bool isDestroyed() {
return m_isDestroyed;
}
private:
std::vector<const char*> m_listType;
public:
@ -208,7 +163,7 @@ namespace ewol {
return m_uniqueId;
};
private:
std::vector<object::EventExtGen*> m_externEvent; //!< Generic list of event generation for output link
std::vector<object::EventExtGen> m_externEvent; //!< Generic list of event generation for output link
std::vector<const char*> m_availlableEventId; //!< List of all event availlable for this widget
protected:
/**
@ -241,23 +196,22 @@ namespace ewol {
* @param[in] _eventIdgenerated event generated when call the distant Object.onReceiveMessage(...)
* @param[in] _overloadData When the user prever to receive a data specificly for this event ...
*/
void registerOnEvent(ewol::Object * _destinationObject,
void registerOnEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const char * _eventIdgenerated = nullptr,
const std::string& _overloadData = "");
/**
* @brief Un-Register an Object over an other.
* @param[in] _destinationObject pointer on the object that might be call when an event is generated
* @param[in] _eventId Event generate inside the object (NULL to remove all event on this object)
* @param[in] _eventId Event generate inside the object (nullptr to remove all event on this object)
*/
void unRegisterOnEvent(ewol::Object * _destinationObject,
const char * _eventId = NULL);
void unRegisterOnEvent(const ewol::object::Shared<ewol::Object>& _destinationObject,
const char * _eventId = nullptr);
/**
* @brief Inform object that an other object is removed ...
* @param[in] _removObject Pointer on the Object remeved == > the user must remove all reference on this Object
* @note : Sub classes must call this class
*/
virtual void onObjectRemove(ewol::Object * _removeObject);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
/**
* @brief Receive a message from an other Object with a specific eventId and data
* @param[in] _msg Message handle
@ -277,10 +231,10 @@ namespace ewol {
* @param[in] _default Default value of this parameter.
*/
void registerConfig(const char* _config,
const char* _type = NULL,
const char* _control = NULL,
const char* _description = NULL,
const char* _default = NULL);
const char* _type = nullptr,
const char* _control = nullptr,
const char* _description = nullptr,
const char* _default = nullptr);
/**
* @brief Configuration requested to the curent Object
* @param[in] _conf Configuration handle.
@ -388,91 +342,6 @@ namespace ewol {
return m_isResource;
}
};
// section to compare shared pointer of an object with an other
//! @not in doc
template<typename T, typename T2>
inline bool operator==(const Object::Shared<T>& _obj, const Object::Shared<T2>& _obj2) noexcept {
return _obj.get() == _obj2.get();
}
//! @not in doc
template<typename T2>
inline bool operator==(const Object::Shared<T2>& _obj, std::nullptr_t) noexcept {
return _obj.get() == NULL;
}
//! @not in doc
template<typename T2>
inline bool operator==(std::nullptr_t, const Object::Shared<T2>& _obj) noexcept {
return _obj.get() == NULL;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const Object::Shared<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() == _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const T* _obj, const Object::Shared<T2>& _obj2) noexcept {
return _obj == _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator!=(const Object::Shared<T>& _obj, const Object::Shared<T2>& _obj2) noexcept {
return _obj.get() != _obj2.get();
}
//! @not in doc
template<typename T>
inline bool operator!=(const Object::Shared<T>& _obj, std::nullptr_t) noexcept {
return _obj.get() != NULL;
}
//! @not in doc
template<typename T>
inline bool operator!=(std::nullptr_t, const Object::Shared<T>& _obj) noexcept {
return _obj.get() != NULL;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const Object::Shared<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() != _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const T* _obj, const Object::Shared<T2>& _obj2) noexcept {
return _obj != _obj2.get();
}
//! @not in doc
template<typename T>
inline void swap(Object::Shared<T>& _obj, Object::Shared<T>& _obj2) noexcept {
_obj2.swap(_obj);
}
//! @not in doc
template<typename T2, typename T>
inline Object::Shared<T2> static_pointer_cast(const Object::Shared<T>& _obj) noexcept {
return Object::Shared<T2>(_obj, static_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline Object::Shared<T2> const_pointer_cast(const Object::Shared<T>& _obj) noexcept {
return Object::Shared<T2>(_obj, const_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline Object::Shared<T2> dynamic_pointer_cast(const Object::Shared<T>& _obj) noexcept {
if (T2* obj = dynamic_cast<T2*>(_obj.get())) {
return Object::Shared<T2>(_obj, obj);
}
return Object::Shared<T2>();
}
};
#endif

262
sources/ewol/object/Owner.h Normal file
View File

@ -0,0 +1,262 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __EWOL_OBJECT_OWNER_H__
#define __EWOL_OBJECT_OWNER_H__
#include <ewol/debug.h>
namespace ewol {
namespace object {
template<typename T>
class Owner {
private:
T* m_pointer;
public:
Owner() :
m_pointer(nullptr) {
// nothing to do ...
}
Owner(T* _pointer) :
m_pointer(_pointer) {
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
}
~Owner() {
reset();
}
// copy constructor
Owner(const Owner& _obj) :
m_pointer(nullptr) {
EWOL_CRITICAL("You can not user copy operator for Owner reference...");
}
// Move Constructor
Owner(Owner&& _obj) :
m_pointer(nullptr) {
// transfert pointer
m_pointer = _obj.m_pointer;
_obj.m_pointer = nullptr;
}
// shared to private constructor
template<typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
Owner(const Shared<T2>& _obj) :
m_pointer(nullptr) {
m_pointer = _obj.get();
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
#ifdef DEBUG
m_pointer->incOwnerCount();
#endif
}
template<typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
Owner& operator=(const Owner<T2>& _obj) noexcept {
if(this == &_obj) {
return *this;
}
reset();
m_pointer = _obj.get();
if (m_pointer != nullptr) {
m_pointer->objRefCountIncrement();
#ifdef DEBUG
m_pointer->incOwnerCount();
#endif
}
return *this;
}
template<typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
Owner& operator=(const Shared<T2>& _obj) noexcept {
reset();
m_pointer = _obj.get();
if (m_pointer != nullptr) {
m_pointer->objRefCountIncrement();
#ifdef DEBUG
m_pointer->incOwnerCount();
#endif
}
return *this;
}
void reset() {
if (m_pointer == nullptr) {
return;
}
//etk::log::displayBacktrace();
// To prevent cyclisme
T* tmp = m_pointer;
m_pointer = nullptr;
tmp->removeObject();
if (tmp->m_objRefCount <= 0) {
EWOL_WARNING("Object will be already removed");
} else if (tmp->m_objRefCount == 1) {
EWOL_VERBOSE("Remove object (in Owner)");
delete tmp;
} else {
tmp->objRefCountDecrement();
#ifdef DEBUG
tmp->decOwnerCount();
#endif
}
}
void resetShared() {
if (m_pointer == nullptr) {
return;
}
// To prevent cyclisme
T* tmp = m_pointer;
m_pointer = nullptr;
if (tmp->m_objRefCount <= 0) {
EWOL_WARNING("Object will be already removed");
} else if (tmp->m_objRefCount == 1) {
EWOL_VERBOSE("Remove object (in Owner)");
delete tmp;
} else {
tmp->objRefCountDecrement();
#ifdef DEBUG
tmp->decOwnerCount();
#endif
}
}
T* get() noexcept {
return m_pointer;
}
T* get() const noexcept {
return m_pointer;
}
T& operator*() const noexcept {
return *m_pointer;
}
T* operator->() const noexcept {
return m_pointer;
}
operator ewol::object::Shared<T>() const noexcept {
return m_pointer;
}
};
};
// section to compare Owner pointer of an object with an other
//! @not in doc
template<typename T, typename T2>
inline bool operator==(const object::Owner<T>& _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj.get() == _obj2.get();
}
//! @not in doc
template<typename T2>
inline bool operator==(const object::Owner<T2>& _obj, std::nullptr_t) noexcept {
return _obj.get() == nullptr;
}
//! @not in doc
template<typename T2>
inline bool operator==(std::nullptr_t, const object::Owner<T2>& _obj) noexcept {
return _obj.get() == nullptr;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const object::Owner<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() == _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const T* _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj == _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator==(const object::Owner<T>& _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj.get() == _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator==(const object::Shared<T>& _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj.get() == _obj2.get();
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const object::Owner<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() != _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const T* _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj != _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator!=(const object::Owner<T>& _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj.get() != _obj2.get();
}
//! @not in doc
template<typename T>
inline bool operator!=(const object::Owner<T>& _obj, std::nullptr_t) noexcept {
return _obj.get() != nullptr;
}
//! @not in doc
template<typename T>
inline bool operator!=(std::nullptr_t, const object::Owner<T>& _obj) noexcept {
return _obj.get() != nullptr;
}
//! @not in doc
template<typename T, typename T2>
inline bool operator!=(const object::Owner<T>& _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj.get() != _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator!=(const object::Shared<T>& _obj, const object::Owner<T2>& _obj2) noexcept {
return _obj.get() != _obj2.get();
}
/*
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
object::Shared<T> operator=(const object::Owner<T2>& _obj) {
return _obj.get();
}
*/
//! @not in doc
template<typename T>
inline void swap(object::Owner<T>& _obj, object::Owner<T>& _obj2) noexcept {
_obj2.swap(_obj);
}
//! @not in doc
template<typename T2, typename T>
inline object::Owner<T2> static_pointer_cast(const object::Owner<T>& _obj) noexcept {
return object::Owner<T2>(_obj, static_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline object::Owner<T2> const_pointer_cast(const object::Owner<T>& _obj) noexcept {
return object::Owner<T2>(_obj, const_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline object::Owner<T2> dynamic_pointer_cast(const object::Owner<T>& _obj) noexcept {
if (T2* obj = dynamic_cast<T2*>(_obj.get())) {
return object::Owner<T2>(_obj, obj);
}
return object::Owner<T2>();
}
};
#endif

View File

@ -0,0 +1,23 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#include <ewol/object/RemoveEvent.h>
#include <ewol/context/Context.h>
ewol::object::RemoveEvent::RemoveEvent() {
Context& tmp = ewol::getContext();
ewol::object::Manager& manager = tmp.getEObjectManager();
manager.add(this);
}
ewol::object::RemoveEvent::~RemoveEvent() {
Context& tmp = ewol::getContext();
ewol::object::Manager& manager = tmp.getEObjectManager();
manager.rm(this);
}

View File

@ -0,0 +1,27 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __EWOL_OBJECT_REMOVE_EVENT_H__
#define __EWOL_OBJECT_REMOVE_EVENT_H__
#include <etk/types.h>
#include <ewol/object/Object.h>
namespace ewol {
namespace object {
class RemoveEvent {
public:
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) = 0;
public:
RemoveEvent();
virtual ~RemoveEvent();
};
}
};
#endif

View File

@ -0,0 +1,190 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD 3 clauses (see license file)
*/
#ifndef __EWOL_OBJECT_SHARED_H__
#define __EWOL_OBJECT_SHARED_H__
#include <ewol/debug.h>
namespace ewol {
namespace object {
template<typename T>
class Shared {
private:
T* m_pointer;
public:
Shared() :
m_pointer(nullptr) {
// nothing to do ...
}
Shared(T* _pointer) :
m_pointer(_pointer) {
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
}
~Shared() {
reset();
}
// copy constructor
Shared(const Shared& _obj) :
m_pointer(nullptr) {
m_pointer = _obj.get();
if (m_pointer == nullptr) {
return;
}
m_pointer->objRefCountIncrement();
}
// Move Constructor
Shared(Shared&& _obj) :
m_pointer(nullptr) {
// transfert pointer
m_pointer = _obj.m_pointer;
_obj.m_pointer = nullptr;
}
Shared& operator=(const Shared<T>& _obj) noexcept {
if(this == &_obj) {
return *this;
}
reset();
m_pointer = _obj.get();
if (m_pointer != nullptr) {
m_pointer->objRefCountIncrement();
}
return *this;
}
void reset() {
if (m_pointer == nullptr) {
return;
}
// To prevent cyclisme
T* tmp = m_pointer;
m_pointer = nullptr;
if (tmp->m_objRefCount <= 0) {
EWOL_WARNING("Object is already removed");
} else if (tmp->m_objRefCount == 1) {
EWOL_VERBOSE("Remove object (in shared)");
delete tmp;
} else {
tmp->objRefCountDecrement();
}
}
T* get() const noexcept {
return m_pointer;
}
T& operator*() const noexcept {
return *m_pointer;
}
T* operator->() const noexcept {
return m_pointer;
}
template<typename T2> operator ewol::object::Shared<T2>() const noexcept {
return m_pointer;
}
};
// after calling this function, you might never call a delete on this pointer. (if you want to be able to use a delete, simply Shared<>(pointer)
template<typename T> Shared<T> makeShared(T* _pointer) {
if (_pointer == nullptr) {
return Shared<T>();
}
Shared<T> tmp(_pointer);
// remove one element to permit to remove at the last instance
_pointer->objRefCountDecrement();
return tmp;
}
};
// section to compare shared pointer of an object with an other
//! @not in doc
template<typename T, typename T2>
inline bool operator==(const object::Shared<T>& _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj.get() == _obj2.get();
}
//! @not in doc
template<typename T2>
inline bool operator==(const object::Shared<T2>& _obj, std::nullptr_t) noexcept {
return _obj.get() == nullptr;
}
//! @not in doc
template<typename T2>
inline bool operator==(std::nullptr_t, const object::Shared<T2>& _obj) noexcept {
return _obj.get() == nullptr;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const object::Shared<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() == _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator==(const T* _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj == _obj2.get();
}
//! @not in doc
template<typename T, typename T2>
inline bool operator!=(const object::Shared<T>& _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj.get() != _obj2.get();
}
//! @not in doc
template<typename T>
inline bool operator!=(const object::Shared<T>& _obj, std::nullptr_t) noexcept {
return _obj.get() != nullptr;
}
//! @not in doc
template<typename T>
inline bool operator!=(std::nullptr_t, const object::Shared<T>& _obj) noexcept {
return _obj.get() != nullptr;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const object::Shared<T>& _obj, const T2* _obj2) noexcept {
return _obj.get() != _obj2;
}
//! @not in doc
template<typename T, typename T2, typename = typename
std::enable_if<std::is_convertible<T*, T2*>::value>::type>
inline bool operator!=(const T* _obj, const object::Shared<T2>& _obj2) noexcept {
return _obj != _obj2.get();
}
//! @not in doc
template<typename T>
inline void swap(object::Shared<T>& _obj, object::Shared<T>& _obj2) noexcept {
_obj2.swap(_obj);
}
//! @not in doc
template<typename T2, typename T>
inline object::Shared<T2> static_pointer_cast(const object::Shared<T>& _obj) noexcept {
return object::Shared<T2>(_obj, static_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline object::Shared<T2> const_pointer_cast(const object::Shared<T>& _obj) noexcept {
return object::Shared<T2>(_obj, const_cast<T2*>(_obj.get()));
}
//! @not in doc
template<typename T2, typename T>
inline object::Shared<T2> dynamic_pointer_cast(const object::Shared<T>& _obj) noexcept {
if (T2* obj = dynamic_cast<T2*>(_obj.get())) {
return ewol::object::Shared<T2>(obj);
}
return ewol::object::Shared<T2>();
}
};
#endif

View File

@ -44,13 +44,13 @@ void ewol::resource::ColorFile::reload() {
return;
}
ejson::Array* baseArray = doc.getArray("color");
if (baseArray == NULL) {
if (baseArray == nullptr) {
EWOL_ERROR("Can not get basic array : 'color'");
return;
}
for (int32_t iii = 0; iii < baseArray->size(); ++iii) {
for (size_t iii = 0; iii < baseArray->size(); ++iii) {
ejson::Object* tmpObj = baseArray->getObject(iii);
if (tmpObj == NULL) {
if (tmpObj == nullptr) {
EWOL_DEBUG(" can not get object in 'color' id=" << iii);
continue;
}
@ -75,38 +75,27 @@ int32_t ewol::resource::ColorFile::request(const std::string& _paramName) {
}
ewol::resource::ColorFile* ewol::resource::ColorFile::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::ColorFile> ewol::resource::ColorFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : ColorFile : file : \"" << _filename << "\"");
ewol::resource::ColorFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::ColorFile*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::ColorFile> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::ColorFile>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// this element create a new one every time ....
object = new ewol::resource::ColorFile(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::ColorFile(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::ColorFile::release(ewol::resource::ColorFile*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -30,6 +30,7 @@ namespace ewol {
* @param[in] _filename Name of the file needed
*/
ColorFile(const std::string& _filename);
public:
/**
* @brief Simple Destructor of this class (nothing specific ...)
*/
@ -73,14 +74,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::ColorFile* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::ColorFile*& _object);
static ewol::object::Shared<ewol::resource::ColorFile> keep(const std::string& _filename);
};
};
};

View File

@ -15,12 +15,12 @@
ewol::resource::Colored3DObject::Colored3DObject() :
m_GLprogram(NULL) {
m_GLprogram(nullptr) {
addObjectType("ewol::Colored3DObject");
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = ewol::resource::Program::keep("DATA:simple3D.prog");
if (NULL != m_GLprogram ) {
if (nullptr != m_GLprogram ) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord3d");
m_GLColor = m_GLprogram->getUniform("EW_color");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
@ -28,8 +28,7 @@ ewol::resource::Colored3DObject::Colored3DObject() :
}
ewol::resource::Colored3DObject::~Colored3DObject() {
// remove dynamics dependencies :
ewol::resource::Program::release(m_GLprogram);
}
@ -40,7 +39,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
if (_vertices.size() <= 0) {
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -83,7 +82,7 @@ void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices,
if (_vertices.size() <= 0) {
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -123,7 +122,7 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
if (_vertices.size() <= 0) {
return;
}
if (m_GLprogram == NULL) {
if (m_GLprogram == nullptr) {
EWOL_ERROR("No shader ...");
return;
}
@ -155,23 +154,15 @@ void ewol::resource::Colored3DObject::drawLine(std::vector<vec3>& _vertices,
}
}
ewol::resource::Colored3DObject* ewol::resource::Colored3DObject::keep() {
ewol::object::Shared<ewol::resource::Colored3DObject> ewol::resource::Colored3DObject::keep() {
EWOL_VERBOSE("KEEP : direct Colored3DObject");
// need to crate a new one ...
ewol::resource::Colored3DObject* object = new ewol::resource::Colored3DObject();
if (NULL == object) {
ewol::object::Shared<ewol::resource::Colored3DObject> object = ewol::object::makeShared(new ewol::resource::Colored3DObject());
if (object == nullptr) {
EWOL_ERROR("allocation error of a resource : ???Colored3DObject??? ");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::Colored3DObject::release(ewol::resource::Colored3DObject*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -19,12 +19,13 @@ namespace ewol {
namespace resource {
class Colored3DObject : public ewol::Resource {
protected:
ewol::resource::Program* m_GLprogram;
ewol::object::Shared<ewol::resource::Program> m_GLprogram;
int32_t m_GLPosition;
int32_t m_GLMatrix;
int32_t m_GLColor;
protected:
Colored3DObject();
public:
virtual ~Colored3DObject();
public:
virtual void draw(std::vector<vec3>& _vertices,
@ -45,14 +46,9 @@ namespace ewol {
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::Colored3DObject* keep();
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::Colored3DObject*& _object);
static ewol::object::Shared<ewol::resource::Colored3DObject> keep();
};
};
};

View File

@ -29,10 +29,10 @@ ewol::resource::ConfigFile::ConfigFile(const std::string& _filename) :
ewol::resource::ConfigFile::~ConfigFile() {
// remove all element
for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) {
for (int32_t iii=0; iii<m_list.size(); iii++){
if (nullptr != m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
m_list[iii] = nullptr;
}
}
m_list.clear();
@ -40,9 +40,9 @@ ewol::resource::ConfigFile::~ConfigFile() {
void ewol::resource::ConfigFile::reload() {
// reset all parameters
for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) {
m_list[iii] = NULL;
for (int32_t iii=0; iii<m_list.size(); iii++){
if (nullptr != m_list[iii]) {
m_list[iii] = nullptr;
}
}
m_doc.load(m_name);
@ -58,7 +58,7 @@ void ewol::resource::ConfigFile::reload() {
int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
// check if the parameters existed :
if (m_list.exist(_paramName) == false) {
m_list.add(_paramName, NULL);
m_list.add(_paramName, nullptr);
}
if (m_doc.exist(_paramName) == true) {
m_list[_paramName] = m_doc[_paramName];
@ -69,11 +69,11 @@ int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
double ewol::resource::ConfigFile::getNumber(int32_t _id) {
if ( _id < 0
|| m_list[_id] == NULL) {
|| m_list[_id] == nullptr) {
return 0.0;
}
ejson::Number* tmp = m_list[_id]->toNumber();
if (tmp == NULL) {
if (tmp == nullptr) {
return 0.0;
}
return tmp->get();
@ -82,11 +82,11 @@ double ewol::resource::ConfigFile::getNumber(int32_t _id) {
const std::string& ewol::resource::ConfigFile::getString(int32_t _id) {
static const std::string& errorString("");
if ( _id < 0
|| m_list[_id] == NULL) {
|| m_list[_id] == nullptr) {
return errorString;
}
ejson::String* tmp = m_list[_id]->toString();
if (tmp == NULL) {
if (tmp == nullptr) {
return errorString;
}
return tmp->get();
@ -94,48 +94,39 @@ const std::string& ewol::resource::ConfigFile::getString(int32_t _id) {
bool ewol::resource::ConfigFile::getBoolean(int32_t _id) {
if ( _id < 0
|| m_list[_id] == NULL) {
|| m_list[_id] == nullptr) {
return false;
}
ejson::Boolean* tmp = m_list[_id]->toBoolean();
if (tmp == NULL) {
if (tmp == nullptr) {
return false;
}
return tmp->get();
}
ewol::resource::ConfigFile* ewol::resource::ConfigFile::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::ConfigFile> ewol::resource::ConfigFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
ewol::resource::ConfigFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::ConfigFile*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::ConfigFile> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::ConfigFile>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// this element create a new one every time ....
object = new ewol::resource::ConfigFile(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::ConfigFile(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : '" << _filename << "'");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::ConfigFile::release(ewol::resource::ConfigFile*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -23,6 +23,7 @@ namespace ewol {
etk::Hash<ejson::Value*> m_list;
protected:
ConfigFile(const std::string& _filename);
public:
virtual ~ConfigFile();
public:
void reload();
@ -37,14 +38,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::ConfigFile* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::ConfigFile*& _object);
static ewol::object::Shared<ewol::resource::ConfigFile> keep(const std::string& _filename);
};
};
};

View File

@ -29,7 +29,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
m_borderSize(10),
m_textureBorderSize(0,0) {
addObjectType("ewol::resource::DistanceFieldFont");
m_font = NULL;
m_font = nullptr;
m_lastGlyphPos.setValue(1,1);
m_lastRawHeigh = 0;
m_sizeRatio = 1.0f;
@ -84,18 +84,18 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
if (m_fileName.size() == 0) {
EWOL_ERROR("can not load FONT name : '" << m_fileName << "'" );
m_font = NULL;
m_font = nullptr;
return;
}
EWOL_INFO("Load FONT name : '" << m_fileName << "'");
m_font = ewol::resource::FontFreeType::keep(m_fileName);
if (m_font == NULL) {
if (m_font == nullptr) {
EWOL_ERROR("Pb Loading FONT name : '" << m_fileName << "'" );
}
// set the bassic charset:
m_listElement.clear();
if (m_font == NULL) {
if (m_font == nullptr) {
return;
}
if (importFromFile() == true) {
@ -121,7 +121,7 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont(const std::string& _fontNam
}
ewol::resource::DistanceFieldFont::~DistanceFieldFont() {
ewol::resource::FontFreeType::release(m_font);
}
@ -211,7 +211,7 @@ void ewol::resource::DistanceFieldFont::generateDistanceField(const egami::Image
bool ewol::resource::DistanceFieldFont::addGlyph(const char32_t& _val) {
bool hasChange = false;
if (m_font == NULL) {
if (m_font == nullptr) {
return false;
}
// add the curent "char"
@ -325,7 +325,7 @@ ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const ch
if (m_listElement.size() > 0) {
return &((m_listElement)[0]);
}
return NULL;
return nullptr;
}
//EWOL_ERROR(" index=" << index);
//EWOL_ERROR(" m_UVal=" << m_listElement[_displayMode][index].m_UVal);
@ -335,56 +335,43 @@ ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const ch
return &((m_listElement)[index]);
}
ewol::resource::DistanceFieldFont* ewol::resource::DistanceFieldFont::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::DistanceFieldFont> ewol::resource::DistanceFieldFont::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : DistanceFieldFont : file : '" << _filename << "'");
ewol::resource::DistanceFieldFont* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::DistanceFieldFont*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::DistanceFieldFont> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::DistanceFieldFont>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// need to crate a new one ...
EWOL_DEBUG("CREATE: DistanceFieldFont : file : '" << _filename << "'");
object = new ewol::resource::DistanceFieldFont(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::DistanceFieldFont(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::DistanceFieldFont::release(ewol::resource::DistanceFieldFont*& _object) {
if (NULL == _object) {
return;
}
std::string name = _object->getName();
int32_t count = _object->getCounter() - 1;
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
if (getManager().release(object2) == true) {
EWOL_DEBUG("REMOVE: DistanceFieldFont : file : '" << name << "' count=" << count);
//etk::displayBacktrace(false);
}
_object = NULL;
}
void ewol::resource::DistanceFieldFont::exportOnFile() {
EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
ejson::Document doc;
ejson::Array* tmpList = new ejson::Array();
if (tmpList == NULL) {
EWOL_ERROR("NULL pointer");
if (tmpList == nullptr) {
EWOL_ERROR("nullptr pointer");
return;
}
for (size_t iii=0; iii<m_listElement.size(); ++iii) {
ejson::Object* tmpObj = new ejson::Object();
if (tmpObj == NULL) {
if (tmpObj == nullptr) {
continue;
}
tmpObj->addString("m_UVal", std::to_string(m_listElement[iii].m_UVal));
@ -427,14 +414,14 @@ bool ewol::resource::DistanceFieldFont::importFromFile() {
m_borderSize = doc.getNumberValue("m_borderSize", 2);
m_textureBorderSize = doc.addString("m_textureBorderSize", "0,0");
ejson::Array* tmpList = doc.getArray("m_listElement");
if (tmpList == NULL) {
EWOL_ERROR("NULL pointer array");
if (tmpList == nullptr) {
EWOL_ERROR("nullptr pointer array");
return false;
}
m_listElement.clear();
for (size_t iii=0; iii<tmpList->size(); ++iii) {
ejson::Object* tmpObj = tmpList->getObject(iii);
if (tmpObj == NULL) {
if (tmpObj == nullptr) {
continue;
}
GlyphProperty prop;

View File

@ -23,7 +23,7 @@ namespace ewol {
// 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::resource::FontBase* m_font;
ewol::object::Shared<ewol::resource::FontBase> m_font;
public:
std::vector<GlyphProperty> m_listElement;
private:
@ -32,7 +32,8 @@ namespace ewol {
int32_t m_lastRawHeigh;
protected:
DistanceFieldFont(const std::string& _fontName);
~DistanceFieldFont();
public:
virtual ~DistanceFieldFont();
public:
float getDisplayRatio(float _size);
/**
@ -60,7 +61,7 @@ namespace ewol {
/**
* @brief get the pointer on the coresponding glyph
* @param[in] _charcode The unicodeValue
* @return The pointer on the glyph == > never NULL
* @return The pointer on the glyph == > never nullptr
*/
ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode);
public:
@ -68,14 +69,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::DistanceFieldFont* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::DistanceFieldFont*& _object);
static ewol::object::Shared<ewol::resource::DistanceFieldFont> keep(const std::string& _filename);
private:
/**
* @brief add a glyph in a texture font.

View File

@ -46,7 +46,7 @@ void ewol::resource::freeTypeUnInit() {
return;
}
int32_t error = FT_Done_FreeType( library );
library = NULL;
library = nullptr;
if(0 != error) {
EWOL_CRITICAL(" when Un-loading FreeType Librairy ...");
}
@ -56,7 +56,7 @@ ewol::resource::FontFreeType::FontFreeType(const std::string& _fontName) :
FontBase(_fontName) {
addObjectType("ewol::FontFreeType");
m_init = false;
m_FileBuffer = NULL;
m_FileBuffer = nullptr;
m_FileSize = 0;
etk::FSNode myfile(_fontName);
@ -75,7 +75,7 @@ ewol::resource::FontFreeType::FontFreeType(const std::string& _fontName) :
}
// allocate data
m_FileBuffer = new FT_Byte[m_FileSize];
if (NULL == m_FileBuffer) {
if (nullptr == m_FileBuffer) {
EWOL_ERROR("Error Memory allocation size=" << _fontName);
return;
}
@ -99,9 +99,9 @@ ewol::resource::FontFreeType::FontFreeType(const std::string& _fontName) :
ewol::resource::FontFreeType::~FontFreeType() {
// clean the tmp memory
if (NULL != m_FileBuffer) {
if (nullptr != m_FileBuffer) {
delete[] m_FileBuffer;
m_FileBuffer = NULL;
m_FileBuffer = nullptr;
}
// must be deleted fftFace
FT_Done_Face( m_fftFace );
@ -390,36 +390,26 @@ void ewol::resource::FontFreeType::display() {
//EWOL_INFO(" Current size = " << (int)m_fftFace->size);
}
ewol::resource::FontBase* ewol::resource::FontFreeType::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::FontBase> ewol::resource::FontFreeType::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\"");
ewol::resource::FontBase* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::FontBase*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::FontBase> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::FontBase>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// need to crate a new one ...
object = new ewol::resource::FontFreeType(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::FontFreeType(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::FontFreeType::release(ewol::resource::FontBase*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -30,7 +30,8 @@ namespace ewol {
void display();
protected:
FontFreeType(const std::string& _fontName);
~FontFreeType();
public:
virtual ~FontFreeType();
public:
bool getGlyphProperty(int32_t _fontSize,
@ -58,14 +59,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::FontBase* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::FontBase*& _object);
static ewol::object::Shared<ewol::resource::FontBase> keep(const std::string& _filename);
};
void freeTypeInit();
void freeTypeUnInit();

View File

@ -62,13 +62,13 @@ static int32_t nextP2(int32_t _value) {
ewol::resource::TextureFile* ewol::resource::TextureFile::keep(const std::string& _filename, ivec2 _size) {
ewol::object::Shared<ewol::resource::TextureFile> ewol::resource::TextureFile::keep(const std::string& _filename, ivec2 _size) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size);
if (_filename == "") {
ewol::resource::TextureFile* object = new ewol::resource::TextureFile("");
if (NULL == object) {
ewol::object::Shared<ewol::resource::TextureFile> object = ewol::object::makeShared(new ewol::resource::TextureFile(""));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
@ -101,36 +101,25 @@ ewol::resource::TextureFile* ewol::resource::TextureFile::keep(const std::string
}
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
ewol::resource::TextureFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(TmpFilename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::TextureFile*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::TextureFile> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(TmpFilename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::TextureFile>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
EWOL_INFO("CREATE: TextureFile: '" << TmpFilename << "' size=" << _size);
// need to crate a new one ...
object = new ewol::resource::TextureFile(TmpFilename, _filename, _size);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::TextureFile(TmpFilename, _filename, _size));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::TextureFile::release(ewol::resource::TextureFile*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -23,6 +23,7 @@ namespace ewol {
private:
TextureFile(const std::string& _genName);
TextureFile(std::string _genName, const std::string& _fileName, const ivec2& _size);
public:
virtual ~TextureFile() { };
public:
const vec2& getRealSize() {
@ -34,14 +35,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::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::resource::TextureFile*& _object);
static ewol::object::Shared<ewol::resource::TextureFile> keep(const std::string& _filename, ivec2 _size=ivec2(-1,-1));
};
};
};

View File

@ -151,13 +151,13 @@ static int32_t nextP2(int32_t _value) {
ewol::resource::ImageDF* ewol::resource::ImageDF::keep(const std::string& _filename, ivec2 _size) {
ewol::object::Shared<ewol::resource::ImageDF> ewol::resource::ImageDF::keep(const std::string& _filename, ivec2 _size) {
EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size);
if (_filename == "") {
ewol::resource::ImageDF* object = new ewol::resource::ImageDF("");
if (NULL == object) {
ewol::object::Shared<ewol::resource::ImageDF> object = ewol::object::makeShared(new ewol::resource::ImageDF(""));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
@ -190,36 +190,26 @@ ewol::resource::ImageDF* ewol::resource::ImageDF::keep(const std::string& _filen
}
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
ewol::resource::ImageDF* object = NULL;
ewol::Resource* object2 = getManager().localKeep("DF__" + TmpFilename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::ImageDF*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::ImageDF> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep("DF__" + TmpFilename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::ImageDF>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
EWOL_INFO("CREATE: ImageDF: '" << TmpFilename << "' size=" << _size);
// need to crate a new one ...
object = new ewol::resource::ImageDF("DF__" + TmpFilename, _filename, _size);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::ImageDF("DF__" + TmpFilename, _filename, _size));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::ImageDF::release(ewol::resource::ImageDF*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -24,7 +24,9 @@ namespace ewol {
protected:
ImageDF(const std::string& _genName);
ImageDF(std::string _genName, const std::string& _fileName, const ivec2& _size);
public:
virtual ~ImageDF() { };
protected:
/**
* @brief Generate distance field of this Image input.
* @param[in] _input Input image to change in distance field mode.
@ -41,14 +43,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::ImageDF* 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::resource::ImageDF*& _object);
static ewol::object::Shared<ewol::resource::ImageDF> keep(const std::string& _filename, ivec2 _size=ivec2(-1,-1));
};
};
};

View File

@ -40,14 +40,15 @@ void ewol::resource::Manager::unInit() {
display();
m_resourceListToUpdate.clear();
// remove all resources ...
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
if (m_resourceList[iii] != NULL) {
EWOL_WARNING("Find a resource that is not removed : [" << m_resourceList[iii]->getId() << "]"
<< "=\"" << m_resourceList[iii]->getName() << "\" "
<< m_resourceList[iii]->getCounter() << " elements");
delete(m_resourceList[iii]);
m_resourceList[iii] = NULL;
auto it(m_resourceList.begin());
while(it != m_resourceList.end()) {
if ((*it) != nullptr) {
EWOL_WARNING("Find a resource that is not removed : [" << (*it)->getId() << "]"
<< "=\"" << (*it)->getName() << "\" "
<< (*it)->getRefCount() << " elements");
}
m_resourceList.erase(it);
it = m_resourceList.begin();
}
m_resourceList.clear();
}
@ -55,12 +56,12 @@ void ewol::resource::Manager::unInit() {
void ewol::resource::Manager::display() {
EWOL_INFO("Resources loaded : ");
// remove all resources ...
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
if (m_resourceList[iii] != NULL) {
EWOL_INFO(" [" << m_resourceList[iii]->getId() << "]"
<< m_resourceList[iii]->getObjectType()
<< "=\"" << m_resourceList[iii]->getName() << "\" "
<< m_resourceList[iii]->getCounter() << " elements");
for (auto &it : m_resourceList) {
if (it != nullptr) {
EWOL_INFO(" [" << it->getId() << "]"
<< it->getObjectType()
<< "=\"" << it->getName() << "\" "
<< it->getRefCount() << " elements");
}
}
EWOL_INFO("Resources ---");
@ -72,11 +73,11 @@ void ewol::resource::Manager::reLoadResources() {
if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" Reload level : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
if(m_resourceList[iii] != NULL) {
if (jjj == m_resourceList[iii]->getResourceLevel()) {
m_resourceList[iii]->reload();
EWOL_INFO(" [" << m_resourceList[iii]->getId() << "]="<< m_resourceList[iii]->getObjectType());
for (auto &it : m_resourceList) {
if(it != nullptr) {
if (jjj == it->getResourceLevel()) {
it->reload();
EWOL_INFO(" [" << it->getId() << "]="<< it->getObjectType());
}
}
}
@ -87,14 +88,13 @@ void ewol::resource::Manager::reLoadResources() {
EWOL_INFO("------------- Resources -------------");
}
void ewol::resource::Manager::update(ewol::Resource* _object) {
void ewol::resource::Manager::update(const ewol::object::Shared<ewol::Resource>& _object) {
// chek if not added before
for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
if (m_resourceListToUpdate[iii] != NULL) {
if (m_resourceListToUpdate[iii] == _object) {
// just prevent some double add ...
return;
}
for (auto &it : m_resourceListToUpdate) {
if ( it != nullptr
&& it == _object) {
// just prevent some double add ...
return;
}
}
// add it ...
@ -103,31 +103,29 @@ void ewol::resource::Manager::update(ewol::Resource* _object) {
// Specific to load or update the data in the openGl context == > system use only
void ewol::resource::Manager::updateContext() {
if (true == m_contextHasBeenRemoved) {
if (m_contextHasBeenRemoved == true) {
// need to update all ...
m_contextHasBeenRemoved = false;
if (m_resourceList.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" updateContext level (D) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if(m_resourceList[iii] != NULL) {
if (jjj == m_resourceList[iii]->getResourceLevel()) {
//EWOL_DEBUG("Update context of " << iii << " named : " << l_resourceList[iii]->getName());
m_resourceList[iii]->updateContext();
}
for (auto &it : m_resourceList) {
if( it != nullptr
&& jjj == it->getResourceLevel()) {
//EWOL_DEBUG("Update context named : " << l_resourceList[iii]->getName());
it->updateContext();
}
}
}
}
}else {
} else {
if (m_resourceListToUpdate.size() != 0) {
for (size_t jjj=0; jjj<MAX_RESOURCE_LEVEL; jjj++) {
EWOL_INFO(" updateContext level (U) : " << jjj << "/" << (MAX_RESOURCE_LEVEL-1));
for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
if(m_resourceListToUpdate[iii] != NULL) {
if (jjj == m_resourceListToUpdate[iii]->getResourceLevel()) {
m_resourceListToUpdate[iii]->updateContext();
}
for (auto &it : m_resourceListToUpdate) {
if ( it != nullptr
&& jjj == it->getResourceLevel()) {
it->updateContext();
}
}
}
@ -139,9 +137,9 @@ void ewol::resource::Manager::updateContext() {
// in this case, it is really too late ...
void ewol::resource::Manager::contextHasBeenDestroyed() {
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) {
m_resourceList[iii]->removeContextToLate();
for (auto &it : m_resourceList) {
if (it != nullptr) {
it->removeContextToLate();
}
}
// no context preent ...
@ -149,26 +147,24 @@ void ewol::resource::Manager::contextHasBeenDestroyed() {
}
// internal generic keeper ...
ewol::Resource* ewol::resource::Manager::localKeep(const std::string& _filename) {
ewol::object::Shared<ewol::Resource> ewol::resource::Manager::localKeep(const std::string& _filename) {
EWOL_VERBOSE("KEEP (DEFAULT) : file : \"" << _filename << "\"");
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] != NULL) {
if(m_resourceList[iii]->getName() == _filename) {
m_resourceList[iii]->increment();
return m_resourceList[iii];
}
for (auto &it : m_resourceList) {
if ( it != nullptr
&& it->getName() == _filename) {
return it;
}
}
// we did not find it ...
return NULL;
return nullptr;
}
// internal generic keeper ...
void ewol::resource::Manager::localAdd(ewol::Resource* _object) {
void ewol::resource::Manager::localAdd(const ewol::object::Shared<ewol::Resource>& _object) {
//Add ... find empty slot
for (size_t iii=0; iii<m_resourceList.size(); iii++) {
if (m_resourceList[iii] == NULL) {
m_resourceList[iii] = _object;
for (auto &it : m_resourceList) {
if (it == nullptr) {
it = _object;
return;
}
}
@ -176,56 +172,24 @@ void ewol::resource::Manager::localAdd(ewol::Resource* _object) {
m_resourceList.push_back(_object);
}
bool ewol::resource::Manager::release(ewol::Resource*& _object) {
if (NULL == _object) {
EWOL_ERROR("Try to remove a resource that have null pointer ...");
return false;
}
for (size_t iii=0; iii<m_resourceListToUpdate.size(); iii++) {
if (m_resourceListToUpdate[iii] == _object) {
m_resourceListToUpdate[iii] = NULL;
//l_resourceListToUpdate.Erase(iii);
}
}
EWOL_VERBOSE("RELEASE (default) : file : \"" << _object->getName() << "\"");
for (int64_t iii=m_resourceList.size()-1; iii >= 0; iii--) {
if (m_resourceList[iii] == NULL) {
// in case of error ...
bool ewol::resource::Manager::checkResourceToRemove() {
//EWOL_INFO("remove object in Manager");
updateContext();
for (auto it(m_resourceList.begin()); it!=m_resourceList.end(); ++it) {
if ((*it) == nullptr) {
m_resourceList.erase(it);
it = m_resourceList.begin();
continue;
}
if(m_resourceList[iii] != _object) {
// 1 in object list, 1 in reference active list, and one here
if ((*it)->getRefCount() > 3) {
continue;
}
if (m_resourceList[iii]->decrement() == true) {
// remove element from the list :
m_resourceList[iii] = NULL;
// delete element
_object->removeObject();
// insidiously remove the pointer for the caller ...
_object = NULL;
return true; // object really removed
}
// insidiously remove the pointer for the caller ...
_object = NULL;
return false; // just decrement ...
EWOL_DEBUG("Request remove of an resource (refcount in Low : " << (*it)->getRefCount() << ")");
m_resourceList.erase(it);
it = m_resourceList.begin();
return true;
}
EWOL_ERROR("Can not find the resources in the list : " << (int64_t)_object);
// insidiously remove the pointer for the caller ...
_object = NULL;
return false;
}
// in case of error ...
void ewol::resource::Manager::onObjectRemove(ewol::Object * _removeObject) {
for (size_t iii=0; iii<m_resourceList.size(); ++iii) {
if (m_resourceList[iii] == _removeObject) {
EWOL_WARNING("Remove Resource that is not removed ... ");
m_resourceList[iii] = NULL;
}
}
for (size_t iii=0; iii<m_resourceListToUpdate.size(); ++iii) {
if (m_resourceListToUpdate[iii] == _removeObject) {
EWOL_WARNING("Remove Resource that is not removed .2. ");
m_resourceListToUpdate[iii] = NULL;
}
}
}

View File

@ -9,16 +9,19 @@
#ifndef __RESOURCES_MANAGER_H__
#define __RESOURCES_MANAGER_H__
#include <list>
#include <vector>
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/resource/Resource.h>
#include <ewol/object/RemoveEvent.h>
namespace ewol {
namespace resource {
class Manager {
class Manager{
private:
std::vector<ewol::Resource*> m_resourceList;
std::vector<ewol::Resource*> m_resourceListToUpdate;
std::list<ewol::object::Owner<ewol::Resource>> m_resourceList;
std::vector<ewol::object::Shared<ewol::Resource>> m_resourceListToUpdate;
bool m_contextHasBeenRemoved;
public:
/**
@ -29,7 +32,7 @@ namespace ewol {
* @brief Uninitiamize the resource manager, free all resources previously requested
* @note when not free == > generate warning, because the segfault can appear after...
*/
~Manager();
virtual ~Manager();
/**
* @brief remove all resources (un-init) out of the destructor (due to the system implementation)
*/
@ -47,7 +50,7 @@ namespace ewol {
* @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);
void update(const ewol::object::Shared<ewol::Resource>& _object);
/**
* @brief Call by the system chen the openGL Context has been unexpectially removed == > This reload all the texture, VBO and other ....
*/
@ -58,17 +61,9 @@ namespace ewol {
void contextHasBeenDestroyed();
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);
public: // herited function
virtual void onObjectRemove(ewol::Object * _removeObject);
ewol::object::Shared<ewol::Resource> localKeep(const std::string& _filename);
void localAdd(const ewol::object::Shared<ewol::Resource>& _object);
virtual bool checkResourceToRemove();
};
};
};

View File

@ -36,8 +36,8 @@ ewol::resource::Program::Program(const std::string& _filename) :
std::string tmpFilename = m_name;
// remove extention ...
tmpFilename.erase(tmpFilename.size()-4, 4);
ewol::resource::Shader* tmpShader = ewol::resource::Shader::keep(tmpFilename+"vert");
if (NULL == tmpShader) {
ewol::object::Shared<ewol::resource::Shader> tmpShader = ewol::resource::Shader::keep(tmpFilename+"vert");
if (nullptr == tmpShader) {
EWOL_CRITICAL("Error while getting a specific shader filename : " << tmpFilename);
return;
} else {
@ -45,7 +45,7 @@ ewol::resource::Program::Program(const std::string& _filename) :
m_shaderList.push_back(tmpShader);
}
tmpShader = ewol::resource::Shader::keep(tmpFilename+"frag");
if (NULL == tmpShader) {
if (nullptr == tmpShader) {
EWOL_CRITICAL("Error while getting a specific shader filename : " << tmpFilename);
return;
} else {
@ -64,7 +64,7 @@ ewol::resource::Program::Program(const std::string& _filename) :
}
#define MAX_LINE_SIZE (2048)
char tmpData[MAX_LINE_SIZE];
while (file.fileGets(tmpData, MAX_LINE_SIZE) != NULL) {
while (file.fileGets(tmpData, MAX_LINE_SIZE) != nullptr) {
int32_t len = strlen(tmpData);
if( tmpData[len-1] == '\n'
|| tmpData[len-1] == '\r') {
@ -80,8 +80,8 @@ ewol::resource::Program::Program(const std::string& _filename) :
}
// get it with relative position :
std::string tmpFilename = file.getRelativeFolder() + tmpData;
ewol::resource::Shader* tmpShader = ewol::resource::Shader::keep(tmpFilename);
if (NULL == tmpShader) {
ewol::object::Shared<ewol::resource::Shader> tmpShader = ewol::resource::Shader::keep(tmpFilename);
if (nullptr == tmpShader) {
EWOL_CRITICAL("Error while getting a specific shader filename : " << tmpFilename);
} else {
EWOL_DEBUG("Add shader on program : "<< tmpFilename);
@ -96,10 +96,6 @@ ewol::resource::Program::Program(const std::string& _filename) :
}
ewol::resource::Program::~Program() {
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
ewol::resource::Shader::release(m_shaderList[iii]);
m_shaderList[iii] = 0;
}
m_shaderList.clear();
removeContext();
m_elementList.clear();
@ -173,7 +169,7 @@ void ewol::resource::Program::updateContext() {
EWOL_DEBUG("Create program with oglID=" << m_program);
// first attach vertex shader, and after fragment shader
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
if (NULL != m_shaderList[iii]) {
if (nullptr != m_shaderList[iii]) {
if (m_shaderList[iii]->getShaderType() == GL_VERTEX_SHADER) {
glAttachShader(m_program, m_shaderList[iii]->getGL_ID());
checkGlError("glAttachShader", __LINE__);
@ -181,7 +177,7 @@ void ewol::resource::Program::updateContext() {
}
}
for (size_t iii=0; iii<m_shaderList.size(); iii++) {
if (NULL != m_shaderList[iii]) {
if (nullptr != m_shaderList[iii]) {
if (m_shaderList[iii]->getShaderType() == GL_FRAGMENT_SHADER) {
glAttachShader(m_program, m_shaderList[iii]->getGL_ID());
checkGlError("glAttachShader", __LINE__);
@ -280,13 +276,13 @@ void ewol::resource::Program::reload() {
return;
}
// remove previous data ...
if (NULL != m_fileData) {
if (nullptr != m_fileData) {
delete[] m_fileData;
m_fileData = 0;
}
// allocate data
m_fileData = new char[fileSize+5];
if (NULL == m_fileData) {
if (nullptr == m_fileData) {
EWOL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
@ -331,7 +327,7 @@ void ewol::resource::Program::sendAttribute(int32_t _idElem,
void ewol::resource::Program::sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::resource::VirtualBufferObject* _vbo,
const ewol::object::Shared<ewol::resource::VirtualBufferObject>& _vbo,
int32_t _index,
int32_t _jumpBetweenSample,
int32_t _offset) {
@ -514,8 +510,8 @@ void ewol::resource::Program::uniform1fv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform1fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -536,8 +532,8 @@ void ewol::resource::Program::uniform2fv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform2fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -558,8 +554,8 @@ void ewol::resource::Program::uniform3fv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform3fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -580,8 +576,8 @@ void ewol::resource::Program::uniform4fv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform4fv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -605,8 +601,8 @@ void ewol::resource::Program::uniform1iv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform1iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -627,8 +623,8 @@ void ewol::resource::Program::uniform2iv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform2iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -649,8 +645,8 @@ void ewol::resource::Program::uniform3iv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform3iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -671,8 +667,8 @@ void ewol::resource::Program::uniform4iv(int32_t _idElem, int32_t _nbElement, co
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL == _value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
if (nullptr == _value) {
EWOL_ERROR("nullptr Input pointer to send at open GL ...");
return;
}
glUniform4iv(m_elementList[_idElem].m_elementId, _nbElement, _value);
@ -775,36 +771,26 @@ void ewol::resource::Program::unUse() {
ewol::resource::Program* ewol::resource::Program::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::Program> ewol::resource::Program::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\"");
ewol::resource::Program* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::Program*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::Program> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::Program>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// need to crate a new one ...
object = new ewol::resource::Program(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::Program(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::Program::release(ewol::resource::Program*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -50,7 +50,7 @@ namespace ewol {
private :
bool m_exist; //!< the file existed
GLuint m_program; //!< openGL id of the current program
std::vector<ewol::resource::Shader*> m_shaderList; //!< List of all the shader loaded
std::vector<ewol::object::Shared<ewol::resource::Shader>> m_shaderList; //!< List of all the shader loaded
std::vector<ewol::resource::progAttributeElement> m_elementList; //!< List of all the attribute requested by the user
bool m_hasTexture; //!< A texture has been set to the current shader
bool m_hasTexture1; //!< A texture has been set to the current shader
@ -60,6 +60,7 @@ namespace ewol {
* @param[in] filename Standard file name format. see @ref etk::FSNode
*/
Program(const std::string& filename);
public:
/**
* @brief Destructor, remove the current Program.
*/
@ -85,7 +86,7 @@ namespace ewol {
int32_t _jumpBetweenSample=0);
void sendAttributePointer(int32_t _idElem,
int32_t _nbElement,
ewol::resource::VirtualBufferObject* _vbo,
const ewol::object::Shared<ewol::resource::VirtualBufferObject>& _vbo,
int32_t _index,
int32_t _jumpBetweenSample=0,
int32_t _offset=0);
@ -297,14 +298,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::Program* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::Program*& _object);
static ewol::object::Shared<ewol::resource::Program> keep(const std::string& _filename);
};
};
};

View File

@ -15,19 +15,19 @@
void ewol::Resource::updateContext() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << getRefCount() << " time(s)");
}
void ewol::Resource::removeContext() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << getRefCount() << " time(s)");
}
void ewol::Resource::removeContextToLate() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << getRefCount() << " time(s)");
}
void ewol::Resource::reload() {
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << m_counter << " time(s)");
EWOL_DEBUG("Not set for : [" << getId() << "]" << getName() << " loaded " << getRefCount() << " time(s)");
}
ewol::resource::Manager& ewol::Resource::getManager() {

View File

@ -25,14 +25,12 @@ namespace ewol {
class Resource : public ewol::Object {
public:
Resource() :
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
};
Resource(const std::string& _name) :
ewol::Object(_name),
m_counter(1),
m_resourceLevel(MAX_RESOURCE_LEVEL-1) {
addObjectType("ewol::Resource");
setStatusResource(true);
@ -40,19 +38,6 @@ namespace ewol {
virtual ~Resource() {
};
private:
uint32_t m_counter; //!< number of time the element was loaded.
public:
void increment() {
m_counter++;
};
bool decrement() {
m_counter--;
return (m_counter == 0)?true:false;
};
int32_t getCounter() {
return m_counter;
};
protected:
uint8_t m_resourceLevel; //!< Level of the resource ==> for updata priority [0..5] 0 must be update first.
public:

View File

@ -18,7 +18,7 @@
ewol::resource::Shader::Shader(const std::string& _filename) :
ewol::Resource(_filename),
m_exist(false),
m_fileData(NULL),
m_fileData(nullptr),
m_shader(0),
m_type(0) {
addObjectType("ewol::Shader");
@ -38,9 +38,9 @@ ewol::resource::Shader::Shader(const std::string& _filename) :
}
ewol::resource::Shader::~Shader() {
if (NULL != m_fileData) {
if (nullptr != m_fileData) {
delete [] m_fileData;
m_fileData = NULL;
m_fileData = nullptr;
}
if (0!=m_shader) {
glDeleteShader(m_shader);
@ -62,7 +62,7 @@ void ewol::resource::Shader::updateContext() {
// Do nothing == > too dangerous ...
} else {
// create the Shader
if (NULL == m_fileData) {
if (nullptr == m_fileData) {
m_shader = 0;
return;
}
@ -73,7 +73,7 @@ void ewol::resource::Shader::updateContext() {
return;
} else {
//EWOL_INFO("Creater shader with GLID=" << m_shader);
glShaderSource(m_shader, 1, (const char**)&m_fileData, NULL);
glShaderSource(m_shader, 1, (const char**)&m_fileData, nullptr);
glCompileShader(m_shader);
GLint compiled = 0;
glGetShaderiv(m_shader, GL_COMPILE_STATUS, &compiled);
@ -128,13 +128,13 @@ void ewol::resource::Shader::reload() {
return;
}
// remove previous data ...
if (NULL != m_fileData) {
if (nullptr != m_fileData) {
delete[] m_fileData;
m_fileData = 0;
}
// allocate data
m_fileData = new char[fileSize+5];
if (NULL == m_fileData) {
if (nullptr == m_fileData) {
EWOL_ERROR("Error Memory allocation size=" << fileSize);
return;
}
@ -149,35 +149,26 @@ void ewol::resource::Shader::reload() {
updateContext();
}
ewol::resource::Shader* ewol::resource::Shader::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::Shader> ewol::resource::Shader::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\"");
ewol::resource::Shader* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::Shader*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::Shader> object = nullptr;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::Shader>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// need to crate a new one ...
object = new ewol::resource::Shader(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::Shader(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::Shader::release(ewol::resource::Shader*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -31,6 +31,7 @@ namespace ewol {
* @param[in] filename Standard file name format. see @ref etk::FSNode
*/
Shader(const std::string& _filename);
public:
/**
* @brief Destructor, remove the current Shader
*/
@ -72,14 +73,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::Shader* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::Shader*& _object);
static ewol::object::Shared<ewol::resource::Shader> keep(const std::string& _filename);
};
};
};

View File

@ -107,22 +107,14 @@ void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
m_data.resize(_newSize);
}
ewol::resource::Texture* ewol::resource::Texture::keep() {
ewol::object::Shared<ewol::resource::Texture> ewol::resource::Texture::keep() {
// this element create a new one every time ....
ewol::resource::Texture* object = new ewol::resource::Texture();
if (NULL == object) {
ewol::object::Shared<ewol::resource::Texture> object = ewol::object::makeShared(new ewol::resource::Texture());
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : ??TEX??");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::Texture::release(ewol::resource::Texture*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -47,7 +47,8 @@ namespace ewol {
protected:
Texture(const std::string& _filename);
Texture();
~Texture();
public:
virtual ~Texture();
public:
// you must set the size here, because it will be set in multiple of pow(2)
void setImageSize(ivec2 newSize);
@ -61,14 +62,9 @@ namespace ewol {
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @return pointer on the resource or NULL if an error occured.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::Texture* keep();
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::Texture*& _object);
static ewol::object::Shared<ewol::resource::Texture> keep();
};
};
};

View File

@ -47,10 +47,10 @@ ewol::resource::TexturedFont::TexturedFont(const std::string& _fontName) :
addObjectType("ewol::resource::TexturedFont");
EWOL_DEBUG("Load font : '" << _fontName << "'" );
m_font[0] = NULL;
m_font[1] = NULL;
m_font[2] = NULL;
m_font[3] = NULL;
m_font[0] = nullptr;
m_font[1] = nullptr;
m_font[2] = nullptr;
m_font[3] = nullptr;
m_modeWraping[0] = ewol::font::Regular;
m_modeWraping[1] = ewol::font::Regular;
@ -72,7 +72,7 @@ ewol::resource::TexturedFont::TexturedFont(const std::string& _fontName) :
const char * tmpData = _fontName.c_str();
const char * tmpPos = strchr(tmpData, ':');
if (tmpPos == NULL) {
if (tmpPos == nullptr) {
m_size = 1;
EWOL_CRITICAL("Can not parse the font name : \"" << _fontName << "\" ??? ':' " );
return;
@ -188,19 +188,19 @@ ewol::resource::TexturedFont::TexturedFont(const std::string& _fontName) :
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
if (m_fileName[iiiFontId].size() == 0) {
EWOL_DEBUG("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size );
m_font[iiiFontId] = NULL;
m_font[iiiFontId] = nullptr;
continue;
}
EWOL_INFO("Load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size);
m_font[iiiFontId] = ewol::resource::FontFreeType::keep(m_fileName[iiiFontId]);
if (m_font[iiiFontId] == NULL) {
if (m_font[iiiFontId] == nullptr) {
EWOL_DEBUG("error in loading FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size );
}
}
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
// set the bassic charset:
m_listElement[iiiFontId].clear();
if (m_font[iiiFontId] == NULL) {
if (m_font[iiiFontId] == nullptr) {
continue;
}
m_height[iiiFontId] = m_font[iiiFontId]->getHeight(m_size);
@ -225,16 +225,14 @@ ewol::resource::TexturedFont::TexturedFont(const std::string& _fontName) :
}
ewol::resource::TexturedFont::~TexturedFont() {
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
ewol::resource::FontFreeType::release(m_font[iiiFontId]);
}
}
bool ewol::resource::TexturedFont::addGlyph(const char32_t& _val) {
bool hasChange = false;
// for each font :
for (int32_t iii=0; iii<4 ; iii++) {
if (m_font[iii] == NULL) {
if (m_font[iii] == nullptr) {
continue;
}
// add the curent "char"
@ -333,7 +331,7 @@ ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_
if (m_listElement[_displayMode].size() > 0) {
return &((m_listElement[_displayMode])[0]);
}
return NULL;
return nullptr;
}
//EWOL_ERROR(" index=" << index);
//EWOL_ERROR(" m_UVal=" << m_listElement[_displayMode][index].m_UVal);
@ -343,42 +341,27 @@ ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_
return &((m_listElement[_displayMode])[index]);
}
ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::string& _filename) {
ewol::object::Shared<ewol::resource::TexturedFont> ewol::resource::TexturedFont::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'");
ewol::resource::TexturedFont* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::TexturedFont*>(object2);
if (NULL == object) {
ewol::object::Shared<ewol::resource::TexturedFont> object;
ewol::object::Shared<ewol::Resource> object2 = getManager().localKeep(_filename);
if (nullptr != object2) {
object = ewol::dynamic_pointer_cast<ewol::resource::TexturedFont>(object2);
if (nullptr == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
return nullptr;
}
}
if (NULL != object) {
if (nullptr != object) {
return object;
}
// need to crate a new one ...
EWOL_INFO("CREATE: TexturedFont : file : '" << _filename << "'");
object = new ewol::resource::TexturedFont(_filename);
if (NULL == object) {
object = ewol::object::makeShared(new ewol::resource::TexturedFont(_filename));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::TexturedFont::release(ewol::resource::TexturedFont*& _object) {
if (NULL == _object) {
return;
}
EWOL_VERBOSE("RELEASE: TexturedFont : file : '" << _object->getName() << "' count=" << _object->getCounter());
std::string name = _object->getName();
int32_t count = _object->getCounter() - 1;
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
if (getManager().release(object2) == true) {
EWOL_ERROR("REMOVE: TexturedFont : file : '" << name << "' count=" << count);
//etk::displayBacktrace(false);
}
_object = NULL;
}

View File

@ -36,7 +36,7 @@ namespace ewol {
// 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::resource::FontBase* m_font[4];
ewol::object::Shared<ewol::resource::FontBase> m_font[4];
enum ewol::font::mode m_modeWraping[4]; //!< This is a wrapping mode to prevent the fact that no font is define for a specific mode
public:
std::vector<GlyphProperty> m_listElement[4];
@ -46,7 +46,8 @@ namespace ewol {
int32_t m_lastRawHeigh[4];
protected:
TexturedFont(const std::string& _fontName);
~TexturedFont();
public:
virtual ~TexturedFont();
public:
/**
* @brief get the display height of this font
@ -74,7 +75,7 @@ namespace ewol {
* @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
* @return The pointer on the glyph == > never nullptr
*/
ewol::GlyphProperty* getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode);
/**
@ -91,14 +92,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::TexturedFont* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::TexturedFont*& _object);
static ewol::object::Shared<ewol::resource::TexturedFont> keep(const std::string& _filename);
private:
/**
* @brief add a glyph in a texture font.

View File

@ -123,22 +123,13 @@ int32_t ewol::resource::VirtualBufferObject::sizeOnBufferVec2(int32_t _id) {
return m_buffer[_id].size()/2;
}
ewol::resource::VirtualBufferObject* ewol::resource::VirtualBufferObject::keep(int32_t _number) {
ewol::object::Shared<ewol::resource::VirtualBufferObject> ewol::resource::VirtualBufferObject::keep(int32_t _number) {
// this element create a new one every time ....
ewol::resource::VirtualBufferObject* object = new ewol::resource::VirtualBufferObject(_number);
if (NULL == object) {
ewol::object::Shared<ewol::resource::VirtualBufferObject> object = ewol::object::makeShared(new ewol::resource::VirtualBufferObject(_number));
if (nullptr == object) {
EWOL_ERROR("allocation error of a resource : ??VBO??");
return NULL;
return nullptr;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::VirtualBufferObject::release(ewol::resource::VirtualBufferObject*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -35,6 +35,7 @@ namespace ewol {
* @param[in] accesMode Acces mode : ???
*/
VirtualBufferObject(int32_t _number);
public:
/**
* @brief Destructor of this VBO.
*/
@ -97,14 +98,9 @@ namespace ewol {
* @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.
* @return pointer on the resource or nullptr if an error occured.
*/
static ewol::resource::VirtualBufferObject* keep(int32_t _number);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::VirtualBufferObject*& _object);
static ewol::object::Shared<ewol::resource::VirtualBufferObject> keep(int32_t _number);
};
};
};

View File

@ -212,7 +212,7 @@ void ewol::translate::autoDetectLanguage() {
EWOL_INFO("Auto-detect language of system");
#if defined(__TARGET_OS__Linux)
char *s = getenv("LANG");
if (s == NULL || strlen(s) < 2) {
if (s == nullptr || strlen(s) < 2) {
EWOL_INFO("Try to determine system language FAIL ...");
} else {
std::string lang;

View File

@ -34,12 +34,12 @@ const char* const ewol::widget::Button::configShaper = "shaper";
#define STATUS_DOWN (3)
static ewol::Widget* Create() {
static ewol::Widget* create() {
return new ewol::widget::Button();
}
void ewol::widget::Button::init(ewol::widget::Manager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__, &Create);
_widgetManager.addWidgetCreator(__class__, &create);
}
ewol::widget::Button::Button(const std::string& _shaperName) :
@ -60,10 +60,10 @@ ewol::widget::Button::Button(const std::string& _shaperName) :
addEventId(eventLeave);
addEventId(eventValue);
// add configuration
registerConfig(configToggle, "bool", NULL, "The Button can toogle");
registerConfig(configValue, "bool", NULL, "Basic value of the widget");
registerConfig(configToggle, "bool", nullptr, "The Button can toogle");
registerConfig(configValue, "bool", nullptr, "Basic value of the widget");
registerConfig(configLock, "list", "none;true;released;pressed", "Lock the button in a special state to permit changing state only by the coder");
registerConfig(configShaper, "string", NULL, "the display name for config file");
registerConfig(configShaper, "string", nullptr, "the display name for config file");
// shaper satatus update:
CheckStatus();

View File

@ -30,18 +30,18 @@ const char * const ewol::widget::ButtonColor::eventChange = "change";
static const char* const eventColorHasChange = "ewol-widget-ButtonColor-colorChange";
static ewol::Widget* Create() {
static ewol::Widget* create() {
return new ewol::widget::ButtonColor();
}
void ewol::widget::ButtonColor::init(ewol::widget::Manager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create);
_widgetManager.addWidgetCreator(__class__, &create);
}
ewol::widget::ButtonColor::ButtonColor(etk::Color<> _baseColor, std::string _shaperName) :
m_shaper(_shaperName),
m_textColorFg(_baseColor),
m_widgetContextMenu(NULL) {
m_widgetContextMenu(nullptr) {
addObjectType("ewol::widget::ButtonColor");
addEventId(eventChange);
changeStatusIn(STATUS_UP);
@ -177,7 +177,7 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
m_mouseHover = false;
// create a context menu :
m_widgetContextMenu = new ewol::widget::ContextMenu();
if (NULL == m_widgetContextMenu) {
if (nullptr == m_widgetContextMenu) {
EWOL_ERROR("Allocation Error");
return true;
}
@ -190,13 +190,12 @@ bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) {
// set it in the pop-up-system :
m_widgetContextMenu->setSubWidget(myColorChooser);
myColorChooser->registerOnEvent(this, "change", eventColorHasChange);
ewol::widget::Windows* currentWindows = getWindows();
if (NULL == currentWindows) {
ewol::object::Shared<ewol::widget::Windows> currentWindows = getWindows();
if (currentWindows == nullptr) {
EWOL_ERROR("Can not get the curent Windows...");
delete(m_widgetContextMenu);
m_widgetContextMenu=NULL;
m_widgetContextMenu.reset();
} else {
currentWindows->popUpWidgetPush(m_widgetContextMenu);
currentWindows->popUpWidgetPush(m_widgetContextMenu.get());
}
markToRedraw();
}

View File

@ -30,7 +30,7 @@ namespace ewol {
ewol::compositing::Shaper m_shaper; //!< Compositing theme.
ewol::compositing::Text m_text; //!< Compositing Test display.
etk::Color<> m_textColorFg; //!< Current color.
ewol::widget::ContextMenu* m_widgetContextMenu; //!< Specific context menu.
ewol::object::Shared<ewol::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 :

View File

@ -27,12 +27,12 @@ const char* const ewol::widget::CheckBox::configShaper = "shaper";
#undef __class__
#define __class__ "CheckBox"
static ewol::Widget* Create() {
static ewol::Widget* create() {
return new ewol::widget::CheckBox();
}
void ewol::widget::CheckBox::init(ewol::widget::Manager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create);
_widgetManager.addWidgetCreator(__class__, &create);
}
ewol::widget::CheckBox::CheckBox(const std::string& _shaperName) :
@ -52,8 +52,8 @@ ewol::widget::CheckBox::CheckBox(const std::string& _shaperName) :
addEventId(eventEnter);
addEventId(eventValue);
// add configuration
registerConfig(configValue, "bool", NULL, "Basic value of the widget");
registerConfig(configShaper, "string", NULL, "the display name for config file");
registerConfig(configValue, "bool", nullptr, "Basic value of the widget");
registerConfig(configShaper, "string", nullptr, "the display name for config file");
m_shaperIdSize = m_shaper.requestConfig("box-size");
m_shaperIdSizeInsize = m_shaper.requestConfig("box-inside");

View File

@ -18,7 +18,7 @@
namespace ewol {
namespace widget {
class ColorBar :public ewol::Widget {
class ColorBar : public ewol::Widget {
public:
// Event list of properties
static const char * const eventChange;

View File

@ -45,10 +45,10 @@ bool ewol::widget::Composer::loadFromFile(const std::string& _fileName) {
return false;
}
exml::Element* root = (exml::Element*)doc.getNamed("composer");
if (NULL == root ) {
if (nullptr == root ) {
// Maybe a multiple node XML for internal config:
root = doc.toElement();
if (NULL == root ) {
if (nullptr == root ) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
}
@ -70,10 +70,10 @@ bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlStrin
return false;
}
exml::Element* root = (exml::Element*)doc.getNamed("composer");
if (NULL == root ) {
if (nullptr == root ) {
// Maybe a multiple node XML for internal config:
root = doc.toElement();
if (NULL == root ) {
if (nullptr == root ) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ...");
return false;
}
@ -96,13 +96,13 @@ void ewol::widget::Composer::registerOnEventNameWidget(const std::string& _subWi
registerOnEventNameWidget(this, _subWidgetName, _eventId, _eventIdgenerated, _overloadData);
}
void ewol::widget::Composer::registerOnEventNameWidget(ewol::Object * _destinationObject,
void ewol::widget::Composer::registerOnEventNameWidget(const ewol::object::Shared<ewol::Object>& _destinationObject,
const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated,
const std::string& _overloadData) {
ewol::Widget* tmpWidget = getWidgetNamed(_subWidgetName);
if (NULL != tmpWidget) {
ewol::object::Shared<ewol::Widget> tmpWidget = getWidgetNamed(_subWidgetName);
if (nullptr != tmpWidget) {
EWOL_DEBUG("Find widget named : \"" << _subWidgetName << "\" register event=\"" << _eventId << "\"");
tmpWidget->registerOnEvent(_destinationObject, _eventId, _eventIdgenerated, _overloadData);
} else {

View File

@ -40,7 +40,7 @@ namespace ewol {
/**
* @brief Destructor
*/
~Composer();
virtual ~Composer();
/**
* @brief load a composition with a file
* @param[in] _fileName Name of the file
@ -66,7 +66,7 @@ namespace ewol {
*/
void registerOnEventNameWidget(const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const char * _eventIdgenerated = nullptr,
const std::string& _overloadData="");
public:
/**
@ -78,10 +78,10 @@ namespace ewol {
* @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::Object * _destinationObject,
void registerOnEventNameWidget(const ewol::object::Shared<ewol::Object>& _destinationObject,
const std::string& _subWidgetName,
const char * _eventId,
const char * _eventIdgenerated = NULL,
const char * _eventIdgenerated = nullptr,
const std::string& _overloadData="");
};
};

View File

@ -16,7 +16,7 @@
#define __class__ "Container"
ewol::widget::Container::Container(ewol::Widget* _subElement) :
ewol::widget::Container::Container(ewol::object::Shared<ewol::Widget> _subElement) :
m_subWidget(_subElement) {
addObjectType("ewol::widget::Container");
// nothing to do ...
@ -26,17 +26,17 @@ ewol::widget::Container::~Container() {
subWidgetRemove();
}
ewol::Widget* ewol::widget::Container::getSubWidget() {
ewol::object::Shared<ewol::Widget> ewol::widget::Container::getSubWidget() {
return m_subWidget;
}
void ewol::widget::Container::setSubWidget(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
void ewol::widget::Container::setSubWidget(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
return;
}
subWidgetRemove();
m_subWidget = _newWidget;
if (m_subWidget!=NULL) {
if (m_subWidget!=nullptr) {
m_subWidget->setUpperWidget(this);
}
markToRedraw();
@ -44,36 +44,37 @@ void ewol::widget::Container::setSubWidget(ewol::Widget* _newWidget) {
}
void ewol::widget::Container::subWidgetRemove() {
if (NULL != m_subWidget) {
if (nullptr != m_subWidget) {
m_subWidget->removeUpperWidget();
m_subWidget->removeObject();
m_subWidget=NULL;
m_subWidget.reset();
markToRedraw();
requestUpdateSize();
}
}
void ewol::widget::Container::subWidgetUnLink() {
if (NULL != m_subWidget) {
if (nullptr != m_subWidget) {
m_subWidget->removeUpperWidget();
}
m_subWidget=NULL;
m_subWidget.reset();
}
ewol::Widget* ewol::widget::Container::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) {
ewol::object::Shared<ewol::Widget> ewol::widget::Container::getWidgetNamed(const std::string& _widgetName) {
ewol::object::Shared<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (nullptr!=tmpUpperWidget) {
return tmpUpperWidget;
}
if (NULL != m_subWidget) {
if (nullptr != m_subWidget) {
return m_subWidget->getWidgetNamed(_widgetName);
}
return NULL;
return nullptr;
}
void ewol::widget::Container::onObjectRemove(ewol::Object* _removeObject) {
if (m_subWidget == _removeObject) {
m_subWidget=NULL;
void ewol::widget::Container::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
ewol::Widget::onObjectRemove(_object);
if (m_subWidget == _object) {
m_subWidget.reset();
markToRedraw();
requestUpdateSize();
}
@ -85,7 +86,7 @@ void ewol::widget::Container::systemDraw(const ewol::DrawProperty& _displayProp)
return;
}
ewol::Widget::systemDraw(_displayProp);
if (NULL!=m_subWidget) {
if (nullptr!=m_subWidget) {
ewol::DrawProperty prop = _displayProp;
prop.limit(m_origin, m_size);
m_subWidget->systemDraw(prop);
@ -93,7 +94,7 @@ void ewol::widget::Container::systemDraw(const ewol::DrawProperty& _displayProp)
}
void ewol::widget::Container::calculateSize(const vec2& _availlable) {
if (NULL!=m_subWidget) {
if (nullptr!=m_subWidget) {
vec2 origin = m_origin+m_offset;
vec2 minSize = m_subWidget->getCalculateMinSize();
bvec2 expand = m_subWidget->getExpand();
@ -123,7 +124,7 @@ void ewol::widget::Container::calculateMinMaxSize() {
// call main class
ewol::Widget::calculateMinMaxSize();
// call sub classes
if (NULL!=m_subWidget) {
if (nullptr!=m_subWidget) {
m_subWidget->calculateMinMaxSize();
vec2 min = m_subWidget->getCalculateMinSize();
m_minSize.setMax(min);
@ -132,23 +133,23 @@ void ewol::widget::Container::calculateMinMaxSize() {
}
void ewol::widget::Container::onRegenerateDisplay() {
if (NULL!=m_subWidget) {
if (nullptr!=m_subWidget) {
m_subWidget->onRegenerateDisplay();
}
}
ewol::Widget* ewol::widget::Container::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> ewol::widget::Container::getWidgetAtPos(const vec2& _pos) {
if (false == isHide()) {
if (NULL!=m_subWidget) {
if (nullptr!=m_subWidget) {
return m_subWidget->getWidgetAtPos(_pos);
}
}
return NULL;
return nullptr;
};
bool ewol::widget::Container::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
// parse generic properties :
@ -159,7 +160,7 @@ bool ewol::widget::Container::loadXML(exml::Element* _node) {
// parse all the elements :
for(size_t iii=0; iii< _node->size(); iii++) {
exml::Element* pNode = _node->getElement(iii);
if (pNode == NULL) {
if (pNode == nullptr) {
// trash here all that is not element
continue;
}
@ -168,13 +169,13 @@ bool ewol::widget::Container::loadXML(exml::Element* _node) {
EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" );
continue;
}
if (NULL != getSubWidget()) {
if (nullptr != getSubWidget()) {
EWOL_ERROR("(l "<<pNode->getPos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
continue;
}
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == NULL) {
ewol::object::Shared<ewol::Widget> tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == nullptr) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}

View File

@ -21,27 +21,27 @@ namespace ewol {
*/
class Container : public ewol::Widget {
protected:
ewol::Widget* m_subWidget;
ewol::object::Owner<ewol::Widget> m_subWidget;
public:
/**
* @brief Constructor
*/
Container(ewol::Widget* _subElement=NULL);
Container(ewol::object::Shared<ewol::Widget> _subElement=nullptr);
/**
* @brief Destructor
*/
~Container();
virtual ~Container();
public:
/**
* @brief get the main node widget
* @return the requested pointer on the node
*/
ewol::Widget* getSubWidget();
ewol::object::Shared<ewol::Widget> getSubWidget();
/**
* @brief set the subWidget node widget.
* @param[in] _newWidget The widget to add.
*/
void setSubWidget(ewol::Widget* _newWidget);
void setSubWidget(ewol::object::Shared<ewol::Widget> _newWidget);
/**
* @brief remove the subWidget node (async).
*/
@ -54,11 +54,11 @@ namespace ewol {
public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay();
virtual void onObjectRemove(ewol::Object* _removeObject);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize();
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual ewol::object::Shared<ewol::Widget> getWidgetAtPos(const vec2& _pos);
virtual ewol::object::Shared<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};

View File

@ -16,7 +16,7 @@
#define __class__ "Container2"
ewol::widget::Container2::Container2(ewol::Widget* _subElement, ewol::Widget* _subElementToggle) :
ewol::widget::Container2::Container2(ewol::object::Shared<ewol::Widget> _subElement, ewol::object::Shared<ewol::Widget> _subElementToggle) :
m_idWidgetDisplayed(0) {
m_subWidget[0] = _subElement;
m_subWidget[1] = _subElementToggle;
@ -29,10 +29,10 @@ ewol::widget::Container2::~Container2() {
subWidgetRemoveToggle();
}
void ewol::widget::Container2::setSubWidget(ewol::Widget* _newWidget, int32_t _idWidget) {
void ewol::widget::Container2::setSubWidget(ewol::object::Shared<ewol::Widget> _newWidget, int32_t _idWidget) {
subWidgetRemove(_idWidget);
m_subWidget[_idWidget] = _newWidget;
if (m_subWidget[_idWidget] != NULL) {
if (m_subWidget[_idWidget] != nullptr) {
EWOL_VERBOSE("Add widget : " << _idWidget);
m_subWidget[_idWidget]->setUpperWidget(this);
}
@ -42,46 +42,46 @@ void ewol::widget::Container2::setSubWidget(ewol::Widget* _newWidget, int32_t _i
void ewol::widget::Container2::subWidgetRemove(int32_t _idWidget) {
if (m_subWidget[_idWidget] != NULL) {
if (m_subWidget[_idWidget] != nullptr) {
EWOL_VERBOSE("Remove widget : " << _idWidget);
m_subWidget[_idWidget]->removeUpperWidget();
m_subWidget[_idWidget]->removeObject();
m_subWidget[_idWidget] = NULL;
m_subWidget[_idWidget].reset();
markToRedraw();
requestUpdateSize();
}
}
void ewol::widget::Container2::subWidgetUnLink(int32_t _idWidget) {
if (m_subWidget[_idWidget] != NULL) {
if (m_subWidget[_idWidget] != nullptr) {
m_subWidget[_idWidget]->removeUpperWidget();
EWOL_VERBOSE("Unlink widget : " << _idWidget);
}
m_subWidget[_idWidget] = NULL;
m_subWidget[_idWidget].resetShared();
}
ewol::Widget* ewol::widget::Container2::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (tmpUpperWidget != NULL) {
ewol::object::Shared<ewol::Widget> ewol::widget::Container2::getWidgetNamed(const std::string& _widgetName) {
ewol::object::Shared<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (tmpUpperWidget != nullptr) {
return tmpUpperWidget;
}
if (m_subWidget[0] != NULL) {
if (m_subWidget[0] != nullptr) {
return m_subWidget[0]->getWidgetNamed(_widgetName);
}
if (m_subWidget[1] != NULL) {
if (m_subWidget[1] != nullptr) {
return m_subWidget[1]->getWidgetNamed(_widgetName);
}
return NULL;
return nullptr;
}
void ewol::widget::Container2::onObjectRemove(ewol::Object* _removeObject) {
if (m_subWidget[0] == _removeObject) {
m_subWidget[0] = NULL;
void ewol::widget::Container2::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
ewol::Widget::onObjectRemove(_object);
if (m_subWidget[0] == _object) {
m_subWidget[0].reset();
markToRedraw();
requestUpdateSize();
}
if (m_subWidget[1] == _removeObject) {
m_subWidget[1] = NULL;
if (m_subWidget[1] == _object) {
m_subWidget[1].reset();
markToRedraw();
requestUpdateSize();
}
@ -93,7 +93,7 @@ void ewol::widget::Container2::systemDraw(const ewol::DrawProperty& _displayProp
return;
}
ewol::Widget::systemDraw(_displayProp);
if (m_subWidget[m_idWidgetDisplayed] != NULL) {
if (m_subWidget[m_idWidgetDisplayed] != nullptr) {
m_subWidget[m_idWidgetDisplayed]->systemDraw(_displayProp);
}
}
@ -119,7 +119,7 @@ ewol::Padding ewol::widget::Container2::calculateSizePadded(const vec2& _availla
vec2 origin = (m_size - subElementSize)*0.5f + vec2(_padding.xLeft(), _padding.yButtom());
subElementSize -= vec2(_padding.x(), _padding.y());
for (size_t iii = 0; iii < 2; ++iii) {
if (m_subWidget[iii] != NULL) {
if (m_subWidget[iii] != nullptr) {
vec2 origin2 = origin+m_offset;
vec2 minSize = m_subWidget[iii]->getCalculateMinSize();
bvec2 expand = m_subWidget[iii]->getExpand();
@ -154,7 +154,7 @@ void ewol::widget::Container2::calculateMinMaxSizePadded(const ewol::Padding& _p
m_minSize = vec2(0,0);
// call sub classes
for (size_t iii = 0; iii < 2; ++iii) {
if (m_subWidget[iii] != NULL) {
if (m_subWidget[iii] != nullptr) {
m_subWidget[iii]->calculateMinMaxSize();
vec2 min = m_subWidget[iii]->getCalculateMinSize();
m_minSize.setMax(min);
@ -168,23 +168,23 @@ void ewol::widget::Container2::calculateMinMaxSizePadded(const ewol::Padding& _p
}
void ewol::widget::Container2::onRegenerateDisplay() {
if (m_subWidget[m_idWidgetDisplayed] != NULL) {
if (m_subWidget[m_idWidgetDisplayed] != nullptr) {
m_subWidget[m_idWidgetDisplayed]->onRegenerateDisplay();
}
}
/*
ewol::Widget* ewol::widget::Container2::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> ewol::widget::Container2::getWidgetAtPos(const vec2& _pos) {
if (isHide() == false) {
if (m_subWidget[m_idWidgetDisplayed] != NULL) {
if (m_subWidget[m_idWidgetDisplayed] != nullptr) {
return m_subWidget[m_idWidgetDisplayed]->getWidgetAtPos(_pos);
}
}
return NULL;
return nullptr;
}
*/
bool ewol::widget::Container2::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
// parse generic properties :
@ -195,7 +195,7 @@ bool ewol::widget::Container2::loadXML(exml::Element* _node) {
// parse all the elements :
for(size_t iii=0; iii< _node->size(); iii++) {
exml::Element* pNode = _node->getElement(iii);
if (pNode == NULL) {
if (pNode == nullptr) {
// trash here all that is not element
continue;
}
@ -205,16 +205,16 @@ bool ewol::widget::Container2::loadXML(exml::Element* _node) {
continue;
}
bool toogleMode=false;
if (NULL != getSubWidget()) {
if (nullptr != getSubWidget()) {
toogleMode=true;
if (NULL != getSubWidgetToggle()) {
if (nullptr != getSubWidgetToggle()) {
EWOL_ERROR("(l "<<pNode->getPos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" );
continue;
}
}
EWOL_DEBUG("try to create subwidget : '" << widgetName << "'");
ewol::Widget* tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == NULL) {
ewol::object::Shared<ewol::Widget> tmpWidget = getWidgetManager().create(widgetName);
if (tmpWidget == nullptr) {
EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}

View File

@ -22,7 +22,7 @@ namespace ewol {
*/
class Container2 : public ewol::Widget {
protected:
ewol::Widget* m_subWidget[2]; //!< 2 subwidget possible
ewol::object::Owner<ewol::Widget> m_subWidget[2]; //!< 2 subwidget possible
int32_t m_idWidgetDisplayed; //!< current widget displayed
public:
/**
@ -30,31 +30,31 @@ namespace ewol {
* @param[in] _subElement Widget to set on the normal position
* @param[in] _subElementToggle Widget to set on the toggle position
*/
Container2(ewol::Widget* _subElement = NULL, ewol::Widget* _subElementToggle = NULL);
Container2(ewol::object::Shared<ewol::Widget> _subElement = nullptr, ewol::object::Shared<ewol::Widget> _subElementToggle = nullptr);
/**
* @brief Destructor
*/
~Container2();
virtual ~Container2();
private:
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add normal
* @param[in] _idWidget Id of the widget to set
*/
void setSubWidget(ewol::Widget* _subWidget, int32_t _idWidget);
void setSubWidget(ewol::object::Shared<ewol::Widget> _subWidget, int32_t _idWidget);
public:
/**
* @brief Specify the current widget
* @param[in] _subWidget Widget to add normal
*/
void setSubWidget(ewol::Widget* _subWidget) {
void setSubWidget(ewol::object::Shared<ewol::Widget> _subWidget) {
setSubWidget(_subWidget, 0);
}
/**
* @brief Specify the current toggle widget
* @param[in] _subWidget Widget to add Toggle
*/
void setSubWidgetToggle(ewol::Widget* _subWidget) {
void setSubWidgetToggle(ewol::object::Shared<ewol::Widget> _subWidget) {
setSubWidget(_subWidget, 1);
}
private:
@ -63,7 +63,7 @@ namespace ewol {
* @param[in] _idWidget Id of the widget to set
* @return The base widget
*/
ewol::Widget* getSubWidget(int32_t _idWidget) const {
ewol::object::Shared<ewol::Widget> getSubWidget(int32_t _idWidget) const {
return m_subWidget[_idWidget];
};
public:
@ -71,14 +71,14 @@ namespace ewol {
* @brief get the current displayed composition
* @return The base widget
*/
ewol::Widget* getSubWidget() const {
ewol::object::Shared<ewol::Widget> getSubWidget() const {
return getSubWidget(0);
};
/**
* @brief get the current displayed composition
* @return The toggle widget
*/
ewol::Widget* getSubWidgetToggle() const {
ewol::object::Shared<ewol::Widget> getSubWidgetToggle() const {
return getSubWidget(1);
};
private:
@ -144,7 +144,7 @@ namespace ewol {
* @return the id of the widget displayable
*/
int32_t convertId(int32_t _id) {
if (m_subWidget[_id] == NULL) {
if (m_subWidget[_id] == nullptr) {
return (_id+1)%2;
}
return _id;
@ -152,15 +152,15 @@ namespace ewol {
public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay();
virtual void onObjectRemove(ewol::Object* _removeObject);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
virtual void calculateSize(const vec2& _availlable) {
calculateSizePadded(_availlable);
}
virtual void calculateMinMaxSize() {
calculateMinMaxSizePadded();
}
//virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
//virtual ewol::object::Shared<ewol::Widget> getWidgetAtPos(const vec2& _pos);
virtual ewol::object::Shared<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};

View File

@ -52,12 +52,12 @@ void ewol::widget::ContainerN::lockExpand(const bvec2& _lockExpand) {
}
int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add An empty Widget ... ");
return -1;
}
if (_newWidget!=NULL) {
if (_newWidget!=nullptr) {
_newWidget->setUpperWidget(this);
}
m_subWidget.push_back(_newWidget);
@ -67,12 +67,12 @@ int32_t ewol::widget::ContainerN::subWidgetAdd(ewol::Widget* _newWidget) {
return _newWidget->getId();
}
int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} Try to add start An empty Widget ... ");
return -1;
}
if (_newWidget!=NULL) {
if (_newWidget!=nullptr) {
_newWidget->setUpperWidget(this);
}
m_subWidget.insert(m_subWidget.begin(), _newWidget);
@ -81,21 +81,15 @@ int32_t ewol::widget::ContainerN::subWidgetAddStart(ewol::Widget* _newWidget) {
return _newWidget->getId();
}
void ewol::widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
void ewol::widget::ContainerN::subWidgetRemove(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
return;
}
size_t errorControl = m_subWidget.size();
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (_newWidget == m_subWidget[iii]) {
m_subWidget[iii]->removeUpperWidget();
m_subWidget[iii]->removeObject();
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] {" << getObjectType() << "} The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[iii] = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
}
for (auto it(m_subWidget.begin()) ; it != m_subWidget.end() ; ++it) {
if (_newWidget == *it) {
(*it)->removeUpperWidget();
m_subWidget.erase(it);
markToRedraw();
requestUpdateSize();
return;
@ -103,15 +97,15 @@ void ewol::widget::ContainerN::subWidgetRemove(ewol::Widget* _newWidget) {
}
}
void ewol::widget::ContainerN::subWidgetUnLink(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
void ewol::widget::ContainerN::subWidgetUnLink(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
return;
}
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (_newWidget == m_subWidget[iii]) {
m_subWidget[iii]->removeUpperWidget();
m_subWidget[iii] = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
for (auto it(m_subWidget.begin()) ; it != m_subWidget.end() ; ++it) {
if (_newWidget == *it) {
(*it)->removeUpperWidget();
(*it).resetShared();
m_subWidget.erase(it);
markToRedraw();
requestUpdateSize();
return;
@ -120,65 +114,45 @@ void ewol::widget::ContainerN::subWidgetUnLink(ewol::Widget* _newWidget) {
}
void ewol::widget::ContainerN::subWidgetRemoveAll() {
size_t errorControl = m_subWidget.size();
// the size automaticly decrement with the auto call of the onObjectRemove function
while (m_subWidget.size() > 0 ) {
if (NULL != m_subWidget[0]) {
m_subWidget[0]->removeUpperWidget();
m_subWidget[0]->removeObject();
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] {" << getObjectType() << "} The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[0] = NULL;
}
} else {
EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Must not have null pointer on the subWidget list ...");
m_subWidget.erase(m_subWidget.begin());
for (auto &it : m_subWidget) {
if (it != nullptr) {
it->removeUpperWidget();
}
errorControl = m_subWidget.size();
}
m_subWidget.clear();
}
void ewol::widget::ContainerN::subWidgetRemoveAllDelayed() {
// the size automaticly decrement with the auto call of the onObjectRemove function
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->removeUpperWidget();
m_subWidget[iii]->removeObject();
m_subWidget[iii] = NULL;
} else {
EWOL_WARNING("[" << getId() << "] {" << getObjectType() << "} Must not have null pointer on the subWidget list ...");
}
}
m_subWidget.clear();
subWidgetRemoveAll();
}
ewol::Widget* ewol::widget::ContainerN::getWidgetNamed(const std::string& _widgetName) {
ewol::Widget* tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (NULL!=tmpUpperWidget) {
ewol::object::Shared<ewol::Widget> ewol::widget::ContainerN::getWidgetNamed(const std::string& _widgetName) {
ewol::object::Shared<ewol::Widget> tmpUpperWidget = ewol::Widget::getWidgetNamed(_widgetName);
if (tmpUpperWidget != nullptr) {
return tmpUpperWidget;
}
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
ewol::Widget* tmpWidget = m_subWidget[iii]->getWidgetNamed(_widgetName);
if (NULL != tmpWidget) {
for (auto &it : m_subWidget) {
if (it != nullptr) {
ewol::object::Shared<ewol::Widget> tmpWidget = it->getWidgetNamed(_widgetName);
if (tmpWidget != nullptr) {
return tmpWidget;
}
}
}
return NULL;
return nullptr;
}
void ewol::widget::ContainerN::onObjectRemove(ewol::Object* _removeObject) {
void ewol::widget::ContainerN::onObjectRemove(const ewol::object::Shared<ewol::Object>& _object) {
// First step call parrent :
ewol::Widget::onObjectRemove(_removeObject);
ewol::Widget::onObjectRemove(_object);
// second step find if in all the elements ...
for (int64_t iii=m_subWidget.size()-1; iii >= 0; iii--) {
if(m_subWidget[iii] == _removeObject) {
EWOL_VERBOSE("[" << getId() << "] {" << getObjectType() << "} remove sizer sub Element [" << iii << "/" << m_subWidget.size()-1 << "] == > destroyed object");
m_subWidget[iii] = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
auto it(m_subWidget.begin());
while (it != m_subWidget.end()) {
if(*it == _object) {
m_subWidget.erase(it);
it = m_subWidget.begin();
} else {
++it;
}
}
}
@ -193,19 +167,19 @@ void ewol::widget::ContainerN::systemDraw(const ewol::DrawProperty& _displayProp
// subwidget draw
ewol::DrawProperty prop = _displayProp;
prop.limit(m_origin, m_size);
for (int64_t iii=m_subWidget.size()-1; iii >= 0; iii--) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->systemDraw(prop);
for (auto it(m_subWidget.rbegin()); it!=m_subWidget.rend(); ++it) {
if (*it != nullptr) {
(*it)->systemDraw(prop);
}
}
}
void ewol::widget::ContainerN::calculateSize(const vec2& _availlable) {
m_size = _availlable;
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->setOrigin(m_origin+m_offset);
m_subWidget[iii]->calculateSize(m_size);
for (auto &it : m_subWidget) {
if (it != nullptr) {
it->setOrigin(m_origin+m_offset);
it->calculateSize(m_size);
}
}
markToRedraw();
@ -216,17 +190,17 @@ void ewol::widget::ContainerN::calculateMinMaxSize() {
m_minSize.setValue(0,0);
m_maxSize.setValue(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE);
//EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} set min size : " << m_minSize);
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->calculateMinMaxSize();
bvec2 subExpendProp = m_subWidget[iii]->canExpand();
for (auto &it : m_subWidget) {
if (it != nullptr) {
it->calculateMinMaxSize();
bvec2 subExpendProp = it->canExpand();
if (true == subExpendProp.x()) {
m_subExpend.setX(true);
}
if (true == subExpendProp.y()) {
m_subExpend.setY(true);
}
vec2 tmpSize = m_subWidget[iii]->getCalculateMinSize();
vec2 tmpSize = it->getCalculateMinSize();
m_minSize.setValue( etk_max(tmpSize.x(), m_minSize.x()),
etk_max(tmpSize.y(), m_minSize.y()) );
}
@ -235,27 +209,27 @@ void ewol::widget::ContainerN::calculateMinMaxSize() {
}
void ewol::widget::ContainerN::onRegenerateDisplay() {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
m_subWidget[iii]->onRegenerateDisplay();
for (auto &it : m_subWidget) {
if (it != nullptr) {
it->onRegenerateDisplay();
}
}
}
ewol::Widget* ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) {
return NULL;
return nullptr;
}
// for all element in the sizer ...
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->getSize();
vec2 tmpOrigin = m_subWidget[iii]->getOrigin();
for (auto &it : m_subWidget) {
if (it != nullptr) {
vec2 tmpSize = it->getSize();
vec2 tmpOrigin = it->getOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[iii]->getWidgetAtPos(_pos);
if (NULL != tmpWidget) {
ewol::object::Shared<ewol::Widget> tmpWidget = it->getWidgetAtPos(_pos);
if (nullptr != tmpWidget) {
return tmpWidget;
}
// stop searching
@ -263,12 +237,12 @@ ewol::Widget* ewol::widget::ContainerN::getWidgetAtPos(const vec2& _pos) {
}
}
}
return NULL;
return nullptr;
};
bool ewol::widget::ContainerN::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
// parse generic properties :
@ -288,7 +262,7 @@ bool ewol::widget::ContainerN::loadXML(exml::Element* _node) {
// parse all the elements :
for (size_t iii=0; iii < _node->size(); iii++) {
exml::Element* pNode = _node->getElement(iii);
if (pNode == NULL) {
if (pNode == nullptr) {
// trash here all that is not element
continue;
}
@ -298,8 +272,8 @@ bool ewol::widget::ContainerN::loadXML(exml::Element* _node) {
continue;
}
EWOL_DEBUG("[" << getId() << "] {" << getObjectType() << "} load new element : \"" << widgetName << "\"");
ewol::Widget *subWidget = getWidgetManager().create(widgetName);
if (subWidget == NULL) {
ewol::object::Shared<ewol::Widget> subWidget = getWidgetManager().create(widgetName);
if (subWidget == nullptr) {
EWOL_ERROR ("[" << getId() << "] {" << getObjectType() << "} (l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\"");
continue;
}

View File

@ -12,6 +12,7 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ewol/widget/Widget.h>
#include <list>
namespace ewol {
namespace widget {
@ -21,7 +22,7 @@ namespace ewol {
*/
class ContainerN : public ewol::Widget {
protected:
std::vector<ewol::Widget*> m_subWidget;
std::list<ewol::object::Owner<ewol::Widget>> m_subWidget;
public:
/**
* @brief Constructor
@ -30,7 +31,7 @@ namespace ewol {
/**
* @brief Destructor
*/
~ContainerN();
virtual ~ContainerN();
protected:
bvec2 m_lockExpand; //!< Lock the expend of the sub widget to this one == > this permit to limit bigger subWidget
bvec2 m_subExpend; //!< reference of the sub element expention requested.
@ -56,13 +57,13 @@ namespace ewol {
* @param[in] _newWidget the element pointer
* @return the ID of the set element
*/
virtual int32_t subWidgetAdd(ewol::Widget* _newWidget);
virtual int32_t subWidgetAdd(ewol::object::Shared<ewol::Widget> _newWidget);
//! @previous
inline int32_t subWidgetAddBack(ewol::Widget* _newWidget) {
inline int32_t subWidgetAddBack(ewol::object::Shared<ewol::Widget> _newWidget) {
return subWidgetAdd(_newWidget);
};
//! @previous
inline int32_t subWidgetAddEnd(ewol::Widget* _newWidget) {
inline int32_t subWidgetAddEnd(ewol::object::Shared<ewol::Widget> _newWidget) {
return subWidgetAdd(_newWidget);
};
/**
@ -70,29 +71,29 @@ namespace ewol {
* @param[in] _newWidget the element pointer
* @return the ID of the set element
*/
virtual int32_t subWidgetAddStart(ewol::Widget* _newWidget);
virtual int32_t subWidgetAddStart(ewol::object::Shared<ewol::Widget> _newWidget);
//! @previous
inline int32_t subWidgetAddFront(ewol::Widget* _newWidget) {
inline int32_t subWidgetAddFront(ewol::object::Shared<ewol::Widget> _newWidget) {
return subWidgetAddStart(_newWidget);
};
/**
* @brief remove definitly a widget from the system and this layer.
* @param[in] _newWidget the element pointer.
*/
virtual void subWidgetRemove(ewol::Widget* _newWidget);
virtual void subWidgetRemove(ewol::object::Shared<ewol::Widget> _newWidget);
/**
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...)
* @param[in] _newWidget the element pointer.
*/
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::object::Shared<ewol::Widget> _newWidget);
public:// Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay();
virtual void onObjectRemove(ewol::Object* _removeObject);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _object);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize();
virtual ewol::Widget* getWidgetAtPos(const vec2& _pos);
virtual ewol::Widget* getWidgetNamed(const std::string& _widgetName);
virtual ewol::object::Shared<ewol::Widget> getWidgetAtPos(const vec2& _pos);
virtual ewol::object::Shared<ewol::Widget> getWidgetNamed(const std::string& _widgetName);
virtual bool loadXML(exml::Element* _node);
virtual void setOffset(const vec2& _newVal);
};

View File

@ -21,12 +21,12 @@ const char* const ewol::widget::ContextMenu::configArrowPosition = "arrow-positi
const char* const ewol::widget::ContextMenu::configArrowMode = "arrow-mode";
const char* const ewol::widget::ContextMenu::configShaper = "shaper";
static ewol::Widget* Create() {
static ewol::Widget* create() {
return new ewol::widget::ContextMenu();
}
void ewol::widget::ContextMenu::init(ewol::widget::Manager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&Create);
_widgetManager.addWidgetCreator(__class__, &create);
}
@ -35,9 +35,9 @@ ewol::widget::ContextMenu::ContextMenu(const std::string& _shaperName) :
m_shaper(_shaperName) {
addObjectType("ewol::widget::ContextMenu");
// add basic configurations :
registerConfig(configArrowPosition, "vec2", NULL, "position of the arrow");
registerConfig(configArrowPosition, "vec2", nullptr, "position of the arrow");
registerConfig(configArrowMode, "list", "none;left;buttom;right;top", "Position of the arrow in the pop-up");
registerConfig(configShaper, "string", NULL, "the display name for config file");
registerConfig(configShaper, "string", nullptr, "the display name for config file");
m_userExpand.setValue(false,false);
@ -69,7 +69,7 @@ void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
m_size = _availlable;
ewol::Padding padding = m_shaper.getPadding();
EWOL_VERBOSE("our origin=" << m_origin << " size=" << m_size);
if (NULL != m_subWidget) {
if (nullptr != m_subWidget) {
vec2 subWidgetSize;
vec2 subWidgetOrigin;
subWidgetSize = m_subWidget->getCalculateMinSize();
@ -158,7 +158,7 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() {
m_shaper.clear();
ewol::Padding padding = m_shaper.getPadding();
if (m_subWidget == NULL) {
if (m_subWidget == nullptr) {
return;
}
vec2 tmpSize = m_subWidget->getSize();
@ -216,7 +216,7 @@ void ewol::widget::ContextMenu::onRegenerateDisplay() {
bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) {
if (_event.getId() > 0) {
if (NULL != ewol::widget::Container::getWidgetAtPos(_event.getPos())) {
if (nullptr != ewol::widget::Container::getWidgetAtPos(_event.getPos())) {
return false;
}
if( _event.getStatus() == ewol::key::statusDown
@ -241,9 +241,9 @@ void ewol::widget::ContextMenu::setPositionMark(enum markPosition _position, vec
markToRedraw();
}
ewol::Widget* ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) {
ewol::Widget* val = ewol::widget::Container::getWidgetAtPos(_pos);
if (NULL != val) {
ewol::object::Shared<ewol::Widget> ewol::widget::ContextMenu::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> val = ewol::widget::Container::getWidgetAtPos(_pos);
if (nullptr != val) {
return val;
}
return this;

View File

@ -67,9 +67,9 @@ namespace ewol {
public: // Derived function
virtual void onRegenerateDisplay();
virtual bool onEventInput(const ewol::event::Input& _event);
virtual void calculateSize(const vec2& availlable);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize();
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual ewol::object::Shared<ewol::Widget> getWidgetAtPos(const vec2& _pos);
};
};
};

View File

@ -73,10 +73,10 @@ ewol::widget::Entry::Entry(std::string _newData) :
shortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
shortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
registerConfig(configMaxChar, "int", NULL, "Maximum cgar that can be set on the Entry");
registerConfig(configRegExp, "string", NULL, "Control what it is write with a regular expression");
registerConfig(configEmptyMessage, "string", NULL, "Text that is displayed when the Entry is empty (decorated text)");
registerConfig(configValue, "string", NULL, "Value display in the entry (decorated text)");
registerConfig(configMaxChar, "int", nullptr, "Maximum cgar that can be set on the Entry");
registerConfig(configRegExp, "string", nullptr, "Control what it is write with a regular expression");
registerConfig(configEmptyMessage, "string", nullptr, "Text that is displayed when the Entry is empty (decorated text)");
registerConfig(configValue, "string", nullptr, "Value display in the entry (decorated text)");
setValue(_newData);
markToRedraw();

View File

@ -26,7 +26,7 @@ void ewol::widget::Gird::init(ewol::widget::Manager& _widgetManager) {
ewol::widget::Gird::Gird(int32_t _colNumber) :
m_sizeRow(0),
m_tmpWidget(NULL),
m_tmpWidget(nullptr),
m_gavityButtom(true),
m_borderSize(0,0) {
addObjectType("ewol::widget::Gird");
@ -59,7 +59,7 @@ void ewol::widget::Gird::calculateSize(const vec2& _availlable) {
m_size -= m_borderSize*2;
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
if (nullptr != m_subWidget[iii].widget) {
//calculate the origin :
vec2 tmpOrigin = m_origin + m_borderSize;
if (false == m_gavityButtom) {
@ -108,7 +108,7 @@ void ewol::widget::Gird::calculateMinMaxSize() {
// change of line :
lastLineID = m_subWidget[iii].row;
}
if (NULL != m_subWidget[iii].widget) {
if (nullptr != m_subWidget[iii].widget) {
m_subWidget[iii].widget->calculateMinMaxSize();
vec2 tmpSize = m_subWidget[iii].widget->getCalculateMinSize();
EWOL_DEBUG(" [" << iii << "] subWidgetMinSize=" << tmpSize);
@ -144,12 +144,11 @@ void ewol::widget::Gird::setColNumber(int32_t _colNumber) {
for (int64_t iii=m_subWidget.size(); iii >= 0; iii--) {
if (m_subWidget[iii].col>(_colNumber-1)) {
// out of bounds : must remove it ...
if (m_subWidget[iii].widget != NULL) {
delete (m_subWidget[iii].widget);
if (m_subWidget[iii].widget != nullptr) {
m_subWidget[iii].widget.reset();
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[iii].widget = NULL;
}
} else {
EWOL_WARNING("[" << getId() << "] Must not have null pointer on the subWidget list ...");
@ -201,12 +200,11 @@ void ewol::widget::Gird::subWidgetRemoveAll() {
size_t errorControl = m_subWidget.size();
// the size automaticly decrement with the auto call of the onObjectRemove function
while (m_subWidget.size() > 0 ) {
if (NULL != m_subWidget[0].widget) {
delete(m_subWidget[0].widget);
if (nullptr != m_subWidget[0].widget) {
m_subWidget[0].widget.reset();
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[0].widget = NULL;
}
} else {
EWOL_WARNING("[" << getId() << "] Must not have null pointer on the subWidget list ...");
@ -218,8 +216,8 @@ void ewol::widget::Gird::subWidgetRemoveAll() {
}
void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
return;
}
GirdProperties prop;
@ -246,11 +244,11 @@ void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widg
// The element already exist == > replace it ...
m_tmpWidget = m_subWidget[iii].widget;
m_subWidget[iii].widget = _newWidget;
if (NULL != m_tmpWidget) {
delete(m_tmpWidget);
if (m_tmpWidget != NULL) {
if (nullptr != m_tmpWidget) {
m_tmpWidget.reset();
if (m_tmpWidget != nullptr) {
EWOL_CRITICAL("[" << getId() << "] Error while replacing a widget ... == > never call when free");
m_tmpWidget = NULL;
m_tmpWidget = nullptr;
}
}
}
@ -260,21 +258,10 @@ void ewol::widget::Gird::subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widg
m_subWidget.push_back(prop);
}
void ewol::widget::Gird::subWidgetRemove(ewol::Widget* _newWidget)
{
if (NULL == _newWidget) {
return;
}
size_t errorControl = m_subWidget.size();
void ewol::widget::Gird::subWidgetRemove(ewol::object::Shared<ewol::Widget> _newWidget) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (_newWidget == m_subWidget[iii].widget) {
delete(m_subWidget[iii].widget);
// no remove, this element is removed with the function onObjectRemove == > it does not exist anymore ...
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[iii].widget = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
}
m_subWidget.erase(m_subWidget.begin()+iii);
return;
}
}
@ -291,33 +278,19 @@ void ewol::widget::Gird::subWidgetRemove(int32_t _colId, int32_t _rowId) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if( m_subWidget[iii].row == _rowId
&& m_subWidget[iii].col == _colId) {
if (m_subWidget[iii].widget == NULL) {
EWOL_WARNING("[" << getId() << "] remove NULL widget");
m_subWidget.erase(m_subWidget.begin()+iii);
} else {
// The element already exist == > replace it ...
if (m_subWidget[iii].widget != NULL) {
delete(m_subWidget[iii].widget);
if (errorControl == m_subWidget.size()) {
EWOL_CRITICAL("[" << getId() << "] The number of element might have been reduced ... == > it is not the case ==> the herited class must call the \"OnObjectRemove\" function...");
m_subWidget[iii].widget = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
}
}
}
m_subWidget.erase(m_subWidget.begin()+iii);
return;
}
}
EWOL_WARNING("[" << getId() << "] Can not remove unExistant widget");
}
void ewol::widget::Gird::subWidgetUnLink(ewol::Widget* _newWidget) {
if (NULL == _newWidget) {
void ewol::widget::Gird::subWidgetUnLink(ewol::object::Shared<ewol::Widget> _newWidget) {
if (nullptr == _newWidget) {
return;
}
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (_newWidget == m_subWidget[iii].widget) {
m_subWidget[iii].widget = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
return;
}
@ -333,7 +306,6 @@ void ewol::widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if( m_subWidget[iii].row == _rowId
&& m_subWidget[iii].col == _colId) {
m_subWidget[iii].widget = NULL;
m_subWidget.erase(m_subWidget.begin()+iii);
return;
}
@ -344,7 +316,7 @@ void ewol::widget::Gird::subWidgetUnLink(int32_t _colId, int32_t _rowId) {
void ewol::widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) {
ewol::Widget::systemDraw(_displayProp);
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
if (nullptr != m_subWidget[iii].widget) {
m_subWidget[iii].widget->systemDraw(_displayProp);
}
}
@ -352,26 +324,26 @@ void ewol::widget::Gird::systemDraw(const ewol::DrawProperty& _displayProp) {
void ewol::widget::Gird::onRegenerateDisplay() {
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
if (nullptr != m_subWidget[iii].widget) {
m_subWidget[iii].widget->onRegenerateDisplay();
}
}
}
ewol::Widget * ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) {
return NULL;
return nullptr;
}
// for all element in the sizer ...
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii].widget) {
if (nullptr != m_subWidget[iii].widget) {
vec2 tmpSize = m_subWidget[iii].widget->getSize();
vec2 tmpOrigin = m_subWidget[iii].widget->getOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[iii].widget->getWidgetAtPos(_pos);
if (NULL != tmpWidget) {
ewol::object::Shared<ewol::Widget> tmpWidget = m_subWidget[iii].widget->getWidgetAtPos(_pos);
if (nullptr != tmpWidget) {
return tmpWidget;
}
// stop searching
@ -379,21 +351,21 @@ ewol::Widget * ewol::widget::Gird::getWidgetAtPos(const vec2& _pos) {
}
}
}
return NULL;
return nullptr;
}
void ewol::widget::Gird::onObjectRemove(ewol::Object * _removeObject) {
void ewol::widget::Gird::onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject) {
// First step call parrent :
ewol::Widget::onObjectRemove(_removeObject);
// second step find if in all the elements ...
for(int32_t iii=m_subWidget.size()-1; iii >= 0; iii--) {
if(m_subWidget[iii].widget == _removeObject) {
EWOL_VERBOSE("[" << getId() << "]={" << getObjectType() << "} remove sizer sub Element [" << iii << "/" << m_subWidget.size()-1 << "] == > destroyed object");
m_subWidget[iii].widget = NULL;
m_subWidget[iii].widget = nullptr;
m_subWidget.erase(m_subWidget.begin()+iii);
}
}
if (m_tmpWidget == _removeObject) {
m_tmpWidget = NULL;
m_tmpWidget.reset();
}
}

View File

@ -26,7 +26,7 @@ namespace ewol {
private:
class GirdProperties {
public:
ewol::Widget* widget;
ewol::object::Shared<ewol::Widget> widget;
int32_t row;
int32_t col;
};
@ -34,7 +34,7 @@ namespace ewol {
int32_t m_uniformSizeRow;
std::vector<int32_t> m_sizeCol; //!< size of all colomn (if set (otherwise 0))
std::vector<GirdProperties> m_subWidget; //!< all sub widget are contained in this element
ewol::Widget* m_tmpWidget; //!< use when replace a widget ...
ewol::object::Shared<ewol::Widget> m_tmpWidget; //!< use when replace a widget ...
bool m_gavityButtom;
public:
/**
@ -97,12 +97,12 @@ namespace ewol {
* @param[in] _rowId Id of the row [0..y].
* @param[in] _newWidget the element pointer
*/
virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::Widget* _newWidget);
virtual void subWidgetAdd(int32_t _colId, int32_t _rowId, ewol::object::Shared<ewol::Widget> _newWidget);
/**
* @brief remove definitly a widget from the system and this Gird.
* @param[in] _newWidget the element pointer.
*/
virtual void subWidgetRemove(ewol::Widget* _newWidget);
virtual void subWidgetRemove(ewol::object::Shared<ewol::Widget> _newWidget);
/**
* @brief remove definitly a widget from the system and this Gird.
* @param[in] _colId Id of the colomn [0..x].
@ -113,7 +113,7 @@ namespace ewol {
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
* @param[in] _newWidget the element pointer.
*/
virtual void subWidgetUnLink(ewol::Widget* _newWidget);
virtual void subWidgetUnLink(ewol::object::Shared<ewol::Widget> _newWidget);
/**
* @brief Just unlick the specify widget, this function does not remove it from the system (if you can, do nt use it ...).
* @param[in] _colId Id of the colomn [0..x].
@ -132,12 +132,14 @@ namespace ewol {
* @brief get the current border size of the current element:
* @return the border size (0 if not used)
*/
const ivec2& getBorderSize() { return m_borderSize; };
const ivec2& getBorderSize() {
return m_borderSize;
};
public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay();
virtual ewol::Widget* getWidgetAtPos(const vec2& pos);
virtual void onObjectRemove(ewol::Object* _removeObject);
virtual ewol::object::Shared<ewol::Widget> getWidgetAtPos(const vec2& pos);
virtual void onObjectRemove(const ewol::object::Shared<ewol::Object>& _removeObject);
virtual void calculateSize(const vec2& _availlable);
virtual void calculateMinMaxSize();
};

View File

@ -36,7 +36,7 @@ const char * const ewol::widget::Image::configPartStart = "part-start";
const char * const ewol::widget::Image::configPartStop = "part-stop";
ewol::widget::Image::Image(const std::string& _file, const ewol::Dimension& _border) :
m_colorProperty(NULL),
m_colorProperty(nullptr),
m_colorId(-1),
m_imageSize(vec2(0.0f,0.0f)),
m_keepRatio(true),
@ -44,22 +44,22 @@ ewol::widget::Image::Image(const std::string& _file, const ewol::Dimension& _bor
m_posStop(1.0f,1.0f) {
addObjectType("ewol::widget::Image");
addEventId(eventPressed);
registerConfig(configRatio, "bool", NULL, "Keep ratio of the image");
registerConfig(configSize, "Dimension", NULL, "Basic display size of the image");
registerConfig(configBorder, "Dimension", NULL, "Border of the image");
registerConfig(configRatio, "bool", nullptr, "Keep ratio of the image");
registerConfig(configSize, "Dimension", nullptr, "Basic display size of the image");
registerConfig(configBorder, "Dimension", nullptr, "Border of the image");
registerConfig(configSource, "string", "Image source path");
registerConfig(configDistanceField, "bool", "Distance field mode");
registerConfig(configPartStart, "vec2", NULL, "Start display position in the image [0.0 .. 1.0]");
registerConfig(configPartStop, "vec2", NULL, "Stop display position in the image [0.0 .. 1.0]");
registerConfig(configPartStart, "vec2", nullptr, "Start display position in the image [0.0 .. 1.0]");
registerConfig(configPartStop, "vec2", nullptr, "Stop display position in the image [0.0 .. 1.0]");
m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:Image.json");
if (m_colorProperty != NULL) {
if (m_colorProperty != nullptr) {
m_colorId = m_colorProperty->request("foreground");
}
set(_file, _border);
}
ewol::widget::Image::~Image() {
ewol::resource::ColorFile::release(m_colorProperty);
}
void ewol::widget::Image::setFile(const std::string& _file) {
@ -147,7 +147,7 @@ void ewol::widget::Image::onRegenerateDisplay() {
if (true == needRedraw()) {
// remove data of the previous composition :
m_compositing.clear();
if (m_colorProperty != NULL) {
if (m_colorProperty != nullptr) {
m_compositing.setColor(m_colorProperty->get(m_colorId));
}
// calculate the new position and size :
@ -230,7 +230,7 @@ bool ewol::widget::Image::onEventInput(const ewol::event::Input& _event) {
}
bool ewol::widget::Image::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
ewol::Widget::loadXML(_node);

View File

@ -41,7 +41,7 @@ namespace ewol {
static void init(ewol::widget::Manager& _widgetManager);
protected:
ewol::compositing::Image m_compositing; //!< compositing element of the image.
ewol::resource::ColorFile* m_colorProperty; //!< theme color property
ewol::object::Shared<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
int32_t m_colorId; //!< Color of the image.
public:
/**

View File

@ -16,10 +16,10 @@ const char * const ewol::widget::Joystick::eventEnable = "enable";
const char * const ewol::widget::Joystick::eventDisable = "disable";
const char * const ewol::widget::Joystick::eventMove = "move";
static bool l_displayBackground(true);
static bool l_displayBackground(true);
static std::string l_background("");
static std::string l_foreground("");
static float l_ratio(1.0/7.0);
static float l_ratio(1.0/7.0);
#undef __class__
#define __class__ "Joystick"
@ -67,9 +67,9 @@ void ewol::widget::Joystick::onRegenerateDisplay() {
// clean the object list ...
/*
ewol::OObject2DColored * tmpOObjects = NULL;
ewol::OObject2DTextured * tmpOOtexBg = NULL;
ewol::OObject2DTextured * tmpOOtexFg = NULL;
ewol::OObject2DColored * tmpOObjects = nullptr;
ewol::OObject2DTextured * tmpOOtexBg = nullptr;
ewol::OObject2DTextured * tmpOOtexFg = nullptr;
// set background
if (true == m_displayBackground) {
if (m_background == "") {
@ -84,7 +84,7 @@ void ewol::widget::Joystick::onRegenerateDisplay() {
// set cursor point
float sizeElement = m_size.x*m_ratio;
if (m_foreground == "") {
if (NULL == tmpOObjects) {
if (nullptr == tmpOObjects) {
tmpOObjects = new ewol::OObject2DColored;
}
tmpOObjects->setColor(m_colorFg);
@ -96,13 +96,13 @@ void ewol::widget::Joystick::onRegenerateDisplay() {
((m_displayPos.y+1.0)/2.0)*(m_size.y-2*sizeElement), sizeElement*2, sizeElement*2);
}
// add all needed objects ...
if (NULL != tmpOObjects) {
if (nullptr != tmpOObjects) {
addOObject(tmpOObjects);
}
if (NULL != tmpOOtexBg) {
if (nullptr != tmpOOtexBg) {
addOObject(tmpOOtexBg);
}
if (NULL != tmpOOtexFg) {
if (nullptr != tmpOOtexFg) {
addOObject(tmpOOtexFg);
}
*/

View File

@ -27,12 +27,12 @@ void ewol::widget::Label::init(ewol::widget::Manager& _widgetManager) {
}
// TODO : Remove the label name in the constructor ...
ewol::widget::Label::Label(std::string _newLabel) :
m_colorProperty(NULL),
m_colorProperty(nullptr),
m_colorDefaultFgText(-1),
m_colorDefaultBgText(-1){
addObjectType("ewol::widget::Label");
m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:Label.json");
if (m_colorProperty != NULL) {
if (m_colorProperty != nullptr) {
m_colorDefaultFgText = m_colorProperty->request("foreground");
m_colorDefaultBgText = m_colorProperty->request("background");
}
@ -40,11 +40,11 @@ ewol::widget::Label::Label(std::string _newLabel) :
addEventId(eventPressed);
setCanHaveFocus(false);
setMouseLimit(1);
registerConfig(configValue, "string", NULL, "displayed value string"); // TODO : do not store in attibute...
registerConfig(configValue, "string", nullptr, "displayed value string"); // TODO : do not store in attibute...
}
ewol::widget::Label::~Label() {
ewol::resource::ColorFile::release(m_colorProperty);
}
void ewol::widget::Label::calculateMinMaxSize() {
@ -124,7 +124,7 @@ void ewol::widget::Label::onRegenerateDisplay() {
// clean the element
m_text.reset();
if (m_colorProperty != NULL) {
if (m_colorProperty != nullptr) {
m_text.setDefaultColorFg(m_colorProperty->get(m_colorDefaultFgText));
m_text.setDefaultColorBg(m_colorProperty->get(m_colorDefaultBgText));
}
@ -148,7 +148,7 @@ bool ewol::widget::Label::onEventInput(const ewol::event::Input& _event) {
}
bool ewol::widget::Label::loadXML(exml::Element* _node) {
if (NULL == _node) {
if (nullptr == _node) {
return false;
}
ewol::Widget::loadXML(_node);

View File

@ -34,7 +34,7 @@ namespace ewol {
private:
ewol::compositing::Text m_text; //!< Compositing text element.
std::u32string m_label; //!< decorated text to display.
ewol::resource::ColorFile* m_colorProperty; //!< theme color property
ewol::object::Shared<ewol::resource::ColorFile> m_colorProperty; //!< theme color property
int32_t m_colorDefaultFgText; //!< Default color of the text
int32_t m_colorDefaultBgText; //!< Default Background color of the text
public:

View File

@ -29,26 +29,27 @@ ewol::widget::Layer::~Layer() {
EWOL_DEBUG("[" << getId() << "] Layer : destroy");
}
ewol::Widget* ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) {
ewol::object::Shared<ewol::Widget> ewol::widget::Layer::getWidgetAtPos(const vec2& _pos) {
if (true == isHide()) {
return NULL;
return nullptr;
}
// for all element in the sizer ...
for (size_t iii=0; iii<m_subWidget.size(); iii++) {
if (NULL != m_subWidget[iii]) {
vec2 tmpSize = m_subWidget[iii]->getSize();
vec2 tmpOrigin = m_subWidget[iii]->getOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::Widget * tmpWidget = m_subWidget[iii]->getWidgetAtPos(_pos);
if (NULL != tmpWidget) {
return tmpWidget;
}
// parse the next layer ...
for (auto &it : m_subWidget) {
if (it == nullptr) {
continue;
}
vec2 tmpSize = it->getSize();
vec2 tmpOrigin = it->getOrigin();
if( (tmpOrigin.x() <= _pos.x() && tmpOrigin.x() + tmpSize.x() >= _pos.x())
&& (tmpOrigin.y() <= _pos.y() && tmpOrigin.y() + tmpSize.y() >= _pos.y()) )
{
ewol::object::Shared<ewol::Widget> tmpWidget = it->getWidgetAtPos(_pos);
if (nullptr != tmpWidget) {
return tmpWidget;
}
// parse the next layer ...
}
}
return NULL;
return nullptr;
};

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