void ewol::Widget::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) { ewol::Object::onParameterChangeValue(_paramPointer); if (_paramPointer == m_canFocus) { if (m_hasFocus == true) { rmFocus(); } } else if (_paramPointer == m_gravity) { markToRedraw(); } else if (_paramPointer == m_hide) { markToRedraw(); requestUpdateSize(); } else if (_paramPointer == m_userFill) { markToRedraw(); requestUpdateSize(); } else if (_paramPointer == m_userExpand) { requestUpdateSize(); markToRedraw(); } else if (_paramPointer == m_userMaxSize) { vec2 pixelMin = m_userMinSize->getPixel(); vec2 pixelMax = m_userMaxSize->getPixel(); // check minimum & maximum compatibility : bool error=false; if (pixelMin.x()>pixelMax.x()) { error=true; } if (pixelMin.y()>pixelMax.y()) { error=true; } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' reset to maximum ..."); m_userMaxSize = gale::Dimension(vec2(ULTIMATE_MAX_SIZE,ULTIMATE_MAX_SIZE),gale::Dimension::Pixel); } requestUpdateSize(); } else if (_paramPointer == m_userMinSize) { vec2 pixelMin = m_userMinSize->getPixel(); vec2 pixelMax = m_userMaxSize->getPixel(); // check minimum & maximum compatibility : bool error=false; if (pixelMin.x()>pixelMax.x()) { error=true; } if (pixelMin.y()>pixelMax.y()) { error=true; } if (error == true) { EWOL_ERROR("Can not set a 'min size' > 'max size' set nothing ..."); m_userMinSize = gale::Dimension(vec2(0,0),gale::Dimension::Pixel); } requestUpdateSize(); } else if (_paramPointer == m_annimationTypeStart) { } else if (_paramPointer == m_annimationTimeStart) { } else if (_paramPointer == m_annimationTypeStop) { } else if (_paramPointer == m_annimationTimeStop) { } }
ewol::object::Manager::~Manager() { m_workerList.clear(); bool hasError = false; if (m_eObjectList.size()!=0) { EWOL_ERROR("Must not have anymore eObject !!!"); hasError = true; } if (true == hasError) { EWOL_ERROR("Check if the function UnInit has been called !!!"); } displayListObject(); }
ewol::resource::Manager::~Manager() { bool hasError = false; if (m_resourceListToUpdate.size()!=0) { EWOL_ERROR("Must not have anymore resources to update !!!"); hasError = true; } // TODO : Remove unneeded elements if (m_resourceList.size()!=0) { EWOL_ERROR("Must not have anymore resources !!!"); hasError = true; } if (true == hasError) { EWOL_ERROR("Check if the function UnInit has been called !!!"); } }
void ewol::resource::DistanceFieldFont::exportOnFile() { std11::unique_lock<std11::recursive_mutex> lock(m_mutex); EWOL_DEBUG("EXPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); ejson::Document doc; std::shared_ptr<ejson::Array> tmpList = ejson::Array::create(); if (tmpList == nullptr) { EWOL_ERROR("nullptr pointer"); return; } for (size_t iii=0; iii<m_listElement.size(); ++iii) { std::shared_ptr<ejson::Object> tmpObj = ejson::Object::create(); if (tmpObj == nullptr) { continue; } tmpObj->addString("m_UVal", etk::to_string(m_listElement[iii].m_UVal)); tmpObj->addNumber("m_glyphIndex", m_listElement[iii].m_glyphIndex); tmpObj->addString("m_sizeTexture", (std::string)m_listElement[iii].m_sizeTexture); tmpObj->addString("m_bearing", (std::string)m_listElement[iii].m_bearing); tmpObj->addString("m_advance", (std::string)m_listElement[iii].m_advance); tmpObj->addString("m_texturePosStart", (std::string)m_listElement[iii].m_texturePosStart); tmpObj->addString("m_texturePosSize", (std::string)m_listElement[iii].m_texturePosSize); tmpObj->addBoolean("m_exist", m_listElement[iii].m_exist); tmpList->add(tmpObj); } doc.add("m_listElement", tmpList); doc.addNumber("m_sizeRatio", m_sizeRatio); doc.addString("m_lastGlyphPos", (std::string)m_lastGlyphPos); doc.addNumber("m_lastRawHeigh", m_lastRawHeigh); doc.addNumber("m_borderSize", m_borderSize); doc.addString("m_textureBorderSize", (std::string)m_textureBorderSize); doc.store(m_fileName + ".json"); egami::store(m_data, m_fileName + ".bmp"); egami::store(m_data, m_fileName + ".png"); }
void ewol::compositing::Text::drawD(bool _disableDepthTest) { // draw BG in any case: m_vectorialDraw.draw(_disableDepthTest); if (m_coord.size() <= 0 || m_font == nullptr) { //EWOL_WARNING("Nothink to draw..."); return; } if (m_font == nullptr) { EWOL_WARNING("no font..."); return; } if (m_GLprogram == nullptr) { EWOL_ERROR("No shader ..."); return; } // set Matrix : translation/positionMatrix mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); // position : m_GLprogram->sendAttribute(m_GLPosition, m_coord); // Texture : m_GLprogram->sendAttribute(m_GLtexture, m_coordTex); // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_coord.size()); m_GLprogram->unUse(); }
void ewol::widget::Spin::onChangePropertyValue() { markToRedraw(); if (m_widgetEntry == nullptr) { EWOL_ERROR("Can not acces at entry ..."); return; } checkValue(*propertyValue); }
void ewol::compositing::Image::draw(bool _disableDepthTest) { if (m_coord.size() <= 0) { //EWOL_WARNING("Nothink to draw..."); return; } if ( m_resource == nullptr && m_resourceDF == nullptr) { // this is a normale case ... the user can choice to have no image ... return; } if (m_GLprogram == nullptr) { EWOL_ERROR("No shader ..."); return; } if (_disableDepthTest == true) { gale::openGL::disable(gale::openGL::flag_depthTest); } else { gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // TextureID if (m_resource != nullptr) { if (m_distanceFieldMode == true) { EWOL_ERROR("FONT type error Request distance field and display normal ..."); } m_GLprogram->setTexture0(m_GLtexID, m_resource->getRendererId()); } else { if (m_distanceFieldMode == false) { EWOL_ERROR("FONT type error Request normal and display distance field ..."); } m_GLprogram->setTexture0(m_GLtexID, m_resourceDF->getRendererId()); } // position : m_GLprogram->sendAttribute(m_GLPosition, m_coord); // Texture : m_GLprogram->sendAttribute(m_GLtexture, m_coordTex); // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_coord.size()); m_GLprogram->unUse(); }
void ewol::widget::ParameterList::addOObject(ewol::Compositing* _newObject, int32_t _pos) { if (nullptr == _newObject) { EWOL_ERROR("Try to add an empty object in the Widget generic display system"); return; } if (_pos < 0 || (size_t)_pos >= m_listOObject.size() ) { m_listOObject.push_back(_newObject); } else { m_listOObject.insert(m_listOObject.begin()+_pos, _newObject); } }
void ewol::resource::ColorFile::reload() { std::unique_lock<std::recursive_mutex> lock(m_mutex); // remove all previous set of value : for (int32_t iii = 0; iii < m_list.size() ; ++iii) { m_list[iii] = m_errorColor; } // 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()); return; } ejson::Array baseArray = doc["color"].toArray(); if (baseArray.exist() == false) { EWOL_ERROR("Can not get basic array : 'color' in file:" << m_name); doc.display(); return; } bool findError = false; for (const auto it : baseArray) { ejson::Object tmpObj = it.toObject(); if (tmpObj.exist() == false) { EWOL_ERROR(" can not get object in 'color' : " << it); findError = true; continue; } std::string name = tmpObj["name"].toString().get(); std::string color = tmpObj["color"].toString().get(m_errorColor.getHexString()); EWOL_DEBUG("find new color : '" << name << "' color='" << color << "'"); if (name.size() == 0) { EWOL_ERROR("Drop an empty name"); findError = true; continue; } m_list.add(name, etk::Color<float>(color)); } if (findError == true) { EWOL_ERROR("pb in parsing file:" << m_name); doc.display(); } }
bool ewol::widget::Container::loadXML(exml::Element* _node) { if (nullptr == _node) { return false; } // parse generic properties : ewol::Widget::loadXML(_node); // remove previous element : subWidgetRemove(); // parse all the elements : for(size_t iii=0; iii< _node->size(); iii++) { exml::Element* pNode = _node->getElement(iii); if (pNode == nullptr) { // trash here all that is not element continue; } std::string widgetName = pNode->getValue(); if (getWidgetManager().exist(widgetName) == false) { EWOL_ERROR("(l "<<pNode->getPos()<<") Unknown basic node=\"" << widgetName << "\" not in : [" << getWidgetManager().list() << "]" ); continue; } if (nullptr != getSubWidget()) { EWOL_ERROR("(l "<<pNode->getPos()<<") " << __class__ << " Can only have one subWidget ??? node=\"" << widgetName << "\"" ); continue; } EWOL_DEBUG("try to create subwidget : '" << widgetName << "'"); std::shared_ptr<ewol::Widget> tmpWidget = getWidgetManager().create(widgetName); if (tmpWidget == nullptr) { EWOL_ERROR ("(l "<<pNode->getPos()<<") Can not create the widget : \"" << widgetName << "\""); continue; } // add widget : setSubWidget(tmpWidget); if (false == tmpWidget->loadXML(pNode)) { EWOL_ERROR ("(l "<<pNode->getPos()<<") can not load widget properties : \"" << widgetName << "\""); return false; } } return true; }
void ewol::resource::Shader::updateContext() { if (true == m_exist) { // Do nothing == > too dangerous ... } else { // create the Shader if (nullptr == m_fileData) { m_shader = 0; return; } m_shader = glCreateShader(m_type); if (!m_shader) { EWOL_ERROR("glCreateShader return error ..."); checkGlError("glCreateShader"); return; } else { //EWOL_INFO("Creater shader with GLID=" << m_shader); glShaderSource(m_shader, 1, (const char**)&m_fileData, nullptr); glCompileShader(m_shader); GLint compiled = 0; glGetShaderiv(m_shader, GL_COMPILE_STATUS, &compiled); if (!compiled) { GLint infoLen = 0; l_bufferDisplayError[0] = '\0'; glGetShaderInfoLog(m_shader, LOG_OGL_INTERNAL_BUFFER_LEN, &infoLen, l_bufferDisplayError); const char * tmpShaderType = "GL_FRAGMENT_SHADER"; if (m_type == GL_VERTEX_SHADER){ tmpShaderType = "GL_VERTEX_SHADER"; } EWOL_ERROR("Could not compile \"" << tmpShaderType << "\" name='" << m_name << "'"); EWOL_ERROR("Error " << l_bufferDisplayError); std::vector<std::string> lines = etk::split(m_fileData, '\n'); for (size_t iii=0 ; iii<lines.size() ; iii++) { EWOL_ERROR("file " << (iii+1) << "|" << lines[iii]); } return; } } m_exist = true; } }
void ewol::resource::Shader::reload() { etk::FSNode file(m_name); if (false == file.exist()) { EWOL_ERROR("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'"); return; } int64_t fileSize = file.fileSize(); if (0 == fileSize) { EWOL_ERROR("This file is empty : " << file); return; } if (false == file.fileOpenRead()) { EWOL_ERROR("Can not open the file : " << file); return; } // remove previous data ... if (nullptr != m_fileData) { delete[] m_fileData; m_fileData = 0; } // allocate data m_fileData = new char[fileSize+5]; if (nullptr == m_fileData) { EWOL_ERROR("Error Memory allocation size=" << fileSize); return; } memset(m_fileData, 0, (fileSize+5)*sizeof(char)); // load data from the file : file.fileRead(m_fileData, 1, fileSize); // close the file: file.fileClose(); // now change the OGL context ... removeContext(); updateContext(); }
bool ewol::widget::Composer::loadFromString(const std::string& _composerXmlString) { exml::Document doc; if (doc.parse(_composerXmlString) == false) { EWOL_ERROR(" can not load file XML string..."); return false; } exml::Element* root = (exml::Element*)doc.getNamed("composer"); if (root == nullptr) { // Maybe a multiple node XML for internal config: root = doc.toElement(); if (root == nullptr) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) main node not find: \"composer\" ..."); return false; } if (root->size() == 0) { EWOL_ERROR("[" << getId() << "] {" << getObjectType() << "} (l ?) no node in the Container XML element."); return false; } } // call upper class to parse his elements ... ewol::widget::Container::loadXML(root); requestUpdateSize(); return true; }
void ewol::compositing::Image::setSource(const std::string& _newFile, const vec2& _size) { clear(); ememory::SharedPtr<ewol::resource::TextureFile> resource = m_resource; ememory::SharedPtr<ewol::resource::ImageDF> resourceDF = m_resourceDF; m_filename = _newFile; m_requestSize = _size; 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::create(m_filename, tmpSize); if (m_resource == nullptr) { EWOL_ERROR("Can not get Image resource"); } } else { m_resourceDF = ewol::resource::ImageDF::create(m_filename, tmpSize); if (m_resourceDF == nullptr) { EWOL_ERROR("Can not get Image resource DF"); } } } if ( m_resource == nullptr && m_resourceDF == nullptr) { if (resource != nullptr) { EWOL_WARNING("Retrive previous resource"); m_resource = resource; } if (resourceDF != nullptr) { EWOL_WARNING("Retrive previous resource (DF)"); m_resourceDF = resourceDF; } } }
void ewol::resource::Shader::init(const std::string& _filename) { ewol::Resource::init(_filename); EWOL_DEBUG("OGL : load SHADER \"" << _filename << "\""); // load data from file "all the time ..." if (etk::end_with(m_name, ".frag") == true) { m_type = GL_FRAGMENT_SHADER; } else if (etk::end_with(m_name, ".vert") == true) { m_type = GL_VERTEX_SHADER; } else { EWOL_ERROR("File does not have extention \".vert\" for Vertex Shader or \".frag\" for Fragment Shader. but : \"" << m_name << "\""); return; } reload(); }
void ewol::object::Manager::unInit() { EWOL_DEBUG(" == > Un-Init Object-Manager"); if (m_workerList.size() > 0) { EWOL_DEBUG(" == > Remove all workers"); m_workerList.clear(); } for (auto &it : m_eObjectList) { std::shared_ptr<ewol::Object> element = it.lock(); if (element != nullptr) { //it->removeObject(); } } if (m_eObjectList.size() != 0) { EWOL_ERROR("Have " << m_eObjectList.size() << " active Object"); } m_eObjectList.clear(); }
void ewol::resource::TextureFile::init(std::string _genName, const std::string& _tmpFilename, const ivec2& _size) { std::unique_lock<std::recursive_mutex> 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); if (m_data.exist() == false) { EWOL_ERROR("ERROR when loading the image : " << _tmpFilename); } //egami::store(m_data, "tmpResult.bmp"); ivec2 tmp = m_data.getSize(); m_realImageSize = vec2(tmp.x(), tmp.y()); #ifdef GENERATE_DISTANCE_FIELD_MODE //egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".bmp"); egami::generateDistanceFieldFile(_tmpFilename, std::string(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf"); #endif flush(); }
void ewol::compositing::Text::drawMT(const mat4& _transformationMatrix, bool _enableDepthTest) { // draw BG in any case: m_vectorialDraw.draw(); if (m_coord.size() <= 0 || m_font == nullptr) { // TODO : a remÃtre ... //EWOL_WARNING("Nothink to draw..."); return; } if (m_font == nullptr) { EWOL_WARNING("no font..."); return; } if (m_GLprogram == nullptr) { EWOL_ERROR("No shader ..."); return; } if (_enableDepthTest == true) { gale::openGL::enable(gale::openGL::flag_depthTest); } // set Matrix : translation/positionMatrix mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix * _transformationMatrix; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // Texture : m_GLprogram->setTexture0(m_GLtexID, m_font->getRendererId()); m_GLprogram->uniform1i(m_GLtextWidth, m_font->getOpenGlSize().x()); m_GLprogram->uniform1i(m_GLtextHeight, m_font->getOpenGlSize().x()); // position : m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z*/, &m_coord[0]); // Texture : m_GLprogram->sendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]); // color : m_GLprogram->sendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]); // Request the draw od the elements : gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_coord.size()); m_GLprogram->unUse(); if (_enableDepthTest == true) { gale::openGL::disable(gale::openGL::flag_depthTest); } }
bool ewol::resource::DistanceFieldFont::importFromFile() { std11::unique_lock<std11::recursive_mutex> lock(m_mutex); EWOL_DEBUG("IMPORT: DistanceFieldFont : file : '" << m_fileName << ".json'"); // test file existance: etk::FSNode fileJSON(m_fileName + ".json"); etk::FSNode fileBMP(m_fileName + ".bmp"); if ( fileJSON.exist() == false || fileBMP.exist() == false) { EWOL_DEBUG("Does not import file for distance field system"); return false; } ejson::Document doc; doc.load(m_fileName + ".json"); m_sizeRatio = doc.getNumberValue("m_sizeRatio", 0); m_lastGlyphPos = doc.getStringValue("m_lastGlyphPos", "0,0"); m_lastRawHeigh = doc.getNumberValue("m_lastRawHeigh", 0); m_borderSize = doc.getNumberValue("m_borderSize", 2); m_textureBorderSize = doc.addString("m_textureBorderSize", "0,0"); std::shared_ptr<ejson::Array> tmpList = doc.getArray("m_listElement"); if (tmpList == nullptr) { EWOL_ERROR("nullptr pointer array"); return false; } m_listElement.clear(); for (size_t iii=0; iii<tmpList->size(); ++iii) { std::shared_ptr<ejson::Object> tmpObj = tmpList->getObject(iii); if (tmpObj == nullptr) { continue; } GlyphProperty prop; prop.m_UVal = etk::string_to_int32_t(tmpObj->getStringValue("m_UVal", "0")); prop.m_glyphIndex = tmpObj->getNumberValue("m_glyphIndex", 0); prop.m_sizeTexture = tmpObj->getStringValue("m_sizeTexture", "0,0"); prop.m_bearing = tmpObj->getStringValue("m_bearing", "0,0"); prop.m_advance = tmpObj->getStringValue("m_advance", "0,0"); prop.m_texturePosStart = tmpObj->getStringValue("m_texturePosStart", "0,0"); prop.m_texturePosSize = tmpObj->getStringValue("m_texturePosSize", "0,0"); prop.m_exist = tmpObj->getBooleanValue("m_exist", false); m_listElement.push_back(prop); } egami::load(m_data, m_fileName + ".bmp"); return true; }
ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_t& _charcode, const enum ewol::font::mode _displayMode) { std::unique_lock<std::recursive_mutex> lock(m_mutex); //EWOL_DEBUG("Get glyph property for mode: " << _displayMode << " == > wrapping index : " << m_modeWraping[_displayMode]); int32_t index = getIndex(_charcode, _displayMode); if( index < 0 || (size_t)index >= m_listElement[_displayMode].size() ) { EWOL_ERROR(" Try to get glyph index inexistant ... == > return the index 0 ... id=" << index); if (m_listElement[_displayMode].size() > 0) { return &((m_listElement[_displayMode])[0]); } return nullptr; } //EWOL_ERROR(" index=" << index); //EWOL_ERROR(" m_UVal=" << m_listElement[_displayMode][index].m_UVal); //EWOL_ERROR(" m_glyphIndex=" << m_listElement[_displayMode][index].m_glyphIndex); //EWOL_ERROR(" m_advance=" << m_listElement[_displayMode][index].m_advance); //EWOL_ERROR(" m_bearing=" << m_listElement[_displayMode][index].m_bearing); return &((m_listElement[_displayMode])[index]); }
void ewol::compositing::Text::setFont(std::string _fontName, int32_t _fontSize) { clear(); // remove old one ememory::SharedPtr<ewol::resource::TexturedFont> previousFont = m_font; if (_fontSize <= 0) { _fontSize = ewol::getContext().getFontDefault().getSize(); } if (_fontName == "") { _fontName = ewol::getContext().getFontDefault().getName(); } _fontName += ":"; _fontName += etk::to_string(_fontSize); EWOL_VERBOSE("plop : " << _fontName << " size=" << _fontSize << " result :" << _fontName); // link to new one m_font = ewol::resource::TexturedFont::create(_fontName); if (m_font == nullptr) { EWOL_ERROR("Can not get font resource"); m_font = previousFont; } }
void ewol::resource::Colored3DObject::draw(std::vector<vec3>& _vertices, const etk::Color<float>& _color, bool _updateDepthBuffer, bool _depthtest) { if (_vertices.size() <= 0) { return; } if (m_GLprogram == nullptr) { EWOL_ERROR("No shader ..."); return; } if (true == _depthtest) { gale::openGL::enable(gale::openGL::flag_depthTest); if (false == _updateDepthBuffer) { glDepthMask(GL_FALSE); } } //EWOL_DEBUG(" display " << m_coord.size() << " elements" ); m_GLprogram->use(); // set Matrix : translation/positionMatrix mat4 projMatrix = gale::openGL::getMatrix(); mat4 camMatrix = gale::openGL::getCameraMatrix(); mat4 tmpMatrix = projMatrix * camMatrix; m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); // position : m_GLprogram->sendAttribute(m_GLPosition, 3/*x,y,z,unused*/, &_vertices[0], 4*sizeof(float)); // color : m_GLprogram->uniform4fv(m_GLColor, 1/*r,g,b,a*/, (float*)&_color); // Request the draw od the elements : gale::openGL::drawArrays(gale::openGL::render_triangle, 0, _vertices.size()); m_GLprogram->unUse(); // Request the draw od the elements : //glDrawArrays(GL_LINES, 0, vertices.size()); //m_GLprogram->UnUse(); if (true == _depthtest) { if (false == _updateDepthBuffer) { glDepthMask(GL_TRUE); } gale::openGL::disable(gale::openGL::flag_depthTest); } }
bool ewol::resource::Texture::updateContext() { std11::unique_lock<std11::recursive_mutex> lock(m_mutex, std11::defer_lock); if (lock.try_lock() == false) { //Lock error ==> try later ... return false; } if (false == m_loaded) { // Request a new texture at openGl : glGenTextures(1, &m_texId); } EWOL_ERROR("plop : load the image:" << m_name); // in all case we set the texture properties : // TODO : check error ??? glBindTexture(GL_TEXTURE_2D, m_texId); // TODO : Check error ??? //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //--- mode nearest //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //--- Mode linear glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); EWOL_INFO("TEXTURE: add [" << getId() << "]=" << m_data.getSize() << " OGl_Id=" <<m_texId); //egami::storeBMP("~/bbb_image.bmp", m_data); glTexImage2D(GL_TEXTURE_2D, // Target 0, // Level GL_RGBA, // Format internal m_data.getWidth(), m_data.getHeight(), 0, // Border GL_RGBA, // format GL_UNSIGNED_BYTE, // type m_data.getTextureDataPointer() ); // now the data is loaded m_loaded = true; return true; }
void ewol::widget::Parameter::menuAdd(std::string _label, std::string _image, std::shared_ptr<ewol::Widget> _associateWidget) { if (nullptr != m_paramList) { m_paramList->menuAdd(_label, m_currentIdList, _image); if (nullptr != m_wSlider) { if (nullptr != _associateWidget) { m_wSlider->subWidgetAdd(_associateWidget); } else { EWOL_DEBUG("Associate an empty widget on it ..."); std::shared_ptr<ewol::widget::Label> myLabel = widget::Label::create(std::string("No widget for : ") + _label); if (nullptr == myLabel) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { myLabel->setExpand(bvec2(true,true)); m_wSlider->subWidgetAdd(myLabel); } } if (m_currentIdList == 0) { m_wSlider->subWidgetSelectSet(0); } } m_currentIdList++; } }
void ewol::compositing::Drawing::draw(bool _disableDepthTest) { if (m_coord.size() <= 0) { // TODO : a remÚtre ... //EWOL_WARNING("Nothink to draw..."); return; } if (m_GLprogram == nullptr) { EWOL_ERROR("No shader ..."); return; } // set Matrix : translation/positionMatrix mat4 tmpMatrix = gale::openGL::getMatrix()*m_matrixApply; m_GLprogram->use(); m_GLprogram->uniformMatrix(m_GLMatrix, tmpMatrix); mat4 tmpMatrix2; m_GLprogram->uniformMatrix(m_GLMatrixPosition, tmpMatrix2); // position : m_GLprogram->sendAttribute(m_GLPosition, m_coord); // color : m_GLprogram->sendAttribute(m_GLColor, m_coordColor); // Request the draw od the elements : gale::openGL::drawArrays(gale::openGL::renderMode::triangle, 0, m_coord.size()); m_GLprogram->unUse(); }
void ewol::compositing::Text::printChar(const char32_t& _charcode) { // get a pointer on the glyph property : ewol::GlyphProperty* myGlyph = getGlyphPointer(_charcode); if (nullptr == myGlyph) { EWOL_ERROR(" font does not really existed ..."); return; } int32_t fontSize = getSize(); int32_t fontHeigh = getHeight(); // get the kerning ofset : float kerningOffset = 0; if (true == m_kerning) { kerningOffset = myGlyph->kerningGet(m_previousCharcode); if (kerningOffset != 0) { //EWOL_DEBUG("Kerning between : '" << m_previousCharcode << "'&'" << myGlyph->m_UVal << "' value : " << kerningOffset); } } // 0x01 == 0x20 == ' '; if (_charcode != 0x01) { /* Bitmap position * xA xB * yC *------* * | | * | | * yD *------* */ float dxA = m_position.x() + myGlyph->m_bearing.x() + kerningOffset; float dxB = dxA + myGlyph->m_sizeTexture.x(); float dyC = m_position.y() + myGlyph->m_bearing.y() + fontHeigh - fontSize; float dyD = dyC - myGlyph->m_sizeTexture.y(); float tuA = myGlyph->m_texturePosStart.x(); float tuB = tuA + myGlyph->m_texturePosSize.x(); float tvC = myGlyph->m_texturePosStart.y(); float tvD = tvC + myGlyph->m_texturePosSize.y(); // Clipping and drawing area if( m_clippingEnable == true && ( dxB < m_clippingPosStart.x() || dxA > m_clippingPosStop.x() || dyC < m_clippingPosStart.y() || dyD > m_clippingPosStop.y() ) ) { // Nothing to diplay ... } else { if (m_clippingEnable == true) { // generata positions... float TexSizeX = tuB - tuA; if (dxA < m_clippingPosStart.x()) { // clip display float drawSize = m_clippingPosStart.x() - dxA; // update element start display dxA = m_clippingPosStart.x(); float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); // update texture start X Pos tuA += addElement; } if (dxB > m_clippingPosStop.x()) { // clip display float drawSize = dxB - m_clippingPosStop.x(); // update element start display dxB = m_clippingPosStop.x(); float addElement = TexSizeX * drawSize / (float)myGlyph->m_sizeTexture.x(); // update texture start X Pos tuB -= addElement; } float TexSizeY = tvC - tvD; if (dyC > m_clippingPosStop.y()) { // clip display float drawSize = dyC - m_clippingPosStop.y(); // update element start display dyC = m_clippingPosStop.y(); float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); // update texture start X Pos tvC -= addElement; } if (dyD < m_clippingPosStart.y()) { // clip display float drawSize = m_clippingPosStart.y() - dyD; // update element start display dyD = m_clippingPosStart.y(); float addElement = TexSizeY * drawSize / (float)myGlyph->m_sizeTexture.y(); // update texture start X Pos tvD += addElement; } } if( dxB <= dxA || dyD >= dyC) { // nothing to do ... } else { /* Bitmap position * 0------1 * | | * | | * 3------2 */ if (m_needDisplay == true) { vec3 bitmapDrawPos[4]; bitmapDrawPos[0].setValue((int32_t)dxA, (int32_t)dyC, 0); bitmapDrawPos[1].setValue((int32_t)dxB, (int32_t)dyC, 0); bitmapDrawPos[2].setValue((int32_t)dxB, (int32_t)dyD, 0); bitmapDrawPos[3].setValue((int32_t)dxA, (int32_t)dyD, 0); /* texture Position : * 0------1 * | | * | | * 3------2 */ vec2 texturePos[4]; texturePos[0].setValue(tuA+m_mode, tvC); texturePos[1].setValue(tuB+m_mode, tvC); texturePos[2].setValue(tuB+m_mode, tvD); texturePos[3].setValue(tuA+m_mode, tvD); // NOTE : Android does not support the Quads elements ... /* Step 1 : * ******** * ****** * **** * ** * */ // set texture coordonates : m_coordTex.push_back(texturePos[0]); m_coordTex.push_back(texturePos[1]); m_coordTex.push_back(texturePos[2]); // set display positions : m_coord.push_back(bitmapDrawPos[0]); m_coord.push_back(bitmapDrawPos[1]); m_coord.push_back(bitmapDrawPos[2]); // set the color m_coordColor.push_back(m_color); m_coordColor.push_back(m_color); m_coordColor.push_back(m_color); /* Step 2 : * * ** * **** * ****** * ******** */ // set texture coordonates : m_coordTex.push_back(texturePos[0]); m_coordTex.push_back(texturePos[2]); m_coordTex.push_back(texturePos[3]); // set display positions : m_coord.push_back(bitmapDrawPos[0]); m_coord.push_back(bitmapDrawPos[2]); m_coord.push_back(bitmapDrawPos[3]); // set the color m_coordColor.push_back(m_color); m_coordColor.push_back(m_color); m_coordColor.push_back(m_color); } } } } // move the position : //EWOL_DEBUG(" 5 pos=" << m_position << " advance=" << myGlyph->m_advance.x() << " kerningOffset=" << kerningOffset); m_position.setX(m_position.x() + myGlyph->m_advance.x() + kerningOffset); //EWOL_DEBUG(" 6 print '" << charcode << "' : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); // Register the previous character m_previousCharcode = _charcode; return; }
bool ewol::widget::ButtonColor::onEventInput(const ewol::event::Input& _event) { bool previousHoverState = m_mouseHover; if(ewol::key::statusLeave == _event.getStatus()) { m_mouseHover = false; m_buttonPressed = false; } else { vec2 relativePos = relativePosition(_event.getPos()); // prevent error from ouside the button if( relativePos.x() < m_selectableAreaPos.x() || relativePos.y() < m_selectableAreaPos.y() || relativePos.x() > m_selectableAreaPos.x() + m_selectableAreaSize.x() || relativePos.y() > m_selectableAreaPos.y() + m_selectableAreaSize.y() ) { m_mouseHover = false; m_buttonPressed = false; } else { m_mouseHover = true; } } bool previousPressed = m_buttonPressed; //EWOL_DEBUG("Event on BT ... mouse position : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { if(ewol::key::statusDown == _event.getStatus()) { m_buttonPressed = true; markToRedraw(); } if(ewol::key::statusUp == _event.getStatus()) { m_buttonPressed = false; markToRedraw(); } if(ewol::key::statusSingle == _event.getStatus()) { m_buttonPressed = false; m_mouseHover = false; // create a context menu : m_widgetContextMenu = ewol::widget::ContextMenu::create(); if (nullptr == m_widgetContextMenu) { EWOL_ERROR("Allocation Error"); return true; } vec2 tmpPos = m_origin + m_selectableAreaPos + m_selectableAreaSize; tmpPos.setX( tmpPos.x() - m_minSize.x()/2.0); m_widgetContextMenu->setPositionMark(ewol::widget::ContextMenu::markButtom, tmpPos ); std::shared_ptr<ewol::widget::ColorChooser> myColorChooser = widget::ColorChooser::create(); myColorChooser->setColor(m_textColorFg.get()); // set it in the pop-up-system : m_widgetContextMenu->setSubWidget(myColorChooser); myColorChooser->signalChange.bind(shared_from_this(), &ewol::widget::ButtonColor::onCallbackColorChange); std::shared_ptr<ewol::widget::Windows> currentWindows = getWindows(); if (currentWindows == nullptr) { EWOL_ERROR("Can not get the curent Windows..."); m_widgetContextMenu.reset(); } else { currentWindows->popUpWidgetPush(m_widgetContextMenu); } markToRedraw(); } } } if( m_mouseHover != previousHoverState || m_buttonPressed != previousPressed) { if (true == m_buttonPressed) { changeStatusIn(STATUS_PRESSED); } else { if (true == m_mouseHover) { changeStatusIn(STATUS_HOVER); } else { changeStatusIn(STATUS_UP); } } } return m_mouseHover; }
void ege::widget::Scene::onDraw() { #ifdef SCENE_DISPLAY_SPEED g_counterNbTimeDisplay++; g_startTime = ewol::getTime(); #endif // draw constant object : { mat4 tmpMatrix; for (auto &it : m_env->getStaticMeshToDraw()) { if (it != nullptr) { it->draw(tmpMatrix); } } } // get camera : ememory::SharedPtr<ege::Camera> camera = m_env->getCamera(m_cameraName); if (camera == nullptr) { EGE_ERROR(" can not get camera named: '" << m_cameraName << "'"); return; } //EGE_DEBUG("Draw (start)"); mat4 tmpMatrix; ememory::SharedPtr<btDynamicsWorld> world = m_env->getPhysicEngine().getDynamicWorld(); if (world != nullptr) { m_env->getOrderedElementForDisplay(m_displayElementOrdered, camera->getEye(), camera->getViewVector()); EGE_VERBOSE("DRAW : " << m_displayElementOrdered.size() << "/" << m_env->getElement().size() << " elements"); // TODO : remove this == > no more needed ==> checked in the generate the list of the element ordered for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) { m_displayElementOrdered[iii].element->preCalculationDraw(*camera); } // note : the first pass is done at the reverse way to prevent multiple display od the same point in the screen // (and we remember that the first pass is to display all the non transparent elements) for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) { m_displayElementOrdered[iii].element->draw(0); } // for the other pass the user can draw transparent elements ... for (int32_t pass=1; pass <= NUMBER_OF_SUB_PASS+1; pass++) { for (size_t iii=0; iii<m_displayElementOrdered.size(); iii++) { m_displayElementOrdered[iii].element->draw(pass); } } if (propertyDebugPhysic.get() == true) { // Draw debug ... (Object) for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) { m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera); } // Draw debug ... (Camera) std::map<std::string, ememory::SharedPtr<ege::Camera>> listCamera = m_env->getCameraList(); for (auto &itCam : listCamera) { if (itCam.second != nullptr) { itCam.second->drawDebug(m_debugDrawProperty, camera); } } } if (propertyDebugApplication.get() == true) { // Draw debug ... (User) signalDisplayDebug.emit(m_debugDrawProperty); } } else { EGE_WARNING("No Dynamic world ..."); } if (camera != nullptr) { m_env->getParticuleEngine().draw(*camera); } #ifdef SCENE_DISPLAY_SPEED float localTime = (float)(ewol::getTime() - g_startTime) / 1000.0f; if (localTime>1) { EWOL_ERROR(" scene : " << localTime << "ms " << g_counterNbTimeDisplay); } else { EWOL_DEBUG(" scene : " << localTime << "ms " << g_counterNbTimeDisplay); } #endif }
void ewol::widget::Parameter::init() { ewol::widget::PopUp::init(); std::shared_ptr<ewol::widget::Sizer> mySizerVert = nullptr; std::shared_ptr<ewol::widget::Sizer> mySizerHori = nullptr; std::shared_ptr<ewol::widget::Spacer> mySpacer = nullptr; #ifdef __TARGET_OS__Android setMinSize(ewol::Dimension(vec2(90, 90), ewol::Dimension::Pourcent)); #else setMinSize(ewol::Dimension(vec2(80, 80), ewol::Dimension::Pourcent)); #endif mySizerVert = ewol::widget::Sizer::create(widget::Sizer::modeVert); if (nullptr == mySizerVert) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { EWOL_INFO("add widget"); mySizerVert->lockExpand(bvec2(true,true)); mySizerVert->setExpand(bvec2(true,true)); // set it in the pop-up-system : setSubWidget(mySizerVert); mySizerHori = ewol::widget::Sizer::create(widget::Sizer::modeHori); if (nullptr == mySizerHori) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerVert->subWidgetAdd(mySizerHori); mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(true,false)); mySizerHori->subWidgetAdd(mySpacer); } std::shared_ptr<ewol::widget::Button> tmpButton = widget::Button::create(); if (nullptr == tmpButton) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, "<composer>\n" " <sizer mode=\"hori\">\n" " <image src=\"THEME:GUI:Save.svg\" expand=\"true\" size=\"8,8mm\"/>\n" " <label>Save</label>\n" " </sizer>\n" "</composer>\n")); tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackParameterSave); mySizerHori->subWidgetAdd(tmpButton); } mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(false,false)); mySpacer->setMinSize(ewol::Dimension(vec2(10,0))); mySizerHori->subWidgetAdd(mySpacer); } tmpButton = ewol::widget::Button::create(); if (nullptr == tmpButton) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { tmpButton->setSubWidget(ewol::widget::Composer::create(widget::Composer::String, "<composer>\n" " <sizer mode=\"hori\">\n" " <image src=\"THEME:GUI:Remove.svg\" expand=\"true\" size=\"8,8mm\"/>\n" " <label>Close</label>\n" " </sizer>\n" "</composer>\n")); tmpButton->signalPressed.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuclosed); mySizerHori->subWidgetAdd(tmpButton); } } mySizerHori = ewol::widget::Sizer::create(widget::Sizer::modeHori); if (nullptr == mySizerHori) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerVert->subWidgetAdd(mySizerHori); m_paramList = ewol::widget::ParameterList::create(); if (nullptr == m_paramList) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { m_paramList->signalSelect.bind(shared_from_this(), &ewol::widget::Parameter::onCallbackMenuSelected); m_paramList->setFill(bvec2(false,true)); m_paramList->setExpand(bvec2(false,true)); mySizerHori->subWidgetAdd(m_paramList); } mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setFill(bvec2(false,true)); mySpacer->setMinSize(vec2(5,5)); mySpacer->setColor(0x000000BF); mySizerHori->subWidgetAdd(mySpacer); } std::shared_ptr<ewol::widget::Sizer> mySizerVert2 = widget::Sizer::create(widget::Sizer::modeVert); if (nullptr == mySizerVert2) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySizerHori->subWidgetAdd(mySizerVert2); mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(true,false)); mySpacer->setMinSize(vec2(5,5)); mySpacer->setColor(0x000000BF); mySizerVert2->subWidgetAdd(mySpacer); } m_wSlider = ewol::widget::WSlider::create(); if (nullptr == m_wSlider) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { m_wSlider->setTransitionSpeed(0.5); m_wSlider->setTransitionMode(ewol::widget::WSlider::sladingTransitionVert); m_wSlider->setExpand(bvec2(true,true)); mySizerVert2->subWidgetAdd(m_wSlider); } } } mySpacer = ewol::widget::Spacer::create(); if (nullptr == mySpacer) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { mySpacer->setExpand(bvec2(true,false)); mySpacer->setMinSize(vec2(5,5)); mySpacer->setColor(0x000000BF); mySizerVert->subWidgetAdd(mySpacer); } m_widgetTitle = ewol::widget::Label::create("File chooser ..."); if (nullptr == m_widgetTitle) { EWOL_ERROR("Can not allocate widget == > display might be in error"); } else { m_widgetTitle->setExpand(bvec2(true,false)); mySizerVert->subWidgetAdd(m_widgetTitle); } } markToRedraw(); }
void ewol::resource::TexturedFont::init(const std::string& _fontName) { std::unique_lock<std::recursive_mutex> lock(m_mutex); ewol::resource::Texture::init(_fontName); EWOL_DEBUG("Load font : '" << _fontName << "'" ); 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; m_modeWraping[2] = ewol::font::Regular; m_modeWraping[3] = ewol::font::Regular; m_lastGlyphPos[0].setValue(1,1); m_lastGlyphPos[1].setValue(1,1); m_lastGlyphPos[2].setValue(1,1); m_lastGlyphPos[3].setValue(1,1); m_lastRawHeigh[0] = 0; m_lastRawHeigh[1] = 0; m_lastRawHeigh[2] = 0; m_lastRawHeigh[3] = 0; int32_t tmpSize = 0; // extarct name and size : const char * tmpData = _fontName.c_str(); const char * tmpPos = strchr(tmpData, ':'); if (tmpPos == nullptr) { m_size = 1; 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 ???"); return; } } std::string localName(_fontName, 0, (tmpPos - tmpData)); if (tmpSize>400) { EWOL_ERROR("Font size too big ==> limit at 400 when exxeed ==> error : " << tmpSize << "==>30"); tmpSize = 30; } m_size = tmpSize; std::vector<std::string> folderList; if (true == ewol::getContext().getFontDefault().getUseExternal()) { #if defined(__TARGET_OS__Android) folderList.push_back("ROOT:system/fonts"); #elif defined(__TARGET_OS__Linux) folderList.push_back("ROOT:usr/share/fonts"); #endif } std::string applicationBaseFont = ewol::getContext().getFontDefault().getFolder(); std::vector<std::string> applicationBaseFontList = etk::FSNodeExplodeMultiplePath(applicationBaseFont); for (auto &it : applicationBaseFontList) { folderList.push_back(it); } for (size_t folderID=0; folderID<folderList.size() ; folderID++) { etk::FSNode myFolder(folderList[folderID]); // find the real Font name : std::vector<std::string> output; myFolder.folderGetRecursiveFiles(output); std::vector<std::string> split = etk::split(localName, ';'); EWOL_INFO("try to find font named : " << split << " in: " << myFolder); //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++) { //EWOL_DEBUG(" file : " << output[iii]); if( true == 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)) { EWOL_INFO(" find Font [Bold] : " << output[iii]); m_fileName[ewol::font::Bold] = output[iii]; hasFindAFont=true; } else if( 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 == 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)) { EWOL_INFO(" find Font [Italic] : " << output[iii]); m_fileName[ewol::font::Italic] = output[iii]; hasFindAFont=true; } else if( 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 == 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)) { EWOL_INFO(" find Font [Bold-Italic] : " << output[iii]); m_fileName[ewol::font::BoldItalic] = output[iii]; hasFindAFont=true; } else 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)) { EWOL_INFO(" find Font [Regular] : " << output[iii]); m_fileName[ewol::font::Regular] = output[iii]; hasFindAFont=true; } } if (hasFindAFont == true) { EWOL_INFO(" find this font : '" << split[jjj] << "'"); break; } else if (jjj == split.size()-1) { EWOL_ERROR("Find NO font in the LIST ... " << split); } } if (hasFindAFont == true) { EWOL_INFO(" find this font : '" << folderList[folderID] << "'"); break; } else if (folderID == folderList.size()-1) { EWOL_ERROR("Find NO font in the LIST ... " << folderList); } } // 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) { refMode = (enum ewol::font::mode)iii; } } 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) { m_modeWraping[iii] = (enum ewol::font::mode)iii; } else { m_modeWraping[iii] = refMode; } } 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] = nullptr; continue; } EWOL_INFO("Load FONT [" << iiiFontId << "] name : \"" << m_fileName[iiiFontId] << "\" == > size=" << m_size); m_font[iiiFontId] = ewol::resource::FontFreeType::create(m_fileName[iiiFontId]); 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] == nullptr) { continue; } m_height[iiiFontId] = m_font[iiiFontId]->getHeight(m_size); // TODO : basic font use 512 is better ... == > maybe estimate it with the dpi ??? setImageSize(ivec2(256,32)); // now we can acces directly on the image m_data.clear(etk::Color<>(0x00000000)); } // add error glyph addGlyph(0); // by default we set only the first AINSI char availlable for (int32_t iii=0x20; iii<0x7F; iii++) { EWOL_VERBOSE("Add clyph :" << iii); addGlyph(iii); } flush(); EWOL_DEBUG("Wrapping properties : "); EWOL_DEBUG(" " << ewol::font::Regular << " == >" << getWrappingMode(ewol::font::Regular)); EWOL_DEBUG(" " << ewol::font::Italic << " == >" << getWrappingMode(ewol::font::Italic)); EWOL_DEBUG(" " << ewol::font::Bold << " == >" << getWrappingMode(ewol::font::Bold)); EWOL_DEBUG(" " << ewol::font::BoldItalic << " == >" << getWrappingMode(ewol::font::BoldItalic)); }