change the clipping with the viewport of openGL

This commit is contained in:
Edouard Dupin 2012-02-23 13:44:22 +01:00
parent 11d9925409
commit 551684fe8e
28 changed files with 146 additions and 140 deletions

View File

@ -133,9 +133,14 @@ bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
}
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::Widget::GenEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos)
{
return OnEventInput(IdInput, typeEvent, x-m_origin.x, y-m_origin.y);
eventPosition_ts eventPos;
eventPos.abs = pos;
eventPos.local.x = pos.x - m_origin.x;
eventPos.local.y = pos.y - m_origin.y;
//EWOL_DEBUG(" event on abs=(" << eventPos.abs.x << "," << eventPos.abs.y << ") local=(" << eventPos.local.x << "," << eventPos.local.y << ")");
return OnEventInput(IdInput, typeEvent, eventPos);
}
bool ewol::Widget::GenEventInputExternal(const char * generateEventId, etkFloat_t x, etkFloat_t y)
@ -241,44 +246,26 @@ void ewol::Widget::SetCanHaveFocus(bool canFocusState)
//#define TEST_CLIPPING_SIZE (3)
#define TEST_CLIPPING_SIZE (0)
#ifdef __PLATFORM__Android
# define clipping_type GLfloat
# define clipping_function glClipPlanef
#else
# define clipping_type GLdouble
# define clipping_function glClipPlane
#endif
bool ewol::Widget::GenDraw(void)
{
glPushMatrix();
#if 1
glTranslatef(m_origin.x,m_origin.y, 0);
//GLfloat
clipping_type eqn1[4] = { 0.0, 1.0, 0.0, -TEST_CLIPPING_SIZE}; // less the Y pos ...
clipping_type eqn2[4] = { 0.0, -1.0, 0.0, m_size.y-TEST_CLIPPING_SIZE}; // upper the y pos ...
clipping_type eqn3[4] = { 1.0, 0.0, 0.0, -TEST_CLIPPING_SIZE}; // less the x pos ...
clipping_type eqn4[4] = {-1.0, 0.0, 0.0, m_size.x-TEST_CLIPPING_SIZE}; // upper the x pos ...
//EWOL_DEBUG("widget size (" << m_size.x << "," << m_size.y << ")" );
glEnable(GL_CLIP_PLANE0);
glEnable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
glEnable(GL_CLIP_PLANE3);
clipping_function(GL_CLIP_PLANE0, eqn1);
clipping_function(GL_CLIP_PLANE1, eqn2);
clipping_function(GL_CLIP_PLANE2, eqn3);
clipping_function(GL_CLIP_PLANE3, eqn4);
#else
glTranslatef(m_origin.x,m_origin.y, 0);
glEnable(GL_SCISSOR_TEST);
glScissor(TEST_CLIPPING_SIZE, TEST_CLIPPING_SIZE, m_size.x-TEST_CLIPPING_SIZE, m_size.y-TEST_CLIPPING_SIZE);
#endif
etkFloat_t testSizeX = m_size.x-TEST_CLIPPING_SIZE*2;
etkFloat_t testSizeY = m_size.y-TEST_CLIPPING_SIZE*2;
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x + TEST_CLIPPING_SIZE,
600 - m_size.y - m_origin.y + TEST_CLIPPING_SIZE,
testSizeX,
testSizeY);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-testSizeX/2, testSizeX/2, testSizeY/2, -testSizeY/2, -1, 1);
//glOrthoEwol(0., m_size.x, 0., -m_size.y, 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-testSizeX/2, -testSizeY/2, -1.0);
bool valRet = OnDraw();
/*
glDisable(GL_CLIP_PLANE3);
glDisable(GL_CLIP_PLANE2);
glDisable(GL_CLIP_PLANE1);
glDisable(GL_CLIP_PLANE0);
*/
glPopMatrix();
return valRet;
}

View File

