Widget: generate a basic interpretation of event inside an area ==> flags must be interpreted
This commit is contained in:
parent
723f1a3c3c
commit
991985635d
@ -47,7 +47,9 @@
|
|||||||
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
||||||
typedef unsigned short int uint16_t;
|
typedef unsigned short int uint16_t;
|
||||||
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
||||||
typedef unsigned long long int uint64_t;
|
#ifndef __uint64_t_defined
|
||||||
|
typedef unsigned long int uint64_t;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define etk_min(elemA, elemB) ((elemA)<(elemB)) ? (elemA) : (elemB)
|
#define etk_min(elemA, elemB) ((elemA)<(elemB)) ? (elemA) : (elemB)
|
||||||
|
@ -52,9 +52,41 @@ bool ewol::Widget::CalculateSize(double availlableX, double availlableY)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y)
|
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, double x, double y)
|
||||||
{
|
{
|
||||||
return true;
|
bool ended = false;
|
||||||
|
for(int32_t iii=m_inputEvent.Size()-1; iii>=0; iii--) {
|
||||||
|
if (EWOL_EVENT_AREA == m_inputEvent[iii].mode) {
|
||||||
|
if( m_inputEvent[iii].area.origin.x <= x
|
||||||
|
&& m_inputEvent[iii].area.origin.y <= y
|
||||||
|
&& m_inputEvent[iii].area.origin.x + m_inputEvent[iii].area.size.x > x
|
||||||
|
&& m_inputEvent[iii].area.origin.y + m_inputEvent[iii].area.size.y > y )
|
||||||
|
{
|
||||||
|
// TODO : What is the flags for ??? how can we use it...
|
||||||
|
if( FLAG_EVENT_INPUT_1 && m_inputEvent[iii].area.flags
|
||||||
|
&& 1 == IdInput)
|
||||||
|
{
|
||||||
|
ended = OnEventArea(m_inputEvent[iii].generateEventId, x, y);
|
||||||
|
if (true == ended) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// todo : call other link widget :
|
||||||
|
if (-1 != m_inputEvent[iii].widgetCall) {
|
||||||
|
ewol::Widget * tmpWidget = NULL;
|
||||||
|
//tmpWidget = ewol::GetWidgetWithID(newEvent.widgetCall);
|
||||||
|
ended = tmpWidget->OnEventAreaExternal(m_uniqueId, m_inputEvent[iii].generateEventId, x, y);
|
||||||
|
if (true == ended) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false == ended) {
|
||||||
|
return OnEventInput(IdInput, typeEvent, x, y);
|
||||||
|
}
|
||||||
|
return ended;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -64,8 +96,42 @@ bool ewol::Widget::GenEventShortCut(bool shift, bool control, bool alt, bool pom
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ewol::Widget::AddEventArea(coord origin, coord size, uint32_t flags, const char * generateEventId)
|
bool ewol::Widget::AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId)
|
||||||
{
|
{
|
||||||
|
if( origin.x < 0.0
|
||||||
|
|| origin.y < 0.0)
|
||||||
|
{
|
||||||
|
EWOL_WARNING("origin under 0.0 ... out of range");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if( size.x < 0.0
|
||||||
|
|| size.y < 0.0)
|
||||||
|
{
|
||||||
|
EWOL_WARNING("size under 0.0 ... out of range");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if( origin.x > m_size.x
|
||||||
|
|| origin.y > m_size.y)
|
||||||
|
{
|
||||||
|
EWOL_WARNING("origin out of range");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if( origin.x + size.x > m_size.x
|
||||||
|
|| origin.y + size.y > m_size.y)
|
||||||
|
{
|
||||||
|
EWOL_WARNING("end area out of size");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
event_ts newEvent;
|
||||||
|
newEvent.generateEventId = generateEventId;
|
||||||
|
newEvent.widgetCall = -1; // by default no widget is called
|
||||||
|
newEvent.mode = EWOL_EVENT_AREA;
|
||||||
|
newEvent.area.origin = origin;
|
||||||
|
newEvent.area.size = size;
|
||||||
|
newEvent.area.flags = flags;
|
||||||
|
m_inputEvent.PushBack(newEvent);
|
||||||
|
EWOL_DEBUG("Add an area event...");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,25 @@ namespace ewol {
|
|||||||
EVENT_KB_MOVE_TYPE_END,
|
EVENT_KB_MOVE_TYPE_END,
|
||||||
} eventKbMoveType_te;
|
} eventKbMoveType_te;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FLAG_EVENT_INPUT_1 = 1 << 0,
|
||||||
|
FLAG_EVENT_INPUT_2 = 1 << 1,
|
||||||
|
FLAG_EVENT_INPUT_3 = 1 << 2,
|
||||||
|
FLAG_EVENT_INPUT_4 = 1 << 3,
|
||||||
|
FLAG_EVENT_INPUT_5 = 1 << 4,
|
||||||
|
FLAG_EVENT_INPUT_MOTION = 1 << 5,
|
||||||
|
FLAG_EVENT_ENTER = 1 << 6,
|
||||||
|
FLAG_EVENT_LEAVE = 1 << 7,
|
||||||
|
FLAG_EVENT_DOWN = 1 << 8,
|
||||||
|
FLAG_EVENT_UP = 1 << 9,
|
||||||
|
FLAG_EVENT_MOVE = 1 << 10,
|
||||||
|
FLAG_EVENT_CLICKED = 1 << 11,
|
||||||
|
FLAG_EVENT_CLICKED_DOUBLE = 1 << 12,
|
||||||
|
FLAG_EVENT_CLICKED_TRIPLE = 1 << 13,
|
||||||
|
};
|
||||||
|
|
||||||
#define UTF8_MAX_SIZE (8)
|
#define UTF8_MAX_SIZE (8)
|
||||||
#define EWOL_EVENT_UNION (0)
|
#define EWOL_EVENT_AREA (0)
|
||||||
#define EWOL_EVENT_SHORTCUT (1)
|
#define EWOL_EVENT_SHORTCUT (1)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -81,7 +98,7 @@ namespace ewol {
|
|||||||
struct {
|
struct {
|
||||||
coord origin; // widget specific
|
coord origin; // widget specific
|
||||||
coord size; // widget specific
|
coord size; // widget specific
|
||||||
uint32_t flags; // widget specific
|
uint64_t flags; // widget specific
|
||||||
} area;
|
} area;
|
||||||
};
|
};
|
||||||
} event_ts;
|
} event_ts;
|
||||||
@ -174,7 +191,7 @@ namespace ewol {
|
|||||||
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y); // call when input event arrive and call OnEventInput, if no event detected
|
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y); // call when input event arrive and call OnEventInput, if no event detected
|
||||||
bool GenEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE]);
|
bool GenEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE]);
|
||||||
protected:
|
protected:
|
||||||
bool AddEventArea(coord origin, coord size, uint32_t flags, const char * generateEventId);
|
bool AddEventArea(coord origin, coord size, uint64_t flags, const char * generateEventId);
|
||||||
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE], const char * generateEventId);
|
bool AddEventShortCut(bool shift, bool control, bool alt, bool pomme, char UTF8_data[UTF8_MAX_SIZE], const char * generateEventId);
|
||||||
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
|
bool AddEventShortCut(char * descriptiveString, const char * generateEventId);
|
||||||
public:
|
public:
|
||||||
@ -182,9 +199,9 @@ namespace ewol {
|
|||||||
bool ExternLinkOnEvent(const char * eventName, int32_t widgetId);
|
bool ExternLinkOnEvent(const char * eventName, int32_t widgetId);
|
||||||
protected:
|
protected:
|
||||||
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y) { return false; };
|
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, double X, double Y) { return false; };
|
||||||
virtual bool OnEventArea(const char * generateEventId) { return false; };
|
virtual bool OnEventArea(const char * generateEventId, double x, double y) { return false; };
|
||||||
// when an event arrive from an other widget, it will arrive here:
|
// when an event arrive from an other widget, it will arrive here:
|
||||||
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId) { return false; };
|
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, double x, double y) { return false; };
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------------------------------
|
||||||
// -- Keboard event (when one is present or when a graphical is present
|
// -- Keboard event (when one is present or when a graphical is present
|
||||||
|
@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
|
||||||
|
//list of local events :
|
||||||
|
const char * eventClose = "Close Windows";
|
||||||
|
|
||||||
bool ewol::Windows::CalculateSize(double availlableX, double availlableY)
|
bool ewol::Windows::CalculateSize(double availlableX, double availlableY)
|
||||||
{
|
{
|
||||||
m_size.x = availlableX;
|
m_size.x = availlableX;
|
||||||
@ -107,14 +110,28 @@ void ewol::Windows::SysDraw(void)
|
|||||||
ewol::OObject2DColored myOObject;
|
ewol::OObject2DColored myOObject;
|
||||||
|
|
||||||
myOObject.Rectangle(20, 30, 100, 50, 1.0, 0.0, 0.0, 1.0);
|
myOObject.Rectangle(20, 30, 100, 50, 1.0, 0.0, 0.0, 1.0);
|
||||||
|
static bool isinit = false;
|
||||||
|
if (false == isinit) {
|
||||||
|
isinit=true;
|
||||||
|
AddEventArea({20.0,30.0}, {100, 50}, FLAG_EVENT_INPUT_1 | FLAG_EVENT_CLICKED, eventClose);
|
||||||
|
}
|
||||||
myOObject.Rectangle(50, 50, 50, 50, 0.0, 1.0, 0.0, 1.0);
|
myOObject.Rectangle(50, 50, 50, 50, 0.0, 1.0, 0.0, 1.0);
|
||||||
myOObject.Rectangle(80, 80, 100, 50, 0.0, 0.0, 1.0, 1.0);
|
myOObject.Rectangle(80, 80, 100, 50, 0.0, 0.0, 1.0, 1.0);
|
||||||
myOObject.Rectangle(50, 00, 300, 300, 0.2, 0.2, 0.2, 0.5);
|
myOObject.Rectangle(50, 00, 300, 300, 0.2, 0.2, 0.2, 0.5);
|
||||||
|
|
||||||
|
|
||||||
myOObject.Rectangle(-50, -50, 120, 120, 0.0, 1.0, 1.0, 0.5);
|
//myOObject.Rectangle(-50, -50, 120, 120, 0.0, 1.0, 1.0, 0.5);
|
||||||
|
|
||||||
myOObject.Draw();
|
myOObject.Draw();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ewol::Windows::OnEventArea(const char * generateEventId, double x, double y)
|
||||||
|
{
|
||||||
|
if(eventClose == generateEventId) {
|
||||||
|
EWOL_DEBUG("Request close of the windows");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ namespace ewol {
|
|||||||
virtual void On(void) { };
|
virtual void On(void) { };
|
||||||
// from Widget management :
|
// from Widget management :
|
||||||
virtual bool CalculateSize(double availlableX, double availlableY);
|
virtual bool CalculateSize(double availlableX, double availlableY);
|
||||||
|
virtual bool OnEventArea(const char * generateEventId, double x, double y);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user