start of the shortcut coding
This commit is contained in:
parent
8989a3dea0
commit
11d9925409
143
Sources/libewol/ewol/ShortCutManager.cpp
Normal file
143
Sources/libewol/ewol/ShortCutManager.cpp
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/ShortCutManager.cpp
|
||||||
|
* @brief ewol shortCut manager (Sources)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/02/2012
|
||||||
|
* @par Project
|
||||||
|
* ewol
|
||||||
|
*
|
||||||
|
* @par Copyright
|
||||||
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Licence summary :
|
||||||
|
* You can modify and redistribute the sources code and binaries.
|
||||||
|
* You can send me the bug-fix
|
||||||
|
*
|
||||||
|
* Term of the licence in in the file licence.txt.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <ewol/ShortCutManager.h>
|
||||||
|
#include <ewol/WidgetMessageMultiCast.h>
|
||||||
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
static etk::VectorType<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data)
|
||||||
|
{
|
||||||
|
EventShortCut * newEvent = new EventShortCut();
|
||||||
|
if (NULL == newEvent) {
|
||||||
|
EWOL_ERROR("Allocation Error on the shortcut ...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
newEvent->generateEventId = generateEventId;
|
||||||
|
newEvent->shift = shift;
|
||||||
|
newEvent->control = control;
|
||||||
|
newEvent->alt = alt;
|
||||||
|
newEvent->meta = meta;
|
||||||
|
newEvent->UnicodeValue = unicodeValue;
|
||||||
|
newEvent->eventData = data;
|
||||||
|
l_inputShortCutEvent.PushBack(newEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::shortCut::Add(char * descriptiveString, const char * generateEventId, etk::UString& data)
|
||||||
|
{
|
||||||
|
if( NULL==descriptiveString
|
||||||
|
|| 0==strlen(descriptiveString))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bool shift = false;
|
||||||
|
bool control = false;
|
||||||
|
bool alt = false;
|
||||||
|
bool meta = false;
|
||||||
|
uint32_t UnicodeValue = 0;
|
||||||
|
|
||||||
|
// parsing of the string :
|
||||||
|
//"ctrl+shift+alt+meta+s"
|
||||||
|
char * tmp = strstr(descriptiveString, "ctrl");
|
||||||
|
if(NULL != tmp) {
|
||||||
|
control = true;
|
||||||
|
}
|
||||||
|
tmp = strstr(descriptiveString, "shift");
|
||||||
|
if(NULL != tmp) {
|
||||||
|
shift = true;
|
||||||
|
}
|
||||||
|
tmp = strstr(descriptiveString, "alt");
|
||||||
|
if(NULL != tmp) {
|
||||||
|
alt = true;
|
||||||
|
}
|
||||||
|
tmp = strstr(descriptiveString, "meta");
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ewol::shortCut::Init(void)
|
||||||
|
{
|
||||||
|
if (l_inputShortCutEvent.Size()>0) {
|
||||||
|
EWOL_WARNING("Old element error in the shortCut system");
|
||||||
|
for(int32_t iii=0; iii< l_inputShortCutEvent.Size(); iii++) {
|
||||||
|
delete(l_inputShortCutEvent[iii]);
|
||||||
|
l_inputShortCutEvent[iii] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l_inputShortCutEvent.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::shortCut::UnInit(void)
|
||||||
|
{
|
||||||
|
if (l_inputShortCutEvent.Size()>0) {
|
||||||
|
for(int32_t iii=0; iii< l_inputShortCutEvent.Size(); iii++) {
|
||||||
|
delete(l_inputShortCutEvent[iii]);
|
||||||
|
l_inputShortCutEvent[iii] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l_inputShortCutEvent.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue)
|
||||||
|
{
|
||||||
|
//EWOL_INFO("Try to find generic shortcut ...");
|
||||||
|
for(int32_t iii=l_inputShortCutEvent.Size()-1; iii>=0; iii--) {
|
||||||
|
if( l_inputShortCutEvent[iii]->shift == shift
|
||||||
|
&& l_inputShortCutEvent[iii]->control == control
|
||||||
|
&& l_inputShortCutEvent[iii]->alt == alt
|
||||||
|
&& l_inputShortCutEvent[iii]->meta == meta
|
||||||
|
&& l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue)
|
||||||
|
{
|
||||||
|
ewol::widgetMessageMultiCast::Send(-1, l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
42
Sources/libewol/ewol/ShortCutManager.h
Normal file
42
Sources/libewol/ewol/ShortCutManager.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/**
|
||||||
|
*******************************************************************************
|
||||||
|
* @file ewol/ShortCutManager.h
|
||||||
|
* @brief ewol shortCut manager (Header)
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @date 22/02/2012
|
||||||
|
* @par Project
|
||||||
|
* ewol
|
||||||
|
*
|
||||||
|
* @par Copyright
|
||||||
|
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY.
|
||||||
|
*
|
||||||
|
* Licence summary :
|
||||||
|
* You can modify and redistribute the sources code and binaries.
|
||||||
|
* You can send me the bug-fix
|
||||||
|
*
|
||||||
|
* Term of the licence in in the file licence.txt.
|
||||||
|
*
|
||||||
|
*******************************************************************************
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EWOL_SHORT_CUT_MANAGER_H__
|
||||||
|
#define __EWOL_SHORT_CUT_MANAGER_H__
|
||||||
|
|
||||||
|
#include <etk/Types.h>
|
||||||
|
#include <etk/UString.h>
|
||||||
|
|
||||||
|
namespace ewol {
|
||||||
|
namespace shortCut {
|
||||||
|
void Init(void);
|
||||||
|
void UnInit(void);
|
||||||
|
bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -31,6 +31,7 @@
|
|||||||
#include <ewol/Texture.h>
|
#include <ewol/Texture.h>
|
||||||
#include <ewol/WidgetManager.h>
|
#include <ewol/WidgetManager.h>
|
||||||
#include <ewol/themeManager.h>
|
#include <ewol/themeManager.h>
|
||||||
|
#include <ewol/ShortCutManager.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -89,8 +90,6 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
|
|||||||
void EWOL_NativeResize(int w, int h );
|
void EWOL_NativeResize(int w, int h );
|
||||||
void EWOL_NativeRegenerateDisplay(void);
|
void EWOL_NativeRegenerateDisplay(void);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void* BaseAppEntry(void* param)
|
static void* BaseAppEntry(void* param)
|
||||||
{
|
{
|
||||||
bool requestEndProcessing = false;
|
bool requestEndProcessing = false;
|
||||||
@ -118,6 +117,7 @@ static void* BaseAppEntry(void* param)
|
|||||||
ewol::texture::Init();
|
ewol::texture::Init();
|
||||||
ewol::theme::Init();
|
ewol::theme::Init();
|
||||||
ewol::InitFont();
|
ewol::InitFont();
|
||||||
|
ewol::shortCut::Init();
|
||||||
APP_Init();
|
APP_Init();
|
||||||
int32_t countNbEvent = 0;
|
int32_t countNbEvent = 0;
|
||||||
EWOL_DEBUG("==> Init BThread (END)");
|
EWOL_DEBUG("==> Init BThread (END)");
|
||||||
@ -161,6 +161,7 @@ static void* BaseAppEntry(void* param)
|
|||||||
{
|
{
|
||||||
eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data;
|
eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data;
|
||||||
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
|
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
|
||||||
|
//if (false==ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue)) { ... }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case THREAD_KEYBORAD_MOVE:
|
case THREAD_KEYBORAD_MOVE:
|
||||||
@ -201,6 +202,7 @@ static void* BaseAppEntry(void* param)
|
|||||||
// call application to uninit
|
// call application to uninit
|
||||||
APP_UnInit();
|
APP_UnInit();
|
||||||
|
|
||||||
|
ewol::shortCut::UnInit();
|
||||||
ewol::texture::UnInit();
|
ewol::texture::UnInit();
|
||||||
ewol::UnInitFont();
|
ewol::UnInitFont();
|
||||||
ewol::widgetManager::UnInit();
|
ewol::widgetManager::UnInit();
|
||||||
|
@ -55,6 +55,10 @@ namespace ewol {
|
|||||||
bool IsSetAltGr(void);
|
bool IsSetAltGr(void);
|
||||||
bool IsSetVerNum(void);
|
bool IsSetVerNum(void);
|
||||||
bool IsSetInsert(void);
|
bool IsSetInsert(void);
|
||||||
|
namespace shortCut {
|
||||||
|
void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString& data);
|
||||||
|
void Add(char * descriptiveString, const char * generateEventId, etk::UString& data);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
int64_t GetCurrentTime(void);
|
int64_t GetCurrentTime(void);
|
||||||
|
@ -1,113 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/widget/WidgetShortCut.cpp
|
|
||||||
* @brief basic ewol short Cut widget (Sources)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 19/02/2012
|
|
||||||
* @par Project
|
|
||||||
* ewol
|
|
||||||
*
|
|
||||||
* @par Copyright
|
|
||||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY.
|
|
||||||
*
|
|
||||||
* Licence summary :
|
|
||||||
* You can modify and redistribute the sources code and binaries.
|
|
||||||
* You can send me the bug-fix
|
|
||||||
*
|
|
||||||
* Term of the licence in in the file licence.txt.
|
|
||||||
*
|
|
||||||
*******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ewol/widget/WidgetShortCut.h>
|
|
||||||
|
|
||||||
|
|
||||||
ewol::WidgetShortCut::WidgetShortCut(void)
|
|
||||||
{
|
|
||||||
// nothing to do ...
|
|
||||||
}
|
|
||||||
|
|
||||||
ewol::WidgetShortCut::~WidgetShortCut(void)
|
|
||||||
{
|
|
||||||
//clean all the object
|
|
||||||
m_inputShortCutEvent.Clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ewol::WidgetShortCut::AddEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue, const char * generateEventId)
|
|
||||||
{
|
|
||||||
eventShortCut_ts newEvent;
|
|
||||||
newEvent.generateEventId = generateEventId;
|
|
||||||
newEvent.shift = shift;
|
|
||||||
newEvent.control = control;
|
|
||||||
newEvent.alt = alt;
|
|
||||||
newEvent.meta = meta;
|
|
||||||
newEvent.UnicodeValue = unicodeValue;
|
|
||||||
m_inputShortCutEvent.PushBack(newEvent);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool ewol::WidgetShortCut::AddEventShortCut(char * descriptiveString, const char * generateEventId)
|
|
||||||
{
|
|
||||||
if( NULL==descriptiveString
|
|
||||||
|| 0==strlen(descriptiveString))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
bool shift = false;
|
|
||||||
bool control = false;
|
|
||||||
bool alt = false;
|
|
||||||
bool meta = false;
|
|
||||||
uint32_t UnicodeValue = 0;
|
|
||||||
|
|
||||||
// parsing of the string :
|
|
||||||
//"ctrl+shift+alt+meta+s"
|
|
||||||
char * tmp = strstr(descriptiveString, "ctrl");
|
|
||||||
if(NULL != tmp) {
|
|
||||||
control = true;
|
|
||||||
}
|
|
||||||
tmp = strstr(descriptiveString, "shift");
|
|
||||||
if(NULL != tmp) {
|
|
||||||
shift = true;
|
|
||||||
}
|
|
||||||
tmp = strstr(descriptiveString, "alt");
|
|
||||||
if(NULL != tmp) {
|
|
||||||
alt = true;
|
|
||||||
}
|
|
||||||
tmp = strstr(descriptiveString, "meta");
|
|
||||||
if(NULL != tmp) {
|
|
||||||
meta = true;
|
|
||||||
}
|
|
||||||
UnicodeValue = descriptiveString[strlen(descriptiveString) -1];
|
|
||||||
// add with generic Adding function ...
|
|
||||||
return AddEventShortCut(shift, control, alt, meta, UnicodeValue, generateEventId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ewol::WidgetShortCut::GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue)
|
|
||||||
{
|
|
||||||
bool ended = false;
|
|
||||||
//EWOL_WARNING("Input event : " << IdInput << " pos(" << x << "," << y << ")");
|
|
||||||
for(int32_t iii=m_inputShortCutEvent.Size()-1; iii>=0; iii--) {
|
|
||||||
if( m_inputShortCutEvent[iii].shift == shift
|
|
||||||
&& m_inputShortCutEvent[iii].control == control
|
|
||||||
&& m_inputShortCutEvent[iii].alt == alt
|
|
||||||
&& m_inputShortCutEvent[iii].meta == meta
|
|
||||||
&& m_inputShortCutEvent[iii].UnicodeValue == unicodeValue)
|
|
||||||
{
|
|
||||||
if (true == GenEventInputExternal(m_inputShortCutEvent[iii].generateEventId, -1, -1)) {
|
|
||||||
ended = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ended;
|
|
||||||
}
|
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
/**
|
|
||||||
*******************************************************************************
|
|
||||||
* @file ewol/widget/WidgetShortCut.h
|
|
||||||
* @brief basic ewol shortCut widget (header)
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @date 19/02/2012
|
|
||||||
* @par Project
|
|
||||||
* ewol
|
|
||||||
*
|
|
||||||
* @par Copyright
|
|
||||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY.
|
|
||||||
*
|
|
||||||
* Licence summary :
|
|
||||||
* You can modify and redistribute the sources code and binaries.
|
|
||||||
* You can send me the bug-fix
|
|
||||||
*
|
|
||||||
* Term of the licence in in the file licence.txt.
|
|
||||||
*
|
|
||||||
*******************************************************************************
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __EWOL_WIDGET_SHORT_CUT_H__
|
|
||||||
#define __EWOL_WIDGET_SHORT_CUT_H__
|
|
||||||
|
|
||||||
#include <ewol/Widget.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char * generateEventId; // event generate ID (to be unique it was pointer on the string name)
|
|
||||||
bool shift;
|
|
||||||
bool control;
|
|
||||||
bool alt;
|
|
||||||
bool meta;
|
|
||||||
uint32_t UnicodeValue;
|
|
||||||
} eventShortCut_ts;
|
|
||||||
|
|
||||||
class WidgetShortCut : virtual public ewol::Widget {
|
|
||||||
public:
|
|
||||||
WidgetShortCut(void);
|
|
||||||
virtual ~WidgetShortCut(void);
|
|
||||||
private:
|
|
||||||
etk::VectorType<eventShortCut_ts> m_inputShortCutEvent; //!< generic short-cut event
|
|
||||||
protected:
|
|
||||||
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, uint32_t unicodeValue, const char * generateEventId);
|
|
||||||
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
|
|
||||||
public:
|
|
||||||
virtual bool GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -17,8 +17,8 @@ FILE_LIST = ewol/ewol.cpp \
|
|||||||
ewol/WidgetManager.cpp \
|
ewol/WidgetManager.cpp \
|
||||||
ewol/WidgetMessageMultiCast.cpp \
|
ewol/WidgetMessageMultiCast.cpp \
|
||||||
ewol/Windows.cpp \
|
ewol/Windows.cpp \
|
||||||
|
ewol/ShortCutManager.cpp \
|
||||||
ewol/widget/WidgetScrolled.cpp \
|
ewol/widget/WidgetScrolled.cpp \
|
||||||
ewol/widget/WidgetShortCut.cpp \
|
|
||||||
ewol/widget/Drawable.cpp \
|
ewol/widget/Drawable.cpp \
|
||||||
ewol/widget/Button.cpp \
|
ewol/widget/Button.cpp \
|
||||||
ewol/widget/Label.cpp \
|
ewol/widget/Label.cpp \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user