Change the management of the event

This commit is contained in:
Edouard Dupin 2012-03-07 17:59:33 +01:00
parent 500e0d929a
commit 0296151234
22 changed files with 605 additions and 187 deletions

View File

@ -23,6 +23,7 @@
*/
#include <ewol/EObjectManager.h>
#include <ewol/base/eventInputManagement.h>
#undef __class__
#define __class__ "EObjectManager"
@ -108,6 +109,8 @@ void informOneObjectIsRemoved(ewol::EObject* object)
m_eObjectList[iii]->OnObjectRemove(object);
}
}
// call input event manager to remove linked widget ...
ewol::eventInput::OnObjectRemove(object);
}

View File

@ -122,6 +122,17 @@ bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::Widget::GetWidgetAtPos(coord2D_ts pos)
{
return this;
}
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos)
{
eventPosition_ts eventPos;

View File

@ -128,6 +128,7 @@ namespace ewol {
public:
void SetOrigin(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y;};
coord2D_ts GetOrigin(void) { return m_origin; };
coord2D_ts RelativePosition(coord2D_ts pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; };
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ...
//update the min Size ... and the expend parameters for the sizer
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; MarkToReedraw(); return true; };
@ -162,10 +163,26 @@ namespace ewol {
virtual void OnLostFocus(void) {};
public:
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
// external acces to set an input event on this widget.
// TODO : deprecated ...
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); // call when input event arrive and call OnEventInput, if no event detected
virtual bool GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue);
protected:
// TODO : Remasterised ...
/**
* @brief Manage input event of this Widget
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Relative and absolute position
* @return true the event is used
* @return false the event is not used
*/
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) { return false; };
// ----------------------------------------------------------------------------------------------------------------
// -- Keboard event (when one is present or when a graphical is present

View File

@ -103,9 +103,41 @@ bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY
return true;
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::Windows::GetWidgetAtPos(coord2D_ts pos)
{
// calculate relative position
coord2D_ts relativePos = RelativePosition(pos);
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
coord2D_ts tmpSize = m_keyBoardwidget->GetMinSize();
if (relativePos.y > m_size.y - tmpSize.y) {
return m_keyBoardwidget->GetWidgetAtPos(pos);
}
}
// event go directly on the pop-up
if (0 < m_popUpWidgetList[m_currentCreateId].Size()) {
if (NULL == m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]) {
m_popUpWidgetList[m_currentCreateId].PopBack();
} else {
return m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]->GetWidgetAtPos(pos);
}
// otherwise in the normal windows
} else if (NULL != m_subWidget[m_currentCreateId]) {
return m_subWidget[m_currentCreateId]->GetWidgetAtPos(pos);
}
// otherwise the event go to this widget ...
return this;
}
bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
/*
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
coord2D_ts tmpSize = m_keyBoardwidget->GetMinSize();
if (pos.local.y > m_size.y - tmpSize.y) {
@ -124,6 +156,7 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, e
} else if (NULL != m_subWidget[m_currentCreateId]) {
m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, pos.abs);
}
*/
return true;
}

View File

@ -52,6 +52,13 @@ namespace ewol {
virtual void On(void) { };
public:
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY);
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
private:
bool m_hasDecoration;

View File

