[DEV] integrate the new interface of URI and file
This commit is contained in:
parent
63ac2d7e07
commit
532b64a1f0
@ -4,7 +4,7 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/compositing/Shaper.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
@ -15,8 +15,8 @@ const int32_t ewol::compositing::Shaper::m_vboIdCoord(0);
|
||||
const int32_t ewol::compositing::Shaper::m_vboIdPos(1);
|
||||
#define NB_VBO (2)
|
||||
|
||||
ewol::compositing::Shaper::Shaper(const etk::String& _shaperName) :
|
||||
m_name(_shaperName),
|
||||
ewol::compositing::Shaper::Shaper(const etk::Uri& _uri) :
|
||||
m_uri(_uri),
|
||||
m_config(null),
|
||||
m_confIdMode(-1),
|
||||
m_confIdDisplayOutside(-1),
|
||||
@ -83,11 +83,11 @@ void ewol::compositing::Shaper::unLoadProgram() {
|
||||
}
|
||||
|
||||
void ewol::compositing::Shaper::loadProgram() {
|
||||
if (m_name == "") {
|
||||
if (m_uri.isEmpty() == true) {
|
||||
EWOL_DEBUG("no Shaper set for loading resources ...");
|
||||
return;
|
||||
}
|
||||
m_config = ewol::resource::ConfigFile::create(m_name);
|
||||
m_config = ewol::resource::ConfigFile::create(m_uri.get());
|
||||
if (m_config != null) {
|
||||
m_confIdMode = m_config->request("mode");
|
||||
m_confIdDisplayOutside = m_config->request("display-outside");
|
||||
@ -113,8 +113,9 @@ void ewol::compositing::Shaper::loadProgram() {
|
||||
etk::String tmpFilename(basicShaderFile);
|
||||
if (tmpFilename.find(':') == etk::String::npos) {
|
||||
// get the relative position of the current file ...
|
||||
etk::FSNode file(m_name);
|
||||
tmpFilename = file.getRelativeFolder() + basicShaderFile;
|
||||
etk::Uri tmpUri = m_uri;
|
||||
tmpUri.setPath(m_uri.getPath().getParent() / basicShaderFile);
|
||||
tmpFilename = tmpUri.get();
|
||||
EWOL_DEBUG("Shaper try load shader : '" << tmpFilename << "' with base : '" << basicShaderFile << "'");
|
||||
} else {
|
||||
EWOL_DEBUG("Shaper try load shader : '" << tmpFilename << "'");
|
||||
@ -140,8 +141,9 @@ void ewol::compositing::Shaper::loadProgram() {
|
||||
etk::String tmpFilename(basicImageFile);
|
||||
if (tmpFilename.find(':') == etk::String::npos) {
|
||||
// get the relative position of the current file ...
|
||||
etk::FSNode file(m_name);
|
||||
tmpFilename = file.getRelativeFolder() + basicImageFile;
|
||||
etk::Uri tmpUri = m_uri;
|
||||
tmpUri.setPath(m_uri.getPath().getParent() / basicImageFile);
|
||||
tmpFilename = tmpUri.get();
|
||||
EWOL_DEBUG("Shaper try load shaper image : '" << tmpFilename << "' with base : '" << basicImageFile << "'");
|
||||
} else {
|
||||
EWOL_DEBUG("Shaper try load shaper image : '" << tmpFilename << "'");
|
||||
@ -155,8 +157,9 @@ void ewol::compositing::Shaper::loadProgram() {
|
||||
etk::String tmpFilename(basicColorFile);
|
||||
if (tmpFilename.find(':') == etk::String::npos) {
|
||||
// get the relative position of the current file ...
|
||||
etk::FSNode file(m_name);
|
||||
tmpFilename = file.getRelativeFolder() + basicColorFile;
|
||||
etk::Uri tmpUri = m_uri;
|
||||
tmpUri.setPath(m_uri.getPath().getParent() / basicColorFile);
|
||||
tmpFilename = tmpUri.get();
|
||||
EWOL_DEBUG("Shaper try load colorFile : '" << tmpFilename << "' with base : '" << basicColorFile << "'");
|
||||
} else {
|
||||
EWOL_DEBUG("Shaper try load colorFile : '" << tmpFilename << "'");
|
||||
@ -626,15 +629,15 @@ ewol::Padding ewol::compositing::Shaper::getBorder() {
|
||||
return padding;
|
||||
}
|
||||
|
||||
void ewol::compositing::Shaper::setSource(const etk::String& _newFile) {
|
||||
void ewol::compositing::Shaper::setSource(const etk::Uri& _uri) {
|
||||
clear();
|
||||
unLoadProgram();
|
||||
m_name = _newFile;
|
||||
m_uri = _uri;
|
||||
loadProgram();
|
||||
}
|
||||
|
||||
bool ewol::compositing::Shaper::hasSources() {
|
||||
return m_GLprogram!=null;
|
||||
return m_GLprogram != null;
|
||||
}
|
||||
|
||||
|
||||
@ -675,7 +678,7 @@ double ewol::compositing::Shaper::getConfigNumber(int32_t _id) {
|
||||
|
||||
namespace etk {
|
||||
template<> etk::String toString<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
||||
return _obj.getSource();
|
||||
return _obj.getSource().get();
|
||||
}
|
||||
template<> etk::UString toUString<ewol::compositing::Shaper>(const ewol::compositing::Shaper& _obj) {
|
||||
return etk::toUString(etk::toString(_obj));
|
||||
|
@ -38,7 +38,7 @@ namespace ewol {
|
||||
// TODO : Abstaraction between states (call by name and the system greate IDs
|
||||
class Shaper : public ewol::Compositing {
|
||||
private:
|
||||
etk::String m_name; //!< Name of the configuration of the shaper.
|
||||
etk::Uri m_uri; //!< Name of the configuration of the shaper.
|
||||
// External theme config:
|
||||
ememory::SharedPtr<ewol::resource::ConfigFile> m_config; //!< pointer on the config file resources
|
||||
int32_t m_confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom
|
||||
@ -92,9 +92,9 @@ namespace ewol {
|
||||
public:
|
||||
/**
|
||||
* @brief generic constructor
|
||||
* @param[in] _shaperName Name of the file that might be loaded
|
||||
* @param[in] _uri URI of the file that might be loaded
|
||||
*/
|
||||
Shaper(const etk::String& _shaperName="");
|
||||
Shaper(const etk::Uri& _uri="");
|
||||
/**
|
||||
* @brief generic destructor
|
||||
*/
|
||||
@ -164,15 +164,15 @@ namespace ewol {
|
||||
ewol::Padding getBorder();
|
||||
/**
|
||||
* @brief change the shaper Source
|
||||
* @param[in] _newFile New file of the shaper
|
||||
* @param[in] _uri New file of the shaper
|
||||
*/
|
||||
void setSource(const etk::String& _newFile);
|
||||
void setSource(const etk::Uri& _uri);
|
||||
/**
|
||||
* @brief get the shaper file Source
|
||||
* @return the shapper file name
|
||||
*/
|
||||
const etk::String& getSource() const {
|
||||
return m_name;
|
||||
const etk::Uri& getSource() const {
|
||||
return m_uri;
|
||||
};
|
||||
/**
|
||||
* @brief Sometimes the user declare an image but not allocate the ressources all the time, this is to know it ..
|
||||
@ -284,10 +284,10 @@ namespace ewol {
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const Shaper& _obj) const {
|
||||
return _obj.m_name == m_name;
|
||||
return _obj.m_uri == m_uri;
|
||||
}
|
||||
bool operator!= (const Shaper& _obj) const {
|
||||
return _obj.m_name != m_name;
|
||||
return _obj.m_uri != m_uri;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <ewol/debug.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace context {
|
||||
@ -17,20 +18,20 @@ namespace ewol {
|
||||
ConfigFont();
|
||||
virtual ~ConfigFont();
|
||||
private:
|
||||
etk::String m_folder;
|
||||
etk::Uri m_folder;
|
||||
public:
|
||||
/**
|
||||
* @brief Specify the default font folder for the Ewol search system (only needed when embended font)
|
||||
* @param[in] _folder basic folder of the font (ex: DATA:fonts)
|
||||
*/
|
||||
void setFolder(const etk::String& _folder) {
|
||||
void setFolder(const etk::Uri& _folder) {
|
||||
m_folder = _folder;
|
||||
};
|
||||
/**
|
||||
* @brief get the default font folder.
|
||||
* @return The default font folder.
|
||||
*/
|
||||
const etk::String& getFolder() {
|
||||
const etk::Uri& getFolder() {
|
||||
return m_folder;
|
||||
};
|
||||
private:
|
||||
|
@ -8,9 +8,9 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/etk.hpp>
|
||||
|
||||
#include <etk/tool.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/theme/theme.hpp>
|
||||
|
||||
#include <ethread/tools.hpp>
|
||||
#include <ethread/Mutex.hpp>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <etranslate/etranslate.hpp>
|
||||
|
||||
#include <gale/context/commandLine.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <gale/Dimension.hpp>
|
||||
|
||||
#ifndef EWOL_VERSION
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/resource/ColorFile.hpp>
|
||||
#include <ejson/ejson.hpp>
|
||||
@ -19,10 +19,10 @@ ewol::resource::ColorFile::ColorFile() :
|
||||
addResourceType("ewol::ColorFile");
|
||||
}
|
||||
|
||||
void ewol::resource::ColorFile::init(const etk::String& _filename) {
|
||||
void ewol::resource::ColorFile::init(const etk::Uri& _uri) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
gale::Resource::init(_filename);
|
||||
EWOL_DEBUG("CF : load \"" << _filename << "\"");
|
||||
gale::Resource::init(_uri.get());
|
||||
EWOL_DEBUG("CF : load \"" << _uri << "\"");
|
||||
reload();
|
||||
EWOL_DEBUG("List of all color : " << m_list.getKeys());
|
||||
}
|
||||
@ -41,8 +41,8 @@ void ewol::resource::ColorFile::reload() {
|
||||
}
|
||||
// open and read all json elements:
|
||||
ejson::Document doc;
|
||||
if (doc.load(m_name) == false) {
|
||||
EWOL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
|
||||
if (doc.load(etk::Uri(m_name)) == false) {
|
||||
EWOL_ERROR("Can not load file : '" << m_name << "'");
|
||||
return;
|
||||
}
|
||||
ejson::Array baseArray = doc["color"].toArray();
|
||||
|
@ -23,10 +23,10 @@ namespace ewol {
|
||||
protected:
|
||||
/**
|
||||
* @brief Constructor of the color property file
|
||||
* @param[in] _filename Name of the file needed
|
||||
* @param[in] _uri Name of the file needed
|
||||
*/
|
||||
ColorFile();
|
||||
void init(const etk::String& _filename);
|
||||
void init(const etk::Uri& _uri);
|
||||
public:
|
||||
DECLARE_RESOURCE_NAMED_FACTORY(ColorFile);
|
||||
/**
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @license MPL v2.0 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/resource/ConfigFile.hpp>
|
||||
#include <gale/resource/Manager.hpp>
|
||||
@ -21,10 +21,10 @@ ewol::resource::ConfigFile::ConfigFile() :
|
||||
addResourceType("ewol::ConfigFile");
|
||||
}
|
||||
|
||||
void ewol::resource::ConfigFile::init(const etk::String& _filename) {
|
||||
void ewol::resource::ConfigFile::init(const etk::Uri& _uri) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
gale::Resource::init(_filename);
|
||||
EWOL_DEBUG("SFP : load \"" << _filename << "\"");
|
||||
gale::Resource::init(_uri.get());
|
||||
EWOL_DEBUG("SFP : load \"" << _uri << "\"");
|
||||
reload();
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ void ewol::resource::ConfigFile::reload() {
|
||||
m_list.getValue(iii) = ejson::empty();
|
||||
}
|
||||
}
|
||||
m_doc.load(m_name);
|
||||
m_doc.load(etk::Uri(m_name));
|
||||
|
||||
for (auto elementName : m_list.getKeys()) {
|
||||
if (m_doc[elementName].exist() == true) {
|
||||
|
@ -19,7 +19,7 @@ namespace ewol {
|
||||
etk::Map<etk::String, ejson::Value> m_list;
|
||||
protected:
|
||||
ConfigFile();
|
||||
void init(const etk::String& _filename);
|
||||
void init(const etk::Uri& _filename);
|
||||
public:
|
||||
virtual ~ConfigFile();
|
||||
DECLARE_RESOURCE_NAMED_FACTORY(ConfigFile);
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <egami/egami.hpp>
|
||||
|
||||
#include <gale/resource/Manager.hpp>
|
||||
@ -34,41 +34,59 @@ ewol::resource::DistanceFieldFont::DistanceFieldFont() :
|
||||
m_sizeRatio = 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get all the Path contain in the specidy path:
|
||||
* @param[in] _path Generic path to parse ...
|
||||
* @return The list of path found
|
||||
* @example[start]
|
||||
* auto out = explodeMultiplePath("DATA:///font?lib=ewol");
|
||||
* // out contain: {"DATA:///font", "DATA:///font?lib=ewol"}
|
||||
* @example[stop]
|
||||
*/
|
||||
static etk::Vector<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) {
|
||||
etk::Vector<etk::Uri> out;
|
||||
out.pushBack(_uri);
|
||||
if (_uri.getQuery().exist("lib") == true) {
|
||||
etk::Uri tmp = _uri;
|
||||
tmp.getQuery().erase("lib");
|
||||
out.pushBack(tmp);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::Texture::init(_fontName);
|
||||
etk::String localName = _fontName;
|
||||
etk::Vector<etk::String> folderList;
|
||||
if (true == ewol::getContext().getFontDefault().getUseExternal()) {
|
||||
etk::Vector<etk::Uri> folderList;
|
||||
if (ewol::getContext().getFontDefault().getUseExternal() == true) {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
folderList.pushBack("ROOT:system/fonts");
|
||||
folderList.pushBack(etk::Path("/system/fonts"));
|
||||
#elif defined(__TARGET_OS__Linux)
|
||||
folderList.pushBack("ROOT:usr/share/fonts/truetype");
|
||||
folderList.pushBack(etk::Path("/usr/share/fonts/truetype"));
|
||||
#endif
|
||||
}
|
||||
etk::String applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
|
||||
etk::Vector<etk::String> applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont);
|
||||
for (auto &it : applicationBaseFontList) {
|
||||
etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
|
||||
for (auto &it : explodeMultiplePath(applicationBaseFont)) {
|
||||
folderList.pushBack(it);
|
||||
}
|
||||
for (size_t folderID = 0; folderID < folderList.size() ; folderID++) {
|
||||
etk::FSNode myFolder(folderList[folderID]);
|
||||
// find the real Font name :
|
||||
etk::Vector<etk::String> output;
|
||||
myFolder.folderGetRecursiveFiles(output);
|
||||
etk::Vector<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]);
|
||||
|
||||
etk::Vector<etk::String> split = etk::split(localName, ';');
|
||||
EWOL_INFO("try to find font named : " << split << " in: " << myFolder);
|
||||
EWOL_INFO("try to find font named : " << split << " in: " << output);
|
||||
//EWOL_CRITICAL("parse string : " << split);
|
||||
bool hasFindAFont = false;
|
||||
for (size_t jjj=0; jjj<split.size(); jjj++) {
|
||||
EWOL_INFO(" try with : '" << split[jjj] << "'");
|
||||
for (size_t iii=0; iii<output.size(); iii++) {
|
||||
etk::String nameFolder = output[iii].getPath().getString();
|
||||
//EWOL_DEBUG(" file : " << output[iii]);
|
||||
if( true == etk::end_with(output[iii], split[jjj]+"-"+"regular"+".ttf", false)
|
||||
|| true == etk::end_with(output[iii], split[jjj]+"-"+"r"+".ttf", false)
|
||||
|| true == etk::end_with(output[iii], split[jjj]+"regular"+".ttf", false)
|
||||
|| true == etk::end_with(output[iii], split[jjj]+"r"+".ttf", false)
|
||||
|| true == etk::end_with(output[iii], split[jjj]+".ttf", false)) {
|
||||
if( true == etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false)
|
||||
|| true == etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false)
|
||||
|| true == etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false)
|
||||
|| true == etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false)
|
||||
|| true == etk::end_with(nameFolder, split[jjj]+".ttf", false)) {
|
||||
EWOL_INFO(" find Font [Regular] : " << output[iii]);
|
||||
m_fileName = output[iii];
|
||||
hasFindAFont=true;
|
||||
@ -90,8 +108,8 @@ void ewol::resource::DistanceFieldFont::init(const etk::String& _fontName) {
|
||||
}
|
||||
}
|
||||
|
||||
if (m_fileName.size() == 0) {
|
||||
EWOL_ERROR("can not load FONT name : '" << m_fileName << "'" );
|
||||
if (m_fileName.isEmpty() == true) {
|
||||
EWOL_ERROR("can not load FONT name : '" << _fontName << "'" );
|
||||
m_font = null;
|
||||
return;
|
||||
}
|
||||
@ -370,24 +388,30 @@ void ewol::resource::DistanceFieldFont::exportOnFile() {
|
||||
doc.add("m_lastRawHeigh", ejson::Number(m_lastRawHeigh));
|
||||
doc.add("m_borderSize", ejson::Number(m_borderSize));
|
||||
doc.add("m_textureBorderSize", ejson::String(m_textureBorderSize));
|
||||
doc.store(m_fileName + ".json");
|
||||
egami::store(m_data, m_fileName + ".bmp");
|
||||
egami::store(m_data, m_fileName + ".png");
|
||||
etk::Uri tmpUri = m_fileName;
|
||||
tmpUri.setPath(m_fileName.getPath() + ".json");
|
||||
doc.store(tmpUri);
|
||||
tmpUri.setPath(m_fileName.getPath() + ".bmp");
|
||||
egami::store(m_data, tmpUri);
|
||||
tmpUri.setPath(m_fileName.getPath() + ".png");
|
||||
egami::store(m_data, tmpUri);
|
||||
}
|
||||
|
||||
bool ewol::resource::DistanceFieldFont::importFromFile() {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'");
|
||||
etk::Uri tmpUriJson = m_fileName;
|
||||
tmpUriJson.setPath(m_fileName.getPath() + ".json");
|
||||
etk::Uri tmpUriBmp = m_fileName;
|
||||
tmpUriBmp.setPath(m_fileName.getPath() + ".bmp");
|
||||
EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << tmpUriJson << "'");
|
||||
// test file existance:
|
||||
etk::FSNode fileJSON(m_fileName + ".json");
|
||||
etk::FSNode fileBMP(m_fileName + ".bmp");
|
||||
if ( fileJSON.exist() == false
|
||||
|| fileBMP.exist() == false) {
|
||||
if ( etk::uri::exist(tmpUriJson) == false
|
||||
|| etk::uri::exist(tmpUriBmp) == false) {
|
||||
EWOL_DEBUG("Does not import file for distance field system");
|
||||
return false;
|
||||
}
|
||||
ejson::Document doc;
|
||||
doc.load(m_fileName + ".json");
|
||||
doc.load(tmpUriJson);
|
||||
|
||||
m_sizeRatio = doc["m_sizeRatio"].toNumber().get(0);
|
||||
m_lastGlyphPos = doc["m_lastGlyphPos"].toString().get("0,0");
|
||||
@ -416,6 +440,6 @@ bool ewol::resource::DistanceFieldFont::importFromFile() {
|
||||
prop.m_exist = tmpObj["m_exist"].toBoolean().get(false);
|
||||
m_listElement.pushBack(prop);
|
||||
}
|
||||
m_data = egami::load(m_fileName + ".bmp");
|
||||
m_data = egami::load(tmpUriBmp);
|
||||
return m_data.exist();
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ namespace ewol {
|
||||
namespace resource {
|
||||
class DistanceFieldFont : public ewol::resource::Texture {
|
||||
private:
|
||||
etk::String m_fileName;
|
||||
etk::Uri m_fileName;
|
||||
float m_sizeRatio;
|
||||
// specific element to have the the know if the specify element is known...
|
||||
// == > otherwise I can just generate italic ...
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/Vector.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
|
||||
|
||||
#include <gale/renderer/openGL/openGL.hpp>
|
||||
@ -56,42 +55,30 @@ ewol::resource::FontFreeType::FontFreeType() {
|
||||
m_FileSize = 0;
|
||||
}
|
||||
|
||||
void ewol::resource::FontFreeType::init(const etk::String& _fontName) {
|
||||
void ewol::resource::FontFreeType::init(const etk::Uri& _uri) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::FontBase::init(_fontName);
|
||||
etk::FSNode myfile(_fontName);
|
||||
if (myfile.exist() == false) {
|
||||
EWOL_ERROR("File Does not exist : " << myfile);
|
||||
ewol::resource::FontBase::init(_uri);
|
||||
auto fileIO = etk::uri::get(_uri);
|
||||
if (fileIO == null) {
|
||||
EWOL_ERROR("File Does not exist : " << _uri);
|
||||
return;
|
||||
}
|
||||
m_FileSize = myfile.fileSize();
|
||||
if (m_FileSize == 0) {
|
||||
EWOL_ERROR("This file is empty : " << myfile);
|
||||
if (fileIO->open(etk::io::OpenMode::Read) == false) {
|
||||
EWOL_ERROR("Can not open the file : " << _uri);
|
||||
return;
|
||||
}
|
||||
if (myfile.fileOpenRead() == false) {
|
||||
EWOL_ERROR("Can not open the file : " << myfile);
|
||||
return;
|
||||
}
|
||||
// allocate data
|
||||
m_FileBuffer.resize(m_FileSize, 0);
|
||||
if (m_FileBuffer.size() != m_FileSize) {
|
||||
EWOL_ERROR("Error Memory allocation size=" << _fontName);
|
||||
return;
|
||||
}
|
||||
// load data from the file :
|
||||
myfile.fileRead(&m_FileBuffer[0], 1, m_FileSize);
|
||||
m_FileBuffer = fileIO->readAll<FT_Byte>();
|
||||
// close the file:
|
||||
myfile.fileClose();
|
||||
fileIO->close();
|
||||
// load Face ...
|
||||
int32_t error = FT_New_Memory_Face(library, &m_FileBuffer[0], m_FileSize, 0, &m_fftFace );
|
||||
int32_t error = FT_New_Memory_Face(library, &m_FileBuffer[0], m_FileBuffer.size(), 0, &m_fftFace );
|
||||
if( FT_Err_Unknown_File_Format == error) {
|
||||
EWOL_ERROR("... the font file could be opened and read, but it appears ... that its font format is unsupported");
|
||||
} else if (0 != error) {
|
||||
EWOL_ERROR("... another error code means that the font file could not ... be opened or read, or simply that it is broken...");
|
||||
} else {
|
||||
// all OK
|
||||
EWOL_INFO("load font : \"" << _fontName << "\" glyph count = " << (int)m_fftFace->num_glyphs);
|
||||
EWOL_INFO("load font : \"" << _uri << "\" glyph count = " << (int)m_fftFace->num_glyphs);
|
||||
m_init = true;
|
||||
//display();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/resource/font/FontBase.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <egami/egami.hpp>
|
||||
|
||||
extern "C" {
|
||||
@ -26,9 +27,9 @@ namespace ewol {
|
||||
void display();
|
||||
protected:
|
||||
FontFreeType();
|
||||
void init(const etk::String& _fontName);
|
||||
void init(const etk::Uri& _uri);
|
||||
public:
|
||||
DECLARE_RESOURCE_NAMED_FACTORY(FontFreeType);
|
||||
DECLARE_RESOURCE_URI_FACTORY(FontFreeType);
|
||||
virtual ~FontFreeType();
|
||||
public:
|
||||
|
||||
|
@ -25,13 +25,13 @@ void ewol::resource::ImageDF::init() {
|
||||
ewol::resource::Texture::init();
|
||||
}
|
||||
|
||||
void ewol::resource::ImageDF::init(etk::String _genName, const etk::String& _tmpfileName, const ivec2& _size) {
|
||||
void ewol::resource::ImageDF::init(etk::String _genName, const etk::Uri& _uri, const ivec2& _size) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::Texture::init(_genName);
|
||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpfileName=" << _tmpfileName << " size=" << _size);
|
||||
m_data = egami::load(_tmpfileName, _size);
|
||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size);
|
||||
m_data = egami::load(_uri, _size);
|
||||
if (m_data.exist() == false) {
|
||||
EWOL_ERROR("ERROR when loading the image : " << _tmpfileName);
|
||||
EWOL_ERROR("ERROR when loading the image : " << _uri);
|
||||
}
|
||||
ivec2 tmp = m_data.getSize();
|
||||
m_realImageSize = vec2(tmp.x(), tmp.y());
|
||||
|
@ -18,7 +18,7 @@ namespace ewol {
|
||||
protected:
|
||||
ImageDF();
|
||||
void init();
|
||||
void init(etk::String _genName, const etk::String& _fileName, const ivec2& _size);
|
||||
void init(etk::String _genName, const etk::Uri& _uri, const ivec2& _size);
|
||||
public:
|
||||
virtual ~ImageDF() { };
|
||||
protected:
|
||||
|
@ -45,16 +45,16 @@ void ewol::resource::TextureFile::init() {
|
||||
ewol::resource::Texture::init();
|
||||
}
|
||||
|
||||
void ewol::resource::TextureFile::init(etk::String _genName, const etk::String& _tmpFilename, const ivec2& _size) {
|
||||
void ewol::resource::TextureFile::init(etk::String _genName, const etk::Uri& _uri, const ivec2& _size) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::Texture::init(_genName);
|
||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size);
|
||||
egami::Image tmp = egami::load(_tmpFilename, _size);
|
||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _uri=" << _uri << " size=" << _size);
|
||||
egami::Image tmp = egami::load(_uri, _size);
|
||||
set(etk::move(tmp));
|
||||
//m_lastSize = m_realImageSize;
|
||||
#ifdef GENERATE_DISTANCE_FIELD_MODE
|
||||
//egami::generateDistanceFieldFile(_tmpFilename, etk::String(_tmpFilename, 0, _tmpFilename.size()-4) + ".bmp");
|
||||
egami::generateDistanceFieldFile(_tmpFilename, etk::String(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf");
|
||||
//egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".bmp");
|
||||
egami::generateDistanceFieldFile(_uri, etk::String(_uri, 0, _uri.size()-4) + ".edf");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace ewol {
|
||||
protected:
|
||||
TextureFile();
|
||||
void init();
|
||||
void init(etk::String _genName, const etk::String& _fileName, const ivec2& _size);
|
||||
void init(etk::String _genName, const etk::Uri& _uri, const ivec2& _size);
|
||||
public:
|
||||
virtual ~TextureFile() { };
|
||||
public:
|
||||
|
@ -5,7 +5,6 @@
|
||||
*/
|
||||
|
||||
#include <etk/types.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <egami/egami.hpp>
|
||||
|
||||
#include <gale/resource/Manager.hpp>
|
||||
@ -44,6 +43,26 @@ ewol::resource::TexturedFont::TexturedFont():
|
||||
addResourceType("ewol::resource::TexturedFont");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get all the Path contain in the specidy path:
|
||||
* @param[in] _path Generic path to parse ...
|
||||
* @return The list of path found
|
||||
* @example[start]
|
||||
* auto out = explodeMultiplePath("DATA:///font?lib=ewol");
|
||||
* // out contain: {"DATA:///font", "DATA:///font?lib=ewol"}
|
||||
* @example[stop]
|
||||
*/
|
||||
static etk::Vector<etk::Uri> explodeMultiplePath(const etk::Uri& _uri) {
|
||||
etk::Vector<etk::Uri> out;
|
||||
out.pushBack(_uri);
|
||||
if (_uri.getQuery().exist("lib") == true) {
|
||||
etk::Uri tmp = _uri;
|
||||
tmp.getQuery().erase("lib");
|
||||
out.pushBack(tmp);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::Texture::init(_fontName);
|
||||
@ -76,84 +95,82 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||
|
||||
if (tmpPos == null) {
|
||||
m_size = 1;
|
||||
EWOL_CRITICAL("Can not parse the font name : '" << _fontName << "' ??? ':' " );
|
||||
EWOL_CRITICAL("Can not parse the font name: '" << _fontName << "' ??? ':' " );
|
||||
return;
|
||||
} else {
|
||||
if (sscanf(tmpPos+1, "%d", &tmpSize)!=1) {
|
||||
m_size = 1;
|
||||
EWOL_CRITICAL("Can not parse the font name : '" << _fontName << "' == > size ???");
|
||||
EWOL_CRITICAL("Can not parse the font name: '" << _fontName << "' == > size ???");
|
||||
return;
|
||||
}
|
||||
}
|
||||
etk::String localName(_fontName, 0, (tmpPos - tmpData));
|
||||
if (tmpSize>400) {
|
||||
EWOL_ERROR("Font size too big ==> limit at 400 when exxeed ==> error : " << tmpSize << "==>30");
|
||||
EWOL_ERROR("Font size too big ==> limit at 400 when exxeed ==> error: " << tmpSize << "==>30");
|
||||
tmpSize = 30;
|
||||
}
|
||||
m_size = tmpSize;
|
||||
|
||||
etk::Vector<etk::String> folderList;
|
||||
etk::Vector<etk::Uri> folderList;
|
||||
if (ewol::getContext().getFontDefault().getUseExternal() == true) {
|
||||
#if defined(__TARGET_OS__Android)
|
||||
folderList.pushBack("ROOT:system/fonts");
|
||||
folderList.pushBack(etk::Path("/system/fonts"));
|
||||
#elif defined(__TARGET_OS__Linux)
|
||||
folderList.pushBack("ROOT:usr/share/fonts");
|
||||
folderList.pushBack(etk::Path("/usr/share/fonts/truetype"));
|
||||
#endif
|
||||
}
|
||||
etk::String applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
|
||||
etk::Vector<etk::String> applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont);
|
||||
for (auto &it : applicationBaseFontList) {
|
||||
etk::Uri applicationBaseFont = ewol::getContext().getFontDefault().getFolder();
|
||||
for (auto &it : explodeMultiplePath(applicationBaseFont)) {
|
||||
folderList.pushBack(it);
|
||||
}
|
||||
for (size_t folderID=0; folderID<folderList.size() ; folderID++) {
|
||||
etk::FSNode myFolder(folderList[folderID]);
|
||||
// find the real Font name :
|
||||
etk::Vector<etk::String> output;
|
||||
myFolder.folderGetRecursiveFiles(output);
|
||||
for (size_t folderID = 0; folderID < folderList.size() ; folderID++) {
|
||||
etk::Vector<etk::Uri> output = etk::uri::listRecursive(folderList[folderID]);
|
||||
|
||||
etk::Vector<etk::String> split = etk::split(localName, ';');
|
||||
EWOL_INFO("try to find font named : " << split << " in: " << myFolder);
|
||||
EWOL_INFO("try to find font named : " << split << " in: " << output);
|
||||
//EWOL_CRITICAL("parse string : " << split);
|
||||
bool hasFindAFont = false;
|
||||
for (size_t jjj=0; jjj<split.size(); jjj++) {
|
||||
EWOL_INFO(" try with : '" << split[jjj] << "'");
|
||||
for (size_t iii=0; iii<output.size(); iii++) {
|
||||
etk::String nameFolder = output[iii].getPath().getString();
|
||||
//EWOL_DEBUG(" file : " << output[iii]);
|
||||
if( etk::end_with(output[iii], split[jjj]+"-"+"bold"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"b"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"bd"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"bold"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"bd"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"b"+".ttf", false) == true) {
|
||||
if( etk::end_with(nameFolder, split[jjj]+"-"+"bold"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"b"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"bd"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"bold"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"bd"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"b"+".ttf", false) == true) {
|
||||
EWOL_INFO(" find Font [Bold] : " << output[iii]);
|
||||
m_fileName[ewol::font::Bold] = output[iii];
|
||||
hasFindAFont = true;
|
||||
} else if( etk::end_with(output[iii], split[jjj]+"-"+"oblique"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"italic"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"Light"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"i"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"oblique"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"italic"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"light"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"i"+".ttf", false) == true) {
|
||||
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"oblique"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"italic"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"Light"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"i"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"oblique"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"italic"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"light"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"i"+".ttf", false) == true) {
|
||||
EWOL_INFO(" find Font [Italic] : " << output[iii]);
|
||||
m_fileName[ewol::font::Italic] = output[iii];
|
||||
hasFindAFont = true;
|
||||
} else if( etk::end_with(output[iii], split[jjj]+"-"+"bolditalic"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"boldoblique"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"bi"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"z"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"bolditalic"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"boldoblique"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"bi"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"z"+".ttf", false) == true) {
|
||||
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"bolditalic"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"boldoblique"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"bi"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"z"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"bolditalic"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"boldoblique"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"bi"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"z"+".ttf", false) == true) {
|
||||
EWOL_INFO(" find Font [Bold-Italic] : " << output[iii]);
|
||||
m_fileName[ewol::font::BoldItalic] = output[iii];
|
||||
hasFindAFont = true;
|
||||
} else if( etk::end_with(output[iii], split[jjj]+"-"+"regular"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"-"+"r"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"regular"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+"r"+".ttf", false) == true
|
||||
|| etk::end_with(output[iii], split[jjj]+".ttf", false) == true) {
|
||||
} else if( etk::end_with(nameFolder, split[jjj]+"-"+"regular"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"-"+"r"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"regular"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+"r"+".ttf", false) == true
|
||||
|| etk::end_with(nameFolder, split[jjj]+".ttf", false) == true) {
|
||||
EWOL_INFO(" find Font [Regular] : " << output[iii]);
|
||||
m_fileName[ewol::font::Regular] = output[iii];
|
||||
hasFindAFont = true;
|
||||
@ -176,7 +193,7 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||
// try to find the reference mode :
|
||||
enum ewol::font::mode refMode = ewol::font::Regular;
|
||||
for(int32_t iii=3; iii >= 0; iii--) {
|
||||
if (m_fileName[iii].size() != 0) {
|
||||
if (m_fileName[iii].isEmpty() == false) {
|
||||
refMode = (enum ewol::font::mode)iii;
|
||||
}
|
||||
}
|
||||
@ -184,7 +201,7 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||
EWOL_DEBUG(" set reference mode : " << refMode);
|
||||
// generate the wrapping on the preventing error
|
||||
for(int32_t iii=3; iii >= 0; iii--) {
|
||||
if (m_fileName[iii].size() != 0) {
|
||||
if (m_fileName[iii].isEmpty() == false) {
|
||||
m_modeWraping[iii] = (enum ewol::font::mode)iii;
|
||||
} else {
|
||||
m_modeWraping[iii] = refMode;
|
||||
@ -192,7 +209,7 @@ void ewol::resource::TexturedFont::init(const etk::String& _fontName) {
|
||||
}
|
||||
|
||||
for (int32_t iiiFontId=0; iiiFontId<4 ; iiiFontId++) {
|
||||
if (m_fileName[iiiFontId].size() == 0) {
|
||||
if (m_fileName[iiiFontId].isEmpty() == true) {
|
||||
EWOL_DEBUG("can not load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size );
|
||||
m_font[iiiFontId] = null;
|
||||
continue;
|
||||
|
@ -25,7 +25,7 @@ namespace ewol {
|
||||
namespace resource {
|
||||
class TexturedFont : public ewol::resource::Texture {
|
||||
private:
|
||||
etk::String m_fileName[4];
|
||||
etk::Uri m_fileName[4];
|
||||
int32_t m_size;
|
||||
int32_t m_height[4];
|
||||
// specific element to have the the know if the specify element is known...
|
||||
|
@ -21,8 +21,8 @@ namespace ewol {
|
||||
FontBase() {
|
||||
addResourceType("ewol::FontFreeType");
|
||||
}
|
||||
void init(const etk::String& _fontName) {
|
||||
gale::Resource::init(_fontName);
|
||||
void init(const etk::Uri& _uri) {
|
||||
gale::Resource::init(_uri);
|
||||
};
|
||||
|
||||
virtual ~FontBase() { };
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include <ewol/ewol.hpp>
|
||||
#include <ewol/widget/Composer.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
#include <ewol/widget/Manager.hpp>
|
||||
#include <ewol/context/Context.hpp>
|
||||
#include <etk/typeInfo.hpp>
|
||||
@ -20,8 +20,12 @@ ewol::widget::Composer::Composer() :
|
||||
// nothing to do ...
|
||||
}
|
||||
|
||||
ewol::WidgetShared ewol::widget::composerGenerateFile(const etk::String& _fileName, uint64_t _id) {
|
||||
etk::String tmpData = etk::FSNodeReadAllData(_fileName);
|
||||
ewol::WidgetShared ewol::widget::composerGenerateFile(const etk::Uri& _uri, uint64_t _id) {
|
||||
etk::String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
EWOL_ERROR("Can not read the file: " << _uri);
|
||||
return null;
|
||||
}
|
||||
return ewol::widget::composerGenerateString(tmpData, _id);
|
||||
}
|
||||
|
||||
@ -74,8 +78,12 @@ ewol::widget::Composer::~Composer() {
|
||||
|
||||
}
|
||||
|
||||
bool ewol::widget::Composer::loadFromFile(const etk::String& _fileName, uint64_t _id) {
|
||||
etk::String tmpData = etk::FSNodeReadAllData(_fileName);
|
||||
bool ewol::widget::Composer::loadFromFile(const etk::Uri& _uri, uint64_t _id) {
|
||||
etk::String tmpData;
|
||||
if (etk::uri::readAll(_uri, tmpData) == false) {
|
||||
EWOL_ERROR("Can not read the file: " << _uri);
|
||||
return false;
|
||||
}
|
||||
return loadFromString(tmpData, _id);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <etk/types.hpp>
|
||||
#include <ewol/debug.hpp>
|
||||
#include <ewol/widget/Container.hpp>
|
||||
#include <etk/uri/uri.hpp>
|
||||
|
||||
namespace ewol {
|
||||
namespace widget {
|
||||
@ -21,7 +22,7 @@ namespace ewol {
|
||||
class Composer : public ewol::widget::Container {
|
||||
public:
|
||||
eproperty::Value<bool> propertyRemoveIfUnderRemove; //!< Remove the composer if sub element request a remove
|
||||
eproperty::Value<etk::String> propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to con,figure it in the xml and not have wrong display
|
||||
eproperty::Value<etk::Uri> propertySubFile; //!< If loading a sub-file, we must do it here ==> permit to configure it in the xml and not have wrong display
|
||||
protected:
|
||||
/**
|
||||
* @brief Constructor
|
||||
@ -35,12 +36,12 @@ namespace ewol {
|
||||
virtual ~Composer();
|
||||
/**
|
||||
* @brief load a composition with a file
|
||||
* @param[in] _fileName Name of the file
|
||||
* @param[in] _uri Name of the file
|
||||
* @param[in] _id Unique ID that is used in replacing the balise "{ID}" inside the File (do nothing if == 0)
|
||||
* @return true == > all done OK
|
||||
* @return false == > some error occured
|
||||
*/
|
||||
bool loadFromFile(const etk::String& _fileName, uint64_t _id=0);
|
||||
bool loadFromFile(const etk::Uri& _uri, uint64_t _id=0);
|
||||
/**
|
||||
* @brief load a composition with a file
|
||||
* @param[in] _composerXmlString xml to parse directly
|
||||
@ -57,6 +58,6 @@ namespace ewol {
|
||||
virtual void onChangePropertySubFile();
|
||||
};
|
||||
ewol::WidgetShared composerGenerateString(const etk::String& _data = "", uint64_t _id=0);
|
||||
ewol::WidgetShared composerGenerateFile(const etk::String& _data = "", uint64_t _id=0);
|
||||
ewol::WidgetShared composerGenerateFile(const etk::Uri& _uri = "", uint64_t _id=0);
|
||||
};
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <ewol/widget/ListFileSystem.hpp>
|
||||
#include <etk/tool.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <etk/path/fileSystem.hpp>
|
||||
|
||||
#include <etk/typeInfo.hpp>
|
||||
ETK_DECLARE_TYPE(ewol::widget::ListFileSystem);
|
||||
@ -17,11 +17,11 @@ ewol::widget::ListFileSystem::ListFileSystem() :
|
||||
signalFolderSelect(this, "folder-select", ""),
|
||||
signalFolderValidate(this, "folder-validate", ""),
|
||||
propertyPath(this, "path",
|
||||
"/",
|
||||
etk::Path("/"),
|
||||
"Path to display",
|
||||
&ewol::widget::ListFileSystem::onChangePropertyPath),
|
||||
propertyFile(this, "select",
|
||||
"",
|
||||
etk::Path(),
|
||||
"selection af a specific file",
|
||||
&ewol::widget::ListFileSystem::onChangePropertyFile),
|
||||
propertyShowFile(this, "show-file",
|
||||
@ -60,12 +60,7 @@ ewol::widget::ListFileSystem::~ListFileSystem() {
|
||||
}
|
||||
|
||||
void ewol::widget::ListFileSystem::clearList() {
|
||||
for (auto &it : m_list) {
|
||||
if (it != null) {
|
||||
ETK_DELETE(etk::FSNode, it);
|
||||
it = null;
|
||||
}
|
||||
}
|
||||
m_list.clear();
|
||||
}
|
||||
|
||||
etk::Color<> ewol::widget::ListFileSystem::getBasicBG() {
|
||||
@ -78,35 +73,39 @@ void ewol::widget::ListFileSystem::regenerateView() {
|
||||
m_selectedLine = -1;
|
||||
m_list.clear();
|
||||
m_originScrooled.setValue(0,0);
|
||||
etk::FSNode tmpFolder(*propertyPath);
|
||||
// get the list:
|
||||
m_list = tmpFolder.folderGetSubList(*propertyShowHidden, *propertyShowFolder, *propertyShowFile, *propertyFilter);
|
||||
uint32_t flags = 0;
|
||||
if (*propertyShowHidden == true) {
|
||||
flags |= etk::path::LIST_HIDDEN;
|
||||
}
|
||||
if (*propertyShowFolder == true) {
|
||||
flags |= etk::path::LIST_FOLDER;
|
||||
}
|
||||
if (*propertyShowFile == true) {
|
||||
flags |= etk::path::LIST_FILE;
|
||||
}
|
||||
m_list = etk::path::list(*propertyPath, flags);
|
||||
// request a redraw ...
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
etk::String ewol::widget::ListFileSystem::getSelect() const {
|
||||
etk::Path ewol::widget::ListFileSystem::getSelect() const {
|
||||
etk::String tmpVal = "";
|
||||
if (m_selectedLine >= 0) {
|
||||
if (m_list[m_selectedLine] != null) {
|
||||
tmpVal = m_list[m_selectedLine]->getNameFile();
|
||||
}
|
||||
tmpVal = m_list[m_selectedLine].getFileName();
|
||||
}
|
||||
return tmpVal;
|
||||
}
|
||||
|
||||
// select the specific file
|
||||
void ewol::widget::ListFileSystem::setSelect(const etk::String& _data) {
|
||||
void ewol::widget::ListFileSystem::setSelect(const etk::Path& _data) {
|
||||
// remove selected line
|
||||
m_selectedLine = -1;
|
||||
// search the coresponding file :
|
||||
for (size_t iii=0; iii<m_list.size(); ++iii) {
|
||||
if (m_list[iii] != null) {
|
||||
if (m_list[iii]->getNameFile() == _data) {
|
||||
// we find the line :
|
||||
m_selectedLine = iii;
|
||||
break;
|
||||
}
|
||||
if (m_list[iii] == _data) {
|
||||
// we find the line :
|
||||
m_selectedLine = iii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
markToRedraw();
|
||||
@ -143,10 +142,9 @@ fluorine::Variant ewol::widget::ListFileSystem::getData(int32_t _role, const ive
|
||||
}
|
||||
}
|
||||
if( _pos.y()-offset >= 0
|
||||
&& _pos.y()-offset < (int32_t)m_list.size()
|
||||
&& m_list[_pos.y()-offset] != null) {
|
||||
EWOL_VERBOSE("get filename for : '" << *m_list[_pos.y()-offset] << ":'" << m_list[_pos.y()-offset]->getNameFile() << "'");
|
||||
return m_list[_pos.y()-offset]->getNameFile();
|
||||
&& _pos.y()-offset < (int32_t)m_list.size()) {
|
||||
EWOL_VERBOSE("get filename for : '" << m_list[_pos.y()-offset] << ":'" << m_list[_pos.y()-offset].getFileName() << "'");
|
||||
return m_list[_pos.y()-offset].getFileName();
|
||||
}
|
||||
}
|
||||
return "<<<ERROR>>>";
|
||||
@ -194,19 +192,12 @@ bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event,
|
||||
// ".." folder
|
||||
signalFolderSelect.emit("..");
|
||||
} else if( m_selectedLine-offset >= 0
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||
&& null != m_list[m_selectedLine-offset] ) {
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size() ) {
|
||||
// generate event extern :
|
||||
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||
case etk::typeNode_file :
|
||||
signalFileSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
case etk::typeNode_folder :
|
||||
signalFolderSelect.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
break;
|
||||
if(etk::path::isDirectory(m_list[m_selectedLine-offset])) {
|
||||
signalFolderSelect.emit(m_list[m_selectedLine-offset].getFileName());
|
||||
} else {
|
||||
signalFileSelect.emit(m_list[m_selectedLine-offset].getFileName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -219,18 +210,11 @@ bool ewol::widget::ListFileSystem::onItemEvent(const ewol::event::Input& _event,
|
||||
// ".." folder
|
||||
signalFolderValidate.emit("..");
|
||||
} else if( m_selectedLine-offset >= 0
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size()
|
||||
&& null != m_list[m_selectedLine-offset] ) {
|
||||
switch(m_list[m_selectedLine-offset]->getNodeType()) {
|
||||
case etk::typeNode_file :
|
||||
signalFileValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
case etk::typeNode_folder :
|
||||
signalFolderValidate.emit(m_list[m_selectedLine-offset]->getNameFile());
|
||||
break;
|
||||
default:
|
||||
EWOL_ERROR("Can not generate event on an unknow type");
|
||||
break;
|
||||
&& m_selectedLine-offset < (int32_t)m_list.size()) {
|
||||
if(etk::path::isDirectory(m_list[m_selectedLine-offset])) {
|
||||
signalFolderSelect.emit(m_list[m_selectedLine-offset].getFileName());
|
||||
} else {
|
||||
signalFileSelect.emit(m_list[m_selectedLine-offset].getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <ewol/widget/List.hpp>
|
||||
#include <etk/os/FSNode.hpp>
|
||||
#include <ewol/resource/ColorFile.hpp>
|
||||
#include <esignal/Signal.hpp>
|
||||
|
||||
@ -20,13 +19,13 @@ namespace ewol {
|
||||
*/
|
||||
class ListFileSystem : public ewol::widget::List {
|
||||
public: // signals
|
||||
esignal::Signal<etk::String> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
||||
esignal::Signal<etk::String> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
||||
esignal::Signal<etk::String> signalFolderSelect;
|
||||
esignal::Signal<etk::String> signalFolderValidate;
|
||||
esignal::Signal<etk::Path> signalFileSelect; //!< @event "file-select" Generated when a file is selected.
|
||||
esignal::Signal<etk::Path> signalFileValidate; //!< @event "file-validate" Generate when the user validate (return) or double click on the element
|
||||
esignal::Signal<etk::Path> signalFolderSelect;
|
||||
esignal::Signal<etk::Path> signalFolderValidate;
|
||||
public: // properties
|
||||
eproperty::Value<etk::String> propertyPath; //!< Current folder that display point on.
|
||||
eproperty::Value<etk::String> propertyFile; //!< current selected file
|
||||
eproperty::Value<etk::Path> propertyPath; //!< Current folder that display point on.
|
||||
eproperty::Value<etk::Path> propertyFile; //!< current selected file
|
||||
eproperty::Value<bool> propertyShowFile; //!< Show files elements
|
||||
eproperty::Value<bool> propertyShowFolder; //!< Display the folders elements
|
||||
eproperty::Value<bool> propertyShowHidden; //!< Display hidden elements
|
||||
@ -48,8 +47,7 @@ namespace ewol {
|
||||
fluorine::Variant getData(int32_t _role, const ivec2& _pos) override;
|
||||
bool onItemEvent(const ewol::event::Input& _event, const ivec2& _pos, const vec2& _mousePosition) override;
|
||||
protected:
|
||||
// TODO: use shred_ptr
|
||||
etk::Vector<etk::FSNode *> m_list; //!< List of all element in the path. (they are filtered)
|
||||
etk::Vector<etk::Path> m_list; //!< List of all element in the path. (they are filtered)
|
||||
/**
|
||||
* @brief Clean the list of element.
|
||||
*/
|
||||
@ -65,12 +63,12 @@ namespace ewol {
|
||||
* @brief Select a specific file in the path
|
||||
* @param[in] _data File to selested.
|
||||
*/
|
||||
virtual void setSelect(const etk::String& _data);
|
||||
virtual void setSelect(const etk::Path& _data);
|
||||
/**
|
||||
* @brief Get the current selected file/folder/... in the list
|
||||
* @return the String of the element selected.
|
||||
*/
|
||||
etk::String getSelect() const ;
|
||||
etk::Path getSelect() const ;
|
||||
protected:
|
||||
virtual void onChangePropertyPath();
|
||||
virtual void onChangePropertyFile();
|
||||
|
Loading…
x
Reference in New Issue
Block a user