[DEV] change the policy of the background of the scene and set the shortcut on Fxx key

This commit is contained in:
Edouard DUPIN 2012-10-11 18:08:30 +02:00
parent a70c2055b9
commit f5c65e0fb6
12 changed files with 149 additions and 43 deletions

@ -1 +1 @@
Subproject commit 4c16ddcbd7f37fc84a663484a1a7388188ceaa79 Subproject commit b6ae353bdfe68963de4652babaf8d4d24b1026d3

View File

@ -87,7 +87,7 @@ void ewol::resource::Display(void)
* @param --- * @param ---
* @return --- * @return ---
*/ */
void ReLoadResources(void) void ewol::resource::ReLoadResources(void)
{ {
EWOL_INFO("------------- Resources re-loaded -------------"); EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ... // remove all resources ...

View File

@ -36,13 +36,27 @@ class EventShortCut {
bool control; bool control;
bool alt; bool alt;
bool meta; bool meta;
uniChar_t UnicodeValue; uniChar_t UnicodeValue; // 0 if not used
ewol::eventKbMoveType_te keyboardMoveValue; // 0 if not used
}; };
static etk::Vector<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event static etk::Vector<EventShortCut *> 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(); EventShortCut * newEvent = new EventShortCut();
if (NULL == newEvent) { if (NULL == newEvent) {
@ -55,6 +69,7 @@ void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_
newEvent->alt = alt; newEvent->alt = alt;
newEvent->meta = meta; newEvent->meta = meta;
newEvent->UnicodeValue = unicodeValue; newEvent->UnicodeValue = unicodeValue;
newEvent->keyboardMoveValue = kbMove;
newEvent->eventData = data; newEvent->eventData = data;
l_inputShortCutEvent.PushBack(newEvent); l_inputShortCutEvent.PushBack(newEvent);
return; return;
@ -92,9 +107,65 @@ void ewol::shortCut::Add(const char * descriptiveString, const char * generateEv
if(NULL != tmp) { if(NULL != tmp) {
meta = true; meta = true;
} }
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]; UnicodeValue = descriptiveString[strlen(descriptiveString) -1];
// add with generic Adding function ... // add with generic Adding function ...
ewol::shortCut::Add(shift, control, alt, meta, UnicodeValue, generateEventId, data); 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') { if (unicodeValue >= 'A' && unicodeValue <='Z') {
unicodeValue += 'a' - 'A'; 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]->control == control
&& l_inputShortCutEvent[iii]->alt == alt && l_inputShortCutEvent[iii]->alt == alt
&& l_inputShortCutEvent[iii]->meta == meta && l_inputShortCutEvent[iii]->meta == meta
&& ( ( l_inputShortCutEvent[iii]->keyboardMoveValue == ewol::EVENT_KB_MOVE_TYPE_NONE
&& l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue) && l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue)
|| ( l_inputShortCutEvent[iii]->keyboardMoveValue == kbMove
&& l_inputShortCutEvent[iii]->UnicodeValue == 0)
) )
{ {
if (isDown) { if (isDown) {
ewol::EObjectMessageMultiCast::AnonymousSend(l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData); ewol::EObjectMessageMultiCast::AnonymousSend(l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData);

View File

@ -27,12 +27,13 @@
#include <etk/Types.h> #include <etk/Types.h>
#include <etk/UString.h> #include <etk/UString.h>
#include <ewol/widget/Widget.h>
namespace ewol { namespace ewol {
namespace shortCut { namespace shortCut {
void Init(void); void Init(void);
void UnInit(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);
}; };
}; };

View File

@ -113,6 +113,7 @@ void ewol::EObjectManager::AutoRemove(ewol::EObject* object)
EWOL_DEBUG("Auto-Remove EObject : [" << object->GetId() << "]"); EWOL_DEBUG("Auto-Remove EObject : [" << object->GetId() << "]");
informOneObjectIsRemoved(object); informOneObjectIsRemoved(object);
m_eObjectAutoRemoveList.PushBack(object); m_eObjectAutoRemoveList.PushBack(object);
ewol::ForceRedrawAll();
return; return;
} }
} }