@ -23,6 +23,7 @@
*/
#include <etk/Types.h>
#include <ewol/ewol.h>
#include <ewol/Debug.h>
#include <ewol/threadMsg.h>
@ -34,6 +35,7 @@
#include <ewol/WidgetManager.h>
#include <ewol/themeManager.h>
#include <ewol/ShortCutManager.h>
#include <ewol/base/eventInputManagement.h>
@ -77,8 +79,6 @@ typedef struct {
float y;
} eventInputState_ts;
void EWOL_NativeEventInputMotion(int pointerID, float x, float y );
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y );
void EWOL_NativeResize(int w, int h );
void EWOL_NativeRegenerateDisplay(void);
@ -107,6 +107,7 @@ static void* BaseAppEntry(void* param)
ewol::EObjectManager::Init();
ewol::EObjectMessageMultiCast::Init();
ewol::eventInput::Init();
ewol::widgetManager::Init();
ewol::texture::Init();
ewol::theme::Init();
@ -140,14 +141,24 @@ static void* BaseAppEntry(void* param)
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
{
eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data;
EWOL_NativeEventInputMotion(tmpData->pointerID, tmpData->x, tmpData->y);
coord2D_ts pos;
pos.x = tmpData->x;
pos.y = tmpData->y;
ewol::eventInput::Motion(tmpData->pointerID, pos);
}
break;
case THREAD_INPUT_STATE:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
{
eventInputState_ts * tmpData = (eventInputState_ts*)data.data;
EWOL_NativeEventInputState(tmpData->pointerID, tmpData->state, tmpData->x, tmpData->y);
bool isdown = true;
if (true==tmpData->state) {
isdown = false;
}
coord2D_ts pos;
pos.x = tmpData->x;
pos.y = tmpData->y;
ewol::eventInput::State(tmpData->pointerID, tmpData->state, pos);
}
break;
case THREAD_KEYBORAD_KEY:
@ -202,6 +213,7 @@ static void* BaseAppEntry(void* param)
ewol::EObjectMessageMultiCast::UnInit();
ewol::EObjectManager::UnInit();
ewol::theme::UnInit();
ewol::eventInput::UnInit();
EWOL_DEBUG("==> Un-Init BThread (END)");
pthread_exit(NULL);
}

View File

