[DEBUG work again

This commit is contained in:
Edouard DUPIN 2013-11-14 21:40:30 +01:00
parent 905091d3fd
commit 971905b0d5
9 changed files with 343 additions and 79 deletions

2
external/ejson vendored

@ -1 +1 @@
Subproject commit 666605419cfab90d858f5687659a10e28146d97e Subproject commit 564ec3130f3874c3bcc2235976f2d85996c4f770

2
external/etk vendored

@ -1 +1 @@
Subproject commit d2a3fcaa63f1d942fcaafb205b806b37ad804090 Subproject commit 4f25fd3ddc690dc066d81b601b9287c260a447fe

View File

@ -362,11 +362,17 @@ void ewol::Text::setDistanceFieldMode(bool _newMode) {
EWOL_TODO("The Distance field mode is not availlable for now ..."); EWOL_TODO("The Distance field mode is not availlable for now ...");
} }
void ewol::Text::print(const std::u32string& _text) {
std::vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty);
}
void ewol::Text::print(const std::string& _text) { void ewol::Text::print(const std::string& _text) {
std::vector<TextDecoration> decorationEmpty; std::vector<TextDecoration> decorationEmpty;
print(_text, decorationEmpty); print(_text, decorationEmpty);
} }
void ewol::Text::parseHtmlNode(exml::Element* _element) { void ewol::Text::parseHtmlNode(exml::Element* _element) {
// get the static real pointer // get the static real pointer
if (_element == NULL) { if (_element == NULL) {
@ -686,6 +692,194 @@ void ewol::Text::print(const std::string& _text, const std::vector<TextDecoratio
//EWOL_DEBUG(" 4 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position); //EWOL_DEBUG(" 4 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position);
} }
} }
void ewol::Text::print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration) {
if (m_font == NULL) {
EWOL_ERROR("Font Id is not corectly defined");
return;
}
etk::Color<> tmpFg(m_color);
etk::Color<> tmpBg(m_colorBg);
if (m_alignement == ewol::Text::alignDisable) {
//EWOL_DEBUG(" 1 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position);
// display the cursor if needed (if it is at the start position...)
if (m_needDisplay == true) {
if (0 == m_cursorPos) {
m_vectorialDraw.setPos(m_position);
setColorBg(m_colorCursor);
printCursor(false);
}
}
// note this is faster when nothing is requested ...
for(int32_t iii=0; iii<_text.size(); iii++) {
// check if ve have decoration
if (iii<_decoration.size()) {
tmpFg = _decoration[iii].m_colorFg;
tmpBg = _decoration[iii].m_colorBg;
setFontMode(_decoration[iii].m_mode);
}
// if real display : ( not display is for size calculation)
if (m_needDisplay == true) {
if( ( m_selectionStartPos-1<iii
&& iii <= m_cursorPos-1)
|| ( m_selectionStartPos-1 >= iii
&& iii > m_cursorPos-1) ) {
setColor( 0x000000FF);
setColorBg(m_colorSelection);
} else {
setColor( tmpFg);
setColorBg(tmpBg);
}
}
if( m_needDisplay == true
&& m_colorBg.a() != 0) {
vec3 pos = m_position;
m_vectorialDraw.setPos(pos);
print(_text[iii]);
float fontHeigh = m_font->getHeight(m_mode);
m_vectorialDraw.rectangleWidth(vec3(m_position.x()-pos.x(),fontHeigh,0.0f) );
m_nbCharDisplayed++;
} else {
print(_text[iii]);
m_nbCharDisplayed++;
}
// display the cursor if needed (if it is at the other position...)
if (m_needDisplay == true) {
if (iii == m_cursorPos-1) {
m_vectorialDraw.setPos(m_position);
setColorBg(m_colorCursor);
printCursor(false);
}
}
}
//EWOL_DEBUG(" 2 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position);
} else {
//EWOL_DEBUG(" 3 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position);
// special start case at the right of the endpoint :
if (m_stopTextPos < m_position.x()) {
forceLineReturn();
}
float basicSpaceWidth = calculateSize(char32_t(' ')).x();
int32_t currentId = 0;
int32_t stop;
int32_t space;
int32_t freeSpace;
while (currentId < _text.size()) {
bool needNoJustify = extrapolateLastId(_text, currentId, stop, space, freeSpace);
float interpolation = basicSpaceWidth;
switch (m_alignement) {
case ewol::Text::alignJustify:
if (needNoJustify == false) {
interpolation += (float)freeSpace / (float)(space-1);
}
break;
case ewol::Text::alignDisable: // must not came from here ...
case ewol::Text::alignLeft:
// nothing to do ...
break;
case ewol::Text::alignRight:
if (m_needDisplay == true) {
// Move the first char at the right :
setPos(vec3(m_position.x() + freeSpace,
m_position.y(),
m_position.z()) );
}
break;
case ewol::Text::alignCenter:
if (m_needDisplay == true) {
// Move the first char at the right :
setPos(vec3(m_position.x() + freeSpace/2,
m_position.y(),
m_position.z()) );
}
break;
}
// display all the elements
if( m_needDisplay == true
&& m_cursorPos == 0) {
m_vectorialDraw.setPos(m_position);
setColorBg(m_colorCursor);
printCursor(false);
}
for(int32_t iii=currentId; iii<stop && iii<_text.size(); iii++) {
float fontHeigh = m_font->getHeight(m_mode);
// get specific decoration if provided
if (iii<_decoration.size()) {
tmpFg = _decoration[iii].m_colorFg;
tmpBg = _decoration[iii].m_colorBg;
setFontMode(_decoration[iii].m_mode);
}
if (m_needDisplay == true) {
if( ( m_selectionStartPos-1<iii
&& iii <= m_cursorPos-1)
|| ( m_selectionStartPos-1 >= iii
&& iii > m_cursorPos-1) ) {
setColor( 0x000000FF);
setColorBg(m_colorSelection);
} else {
setColor( tmpFg);
setColorBg(tmpBg);
}
}
// special for the justify mode
if (_text[iii] == etk::UChar::Space) {
//EWOL_DEBUG(" generateString : \" \"");
if( m_needDisplay == true
&& m_colorBg.a() != 0) {
m_vectorialDraw.setPos(m_position);
}
// Must generate a dynamic space :
setPos(vec3(m_position.x() + interpolation,
m_position.y(),
m_position.z()) );
if( m_needDisplay == true
&& m_colorBg.a() != 0) {
m_vectorialDraw.rectangleWidth(vec3(interpolation,fontHeigh,0.0f) );
}
} else {
//EWOL_DEBUG(" generateString : \"" << (char)text[iii] << "\"");
if( m_needDisplay == true
&& m_colorBg.a() != 0) {
vec3 pos = m_position;
m_vectorialDraw.setPos(pos);
print(_text[iii]);
m_vectorialDraw.rectangleWidth(vec3(m_position.x()-pos.x(),fontHeigh,0.0f) );
m_nbCharDisplayed++;
} else {
print(_text[iii]);
m_nbCharDisplayed++;
}
}
if (m_needDisplay == true) {
if (iii == m_cursorPos-1) {
m_vectorialDraw.setPos(m_position);
setColorBg(m_colorCursor);
printCursor(false);
}
}
}
if (currentId == stop) {
currentId++;
} else if(_text[stop] == etk::UChar::Space) {
currentId = stop+1;
// reset position :
setPos(vec3(m_startTextpos,
(float)(m_position.y() - m_font->getHeight(m_mode)),
m_position.z()) );
m_nbCharDisplayed++;
} else if(_text[stop] == etk::UChar::Return) {
currentId = stop+1;
// reset position :
setPos(vec3(m_startTextpos,
(float)(m_position.y() - m_font->getHeight(m_mode)),
m_position.z()) );
m_nbCharDisplayed++;
} else {
currentId = stop;
}
}
//EWOL_DEBUG(" 4 print in not alligned mode : start=" << m_sizeDisplayStart << " stop=" << m_sizeDisplayStop << " pos=" << m_position);
}
}
void ewol::Text::print(const char32_t& _charcode) { void ewol::Text::print(const char32_t& _charcode) {
@ -1038,6 +1232,69 @@ bool ewol::Text::extrapolateLastId(const std::string& _text,
} }
} }
bool ewol::Text::extrapolateLastId(const std::u32string& _text,
const int32_t _start,
int32_t& _stop,
int32_t& _space,
int32_t& _freeSpace) {
// store previous :
char32_t storePrevious = m_previousCharcode;
_stop = _text.size();
_space = 0;
int32_t lastSpacePosition = _start;
int32_t lastSpacefreeSize;
float endPos = m_position.x();
bool endOfLine = false;
float stopPosition = m_stopTextPos;
if( m_needDisplay == false
|| m_stopTextPos == m_startTextpos) {
stopPosition = m_startTextpos + 3999999999.0;
}
for (int32_t iii=_start; iii<_text.size(); iii++) {
vec3 tmpSize = calculateSize(_text[iii]);
// check oveflow :
if (endPos + tmpSize.x() > stopPosition) {
_stop = iii;
break;
}
// save number of space :
if (_text[iii] == etk::UChar::Space) {
_space++;
lastSpacePosition = iii;
lastSpacefreeSize = stopPosition - endPos;
} else if (_text[iii] == etk::UChar::Return) {
_stop = iii;
endOfLine = true;
break;
}
// update local size :
endPos += tmpSize.x();
}
_freeSpace = stopPosition - endPos;
// retore previous :
m_previousCharcode = storePrevious;
// need to align left or right ...
if(_stop == _text.size()) {
return true;
} else {
if (endOfLine) {
return true;
} else {
if (_space == 0) {
return true;
}
_stop = lastSpacePosition;
_freeSpace = lastSpacefreeSize;
return false;
}
}
}
void ewol::Text::htmlAddData(const std::string& _data) { void ewol::Text::htmlAddData(const std::string& _data) {
if( m_htmlCurrrentLine.size()>0 if( m_htmlCurrrentLine.size()>0
&& m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') { && m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') {

View File

@ -16,6 +16,7 @@
#include <ewol/compositing/Drawing.h> #include <ewol/compositing/Drawing.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <exml/exml.h> #include <exml/exml.h>
#include <string>
namespace ewol { namespace ewol {
/** /**
@ -236,6 +237,7 @@ namespace ewol {
* @param[in] _text The string to display. * @param[in] _text The string to display.
*/ */
void print(const std::string& _text); void print(const std::string& _text);
void print(const std::u32string& _text);
/** /**
* @brief display a compleat string in the current element with the generic decoration specification. (basic html data) * @brief display a compleat string in the current element with the generic decoration specification. (basic html data)
* <pre> * <pre>
@ -302,6 +304,7 @@ namespace ewol {
* @param[in] _decoration The text decoration for the text that might be display (if the vector is smaller, the last parameter is get) * @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<TextDecoration>& _decoration); void print(const std::string& _text, const std::vector<TextDecoration>& _decoration);
void print(const std::u32string& _text, const std::vector<TextDecoration>& _decoration);
/** /**
* @brief display the current char in the current element (note that the kerning is availlable if the position is not changed) * @brief display the current char in the current element (note that the kerning is availlable if the position is not changed)
* @param[in] _charcode Char that might be dispalyed * @param[in] _charcode Char that might be dispalyed
@ -376,6 +379,7 @@ namespace ewol {
* @return true if the rifht has free space that can be use for jystify (return false if we find \n * @return true if the rifht has free space that can be use for jystify (return false if we find \n
*/ */
bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace); bool extrapolateLastId(const std::string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
bool extrapolateLastId(const std::u32string& _text, const int32_t _start, int32_t& _stop, int32_t& _space, int32_t& _freeSpace);
private: private:
// this section is reserved for HTML parsing and display: // this section is reserved for HTML parsing and display:
std::string m_htmlCurrrentLine; //!< current line for HTML display std::string m_htmlCurrrentLine; //!< current line for HTML display

View File

@ -67,10 +67,12 @@ void ewol::EObject::generateEventId(const char * _generateEventId, const std::st
if (NULL != m_externEvent[iii]->destEObject) { if (NULL != m_externEvent[iii]->destEObject) {
if (m_externEvent[iii]->overloadData.size() <= 0){ if (m_externEvent[iii]->overloadData.size() <= 0){
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, _data); ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, _data);
EWOL_VERBOSE("send message " << tmpMsg);
m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg); m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg);
} else { } else {
// set the user requested data ... // set the user requested data ...
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData); ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
EWOL_VERBOSE("send message " << tmpMsg);
m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg); m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg);
} }
} }

