Change the policy to get widget at position and add stop/resume in the scene
This commit is contained in:
parent
afae43697d
commit
185e85293d
@ -196,8 +196,8 @@ static void* BaseAppEntry(void* param)
|
||||
if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) {
|
||||
if (countNbEvent > 0) {
|
||||
if(true == ewol::threadMsg::HasDisplayDone(androidJniMsg)) {
|
||||
|
||||
ewol::widgetManager::PeriodicCall(0);
|
||||
int64_t localTime = GetCurrentTime();
|
||||
ewol::widgetManager::PeriodicCall(localTime);
|
||||
}
|
||||
EWOL_NativeRegenerateDisplay();
|
||||
countNbEvent = 0;
|
||||
|
@ -158,7 +158,8 @@ void guiAbstraction::KeyboardHide(void)
|
||||
static int64_t startTime = -1;
|
||||
static int64_t nbCallTime = 0;
|
||||
static int64_t nbDisplayTime = 0;
|
||||
#define DISPLAY_PERIODE_MS (1000)
|
||||
// display every second ...
|
||||
#define DISPLAY_PERIODE_US (1000000)
|
||||
|
||||
|
||||
void EWOL_GenericDraw(bool everyTime)
|
||||
@ -170,9 +171,10 @@ void EWOL_GenericDraw(bool everyTime)
|
||||
}
|
||||
int64_t currentTime = GetCurrentTime();
|
||||
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
|
||||
if ( (currentTime - startTime) > DISPLAY_PERIODE_MS) {
|
||||
if ( (currentTime - startTime) > DISPLAY_PERIODE_US) {
|
||||
display = true;
|
||||
}
|
||||
// TODO : Remove this ...
|
||||
if (ewol::widgetManager::PeriodicCallHave()) {
|
||||
everyTime = true;
|
||||
}
|
||||
@ -183,14 +185,13 @@ void EWOL_GenericDraw(bool everyTime)
|
||||
ewol::texture::UpdateContext();
|
||||
nbDisplayTime++;
|
||||
gui_uniqueWindows->SysDraw();
|
||||
//EWOL_WARNING("DRAW...");
|
||||
}
|
||||
ewol::widgetManager::DoubleBufferUnLock();
|
||||
// send Message that we just finished a display ...
|
||||
EWOL_ThreadEventHasJustDisplay();
|
||||
|
||||
if (true == display) {
|
||||
EWOL_DEBUG("display property : " << (int32_t)((double)nbDisplayTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "/" << (int32_t)((double)nbCallTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "fps");
|
||||
EWOL_DEBUG("display property : " << nbDisplayTime << "/" << nbCallTime << "fps");
|
||||
nbCallTime = 0;
|
||||
nbDisplayTime = 0;
|
||||
startTime = -1;
|
||||
|
@ -41,9 +41,9 @@
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "AndroidJNI"
|
||||
int32_t separateClickTime = 800;
|
||||
int32_t offsetMoveClicked = 40;
|
||||
int32_t offsetMoveClickedDouble = 300;
|
||||
int32_t separateClickTime = 800000;
|
||||
int32_t offsetMoveClicked = 40000;
|
||||
int32_t offsetMoveClickedDouble = 300000;
|
||||
|
||||
extern etkFloat_t gui_width;
|
||||
extern etkFloat_t gui_height;
|
||||
@ -54,7 +54,7 @@ int64_t GetCurrentTime(void)
|
||||
struct timeval now;
|
||||
gettimeofday(&now, NULL);
|
||||
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000 + (int64_t)now.tv_usec/(int64_t)1000);
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec);
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,7 +55,7 @@ int64_t GetCurrentTime(void)
|
||||
now.tv_nsec = 0;
|
||||
}
|
||||
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000 + (int64_t)now.tv_nsec/(int64_t)1000000);
|
||||
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_nsec/(int64_t)1000);
|
||||
}
|
||||
|
||||
#undef __class__
|
||||
@ -119,9 +119,9 @@ extern ewol::Windows* gui_uniqueWindows;
|
||||
extern etkFloat_t gui_width;
|
||||
extern etkFloat_t gui_height;
|
||||
|
||||
int32_t separateClickTime = 300;
|
||||
int32_t offsetMoveClicked = 10;
|
||||
int32_t offsetMoveClickedDouble = 20;
|
||||
int32_t separateClickTime = 300000;
|
||||
int32_t offsetMoveClicked = 10000;
|
||||
int32_t offsetMoveClickedDouble = 20000;
|
||||
|
||||
|
||||
bool inputIsPressed[20];
|
||||
|
@ -245,7 +245,10 @@ ewol::Widget * ewol::Layer::GetWidgetAtPos(coord2D_ts pos)
|
||||
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);
|
||||
ewol::Widget * tmpWidget = m_subWidget[m_currentCreateId][iii]->GetWidgetAtPos(pos);
|
||||
if (NULL != tmpWidget) {
|
||||
return tmpWidget;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,8 +44,11 @@ void ewol::WIDGET_SceneInit(void)
|
||||
|
||||
ewol::Scene::Scene(void)
|
||||
{
|
||||
m_isRunning = true;
|
||||
SetCanHaveFocus(true);
|
||||
PeriodicCallSet(true);
|
||||
m_lastCallTime = -1;
|
||||
m_sceneElement.id = 1;
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +163,7 @@ int32_t ewol::SceneElement::AddElement(ewol::GameElement* newElement)
|
||||
return listAnimatedElements.Size()-1;
|
||||
}
|
||||
|
||||
|
||||
#define CYCLIC_CALL_PERIODE_US (10000)
|
||||
/**
|
||||
* @brief Periodic call of this widget
|
||||
* @param localTime curent system time
|
||||
@ -168,14 +171,32 @@ int32_t ewol::SceneElement::AddElement(ewol::GameElement* newElement)
|
||||
*/
|
||||
void ewol::Scene::PeriodicCall(int64_t localTime)
|
||||
{
|
||||
|
||||
//EWOL_ERROR("Periodic Call ... " << localTime);
|
||||
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements.Size(); iii++) {
|
||||
if (NULL != m_sceneElement.listAnimatedElements[iii]) {
|
||||
// check if the element request an auto Kill ...
|
||||
if (true == m_sceneElement.listAnimatedElements[iii]->Process(localTime, 20000, m_sceneElement) ) {
|
||||
delete(m_sceneElement.listAnimatedElements[iii]);
|
||||
m_sceneElement.listAnimatedElements[iii] = NULL;
|
||||
// First time :
|
||||
if (-1 == m_lastCallTime) {
|
||||
m_lastCallTime = localTime;
|
||||
}
|
||||
// check if the processing is availlable
|
||||
if (false == m_isRunning) {
|
||||
m_lastCallTime = localTime;
|
||||
MarkToReedraw();
|
||||
return;
|
||||
}
|
||||
// cut the processing in small slot of time to prevent error in the real-time Display (Android call us between 30 to 60 fps)
|
||||
int32_t deltaTime = (int32_t) (localTime - m_lastCallTime);
|
||||
//EWOL_DEBUG(" currentTime = " << localTime << " last=" << m_lastCallTime << " delta=" << deltaTime);
|
||||
while (deltaTime >= CYCLIC_CALL_PERIODE_US) {
|
||||
//EWOL_DEBUG(" process = " << CYCLIC_CALL_PERIODE_US);
|
||||
m_lastCallTime += CYCLIC_CALL_PERIODE_US;
|
||||
deltaTime -= CYCLIC_CALL_PERIODE_US;
|
||||
ScenePeriodicCall(m_lastCallTime, CYCLIC_CALL_PERIODE_US);
|
||||
//EWOL_ERROR("Periodic Call ... " << localTime);
|
||||
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements.Size(); iii++) {
|
||||
if (NULL != m_sceneElement.listAnimatedElements[iii]) {
|
||||
// check if the element request an auto Kill ...
|
||||
if (true == m_sceneElement.listAnimatedElements[iii]->Process(m_lastCallTime, CYCLIC_CALL_PERIODE_US, m_sceneElement) ) {
|
||||
delete(m_sceneElement.listAnimatedElements[iii]);
|
||||
m_sceneElement.listAnimatedElements[iii] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,10 @@ namespace ewol {
|
||||
class SceneElement {
|
||||
public:
|
||||
etk::VectorType<ewol::OObject*> backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::GameElement*> listAnimatedElements; //!< generic element to display...
|
||||
etk::VectorType<ewol::Sprite*> animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::GameElement*> listAnimatedElements; //!< generic element to display...
|
||||
int32_t id; //!< Unique element ID
|
||||
int32_t AddElement(ewol::GameElement* newElement);
|
||||
};
|
||||
|
||||
@ -48,6 +49,8 @@ namespace ewol {
|
||||
// TODO : Set it in private ...
|
||||
protected:
|
||||
SceneElement m_sceneElement; //!< all element neede in the scene
|
||||
bool m_isRunning;
|
||||
int64_t m_lastCallTime;
|
||||
public:
|
||||
Scene(void);
|
||||
virtual ~Scene(void);
|
||||
@ -80,6 +83,32 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnDraw(void);
|
||||
/**
|
||||
* @brief Set the scene in pause for a while
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void Pause(void) { m_isRunning = false; };
|
||||
/**
|
||||
* @brief Resume the scene activity
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void Resume(void) { m_isRunning = true; };
|
||||
/**
|
||||
* @brief Toggle between pause and running
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void PauseToggle(void) { if(true==m_isRunning){ m_isRunning=false;}else{m_isRunning=true;} };
|
||||
protected:
|
||||
/**
|
||||
* @brief Periodic call in the sub element timed
|
||||
* @param localTime curent system time
|
||||
* @param deltaTime delta time while the previous call
|
||||
* @return ---
|
||||
*/
|
||||
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -288,12 +288,18 @@ ewol::Widget * ewol::SizerHori::GetWidgetAtPos(coord2D_ts pos)
|
||||
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);
|
||||
ewol::Widget * tmpWidget = m_subWidget[m_currentCreateId][iii]->GetWidgetAtPos(pos);
|
||||
if (NULL != tmpWidget) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// stop searching
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise the event go to this widget ...
|
||||
return this;
|
||||
// TODO : Check if we have a mover, otherwire return NULL;
|
||||
return NULL;
|
||||
//return this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,12 +288,18 @@ ewol::Widget * ewol::SizerVert::GetWidgetAtPos(coord2D_ts pos)
|
||||
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);
|
||||
ewol::Widget * tmpWidget = m_subWidget[m_currentCreateId][iii]->GetWidgetAtPos(pos);
|
||||
if (NULL != tmpWidget) {
|
||||
return tmpWidget;
|
||||
}
|
||||
// stop searching
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// otherwise the event go to this widget ...
|
||||
return this;
|
||||
// TODO : Check if we have a mover, otherwire return NULL;
|
||||
return NULL;
|
||||
//return this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -52,6 +52,14 @@ namespace ewol {
|
||||
virtual const char * const GetObjectType(void);
|
||||
virtual bool CalculateMinSize(void);
|
||||
void SetSize(etkFloat_t size);
|
||||
/**
|
||||
* @brief Get the widget at the specific windows absolute position
|
||||
* @note the sizer return NULL, because nothing can be done inside nothing
|
||||
* @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) { return NULL; };
|
||||
private:
|
||||
etkFloat_t m_size;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user