[DEV] update to the new vector 3d

This commit is contained in:
Edouard DUPIN 2013-01-28 22:46:48 +01:00
parent 4f09da0f0f
commit c767266dfe
2 changed files with 43 additions and 49 deletions

View File

@ -45,8 +45,7 @@ void BufferText::BasicInit(void)
m_cursorPos = 0; m_cursorPos = 0;
m_cursorPreferredCol = -1; m_cursorPreferredCol = -1;
//m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL; //m_cursorMode = CURSOR_DISPLAY_MODE_NORMAL;
m_displaySize.x = 200; m_displaySize.setValue(200,20);
m_displaySize.y = 20;
m_centerRequested = false; m_centerRequested = false;
} }
@ -116,8 +115,7 @@ bool BufferText::NeedToUpdateDisplayPosition(void)
vec2 BufferText::GetBorderSize(void) vec2 BufferText::GetBorderSize(void)
{ {
vec2 tmpVal; vec2 tmpVal;
tmpVal.x = 30; tmpVal.setValue(30,30);
tmpVal.y = 30;
return tmpVal; return tmpVal;
} }
@ -315,8 +313,8 @@ int32_t BufferText::Display(ewol::Text& OOText,
vec3 tmpLetterSize = OOText.CalculateSize((uniChar_t)'A'); vec3 tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
int32_t letterWidth = tmpLetterSize.x; int32_t letterWidth = tmpLetterSize.x();
int32_t letterHeight = tmpLetterSize.y; int32_t letterHeight = tmpLetterSize.y();
int32_t displayStartLineId = offsetY / letterHeight - 1; int32_t displayStartLineId = offsetY / letterHeight - 1;
displayStartLineId = etk_max(0, displayStartLineId); displayStartLineId = etk_max(0, displayStartLineId);
@ -325,14 +323,14 @@ int32_t BufferText::Display(ewol::Text& OOText,
// update the display position with the scroll ofset : // update the display position with the scroll ofset :
int32_t displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId); int32_t displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
vec2 maxSize; vec2 maxSize;
maxSize.x = 0.0; maxSize.setX(0);
maxSize.y = m_EdnBuf.NumberOfLines() * tmpLetterSize.y; maxSize.setY(m_EdnBuf.NumberOfLines() * tmpLetterSize.y());
int32_t nbColoneForLineNumber = GetLineNumberNumberOfElement(); int32_t nbColoneForLineNumber = GetLineNumberNumberOfElement();
// update the number of element that can be displayed // update the number of element that can be displayed
m_displaySize.x = (sizeX/letterWidth) + 1 - nbColoneForLineNumber; m_displaySize.setX((sizeX/letterWidth) + 1 - nbColoneForLineNumber);
m_displaySize.y = (sizeY/letterHeight) + 1; m_displaySize.setY((sizeY/letterHeight) + 1);
APPL_VERBOSE("main DIPLAY " << m_displaySize.x << " char * " << m_displaySize.y << " char"); APPL_VERBOSE("main DIPLAY " << m_displaySize.x() << " char * " << m_displaySize.y() << " char");
selHave = m_EdnBuf.GetSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd); selHave = m_EdnBuf.GetSelectionPos(selStart, selEnd, selIsRect, selRectStart, selRectEnd);
@ -353,7 +351,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
int displayLines = 0; int displayLines = 0;
// Regenerate the colorizing if necessary ... // Regenerate the colorizing if necessary ...
displayHLData_ts m_displayLocalSyntax; displayHLData_ts m_displayLocalSyntax;
m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, displayStartBufferPos, m_displaySize.y); m_EdnBuf.HightlightGenerateLines(m_displayLocalSyntax, displayStartBufferPos, m_displaySize.y());
int64_t stopTime = ewol::GetTime(); int64_t stopTime = ewol::GetTime();
APPL_DEBUG("Parsing Highlight = " << stopTime - startTime << " micro-s"); APPL_DEBUG("Parsing Highlight = " << stopTime - startTime << " micro-s");
@ -377,7 +375,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
vec3 drawClippingPos(0,0,-0.5); vec3 drawClippingPos(0,0,-0.5);
vec3 drawClippingSize(sizeX, sizeY, 1); vec3 drawClippingSize(sizeX, sizeY, 1);
OOText.SetClippingWidth(vec3((float)pixelX, 0.0f, -0.5f), OOText.SetClippingWidth(vec3((float)pixelX, 0.0f, -0.5f),
vec3((float)(sizeX - drawClippingPos.x), (float)sizeY, 0.5f) ); vec3((float)(sizeX - drawClippingPos.x()), (float)sizeY, 0.5f) );
// Clear the line intexation : // Clear the line intexation :
m_elmentList.Clear(); m_elmentList.Clear();
@ -403,12 +401,10 @@ int32_t BufferText::Display(ewol::Text& OOText,
int32_t drawSize = 0; int32_t drawSize = 0;
// update display position : // update display position :
vec2 textPos; vec2 textPos(pixelX-offsetX, y);
textPos.x = pixelX-offsetX;
textPos.y = y;
// update X pos // update X pos
tmpElementProperty.m_xOffset = textPos.x; tmpElementProperty.m_xOffset = textPos.x();
tmpElementProperty.m_yOffset = textPos.y; tmpElementProperty.m_yOffset = textPos.y();
//APPL_INFO("diplay element=" << new_i); //APPL_INFO("diplay element=" << new_i);
if (currentChar!='\n') { if (currentChar!='\n') {
@ -447,10 +443,10 @@ int32_t BufferText::Display(ewol::Text& OOText,
OOText.SetFontBold(selectColor->GetBold()); OOText.SetFontBold(selectColor->GetBold());
OOText.SetFontItalic(selectColor->GetItalic()); OOText.SetFontItalic(selectColor->GetItalic());
myStringToDisplay = displayChar; myStringToDisplay = displayChar;
OOText.SetPos(vec3(textPos.x, textPos.y, 0.0f) ); OOText.SetPos(vec3(textPos.x(), textPos.y(), 0.0f) );
OOText.Print(myStringToDisplay); OOText.Print(myStringToDisplay);
// To update the display position // To update the display position
drawSize = OOText.GetPos().x - textPos.x; drawSize = OOText.GetPos().x() - textPos.x();
//APPL_DEBUG("add element : " << tmpElementProperty.m_yOffset << "," << tmpElementProperty.m_xOffset); //APPL_DEBUG("add element : " << tmpElementProperty.m_yOffset << "," << tmpElementProperty.m_xOffset);
m_elmentList.PushBack(tmpElementProperty); m_elmentList.PushBack(tmpElementProperty);
@ -464,7 +460,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
pixelX += drawSize; pixelX += drawSize;
// move to next line ... // move to next line ...
if (currentChar=='\n') { if (currentChar=='\n') {
maxSize.x = etk_max(lineMaxSize, maxSize.x); maxSize.setX(etk_max(lineMaxSize, maxSize.x()));
lineMaxSize = 0.0; lineMaxSize = 0.0;
idX =0; idX =0;
pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER; pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
@ -486,7 +482,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
if (m_cursorPos == iii) { if (m_cursorPos == iii) {
tmpCursorPosition = vec3(pixelX - offsetX, y, 0); tmpCursorPosition = vec3(pixelX - offsetX, y, 0);
} }
if (tmpCursorPosition.z!=-1) { if (tmpCursorPosition.z()!=-1) {
// display the cursor: // display the cursor:
OOText.SetPos(tmpCursorPosition); OOText.SetPos(tmpCursorPosition);
OOText.SetColor(ColorizeManager::Get(COLOR_CODE_CURSOR)); OOText.SetColor(ColorizeManager::Get(COLOR_CODE_CURSOR));
@ -510,8 +506,8 @@ int32_t BufferText::GetMousePosition(vec2 pos)
for(int32_t iii=0; iii<m_elmentList.Size()-1; iii++) { 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)); //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(false == inLineDone) {
if( pos.y>=m_elmentList[iii].m_yOffset if( pos.y()>=m_elmentList[iii].m_yOffset
&& pos.y<m_elmentList[iii].m_yOffset + m_elmentList[iii].m_ySize ) { && pos.y()<m_elmentList[iii].m_yOffset + m_elmentList[iii].m_ySize ) {
// we find the line (int theory) ==> note : Some problem can appear here when the size are not the same ... // we find the line (int theory) ==> note : Some problem can appear here when the size are not the same ...
// this is to prevent multiple size font ... // this is to prevent multiple size font ...
inLineDone = true; inLineDone = true;
@ -520,8 +516,8 @@ int32_t BufferText::GetMousePosition(vec2 pos)
} }
// we detected the line // we detected the line
if(true == inLineDone) { if(true == inLineDone) {
if( pos.x>=m_elmentList[iii].m_xOffset if( pos.x()>=m_elmentList[iii].m_xOffset
&& pos.x<m_elmentList[iii+1].m_xOffset ) { && pos.x()<m_elmentList[iii+1].m_xOffset ) {
// we get the position ... // we get the position ...
return m_elmentList[iii].m_bufferPos; return m_elmentList[iii].m_bufferPos;
} else if (m_elmentList[iii].m_xOffset>=m_elmentList[iii+1].m_xOffset) { } else if (m_elmentList[iii].m_xOffset>=m_elmentList[iii+1].m_xOffset) {
@ -531,7 +527,7 @@ int32_t BufferText::GetMousePosition(vec2 pos)
} }
} }
if (m_elmentList.Size()>0) { if (m_elmentList.Size()>0) {
if(pos.y<m_elmentList[m_elmentList.Size()/2].m_yOffset) { if(pos.y()<m_elmentList[m_elmentList.Size()/2].m_yOffset) {
//APPL_DEBUG("Error to get position (return Last)"); //APPL_DEBUG("Error to get position (return Last)");
return m_elmentList[m_elmentList.Size()-1].m_bufferPos; return m_elmentList[m_elmentList.Size()-1].m_bufferPos;
} else { } else {
@ -831,11 +827,11 @@ void BufferText::cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent)
break; break;
case ewol::keyEvent::keyboardPageUp: case ewol::keyEvent::keyboardPageUp:
//APPL_INFO("keyEvent : <PAGE-UP>"); //APPL_INFO("keyEvent : <PAGE-UP>");
TextDMoveUp(m_displaySize.y); TextDMoveUp(m_displaySize.y());
break; break;
case ewol::keyEvent::keyboardPageDown: case ewol::keyEvent::keyboardPageDown:
//APPL_INFO("keyEvent : <PAGE-DOWN>"); //APPL_INFO("keyEvent : <PAGE-DOWN>");
TextDMoveDown(m_displaySize.y); TextDMoveDown(m_displaySize.y());
break; break;
case ewol::keyEvent::keyboardStart: case ewol::keyEvent::keyboardStart:
//APPL_INFO("keyEvent : <Start of line>"); //APPL_INFO("keyEvent : <Start of line>");
@ -873,11 +869,11 @@ vec2 BufferText::GetPosition(int32_t fontId, bool& centerRequested)
// Display position (Y mode): // Display position (Y mode):
APPL_INFO("change the position : " << m_cursorPos); APPL_INFO("change the position : " << m_cursorPos);
// get the line id of the curent position of the cursor : // get the line id of the curent position of the cursor :
outputPosition.y = m_EdnBuf.CountLines(0, m_cursorPos); outputPosition.setY(m_EdnBuf.CountLines(0, m_cursorPos));
// get the first position of the current line // get the first position of the current line
int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos); int32_t lineStartPos = m_EdnBuf.StartOfLine(m_cursorPos);
// count the number of char in the line (real displayed char with whar like <kjkj>) // count the number of char in the line (real displayed char with whar like <kjkj>)
outputPosition.x = m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos); outputPosition.setX(m_EdnBuf.CountDispChars(lineStartPos, m_cursorPos));
APPL_INFO("Curent cursor pos=" << outputPosition); APPL_INFO("Curent cursor pos=" << outputPosition);
// get font porperties : // get font porperties :
@ -889,8 +885,8 @@ vec2 BufferText::GetPosition(int32_t fontId, bool& centerRequested)
*/ */
float letterWidth = 10; float letterWidth = 10;
float letterHeight = 15; float letterHeight = 15;
outputPosition.x *= letterWidth; outputPosition.setValue(outputPosition.x() * letterWidth,
outputPosition.y *= letterHeight; outputPosition.y() * letterHeight);
return outputPosition; return outputPosition;
/* if we request a center : /* if we request a center :

View File

@ -85,8 +85,7 @@ CodeView::~CodeView(void)
void CodeView::UpdateNumberOfLineReference(int32_t bufferID) void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
{ {
vec2 tmpCoord; vec2 tmpCoord;
tmpCoord.x = 0; tmpCoord.setValue(0,0);
tmpCoord.y = 0;
if (m_lineNumberList.Size()<=bufferID) { if (m_lineNumberList.Size()<=bufferID) {
// update the number of elements : // update the number of elements :
for (int32_t iii=m_lineNumberList.Size(); iii <= bufferID; iii++) { for (int32_t iii=m_lineNumberList.Size(); iii <= bufferID; iii++) {
@ -99,20 +98,19 @@ void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
bool CodeView::CalculateMinSize(void) bool CodeView::CalculateMinSize(void)
{ {
m_minSize.x = 50; m_minSize.setValue(50,50);
m_minSize.y = 50;
return true; return true;
} }
void CodeView::CalculateMaxSize(void) void CodeView::CalculateMaxSize(void)
{ {
m_maxSize.x = 2048; m_maxSize.setX(2048);
int32_t letterHeight = m_displayText.CalculateSize('A').y; int32_t letterHeight = m_displayText.CalculateSize('A').y();
BufferText* tmpBuffer = BufferManager::Get(m_bufferID); BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) { if (NULL!=tmpBuffer) {
m_maxSize.y = tmpBuffer->GetNumberOfLine() * letterHeight; m_maxSize.setY(tmpBuffer->GetNumberOfLine() * letterHeight);
} else { } else {
m_maxSize.y = 50; m_maxSize.setY(50);
} }
} }
@ -151,10 +149,10 @@ void CodeView::OnRegenerateDisplay(void)
// generate the objects : // generate the objects :
if (-1 == m_bufferID) { if (-1 == m_bufferID) {
m_displayText.SetTextAlignement(10, m_size.x-20, ewol::Text::alignLeft); m_displayText.SetTextAlignement(10, m_size.x()-20, ewol::Text::alignLeft);
m_displayDrawing.SetColor(0x00000022); m_displayDrawing.SetColor(0x00000022);
m_displayDrawing.SetPos(vec3(10, 0, 0)); m_displayDrawing.SetPos(vec3(10, 0, 0));
m_displayDrawing.Rectangle(vec3((int32_t)m_size.x-20, 1500, 0) ); m_displayDrawing.Rectangle(vec3((int32_t)m_size.x()-20, 1500, 0) );
m_displayText.SetRelPos(vec3(10, 0, 0)); m_displayText.SetRelPos(vec3(10, 0, 0));
// nothing to display : // nothing to display :
@ -171,13 +169,13 @@ void CodeView::OnRegenerateDisplay(void)
" No Buffer Availlable to display\n" " No Buffer Availlable to display\n"
" </i>\n" " </i>\n"
"</font>\n"); "</font>\n");
m_displayText.SetPos(vec3(0.0f, m_size.y, 0.0f) ); m_displayText.SetPos(vec3(0.0f, m_size.y(), 0.0f) );
m_displayText.ForceLineReturn(); m_displayText.ForceLineReturn();
m_displayText.PrintDecorated(tmpString); m_displayText.PrintDecorated(tmpString);
} else { } else {
BufferText* tmpBuffer = BufferManager::Get(m_bufferID); BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if (NULL!=tmpBuffer) { if (NULL!=tmpBuffer) {
tmpBuffer->Display(m_displayText, m_originScrooled.x, m_originScrooled.y, m_size.x, m_size.y); tmpBuffer->Display(m_displayText, m_originScrooled.x(), m_originScrooled.y(), m_size.x(), m_size.y());
} }
// set the current size of the windows // set the current size of the windows
SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize()); SetMaxSize(BufferManager::Get(m_bufferID)->GetMaxSize());
@ -248,8 +246,8 @@ bool CodeView::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol:
//relativePos.y = m_size.y - relativePos.y; //relativePos.y = m_size.y - relativePos.y;
vec2 limitedPos = relativePos; vec2 limitedPos = relativePos;
limitedPos.x = etk_avg(1, limitedPos.x, m_size.x-1); limitedPos.setValue(etk_avg(1, limitedPos.x(), m_size.x()-1),
limitedPos.y = etk_avg(1, limitedPos.y, m_size.y-1); etk_avg(1, limitedPos.y(), m_size.y()-1));
if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) { if (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this); ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widget ... // nothing to do ... done on upper widget ...
@ -306,8 +304,8 @@ bool CodeView::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol:
} else if (ewol::keyEvent::statusMove == typeEvent) { } else if (ewol::keyEvent::statusMove == typeEvent) {
if (true == m_buttunOneSelected) { if (true == m_buttunOneSelected) {
int xxx, yyy; int xxx, yyy;
xxx = relativePos.x; xxx = relativePos.x();
yyy = relativePos.y; yyy = relativePos.y();
if (xxx<0) { if (xxx<0) {
xxx = 0; xxx = 0;
} }