diff --git a/build b/build index 5079829d..0e08561a 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit 5079829d049c9233370ffef084cb73c26459ced7 +Subproject commit 0e08561a5db3080036ffd546c98dcd0a95d6f4a9 diff --git a/external/ejson b/external/ejson index fbf39d9a..8cca9d9c 160000 --- a/external/ejson +++ b/external/ejson @@ -1 +1 @@ -Subproject commit fbf39d9ac20b7666f907154b58c8f7872bb1e271 +Subproject commit 8cca9d9ce2bed7715d3f6febb5f756728e515220 diff --git a/external/etk b/external/etk index 64d54ca8..fc6e425c 160000 --- a/external/etk +++ b/external/etk @@ -1 +1 @@ -Subproject commit 64d54ca8da34f71c5b1b98f50f6ae3902a136db9 +Subproject commit fc6e425cebc2bafc2d4169b8235878ae493e1545 diff --git a/monk b/monk index 3ce578da..7654eea3 160000 --- a/monk +++ b/monk @@ -1 +1 @@ -Subproject commit 3ce578dac170394152c12478d24f8fbc7e8b01f1 +Subproject commit 7654eea321b123e9af6b76f0d9e708e92d9448e4 diff --git a/sources/ewol/compositing/Text.cpp b/sources/ewol/compositing/Text.cpp index 05237bda..2f5e0971 100644 --- a/sources/ewol/compositing/Text.cpp +++ b/sources/ewol/compositing/Text.cpp @@ -184,7 +184,7 @@ void ewol::compositing::Text::reset(void) { m_startTextpos = 0; m_stopTextPos = 0; m_alignement = alignDisable; - m_htmlCurrrentLine = ""; + m_htmlCurrrentLine = U""; m_selectionStartPos = -100; m_cursorPos = -100; m_htmlDecoration.clear(); @@ -385,7 +385,7 @@ void ewol::compositing::Text::parseHtmlNode(exml::Element* _element) { // nothing to do ... } else if (_element->getType(iii) == exml::typeText) { exml::Node* child = _element->getNode(iii); - htmlAddData(child->getValue() ); + htmlAddData(std::to_u32string(child->getValue())); EWOL_VERBOSE("XML add : " << child->getValue()); continue; } else if (_element->getType(iii)!=exml::typeElement) { @@ -472,8 +472,16 @@ void ewol::compositing::Text::parseHtmlNode(exml::Element* _element) { void ewol::compositing::Text::printDecorated(const std::string& _text) { std::string tmpData("\n\n"); - tmpData+=_text; - tmpData+="\n\n\n"; + tmpData += _text; + tmpData += "\n\n\n"; + //EWOL_DEBUG("plop : " << tmpData); + printHTML(tmpData); +} + +void ewol::compositing::Text::printDecorated(const std::u32string& _text) { + std::u32string tmpData(U"\n\n"); + tmpData += _text; + tmpData += U"\n\n\n"; //EWOL_DEBUG("plop : " << tmpData); printHTML(tmpData); } @@ -506,6 +514,34 @@ void ewol::compositing::Text::printHTML(const std::string& _text) { htmlFlush(); } +void ewol::compositing::Text::printHTML(const std::u32string& _text) { + exml::Document doc; + + // reset parameter : + m_htmlDecoTmp.m_colorBg = etk::color::none; + m_htmlDecoTmp.m_colorFg = etk::color::black; + m_htmlDecoTmp.m_mode = ewol::font::Regular; + // TODO : Create an instance of xml parser to manage std::u32string... + if (doc.parse(std::to_string(_text)) == false) { + EWOL_ERROR( "can not load XML: PARSING error: Decorated text "); + return; + } + + exml::Element* root = (exml::Element*)doc.getNamed( "html" ); + if (root == NULL) { + EWOL_ERROR( "can not load XML: main node not find: \"html\""); + doc.display(); + return; + } + exml::Element* bodyNode = (exml::Element*)root->getNamed( "body" ); + if (root == NULL) { + EWOL_ERROR( "can not load XML: main node not find: \"body\""); + return; + } + (void)parseHtmlNode(bodyNode); + htmlFlush(); +} + void ewol::compositing::Text::print(const std::string& _text, const std::vector& _decoration) { if (m_font == NULL) { EWOL_ERROR("Font Id is not corectly defined"); @@ -1109,6 +1145,37 @@ vec3 ewol::compositing::Text::calculateSizeHTML(const std::string& _text) { m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); } +vec3 ewol::compositing::Text::calculateSizeHTML(const std::u32string& _text) { + // remove intermediate result + reset(); + //EWOL_DEBUG(" 0 size for=\n" << text); + // disable display system + m_needDisplay = false; + + setPos(vec3(0,0,0) ); + // same as print without the end display ... + printHTML(_text); + //EWOL_DEBUG(" 1 Start pos=" << m_sizeDisplayStart); + //EWOL_DEBUG(" 1 Stop pos=" << m_sizeDisplayStop); + + // get the last elements + m_sizeDisplayStop.setValue(etk_max(m_position.x(), m_sizeDisplayStop.x()) , + etk_max(m_position.y(), m_sizeDisplayStop.y()) , + 0); + m_sizeDisplayStart.setValue(etk_min(m_position.x(), m_sizeDisplayStart.x()) , + etk_min(m_position.y(), m_sizeDisplayStart.y()) , + 0); + + //EWOL_DEBUG(" 2 Start pos=" << m_sizeDisplayStart); + //EWOL_DEBUG(" 2 Stop pos=" << m_sizeDisplayStop); + // set back the display system + m_needDisplay = true; + + return vec3( m_sizeDisplayStop.x()-m_sizeDisplayStart.x(), + m_sizeDisplayStop.y()-m_sizeDisplayStart.y(), + m_sizeDisplayStop.z()-m_sizeDisplayStart.z()); +} + vec3 ewol::compositing::Text::calculateSizeDecorated(const std::string& _text) { if (_text.size() == 0) { return vec3(0,0,0); @@ -1120,6 +1187,17 @@ vec3 ewol::compositing::Text::calculateSizeDecorated(const std::string& _text) { return tmpVal; } +vec3 ewol::compositing::Text::calculateSizeDecorated(const std::u32string& _text) { + if (_text.size() == 0) { + return vec3(0,0,0); + } + std::u32string tmpData(U"\n"); + tmpData += _text; + tmpData += U"\n\n"; + vec3 tmpVal = calculateSizeHTML(tmpData); + return tmpVal; +} + vec3 ewol::compositing::Text::calculateSize(const std::string& _text) { if (m_font == NULL) { EWOL_ERROR("Font Id is not corectly defined"); @@ -1136,6 +1214,22 @@ vec3 ewol::compositing::Text::calculateSize(const std::string& _text) { return outputSize; } +vec3 ewol::compositing::Text::calculateSize(const std::u32string& _text) { + if (m_font == NULL) { + EWOL_ERROR("Font Id is not corectly defined"); + return vec3(0,0,0); + } + vec3 outputSize(0, 0, 0); + for(auto element : _text) { + vec3 tmpp = calculateSize(element); + if (outputSize.y() == 0) { + outputSize.setY(tmpp.y()); + } + outputSize.setX( outputSize.x() + tmpp.x()); + } + return outputSize; +} + vec3 ewol::compositing::Text::calculateSize(const char32_t& _charcode) { if (m_font == NULL) { EWOL_ERROR("Font Id is not corectly defined"); @@ -1296,10 +1390,10 @@ bool ewol::compositing::Text::extrapolateLastId(const std::u32string& _text, } } -void ewol::compositing::Text::htmlAddData(const std::string& _data) { +void ewol::compositing::Text::htmlAddData(const std::u32string& _data) { if( m_htmlCurrrentLine.size()>0 && m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') { - m_htmlCurrrentLine+=" "; + m_htmlCurrrentLine += U" "; if(m_htmlDecoration.size()>0) { TextDecoration tmp = m_htmlDecoration[m_htmlDecoration.size()-1]; m_htmlDecoration.push_back(tmp); @@ -1317,7 +1411,7 @@ void ewol::compositing::Text::htmlFlush(void) { if (m_htmlCurrrentLine.size()>0) { print(m_htmlCurrrentLine, m_htmlDecoration); } - m_htmlCurrrentLine = ""; + m_htmlCurrrentLine = U""; m_htmlDecoration.clear(); } diff --git a/sources/ewol/compositing/Text.h b/sources/ewol/compositing/Text.h index f281b436..efd42741 100644 --- a/sources/ewol/compositing/Text.h +++ b/sources/ewol/compositing/Text.h @@ -284,6 +284,8 @@ namespace ewol { * @TODO : implementation not done .... */ void printDecorated(const std::string& _text); + //! @previous + void printDecorated(const std::u32string& _text); /** * @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @@ -318,15 +320,15 @@ namespace ewol { * @TODO : implementation not done .... */ void printHTML(const std::string& _text); + //! @previous + void printHTML(const std::u32string& _text); /** * @brief display a compleat string in the current element whith specific decorations (advence mode). * @param[in] _text The string to display. * @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get) */ void print(const std::string& _text, const std::vector& _decoration); - /** - * @previous - */ + //! @previous void print(const std::u32string& _text, const std::vector& _decoration); /** * @brief display the current char in the current element (note that the kerning is availlable if the position is not changed) @@ -367,18 +369,24 @@ namespace ewol { * @return The theoric size used. */ vec3 calculateSizeHTML(const std::string& _text); + //!@previous + vec3 calculateSizeHTML(const std::u32string& _text); /** * @brief calculate a theoric text size * @param[in] _text The string to calculate dimention. * @return The theoric size used. */ vec3 calculateSizeDecorated(const std::string& _text); + //!@previous + vec3 calculateSizeDecorated(const std::u32string& _text); /** * @brief calculate a theoric text size * @param[in] _text The string to calculate dimention. * @return The theoric size used. */ vec3 calculateSize(const std::string& _text); + //!@previous + vec3 calculateSize(const std::u32string& _text); /** * @brief calculate a theoric charcode size * @param[in] _charcode The ľUnicode value to calculate dimention. @@ -410,14 +418,14 @@ namespace ewol { bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); private: // this section is reserved for HTML parsing and display: - std::string m_htmlCurrrentLine; //!< current line for HTML display + std::u32string m_htmlCurrrentLine; //!< current line for HTML display std::vector m_htmlDecoration; //!< current decoration for the HTML display TextDecoration m_htmlDecoTmp; //!< current decoration /** * @brief add a line with the current m_htmlDecoTmp decoration * @param[in] _data The cuurent data to add. */ - void htmlAddData(const std::string& _data); + void htmlAddData(const std::u32string& _data); /** * @brief draw the current line */ diff --git a/sources/ewol/widget/Label.cpp b/sources/ewol/widget/Label.cpp index bd55b5a5..9ca623d1 100644 --- a/sources/ewol/widget/Label.cpp +++ b/sources/ewol/widget/Label.cpp @@ -28,7 +28,7 @@ void ewol::widget::Label::init(ewol::widget::Manager& _widgetManager) { ewol::widget::Label::Label(std::string _newLabel) { addObjectType("ewol::widget::Label"); - m_label = _newLabel; + m_label = std::to_u32string(_newLabel); addEventId(eventPressed); setCanHaveFocus(false); registerConfig(configValue, "string", NULL, "displayed value string"); // TODO : do not store in attibute... @@ -51,13 +51,13 @@ void ewol::widget::Label::calculateMinMaxSize(void) { } void ewol::widget::Label::setLabel(const std::string& _newLabel) { - m_label = _newLabel; + m_label = std::to_u32string(_newLabel); markToRedraw(); requestUpdateSize(); } std::string ewol::widget::Label::getLabel(void) const { - return m_label; + return std::to_string(m_label); } void ewol::widget::Label::onDraw(void) { diff --git a/sources/ewol/widget/Label.h b/sources/ewol/widget/Label.h index 45548b26..3eef7fa7 100644 --- a/sources/ewol/widget/Label.h +++ b/sources/ewol/widget/Label.h @@ -32,7 +32,7 @@ namespace ewol { static void init(ewol::widget::Manager& _widgetManager); private: ewol::compositing::Text m_text; //!< Compositing text element. - std::string m_label; //!< decorated text to display. + std::u32string m_label; //!< decorated text to display. public: /** * @brief Constructor