@ -93,13 +93,19 @@ namespace ewol {
char* GetCharTypeMoveEvent(eventKbMoveType_te type);
extern "C" {
typedef struct {
const char * generateEventId; //!< event generate ID (to be unique it was pointer on the string name)
int32_t widgetCall; //!< unique ID of the widget
const char * generateEventIdExtern; //!< External generated event ID (to be unique it was pointer on the string name)
} eventExtern_ts;
};
typedef struct {
const char * generateEventId; //!< event generate ID (to be unique it was pointer on the string name)
int32_t widgetCall; //!< unique ID of the widget
const char * generateEventIdExtern; //!< External generated event ID (to be unique it was pointer on the string name)
} eventExtern_ts;
typedef struct {
coord2D_ts abs;
coord2D_ts local;
} eventPosition_ts;
class Widget {
public:
@ -173,7 +179,7 @@ namespace ewol {
etk::VectorType<const char*> m_ListEventAvaillable; //!< List of all event availlable for this widget
public:
// external acces to set an input event on this widget.
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t X, etkFloat_t Y); // call when input event arrive and call OnEventInput, if no event detected
bool GenEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos); // call when input event arrive and call OnEventInput, if no event detected
bool GenEventInputExternal(const char * generateEventId, etkFloat_t x, etkFloat_t y);
virtual bool GenEventShortCut(bool shift, bool control, bool alt, bool meta, uint32_t unicodeValue);
protected:
@ -186,7 +192,7 @@ namespace ewol {
// to link an extern widget at the internal event of this one it will access by here :
bool ExternLinkOnEvent(const char * eventName, int32_t widgetId, const char * eventExternId = NULL);
protected:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t X, etkFloat_t Y) { return false; };
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos) { return false; };
public:
// when an event arrive from an other widget, it will arrive here:
// TODO : change name ...

View File

@ -104,12 +104,12 @@ bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY
}
bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
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 (y > m_size.y - tmpSize.y) {
m_keyBoardwidget->GenEventInput(IdInput, typeEvent, x, y);
if (pos.local.y > m_size.y - tmpSize.y) {
m_keyBoardwidget->GenEventInput(IdInput, typeEvent, pos.abs);
return true;
}
}
@ -118,11 +118,11 @@ bool ewol::Windows::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, e
if (NULL == m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]) {
m_popUpWidgetList[m_currentCreateId].PopBack();
} else {
m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]->GenEventInput(IdInput, typeEvent, x, y);
m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]->GenEventInput(IdInput, typeEvent, pos.abs);
}
// otherwise in the normal windows
} else if (NULL != m_subWidget[m_currentCreateId]) {
m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, x, y);
m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, pos.abs);
}
return true;
}
@ -133,20 +133,15 @@ void ewol::Windows::SysDraw(void)
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
// set the size of the open GL system
glViewport(0,0,m_size.x,m_size.y);
// Clear the screen with transparency ...
glClearColor(0.750, 0.750, 0.750, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/*
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//#if defined(__PLATFORM__Android)
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
/*
#else
glOrtho(0., m_size.x, 0., -m_size.y, 1., 20.);
@ -155,19 +150,8 @@ void ewol::Windows::SysDraw(void)
glTranslatef(0, -m_size.y, -5);
#endif
*/
//http://www.khronos.org/opengles/documentation/opengles1_0/html/glBlendFunc.html
//glEnable(GL_POLYGON_SMOOTH);
//glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glShadeModel(GL_POLYGON_SMOOTH);
//glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
GenDraw();
@ -193,6 +177,11 @@ void ewol::Windows::OnRegenerateDisplay(void)
bool ewol::Windows::OnDraw(void)
{
// Clear the screen with transparency ...
glClearColor(0.750, 0.750, 0.750, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId);
// first display the windows on the display
if (NULL != m_subWidget[m_currentDrawId]) {

View File

@ -52,7 +52,7 @@ namespace ewol {
virtual void On(void) { };
public:
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual bool OnEventAreaExternal(int32_t widgetID, const char * generateEventId, const char * eventExternId, etkFloat_t x, etkFloat_t y);
private:
bool m_hasDecoration;

View File

@ -152,7 +152,11 @@ void EWOL_NativeEventInputMotion(int pointerID, float x, float 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 << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_MOVE, (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);
}
}
}
@ -166,7 +170,11 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
// Send Down message
if (NULL != gui_uniqueWindows) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOWN] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_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;
@ -196,7 +204,11 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
// Send Down message
if (NULL != gui_uniqueWindows) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [UP] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_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;
@ -216,7 +228,11 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
{
// might generate an sigle event :
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [SINGLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_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;
@ -239,12 +255,20 @@ void EWOL_NativeEventInputState(int pointerID, bool isUp, float x, float y )
// might generate an sigle event :
if (false == m_previousDouble) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << " [DOUBLE] (" << (etkFloat_t)x << "," << (etkFloat_t)y << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_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 << ")");
gui_uniqueWindows->GenEventInput(pointerID, ewol::EVENT_INPUT_TYPE_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;

View File

@ -184,7 +184,7 @@ void ewol::Button::OnRegenerateDisplay(void)
}
bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
//EWOL_DEBUG("Event on BT ...");
if (1 == IdInput) {
@ -192,7 +192,7 @@ bool ewol::Button::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, et
|| ewol::EVENT_INPUT_TYPE_DOUBLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent) {
// nothing to do ...
GenEventInputExternal(ewolEventButtonPressed, x, y);
GenEventInputExternal(ewolEventButtonPressed, pos.abs.x, pos.abs.y);
MarkToReedraw();
return true;
}

View File

@ -61,7 +61,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual bool OnEventKb(ewol::eventKbType_te typeEvent, uniChar_t unicodeData);
};
};