@ -0,0 +1,312 @@
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/OObject.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
#include <ewol/base/gui.h>
#include <ewol/Debug.h>
#include <etk/UString.h>
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/ewol.h>
#include <ewol/Texture.h>
#include <ewol/base/MainThread.h>
#include <ewol/base/eventInputManagement.h>
typedef struct {
bool isUsed;
int32_t destinationInputId;
int64_t lastTimeEvent;
ewol::Widget* curentWidgetEvent;
coord2D_ts origin;
coord2D_ts size;
coord2D_ts downStart;
coord2D_ts lastEventPos;
bool isDown;
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3
} InputPoperty_ts;
#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 remeved ==> 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<MAX_MANAGE_INPUT; iii++) {
if (eventInputSaved[iii].curentWidgetEvent == removeObject) {
eventInputSaved[iii].curentWidgetEvent = NULL;
}
}
}
static void CleanInputElement(int32_t idInput)
{
eventInputSaved[idInput].isUsed = false;
eventInputSaved[idInput].destinationInputId = 0;
eventInputSaved[idInput].lastTimeEvent = 0;
eventInputSaved[idInput].curentWidgetEvent = NULL;
eventInputSaved[idInput].origin.x = 0;
eventInputSaved[idInput].origin.y = 0;
eventInputSaved[idInput].size.x = 0;
eventInputSaved[idInput].size.y = 0;
eventInputSaved[idInput].downStart.x = 0;
eventInputSaved[idInput].downStart.y = 0;
eventInputSaved[idInput].lastEventPos.x = 0;
eventInputSaved[idInput].lastEventPos.y = 0;
eventInputSaved[idInput].isDown = false;
eventInputSaved[idInput].nbClickEvent = 0;
}
void ewol::eventInput::Init(void)
{
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
eventInputSaved[iii].isUsed = false;
eventInputSaved[iii].destinationInputId = 0;
eventInputSaved[iii].lastTimeEvent = 0;
eventInputSaved[iii].curentWidgetEvent = NULL;
eventInputSaved[iii].origin.x = 0;
eventInputSaved[iii].origin.y = 0;
eventInputSaved[iii].size.x = 0;
eventInputSaved[iii].size.y = 0;
eventInputSaved[iii].downStart.x = 0;
eventInputSaved[iii].downStart.y = 0;
eventInputSaved[iii].lastEventPos.x = 0;
eventInputSaved[iii].lastEventPos.y = 0;
eventInputSaved[iii].isDown = false;
eventInputSaved[iii].nbClickEvent = 0;
}
}
void ewol::eventInput::UnInit(void)
{
}
extern ewol::Windows* gui_uniqueWindows;
bool localEventInput(ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
{
if (NULL != destWidget) {
ewol::eventPosition_ts tmpEventPosition;
tmpEventPosition.abs = pos;
tmpEventPosition.local = destWidget->RelativePosition(pos);
return destWidget->OnEventInput(IdInput, typeEvent, tmpEventPosition);
}
return false;
}
// defined by the platform specific file :
extern int32_t separateClickTime;
extern int32_t offsetMoveClicked;
extern int32_t offsetMoveClickedDouble;
void ewol::eventInput::Motion(int pointerID, coord2D_ts pos)
{
if( pointerID > MAX_MANAGE_INPUT
|| pointerID < 0) {
// not manage input
return;
}
if (true == eventInputSaved[pointerID].isUsed) {
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [MOVE] (" << pos.x << "," << pos.y << ")");
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_MOVE, pos);
}
}
void ewol::eventInput::State(int pointerID, bool isDown, coord2D_ts pos)
{
if( pointerID > MAX_MANAGE_INPUT
|| pointerID < 0) {
// not manage input
return;
}
// get the curent time ...
int64_t currentTime = GetCurrentTime();
if (true == isDown) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOWN] x=" << pos.x << " y=" << pos.y);
if(true == eventInputSaved[pointerID].isUsed) {
// bad case ... ???
} else {
// Mark it used :
eventInputSaved[pointerID].isUsed = true;
// Save current position :
eventInputSaved[pointerID].downStart = pos;
// save start time
eventInputSaved[pointerID].lastTimeEvent = currentTime;
// get destination widget :
if(NULL != gui_uniqueWindows) {
eventInputSaved[pointerID].curentWidgetEvent = gui_uniqueWindows->GetWidgetAtPos(pos);
} else {
eventInputSaved[pointerID].curentWidgetEvent = NULL;
}
// generate DOWN Event
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] x=" << pos.x << " y=" << pos.y);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_DOWN, pos);
}
} else {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [UP] (" << pos.x << "," << pos.y << ")");
if(false == eventInputSaved[pointerID].isUsed) {
// bad case ... ???
EWOL_WARNING("Up event without previous down ... ");
// Mark it un-used :
eventInputSaved[pointerID].isUsed = false;
// revove the widget ...
eventInputSaved[pointerID].curentWidgetEvent = NULL;
} else {
// generate UP Event
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [UP] (" << pos.x << "," << pos.y << ")");
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_UP, pos);
// generate event (single)
if( abs(eventInputSaved[pointerID].downStart.x - pos.x) < offsetMoveClicked
&& abs(eventInputSaved[pointerID].downStart.y - pos.y) < offsetMoveClicked ){
// Save current position :
eventInputSaved[pointerID].downStart = pos;
// save start time
eventInputSaved[pointerID].lastTimeEvent = currentTime;
// generate event :
EWOL_DEBUG("GUI : Input ID=" << pointerID << " [SINGLE] (" << pos.x << "," << pos.y << ")");
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, pos);
}
// Mark it un-used :
eventInputSaved[pointerID].isUsed = false;
// revove the widget ...
eventInputSaved[pointerID].curentWidgetEvent = NULL;
}
}
}
/*
void EWOL_NativeEventInputState(int pointerID, bool isDown, float x, float y )
{
coord2D_t pos;
pos.x = x;
pos.y = y;
if( pointerID > MAX_MANAGE_INPUT
|| pointerID < 0) {
// not manage input
return;
}
//EWOL_INFO("GUI : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y);
if (isDown) {
//EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y);
// Send Down message
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
localEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOWN, pos);
// Check double or triple click event ...
m_previousDown_x = x;
m_previousDown_y = y;
if (m_previousBouttonId != pointerID) {
m_previousBouttonId = pointerID;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
} else {
if( abs(m_previous_x - x) < offsetMoveClicked
&& abs(m_previous_y - y) < offsetMoveClicked )
{
// nothink to do ... wait up ...
} else {
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
}
} else {
//EWOL_DEBUG("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y);
// Send Down message
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
localEventInput(pointerID, ewol::EVENT_INPUT_TYPE_UP, pos);
if (m_previousBouttonId != pointerID) {
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
} else {
int64_t currentTime = GetCurrentTime(); // return the tic in 1ms
EWOL_VERBOSE("time is : " << (int)currentTime << " "<< (int)(currentTime/1000) <<"s " << (int)((currentTime%100)*10) << "ms delta : " << (currentTime - m_previousTime) << "<" << separateClickTime );
if (currentTime - m_previousTime >= separateClickTime) {
//check if the same area click :
if( abs(m_previousDown_x - x) < offsetMoveClicked
&& abs(m_previousDown_y - y) < offsetMoveClicked )
{
// might generate an sigle event :
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
localEventInput(pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, pos);
m_previous_x = m_previousDown_x;
m_previous_y = m_previousDown_y;
m_previousTime = currentTime;
} else {
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
}
m_previousDouble = false;
} else {
// TODO : the double ckick does not work, I need to check this later ... if needed
//check if the same area click :
if( abs(m_previous_x - x) < offsetMoveClickedDouble
&& abs(m_previous_y - y) < offsetMoveClickedDouble )
{
// might generate an sigle event :
if (false == m_previousDouble) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
localEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOUBLE, pos);
m_previousTime = currentTime;
m_previousDouble = true;
} else {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [TRIPLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
localEventInput(pointerID, ewol::EVENT_INPUT_TYPE_TRIPLE, pos);
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
} else {
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
}
}
}
}
*/

