[DEBUG work again
This commit is contained in:
parent
905091d3fd
commit
971905b0d5
2
external/ejson
vendored
2
external/ejson
vendored
@ -1 +1 @@
|
||||
Subproject commit 666605419cfab90d858f5687659a10e28146d97e
|
||||
Subproject commit 564ec3130f3874c3bcc2235976f2d85996c4f770
|
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
||||
Subproject commit d2a3fcaa63f1d942fcaafb205b806b37ad804090
|
||||
Subproject commit 4f25fd3ddc690dc066d81b601b9287c260a447fe
|
@ -362,11 +362,17 @@ void ewol::Text::setDistanceFieldMode(bool _newMode) {
|
||||
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) {
|
||||
std::vector<TextDecoration> decorationEmpty;
|
||||
print(_text, decorationEmpty);
|
||||
}
|
||||
|
||||
|
||||
void ewol::Text::parseHtmlNode(exml::Element* _element) {
|
||||
// get the static real pointer
|
||||
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);
|
||||
}
|
||||
}
|
||||
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) {
|
||||
@ -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) {
|
||||
if( m_htmlCurrrentLine.size()>0
|
||||
&& m_htmlCurrrentLine[m_htmlCurrrentLine.size()-1] != ' ') {
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <ewol/compositing/Drawing.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <exml/exml.h>
|
||||
#include <string>
|
||||
|
||||
namespace ewol {
|
||||
/**
|
||||
@ -236,6 +237,7 @@ namespace ewol {
|
||||
* @param[in] _text The string to display.
|
||||
*/
|
||||
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)
|
||||
* <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)
|
||||
*/
|
||||
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)
|
||||
* @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
|
||||
*/
|
||||
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:
|
||||
// this section is reserved for HTML parsing and display:
|
||||
std::string m_htmlCurrrentLine; //!< current line for HTML display
|
||||
|
@ -67,10 +67,12 @@ void ewol::EObject::generateEventId(const char * _generateEventId, const std::st
|
||||
if (NULL != m_externEvent[iii]->destEObject) {
|
||||
if (m_externEvent[iii]->overloadData.size() <= 0){
|
||||
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, _data);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg);
|
||||
} else {
|
||||
// set the user requested data ...
|
||||
ewol::EMessage tmpMsg(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->overloadData);
|
||||
EWOL_VERBOSE("send message " << tmpMsg);
|
||||
m_externEvent[iii]->destEObject->onReceiveMessage(tmpMsg);
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,22 @@
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/resources/ConfigFile.h>
|
||||
#include <ewol/resources/ResourceManager.h>
|
||||
#include <stdexcept>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ConfigFile"
|
||||
|
||||
|
||||
void ewol::SimpleConfigElement::parse(const std::string& value) {
|
||||
m_valueInt = std::stoi(value);
|
||||
m_valuefloat = std::stof(value);
|
||||
m_value = value;
|
||||
void ewol::SimpleConfigElement::parse(const std::string& _value) {
|
||||
m_value = _value;
|
||||
try {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -88,9 +88,9 @@ ewol::TextureFile* ewol::TextureFile::keep(const std::string& _filename, ivec2 _
|
||||
_size.setValue(nextP2(_size.x()), nextP2(_size.y()));
|
||||
#endif
|
||||
TmpFilename += ":";
|
||||
TmpFilename += _size.x();
|
||||
TmpFilename += std::to_string(_size.x());
|
||||
TmpFilename += "x";
|
||||
TmpFilename += _size.y();
|
||||
TmpFilename += std::to_string(_size.y());
|
||||
}
|
||||
|
||||
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
|
||||
|
@ -89,13 +89,9 @@ void widget::Button::setShaperName(const std::string& _shaperName) {
|
||||
void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
|
||||
int32_t idWidget=0;
|
||||
if (NULL!=m_subWidget[idWidget]) {
|
||||
delete(m_subWidget[idWidget]);
|
||||
// the pointer might already set at NULL:
|
||||
if (NULL != m_subWidget[idWidget]) {
|
||||
EWOL_ERROR("error while removing previous widget...");
|
||||
m_subWidget[idWidget]->removeObject();
|
||||
m_subWidget[idWidget]=NULL;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
|
||||
m_subWidget[idWidget] = _subWidget;
|
||||
// element change ... We need to recalculate all the subElments :
|
||||
@ -106,13 +102,9 @@ void widget::Button::setSubWidget(ewol::Widget* _subWidget) {
|
||||
void widget::Button::setSubWidgetToggle(ewol::Widget* _subWidget) {
|
||||
int32_t idWidget=1;
|
||||
if (NULL!=m_subWidget[idWidget]) {
|
||||
delete(m_subWidget[idWidget]);
|
||||
// the pointer might already set at NULL:
|
||||
if (NULL != m_subWidget[idWidget]) {
|
||||
EWOL_ERROR("error while removing previous widget...");
|
||||
m_subWidget[idWidget]->removeObject();
|
||||
m_subWidget[idWidget]=NULL;
|
||||
}
|
||||
}
|
||||
EWOL_VERBOSE("Add button : " << idWidget << " element : " << (int64_t)_subWidget);
|
||||
m_subWidget[idWidget] = _subWidget;
|
||||
// element change ... We need to recalculate all the subElments :
|
||||
@ -318,7 +310,7 @@ bool widget::Button::onEventInput(const ewol::EventInput& _event) {
|
||||
m_value = (m_value)?false:true;
|
||||
//EWOL_DEBUG("Generate event : " << 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));
|
||||
if( false == m_toggleMode
|
||||
&& true == m_value) {
|
||||
|
@ -78,7 +78,10 @@ void widget::ButtonColor::onDraw(void) {
|
||||
|
||||
|
||||
void widget::ButtonColor::onRegenerateDisplay(void) {
|
||||
if (true == needRedraw()) {
|
||||
if (needRedraw() == false) {
|
||||
return;
|
||||
}
|
||||
EWOL_DEBUG("redraw");
|
||||
m_text.clear();
|
||||
m_shaper.clear();
|
||||
|
||||
@ -137,7 +140,6 @@ void widget::ButtonColor::onRegenerateDisplay(void) {
|
||||
vec2 tmpp2(tmpp.x(), tmpp.y());
|
||||
m_shaper.setInsideSize(tmpp2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool widget::ButtonColor::onEventInput(const ewol::EventInput& _event) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user