View File

@ -148,7 +148,7 @@ void ewol::CheckBox::OnRegenerateDisplay(void)
}
bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
//EWOL_DEBUG("Event on checkbox ...");
if (1 == IdInput) {
@ -158,7 +158,7 @@ bool ewol::CheckBox::OnEventInput(int32_t IdInput, eventInputType_te typeEvent,
} else {
m_value = true;
}
GenEventInputExternal(ewolEventCheckBoxClicked, x, y);
GenEventInputExternal(ewolEventCheckBoxClicked, pos.abs.x, pos.abs.y);
ewol::widgetManager::FocusKeep(this);
MarkToReedraw();
return true;

View File

@ -51,7 +51,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData);
};
};

View File

@ -243,15 +243,15 @@ void ewol::ContextMenu::OnRegenerateDisplay(void)
}
bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::ContextMenu::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
if (NULL != m_subWidget) {
coord2D_ts tmpSize = m_subWidget->GetSize();
coord2D_ts tmpOrigin = m_subWidget->GetOrigin();
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
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) )
{
return m_subWidget->GenEventInput(IdInput, typeEvent, x, y);
return m_subWidget->GenEventInput(IdInput, typeEvent, pos.abs);
} else {
//EWOL_INFO("Event ouside the context menu");
if (IdInput > 0) {

View File

@ -66,7 +66,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
};
};

View File

@ -49,10 +49,10 @@ void ewol::Drawable::AddOObject(ewol::OObject* newObject, int32_t pos)
EWOL_ERROR("Try to add an empty object in the Widget generic display system");
return;
}
// TODO : Chow why I use this ...
//EWOL_INFO("UPDATE AT size : (" << m_size.x << "," << m_size.y << ")");
newObject->UpdateSize(m_size.x, m_size.y);
//EWOL_INFO("UPDATE AT origin : (" << m_origin.x << "," << m_origin.y << ")");
//newObject->UpdateOrigin(m_origin.x, m_origin.y);
if (pos < 0 || pos >= m_listOObject[m_currentCreateId].Size() ) {
m_listOObject[m_currentCreateId].PushBack(newObject);
} else {

View File

@ -171,13 +171,13 @@ void ewol::Entry::OnRegenerateDisplay(void)
}
bool ewol::Entry::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::Entry::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
//EWOL_DEBUG("Event on Entry ...");
if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// nothing to do ...
GenEventInputExternal(ewolEventEntryClick, x, y);
GenEventInputExternal(ewolEventEntryClick, pos.abs.x, pos.abs.y);
ewol::widgetManager::FocusKeep(this);
MarkToReedraw();
return true;

View File

@ -62,7 +62,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData);
protected:
virtual void OnGetFocus(void);

View File

@ -119,13 +119,13 @@ void ewol::Label::OnRegenerateDisplay(void)
}
bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::Label::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
//EWOL_DEBUG("Event on Label ...");
if (1 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_SINGLE == typeEvent) {
// nothing to do ...
GenEventInputExternal(ewolEventLabelPressed, x, y);
GenEventInputExternal(ewolEventLabelPressed, pos.abs.x, pos.abs.y);
return true;
}
}

View File

@ -47,7 +47,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
};
};

View File

