From f2b777f3c07cc24d865a171f6ef98f0ba6ad853e Mon Sep 17 00:00:00 2001 From: Edouard Dupin Date: Thu, 5 Apr 2012 18:29:53 +0200 Subject: [PATCH] Some widget corection and correct the multiple event when a new layer arrive in a pop-up apear --- Sources/libewol/ewol/ClipBoard.cpp | 17 ++++--- Sources/libewol/ewol/ClipBoard.h | 5 +- Sources/libewol/ewol/Windows.cpp | 2 + .../ewol/base/eventInputManagement.cpp | 45 +++++++++++------ .../libewol/ewol/base/eventInputManagement.h | 6 +++ Sources/libewol/ewol/base/guiAndroid.cpp | 48 +++++++++++++++++++ Sources/libewol/ewol/base/guiX11.cpp | 43 ++++++----------- Sources/libewol/ewol/threadMsg.cpp | 17 +++++++ Sources/libewol/ewol/threadMsg.h | 1 + Sources/libewol/ewol/widget/CheckBox.cpp | 3 +- Sources/libewol/ewol/widget/PopUp.cpp | 9 +++- Sources/libewol/ewol/widget/PopUp.h | 1 + 12 files changed, 143 insertions(+), 54 deletions(-) diff --git a/Sources/libewol/ewol/ClipBoard.cpp b/Sources/libewol/ewol/ClipBoard.cpp index f5fda41d..a37a4e7e 100644 --- a/Sources/libewol/ewol/ClipBoard.cpp +++ b/Sources/libewol/ewol/ClipBoard.cpp @@ -60,14 +60,18 @@ void ewol::clipBoard::UnInit(void) void ewol::clipBoard::Set(uint8_t clipboardID, etk::UString &data) { // check if ID is correct - if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) { - EWOL_WARNING("request ClickBoard id error"); - } else if(0 == data.Size()) { + if(0 == data.Size()) { EWOL_INFO("request a copy of nothing"); + return; } else if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) { guiAbstraction::ClipBoardSet(data, guiAbstraction::CLIPBOARD_MODE_STD); + return; } else if (ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) { guiAbstraction::ClipBoardSet(data, guiAbstraction::CLIPBOARD_MODE_PRIMARY); + return; + }else if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) { + EWOL_WARNING("request ClickBoard id error"); + return; } // Copy datas ... mesCopy[clipboardID] = data; @@ -75,14 +79,15 @@ void ewol::clipBoard::Set(uint8_t clipboardID, etk::UString &data) void ewol::clipBoard::Get(uint8_t clipboardID, etk::UString &data) { - if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) { - EWOL_WARNING("request ClickBoard id error"); - } else if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) { + if (ewol::clipBoard::CLIPBOARD_STD == clipboardID) { guiAbstraction::ClipBoardGet(data, guiAbstraction::CLIPBOARD_MODE_STD); return; } else if (ewol::clipBoard::CLIPBOARD_SELECTION == clipboardID) { guiAbstraction::ClipBoardGet(data, guiAbstraction::CLIPBOARD_MODE_PRIMARY); return; + } else if(clipboardID >= ewol::clipBoard::TOTAL_OF_CLICKBOARD) { + EWOL_WARNING("request ClickBoard id error"); + return; } // Copy datas ... data = mesCopy[clipboardID]; diff --git a/Sources/libewol/ewol/ClipBoard.h b/Sources/libewol/ewol/ClipBoard.h index 89c38ea2..3c89bcaa 100644 --- a/Sources/libewol/ewol/ClipBoard.h +++ b/Sources/libewol/ewol/ClipBoard.h @@ -33,7 +33,7 @@ namespace ewol { namespace clipBoard { enum { - CLIPBOARD_STD, + CLIPBOARD_0, CLIPBOARD_1, CLIPBOARD_2, CLIPBOARD_3, @@ -43,8 +43,9 @@ namespace ewol { CLIPBOARD_7, CLIPBOARD_8, CLIPBOARD_9, - CLIPBOARD_SELECTION, TOTAL_OF_CLICKBOARD, + CLIPBOARD_STD, + CLIPBOARD_SELECTION, }; void Init(void); void UnInit(void); diff --git a/Sources/libewol/ewol/Windows.cpp b/Sources/libewol/ewol/Windows.cpp index 6bd2a6d8..1c25d0f9 100644 --- a/Sources/libewol/ewol/Windows.cpp +++ b/Sources/libewol/ewol/Windows.cpp @@ -32,6 +32,7 @@ #include #include #include +#include @@ -270,6 +271,7 @@ void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget) // Regenerate the size calculation : CalculateSize(m_size.x, m_size.y); m_needFlipFlop = true; + ewol::eventInput::NewLayerSet(); } void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode) diff --git a/Sources/libewol/ewol/base/eventInputManagement.cpp b/Sources/libewol/ewol/base/eventInputManagement.cpp index 0481ae4e..f949d1fe 100644 --- a/Sources/libewol/ewol/base/eventInputManagement.cpp +++ b/Sources/libewol/ewol/base/eventInputManagement.cpp @@ -35,21 +35,6 @@ typedef struct { #define MAX_MANAGE_INPUT (10) InputPoperty_ts eventInputSaved[MAX_MANAGE_INPUT]; -/** - * @brief Inform object that an other object is removed ... - * @param[in] removeObject Pointer on the EObject removed ==> the user must remove all reference on this EObject - * @note : Sub classes must call this class - * @return --- - */ -void ewol::eventInput::OnObjectRemove(ewol::EObject * removeObject) -{ - for(int32_t iii=0; iii the user must remove all reference on this EObject + * @note : Sub classes must call this class + * @return --- + */ +void ewol::eventInput::OnObjectRemove(ewol::EObject * removeObject) +{ + for(int32_t iii=0; iii might remove all the property of the current element ... + * @param --- + * @return --- + */ +void ewol::eventInput::NewLayerSet(void) +{ + for(int32_t iii=0; iii might remove all the property of the current element ... + * @param --- + * @return --- + */ + void NewLayerSet(void); } } #endif diff --git a/Sources/libewol/ewol/base/guiAndroid.cpp b/Sources/libewol/ewol/base/guiAndroid.cpp index e021a74d..86c2159f 100644 --- a/Sources/libewol/ewol/base/guiAndroid.cpp +++ b/Sources/libewol/ewol/base/guiAndroid.cpp @@ -74,6 +74,8 @@ int64_t m_previousTime = 0; bool m_previousDouble = false; +static etk::UString l_clipBoardPrimary(""); // local copy of the selection +static etk::UString l_clipBoardStd(""); // local copy of the clipboard static etkFloat_t gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f }; @@ -191,6 +193,52 @@ void ewol::SetTitle(etk::UString title) // can not set the title in Android ... } +// ClipBoard AREA : +void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode) +{ + EWOL_INFO("Request Get of a clipboard : " << mode << " size=" << newData.Size() ); + newData = ""; + switch (mode) + { + case CLIPBOARD_MODE_PRIMARY: + // get our own buffer ... (no current selectin on Android ... + newData = l_clipBoardPrimary; + break; + case CLIPBOARD_MODE_STD: + EWOL_TODO("implement on Android"); + // get our own buffer ... + newData = l_clipBoardStd; + break; + default: + EWOL_ERROR("Request an unknow ClipBoard ..."); + break; + } +} + +void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode) +{ + EWOL_VERBOSE("Request set of a clipboard : " << mode << " size=" << newData.Size() ); + switch (mode) + { + case CLIPBOARD_MODE_PRIMARY: + if (newData.Size() > 0) { + // copy it ... + l_clipBoardPrimary = newData; + } + break; + case CLIPBOARD_MODE_STD: + if (newData.Size() > 0) { + // copy it ... + l_clipBoardStd = newData; + // Request the clipBoard : + EWOL_TODO("implement on Android copy the copy data"); + } + break; + default: + EWOL_ERROR("Request an unknow ClipBoard ..."); + break; + } +} #undef __class__ #define __class__ "guiAbstraction" diff --git a/Sources/libewol/ewol/base/guiX11.cpp b/Sources/libewol/ewol/base/guiX11.cpp index 260a6b47..bdd49520 100644 --- a/Sources/libewol/ewol/base/guiX11.cpp +++ b/Sources/libewol/ewol/base/guiX11.cpp @@ -127,12 +127,12 @@ int32_t offsetMoveClickedDouble = 20; bool inputIsPressed[20]; // internal copy of the clipBoard ... -static ewol::simpleMsg::simpleMsg_ts l_clipboardMessage; -static bool l_clipBoardRequestPrimary = false; -static bool l_clipBoardOwnerPrimary = false; -static etk::UString l_clipBoardPrimary(""); -static bool l_clipBoardOwnerStd = false; -static etk::UString l_clipBoardStd(""); +static ewol::simpleMsg::simpleMsg_ts l_clipboardMessage; /// message to prevent the other thread that we have receive the requested data +static bool l_clipBoardRequestPrimary = false; // if false : request the copy/past buffer, if true : request current selection +static bool l_clipBoardOwnerPrimary = false; // we are the owner of the current selection +static etk::UString l_clipBoardPrimary(""); // local copy of the selection +static bool l_clipBoardOwnerStd = false; // we are the owner of the current copy buffer +static etk::UString l_clipBoardStd(""); // local copy of the clipboard // Atom access... static Atom XAtomeSelection = 0; static Atom XAtomeClipBoard = 0; @@ -525,10 +525,12 @@ void X11_Run(void) ); if (true == l_clipBoardRequestPrimary) { l_clipBoardPrimary = (char*)buf; + // inform that we have receive the data ewol::simpleMsg::SendMessage(l_clipboardMessage, 4); EWOL_VERBOSE(" ==> data : " << l_clipBoardPrimary); } else { l_clipBoardStd = (char*)buf; + // inform that we have receive the data ewol::simpleMsg::SendMessage(l_clipboardMessage, 2); EWOL_VERBOSE(" ==> data : " << l_clipBoardStd); } @@ -914,6 +916,9 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode) case CLIPBOARD_MODE_PRIMARY: if (false == l_clipBoardOwnerPrimary) { l_clipBoardRequestPrimary = true; + // clear old request .. + ewol::simpleMsg::Clear(l_clipboardMessage); + // Generate a request on X11 XConvertSelection(m_display, XAtomeSelection,// atom, XAtomeTargetStringUTF8, // type? @@ -932,6 +937,9 @@ void guiAbstraction::ClipBoardGet(etk::UString &newData, clipBoardMode_te mode) case CLIPBOARD_MODE_STD: if (false == l_clipBoardOwnerStd) { l_clipBoardRequestPrimary = false; + // clear old request .. + ewol::simpleMsg::Clear(l_clipboardMessage); + // Generate a request on X11 XConvertSelection(m_display, XAtomeClipBoard,// atom, XAtomeTargetStringUTF8, // type? @@ -985,29 +993,6 @@ void guiAbstraction::ClipBoardSet(etk::UString &newData, clipBoardMode_te mode) break; } } -/* -void ewol::clipboard::Copy(etk::UString newData, int32_t bufferId) -{ - char * tmpPointer = newData.Utf8Data(); - - Atom selection = XA_PRIMARY; - //All your selection are belong to us... - XSetSelectionOwner(m_display, selection, WindowHandle, CurrentTime); - - EWOL_DEBUG("--------------------------------------------------------------"); - if (BadAlloc == XStoreBuffer(m_display, tmpPointer, strlen(tmpPointer), bufferId)) { - EWOL_ERROR("Copy error"); - } else { - EWOL_DEBUG("Copy well done : \"" << tmpPointer << "\"=" << strlen(tmpPointer)); - } - if (BadAlloc == XStoreBytes(m_display, tmpPointer, strlen(tmpPointer))) { - EWOL_ERROR("Copy error"); - } else { - EWOL_DEBUG("Copy well done"); - } - EWOL_DEBUG("--------------------------------------------------------------"); -} -*/ diff --git a/Sources/libewol/ewol/threadMsg.cpp b/Sources/libewol/ewol/threadMsg.cpp index bbdeb38a..23e68818 100644 --- a/Sources/libewol/ewol/threadMsg.cpp +++ b/Sources/libewol/ewol/threadMsg.cpp @@ -262,4 +262,21 @@ void ewol::simpleMsg::SendMessage(ewol::simpleMsg::simpleMsg_ts& handle, uint32_ } +void ewol::simpleMsg::Clear(simpleMsg_ts& handle) +{ + if (false == handle.isInit) { + return; + } + pthread_mutex_lock(&handle.mutex); + if (handle.messageValue !=0) { + struct timespec timeout; + timeout.tv_sec = 0; + timeout.tv_nsec = 0; + pthread_cond_timedwait(&handle.condition, &handle.mutex, &timeout); + + } + pthread_mutex_unlock(&handle.mutex); +} + + diff --git a/Sources/libewol/ewol/threadMsg.h b/Sources/libewol/ewol/threadMsg.h index 65963311..d9790c11 100644 --- a/Sources/libewol/ewol/threadMsg.h +++ b/Sources/libewol/ewol/threadMsg.h @@ -79,6 +79,7 @@ namespace ewol { void UnInit( simpleMsg_ts& handle); uint32_t WaitingMessage(simpleMsg_ts& handle, int32_t timeOut=0); void SendMessage( simpleMsg_ts& handle, uint32_t message); + void Clear( simpleMsg_ts& handle); }; }; diff --git a/Sources/libewol/ewol/widget/CheckBox.cpp b/Sources/libewol/ewol/widget/CheckBox.cpp index 0e5e1f46..4ac52469 100644 --- a/Sources/libewol/ewol/widget/CheckBox.cpp +++ b/Sources/libewol/ewol/widget/CheckBox.cpp @@ -165,7 +165,8 @@ void ewol::CheckBox::OnRegenerateDisplay(void) clipping_ts drawClipping; drawClipping.x = 0; drawClipping.y = 0; - drawClipping.w = m_size.x - (boxSize+5); + // note : pb on the clipping properties ... + drawClipping.w = m_size.x;// - (boxSize+5); drawClipping.h = m_size.y; tmpText->Text(textPos, drawClipping, m_label); diff --git a/Sources/libewol/ewol/widget/PopUp.cpp b/Sources/libewol/ewol/widget/PopUp.cpp index 6cb69a43..89795da0 100644 --- a/Sources/libewol/ewol/widget/PopUp.cpp +++ b/Sources/libewol/ewol/widget/PopUp.cpp @@ -45,6 +45,11 @@ ewol::PopUp::PopUp(void) m_colorEmptyArea.blue = 0.0; m_colorEmptyArea.alpha = 0.50; + m_colorBorder.red = 0.0; + m_colorBorder.green = 0.0; + m_colorBorder.blue = 0.0; + m_colorBorder.alpha = 0.50; + for (int32_t iii=0; iiiGetSize(); coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId]->GetOrigin(); + BGOObjects->SetColor(m_colorBorder); + BGOObjects->Rectangle(tmpOrigin.x-BORDER_SIZE_TMP, tmpOrigin.y-BORDER_SIZE_TMP, tmpSize.x+2*BORDER_SIZE_TMP, tmpSize.y+2*BORDER_SIZE_TMP); BGOObjects->SetColor(m_colorBackGroung); BGOObjects->Rectangle(tmpOrigin.x, tmpOrigin.y, tmpSize.x, tmpSize.y); } diff --git a/Sources/libewol/ewol/widget/PopUp.h b/Sources/libewol/ewol/widget/PopUp.h index 5d40ce96..0a3bf23a 100644 --- a/Sources/libewol/ewol/widget/PopUp.h +++ b/Sources/libewol/ewol/widget/PopUp.h @@ -60,6 +60,7 @@ namespace ewol { void SetDisplayRatio(etkFloat_t ratio); private: color_ts m_colorBackGroung; + color_ts m_colorBorder; color_ts m_colorEmptyArea; ewol::Widget* m_subWidget[NB_BOUBLE_BUFFER]; etkFloat_t m_displayRatio;