View File

@ -51,6 +51,10 @@ ewol::SceneElement::SceneElement(void)
} }
retreviveElement = 0; retreviveElement = 0;
allocatedElements = 0; allocatedElements = 0;
if (false == ewol::resource::Keep(background) ) {
EWOL_ERROR("error to keep the scene background");
background = NULL;
}
} }
ewol::SceneElement::~SceneElement(void) ewol::SceneElement::~SceneElement(void)
@ -87,6 +91,9 @@ ewol::SceneElement::~SceneElement(void)
} }
} }
animated.Clear(); animated.Clear();
if (NULL != background) {
ewol::resource::Release(background);
}
} }
void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString) void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString)

View File

@ -55,6 +55,7 @@ namespace ewol {
int32_t numberOfGroup; //!< curent scene number of group int32_t numberOfGroup; //!< curent scene number of group
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
ewol::Texture* background; //!< background element
etk::Vector<ewol::Sprite*> animated; //!< element that must be display the second etk::Vector<ewol::Sprite*> animated; //!< element that must be display the second
etk::Vector<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group etk::Vector<ewol::GameElement*> listAnimatedElements[MAX_GROUP_NUMBER]; //!< generic element to display order in the diffferent group
etk::Vector<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free etk::Vector<ewol::GameElement*> listGarbage; //!< garbage of the old element allocated ==> prevent multiple alloc and free
@ -93,6 +94,7 @@ namespace ewol {
void AddEarrerDestroy(uint32_t uId); void AddEarrerDestroy(uint32_t uId);
void RmEarrerDestroy(uint32_t uId); void RmEarrerDestroy(uint32_t uId);
void SendEventRemove(uint32_t uId); void SendEventRemove(uint32_t uId);
ewol::Texture* GetBackground(void) { return background; };
}; };
}; };

View File

@ -75,6 +75,7 @@ void ewol::OObject3DTextured::Draw(void)
EWOL_ERROR("No shader ..."); EWOL_ERROR("No shader ...");
return; return;
} }
//EWOL_DEBUG(" Display " << m_coord.Size() << " elements" );
m_GLprogram->Use(); m_GLprogram->Use();
// set Matrix : translation/positionMatrix // set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix(); etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();

View File