View File

@ -0,0 +1,28 @@
#ifndef __EWOL_EVENT_INPUT_MANAGEMENT_H__
#define __EWOL_EVENT_INPUT_MANAGEMENT_H__
namespace ewol
{
namespace eventInput
{
void Init(void);
void UnInit(void);
void Motion(int pointerID, coord2D_ts pos );
void State(int pointerID, bool isDown, coord2D_ts pos);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void OnObjectRemove(ewol::EObject * removeObject);
}
}
#endif

View File

@ -150,167 +150,10 @@ void guiAbstraction::KeyboardHide(void)
}
// defined by the platform specific file :
extern int32_t separateClickTime;
extern int32_t offsetMoveClicked;
extern int32_t offsetMoveClickedDouble;
static int32_t m_previousBouttonId = -1;
static int32_t m_previousDown_x = -1;
static int32_t m_previousDown_y = -1;
static int32_t m_previous_x = -1;
static int32_t m_previous_y = -1;
static int64_t m_previousTime = 0;
static bool m_previousDouble = false;
void EWOL_NativeEventInputMotion(int pointerID, float x, float y )
{
//EWOL_INFO("Event : Input Motion ID=" << pointerID << " x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
if(NULL != gui_uniqueWindows) {
//EWOL_DEBUG("Event: bt=" << pointerID+1 << " ** = \"MotionNotify\" (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_MOVE, tmpCoord);
}
}
}
void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{
//EWOL_INFO("GUI : Input ID=" << pointerID << " [" << isUp << "] x=" << x << " y=" << y);
if (isUp) {
//EWOL_DEBUG("GUI : Input ID=" << pointerID << " [DOWN] x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message
if (NULL != gui_uniqueWindows) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOWN, tmpCoord);
}
// Check double or triple click event ...
m_previousDown_x = x;
m_previousDown_y = y;
if (m_previousBouttonId != pointerID) {
m_previousBouttonId = pointerID;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
} else {
if( abs(m_previous_x - x) < offsetMoveClicked
&& abs(m_previous_y - y) < offsetMoveClicked )
{
// nothink to do ... wait up ...
} else {
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
}
}
} else {
//EWOL_DEBUG("Event : Input ID=" << pointerID << " [UP] x=" << x << " y=" << y);
if(0<=pointerID && pointerID < NB_MAX_INPUT ) {
// Send Down message
if (NULL != gui_uniqueWindows) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_UP, tmpCoord);
}
if (m_previousBouttonId != pointerID) {
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
} else {
int64_t currentTime = GetCurrentTime(); // return the tic in 1ms
EWOL_VERBOSE("time is : " << (int)currentTime << " "<< (int)(currentTime/1000) <<"s " << (int)((currentTime%100)*10) << "ms delta : " << (currentTime - m_previousTime) << "<" << separateClickTime );
if (currentTime - m_previousTime >= separateClickTime) {
//check if the same area click :
if( abs(m_previousDown_x - x) < offsetMoveClicked
&& abs(m_previousDown_y - y) < offsetMoveClicked )
{
// might generate an sigle event :
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_SINGLE, tmpCoord);
m_previous_x = m_previousDown_x;
m_previous_y = m_previousDown_y;
m_previousTime = currentTime;
} else {
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
}
m_previousDouble = false;
} else {
// TODO : the double ckick does not work, I need to check this later ... if needed
//check if the same area click :
if( abs(m_previous_x - x) < offsetMoveClickedDouble
&& abs(m_previous_y - y) < offsetMoveClickedDouble )
{
// might generate an sigle event :
if (false == m_previousDouble) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_DOUBLE, tmpCoord);
m_previousTime = currentTime;
m_previousDouble = true;
} else {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [TRIPLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
// TODO : Rework this ...
coord2D_ts tmpCoord;
tmpCoord.x = x;
tmpCoord.y = y;
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_TRIPLE, tmpCoord);
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
} else {
// reset values ...
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previousBouttonId = 0;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
}
}
}
}
}
}
static int64_t startTime = -1;
static int64_t nbCallTime = 0;

