Change makefile principe and rework the mouse position event

This commit is contained in:
Edouard Dupin 2012-08-31 16:46:57 +02:00
parent 27db00a6f6
commit 244b83ed16
10 changed files with 281 additions and 85 deletions

View File

@ -91,8 +91,8 @@ class Buffer {
}
virtual void AddChar(uniChar_t unicodeData) {};
virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent) {};
virtual void MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height) {};
virtual void MouseEvent(int32_t fontId, int32_t width, int32_t height) {};
virtual void MouseSelectFromCursorTo(Vector2D<float> pos) {};
virtual void MouseEvent(Vector2D<float> pos) {};
virtual void MouseEventDouble(void) {};
virtual void MouseEventTriple(void) {};
virtual void RemoveLine(void) {};

View File

@ -372,14 +372,35 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
OOTextBoldItalic.clippingSet(drawClippingTextArea);
OOColored.clippingSet(drawClippingTextArea);
// Clear the line intexation :
m_elmentList.Clear();
// every char element is register to find the diplay pos when mouse event arrive
CharElement tmpElementProperty;
tmpElementProperty.m_yOffset = y;
tmpElementProperty.m_xOffset = 0;
tmpElementProperty.m_ySize = 10;
tmpElementProperty.m_bufferPos = displayStartBufferPos;
m_elmentList.PushBack(tmpElementProperty);
float lineMaxSize = 0.0;
for (iii=displayStartBufferPos; iii<mylen && displayLines < m_displaySize.y ; iii = new_i) {
for (iii=displayStartBufferPos; iii<mylen && displayLines >=0 ; iii = new_i) {
//APPL_DEBUG("diplay element=" << iii);
int displaywidth;
uint32_t currentChar = '\0';
new_i = iii;
// update the element buffer pos:
tmpElementProperty.m_bufferPos = new_i;
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
int32_t drawSize = 0;
// update display position :
Vector2D<float> textPos;
textPos.x = pixelX-offsetX;
textPos.y = y;
// update X pos
tmpElementProperty.m_xOffset = textPos.x;
tmpElementProperty.m_yOffset = textPos.y;
//APPL_INFO("diplay element=" << new_i);
if (currentChar!='\n') {
selectColor = myColor;
@ -413,9 +434,6 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
haveBg = selectColor->HaveBg();
}
}
Vector2D<float> textPos;
textPos.x = pixelX-offsetX;
textPos.y = y;
if (true == selectColor->GetItalic() ) {
if (true == selectColor->GetBold() ) {
OOTextSelected = &OOTextBoldItalic;
@ -429,10 +447,14 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
OOTextSelected = &OOTextNormal;
}
}
tmpElementProperty.m_ySize = OOTextSelected->GetHeight();
//tmpElementProperty.m_yOffset += tmpElementProperty.m_ySize;
OOTextSelected->SetColor(selectColor->GetFG());
// TODO : Remove this unreallistic leak of time
myStringToDisplay = displayChar;
drawSize = OOTextSelected->Text(textPos, 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);
@ -460,6 +482,8 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
DrawLineNumber(&OOTextNormal, &OOColored, x_base, sizeY, nbColoneForLineNumber, currentLineID, y);
OOTextNormal.clippingEnable();
OOColored.clippingEnable();
// add elements :
m_elmentList.PushBack(tmpElementProperty);
}
}
// special case : the cursor is at the end of the buffer...
@ -476,70 +500,45 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t height)
int32_t BufferText::GetMousePosition(Vector2D<float> pos)
{
// TODO : Set it back ...
#if 1
int32_t letterWidth = 8;
int32_t letterHeight = 15;
#else
int32_t letterWidth = ewol::GetWidth(fontId, "9");
int32_t letterHeight = ewol::GetHeight(fontId);
/*
int32_t letterWidth = OOTextNormal.GetSize("A").x;
int32_t letterHeight = OOTextNormal.GetHeight();
*/
#endif
int32_t lineOffset = height / letterHeight;
//******************************* get the X position : *******************************************
int32_t iii, new_i;
int mylen = m_EdnBuf.Size();
int32_t x_base=GetLineNumberNumberOfElement()*letterWidth + SEPARATION_SIZE_LINE_NUMBER;
width -= x_base;
if (width < 0) {
width = 0;
}
int32_t idX = 0;
uniChar_t displayChar[MAX_EXP_CHAR_LEN];
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
int32_t pixelX = 0;
int32_t startLinePosition = m_EdnBuf.CountForwardNLines(0, lineOffset);
if (width <= 0) {
APPL_DEBUG(" Element : Befor the start of the line ... ==> END");
return startLinePosition;
}
APPL_VERBOSE("Get id element : x=" << width << "px y=" << height << "px");
APPL_VERBOSE(" line offset = " << lineOffset);
for (iii=startLinePosition; iii<mylen; iii = new_i) {
int displaywidth;
uint32_t currentChar = '\0';
new_i = iii;
displaywidth = m_EdnBuf.GetExpandedChar(new_i, idX, displayChar, currentChar);
if (currentChar!='\n') {
// TODO : Set it back ...
//int32_t drawSize = ewol::GetWidth(fontId, displayChar);
int32_t drawSize = 50;
APPL_VERBOSE(" Element : " << currentChar << "=\"" << (char)currentChar << "\" display offset=" << pixelX << "px width=" << drawSize << "px");
pixelX += drawSize;
if (width <= pixelX) {
APPL_VERBOSE(" Find IT ==> END");
// find position ...
break;
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
&& 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 ...
// this is to prevent multiple size font ...
inLineDone = true;
//APPL_DEBUG(" ==> " << m_elmentList[iii+1].m_xOffset << "> " << pos.x << " >=" << m_elmentList[iii].m_xOffset);
}
}
// we detected the line
if(true == inLineDone) {
if( pos.x>=m_elmentList[iii].m_xOffset
&& pos.x<m_elmentList[iii+1].m_xOffset ) {
// we get the position ...
return m_elmentList[iii].m_bufferPos;
} else if (m_elmentList[iii].m_xOffset>=m_elmentList[iii+1].m_xOffset) {
// prevent "end of line" cursor pos ...
return m_elmentList[iii].m_bufferPos;
}
} else {
APPL_VERBOSE(" Element : \"\\n\" display width=---px ==> end of line ==> END");
// end of line ... exit cycle
break;
}
idX += displaywidth;
}
APPL_VERBOSE("BufferText::GetMousePosition(" << width << "," << height << "); ==> " << iii );
return iii;
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;
} else {
//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;
}
}
@ -552,13 +551,13 @@ int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t heig
*
*/
// TODO : Simplify selection ....
void BufferText::MouseEvent(int32_t fontId, int32_t width, int32_t height)
void BufferText::MouseEvent(Vector2D<float> pos)
{
if (true == ewol::IsSetShift() ) {
MouseSelectFromCursorTo(fontId, width, height);
MouseSelectFromCursorTo(pos);
} else {
// Get the caracter mouse position
int32_t newPos = GetMousePosition(fontId, width, height);
int32_t newPos = GetMousePosition(pos);
// move the cursor
SetInsertPosition(newPos);
@ -582,11 +581,10 @@ void BufferText::MouseEvent(int32_t fontId, int32_t width, int32_t height)
* @todo : Set the move up and DOWN...
*
*/
// TODO : Simplify selection ....
void BufferText::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height)
void BufferText::MouseSelectFromCursorTo(Vector2D<float> pos)
{
// Get the caracter mouse position
int32_t newPos = GetMousePosition(fontId, width, height);
int32_t newPos = GetMousePosition(pos);
int32_t selStart, selEnd, selRectStart, selRectEnd;
bool selIsRect;

View File

@ -36,6 +36,15 @@ typedef enum {
CURSOR_DISPLAY_MODE_NOT_FOCUS,
} cursorDisplayMode_te;
class CharElement
{
public:
int16_t m_yOffset;
int16_t m_xOffset;
int16_t m_ySize;
int32_t m_bufferPos;
};
class BufferText : public Buffer {
public:
BufferText(void);
@ -55,8 +64,8 @@ class BufferText : public Buffer {
int32_t sizeX, int32_t sizeY);
void AddChar(uniChar_t unicodeData);
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
void MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height);
void MouseEvent(int32_t fontId, int32_t width, int32_t height);
void MouseSelectFromCursorTo(Vector2D<float> pos);
void MouseEvent(Vector2D<float> pos);
void MouseEventDouble(void);
void MouseEventTriple(void);
@ -84,12 +93,13 @@ class BufferText : public Buffer {
int32_t GetLineNumberNumberOfElement(void);
// Direct buffer IO
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
Vector2D<float> m_displaySize; //!< number of char displayable in the screan
EdnBuf m_EdnBuf; //!< buffer associated on this displayer
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 ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
int32_t m_cursorPos; //!< position in the buffer of the cursor
int32_t m_cursorPreferredCol; //!< colomn of the last up and down ...
cursorDisplayMode_te m_cursorMode; //!< type of cursor Selected
etk::Vector<CharElement> m_elmentList; //!< Elemnt position for every char displayed
// internal function
void BasicInit(void);
@ -102,7 +112,7 @@ class BufferText : public Buffer {
bool TextDMoveDown(int32_t offset);
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
int32_t GetMousePosition(int32_t fontId, int32_t width, int32_t height);
int32_t GetMousePosition(Vector2D<float> pos);
void DrawLineNumber(ewol::OObject2DTextColored* 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);

View File

@ -208,7 +208,11 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
{
Vector2D<float> relativePos = RelativePosition(pos);
// corection for the openGl abstraction
relativePos.y = m_size.y - relativePos.y;
//relativePos.y = m_size.y - relativePos.y;
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 (m_bufferID < 0) {
return false;
@ -224,7 +228,7 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
m_buttunOneSelected = true;
ewol::widgetManager::FocusKeep(this);
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseEvent(999/*m_fontNormal*/, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
MarkToRedraw();
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_buttunOneSelected = false;
@ -235,7 +239,7 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
#ifdef __MODE__Touch
ewol::widgetManager::FocusKeep(this);
BufferManager::Get(m_bufferID)->MouseEvent(999/*m_fontNormal*/, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
MarkToRedraw();
#else
// nothing to do ...
@ -259,14 +263,14 @@ bool CodeView::OnEventInput(ewol::inputType_te type, int32_t IdInput, ewol::even
}
//APPL_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(999/*m_fontNormal*/, xxx+m_originScrooled.x, yyy+m_originScrooled.y);
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(limitedPos);
MarkToRedraw();
}
}
} else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// TODO : Set something good
BufferManager::Get(m_bufferID)->MouseEvent(999/*m_fontNormal*/, relativePos.x+m_originScrooled.x, relativePos.y+m_originScrooled.y);
BufferManager::Get(m_bufferID)->MouseEvent(limitedPos);
ewol::clipBoard::Request(ewol::clipBoard::CLIPBOARD_SELECTION);
ewol::widgetManager::FocusKeep(this);
}

View File

@ -0,0 +1,30 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDNPACKAGE=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
# CONFIG_EWOL_OPENGL_ES_V1 is not set
CONFIG_EWOL_OPENGL_ES_V2=y

View File

@ -0,0 +1,30 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDNPACKAGE=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
# CONFIG_EWOL_OPENGL_ES_V1 is not set
CONFIG_EWOL_OPENGL_ES_V2=y

31
config/Linux_debug.config Normal file
View File

@ -0,0 +1,31 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDN=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_PORTAUDIO=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
# CONFIG_EWOL_OPENGL_ES_V1 is not set
CONFIG_EWOL_OPENGL_ES_V2=y

View File

@ -0,0 +1,31 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDN=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_PORTAUDIO=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
CONFIG_EWOL_OPENGL_ES_V1=y
# CONFIG_EWOL_OPENGL_ES_V2 is not set

View File

@ -0,0 +1,31 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDN=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_GLEW=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
# CONFIG_EWOL_OPENGL_ES_V1 is not set
CONFIG_EWOL_OPENGL_ES_V2=y

View File

@ -0,0 +1,31 @@
#
# Automatically generated make config: don't edit
# Linux kernel version:
#
#
# Modules
#
CONFIG_BUILD_EDN=y
CONFIG_BUILD_AGG=y
CONFIG_BUILD_ETK=y
CONFIG_BUILD_EWOL=y
CONFIG_BUILD_FREETYPE=y
CONFIG_BUILD_GLEW=y
CONFIG_BUILD_LUA=y
CONFIG_BUILD_OGG=y
CONFIG_BUILD_PARSERSVG=y
CONFIG_BUILD_LIBPNG=y
CONFIG_BUILD_TINYXML=y
CONFIG_BUILD_ZLIB=y
CONFIG_BUILD_LIBZIP=y
#
# ewol
#
#
# General
#
# CONFIG_EWOL_OPENGL_ES_V1 is not set
CONFIG_EWOL_OPENGL_ES_V2=y