Optimise the display of the CodeViewer ==> usable on Android

This commit is contained in:
Edouard Dupin 2012-02-18 15:56:00 +01:00
parent 0d0afec709
commit 0a11251ccc
10 changed files with 122 additions and 88 deletions

View File

@ -1,4 +1,12 @@
# action a faire (ordonner par révision) :
dans la liste des truc important a refaire
l'annalyseur d'expression regulière pour le display, le faire ligne par ligne
ne pas regénéré l'affichage des widget quand les taille change
mettre en place le positionnement des élément par matrice ... ==> gain de temps en repaint...
* 0.2.X :
- gui : Amelioration du full-screen et du display de base (sans l'entete de la fenetre)
- gui : Mise en place d'un display ligne par ligne

View File

@ -15,7 +15,8 @@ LOCAL_SRC_FILES := $(FILE_LIST)
LOCAL_LDLIBS :=
LOCAL_CFLAGS := -DEWOL_USE_FREE_TYPE \
LOCAL_CFLAGS := -D__PLATFORM__Linux \
-DEWOL_USE_FREE_TYPE \
-DEDN_DEBUG_LEVEL=3
include $(BUILD_EXECUTABLE)

View File

@ -148,10 +148,10 @@ void Buffer::SetLineDisplay(uint32_t lineNumber)
* @return ---
*
*/
int32_t Buffer::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored,
int32_t Buffer::Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic, ewol::OObject2DColored& OOColored,
int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{
return ERR_NONE;

View File

@ -82,11 +82,11 @@ class Buffer {
virtual void GetInfo(infoStatBuffer_ts &infoToUpdate);
virtual void SetLineDisplay(uint32_t lineNumber);
virtual int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
virtual int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
virtual void ForceReDraw(bool allElement);
virtual void AddChar(uniChar_t unicodeData);
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);

View File

@ -67,27 +67,17 @@ BufferEmpty::~BufferEmpty(void)
* @return ---
*
*/
int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
int32_t BufferEmpty::Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY)
{
ColorizeManager * myColorManager = ColorizeManager::getInstance();
// Get color :
Colorize *myColor = NULL;
//drawer.Flush();
if (NULL == OOTextNormal) {
EDN_ERROR("Input VALUE is NULL");
return ERR_FAIL;
}
if (NULL == OOColored) {
EDN_ERROR("Input VALUE is NULL");
return ERR_FAIL;
}
int32_t fontId = OOTextNormal->GetFontID();
int32_t fontId = OOTextNormal.GetFontID();
int32_t letterHeight = ewol::GetHeight(fontId);
coord2D_ts textPos;
@ -100,15 +90,15 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
drawClipping.h = sizeY;
myColor = myColorManager->Get("normal");
OOTextNormal->SetColor(myColor->GetFG());
OOTextNormal.SetColor(myColor->GetFG());
etk::UString tmpDisplay = "edn - Editeur De N'ours";
OOTextBold->Text(textPos, drawClipping, tmpDisplay);
OOTextBold.Text(textPos, drawClipping, tmpDisplay);
myColor = myColorManager->Get("commentDoxygen");
OOTextNormal->SetColor(myColor->GetFG());
OOTextNormal.SetColor(myColor->GetFG());
textPos.y = (int32_t)(textPos.y + letterHeight*1.30);
tmpDisplay = "No Buffer Availlable to display";
OOTextNormal->Text(textPos, drawClipping, tmpDisplay);
OOTextNormal.Text(textPos, drawClipping, tmpDisplay);
color_ts bgColor; //!< Text color
@ -116,8 +106,8 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal,
bgColor.green = 1.0;
bgColor.blue = 1.0;
bgColor.alpha = 1.0;
OOColored->SetColor(bgColor);
OOColored->Rectangle( 0, 0, sizeX, sizeY);
OOColored.SetColor(bgColor);
OOColored.Rectangle( 0, 0, sizeX, sizeY);
return ERR_NONE;
}

View File

@ -32,11 +32,11 @@ class BufferEmpty : public Buffer {
public:
BufferEmpty(void);
virtual ~BufferEmpty(void);
int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic,
ewol::OObject2DColored& OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY);
};

View File

