From f5c65e0fb65d77de7c38e64519d290e2225fa811 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 11 Oct 2012 18:08:30 +0200 Subject: [PATCH] [DEV] change the policy of the background of the scene and set the shortcut on Fxx key --- Sources/libagg | 2 +- Sources/libewol/ewol/ResourceManager.cpp | 2 +- Sources/libewol/ewol/ShortCutManager.cpp | 101 +++++++++++++++--- Sources/libewol/ewol/ShortCutManager.h | 3 +- .../libewol/ewol/eObject/EObjectManager.cpp | 1 + Sources/libewol/ewol/game/SceneElement.cpp | 7 ++ Sources/libewol/ewol/game/SceneElement.h | 2 + Sources/libewol/ewol/oObject/3DTextured.cpp | 1 + Sources/libewol/ewol/openGL/Program.cpp | 60 ++++++----- Sources/libewol/ewol/os/eSystem.cpp | 9 +- Sources/libewol/ewol/widget/Scene.cpp | 3 + Sources/libewol/ewol/widget/Widget.h | 1 + 12 files changed, 149 insertions(+), 43 deletions(-) diff --git a/Sources/libagg b/Sources/libagg index 4c16ddcb..b6ae353b 160000 --- a/Sources/libagg +++ b/Sources/libagg @@ -1 +1 @@ -Subproject commit 4c16ddcbd7f37fc84a663484a1a7388188ceaa79 +Subproject commit b6ae353bdfe68963de4652babaf8d4d24b1026d3 diff --git a/Sources/libewol/ewol/ResourceManager.cpp b/Sources/libewol/ewol/ResourceManager.cpp index 245f8ca7..7bad4c42 100644 --- a/Sources/libewol/ewol/ResourceManager.cpp +++ b/Sources/libewol/ewol/ResourceManager.cpp @@ -87,7 +87,7 @@ void ewol::resource::Display(void) * @param --- * @return --- */ -void ReLoadResources(void) +void ewol::resource::ReLoadResources(void) { EWOL_INFO("------------- Resources re-loaded -------------"); // remove all resources ... diff --git a/Sources/libewol/ewol/ShortCutManager.cpp b/Sources/libewol/ewol/ShortCutManager.cpp index 788668a1..87d5781c 100644 --- a/Sources/libewol/ewol/ShortCutManager.cpp +++ b/Sources/libewol/ewol/ShortCutManager.cpp @@ -30,19 +30,33 @@ class EventShortCut { public: - const char * generateEventId; // event generate ID (to be unique it was pointer on the string name) - etk::UString eventData; - bool shift; - bool control; - bool alt; - bool meta; - uniChar_t UnicodeValue; + const char * generateEventId; // event generate ID (to be unique it was pointer on the string name) + etk::UString eventData; + bool shift; + bool control; + bool alt; + bool meta; + uniChar_t UnicodeValue; // 0 if not used + ewol::eventKbMoveType_te keyboardMoveValue; // 0 if not used }; static etk::Vector l_inputShortCutEvent; //!< generic short-cut event +namespace ewol { + namespace shortCut { + void Add(bool shift, bool control, bool alt, bool meta, + uniChar_t unicodeValue, + ewol::eventKbMoveType_te kbMove, + const char * generateEventId, + etk::UString data); + }; +}; -void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data) +void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, + uniChar_t unicodeValue, + ewol::eventKbMoveType_te kbMove, + const char * generateEventId, + etk::UString data) { EventShortCut * newEvent = new EventShortCut(); if (NULL == newEvent) { @@ -55,6 +69,7 @@ void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_ newEvent->alt = alt; newEvent->meta = meta; newEvent->UnicodeValue = unicodeValue; + newEvent->keyboardMoveValue = kbMove; newEvent->eventData = data; l_inputShortCutEvent.PushBack(newEvent); return; @@ -92,9 +107,65 @@ void ewol::shortCut::Add(const char * descriptiveString, const char * generateEv if(NULL != tmp) { meta = true; } - UnicodeValue = descriptiveString[strlen(descriptiveString) -1]; - // add with generic Adding function ... - ewol::shortCut::Add(shift, control, alt, meta, UnicodeValue, generateEventId, data); + if(NULL != strstr(descriptiveString, "F12") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F12, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F11") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F11, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F10") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F10, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F9") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F9, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F8") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F8, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F7") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F7, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F6") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F6, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F5") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F5, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F4") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F4, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F3") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F3, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F2") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F2, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "F1") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_F1, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "LEFT") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_LEFT, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "RIGHT") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_RIGHT, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "UP") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_UP, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "DOWN") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_DOWN, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "PAGE_UP") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_PAGE_UP, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "PAGE_DOWN") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "START") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_START, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "END") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_END, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "CENTER") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_CENTER, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "ARRET_DEFIL") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "WAIT") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_WAIT, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "INSERT") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_INSERT, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "CAPLOCK") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_CAPLOCK, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "CONTEXT_MENU") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU, generateEventId, data); + } else if(NULL != strstr(descriptiveString, "VER_NUM") ) { + ewol::shortCut::Add(shift, control, alt, meta, 0, ewol::EVENT_KB_MOVE_TYPE_VER_NUM, generateEventId, data); + } else { + UnicodeValue = descriptiveString[strlen(descriptiveString) -1]; + // add with generic Adding function ... + ewol::shortCut::Add(shift, control, alt, meta, UnicodeValue, ewol::EVENT_KB_MOVE_TYPE_NONE, generateEventId, data); + } } @@ -123,7 +194,7 @@ void ewol::shortCut::UnInit(void) -bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown) +bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown) { if (unicodeValue >= 'A' && unicodeValue <='Z') { unicodeValue += 'a' - 'A'; @@ -134,7 +205,11 @@ bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniC && l_inputShortCutEvent[iii]->control == control && l_inputShortCutEvent[iii]->alt == alt && l_inputShortCutEvent[iii]->meta == meta - && l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue) + && ( ( l_inputShortCutEvent[iii]->keyboardMoveValue == ewol::EVENT_KB_MOVE_TYPE_NONE + && l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue) + || ( l_inputShortCutEvent[iii]->keyboardMoveValue == kbMove + && l_inputShortCutEvent[iii]->UnicodeValue == 0) + ) ) { if (isDown) { ewol::EObjectMessageMultiCast::AnonymousSend(l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData); diff --git a/Sources/libewol/ewol/ShortCutManager.h b/Sources/libewol/ewol/ShortCutManager.h index 567120ec..dc72285d 100644 --- a/Sources/libewol/ewol/ShortCutManager.h +++ b/Sources/libewol/ewol/ShortCutManager.h @@ -27,12 +27,13 @@ #include #include +#include namespace ewol { namespace shortCut { void Init(void); void UnInit(void); - bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown); + bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, ewol::eventKbMoveType_te kbMove, bool isDown); }; }; diff --git a/Sources/libewol/ewol/eObject/EObjectManager.cpp b/Sources/libewol/ewol/eObject/EObjectManager.cpp index ee8d8677..dd7030e4 100644 --- a/Sources/libewol/ewol/eObject/EObjectManager.cpp +++ b/Sources/libewol/ewol/eObject/EObjectManager.cpp @@ -113,6 +113,7 @@ void ewol::EObjectManager::AutoRemove(ewol::EObject* object) EWOL_DEBUG("Auto-Remove EObject : [" << object->GetId() << "]"); informOneObjectIsRemoved(object); m_eObjectAutoRemoveList.PushBack(object); + ewol::ForceRedrawAll(); return; } } diff --git a/Sources/libewol/ewol/game/SceneElement.cpp b/Sources/libewol/ewol/game/SceneElement.cpp index a7f11e66..6eebf69e 100644 --- a/Sources/libewol/ewol/game/SceneElement.cpp +++ b/Sources/libewol/ewol/game/SceneElement.cpp @@ -51,6 +51,10 @@ ewol::SceneElement::SceneElement(void) } retreviveElement = 0; allocatedElements = 0; + if (false == ewol::resource::Keep(background) ) { + EWOL_ERROR("error to keep the scene background"); + background = NULL; + } } ewol::SceneElement::~SceneElement(void) @@ -87,6 +91,9 @@ ewol::SceneElement::~SceneElement(void) } } animated.Clear(); + if (NULL != background) { + ewol::resource::Release(background); + } } void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString) diff --git a/Sources/libewol/ewol/game/SceneElement.h b/Sources/libewol/ewol/game/SceneElement.h index 6e427db1..f3f06df3 100644 --- a/Sources/libewol/ewol/game/SceneElement.h +++ b/Sources/libewol/ewol/game/SceneElement.h @@ -55,6 +55,7 @@ namespace ewol { int32_t numberOfGroup; //!< curent scene number of group etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy + ewol::Texture* background; //!< background element etk::Vector animated; //!< element that must be display the second etk::Vector listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group etk::Vector listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free @@ -93,6 +94,7 @@ namespace ewol { void AddEarrerDestroy(uint32_t uId); void RmEarrerDestroy(uint32_t uId); void SendEventRemove(uint32_t uId); + ewol::Texture* GetBackground(void) { return background; }; }; }; diff --git a/Sources/libewol/ewol/oObject/3DTextured.cpp b/Sources/libewol/ewol/oObject/3DTextured.cpp index 865ec6b7..c2f25498 100644 --- a/Sources/libewol/ewol/oObject/3DTextured.cpp +++ b/Sources/libewol/ewol/oObject/3DTextured.cpp @@ -75,6 +75,7 @@ void ewol::OObject3DTextured::Draw(void) EWOL_ERROR("No shader ..."); return; } + //EWOL_DEBUG(" Display " << m_coord.Size() << " elements" ); m_GLprogram->Use(); // set Matrix : translation/positionMatrix etk::Matrix tmpMatrix = ewol::openGL::GetMatrix(); diff --git a/Sources/libewol/ewol/openGL/Program.cpp b/Sources/libewol/ewol/openGL/Program.cpp index 58d21526..1f3308ef 100644 --- a/Sources/libewol/ewol/openGL/Program.cpp +++ b/Sources/libewol/ewol/openGL/Program.cpp @@ -134,6 +134,28 @@ int32_t ewol::Program::GetAttribute(etk::UString tmpElement) +int32_t ewol::Program::GetUniform(etk::UString tmpElement) +{ + // check if it exist previously : + for(int32_t iii=0; iii