View File

@ -10,15 +10,22 @@
#include <ewol/debug.h> #include <ewol/debug.h>
#include <ewol/resources/ConfigFile.h> #include <ewol/resources/ConfigFile.h>
#include <ewol/resources/ResourceManager.h> #include <ewol/resources/ResourceManager.h>
#include <stdexcept>
#undef __class__ #undef __class__
#define __class__ "ConfigFile" #define __class__ "ConfigFile"
void ewol::SimpleConfigElement::parse(const std::string& value) { void ewol::SimpleConfigElement::parse(const std::string& _value) {
m_valueInt = std::stoi(value); m_value = _value;
m_valuefloat = std::stof(value); try {
m_value = value; m_valueInt = std::stoi(_value);
m_valuefloat = std::stof(_value);
} catch (const std::invalid_argument& ia) {
EWOL_VERBOSE(" invalid argument= " << ia.what() << "val='" << _value << "'");
m_valueInt = 0;
m_valuefloat = 0;
}
} }

View File

@ -88,9 +88,9 @@ ewol::TextureFile* ewol::TextureFile::keep(const std::string& _filename, ivec2 _
_size.setValue(nextP2(_size.x()), nextP2(_size.y())); _size.setValue(nextP2(_size.x()), nextP2(_size.y()));
#endif #endif
TmpFilename += ":"; TmpFilename += ":";
TmpFilename += _size.x(); TmpFilename += std::to_string(_size.x());
TmpFilename += "x"; TmpFilename += "x";
TmpFilename += _size.y(); TmpFilename += std::to_string(_size.y());
} }
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size); EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);

