[DEV] try to think about a simplest way to display the colored text

This commit is contained in:
Edouard DUPIN 2012-11-19 22:38:36 +01:00
parent 395c7e4893
commit af38aaf01a
7 changed files with 156 additions and 331 deletions

View File

@ -30,6 +30,8 @@
#include <etk/os/FSNode.h>
#include <etk/unicode.h>
#include <ewol/ewol.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/compositing/Text.h>
typedef struct{
@ -41,12 +43,6 @@ typedef struct{
uint32_t diplayableLine; //!< NB Line that can be displayed
}infoStatBuffer_ts;
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
#define TEXT_DISPLAY_TYPE OObject2DTextShader
#else
#define TEXT_DISPLAY_TYPE OObject2DTextColored
#endif
class Buffer {
public:
Buffer(void);
@ -85,8 +81,8 @@ class Buffer {
public:
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate) {};
virtual void SetLineDisplay(uint32_t lineNumber) {};
virtual int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
virtual int32_t Display(ewol::Text& OOText,
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{
return ERR_NONE;
}

View File

@ -67,13 +67,14 @@ BufferEmpty::~BufferEmpty(void)
* @return ---
*
*/
int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
int32_t BufferEmpty::Display(ewol::Text& OOText,
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{
// Get color :
Colorize *myColor = NULL;
int32_t letterHeight = OOText.GetHeight();
etk::Vector3D<float> tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
int32_t letterHeight = tmpLetterSize.y;
etk::Vector2D<float> textPos;
textPos.x = 20;
@ -82,31 +83,24 @@ int32_t BufferEmpty::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
myColor = ColorizeManager::Get("normal");
tmpDisplay = "edn - Editeur De N'ours";
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
OOText.SetColor(myColor->GetFG());
OOText.SetBold(true);
OOText.SetItalic(false);
OOText.Text(textPos, tmpDisplay);
#else
OOText.SetColor(myColor->GetFG());
OOText.Text(textPos, tmpDisplay, ewol::font::Bold);
#endif
OOText.SetColor(myColor->GetFG());
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
OOText.SetFontMode(ewol::font::Bold);
OOText.Print(tmpDisplay);
myColor = ColorizeManager::Get("commentDoxygen");
textPos.y = (int32_t)(textPos.y - letterHeight*1.30);
tmpDisplay = "No Buffer Availlable to display";
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
OOText.SetBold(false);
OOText.SetItalic(false);
OOText.SetColor(myColor->GetFG());
OOText.Text(textPos, tmpDisplay);
#else
OOText.SetColor(myColor->GetFG());
OOText.Text(textPos, tmpDisplay, ewol::font::Regular);
#endif
OOText.SetColor(myColor->GetFG());
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
OOText.SetFontMode(ewol::font::Regular);
OOText.Print(tmpDisplay);
OOColored.SetColor(draw::color::white);
OOColored.Rectangle( 0, 0, sizeX, sizeY);
OOText.SetPos(etk::Vector3D<float>(0.0f, 0.0f, 0.0f) );
OOColored.RectangleWidth(etk::Vector3D<float>((float)sizeX, (float)sizeY, 0.0f) );
return ERR_NONE;
}

View File

@ -32,8 +32,8 @@ class BufferEmpty : public Buffer {
public:
BufferEmpty(void);
virtual ~BufferEmpty(void);
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
int32_t Display(ewol::Text& OOText,
ewol::Drawing& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
};

View File

@ -206,25 +206,21 @@ void BufferText::SetLineDisplay(uint32_t lineNumber)
#define SEPARATION_SIZE_LINE_NUMBER (3)
void BufferText::DrawLineNumber(ewol::TEXT_DISPLAY_TYPE* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
void BufferText::DrawLineNumber(ewol::Text* OOText, ewol::Drawing* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY)
{
char tmpLineNumber[50];
sprintf(tmpLineNumber, "%*d", nbColomn, lineNumber);
OOColored->SetColor(ColorizeManager::Get(COLOR_LIST_BG_2));
OOColored->Rectangle( 0, positionY, sizeX+0.5*SEPARATION_SIZE_LINE_NUMBER, sizeY);
OOText->SetColor(ColorizeManager::Get(COLOR_CODE_LINE_NUMBER));
etk::Vector2D<float> textPos;
textPos.x = 1;
textPos.y = positionY;
etk::UString tmppp = tmpLineNumber;
OOText->Text(textPos, tmppp);
//OOText->SetColor(ColorizeManager::Get(COLOR_LIST_BG_2));
//OOText->SetColorBg(ColorizeManager::Get(COLOR_CODE_LINE_NUMBER));
OOText->SetPos(etk::Vector3D<float>(1.0f, (float)positionY, 0.0f) );
OOText->Print(tmpLineNumber);
}
#define CURSOR_WIDTH (5)
#define CURSOR_THICKNESS (1.2)
void BufferText::DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip)
void BufferText::DrawCursor(ewol::Drawing* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth)//, clipping_ts &clip)
{
/*
draw::Color & tmpppppp = ColorizeManager::Get(COLOR_CODE_CURSOR);
OOColored->SetColor(tmpppppp);
if (true == ewol::IsSetInsert()) {
@ -234,6 +230,7 @@ void BufferText::DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_
OOColored->Line( (int32_t)(x-CURSOR_WIDTH), (int32_t)(y+letterHeight-CURSOR_THICKNESS), (int32_t)(x+CURSOR_WIDTH), (int32_t)(y+letterHeight-CURSOR_THICKNESS), CURSOR_THICKNESS);
OOColored->Line( (int32_t)(x) , (int32_t)(y) , (int32_t)(x) , (int32_t)(y+letterHeight-CURSOR_THICKNESS), CURSOR_THICKNESS);
}
*/
}
@ -277,17 +274,89 @@ int32_t BufferText::GetNumberOfLine(void)
* @return
*
*/
int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored,
int32_t BufferText::Display(ewol::Text& OOText,
ewol::Drawing& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY)
{
OOColored.SetPos(etk::Vector3D<float>(0,0,0));
OOColored.SetColor(0xFFFFFFFF);
OOColored.RectangleWidth(etk::Vector3D<float>(4096, 4096, 0) );
OOText.SetColor(0x000000FF);
OOText.SetColorBg(0x00000000);
OOText.Translate(etk::Vector3D<float>(0,sizeY,0) );
OOText.SetPos(etk::Vector3D<float>(0,0,0));
// the text is all the time writtent upper (due top the openGL system ==> the the first line must be written under ...
OOText.ForceLineReturn();
// This is use to generate an automatic return when \n is done ... ==> this permit to not know the line height ...
OOText.SetTextAlignement(0, sizeX, ewol::Text::alignDisable);
// Generate MawSize
/*
maxSize.x = 0.0;
maxSize.y = m_EdnBuf.NumberOfLines() * OOText.CalculateSize((uniChar_t)'A').y;
*/
// Clear the line intexation :
m_elmentList.Clear();
// every char element is register to find the diplay pos when mouse event arrive
CharElement tmpElementProperty;
// set the first char :
//tmpElementProperty.m_LineOffset = OOText.GetPos().y;
//tmpElementProperty.m_bufferPos = displayStartBufferPos;
//m_elmentList.PushBack(tmpElementProperty);
int32_t displayStartLineId = (float)offsetY / OOText.CalculateSize((uniChar_t)'A').y;
// the ofsset is all time negative ...
displayStartLineId = etk_max(0, displayStartLineId);
APPL_DEBUG(" request offset : " << offsetY << " ==> " << displayStartLineId);
// update the display position with the scroll ofset :
int32_t currentLineStartPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
int32_t findPos;
etk::UString lineText;
while (true == m_EdnBuf.SearchForward(currentLineStartPos, '\n', &findPos) ) {
// remember the start line display position in the buffer
tmpElementProperty.m_bufferPos = currentLineStartPos;
// we did not copy the \n
m_EdnBuf.GetRange(currentLineStartPos, findPos-1, lineText);
// update the next extract position with the \n removed
currentLineStartPos = findPos+1;
OOText.Print(lineText);
// Remember the last position of the current Line :
tmpElementProperty.m_LineOffset = OOText.GetPos().y;
// element list is used to manage the current line position
m_elmentList.PushBack(tmpElementProperty);
// go to the start of the line ...
OOText.ForceLineReturn();
}
// TODO : Missing the last line ...
#ifdef QSDFQSDFSDFQS_QSDFQSDf_QSDFQSDF___QSDFQSDFQ
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;
int32_t selHave;
int32_t letterWidth = OOText.GetSize("A").x;
int32_t letterHeight = OOText.GetHeight();
etk::Vector3D<float> tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
int32_t letterWidth = tmpLetterSize.x;
int32_t letterHeight = tmpLetterSize.y;
int32_t displayStartLineId = offsetY / letterHeight - 1;
displayStartLineId = etk_max(0, displayStartLineId);
@ -320,8 +389,9 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
int32_t x_base=nbColoneForLineNumber*letterWidth;
int32_t idX = 0;
OOColored.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
OOColored.Rectangle( 0, 0, sizeX, sizeY);
//OOColored.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
OOColored.SetPos(etk::Vector3D<float>(0,0,0));
OOColored.RectangleWidth(etk::Vector3D<float>(sizeX, sizeY, 0) );
int64_t startTime = ewol::GetTime();
int displayLines = 0;
@ -344,8 +414,8 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
y = sizeY - y;
y -= letterHeight;
OOColored.clippingDisable();
OOText.clippingDisable();
OOColored.SetClippingMode(false);
OOText.SetClippingMode(false);
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
@ -355,14 +425,10 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
drawClipping.w = sizeX;
drawClipping.h = sizeY;
clipping_ts drawClippingTextArea;
drawClippingTextArea.x = pixelX;
drawClippingTextArea.y = 0;
drawClippingTextArea.w = sizeX - drawClipping.x;
drawClippingTextArea.h = sizeY;
OOText.clippingSet(drawClippingTextArea);
OOColored.clippingSet(drawClippingTextArea);
OOText.SetClippingWidth(etk::Vector3D<float>((float)pixelX, 0.0f, -0.5f),
etk::Vector3D<float>((float)(sizeX - drawClipping.x), (float)sizeY, 0.5f) );
OOColored.SetClippingWidth(etk::Vector3D<float>(0.0f, 0.0f, -0.5f),
etk::Vector3D<float>((float)sizeX, (float)sizeY, 0.5f) );
// Clear the line intexation :
m_elmentList.Clear();
@ -402,6 +468,7 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
selectColor = HLColor->patern->GetColor();
}
}
/*
bool haveBg = false;
if( true == selHave
&& selStart <= iii
@ -425,48 +492,25 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
OOColored.SetColor(selectColor->GetBG());
haveBg = selectColor->HaveBg();
}
}
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
tmpElementProperty.m_ySize = OOText.GetHeight();
OOText.SetColor(selectColor->GetFG());
OOText.SetBold(selectColor->GetBold());
OOText.SetItalic(selectColor->GetItalic());
myStringToDisplay = displayChar;
drawSize = OOText.Text(textPos, myStringToDisplay);
#else
ewol::font::mode_te tmpMode = ewol::font::Regular;
if (true == selectColor->GetItalic() ) {
if (true == selectColor->GetBold() ) {
tmpMode = ewol::font::BoldItalic;
} else {
tmpMode = ewol::font::Italic;
}
} else {
if (true == selectColor->GetBold() ) {
tmpMode = ewol::font::Bold;
} else {
tmpMode = ewol::font::Regular;
}
}
tmpElementProperty.m_ySize = OOText.GetHeight();
//tmpElementProperty.m_yOffset += tmpElementProperty.m_ySize;
OOText.SetColor(selectColor->GetFG());
// TODO : Remove this unreallistic leak of time
myStringToDisplay = displayChar;
drawSize = OOText.Text(textPos, myStringToDisplay, tmpMode);
#endif
}*/
tmpElementProperty.m_ySize = 20;//OOText.GetHeight();
//OOText.SetColor(selectColor->GetFG());
//OOText.SetColorBg(selectColor->GetFG());
OOText.SetFontBold(selectColor->GetBold());
OOText.SetFontItalic(selectColor->GetItalic());
myStringToDisplay = displayChar;
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
OOText.Print(myStringToDisplay);
//APPL_DEBUG("add element : " << tmpElementProperty.m_yOffset << "," << tmpElementProperty.m_xOffset);
m_elmentList.PushBack(tmpElementProperty);
if (true == haveBg ) {
OOColored.Rectangle(textPos.x, y, drawSize, letterHeight);
}
}
idX += displaywidth;
// display cursor :
if (m_cursorPos == iii) {
// display the cursor:
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth, drawClippingTextArea);
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth);
}
lineMaxSize += drawSize;
pixelX += drawSize;
@ -480,19 +524,13 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
//APPL_DEBUG("display pos =" << y);
displayLines++;
currentLineID++;
OOColored.clippingDisable();
#ifdef APPL_BUFFER_FONT_DISTANCE_FIELD
OOText.clippingDisable();
OOText.SetBold(false);
OOText.SetItalic(false);
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
OOText.clippingEnable();
#else
OOText.clippingDisable();
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
OOText.clippingEnable();
#endif
OOColored.clippingEnable();
OOColored.SetClippingMode(false);
OOText.SetClippingMode(false);
OOText.SetFontBold(false);
OOText.SetFontItalic(false);
DrawLineNumber(&OOText, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
OOText.SetClippingMode(true);
OOColored.SetClippingMode(true);
// add elements :
m_elmentList.PushBack(tmpElementProperty);
}
@ -500,13 +538,13 @@ int32_t BufferText::Display(ewol::TEXT_DISPLAY_TYPE& OOText,
//APPL_DEBUG("end at pos buf =" << iii << " / " << m_EdnBuf.Size());
// special case : the cursor is at the end of the buffer...
if (m_cursorPos == iii) {
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth, drawClippingTextArea);
DrawCursor(&OOColored, pixelX - offsetX, y, letterHeight, letterWidth);//, drawClippingTextArea);
}
// set the maximum size for the display ...
SetMaximumSize(maxSize);
int64_t stopTime2 = ewol::GetTime();
APPL_DEBUG("DRAW text (brut) = " << stopTime2 - stopTime << " micro-s");
#endif
return ERR_NONE;
}
@ -517,6 +555,7 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
bool inLineDone=false;
//APPL_DEBUG("try to find in : " << width << "," << height);
for(int32_t iii=0; iii<m_elmentList.Size()-1; iii++) {
/*
//APPL_DEBUG("check element : " << m_elmentList[iii].m_yOffset << "<= " << pos.y << " <" << (m_elmentList[iii].m_yOffset + m_elmentList[iii].m_ySize));
if(false == inLineDone) {
if( pos.y>=m_elmentList[iii].m_yOffset
@ -538,8 +577,10 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
return m_elmentList[iii].m_bufferPos;
}
}
*/
}
if (m_elmentList.Size()>0) {
/*
if(pos.y<m_elmentList[m_elmentList.Size()/2].m_yOffset) {
//APPL_DEBUG("Error to get position (return Last)");
return m_elmentList[m_elmentList.Size()-1].m_bufferPos;
@ -547,6 +588,7 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
//APPL_DEBUG("Error to get position (return begin)");
return m_elmentList[0].m_bufferPos;
}
*/
} else {
APPL_CRITICAL("Error to get position (very bad)");
return 0;

View File

@ -39,10 +39,8 @@ typedef enum {
class CharElement
{
public:
int16_t m_yOffset;
int16_t m_xOffset;
int16_t m_ySize;
int32_t m_bufferPos;
float m_LineOffset;
int32_t m_bufferPos;
};
class BufferText : public Buffer {
@ -54,8 +52,8 @@ class BufferText : public Buffer {
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
int32_t Display(ewol::TEXT_DISPLAY_TYPE& OOText,
ewol::OObject2DColored& OOColored,
int32_t Display(ewol::Text& OOText,
ewol::Drawing& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
void AddChar(uniChar_t unicodeData);
@ -90,7 +88,7 @@ class BufferText : public Buffer {
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
etk::Vector2D<float> m_displaySize; //!< number of char displayable in the screan
etk::Vector2D<float> m_displaySize; //!< number of char displayable in the screan
// Cursor :
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
@ -110,8 +108,8 @@ class BufferText : public Buffer {
int32_t GetMousePosition(etk::Vector2D<float> pos);
void DrawLineNumber(ewol::TEXT_DISPLAY_TYPE* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
void DrawCursor(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip);
void DrawLineNumber(ewol::Text* OOText, ewol::Drawing* OOColored, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);
void DrawCursor(ewol::Drawing* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth);//, clipping_ts &clip);
};

View File

@ -43,9 +43,8 @@
void CodeView::Init(void)
{
m_alignement = ewol::Text::alignJustify;
m_label = "CodeView is disable ...";
m_clipping = false;
m_bufferID = -1;
m_buttunOneSelected = false;
@ -80,9 +79,7 @@ void CodeView::Init(void)
}
CodeView::CodeView(etk::UString fontName, int32_t fontSize) :
m_OObjectText(fontName, fontSize),
//m_displayText("Times_New_Roman", 14)
m_displayText("Arial", 14)
m_displayText(fontName, fontSize)
{
Init();
}
@ -105,7 +102,7 @@ CodeView::~CodeView(void)
*/
void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
{
etk::Vector2D<float> tmpCoord;
etk::Vector2D<float> tmpCoord;
tmpCoord.x = 0;
tmpCoord.y = 0;
if (m_lineNumberList.Size()<=bufferID) {
@ -128,15 +125,13 @@ bool CodeView::CalculateMinSize(void)
void CodeView::CalculateMaxSize(void)
{
m_maxSize.x = 2048;
int32_t letterHeight = m_OObjectText.GetHeight();
int32_t letterHeight = m_displayText.CalculateSize('A').y;
m_maxSize.y = BufferManager::Get(m_bufferID)->GetNumberOfLine() * letterHeight;
}
void CodeView::OnDraw(ewol::DrawProperty& displayProp)
{
m_OObjectsColored.Draw();
//m_OObjectText.Draw();
m_displayDrawing.Draw();
m_displayText.Draw();
WidgetScrooled::OnDraw(displayProp);
@ -149,177 +144,8 @@ void CodeView::OnRegenerateDisplay(void)
// For the scrooling windows
CalculateMaxSize();
m_OObjectText.Clear();
m_displayDrawing.Clear();
m_displayText.Clear();
m_OObjectsColored.Clear();
#if 1
m_OObjectsColored.SetColor(draw::color::white);
m_OObjectsColored.Rectangle( 0, 0, m_size.x, m_size.y);
m_displayText.SetColor(draw::color::red);
etk::UString tmpString("PETIT test sur les Text Display : ");
switch (m_alignement)
{
case ewol::Text::alignJustify:
m_displayText.SetFontMode(ewol::font::Regular);
tmpString += "mode JUSTIFY";
break;
case ewol::Text::alignLeft:
m_displayText.SetFontMode(ewol::font::Bold);
tmpString += "mode Left";
break;
case ewol::Text::alignRight:
m_displayText.SetFontMode(ewol::font::Italic);
tmpString += "mode Right";
break;
case ewol::Text::alignCenter:
m_displayText.SetFontMode(ewol::font::BoldItalic);
tmpString += "mode Center";
break;
case ewol::Text::alignDisable:
tmpString += "mode Disable";
break;
}
m_displayText.SetPos(etk::Vector3D<float>((float)20,(float)m_size.y-20,(float)0) );
m_displayText.Print(tmpString);
tmpString = "test de text complexe ...";
etk::Vector<ewol::TextDecoration> decoration;
ewol::TextDecoration plop;
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::green;
plop.m_colorBg = draw::color::red;
plop.m_mode = ewol::font::BoldItalic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::yellow;
plop.m_colorBg = draw::color::orange;
plop.m_mode = ewol::font::Bold;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::black;
plop.m_colorBg = draw::color::gray;
plop.m_mode = ewol::font::Italic;
decoration.PushBack(plop);
plop.m_colorFg = draw::color::red;
plop.m_colorBg = draw::color::green;
plop.m_mode = ewol::font::Regular;
decoration.PushBack(plop);
m_displayText.SetPos(etk::Vector3D<float>((float)20,(float)m_size.y-50,(float)0) );
m_displayText.Print(tmpString, decoration);
m_displayText.SetColor(draw::color::black);
m_displayText.SetFontMode(ewol::font::Regular);
m_OObjectsColored.SetColor(draw::color::aqua);
m_OObjectsColored.Rectangle( 20, 0, m_size.x-40, m_size.y-100);
m_displayText.SetColorBG(draw::color::none);
if (true == m_clipping) {
m_OObjectsColored.SetColor(draw::color::green);
m_OObjectsColored.Rectangle( 200, 200, 200, 200);
etk::Vector3D<float> drawClippingPos(200.0, 200.0, -0.5);
etk::Vector3D<float> drawClippingSize(400.0, 400.0, 1.0);
m_displayText.SetClipping(drawClippingPos, drawClippingSize);
}
tmpString = "Un jour Cosette se regarda par hasard dans son miroir et se dit: Tiens! Il lui semblait presque qu'elle était jolie. Ceci la jeta dans un trouble singulier. Jusqu'à ce moment elle n'avait point songé à sa figure. Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide ; Jean Valjean seul disait doucement : Mais non! mais non! Quoi qu'il en fût, Cosette s'était toujours crue laide, et avait grandi dans cette idée avec la résignation facile de l'enfance. Voici que tout d'un coup son miroir lui disait comme Jean Valjean : Mais non! Elle ne dormit pas de la nuit. Si j'étais jolie ? pensait-elle, comme cela serait drôle que je fusse jolie! Et elle se rappelait celles de ses compagnes dont la beauté faisait effet dans le couvent, et elle se disait : Comment ! je serais comme mademoiselle une telle!\n"
"sdfsqdfqsdjfhqlskdjhf qlksjdhflqkjsdhlfkqjshdlkfjqhslkdjfhqlskdjhfqlksjdhflqkjsdhflkqjsdhlkfqjshdlkfjqshldkjqfhsldkfjqhslkdjfqhlskdjfhqlskjdhflqksjdhflkqjshdlfkqjsdf\n\n"
"Le lendemain elle se regarda, mais non par hasard, et elle douta: Où avais-je l'esprit ? dit-elle, non, je suis laide. Elle avait tout simplement mal dormi, elle avait les yeux battus et elle était pâle. Elle ne s'était pas sentie très joyeuse la veille de croire à sa beauté, mais elle fut triste de n'y plus croire. Elle ne se regarda plus, et pendant plus de quinze jours elle tâcha de se coiffer tournant le dos au miroir.\n"
"Le soir, après le dîner, elle faisait assez habituellement de la tapisserie dans le salon, ou quelque ouvrage de couvent, et Jean Valjean lisait à côté d'elle. Une fois elle leva les yeux de son ouvrage et elle fut toute surprise de la façon inquiète dont son père la regardait.\n"
"Une autre fois, elle passait dans la rue, et il lui sembla que quelqu'un qu'elle ne vit pas disait derrière elle : Jolie femme ! mais mal mise. Bah ! pensa-t-elle, ce n'est pas moi. Je suis bien mise et laide. Elle avait alors son chapeau de peluche et sa robe de mérinos.\n"
"Un jour enfin, elle était dans le jardin, et elle entendit la pauvre vieille Toussaint qui disait : Monsieur, remarquez-vous comme mademoiselle devient jolie ? Cosette n'entendit pas ce que son père répondit, les paroles de Toussaint furent pour elle une sorte de commotion. Elle s'échappa du jardin, monta à sa chambre, courut à la glace, il y avait trois mois qu'elle ne s'était regardée, et poussa un cri. Elle venait de s'éblouir elle-même.";
m_displayText.SetPos(etk::Vector3D<float>((float)40,(float)m_size.y-100,(float)0) );
m_displayText.SetTextAlignement(20, m_size.x-20, m_alignement);
m_displayText.Print(tmpString);
/*
draw::Color tmpColor = 0x0000FF55;
m_displayDrawing.SetColor(tmpColor);
m_displayDrawing.Tranlate(etk::Vector3D<float>(100, 100, 0) );
m_displayDrawing.SetThickness(2);
m_displayDrawing.Rectangle(etk::Vector3D<float>(200, 200, 0) );
m_displayDrawing.SetColor(0x00F46799);
m_displayDrawing.SetPos(etk::Vector3D<float>(300, 0, 0) );
m_displayDrawing.SetThickness(20);
m_displayDrawing.LineTo(etk::Vector3D<float>(200, 200, 0) );
*/
// force the redraw
PeriodicCallSet(true);
MarkToRedraw();
#else
if(true == BufferManager::Get(m_bufferID)->NeedToUpdateDisplayPosition() ) {
etk::Vector2D<float> borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
@ -330,8 +156,8 @@ void CodeView::OnRegenerateDisplay(void)
} // else : nothing to do ...
// generate the objects :
BufferManager::Get(m_bufferID)->Display(m_OObjectText,
m_OObjectsColored,
BufferManager::Get(m_bufferID)->Display(m_displayText,
m_displayDrawing,
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
// set the current size of the windows
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
@ -341,7 +167,6 @@ void CodeView::OnRegenerateDisplay(void)
// call the herited class...
WidgetScrooled::OnRegenerateDisplay();
#endif
}
}
@ -396,31 +221,6 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
etk::Vector2D<float> limitedPos = relativePos;
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1);
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1);
if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
APPL_DEBUG("Must change the display ... ");
switch (m_alignement)
{
case ewol::Text::alignJustify:
m_alignement = ewol::Text::alignLeft;
break;
case ewol::Text::alignLeft:
m_alignement = ewol::Text::alignRight;
break;
case ewol::Text::alignRight:
m_alignement = ewol::Text::alignCenter;
break;
case ewol::Text::alignCenter:
m_alignement = ewol::Text::alignDisable;
break;
case ewol::Text::alignDisable:
m_alignement = ewol::Text::alignJustify;
m_clipping = (m_clipping)?false:true;
break;
}
MarkToRedraw();
}
}
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widget ...
@ -605,12 +405,12 @@ void CodeView::OnLostFocus(void)
void CodeView::SetFontSize(int32_t size)
{
m_OObjectText.SetSize(size);
m_displayText.SetFontSize(size);
SetScrollingSize(size*3.0*1.46); // 1.46 is a magic nmber ...
}
void CodeView::SetFontName(etk::UString fontName)
{
m_OObjectText.SetFont(fontName);
m_displayText.SetFontName(fontName);
}

View File

@ -35,7 +35,7 @@
#include <ewol/widget/WidgetScrolled.h>
#include <ewol/ResourceManager.h>
#include <ewol/compositing/Text.h>
#include <ewol/compositing/Draw.h>
#include <ewol/compositing/Drawing.h>
class CodeView :public ewol::WidgetScrooled
{
@ -61,13 +61,8 @@ class CodeView :public ewol::WidgetScrooled
etk::Vector<etk::Vector2D<float> > m_lineNumberList;
void UpdateNumberOfLineReference(int32_t bufferID);
// drawing elements :
ewol::TEXT_DISPLAY_TYPE m_OObjectText;
ewol::Text m_displayText;
ewol::Drawing m_displayDrawing;
ewol::OObject2DColored m_OObjectsColored;
// TODO : Remove :
ewol::Text::aligneMode_te m_alignement;
bool m_clipping;
public:
virtual void OnRegenerateDisplay(void);
/**