@ -324,11 +324,11 @@ static int32_t g_basicfontId = 0;
* @return
*
*/
int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored,
int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic,
ewol::OObject2DColored& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY)
{
@ -340,7 +340,7 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
bool selIsRect;
int32_t selHave;
int32_t fontId = OOTextNormal->GetFontID();
int32_t fontId = OOTextNormal.GetFontID();
// TODO : Remove this ...
g_basicfontId = fontId;
int32_t letterWidth = ewol::GetWidth(fontId, "A");
@ -390,14 +390,18 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
int32_t x_base=nbColoneForLineNumber*letterWidth;
int32_t idX = 0;
OOColored->SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG));
OOColored->Rectangle( 0, 0, sizeX, sizeY);
OOColored.SetColor(myColorManager->Get(COLOR_CODE_BASIC_BG));
OOColored.Rectangle( 0, 0, sizeX, sizeY);
int64_t startTime = GetCurrentTime();
int displayLines = 0;
// Regenerate the colorizing if necessary ...
displayHLData_ts m_displayLocalSyntax;
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, m_displayStartBufferPos, m_displaySize.y);
int64_t stopTime = GetCurrentTime();
EDN_DEBUG("Parsing Highlight = " << stopTime - startTime << " milli-s");
uniChar_t displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
etk::UString myStringToDisplay;
@ -407,7 +411,7 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
EDN_VERBOSE("cursor Pos : " << m_cursorPos << "start at pos=" << m_displayStartBufferPos);
DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, myPrint, currentLineID, y);
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
clipping_ts drawClipping;
@ -444,21 +448,21 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
&& selEnd > iii)
{
selectColor = myColorSel;
OOColored->SetColor(selectColor->GetBG());
OOColored.SetColor(selectColor->GetBG());
haveBg = selectColor->HaveBg();
} else {
if( ' ' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
{
OOColored->SetColor(myColorSpace);
OOColored.SetColor(myColorSpace);
haveBg = true;
} else if( '\t' == currentChar
&& true == globals::IsSetDisplaySpaceChar() )
{
OOColored->SetColor(myColorTab);
OOColored.SetColor(myColorTab);
haveBg = true;
} else {
OOColored->SetColor(selectColor->GetBG());
OOColored.SetColor(selectColor->GetBG());
haveBg = selectColor->HaveBg();
}
}
@ -467,30 +471,31 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
textPos.y = y;
if (true == selectColor->GetItalic() ) {
if (true == selectColor->GetBold() ) {
OOTextSelected = OOTextBoldItalic;
OOTextSelected = &OOTextBoldItalic;
} else {
OOTextSelected = OOTextItalic;
OOTextSelected = &OOTextItalic;
}
} else {
if (true == selectColor->GetBold() ) {
OOTextSelected = OOTextBold;
OOTextSelected = &OOTextBold;
} else {
OOTextSelected = OOTextNormal;
OOTextSelected = &OOTextNormal;
}
}
OOTextSelected->SetColor(selectColor->GetFG());
// TODO : Remove this unreallistic leak of time
myStringToDisplay = displayChar;
drawSize = OOTextSelected->Text(textPos, drawClippingTextArea, myStringToDisplay);
if (true == haveBg ) {
OOColored->Rectangle(textPos.x, y, drawSize, letterHeight, drawClippingTextArea);
OOColored.Rectangle(textPos.x, y, drawSize, letterHeight, drawClippingTextArea);
}
}
idX += displaywidth;
// display cursor :
if (m_cursorPos == iii) {
// display the cursor:
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
CursorDisplay(&OOColored, pixelX, y, letterHeight, letterWidth);
}
pixelX += drawSize;
// move to next line ...
@ -500,13 +505,16 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal,
y += letterHeight;
displayLines++;
currentLineID++;
DrawLineNumber(OOTextNormal, OOColored, x_base, sizeY, myPrint, currentLineID, y);
DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, myPrint, currentLineID, y);
}
}
// special case : the cursor is at the end of the buffer...
if (m_cursorPos == iii) {
CursorDisplay(OOColored, pixelX, y, letterHeight, letterWidth);
CursorDisplay(&OOColored, pixelX, y, letterHeight, letterWidth);
}
int64_t stopTime2 = GetCurrentTime();
EDN_DEBUG("DRAW text (brut) = " << stopTime2 - stopTime << " milli-s");
return ERR_NONE;
}

View File

