void ewol::Widget::periodicCallEnable() { if (getObjectManager().periodicCall.isRegistered(shared_from_this()) == true) { EWOL_VERBOSE("Perodic call enable " << getName() << " ==> rejected"); return; } else { EWOL_VERBOSE("Perodic call enable " << getName()); } getObjectManager().periodicCall.bind(shared_from_this(), &ewol::Widget::periodicCall); }
// clean all Object that request an autoRemove ... void ewol::object::Manager::cleanInternalRemoved() { size_t nbObject = m_eObjectList.size(); EWOL_VERBOSE("Clean Object List (if needed) : " << m_eObjectList.size() << " elements"); auto it(m_eObjectList.begin()); while (it != m_eObjectList.end()) { if (it->expired() == true) { it = m_eObjectList.erase(it); } else { ++it; } } if (m_eObjectList.size() != nbObject) { EWOL_VERBOSE(" remove " << nbObject - m_eObjectList.size() << " deprecated objects"); } }
bool ewol::widget::ListFileSystem::getElement(int32_t _colomn, int32_t _raw, std::string& _myTextToWrite, etk::Color<>& _fg, etk::Color<>& _bg) { int32_t offset = 0; if (m_showFolder == true) { if (m_folder.get() == "/") { offset = 1; } else { offset = 2; } if (_raw == 0) { _myTextToWrite = "."; } else if ( _raw == 1 && m_folder.get() != "/") { _myTextToWrite = ".."; } } if( _raw-offset >= 0 && _raw-offset < (int32_t)m_list.size() && nullptr != m_list[_raw-offset]) { _myTextToWrite = m_list[_raw-offset]->getNameFile(); EWOL_VERBOSE("get filename for : '" << *m_list[_raw-offset] << ":'" << _myTextToWrite << "'"); } _fg = m_colorProperty->get(m_colorIdText); if (_raw % 2) { _bg = m_colorProperty->get(m_colorIdBackground1); } else { _bg = m_colorProperty->get(m_colorIdBackground2); } if (m_selectedLine == _raw) { _bg = m_colorProperty->get(m_colorIdBackgroundSelected); } return true; };
bool ewol::widget::Slider::onEventInput(const ewol::event::Input& _event) { vec2 relativePos = relativePosition(_event.getPos()); //EWOL_DEBUG("Event on Slider ..." << _event); if (1 == _event.getId()) { if( gale::key::status_single == _event.getStatus() || gale::key::status_move == _event.getStatus()) { // get the new position : EWOL_VERBOSE("Event on Slider (" << relativePos.x() << "," << relativePos.y() << ")"); float oldValue = m_value.get(); updateValue(m_min + (float)(relativePos.x() - dotRadius) / (m_size.x()-2*dotRadius) * (m_max-m_min)); if (oldValue != m_value) { EWOL_VERBOSE(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]"); signalChange.emit(m_value); } return true; } } return false; }
// internal generic keeper ... std::shared_ptr<ewol::Resource> ewol::resource::Manager::localKeep(const std::string& _filename) { EWOL_VERBOSE("KEEP (DEFAULT) : file : '" << _filename << "' in " << m_resourceList.size() << " resources"); for (auto &it : m_resourceList) { std::shared_ptr<ewol::Resource> tmpRessource = it.lock(); if (tmpRessource != nullptr) { if (tmpRessource->getName() == _filename) { return tmpRessource; } } } return nullptr; }
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::widget::Image::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) { ewol::Widget::onParameterChangeValue(_paramPointer); if ( _paramPointer == m_fileName || _paramPointer == m_imageSize) { markToRedraw(); requestUpdateSize(); EWOL_VERBOSE("Set sources : " << m_fileName << " size=" << m_imageSize); m_compositing.setSource(m_fileName, m_imageSize->getPixel()); } else if ( _paramPointer == m_border || _paramPointer == m_keepRatio || _paramPointer == m_posStart || _paramPointer == m_posStop) { markToRedraw(); requestUpdateSize(); } else if (_paramPointer == m_distanceFieldMode) { markToRedraw(); } else if (_paramPointer == m_smooth) { markToRedraw(); } }
void ewol::Widget::periodicCallDisable() { EWOL_VERBOSE("Perodic call disable " << getName()); getObjectManager().periodicCall.release(shared_from_this()); }
bool ewol::widget::ColorBar::onEventInput(const ewol::event::Input& _event) { vec2 relativePos = relativePosition(_event.getPos()); //EWOL_DEBUG("Event on BT ..."); if (1 == _event.getId()) { relativePos.setValue( std::avg(0.0f, m_size.x(),relativePos.x()), std::avg(0.0f, m_size.y(),relativePos.y()) ); if( gale::key::status_single == _event.getStatus() || gale::key::status_move == _event.getStatus()) { // nothing to do ... m_currentUserPos.setValue( relativePos.x()/m_size.x(), relativePos.y()/m_size.y() ); markToRedraw(); // == > try to estimate color EWOL_VERBOSE("event on (" << relativePos.x() << "," << relativePos.y() << ")"); int32_t bandID = (int32_t)(relativePos.x()/(m_size.x()/6)); float localPos = relativePos.x() - (m_size.x()/6) * bandID; float poroportionnalPos = localPos/(m_size.x()/6); EWOL_VERBOSE("bandId=" << bandID << " relative pos=" << localPos); etk::Color<> estimateColor = etk::color::white; if (s_listColor[bandID].r() == s_listColor[bandID+1].r()) { estimateColor.setR(s_listColor[bandID].r()); } else if (s_listColor[bandID].r() < s_listColor[bandID+1].r()) { estimateColor.setR(s_listColor[bandID].r() + (s_listColor[bandID+1].r()-s_listColor[bandID].r())*poroportionnalPos); } else { estimateColor.setR(s_listColor[bandID+1].r() + (s_listColor[bandID].r()-s_listColor[bandID+1].r())*(1-poroportionnalPos)); } if (s_listColor[bandID].g() == s_listColor[bandID+1].g()) { estimateColor.setG(s_listColor[bandID].g()); } else if (s_listColor[bandID].g() < s_listColor[bandID+1].g()) { estimateColor.setG(s_listColor[bandID].g() + (s_listColor[bandID+1].g()-s_listColor[bandID].g())*poroportionnalPos); } else { estimateColor.setG(s_listColor[bandID+1].g() + (s_listColor[bandID].g()-s_listColor[bandID+1].g())*(1-poroportionnalPos)); } if (s_listColor[bandID].b() == s_listColor[bandID+1].b()) { estimateColor.setB(s_listColor[bandID].b()); } else if (s_listColor[bandID].b() < s_listColor[bandID+1].b()) { estimateColor.setB(s_listColor[bandID].b() + (s_listColor[bandID+1].b()-s_listColor[bandID].b())*poroportionnalPos); } else { estimateColor.setB(s_listColor[bandID+1].b() + (s_listColor[bandID].b()-s_listColor[bandID+1].b())*(1-poroportionnalPos)); } // step 2 generate the white and black ... if (m_currentUserPos.y() == 0.5) { // nothing to do ... just get the current color ... } else if (m_currentUserPos.y() < 0.5) { float poroportionnalWhite = (0.5-m_currentUserPos.y())*2.0; estimateColor.setR(estimateColor.r() + (0xFF-estimateColor.r())*poroportionnalWhite); estimateColor.setG(estimateColor.g() + (0xFF-estimateColor.g())*poroportionnalWhite); estimateColor.setB(estimateColor.b() + (0xFF-estimateColor.b())*poroportionnalWhite); } else { float poroportionnalBlack = (m_currentUserPos.y()-0.5)*2.0; estimateColor.setR(estimateColor.r() - estimateColor.r()*poroportionnalBlack); estimateColor.setG(estimateColor.g() - estimateColor.g()*poroportionnalBlack); estimateColor.setB(estimateColor.b() - estimateColor.b()*poroportionnalBlack); } if(m_currentColor != estimateColor) { m_currentColor = estimateColor; signalChange.emit(m_currentColor); } return true; } } return false; }
void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) { //EWOL_DEBUG("CalculateSize=" << availlable); // pop-up fill all the display : m_size = _availlable; ewol::Padding padding = m_shaper->getPadding(); EWOL_VERBOSE("our origin=" << m_origin << " size=" << m_size); if (nullptr != m_subWidget) { vec2 subWidgetSize; vec2 subWidgetOrigin; subWidgetSize = m_subWidget->getCalculateMinSize(); if (true == m_subWidget->canExpand().x()) { subWidgetSize.setX(m_size.x()); } if (true == m_subWidget->canExpand().y()) { subWidgetSize.setY(m_size.y()); } int32_t minWidth = 100; int32_t maxWidth = 300; subWidgetSize.setX((int32_t)std::max(minWidth, (int32_t)subWidgetSize.x())); subWidgetSize.setX((int32_t)std::min(maxWidth, (int32_t)subWidgetSize.x())); subWidgetSize.setY((int32_t)subWidgetSize.y()); // set config to the Sub-widget switch (m_arrawBorder) { case markTop: subWidgetOrigin.setX((int32_t)(m_arrowPos->x() - subWidgetSize.x()/2)); subWidgetOrigin.setY((int32_t)(m_arrowPos->y() - m_offset - subWidgetSize.y())); break; case markButtom: subWidgetOrigin.setX((int32_t)(m_arrowPos->x() - subWidgetSize.x()/2)); subWidgetOrigin.setY((int32_t)(m_arrowPos->y() + m_offset)); break; case markRight: case markLeft: default: subWidgetOrigin.setX((int32_t)(m_size.x() - m_origin.x() - subWidgetSize.x())/2 + m_origin.x()); subWidgetOrigin.setY((int32_t)(m_size.y() - m_origin.y() - subWidgetSize.y())/2 + m_origin.y()); break; } // set the widget position at the border of the screen subWidgetOrigin.setX( (int32_t)( std::max(0, (int32_t)(subWidgetOrigin.x()-padding.x())) + padding.x()) ); subWidgetOrigin.setY( (int32_t)( std::max(0, (int32_t)(subWidgetOrigin.y()-padding.y())) + padding.y()) ); switch (m_arrawBorder) { default: case markTop: case markButtom: if (m_arrowPos->x() <= m_offset ) { subWidgetOrigin.setX(m_arrowPos->x()+padding.xLeft()); } break; case markRight: case markLeft: if (m_arrowPos->y() <= m_offset ) { subWidgetOrigin.setY(m_arrowPos->y()+padding.yButtom()); } break; } EWOL_VERBOSE(" == > sub origin=" << subWidgetOrigin << " size=" << subWidgetSize); m_subWidget->setOrigin(subWidgetOrigin); m_subWidget->calculateSize(subWidgetSize); } markToRedraw(); }
bool ewol::widget::Button::onEventInput(const ewol::event::Input& _event) { EWOL_VERBOSE("Event on BT : " << _event); // disable event in the lock access mode : if(ewol::widget::Button::lockAccess == *propertyLock) { return false; } if( gale::key::status::leave == _event.getStatus() || gale::key::status::abort == _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; } } EWOL_VERBOSE("Event on BT ... mouse hover : " << m_mouseHover); if (true == m_mouseHover) { if (1 == _event.getId()) { if(gale::key::status::down == _event.getStatus()) { EWOL_VERBOSE(*propertyName << " : Generate event : " << signalDown); signalDown.emit(); m_buttonPressed = true; markToRedraw(); } if(gale::key::status::up == _event.getStatus()) { EWOL_VERBOSE(*propertyName << " : Generate event : " << signalUp); signalUp.emit(); m_buttonPressed = false; markToRedraw(); } if(gale::key::status::pressSingle == _event.getStatus()) { if( ( *propertyValue == true && ewol::widget::Button::lockWhenPressed == propertyLock) || ( *propertyValue == false && ewol::widget::Button::lockWhenReleased == propertyLock) ) { // nothing to do : Lock mode ... // user might set himself the new correct value with @ref setValue(xxx) } else { // inverse value : propertyValue.set((*propertyValue)?false:true); EWOL_VERBOSE(*propertyName << " : Generate event : " << signalPressed); signalPressed.emit(); EWOL_VERBOSE(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue ); signalValue.emit(*propertyValue); if( *propertyToggleMode == false && *propertyValue == true) { propertyValue.set(false); EWOL_VERBOSE(*propertyName << " : Generate event : " << signalValue << " val=" << *propertyValue); signalValue.emit(*propertyValue); } } markToRedraw(); } } } CheckStatus(); return m_mouseHover; }
void ewol::widget::Button::onLostFocus() { m_buttonPressed = false; EWOL_VERBOSE(propertyName.get() << " : Remove Focus ..."); CheckStatus(); }
void ewol::widget::Image::onRegenerateDisplay() { if (true == needRedraw()) { // remove data of the previous composition : m_compositing.clear(); if (m_colorProperty != nullptr) { m_compositing.setColor(m_colorProperty->get(m_colorId)); } // calculate the new position and size : vec2 imageBoder = m_border->getPixel(); vec2 origin = imageBoder; imageBoder *= 2.0f; vec2 imageRealSize = m_imageRenderSize - imageBoder; vec2 imageRealSizeMax = m_size - imageBoder; vec2 ratioSizeDisplayRequested = m_posStop.get() - m_posStart.get(); //imageRealSizeMax *= ratioSizeDisplayRequested; if (m_userFill->x() == true) { imageRealSize.setX(imageRealSizeMax.x()); } else { switch(m_gravity) { case gravityCenter: case gravityTop: case gravityButtom: origin.setX(origin.x() + (m_size.x()-m_imageRenderSize.x())*0.5f); break; case gravityTopLeft: case gravityButtomLeft: case gravityLeft: // nothing to do ... break; case gravityTopRight: case gravityRight: case gravityButtomRight: origin.setX(origin.x() + (m_size.x()-m_imageRenderSize.x())*0.5f); break; } } if (m_userFill->y() == true) { imageRealSize.setY(imageRealSizeMax.y()); } else { // switch(m_gravity) { case gravityCenter: case gravityRight: case gravityLeft: origin.setY(origin.y() + (m_size.y()-m_imageRenderSize.y())*0.5f); break; case gravityTopLeft: case gravityTop: case gravityTopRight: origin.setY(origin.y() + (m_size.y()-m_imageRenderSize.y())); break; case gravityButtomRight: case gravityButtom: case gravityButtomLeft: // nothing to do ... break; } } if (m_keepRatio == true) { vec2 tmpSize = m_compositing.getRealSize(); //float ratio = tmpSize.x() / tmpSize.y(); float ratio = (tmpSize.x()*ratioSizeDisplayRequested.x()) / (tmpSize.y() * ratioSizeDisplayRequested.y()); //float ratioCurrent = (imageRealSize.x()*ratioSizeDisplayRequested.x()) / (imageRealSize.y() * ratioSizeDisplayRequested.y()); float ratioCurrent = imageRealSize.x() / imageRealSize.y(); if (ratio == ratioCurrent) { // nothing to do ... } else if (ratio < ratioCurrent) { float oldX = imageRealSize.x(); imageRealSize.setX(imageRealSize.y()*ratio); origin += vec2((oldX - imageRealSize.x()) * 0.5f, 0); } else { float oldY = imageRealSize.y(); imageRealSize.setY(imageRealSize.x()/ratio); origin += vec2(0, (oldY - imageRealSize.y()) * 0.5f); } } // set the somposition properties : if (m_smooth.get() == true) { m_compositing.setPos(origin); } else { m_compositing.setPos(ivec2(origin)); } m_compositing.printPart(imageRealSize, m_posStart, m_posStop); //EWOL_DEBUG("Paint Image at : " << origin << " size=" << imageRealSize << " origin=" << origin); EWOL_VERBOSE("Paint Image :" << m_fileName << " realsize=" << m_compositing.getRealSize() << " size=" << imageRealSize); } }
void ewol::widget::Image::set(const std::string& _file, const gale::Dimension& _border) { EWOL_VERBOSE("Set Image : " << _file << " border=" << _border); m_border.set(_border); m_fileName.set(_file); }
ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const std::string& _filename, ivec2 _size, ivec2 _sizeRegister) { EWOL_VERBOSE("KEEP: TextureFile: '" << _filename << "' size=" << _size << " sizeRegister=" << _sizeRegister); if (_filename == "") { ememory::SharedPtr<ewol::resource::TextureFile> object(new ewol::resource::TextureFile()); if (object == nullptr) { EWOL_ERROR("allocation error of a resource : ??TEX??"); return nullptr; } object->init(); getManager().localAdd(object); return object; } if (_size.x() == 0) { _size.setX(-1); //EWOL_ERROR("Error Request the image size.x() =0 ???"); } if (_size.y() == 0) { _size.setY(-1); //EWOL_ERROR("Error Request the image size.y() =0 ???"); } std::string tmpFilename = _filename; if (etk::end_with(_filename, ".svg") == false) { _size = ewol::resource::TextureFile::sizeAuto; } if (_size.x()>0 && _size.y()>0) { EWOL_VERBOSE(" == > specific size : " << _size); #if defined(__TARGET_OS__Android) \ || defined(__TARGET_OS__MacOs) \ || defined(__TARGET_OS__IOs) _size.setValue(nextP2(_size.x()), nextP2(_size.y())); #endif if (_sizeRegister != ewol::resource::TextureFile::sizeAuto) { if (_sizeRegister != ewol::resource::TextureFile::sizeDefault) { tmpFilename += ":"; tmpFilename += etk::to_string(_size.x()); tmpFilename += "x"; tmpFilename += etk::to_string(_size.y()); } } } EWOL_VERBOSE("KEEP: TextureFile: '" << tmpFilename << "' new size=" << _size); ememory::SharedPtr<ewol::resource::TextureFile> object = nullptr; ememory::SharedPtr<gale::Resource> object2 = getManager().localKeep(tmpFilename); if (object2 != nullptr) { object = ememory::dynamicPointerCast<ewol::resource::TextureFile>(object2); if (object == nullptr) { EWOL_CRITICAL("Request resource file : '" << tmpFilename << "' With the wrong type (dynamic cast error)"); return nullptr; } } if (object != nullptr) { return object; } EWOL_INFO("CREATE: TextureFile: '" << tmpFilename << "' size=" << _size); // need to crate a new one ... object = ememory::SharedPtr<ewol::resource::TextureFile>(new ewol::resource::TextureFile()); if (object == nullptr) { EWOL_ERROR("allocation error of a resource : " << _filename); return nullptr; } object->init(tmpFilename, _filename, _size); getManager().localAdd(object); return object; }
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)); }
bool ewol::widget::ListFileSystem::onItemEvent(int32_t _IdInput, enum gale::key::status _typeEvent, int32_t _colomn, int32_t _raw, float _x, float _y) { int32_t offset = 0; if (m_showFolder == true) { if (m_folder.get() == "/") { offset = 1; } else { offset = 2; } } if (_typeEvent == gale::key::status_single) { EWOL_VERBOSE("Event on List : IdInput=" << _IdInput << " colomn=" << _colomn << " raw=" << _raw ); if (1 == _IdInput) { int32_t previousRaw = m_selectedLine; if (_raw > (int32_t)m_list.size()+offset ) { m_selectedLine = -1; } else { m_selectedLine = _raw; } if (previousRaw != m_selectedLine) { if( m_showFolder == true && m_selectedLine == 0) { // "." folder signalFolderSelect.emit("."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder signalFolderSelect.emit(".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { // generate event extern : switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : signalFileSelect.emit(m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : signalFolderSelect.emit(m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); break; } } } else { if( m_showFolder == true && m_selectedLine == 0) { // "." folder signalFolderValidate.emit("."); } else if ( m_showFolder == true && m_selectedLine == 1) { // ".." folder signalFolderValidate.emit(".."); } else if( m_selectedLine-offset >= 0 && m_selectedLine-offset < (int32_t)m_list.size() && nullptr != m_list[m_selectedLine-offset] ) { switch(m_list[m_selectedLine-offset]->getNodeType()) { case etk::FSN_FILE : signalFileValidate.emit(m_list[m_selectedLine-offset]->getNameFile()); break; case etk::FSN_FOLDER : signalFolderValidate.emit(m_list[m_selectedLine-offset]->getNameFile()); break; default: EWOL_ERROR("Can not generate event on an unknow type"); break; } } } // need to regenerate the display of the list : markToRedraw(); return true; } } return false; }