View File

@ -89,12 +89,8 @@ void widget::Button::setShaperName(const std::string& _shaperName) {
void widget::Button::setSubWidget(ewol::Widget* _subWidget) { void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
int32_t idWidget=0; int32_t idWidget=0;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
delete(m_subWidget[idWidget]); m_subWidget[idWidget]->removeObject();
// the pointer might already set at NULL: m_subWidget[idWidget]=NULL;
if (NULL != m_subWidget[idWidget]) {
EWOL_ERROR("error while removing previous widget...");
m_subWidget[idWidget]=NULL;
}
} }
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget); EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget; m_subWidget[idWidget] = _subWidget;
@ -106,12 +102,8 @@ void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) { void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
int32_t idWidget=1; int32_t idWidget=1;
if (NULL!=m_subWidget[idWidget]) { if (NULL!=m_subWidget[idWidget]) {
delete(m_subWidget[idWidget]); m_subWidget[idWidget]->removeObject();
// the pointer might already set at NULL: m_subWidget[idWidget]=NULL;
if (NULL != m_subWidget[idWidget]) {
EWOL_ERROR("error while removing previous widget...");
m_subWidget[idWidget]=NULL;
}
} }
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget); EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
m_subWidget[idWidget] = _subWidget; m_subWidget[idWidget] = _subWidget;
@ -318,7 +310,7 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
m_value = (m_value)?false:true; m_value = (m_value)?false:true;
//EWOL_DEBUG("Generate event : " << eventPressed); //EWOL_DEBUG("Generate event : " << eventPressed);
generateEventId(eventPressed); generateEventId(eventPressed);
EWOL_CRITICAL("Generate event : " << eventValue << " val=" << m_value << " plop : " << std::to_string(m_value)); //EWOL_DEBUG("Generate event : " << eventValue << " val=" << m_value );
generateEventId(eventValue, std::to_string(m_value)); generateEventId(eventValue, std::to_string(m_value));
if( false == m_toggleMode if( false == m_toggleMode
&& true == m_value) { && true == m_value) {

View File

@ -78,65 +78,67 @@ void widget::ButtonColor::onDraw(void) {
void widget::ButtonColor::onRegenerateDisplay(void) { void widget::ButtonColor::onRegenerateDisplay(void) {
if (true == needRedraw()) { if (needRedraw() == false) {
m_text.clear(); return;
m_shaper.clear();
vec2 padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString();
ivec2 localSize = m_minSize;
vec3 tmpOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
// no change for the text orogin :
vec3 tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
if (true == m_userFill.x()) {
localSize.setX(m_size.x());
tmpOrigin.setX(0);
tmpTextOrigin.setX(0);
}
if (true == m_userFill.y()) {
localSize.setY(m_size.y());
}
tmpOrigin += vec3(padding.x(), padding.y(), 0);
tmpTextOrigin += vec3(padding.x(), padding.y(), 0);
localSize -= ivec2(2*padding.x(), 2*padding.y());
// clean the element
m_text.reset();
if( m_textColorFg.r() < 100
|| m_textColorFg.g() < 100
|| m_textColorFg.b() < 100) {
m_text.setColor(etk::color::white);
} else {
m_text.setColor(etk::color::black);
}
m_text.setPos(tmpTextOrigin);
m_text.setColorBg(m_textColorFg);
m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::Text::alignCenter);
m_text.print(label);
if (true == m_userFill.y()) {
tmpOrigin.setY(padding.y());
}
// selection area :
m_selectableAreaPos = vec2(tmpOrigin.x()-padding.x(), tmpOrigin.y()-padding.y());
m_selectableAreaSize = localSize + vec2(2,2)*padding;
m_shaper.setOrigin(m_selectableAreaPos );
m_shaper.setSize(m_selectableAreaSize);
m_shaper.setInsidePos(vec2(tmpTextOrigin.x(), tmpTextOrigin.y()) );
vec3 tmpp = m_text.calculateSize(label);
vec2 tmpp2(tmpp.x(), tmpp.y());
m_shaper.setInsideSize(tmpp2);
} }
EWOL_DEBUG("redraw");
m_text.clear();
m_shaper.clear();
vec2 padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString();
ivec2 localSize = m_minSize;
vec3 tmpOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
// no change for the text orogin :
vec3 tmpTextOrigin((m_size.x() - m_minSize.x()) / 2.0,
(m_size.y() - m_minSize.y()) / 2.0,
0);
if (true == m_userFill.x()) {
localSize.setX(m_size.x());
tmpOrigin.setX(0);
tmpTextOrigin.setX(0);
}
if (true == m_userFill.y()) {
localSize.setY(m_size.y());
}
tmpOrigin += vec3(padding.x(), padding.y(), 0);
tmpTextOrigin += vec3(padding.x(), padding.y(), 0);
localSize -= ivec2(2*padding.x(), 2*padding.y());
// clean the element
m_text.reset();
if( m_textColorFg.r() < 100
|| m_textColorFg.g() < 100
|| m_textColorFg.b() < 100) {
m_text.setColor(etk::color::white);
} else {
m_text.setColor(etk::color::black);
}
m_text.setPos(tmpTextOrigin);
m_text.setColorBg(m_textColorFg);
m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::Text::alignCenter);
m_text.print(label);
if (true == m_userFill.y()) {
tmpOrigin.setY(padding.y());
}
// selection area :
m_selectableAreaPos = vec2(tmpOrigin.x()-padding.x(), tmpOrigin.y()-padding.y());
m_selectableAreaSize = localSize + vec2(2,2)*padding;
m_shaper.setOrigin(m_selectableAreaPos );
m_shaper.setSize(m_selectableAreaSize);
m_shaper.setInsidePos(vec2(tmpTextOrigin.x(), tmpTextOrigin.y()) );
vec3 tmpp = m_text.calculateSize(label);
vec2 tmpp2(tmpp.x(), tmpp.y());
m_shaper.setInsideSize(tmpp2);
} }