View File

@ -215,6 +215,8 @@ bool ewol::ColorBar::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
{
//EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) {
pos.local.x = etk_max(etk_min(pos.local.x, m_size.x),0);
pos.local.y = etk_max(etk_min(pos.local.y, m_size.y),0);
if( ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent

View File

@ -258,33 +258,55 @@ void ewol::ContextMenu::OnRegenerateDisplay(void)
}
bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::ContextMenu::GetWidgetAtPos(coord2D_ts pos)
{
// calculate relative position
coord2D_ts relativePos = RelativePosition(pos);
// Check for sub Element
if (NULL != m_subWidget[m_currentCreateId]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId]->GetSize();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId]->GetOrigin();
if( (tmpOrigin.x <= pos.local.x && tmpOrigin.x + tmpSize.x >= pos.local.x)
&& (tmpOrigin.y <= pos.local.y && tmpOrigin.y + tmpSize.y >= pos.local.y) )
if( (tmpOrigin.x <= relativePos.x && tmpOrigin.x + tmpSize.x >= relativePos.x)
&& (tmpOrigin.y <= relativePos.y && tmpOrigin.y + tmpSize.y >= relativePos.y) )
{
return m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, pos.abs);
} else {
//EWOL_INFO("Event ouside the context menu");
if (IdInput > 0) {
if( typeEvent == ewol::EVENT_INPUT_TYPE_DOWN
|| typeEvent == ewol::EVENT_INPUT_TYPE_MOVE
|| typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_DOUBLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_TRIPLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_UP
|| typeEvent == ewol::EVENT_INPUT_TYPE_ENTER
|| typeEvent == ewol::EVENT_INPUT_TYPE_LEAVE ) {
// Auto-remove ...
MarkToRemove();
}
}
return m_subWidget[m_currentCreateId]->GetWidgetAtPos(pos);
}
}
return true;
return this;
}
/**
* @brief Manage input event of this Widget
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Relative and absolute position
* @return true the event is used
* @return false the event is not used
*/
bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
//EWOL_INFO("Event ouside the context menu");
if (IdInput > 0) {
if( typeEvent == ewol::EVENT_INPUT_TYPE_DOWN
|| typeEvent == ewol::EVENT_INPUT_TYPE_MOVE
|| typeEvent == ewol::EVENT_INPUT_TYPE_SINGLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_DOUBLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_TRIPLE
|| typeEvent == ewol::EVENT_INPUT_TYPE_UP
|| typeEvent == ewol::EVENT_INPUT_TYPE_ENTER
|| typeEvent == ewol::EVENT_INPUT_TYPE_LEAVE ) {
// Auto-remove ...
MarkToRemove();
return true;
}
}
return false;
}

View File

@ -66,6 +66,13 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
};

View File

