From 7734a8ce3644f8fe6db79e6ae9aee78e20ffd7ce Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Mon, 6 Feb 2012 17:59:48 +0100 Subject: [PATCH] start Abstraction of the scrooling windows --- jni/edn/Buffer/Buffer.cpp | 3 +- jni/edn/Buffer/Buffer.h | 2 +- jni/edn/Buffer/BufferEmpty.cpp | 2 +- jni/edn/Buffer/BufferEmpty.h | 2 +- jni/edn/Buffer/BufferText.cpp | 10 +++++- jni/edn/Buffer/BufferText.h | 4 ++- .../CustumWidget/BufferView/BufferView.cpp | 8 ++--- jni/edn/CustumWidget/CodeView/CodeView.cpp | 33 ++++++++++++------- jni/edn/CustumWidget/CodeView/CodeView.h | 3 +- 9 files changed, 44 insertions(+), 23 deletions(-) diff --git a/jni/edn/Buffer/Buffer.cpp b/jni/edn/Buffer/Buffer.cpp index 46af1a0..ddbd435 100644 --- a/jni/edn/Buffer/Buffer.cpp +++ b/jni/edn/Buffer/Buffer.cpp @@ -150,7 +150,8 @@ void Buffer::SetLineDisplay(uint32_t lineNumber) int32_t Buffer::Display(ewol::OObject2DTextColored* OOTextNormal, ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, - ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) + ewol::OObject2DTextColored* OOTextBoldItalic, ewol::OObject2DColored* OOColored, + int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) { return ERR_NONE; } diff --git a/jni/edn/Buffer/Buffer.h b/jni/edn/Buffer/Buffer.h index beaa737..c1abea3 100644 --- a/jni/edn/Buffer/Buffer.h +++ b/jni/edn/Buffer/Buffer.h @@ -86,7 +86,7 @@ class Buffer { ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, ewol::OObject2DTextColored* OOTextBoldItalic, - ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); virtual void ForceReDraw(bool allElement); virtual void AddChar(char * UTF8data); virtual void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); diff --git a/jni/edn/Buffer/BufferEmpty.cpp b/jni/edn/Buffer/BufferEmpty.cpp index 375c703..ccdfcf3 100644 --- a/jni/edn/Buffer/BufferEmpty.cpp +++ b/jni/edn/Buffer/BufferEmpty.cpp @@ -71,7 +71,7 @@ int32_t BufferEmpty::Display(ewol::OObject2DTextColored* OOTextNormal, ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, ewol::OObject2DTextColored* OOTextBoldItalic, - ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) + ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY) { ColorizeManager * myColorManager = ColorizeManager::getInstance(); // Get color : diff --git a/jni/edn/Buffer/BufferEmpty.h b/jni/edn/Buffer/BufferEmpty.h index 3a424b3..c613c2c 100644 --- a/jni/edn/Buffer/BufferEmpty.h +++ b/jni/edn/Buffer/BufferEmpty.h @@ -36,7 +36,7 @@ class BufferEmpty : public Buffer { ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, ewol::OObject2DTextColored* OOTextBoldItalic, - ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + ewol::OObject2DColored* OOColored, int32_t offsetX, int32_t offsetY, int32_t sizeX, int32_t sizeY); }; diff --git a/jni/edn/Buffer/BufferText.cpp b/jni/edn/Buffer/BufferText.cpp index a68720f..f3a88e7 100644 --- a/jni/edn/Buffer/BufferText.cpp +++ b/jni/edn/Buffer/BufferText.cpp @@ -310,7 +310,9 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal, ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, ewol::OObject2DTextColored* OOTextBoldItalic, - ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY) + ewol::OObject2DColored* OOColored, + int32_t offsetX, int32_t offsetY, + int32_t sizeX, int32_t sizeY) { int32_t selStart, selEnd, selRectStart, selRectEnd; bool selIsRect; @@ -322,6 +324,12 @@ int32_t BufferText::Display(ewol::OObject2DTextColored* OOTextNormal, int32_t letterWidth = ewol::GetWidth(fontId, "A"); int32_t letterHeight = ewol::GetHeight(fontId); + m_displayStartLineId = offsetY / letterHeight; + + // update the display position with the scroll ofset : + m_displayStartBufferPos = m_EdnBuf.CountForwardNLines(0, m_displayStartLineId); + + // update the number of element that can be displayed m_displaySize.x = (sizeX/letterWidth) + 1 - nbColoneForLineNumber; m_displaySize.y = (sizeY/letterHeight) + 1; diff --git a/jni/edn/Buffer/BufferText.h b/jni/edn/Buffer/BufferText.h index 3db245d..a4522d5 100644 --- a/jni/edn/Buffer/BufferText.h +++ b/jni/edn/Buffer/BufferText.h @@ -50,7 +50,9 @@ class BufferText : public Buffer { ewol::OObject2DTextColored* OOTextBold, ewol::OObject2DTextColored* OOTextItalic, ewol::OObject2DTextColored* OOTextBoldItalic, - ewol::OObject2DColored* OOColored, int32_t sizeX, int32_t sizeY); + ewol::OObject2DColored* OOColored, + int32_t offsetX, int32_t offsetY, + int32_t sizeX, int32_t sizeY); void ForceReDraw(bool allElement); void AddChar(char * UTF8data); void cursorMove(ewol::eventKbMoveType_te moveTypeEvent); diff --git a/jni/edn/CustumWidget/BufferView/BufferView.cpp b/jni/edn/CustumWidget/BufferView/BufferView.cpp index 5140d57..72524db 100644 --- a/jni/edn/CustumWidget/BufferView/BufferView.cpp +++ b/jni/edn/CustumWidget/BufferView/BufferView.cpp @@ -61,11 +61,11 @@ GtkWidget * BufferView::GetMainWidget(void) bool BufferView::OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y) { if (generateEventId == ednMsgBufferListChange) { - OnRegenerateDisplay(); + MarkToReedraw(); }else if (ednMsgBufferId == ednMsgBufferListChange) { - OnRegenerateDisplay(); + MarkToReedraw(); }else if (ednMsgBufferState == ednMsgBufferListChange) { - OnRegenerateDisplay(); + MarkToReedraw(); } return false; } @@ -144,7 +144,7 @@ bool BufferView::OnItemEvent(int32_t IdInput, ewol::eventInputType_te typeEvent, ewol::widgetMessageMultiCast::Send(GetWidgetId(), ednMsgBufferId, selectBuf); } } - OnRegenerateDisplay(); + MarkToReedraw(); return false; } diff --git a/jni/edn/CustumWidget/CodeView/CodeView.cpp b/jni/edn/CustumWidget/CodeView/CodeView.cpp index 878aec4..ad54b09 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.cpp +++ b/jni/edn/CustumWidget/CodeView/CodeView.cpp @@ -119,7 +119,8 @@ void CodeView::OnRegenerateDisplay(void) // generate the objects : //m_bufferID = 0; - m_bufferManager->Get(m_bufferID)->Display(myOObjectTextNormal, myOObjectTextBold, myOObjectTextItalic, myOObjectTextBoldItalic, myOObjectsColored, m_size.x, m_size.y); + m_bufferManager->Get(m_bufferID)->Display(myOObjectTextNormal, myOObjectTextBold, myOObjectTextItalic, myOObjectTextBoldItalic, myOObjectsColored, + m_originScrooledX, m_originScrooledY, m_size.x, m_size.y); // clean the object list ... ClearOObjectList(); @@ -137,7 +138,7 @@ bool CodeView::OnEventKb(ewol::eventKbType_te typeEvent, char UTF8_data[UTF8_MAX //EDN_DEBUG("KB EVENT : \"" << UTF8_data << "\" size=" << strlen(UTF8_data) << "type=" << (int32_t)typeEvent); if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) { m_bufferManager->Get(m_bufferID)->AddChar(UTF8_data); - OnRegenerateDisplay(); + MarkToReedraw(); } return true; } @@ -147,7 +148,7 @@ bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveTy { if (typeEvent == ewol::EVENT_KB_TYPE_DOWN) { m_bufferManager->Get(m_bufferID)->cursorMove(moveTypeEvent); - OnRegenerateDisplay(); + MarkToReedraw(); } return true; } @@ -156,6 +157,11 @@ bool CodeView::OnEventKbMove(ewol::eventKbType_te typeEvent, ewol::eventKbMoveTy bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y) { + if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, x, y)) { + ewol::widgetManager::FocusKeep(this); + // nothing to do ... done on upper widet ... + return true; + } x -= m_origin.x; y -= m_origin.y; /* @@ -199,19 +205,19 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, } else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) { m_buttunOneSelected = false; m_bufferManager->Get(m_bufferID)->Copy(COPY_MIDDLE_BUTTON); - OnRegenerateDisplay(); + MarkToReedraw(); } else if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { //EDN_INFO("mouse-event BT1 ==> One Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y); m_bufferManager->Get(m_bufferID)->MouseEvent(x, y); - OnRegenerateDisplay(); + MarkToReedraw(); } else if (ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent) { //EDN_INFO("mouse-event BT1 ==> Double Clicked %d, %d", (uint32_t)event->x, (uint32_t)event->y); m_bufferManager->Get(m_bufferID)->MouseEventDouble(); - OnRegenerateDisplay(); + MarkToReedraw(); } else if (ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) { //EDN_INFO("mouse-event BT1 ==> Triple Clicked"); m_bufferManager->Get(m_bufferID)->MouseEventTriple(); - OnRegenerateDisplay(); + MarkToReedraw(); } else if (ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) { if (true == m_buttunOneSelected) { int xxx, yyy; @@ -225,30 +231,33 @@ bool CodeView::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, } //EDN_INFO("mouse-motion BT1 %d, %d", xxx, yyy); m_bufferManager->Get(m_bufferID)->MouseSelectFromCursorTo(xxx, yyy); - OnRegenerateDisplay(); + MarkToReedraw(); } } } else if (2 == IdInput) { if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) { m_bufferManager->Get(m_bufferID)->MouseEvent(x, y); m_bufferManager->Get(m_bufferID)->Paste(COPY_MIDDLE_BUTTON); - OnRegenerateDisplay(); + MarkToReedraw(); ewol::widgetManager::FocusKeep(this); } } + // TODO : No mere used here ... ==> set in the scrooled windows ... + /* if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { //EDN_INFO("mouse-event GDK_SCROLL_UP"); m_bufferManager->Get(m_bufferID)->ScrollUp(); - OnRegenerateDisplay(); + MarkToReedraw(); ewol::widgetManager::FocusKeep(this); } else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) { //EDN_INFO("mouse-event GDK_SCROLL_DOWN"); m_bufferManager->Get(m_bufferID)->ScrollDown(); - OnRegenerateDisplay(); + MarkToReedraw(); ewol::widgetManager::FocusKeep(this); } + */ return true; } @@ -410,7 +419,7 @@ bool CodeView::OnEventAreaExternal(int32_t widgetID, const char * generateEventI } */ // Force redraw of the widget - OnRegenerateDisplay(); + MarkToReedraw(); return true; } diff --git a/jni/edn/CustumWidget/CodeView/CodeView.h b/jni/edn/CustumWidget/CodeView/CodeView.h index f59ff03..42df0fa 100644 --- a/jni/edn/CustumWidget/CodeView/CodeView.h +++ b/jni/edn/CustumWidget/CodeView/CodeView.h @@ -34,8 +34,9 @@ #include #include +#include -class CodeView :public ewol::Widget +class CodeView :public ewol::WidgetScrooled { public: CodeView(void);