From 160a7dec3061e3a4a1dad25a9fc646d21500fd56 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Tue, 23 Oct 2018 22:17:53 +0200 Subject: [PATCH] [DEV] update of new etk Uri API --- ewol/compositing/Image.cpp | 10 ++++---- ewol/compositing/Image.hpp | 14 ++++++------ ewol/context/Context.cpp | 2 +- ewol/context/Context.hpp | 2 +- ewol/resource/ImageDF.cpp | 28 +++++++++++------------ ewol/resource/ImageDF.hpp | 2 +- ewol/resource/TextureFile.cpp | 22 ++++++++---------- ewol/resource/TextureFile.hpp | 2 +- ewol/widget/Image.cpp | 6 ++--- ewol/widget/Image.hpp | 6 ++--- sample/treeView/appl/widget/BasicTree.cpp | 1 - sample/treeView/appl/widget/BasicTree.hpp | 1 - test/main.cpp | 1 - tools/platform_test/appl/MainWindows.cpp | 2 -- tools/platform_test/appl/init.cpp | 3 ++- tools/platform_test/data/gui.xml | 1 + 16 files changed, 48 insertions(+), 55 deletions(-) diff --git a/ewol/compositing/Image.cpp b/ewol/compositing/Image.cpp index b42cd8a8..76e8f67c 100644 --- a/ewol/compositing/Image.cpp +++ b/ewol/compositing/Image.cpp @@ -17,7 +17,7 @@ const int32_t ewol::compositing::Image::m_vboIdCoordTex(1); const int32_t ewol::compositing::Image::m_vboIdColor(2); #define NB_VBO (3) -ewol::compositing::Image::Image(const etk::String& _imageName, +ewol::compositing::Image::Image(const etk::Uri& _imageName, bool _df, int32_t _size) : m_filename(_imageName), @@ -271,9 +271,9 @@ void ewol::compositing::Image::printPart(const vec2& _size, m_VBO->flush(); } -void ewol::compositing::Image::setSource(const etk::String& _newFile, const vec2& _size) { +void ewol::compositing::Image::setSource(const etk::Uri& _uri, const vec2& _size) { clear(); - if ( m_filename == _newFile + if ( m_filename == _uri && m_requestSize == _size) { // Nothing to do ... return; @@ -281,14 +281,14 @@ void ewol::compositing::Image::setSource(const etk::String& _newFile, const vec2 ememory::SharedPtr resource = m_resource; ememory::SharedPtr resourceDF = m_resourceDF; ememory::SharedPtr resourceTex = m_resourceImage; - m_filename = _newFile; + m_filename = _uri; m_requestSize = _size; m_resource.reset(); m_resourceDF.reset(); m_resourceImage.reset(); ivec2 tmpSize(_size.x(),_size.y()); // note that no image can be loaded... - if (_newFile != "") { + if (_uri.isEmpty() == false) { // link to new one if (m_distanceFieldMode == false) { m_resource = ewol::resource::TextureFile::create(m_filename, tmpSize); diff --git a/ewol/compositing/Image.hpp b/ewol/compositing/Image.hpp index 4334181e..9725a154 100644 --- a/ewol/compositing/Image.hpp +++ b/ewol/compositing/Image.hpp @@ -17,7 +17,7 @@ namespace ewol { public: static const int32_t sizeAuto; private: - etk::String m_filename; + etk::Uri m_filename; ivec2 m_requestSize; vec3 m_position; //!< The current position to draw vec3 m_clippingPosStart; //!< Clipping start position @@ -50,11 +50,11 @@ namespace ewol { public: /** * @brief generic constructor - * @param[in] _imageName Name of the file that might be loaded + * @param[in] _uri URI of the file that might be loaded * @param[in] _df enable distance field mode * @param[in] _size for the image when Verctorial image loading is requested */ - Image(const etk::String& _imageName="", + Image(const etk::Uri& _uri="", bool _df=false, int32_t _size=ewol::compositing::Image::sizeAuto); /** @@ -156,13 +156,13 @@ namespace ewol { vec2 _sourcePosStop); /** * @brief change the image Source == > can not be done to display 2 images at the same time ... - * @param[in] _newFile New file of the Image + * @param[in] _uri New file of the Image * @param[in] _size for the image when Verctorial image loading is requested */ - void setSource(const etk::String& _newFile, int32_t _size=32) { - setSource(_newFile, vec2(_size,_size)); + void setSource(const etk::Uri& _uri, int32_t _size=32) { + setSource(_uri, vec2(_size,_size)); }; - void setSource(const etk::String& _newFile, const vec2& _size); + void setSource(const etk::Uri& _uri, const vec2& _size); void setSource(egami::Image _image); /** * @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it .. diff --git a/ewol/context/Context.cpp b/ewol/context/Context.cpp index aa9e350c..c25c10a4 100644 --- a/ewol/context/Context.cpp +++ b/ewol/context/Context.cpp @@ -44,7 +44,7 @@ ewol::Context& ewol::getContext() { } -void ewol::Context::setInitImage(const etk::String& _fileName) { +void ewol::Context::setInitImage(const etk::Uri& _fileName) { //m_initDisplayImageName = _fileName; } diff --git a/ewol/context/Context.hpp b/ewol/context/Context.hpp index 70e96875..8adf8ea1 100644 --- a/ewol/context/Context.hpp +++ b/ewol/context/Context.hpp @@ -142,7 +142,7 @@ namespace ewol { * @brief Special for init (main) set the start image when loading data * @param[in] _fileName Name of the image to load */ - void setInitImage(const etk::String& _fileName); + void setInitImage(const etk::Uri& _fileName); public: /** * @brief Request a display after call a resize diff --git a/ewol/resource/ImageDF.cpp b/ewol/resource/ImageDF.cpp index 2c980432..86e75b69 100644 --- a/ewol/resource/ImageDF.cpp +++ b/ewol/resource/ImageDF.cpp @@ -160,9 +160,9 @@ static int32_t nextP2(int32_t _value) { -ememory::SharedPtr ewol::resource::ImageDF::create(const etk::String& _filename, ivec2 _size) { - EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size); - if (_filename == "") { +ememory::SharedPtr ewol::resource::ImageDF::create(const etk::Uri& _uri, ivec2 _size) { + EWOL_VERBOSE("KEEP: TextureFile: '" << _uri << "' size=" << _size); + if (_uri.isEmpty() == true) { ememory::SharedPtr object(ETK_NEW(ewol::resource::ImageDF)); if (object == null) { EWOL_ERROR("allocation error of a resource : ??TEX??"); @@ -180,8 +180,8 @@ ememory::SharedPtr ewol::resource::ImageDF::create(cons _size.setY(-1); //EWOL_ERROR("Error Request the image size.y() =0 ???"); } - etk::String TmpFilename = _filename; - if (etk::end_with(_filename, ".svg") == false) { + etk::Uri tmpFilename = _uri; + if (etk::toLower(_uri.getPath().getExtention()) != "svg") { _size = ivec2(-1,-1); } #ifdef __TARGET_OS__MacOs @@ -194,33 +194,31 @@ ememory::SharedPtr ewol::resource::ImageDF::create(cons #ifdef __TARGET_OS__Android _size.setValue(nextP2(_size.x()), nextP2(_size.y())); #endif - TmpFilename += ":"; - TmpFilename += etk::toString(_size.x()); - TmpFilename += "x"; - TmpFilename += etk::toString(_size.y()); + tmpFilename.getQuery().set("x", etk::toString(_size.x())); + tmpFilename.getQuery().set("y", etk::toString(_size.y())); } - EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); + EWOL_VERBOSE("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); ememory::SharedPtr object = null; - ememory::SharedPtr object2 = getManager().localKeep("DF__" + TmpFilename); + ememory::SharedPtr object2 = getManager().localKeep("DF__" + tmpFilename.getString()); if (object2 != null) { object = ememory::dynamicPointerCast(object2); if (object == null) { - EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)"); + EWOL_CRITICAL("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); return null; } } if (object != null) { return object; } - EWOL_INFO("CREATE: ImageDF: '" << TmpFilename << "' size=" << _size); + EWOL_INFO("CREATE: ImageDF: '" << tmpFilename << "' size=" << _size); // need to crate a new one ... object = ememory::SharedPtr(ETK_NEW(ewol::resource::ImageDF)); if (object == null) { - EWOL_ERROR("allocation error of a resource : " << _filename); + EWOL_ERROR("allocation error of a resource : " << _uri); return null; } - object->init("DF__" + TmpFilename, _filename, _size); + object->init("DF__" + tmpFilename.getString(), _uri, _size); getManager().localAdd(object); return object; } diff --git a/ewol/resource/ImageDF.hpp b/ewol/resource/ImageDF.hpp index 513cce06..4c4b9fcd 100644 --- a/ewol/resource/ImageDF.hpp +++ b/ewol/resource/ImageDF.hpp @@ -40,7 +40,7 @@ namespace ewol { * @param[in] _requested size of the image (usefull when loading .svg to automatic rescale) * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr create(const etk::String& _filename, ivec2 _size=ivec2(-1,-1)); + static ememory::SharedPtr create(const etk::Uri& _uri, ivec2 _size=ivec2(-1,-1)); }; }; }; diff --git a/ewol/resource/TextureFile.cpp b/ewol/resource/TextureFile.cpp index f6cf42de..c6a36af8 100644 --- a/ewol/resource/TextureFile.cpp +++ b/ewol/resource/TextureFile.cpp @@ -58,9 +58,9 @@ void ewol::resource::TextureFile::init(etk::String _genName, const etk::Uri& _ur #endif } -ememory::SharedPtr ewol::resource::TextureFile::create(const etk::String& _filename, ivec2 _size, ivec2 _sizeRegister) { - EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size << " sizeRegister=" << _sizeRegister); - if (_filename == "") { +ememory::SharedPtr ewol::resource::TextureFile::create(const etk::Uri& _uri, ivec2 _size, ivec2 _sizeRegister) { + EWOL_VERBOSE("KEEP: TextureFile: '" << _uri << "' size=" << _size << " sizeRegister=" << _sizeRegister); + if (_uri.isEmpty() == true) { ememory::SharedPtr object(ETK_NEW(ewol::resource::TextureFile)); if (object == null) { EWOL_ERROR("allocation error of a resource : ??TEX??"); @@ -78,8 +78,8 @@ ememory::SharedPtr ewol::resource::TextureFile::cre _size.setY(-1); //EWOL_ERROR("Error Request the image size.y() =0 ???"); } - etk::String tmpFilename = _filename; - if (etk::end_with(_filename, ".svg") == false) { + etk::Uri tmpFilename = _uri; + if (etk::toLower(_uri.getPath().getExtention()) != "svg") { _size = ewol::resource::TextureFile::sizeAuto; } if (_size.x()>0 && _size.y()>0) { @@ -87,17 +87,15 @@ ememory::SharedPtr ewol::resource::TextureFile::cre _size.setValue(nextP2(_size.x()), nextP2(_size.y())); if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { - tmpFilename += ":"; - tmpFilename += etk::toString(_size.x()); - tmpFilename += "x"; - tmpFilename += etk::toString(_size.y()); + tmpFilename.getQuery().set("x", etk::toString(_size.x())); + tmpFilename.getQuery().set("y", etk::toString(_size.y())); } } } EWOL_VERBOSE("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); ememory::SharedPtr object = null; - ememory::SharedPtr object2 = getManager().localKeep(tmpFilename); + ememory::SharedPtr object2 = getManager().localKeep(tmpFilename.getString()); if (object2 != null) { object = ememory::dynamicPointerCast(object2); if (object == null) { @@ -112,10 +110,10 @@ ememory::SharedPtr ewol::resource::TextureFile::cre // need to crate a new one ... object = ememory::SharedPtr(ETK_NEW(ewol::resource::TextureFile)); if (object == null) { - EWOL_ERROR("allocation error of a resource : " << _filename); + EWOL_ERROR("allocation error of a resource : " << _uri); return null; } - object->init(tmpFilename, _filename, _size); + object->init(tmpFilename.getString(), _uri, _size); getManager().localAdd(object); return object; } diff --git a/ewol/resource/TextureFile.hpp b/ewol/resource/TextureFile.hpp index f912a8a1..8dc61a05 100644 --- a/ewol/resource/TextureFile.hpp +++ b/ewol/resource/TextureFile.hpp @@ -38,7 +38,7 @@ namespace ewol { * @param[in] _sizeRegister size register in named (When you preaload the images the size write here will be ) * @return pointer on the resource or null if an error occured. */ - static ememory::SharedPtr create(const etk::String& _filename, + static ememory::SharedPtr create(const etk::Uri& _filename, ivec2 _size=ewol::resource::TextureFile::sizeAuto, ivec2 _sizeRegister=ewol::resource::TextureFile::sizeAuto); }; diff --git a/ewol/widget/Image.cpp b/ewol/widget/Image.cpp index 71c4552e..00f4e3b9 100644 --- a/ewol/widget/Image.cpp +++ b/ewol/widget/Image.cpp @@ -44,10 +44,10 @@ void ewol::widget::Image::init() { } } -void ewol::widget::Image::set(const etk::String& _file, const gale::Dimension& _border) { - EWOL_VERBOSE("Set Image : " << _file << " border=" << _border); +void ewol::widget::Image::set(const etk::Uri& _uri, const gale::Dimension& _border) { + EWOL_VERBOSE("Set Image : " << _uri << " border=" << _border); propertyBorder.set(_border); - propertySource.set(_file); + propertySource.set(_uri); } void ewol::widget::Image::setCustumSource(const egami::Image& _image) { diff --git a/ewol/widget/Image.hpp b/ewol/widget/Image.hpp index 5687237b..e0920c9d 100644 --- a/ewol/widget/Image.hpp +++ b/ewol/widget/Image.hpp @@ -25,7 +25,7 @@ namespace ewol { public: // signals esignal::Signal<> signalPressed; public: // properties - eproperty::Value propertySource; //!< file name of the image. + eproperty::Value propertySource; //!< file name of the image. eproperty::Value propertyBorder; //!< border to add at the image. eproperty::Value propertyImageSize; //!< border to add at the image. eproperty::Value propertyKeepRatio; //!< keep the image ratio between width and hight @@ -52,10 +52,10 @@ namespace ewol { virtual ~Image(); /** * @brief set All the configuration of the current image - * @param[in] _file Filaneme of the new image + * @param[in] _uri URI of the new image * @param[in] _border New border size to set */ - void set(const etk::String& _file, const gale::Dimension& _border); + void set(const etk::Uri& _uri, const gale::Dimension& _border); /** * @brief Set an image with direct elements * @param[in] _image Image to set in the display diff --git a/sample/treeView/appl/widget/BasicTree.cpp b/sample/treeView/appl/widget/BasicTree.cpp index ea16c071..5b738c0b 100644 --- a/sample/treeView/appl/widget/BasicTree.cpp +++ b/sample/treeView/appl/widget/BasicTree.cpp @@ -6,7 +6,6 @@ #include "BasicTree.hpp" #include -#include #include #include diff --git a/sample/treeView/appl/widget/BasicTree.hpp b/sample/treeView/appl/widget/BasicTree.hpp index 93cff718..eca97f2f 100644 --- a/sample/treeView/appl/widget/BasicTree.hpp +++ b/sample/treeView/appl/widget/BasicTree.hpp @@ -6,7 +6,6 @@ #pragma once #include -#include #include #include #include diff --git a/test/main.cpp b/test/main.cpp index dc11cd7a..837fdd1f 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include diff --git a/tools/platform_test/appl/MainWindows.cpp b/tools/platform_test/appl/MainWindows.cpp index 2f91b3cf..0914e14e 100644 --- a/tools/platform_test/appl/MainWindows.cpp +++ b/tools/platform_test/appl/MainWindows.cpp @@ -24,8 +24,6 @@ #include #include #include -#include -#include #include appl::MainWindows::MainWindows() { diff --git a/tools/platform_test/appl/init.cpp b/tools/platform_test/appl/init.cpp index d2a3ae87..e77f152a 100644 --- a/tools/platform_test/appl/init.cpp +++ b/tools/platform_test/appl/init.cpp @@ -6,15 +6,16 @@ #include #include -#include #include #include #include #include +#include #include #include #include + namespace appl { class MainApplication : public ewol::context::Application { public: diff --git a/tools/platform_test/data/gui.xml b/tools/platform_test/data/gui.xml index d0df67ba..b94cc9c9 100644 --- a/tools/platform_test/data/gui.xml +++ b/tools/platform_test/data/gui.xml @@ -64,5 +64,6 @@ +