@ -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<m_elementList.Size(); iii++) {
if (m_elementList[iii].m_name == tmpElement) {
return iii;
}
}
progAttributeElement tmp;
tmp.m_name = tmpElement;
tmp.m_isAttribute = false;
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
if (tmp.m_elementId<0) {
checkGlError("glGetUniformLocation", __LINE__);
EWOL_INFO("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
return -1;
}
m_elementList.PushBack(tmp);
return m_elementList.Size()-1;
}
void ewol::Program::UpdateContext(void) void ewol::Program::UpdateContext(void)
{ {
if (true==m_exist) { if (true==m_exist) {
@ -171,11 +193,19 @@ void ewol::Program::UpdateContext(void)
m_exist = true; m_exist = true;
// now get the old attribute requested priviously ... // now get the old attribute requested priviously ...
for(int32_t iii=0; iii<m_elementList.Size(); iii++) { for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
if (true==m_elementList[iii].m_isAttribute) {
m_elementList[iii].m_elementId = glGetAttribLocation(m_program, m_elementList[iii].m_name.c_str()); m_elementList[iii].m_elementId = glGetAttribLocation(m_program, m_elementList[iii].m_name.c_str());
if (m_elementList[iii].m_elementId<0) { if (m_elementList[iii].m_elementId<0) {
checkGlError("glGetAttribLocation", __LINE__); checkGlError("glGetAttribLocation", __LINE__);
EWOL_INFO("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId); EWOL_INFO("glGetAttribLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
} }
} else {
m_elementList[iii].m_elementId = glGetUniformLocation(m_program, m_elementList[iii].m_name.c_str());
if (m_elementList[iii].m_elementId<0) {
checkGlError("glGetUniformLocation", __LINE__);
EWOL_INFO("glGetUniformLocation(\"" << m_elementList[iii].m_name << "\") = " << m_elementList[iii].m_elementId);
}
}
} }
} }
} }
@ -253,28 +283,6 @@ void ewol::Program::Reload(void)
int32_t ewol::Program::GetUniform(etk::UString tmpElement)
{
// check if it exist previously :
for(int32_t iii=0; iii<m_elementList.Size(); iii++) {
if (m_elementList[iii].m_name == tmpElement) {
return iii;
}
}
progAttributeElement tmp;
tmp.m_name = tmpElement;
tmp.m_isAttribute = false;
tmp.m_elementId = glGetUniformLocation(m_program, tmp.m_name.c_str());
if (tmp.m_elementId<0) {
checkGlError("glGetUniformLocation", __LINE__);
EWOL_INFO("glGetUniformLocation(\"" << tmp.m_name << "\") = " << tmp.m_elementId);
return -1;
}
m_elementList.PushBack(tmp);
return m_elementList.Size()-1;
}
void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample) void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample)
{ {
if (idElem<0 || idElem>m_elementList.Size()) { if (idElem<0 || idElem>m_elementList.Size()) {

View File

@ -159,6 +159,7 @@ void ewolProcessEvents(void)
data.keyboardKey.special.alt, data.keyboardKey.special.alt,
data.keyboardKey.special.meta, data.keyboardKey.special.meta,
data.keyboardKey.myChar, data.keyboardKey.myChar,
ewol::EVENT_KB_MOVE_TYPE_NONE,
data.keyboardKey.isDown)) { data.keyboardKey.isDown)) {
// Get the current Focused Widget : // Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
@ -176,7 +177,13 @@ void ewolProcessEvents(void)
break; break;
case THREAD_KEYBORAD_MOVE: case THREAD_KEYBORAD_MOVE:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE"); //EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
{ if (false==ewol::shortCut::Process(data.keyboardKey.special.shift,
data.keyboardKey.special.ctrl,
data.keyboardKey.special.alt,
data.keyboardKey.special.meta,
0,
data.keyboardMove.move,
data.keyboardKey.isDown)) {
specialCurrentKey = data.keyboardMove.special; specialCurrentKey = data.keyboardMove.special;
// Get the current Focused Widget : // Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet(); ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();

View File

@ -88,6 +88,9 @@ void ewol::Scene::OnRegenerateDisplay(void)
void ewol::Scene::OnDraw(DrawProperty& displayProp) void ewol::Scene::OnDraw(DrawProperty& displayProp)
{ {
//EWOL_ERROR(" On draw : " << m_currentDrawId); //EWOL_ERROR(" On draw : " << m_currentDrawId);
// draw background :
// TODO : ...
//background
// draw elements // draw elements
for (int32_t iii=0; iii<m_sceneElement.animated.Size(); iii++) { for (int32_t iii=0; iii<m_sceneElement.animated.Size(); iii++) {
if (NULL != m_sceneElement.animated[iii]) { if (NULL != m_sceneElement.animated[iii]) {

View File

@ -58,6 +58,7 @@ namespace ewol {
} eventKbType_te; } eventKbType_te;
typedef enum { typedef enum {
EVENT_KB_MOVE_TYPE_NONE,
EVENT_KB_MOVE_TYPE_LEFT, EVENT_KB_MOVE_TYPE_LEFT,
EVENT_KB_MOVE_TYPE_RIGHT, EVENT_KB_MOVE_TYPE_RIGHT,
EVENT_KB_MOVE_TYPE_UP, EVENT_KB_MOVE_TYPE_UP,