@ -154,9 +154,9 @@ void ewol::List::OnRegenerateDisplay(void)
}
bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, x, y)) {
if (true == WidgetScrooled::OnEventInput(IdInput, typeEvent, pos)) {
ewol::widgetManager::FocusKeep(this);
// nothing to do ... done on upper widet ...
return true;
@ -165,9 +165,9 @@ bool ewol::List::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkF
//int32_t minWidth = ewol::GetWidth(fontId, m_label.c_str());
int32_t minHeight = ewol::GetHeight(fontId);
int32_t rawID = (y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
int32_t rawID = (pos.local.y+m_originScrooled.y) / (minHeight + 2*m_paddingSizeY);
//EWOL_DEBUG("OnEventInput(" << IdInput << "," << typeEvent << "," << 0 << "," << rawID << "," << x <<"," << y << ");");
bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, x, y);
bool isUsed = OnItemEvent(IdInput, typeEvent, 0, rawID, pos.local.x, pos.local.y);
if (true == isUsed) {
// TODO : this generate bugs ... I did not understand why ..
//ewol::widgetManager::FocusKeep(this);

View File

@ -46,7 +46,7 @@ namespace ewol {
int32_t m_displayCurrentNbLine; //!< Number of line in the display
public:
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
protected:
// function call to display the list :
virtual color_ts GetBasicBG(void) {

View File

@ -175,15 +175,15 @@ void ewol::PopUp::OnRegenerateDisplay(void)
}
bool ewol::PopUp::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
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();
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
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) )
{
return m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, x, y);
return m_subWidget[m_currentCreateId]->GenEventInput(IdInput, typeEvent, pos.abs);
} else {
//EWOL_INFO("Event ouside the Pop-up");
}

View File

@ -56,7 +56,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
};
};

View File

@ -71,8 +71,8 @@ bool ewol::SizerHori::CalculateSize(etkFloat_t availlableX, etkFloat_t availlabl
}
}
coord2D_ts tmpOrigin;
tmpOrigin.x = 0;
tmpOrigin.y = 0;
tmpOrigin.x = m_origin.x;
tmpOrigin.y = m_origin.y;
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]->GetMinSize();
@ -235,16 +235,16 @@ void ewol::SizerHori::OnRegenerateDisplay(void)
}
bool ewol::SizerHori::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
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();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId][iii]->GetOrigin();
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
if( (tmpOrigin.x <= pos.abs.x && tmpOrigin.x + tmpSize.x >= pos.abs.x)
&& (tmpOrigin.y <= pos.abs.y && tmpOrigin.y + tmpSize.y >= pos.abs.y) )
{
return m_subWidget[m_currentCreateId][iii]->GenEventInput(IdInput, typeEvent, x, y);
return m_subWidget[m_currentCreateId][iii]->GenEventInput(IdInput, typeEvent, pos.abs);
}
}
}

View File

@ -56,7 +56,7 @@ namespace ewol {
virtual bool OnDraw(void);
public:
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
};
};

View File

@ -73,8 +73,8 @@ bool ewol::SizerVert::CalculateSize(etkFloat_t availlableX, etkFloat_t availlabl
}
}
coord2D_ts tmpOrigin;
tmpOrigin.x = 0;
tmpOrigin.y = 0;
tmpOrigin.x = m_origin.x;
tmpOrigin.y = m_origin.y;
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]->GetMinSize();
@ -235,16 +235,16 @@ void ewol::SizerVert::OnRegenerateDisplay(void)
}
bool ewol::SizerVert::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
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();
coord2D_ts tmpOrigin = m_subWidget[m_currentCreateId][iii]->GetOrigin();
if( (tmpOrigin.x <= x && tmpOrigin.x + tmpSize.x >= x)
&& (tmpOrigin.y <= y && tmpOrigin.y + tmpSize.y >= y) )
if( (tmpOrigin.x <= pos.abs.x && tmpOrigin.x + tmpSize.x >= pos.abs.x)
&& (tmpOrigin.y <= pos.abs.y && tmpOrigin.y + tmpSize.y >= pos.abs.y) )
{
return m_subWidget[m_currentCreateId][iii]->GenEventInput(IdInput, typeEvent, x, y);
return m_subWidget[m_currentCreateId][iii]->GenEventInput(IdInput, typeEvent, pos.abs);
}
}
}

View File

@ -57,7 +57,7 @@ namespace ewol {
public:
virtual void OnRegenerateDisplay(void);
public:
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
virtual void OnFlipFlopEvent(void);
};
};

View File