@ -179,8 +179,35 @@ void ewol::PopUp::OnRegenerateDisplay(void)
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::PopUp::GetWidgetAtPos(coord2D_ts pos)
{
// calculate relative position
coord2D_ts relativePos = RelativePosition(pos);
// for the element in the pop-up ...
if (NULL != m_subWidget[m_currentCreateId]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId]->GetSize();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId]->GetOrigin();
if( (tmpOrigin.x <= relativePos.x && tmpOrigin.x + tmpSize.x >= relativePos.x)
&& (tmpOrigin.y <= relativePos.y && tmpOrigin.y + tmpSize.y >= relativePos.y) )
{
return m_subWidget[m_currentCreateId]->GetWidgetAtPos(pos);
} else {
//EWOL_INFO("Event ouside the Pop-up");
}
}
// otherwise the event go to this widget ...
return this;
}
bool ewol::PopUp::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
/*
if (NULL != m_subWidget[m_currentCreateId]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId]->GetSize();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId]->GetOrigin();
@ -192,6 +219,7 @@ bool ewol::PopUp::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eve
//EWOL_INFO("Event ouside the Pop-up");
}
}
*/
return true;
}

View File

@ -56,6 +56,13 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
/**

View File

@ -234,8 +234,34 @@ void ewol::SizerHori::OnRegenerateDisplay(void)
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::SizerHori::GetWidgetAtPos(coord2D_ts pos)
{
// for all element in the sizer ...
for (int32_t iii=0; iii<m_subWidget[m_currentCreateId].Size(); iii++) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId][iii]->GetSize();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId][iii]->GetOrigin();
if( (tmpOrigin.x <= pos.x && tmpOrigin.x + tmpSize.x >= pos.x)
&& (tmpOrigin.y <= pos.y && tmpOrigin.y + tmpSize.y >= pos.y) )
{
return m_subWidget[m_currentCreateId][iii]->GetWidgetAtPos(pos);
}
}
}
// otherwise the event go to this widget ...
return this;
}
bool ewol::SizerHori::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
/*
for (int32_t iii=0; iii<m_subWidget[m_currentCreateId].Size(); iii++) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId][iii]->GetSize();
@ -247,6 +273,7 @@ bool ewol::SizerHori::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
}
}
}
*/
return true;
}

View File

@ -56,6 +56,13 @@ namespace ewol {
virtual bool OnDraw(void);
public:
virtual void OnRegenerateDisplay(void);
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
/**

View File

@ -234,8 +234,33 @@ void ewol::SizerVert::OnRegenerateDisplay(void)
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::SizerVert::GetWidgetAtPos(coord2D_ts pos)
{
// for all element in the sizer ...
for (int32_t iii=0; iii<m_subWidget[m_currentCreateId].Size(); iii++) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId][iii]->GetSize();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId][iii]->GetOrigin();
if( (tmpOrigin.x <= pos.x && tmpOrigin.x + tmpSize.x >= pos.x)
&& (tmpOrigin.y <= pos.y && tmpOrigin.y + tmpSize.y >= pos.y) )
{
return m_subWidget[m_currentCreateId][iii]->GetWidgetAtPos(pos);
}
}
}
// otherwise the event go to this widget ...
return this;
}
bool ewol::SizerVert::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
/*
for (int32_t iii=0; iii<m_subWidget[m_currentCreateId].Size(); iii++) {
if (NULL != m_subWidget[m_currentCreateId][iii]) {
coord2D_ts tmpSize = m_subWidget[m_currentCreateId][iii]->GetSize();
@ -247,6 +272,7 @@ bool ewol::SizerVert::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
}
}
}
*/
return true;
}

View File