@ -46,11 +46,11 @@ class BufferText : public Buffer {
void GetInfo(infoStatBuffer_ts &infoToUpdate);
void SetLineDisplay(uint32_t lineNumber);
int32_t Display(ewol::OObject2DTextColored* OOTextNormal,
ewol::OObject2DTextColored* OOTextBold,
ewol::OObject2DTextColored* OOTextItalic,
ewol::OObject2DTextColored* OOTextBoldItalic,
ewol::OObject2DColored* OOColored,
int32_t Display(ewol::OObject2DTextColored& OOTextNormal,
ewol::OObject2DTextColored& OOTextBold,
ewol::OObject2DTextColored& OOTextItalic,
ewol::OObject2DTextColored& OOTextBoldItalic,
ewol::OObject2DColored& OOColored,
int32_t offsetX, int32_t offsetY,
int32_t sizeX, int32_t sizeY);
void ForceReDraw(bool allElement);

View File

@ -70,6 +70,9 @@ CodeView::CodeView(void)
m_textColorBg.alpha = 0.25;
SetCanHaveFocus(true);
ewol::widgetMessageMultiCast::Add(GetWidgetId(), ednMsgBufferId);
GenericDrawDisable();
SpecificDrawEnable();
}
CodeView::~CodeView(void)
@ -90,8 +93,21 @@ void CodeView::CalculateMaxSize(void)
int32_t letterHeight = ewol::GetHeight(m_fontNormal);
m_maxSize.y = m_bufferManager->Get(m_bufferID)->GetNumberOfLine() * letterHeight;
}
// TODO : remove this from here ...
#include <ewol/importgl.h>
bool CodeView::OnDraw(void)
{
//glLoadIdentity();
glTranslatef(m_origin.x,m_origin.y, 0);
m_OObjectsColored[ m_currentDrawId].Draw();
m_OObjectTextNormal[ m_currentDrawId].Draw();
m_OObjectTextBold[ m_currentDrawId].Draw();
m_OObjectTextItalic[ m_currentDrawId].Draw();
m_OObjectTextBoldItalic[m_currentDrawId].Draw();
glTranslatef(-m_origin.x,-m_origin.y, 0);
return true;
}
void CodeView::OnRegenerateDisplay(void)
{
@ -101,32 +117,33 @@ void CodeView::OnRegenerateDisplay(void)
// For the scrooling windows
CalculateMaxSize();
// create tmp object :
ewol::OObject2DTextColored* myOObjectTextNormal = new ewol::OObject2DTextColored(m_fontNormal);
ewol::OObject2DTextColored* myOObjectTextBold = new ewol::OObject2DTextColored(m_fontBold);
ewol::OObject2DTextColored* myOObjectTextItalic = new ewol::OObject2DTextColored(m_fontItalic);
ewol::OObject2DTextColored* myOObjectTextBoldItalic = new ewol::OObject2DTextColored(m_fontBoldItalic);
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
// clean internal elements ...
m_OObjectTextNormal[ m_currentCreateId].SetFontID(m_fontNormal);
m_OObjectTextBold[ m_currentCreateId].SetFontID(m_fontBold);
m_OObjectTextItalic[ m_currentCreateId].SetFontID(m_fontItalic);
m_OObjectTextBoldItalic[m_currentCreateId].SetFontID(m_fontBoldItalic);
m_OObjectTextNormal[ m_currentCreateId].Clear();
m_OObjectTextBold[ m_currentCreateId].Clear();
m_OObjectTextItalic[ m_currentCreateId].Clear();
m_OObjectTextBoldItalic[m_currentCreateId].Clear();
m_OObjectsColored[ m_currentCreateId].Clear();
// generate the objects :
//m_bufferID = 0;
m_bufferManager->Get(m_bufferID)->Display(myOObjectTextNormal, myOObjectTextBold, myOObjectTextItalic, myOObjectTextBoldItalic, myOObjectsColored,
m_bufferManager->Get(m_bufferID)->Display(m_OObjectTextNormal[m_currentCreateId],
m_OObjectTextBold[m_currentCreateId],
m_OObjectTextItalic[m_currentCreateId],
m_OObjectTextBoldItalic[m_currentCreateId],
m_OObjectsColored[m_currentCreateId],
m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y);
// clean the object list ...
ClearOObjectList();
// add generated element
AddOObject(myOObjectsColored, "CodeViewBackground");
AddOObject(myOObjectTextNormal, "CodeViewTextNormal");
AddOObject(myOObjectTextBold, "CodeViewTextBold");
AddOObject(myOObjectTextItalic, "CodeViewTextItalic");
AddOObject(myOObjectTextBoldItalic, "CodeViewTextBoldItalic");
int64_t stopTime = GetCurrentTime();
EDN_DEBUG("Display Code Generation = " << stopTime - startTime << " milli-s");
// call the herited class...
WidgetScrooled::OnRegenerateDisplay();
m_needFlipFlop = true;
}
}

View File

@ -42,13 +42,20 @@ class CodeView :public ewol::WidgetScrooled
virtual ~CodeView(void);
virtual bool CalculateMinSize(void);
private:
etk::UString m_label;
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;
int32_t m_bufferID;
bool m_buttunOneSelected;
etk::UString m_label;
color_ts m_textColorFg; //!< Text color
color_ts m_textColorBg; //!< Background color
BufferManager * m_bufferManager;
ColorizeManager * m_colorManager;
int32_t m_bufferID;
bool m_buttunOneSelected;
// drawing elements :
ewol::OObject2DTextColored m_OObjectTextNormal[NB_BOUBLE_BUFFER];
ewol::OObject2DTextColored m_OObjectTextBold[NB_BOUBLE_BUFFER];
ewol::OObject2DTextColored m_OObjectTextItalic[NB_BOUBLE_BUFFER];
ewol::OObject2DTextColored m_OObjectTextBoldItalic[NB_BOUBLE_BUFFER];
ewol::OObject2DColored m_OObjectsColored[NB_BOUBLE_BUFFER];
public:
virtual void OnRegenerateDisplay(void);
bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
@ -72,6 +79,9 @@ class CodeView :public ewol::WidgetScrooled
void SetFontNameBoldItalic(etk::UString fontName);
private:
void CalculateMaxSize(void);
// widget drawing :
protected:
virtual bool OnDraw(void);
};
#endif