manage the tablette scrolling

This commit is contained in:
Edouard Dupin 2012-02-11 11:18:53 +01:00
parent 64a5571451
commit df8c5b3f34
3 changed files with 125 additions and 66 deletions

View File

@ -11,6 +11,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -ldl -llog -lz
LOCAL_CFLAGS := -D__PLATFORM__Android \
-D__MODE__Touch \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=3 \

View File

@ -44,85 +44,139 @@ ewol::WidgetScrooled::~WidgetScrooled(void)
void ewol::WidgetScrooled::OnRegenerateDisplay(void)
{
if( ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode
|| ewol::SCROLL_ENABLE_VERTICAL ==m_highSpeedMode) {
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.4);
myOObjectsColored->Disc(m_highSpeedStartPos.x, m_highSpeedStartPos.y, 10);
AddOObject(myOObjectsColored, "scolling object");
}
#ifdef __MODE__Touch
/*
if(ewol::SCROLL_ENABLE==m_highSpeedMode) {
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.4);
myOObjectsColored->Disc(m_highSpeedStartPos.x, m_highSpeedStartPos.y, 10);
AddOObject(myOObjectsColored, "scolling object");
}
*/
#else
if( ewol::SCROLL_ENABLE_HORIZONTAL==m_highSpeedMode
|| ewol::SCROLL_ENABLE_VERTICAL ==m_highSpeedMode) {
ewol::OObject2DColored* myOObjectsColored = new ewol::OObject2DColored();
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.4);
myOObjectsColored->Disc(m_highSpeedStartPos.x, m_highSpeedStartPos.y, 10);
AddOObject(myOObjectsColored, "scolling object");
}
#endif
}
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, etkFloat_t x, etkFloat_t y)
{
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_UP");
m_originScrooled.y -= m_pixelScrolling;
if (m_originScrooled.y < 0) {
m_originScrooled.y = 0;
}
MarkToReedraw();
return true;
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_DOWN");
m_originScrooled.y += m_pixelScrolling;
if (m_maxSize.y < m_originScrooled.y) {
m_originScrooled.y = m_maxSize.y;
}
MarkToReedraw();
return true;
}else if (2 == IdInput) {
x -= m_origin.x;
y -= m_origin.y;
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
#ifdef __MODE__Touch
if (1 == IdInput) {
x -= m_origin.x;
y -= m_origin.y;
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
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 ) {
// the scrooling can start :
// select the direction :
m_highSpeedMode = ewol::SCROLL_ENABLE;
MarkToReedraw();
}
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 = 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;
MarkToReedraw();
return true;
}
} else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
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 ) {
// the scrooling can start :
// select the direction :
if (x == m_highSpeedStartPos.x) {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
} else if (y == m_highSpeedStartPos.y) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
etkFloat_t coef = (y - m_highSpeedStartPos.y) / (x - m_highSpeedStartPos.x);
if (abs(coef) <= 1 ) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
}
}
if (m_highSpeedMode == ewol::SCROLL_ENABLE_HORIZONTAL) {
m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * m_size.x;
} else {
m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * m_size.y;
}
MarkToReedraw();
}
#else
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_UP");
m_originScrooled.y -= m_pixelScrolling;
if (m_originScrooled.y < 0) {
m_originScrooled.y = 0;
}
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);
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);
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
EWOL_INFO("mouse-event GDK_SCROLL_DOWN");
m_originScrooled.y += m_pixelScrolling;
if (m_maxSize.y < m_originScrooled.y) {
m_originScrooled.y = m_maxSize.y;
}
MarkToReedraw();
return true;
}else if (2 == IdInput) {
x -= m_origin.x;
y -= m_origin.y;
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {
m_highSpeedMode = ewol::SCROLL_INIT;
m_highSpeedStartPos.x = x;
m_highSpeedStartPos.y = y;
return true;
} else if (ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
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 ) {
// the scrooling can start :
// select the direction :
if (x == m_highSpeedStartPos.x) {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
} else if (y == m_highSpeedStartPos.y) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
etkFloat_t coef = (y - m_highSpeedStartPos.y) / (x - m_highSpeedStartPos.x);
if (abs(coef) <= 1 ) {
m_highSpeedMode = ewol::SCROLL_ENABLE_HORIZONTAL;
} else {
m_highSpeedMode = ewol::SCROLL_ENABLE_VERTICAL;
}
}
if (m_highSpeedMode == ewol::SCROLL_ENABLE_HORIZONTAL) {
m_highSpeedStartPos.x = m_originScrooled.x / m_maxSize.x * m_size.x;
} else {
m_highSpeedStartPos.y = m_originScrooled.y / m_maxSize.y * m_size.y;
}
MarkToReedraw();
}
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);
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);
MarkToReedraw();
return true;
}
} else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
return true;
}
} else if (ewol::SCROLL_DISABLE!=m_highSpeedMode && ewol::EVENT_INPUT_TYPE_LEAVE == typeEvent) {
m_highSpeedMode = ewol::SCROLL_DISABLE;
MarkToReedraw();
return true;
}
#endif
return false;
}

View File

@ -33,8 +33,12 @@ namespace ewol {
typedef enum {
SCROLL_DISABLE,
SCROLL_INIT,
#ifdef __MODE__Touch
SCROLL_ENABLE,
#else
SCROLL_ENABLE_HORIZONTAL,
SCROLL_ENABLE_VERTICAL,
#endif
}highSpeedMode_te;
class WidgetScrooled :public ewol::Widget