@ -66,15 +66,15 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void)
#endif
}
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, eventPosition_ts pos)
{
#ifdef __MODE__Touch
if (1 == IdInput) {
EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
m_highSpeedStartPos.x = pos.local.x;
m_highSpeedStartPos.y = pos.local.y;
EWOL_VERBOSE("SCROOL ==> INIT");
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
@ -84,8 +84,8 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
return true;
} else if (ewol::SCROLL_INIT==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// wait that the cursor move more than 10 px to enable it :
if( abs(x - m_highSpeedStartPos.x) > 10
|| abs(y - m_highSpeedStartPos.y) > 10 ) {
if( abs(pos.local.x - m_highSpeedStartPos.x) > 10
|| abs(pos.local.y - m_highSpeedStartPos.y) > 10 ) {
// the scrooling can start :
// select the direction :
m_highSpeedMode = ewol::SCROLL_ENABLE;
@ -95,14 +95,14 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
return true;
} if (ewol::SCROLL_ENABLE==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
//m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
m_originScrooled.x -= x - m_highSpeedStartPos.x;
m_originScrooled.y -= y - m_highSpeedStartPos.y;
m_originScrooled.x -= pos.local.x - m_highSpeedStartPos.x;
m_originScrooled.y -= pos.local.y - m_highSpeedStartPos.y;
m_originScrooled.x = etk_max(m_originScrooled.x, 0);
m_originScrooled.y = etk_max(m_originScrooled.y, 0);
m_originScrooled.x = etk_min(m_originScrooled.x, m_maxSize.x);
m_originScrooled.y = etk_min(m_originScrooled.y, m_maxSize.y);
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
m_highSpeedStartPos.x = pos.local.x;
m_highSpeedStartPos.y = pos.local.y;
EWOL_VERBOSE("SCROOL ==> MOVE (" << m_originScrooled.x << "," << m_originScrooled.y << ")");
MarkToReedraw();
return true;
@ -133,8 +133,8 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
}else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
m_highSpeedStartPos.x = pos.local.x;
m_highSpeedStartPos.y = pos.local.y;
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
@ -142,16 +142,16 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
return true;
} else if (ewol::SCROLL_INIT==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// wait that the cursor move more than 10 px to enable it :
if( abs(x - m_highSpeedStartPos.x) > 10
|| abs(y - m_highSpeedStartPos.y) > 10 ) {
if( abs(pos.local.x - m_highSpeedStartPos.x) > 10
|| abs(pos.local.y - m_highSpeedStartPos.y) > 10 ) {
// the scrooling can start :
// select the direction :
if (x == m_highSpeedStartPos.x) {
if (pos.local.x == m_highSpeedStartPos.x) {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
} else if (y == m_highSpeedStartPos.y) {
} else if (pos.local.y == m_highSpeedStartPos.y) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
etkFloat_t coef = (y - m_highSpeedStartPos.y) / (x - m_highSpeedStartPos.x);
etkFloat_t coef = (pos.local.y - m_highSpeedStartPos.y) / (pos.local.x - m_highSpeedStartPos.x);
if (abs(coef) <= 1 ) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
@ -167,11 +167,11 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
}
return true;
} if (ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
m_originScrooled.x = (int32_t)(m_maxSize.x * x / m_size.x);
m_originScrooled.x = (int32_t)(m_maxSize.x * pos.local.x / m_size.x);
MarkToReedraw();
return true;
} if (ewol::SCROLL_ENABLE_VERTICAL==m_highSpeedMode && ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
m_originScrooled.y = (int32_t)(m_maxSize.y * y / m_size.y);
m_originScrooled.y = (int32_t)(m_maxSize.y * pos.local.y / m_size.y);
MarkToReedraw();
return true;
}

View File

@ -54,7 +54,7 @@ namespace ewol {
WidgetScrooled(void);
virtual ~WidgetScrooled(void);
virtual void OnRegenerateDisplay(void);
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, eventPosition_ts pos);
protected:
void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; };
};

View File

@ -301,10 +301,10 @@ void ewol::Keyboard::OnRegenerateDisplay(void)
}
}
bool ewol::Keyboard::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
bool ewol::Keyboard::OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos)
{
if (NULL != m_subWidget) {
return m_subWidget->GenEventInput(IdInput, typeEvent, x, y);
return m_subWidget->GenEventInput(IdInput, typeEvent, pos.abs);
}
return false;
}

View File

@ -62,7 +62,7 @@ namespace ewol {
virtual void SetMinSise(etkFloat_t x=-1, etkFloat_t y=-1);
virtual void SetExpendX(bool newExpend=false);
virtual void SetExpendY(bool newExpend=false);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y);
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, eventPosition_ts pos);
};
};