Strat simplify of the buffer access
This commit is contained in:
parent
f6f8679b76
commit
75f56d52d4
@ -168,7 +168,7 @@ int32_t Buffer::Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
* @todo : Set the move up and DOWN...
|
||||
*
|
||||
*/
|
||||
void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
void Buffer::MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@ -183,7 +183,7 @@ void Buffer::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::MouseEvent(int32_t width, int32_t height)
|
||||
void Buffer::MouseEvent(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
@ -215,49 +215,6 @@ void Buffer::MouseEventTriple(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ScrollDown(void)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ScrollUp(void)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void Buffer::ForceReDraw(bool allElement)
|
||||
{
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Buffer::cursorMove(ewol::eventKbMoveType_te moveTypeEvent)
|
||||
{
|
||||
// nothing to do
|
||||
|
@ -87,15 +87,12 @@ class Buffer {
|
||||
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);
|
||||
virtual void MouseSelectFromCursorTo(int32_t width, int32_t height);
|
||||
virtual void MouseEvent(int32_t width, int32_t height);
|
||||
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 MouseEventDouble(void);
|
||||
virtual void MouseEventTriple(void);
|
||||
virtual void ScrollDown(void);
|
||||
virtual void ScrollUp(void);
|
||||
virtual void RemoveLine(void);
|
||||
virtual void SelectAll(void);
|
||||
virtual void SelectNone(void);
|
||||
|
@ -61,7 +61,6 @@ extern "C"
|
||||
*/
|
||||
void BufferText::BasicInit(void)
|
||||
{
|
||||
NeedToCleanEndPage = true;
|
||||
// set the first element that is displayed
|
||||
m_displayStartBufferPos = 0;
|
||||
|
||||
@ -148,7 +147,6 @@ BufferText::BufferText(etk::File &fileName) : Buffer(fileName)
|
||||
SetModify(true);
|
||||
}
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
|
||||
@ -530,7 +528,7 @@ int32_t BufferText::Display(ewol::OObject2DTextColored& OOTextNormal,
|
||||
|
||||
|
||||
|
||||
int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
int32_t BufferText::GetMousePosition(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
int32_t letterWidth = ewol::GetWidth(g_basicfontId, "9");
|
||||
int32_t letterHeight = ewol::GetHeight(g_basicfontId);
|
||||
@ -564,7 +562,7 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
memset(displayChar, 0, sizeof(uniChar_t)*MAX_EXP_CHAR_LEN);
|
||||
|
||||
int32_t pixelX = x_base;
|
||||
int32_t startLinePosition = m_EdnBuf.CountForwardNLines(m_displayStartBufferPos, lineOffset);
|
||||
int32_t startLinePosition = m_EdnBuf.CountForwardNLines(0, lineOffset);
|
||||
if (width <= pixelX) {
|
||||
EDN_DEBUG(" Element : Befor the start of the line ... ==> END");
|
||||
return startLinePosition;
|
||||
@ -606,7 +604,7 @@ int32_t BufferText::GetMousePosition(int32_t width, int32_t height)
|
||||
*
|
||||
*/
|
||||
// TODO : Simplify selection ....
|
||||
void BufferText::MouseEvent(int32_t width, int32_t height)
|
||||
void BufferText::MouseEvent(int32_t fontId, int32_t width, int32_t height)
|
||||
{
|
||||
if (true == ewol::IsSetShift() ) {
|
||||
MouseSelectFromCursorTo(width, height);
|
||||
@ -622,7 +620,6 @@ void BufferText::MouseEvent(int32_t width, int32_t height)
|
||||
}*/
|
||||
m_EdnBuf.Unselect(SELECTION_PRIMARY);
|
||||
|
||||
ForceReDraw(true);
|
||||
UpdateWindowsPosition();
|
||||
}
|
||||
}
|
||||
@ -665,7 +662,6 @@ void BufferText::MouseSelectFromCursorTo(int32_t width, int32_t height)
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, selStart, m_cursorPos);
|
||||
}
|
||||
}
|
||||
ForceReDraw(true);
|
||||
UpdateWindowsPosition();
|
||||
}
|
||||
|
||||
@ -685,7 +681,6 @@ void BufferText::MouseEventDouble(void)
|
||||
if (true == m_EdnBuf.SelectAround(m_cursorPos, beginPos, endPos)) {
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, beginPos, endPos);
|
||||
m_cursorPos = endPos;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
// no else
|
||||
}
|
||||
@ -702,7 +697,6 @@ void BufferText::MouseEventTriple(void)
|
||||
{
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, m_EdnBuf.StartOfLine(m_cursorPos), m_EdnBuf.EndOfLine(m_cursorPos));
|
||||
m_cursorPos = m_EdnBuf.EndOfLine(m_cursorPos);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
void BufferText::RemoveLine(void)
|
||||
@ -718,27 +712,11 @@ void BufferText::SelectAll(void)
|
||||
{
|
||||
m_EdnBuf.Select(SELECTION_PRIMARY, 0, m_EdnBuf.Size());
|
||||
m_cursorPos = m_EdnBuf.Size();
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
void BufferText::SelectNone(void)
|
||||
{
|
||||
m_EdnBuf.Unselect(SELECTION_PRIMARY);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
// TODO : Deprecated...
|
||||
void BufferText::ScrollDown(void)
|
||||
{
|
||||
MoveUpDown(3);
|
||||
}
|
||||
|
||||
|
||||
@ -750,59 +728,6 @@ void BufferText::ScrollDown(void)
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
// TODO : Deprecated...
|
||||
void BufferText::ScrollUp(void)
|
||||
{
|
||||
MoveUpDown(-3);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::MoveUpDown(int32_t ofset)
|
||||
{
|
||||
if (ofset >= 0) {
|
||||
int32_t nbLine = m_EdnBuf.NumberOfLines();
|
||||
if (m_displayStartLineId+ofset+3 > nbLine) {
|
||||
m_displayStartLineId = nbLine-3;
|
||||
} else {
|
||||
m_displayStartLineId += ofset;
|
||||
}
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
} else {
|
||||
ofset *= -1;
|
||||
if (m_displayStartLineId < ofset) {
|
||||
m_displayStartLineId = 0;
|
||||
m_displayStartBufferPos = 0;
|
||||
} else {
|
||||
m_displayStartLineId -= ofset;
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param[in,out] ---
|
||||
*
|
||||
* @return ---
|
||||
*
|
||||
*/
|
||||
void BufferText::ForceReDraw(bool allElement)
|
||||
{
|
||||
NeedToCleanEndPage = true;
|
||||
}
|
||||
|
||||
void BufferText::SetInsertPosition(int32_t newPos, bool insertChar)
|
||||
{
|
||||
int32_t SelectionStart, SelectionEnd, SelectionRectStart, SelectionRectEnd;
|
||||
@ -1012,11 +937,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
m_displayStartLineId = cursorPosition.y - globals::getNbLineBorder();
|
||||
if (m_displayStartLineId < 0) {
|
||||
m_displayStartLineId = 0;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
} else if (m_displayStartLineId + m_displaySize.y <= (int32_t)cursorPosition.y + globals::getNbLineBorder() ) {
|
||||
m_displayStartLineId = cursorPosition.y - m_displaySize.y + globals::getNbLineBorder() + 1;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
// Display position (X mode):
|
||||
//EDN_INFO("cursorPosition X : " << cursorPosition.y << " windows " << m_displayStartLineId << "=>" << m_displayStartPixelX + m_displaySize.x);
|
||||
@ -1024,11 +947,9 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
m_displayStartPixelX = cursorPosition.x - globals::getNbColoneBorder();
|
||||
if (m_displayStartPixelX < 0) {
|
||||
m_displayStartPixelX = 0;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
} else if (m_displayStartPixelX + m_displaySize.x <= cursorPosition.x + globals::getNbColoneBorder() ) {
|
||||
m_displayStartPixelX = cursorPosition.x - m_displaySize.x + globals::getNbColoneBorder() + 1;
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
//update the buffer position ID :
|
||||
@ -1048,7 +969,6 @@ void BufferText::UpdateWindowsPosition(bool centerPage)
|
||||
m_displayStartLineId = edn_max(m_displayStartLineId, 0);
|
||||
|
||||
m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId);
|
||||
ForceReDraw(true);
|
||||
//EDN_DEBUG(" display start : " << m_displayStartPixelX << "x" << m_displayStartLineId);
|
||||
//EDN_DEBUG(" -------------------------------------------------");
|
||||
}
|
||||
@ -1356,7 +1276,6 @@ void BufferText::Cut(int8_t clipboardID)
|
||||
m_cursorPos = SelectionStart;
|
||||
}
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
SetModify(true);
|
||||
}
|
||||
|
||||
@ -1393,7 +1312,6 @@ void BufferText::Paste(int8_t clipboardID)
|
||||
}
|
||||
*/
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
SetModify(true);
|
||||
}
|
||||
|
||||
@ -1404,7 +1322,6 @@ void BufferText::Undo(void)
|
||||
if (newPos >= 0) {
|
||||
SetInsertPosition(newPos, true);
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
SetModify(true);
|
||||
}
|
||||
}
|
||||
@ -1415,7 +1332,6 @@ void BufferText::Redo(void)
|
||||
if (newPos >= 0) {
|
||||
SetInsertPosition(newPos, true);
|
||||
UpdateWindowsPosition();
|
||||
ForceReDraw(true);
|
||||
SetModify(true);
|
||||
}
|
||||
}
|
||||
@ -1424,6 +1340,5 @@ void BufferText::Redo(void)
|
||||
void BufferText::SetCharset(unicode::charset_te newCharset)
|
||||
{
|
||||
m_EdnBuf.SetCharsetType(newCharset);
|
||||
ForceReDraw(true);
|
||||
}
|
||||
|
||||
|
@ -53,15 +53,12 @@ class BufferText : public Buffer {
|
||||
ewol::OObject2DColored& OOColored,
|
||||
int32_t offsetX, int32_t offsetY,
|
||||
int32_t sizeX, int32_t sizeY);
|
||||
void ForceReDraw(bool allElement);
|
||||
void AddChar(uniChar_t unicodeData);
|
||||
void cursorMove(ewol::eventKbMoveType_te moveTypeEvent);
|
||||
void MouseSelectFromCursorTo(int32_t width, int32_t height);
|
||||
void MouseEvent(int32_t width, int32_t height);
|
||||
void MouseSelectFromCursorTo(int32_t fontId, int32_t width, int32_t height);
|
||||
void MouseEvent(int32_t fontId, int32_t width, int32_t height);
|
||||
void MouseEventDouble(void);
|
||||
void MouseEventTriple(void);
|
||||
void ScrollDown(void);
|
||||
void ScrollUp(void);
|
||||
|
||||
void Copy(int8_t clipboardID);
|
||||
void Cut(int8_t clipboardID);
|
||||
@ -85,7 +82,6 @@ class BufferText : public Buffer {
|
||||
|
||||
private:
|
||||
// Display
|
||||
bool NeedToCleanEndPage; //!< if true, the end of the page need to be clean (arrive after a remove line)
|
||||
uint32_t nbColoneForLineNumber; //!< number of colome used to display the line Number
|
||||
|
||||
// Direct buffer IO
|
||||
@ -115,7 +111,6 @@ class BufferText : public Buffer {
|
||||
void SetInsertPosition(int32_t newPosition, bool insertChar = false);
|
||||
|
||||
int32_t GetMousePosition(int32_t width, int32_t height);
|
||||
void MoveUpDown(int32_t ofset);
|
||||
void DrawLineNumber(ewol::OObject2DTextColored* OOText, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY,char *myPrint, int32_t lineNumber, int32_t positionY);
|
||||
|
||||
void CursorDisplay(ewol::OObject2DColored* OOColored, int32_t x, int32_t y, int32_t letterHeight, int32_t letterWidth, clipping_ts &clip);
|
||||
|
@ -174,7 +174,7 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
|
||||
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
|
||||
m_buttunOneSelected = true;
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(pos.local.x, pos.local.y);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, pos.local.x+m_originScrooled.x, pos.local.y+m_originScrooled.y);
|
||||
MarkToReedraw();
|
||||
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||
m_buttunOneSelected = false;
|
||||
@ -185,7 +185,7 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
#ifdef __MODE__Touch
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(pos.local.x, pos.local.y);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, pos.local.x+m_originScrooled.x, pos.local.y+m_originScrooled.y);
|
||||
MarkToReedraw();
|
||||
#else
|
||||
// nothing to do ...
|
||||
@ -208,13 +208,13 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent,
|
||||
yyy = 0;
|
||||
}
|
||||
//EDN_INFO("mouse-motion BT1 %d, %d", xxx, yyy);
|
||||
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(xxx, yyy);
|
||||
BufferManager::Get(m_bufferID)->MouseSelectFromCursorTo(m_fontNormal, xxx, yyy);
|
||||
MarkToReedraw();
|
||||
}
|
||||
}
|
||||
} else if (2 == IdInput) {
|
||||
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(pos.local.x, pos.local.y);
|
||||
BufferManager::Get(m_bufferID)->MouseEvent(m_fontNormal, pos.local.x+m_originScrooled.x, pos.local.y+m_originScrooled.y);
|
||||
BufferManager::Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON);
|
||||
MarkToReedraw();
|
||||
ewol::widgetManager::FocusKeep(this);
|
||||
@ -244,7 +244,6 @@ void CodeView::OnReceiveMessage(ewol::EObject * CallerObject, const char * event
|
||||
sscanf(data.Utf8Data(), "%d", &bufferID);
|
||||
EDN_INFO("Select a new Buffer ... " << bufferID);
|
||||
m_bufferID = bufferID;
|
||||
BufferManager::Get(m_bufferID)->ForceReDraw(true);
|
||||
// TODO : need to update the state of the file and the filenames ...
|
||||
}
|
||||
// old
|
||||
|
@ -84,7 +84,6 @@ class CodeView :public ewol::WidgetScrooled
|
||||
void SetFontNameBoldItalic(etk::UString fontName);
|
||||
private:
|
||||
void CalculateMaxSize(void);
|
||||
// widget drawing :
|
||||
protected:
|
||||
virtual bool OnDraw(void);
|
||||
};
|
||||
|
@ -177,18 +177,16 @@ void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * ev
|
||||
PopUpWidgetPush(tmpWidget);
|
||||
tmpWidget->RegisterOnEvent(this, ewolEventFileChooserValidate, ednEventPopUpFileSelected);
|
||||
} else if (eventId == ednEventPopUpFileSelected) {
|
||||
/*
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(ewol::widgetManager::Get(widgetID));
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << widgetID);
|
||||
return false;
|
||||
EDN_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request opening the file : " << tmpData);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgOpenFile, tmpData);
|
||||
*/
|
||||
SendMultiCast(ednMsgOpenFile, tmpData);
|
||||
} else if (eventId == ednMsgGuiSaveAs) {
|
||||
if (data == "") {
|
||||
EDN_ERROR("Null data for Save As file ... ");
|
||||
@ -221,20 +219,18 @@ void MainWindows::OnReceiveMessage(ewol::EObject * CallerObject, const char * ev
|
||||
}
|
||||
}
|
||||
} else if (eventId == ednEventPopUpFileSaveAs) {
|
||||
/*
|
||||
// get widget:
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(ewol::widgetManager::Get(widgetID));
|
||||
ewol::FileChooser * tmpWidget = static_cast<ewol::FileChooser*>(CallerObject);
|
||||
if (NULL == tmpWidget) {
|
||||
EDN_ERROR("impossible to get pop_upWidget " << widgetID);
|
||||
return false;
|
||||
EDN_ERROR("impossible to get pop_upWidget " << CallerObject);
|
||||
return;
|
||||
}
|
||||
// get the filename :
|
||||
etk::UString tmpData = tmpWidget->GetCompleateFileName();
|
||||
EDN_DEBUG("Request Saving As file : " << tmpData);
|
||||
|
||||
BufferManager::Get(m_currentSavingAsIdBuffer)->SetFileName(tmpData);
|
||||
ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
*/
|
||||
SendMultiCast(ednMsgGuiSave, m_currentSavingAsIdBuffer);
|
||||
} else if( eventId == ednMsgBufferState
|
||||
|| eventId == ednMsgBufferId) {
|
||||
// the buffer change we need to update the widget string
|
||||
|
Loading…
x
Reference in New Issue
Block a user