@ -57,6 +57,14 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
/**

View File

@ -35,6 +35,7 @@ extern const char * const ewolEventSliderChange = "ewol-event-slider-change";
#undef __class__
#define __class__ "Slider"
const int32_t dotRadius = 6;
ewol::Slider::Slider(void)
{
@ -66,7 +67,7 @@ ewol::Slider::~Slider(void)
bool ewol::Slider::CalculateMinSize(void)
{
m_minSize.x = 40;
m_minSize.y = 15;
m_minSize.y = dotRadius*2;
MarkToReedraw();
return true;
}
@ -111,9 +112,9 @@ void ewol::Slider::OnRegenerateDisplay(void)
tmpOObjects->SetColor(m_textColorFg);
// draw a line :
tmpOObjects->Line(4, m_size.y/2, m_size.x-4, m_size.y/2, 1);
tmpOObjects->Line(dotRadius, m_size.y/2, m_size.x-dotRadius, m_size.y/2, 1);
tmpOObjects->Disc(4+((etkFloat_t)(m_value-m_min)/(etkFloat_t)(m_max-m_min))*(etkFloat_t)(m_size.x-8), m_size.y/2, 4);
tmpOObjects->Disc(4+((etkFloat_t)(m_value-m_min)/(etkFloat_t)(m_max-m_min))*(etkFloat_t)(m_size.x-2*dotRadius), m_size.y/2, dotRadius);
AddOObject(tmpOObjects);
}
@ -130,9 +131,9 @@ bool ewol::Slider::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, ev
|| ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// get the new position :
EWOL_DEBUG("Event on Slider (" << pos.local.x << "," << pos.local.y << ")");
m_value = m_min + (etkFloat_t)(pos.local.x - 4) / (etkFloat_t)(m_size.x-8) * (etkFloat_t)(m_max-m_min);
m_value = m_min + (etkFloat_t)(pos.local.x - dotRadius) / (etkFloat_t)(m_size.x-2*dotRadius) * (etkFloat_t)(m_max-m_min);
m_value = etk_max(etk_min(m_value, m_max), m_min);
EWOL_DEBUG(" new value : " << m_value << "¤ [" << m_min << ".." << m_max << "]");
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
GenerateEventId(ewolEventSliderChange);
MarkToReedraw();
return true;

View File

@ -42,6 +42,7 @@ namespace ewol {
int32_t GetValue(void);
void SetMin(int32_t val);
void SetMax(int32_t val);
void SetColor(color_ts newColor) { m_textColorFg = newColor; };
private:
int32_t m_value;
int32_t m_min;

View File

@ -71,18 +71,30 @@ ewol::ColorChooser::ColorChooser(void)
*/
SubWidgetAdd(m_widgetColorBar);
color_ts sliderColor;
sliderColor.red = 0.0;
sliderColor.green = 0.0;
sliderColor.blue = 0.0;
sliderColor.alpha = 1.0;
m_widgetRed = new ewol::Slider();
m_widgetRed->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
m_widgetRed->SetExpendX(true);
m_widgetRed->SetFillX(true);
m_widgetRed->SetMin(0);
m_widgetRed->SetMax(255);
sliderColor.red = 1.0;
m_widgetRed->SetColor(sliderColor);
sliderColor.red = 0.0;
SubWidgetAdd(m_widgetRed);
m_widgetGreen = new ewol::Slider();
m_widgetGreen->RegisterOnEvent(this, ewolEventSliderChange, eventColorSpecificHasChange);
m_widgetGreen->SetExpendX(true);
m_widgetGreen->SetFillX(true);
m_widgetGreen->SetMin(0);
sliderColor.green = 1.0;
m_widgetGreen->SetColor(sliderColor);
sliderColor.green = 0.0;
m_widgetGreen->SetMax(255);
SubWidgetAdd(m_widgetGreen);
m_widgetBlue = new ewol::Slider();
@ -90,6 +102,9 @@ ewol::ColorChooser::ColorChooser(void)
m_widgetBlue->SetExpendX(true);
m_widgetBlue->SetFillX(true);
m_widgetBlue->SetMin(0);
sliderColor.blue = 1.0;
m_widgetBlue->SetColor(sliderColor);
sliderColor.blue = 0.0;
m_widgetBlue->SetMax(255);
SubWidgetAdd(m_widgetBlue);
m_widgetAlpha = new ewol::Slider();

View File

@ -4,6 +4,7 @@ FILE_LIST = ewol/ewol.cpp \
ewol/threadMsg.cpp \
ewol/base/MainThread.cpp \
ewol/base/gui.cpp \
ewol/base/eventInputManagement.cpp \
ewol/Debug.cpp \
ewol/EObject.cpp \
ewol/EObjectManager.cpp \