[DEV] adapte vector 2D, 3D and 4D wrapper with statdard glsl vec[2-4] ivec[2-4] and std mat4

This commit is contained in:
Edouard DUPIN 2012-12-03 10:00:43 +01:00
parent 33a9050df2
commit fcb060c416
5 changed files with 44 additions and 44 deletions

View File

@ -113,9 +113,9 @@ bool BufferText::NeedToUpdateDisplayPosition(void)
return tmpVal;
}
etk::Vector2D<float> BufferText::GetBorderSize(void)
vec2 BufferText::GetBorderSize(void)
{
etk::Vector2D<float> tmpVal;
vec2 tmpVal;
tmpVal.x = 30;
tmpVal.y = 30;
return tmpVal;
@ -260,7 +260,7 @@ void BufferText::DrawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY
sprintf(tmpLineNumber, "%*d", nbColomn, lineNumber);
OOText->SetColorBg(ColorizeManager::Get(COLOR_LIST_BG_2));
OOText->SetColor(ColorizeManager::Get(COLOR_CODE_LINE_NUMBER));
OOText->SetPos(etk::Vector3D<float>(1.0f, (float)positionY, 0.0f) );
OOText->SetPos(vec3(1.0f, (float)positionY, 0.0f) );
OOText->Print(tmpLineNumber);
}
@ -315,7 +315,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
bool selIsRect;
int32_t selHave;
etk::Vector3D<float> tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
vec3 tmpLetterSize = OOText.CalculateSize((uniChar_t)'A');
int32_t letterWidth = tmpLetterSize.x;
int32_t letterHeight = tmpLetterSize.y;
@ -326,7 +326,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
// update the display position with the scroll ofset :
int32_t displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, displayStartLineId);
etk::Vector2D<float> maxSize;
vec2 maxSize;
maxSize.x = 0.0;
maxSize.y = m_EdnBuf.NumberOfLines() * letterHeight;
int32_t nbColoneForLineNumber = GetLineNumberNumberOfElement();
@ -376,10 +376,10 @@ int32_t BufferText::Display(ewol::Text& OOText,
DrawLineNumber(&OOText, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
int32_t pixelX = x_base + SEPARATION_SIZE_LINE_NUMBER;
etk::Vector3D<float> drawClippingPos(0,0,-0.5);
etk::Vector3D<float> drawClippingSize(sizeX, sizeY, 1);
OOText.SetClippingWidth(etk::Vector3D<float>((float)pixelX, 0.0f, -0.5f),
etk::Vector3D<float>((float)(sizeX - drawClippingPos.x), (float)sizeY, 0.5f) );
vec3 drawClippingPos(0,0,-0.5);
vec3 drawClippingSize(sizeX, sizeY, 1);
OOText.SetClippingWidth(vec3((float)pixelX, 0.0f, -0.5f),
vec3((float)(sizeX - drawClippingPos.x), (float)sizeY, 0.5f) );
// Clear the line intexation :
m_elmentList.Clear();
@ -391,7 +391,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
tmpElementProperty.m_bufferPos = displayStartBufferPos;
m_elmentList.PushBack(tmpElementProperty);
etk::Vector3D<float> tmpCursorPosition(0, 0, -1); //Cursor is display only at the end to be all time over the background ... (-1 in z no cursor)
vec3 tmpCursorPosition(0, 0, -1); //Cursor is display only at the end to be all time over the background ... (-1 in z no cursor)
float lineMaxSize = 0.0;
for (iii=displayStartBufferPos; iii<mylen && displayLines >=0 && y >= -2*letterHeight; iii = new_i) {
@ -405,7 +405,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
int32_t drawSize = 0;
// update display position :
etk::Vector2D<float> textPos;
vec2 textPos;
textPos.x = pixelX-offsetX;
textPos.y = y;
// update X pos
@ -449,7 +449,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
OOText.SetFontBold(selectColor->GetBold());
OOText.SetFontItalic(selectColor->GetItalic());
myStringToDisplay = displayChar;
OOText.SetPos(etk::Vector3D<float>(textPos.x, textPos.y, 0.0f) );
OOText.SetPos(vec3(textPos.x, textPos.y, 0.0f) );
OOText.Print(myStringToDisplay);
// To update the display position
drawSize = OOText.GetPos().x - textPos.x;
@ -460,7 +460,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
idX += displaywidth;
// display cursor :
if (m_cursorPos == iii) {
tmpCursorPosition = etk::Vector3D<float>(pixelX - offsetX, y, 0);
tmpCursorPosition = vec3(pixelX - offsetX, y, 0);
}
lineMaxSize += drawSize;
pixelX += drawSize;
@ -486,7 +486,7 @@ int32_t BufferText::Display(ewol::Text& 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) {
tmpCursorPosition = etk::Vector3D<float>(pixelX - offsetX, y, 0);
tmpCursorPosition = vec3(pixelX - offsetX, y, 0);
}
if (tmpCursorPosition.z!=-1) {
// display the cursor:
@ -505,7 +505,7 @@ int32_t BufferText::Display(ewol::Text& OOText,
int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
int32_t BufferText::GetMousePosition(vec2 pos)
{
bool inLineDone=false;
//APPL_DEBUG("try to find in : " << width << "," << height);
@ -557,7 +557,7 @@ int32_t BufferText::GetMousePosition(etk::Vector2D<float> pos)
*
*/
// TODO : Simplify selection ....
void BufferText::MouseEvent(etk::Vector2D<float> pos)
void BufferText::MouseEvent(vec2 pos)
{
if (ewol::GetCurrentSpecialKeyStatus().IsSetShift() ) {
MouseSelectFromCursorTo(pos);
@ -587,7 +587,7 @@ void BufferText::MouseEvent(etk::Vector2D<float> pos)
* @todo : Set the move up and DOWN...
*
*/
void BufferText::MouseSelectFromCursorTo(etk::Vector2D<float> pos)
void BufferText::MouseSelectFromCursorTo(vec2 pos)
{
// Get the caracter mouse position
int32_t newPos = GetMousePosition(pos);
@ -866,11 +866,11 @@ void BufferText::cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent)
* @return ---
*
*/
etk::Vector2D<float> BufferText::GetPosition(int32_t fontId, bool& centerRequested)
vec2 BufferText::GetPosition(int32_t fontId, bool& centerRequested)
{
centerRequested = m_centerRequested;
m_centerRequested = false;
etk::Vector2D<float> outputPosition;
vec2 outputPosition;
// Display position (Y mode):
APPL_INFO("change the position : " << m_cursorPos);
@ -898,7 +898,7 @@ etk::Vector2D<float> BufferText::GetPosition(int32_t fontId, bool& centerReques
/* if we request a center :
} else {
// center the line at the middle of the screen :
etk::Vector2D<float> outputPosition;
vec2 outputPosition;
//APPL_DEBUG(" -------------------------------------------------");
outputPosition.y = m_EdnBuf.CountLines(0, m_cursorPos);
//APPL_DEBUG(" cursor position : " << m_cursorPos << " ==> ligne=" << outputPosition.y);

View File

@ -54,14 +54,14 @@ class BufferText
etk::FSNode m_fileName; //!< filename of the curent buffer
bool m_haveName; //!< to know if the file have a name or NOT
bool m_updatePositionRequested; //!< if a position xhange in the windows ...
etk::Vector2D<float> m_maximumSize; //!< current maxSize of the buffer
vec2 m_maximumSize; //!< current maxSize of the buffer
public:
void SetModify(bool status);
virtual etk::Vector2D<float> GetBorderSize(void);
virtual vec2 GetBorderSize(void);
void RequestUpdateOfThePosition(void) { m_updatePositionRequested = true; };
void SetMaximumSize(etk::Vector2D<float> maxSize) { m_maximumSize = maxSize; };
void SetMaximumSize(vec2 maxSize) { m_maximumSize = maxSize; };
bool NeedToUpdateDisplayPosition(void);
etk::Vector2D<float> GetMaxSize(void) { return m_maximumSize; };
vec2 GetMaxSize(void) { return m_maximumSize; };
bool IsModify(void);
public:
etk::FSNode GetFileName(void)
@ -100,8 +100,8 @@ class BufferText
int32_t sizeX, int32_t sizeY);
void AddChar(uniChar_t unicodeData);
void cursorMove(ewol::keyEvent::keyboard_te moveTypeEvent);
void MouseSelectFromCursorTo(etk::Vector2D<float> pos);
void MouseEvent(etk::Vector2D<float> pos);
void MouseSelectFromCursorTo(vec2 pos);
void MouseEvent(vec2 pos);
void MouseEventDouble(void);
void MouseEventTriple(void);
@ -130,7 +130,7 @@ class BufferText
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
etk::Vector2D<float> m_displaySize; //!< number of char displayable in the screan
vec2 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 ...
@ -142,13 +142,13 @@ class BufferText
private:
bool m_centerRequested;
public:
virtual etk::Vector2D<float> GetPosition(int32_t fontId, bool& centerRequested);
virtual vec2 GetPosition(int32_t fontId, bool& centerRequested);
private:
bool TextDMoveUp(int32_t offset);
bool TextDMoveDown(int32_t offset);
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
int32_t GetMousePosition(etk::Vector2D<float> pos);
int32_t GetMousePosition(vec2 pos);
void DrawLineNumber(ewol::Text* OOText, int32_t sizeX, int32_t sizeY, int32_t nbColomn, int32_t lineNumber, int32_t positionY);

View File

@ -84,7 +84,7 @@ CodeView::~CodeView(void)
*/
void CodeView::UpdateNumberOfLineReference(int32_t bufferID)
{
etk::Vector2D<float> tmpCoord;
vec2 tmpCoord;
tmpCoord.x = 0;
tmpCoord.y = 0;
if (m_lineNumberList.Size()<=bufferID) {
@ -135,17 +135,17 @@ void CodeView::OnRegenerateDisplay(void)
m_displayText.Clear();
// Reset the background :
m_displayDrawing.SetPos(etk::Vector3D<float>(-2048, -2048, 0));
m_displayDrawing.SetPos(vec3(-2048, -2048, 0));
m_displayDrawing.SetColor(ColorizeManager::Get(COLOR_CODE_BASIC_BG));
m_displayDrawing.RectangleWidth(etk::Vector3D<float>(4096, 4096, 0) );
m_displayDrawing.RectangleWidth(vec3(4096, 4096, 0) );
BufferText* tmpBuffer = BufferManager::Get(m_bufferID);
if( NULL != tmpBuffer
&& true == tmpBuffer->NeedToUpdateDisplayPosition() ) {
etk::Vector2D<float> borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
vec2 borderWidth = BufferManager::Get(m_bufferID)->GetBorderSize();
bool centerRequested = false;
// TODO : set it back ...
etk::Vector2D<float> currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested);
vec2 currentPosition = BufferManager::Get(m_bufferID)->GetPosition(999/*m_OObjectTextNormal.GetFontID()*/, centerRequested);
SetScrollingPositionDynamic(borderWidth, currentPosition, centerRequested);
} // else : nothing to do ...
@ -153,10 +153,10 @@ void CodeView::OnRegenerateDisplay(void)
if (-1 == m_bufferID) {
m_displayText.SetTextAlignement(10, m_size.x-20, ewol::Text::alignLeft);
m_displayDrawing.SetColor(0x00000022);
m_displayDrawing.SetPos(etk::Vector3D<float>(10, 0, 0));
m_displayDrawing.Rectangle(etk::Vector3D<float>((int32_t)m_size.x-20, 1500, 0) );
m_displayDrawing.SetPos(vec3(10, 0, 0));
m_displayDrawing.Rectangle(vec3((int32_t)m_size.x-20, 1500, 0) );
m_displayText.SetRelPos(etk::Vector3D<float>(10, 0, 0));
m_displayText.SetRelPos(vec3(10, 0, 0));
// nothing to display :
etk::UString tmpString("<br/>\n"
"<font color=\"red\">\n"
@ -191,7 +191,7 @@ void CodeView::OnRegenerateDisplay(void)
"<justify>\n"
" Un jour Cosette se <b>regarda</b> par hasard dans son miroir et se dit: Tiens! <b>Il lui semblait presque <i>qu'elle était jolie.</i></b> Ceci la jeta dans un trouble singulier. <font color=\"#FF0\">Jusqu'à ce moment elle <b>n'avait</b> point <i>songé</i> à sa figure.</font> Elle se voyait dans son miroir, mais elle ne s'y regardait pas. Et puis, on lui avait souvent dit qu'elle était laide;<br/> Jean Valjean seul disait doucement :<br/> Mais non!<br/> mais non!<br/> Quoi qu'il en fut, 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 drole 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"
"</justify>\n");
m_displayText.SetPos(etk::Vector3D<float>(0.0f, m_size.y, 0.0f) );
m_displayText.SetPos(vec3(0.0f, m_size.y, 0.0f) );
m_displayText.ForceLineReturn();
m_displayText.PrintDecorated(tmpString);
} else {
@ -261,13 +261,13 @@ void CodeView::OnEventClipboard(ewol::clipBoard::clipboardListe_te clipboardID)
* @return true the event is used
* @return false the event is not used
*/
bool CodeView::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, etk::Vector2D<float> pos)
bool CodeView::OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos)
{
etk::Vector2D<float> relativePos = RelativePosition(pos);
vec2 relativePos = RelativePosition(pos);
// corection for the openGl abstraction
//relativePos.y = m_size.y - relativePos.y;
etk::Vector2D<float> limitedPos = relativePos;
vec2 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 (true == WidgetScrooled::OnEventInput(type, IdInput, typeEvent, pos)) {

View File

@ -35,7 +35,7 @@ class CodeView :public widget::WidgetScrooled
draw::Color m_textColorBg; //!< Background color
int32_t m_bufferID;
bool m_buttunOneSelected;
etk::Vector<etk::Vector2D<float> > m_lineNumberList;
etk::Vector<vec2 > m_lineNumberList;
void UpdateNumberOfLineReference(int32_t bufferID);
// drawing elements :
ewol::Text m_displayText;
@ -47,7 +47,7 @@ class CodeView :public widget::WidgetScrooled
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
public:
// Derived function
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, etk::Vector2D<float> pos);
virtual bool OnEventInput(ewol::keyEvent::type_te type, int32_t IdInput, ewol::keyEvent::status_te typeEvent, vec2 pos);
// Derived function
virtual bool OnEventKb(ewol::keyEvent::status_te typeEvent, uniChar_t unicodeData);
// Derived function

View File

@ -61,7 +61,7 @@ void APP_Init(void)
APPL_INFO("==> Init "PROJECT_NAME" (START) (Android) (Debug)");
#endif
#endif
ewol::ChangeSize(etk::Vector2D<int32_t>(800, 600));
ewol::ChangeSize(ivec2(800, 600));
etk::InitDefaultFolder(PROJECT_NAME);
#ifdef __TARGET_OS__Android
ewol::config::FontSetDefault("FreeSerif", 19);