Force power 2 texture, and update the scene system
This commit is contained in:
parent
59b78d1c00
commit
17974d4c98
@ -33,6 +33,8 @@
|
|||||||
*/
|
*/
|
||||||
ewol::GameElement::GameElement(void)
|
ewol::GameElement::GameElement(void)
|
||||||
{
|
{
|
||||||
|
m_group = -1;
|
||||||
|
m_type = -1;
|
||||||
m_visible = true;
|
m_visible = true;
|
||||||
m_position.x = 0.0;
|
m_position.x = 0.0;
|
||||||
m_position.y = 0.0;
|
m_position.y = 0.0;
|
||||||
@ -44,56 +46,6 @@ ewol::GameElement::GameElement(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Destructor : This does not remove the sprite requested, they will be supressed when the scene is removed ...
|
|
||||||
* @param ---
|
|
||||||
* @return ---
|
|
||||||
*/
|
|
||||||
ewol::GameElement::~GameElement(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Periodicly this fuction will be call tu change property of all the dynamic obbjects
|
|
||||||
* @param[in] time Current game time (start at 0)
|
|
||||||
* @param[in] deltaTime delta time before the previous call
|
|
||||||
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
|
||||||
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
|
||||||
* @return true if the object must be remove
|
|
||||||
* @return false if the object must be keep
|
|
||||||
*/
|
|
||||||
bool ewol::GameElement::Process(int64_t time, int32_t deltaTime, etk::VectorType<ewol::GameElement*> & listOfElement)
|
|
||||||
{
|
|
||||||
// nothing to do here ...
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
|
||||||
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
|
||||||
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
|
||||||
* @return ---
|
|
||||||
*/
|
|
||||||
void ewol::GameElement::Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects)
|
|
||||||
{
|
|
||||||
// nothing to do here ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief an element has been remove, just remove reference on it or ID on IT, it can be replace whith an other that have no link
|
|
||||||
* @param[in] idOfElement Id of the element that has been removed
|
|
||||||
* @return ---
|
|
||||||
*/
|
|
||||||
void ewol::GameElement::RemoveElement(int32_t idOfElement)
|
|
||||||
{
|
|
||||||
// nothing to do here ...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
||||||
* @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one
|
* @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one
|
||||||
@ -124,3 +76,11 @@ int32_t ewol::GameElement::LoadSprite(etk::VectorType<ewol::Sprite*> listOfEleme
|
|||||||
return listOfElement[0].Size() -1;
|
return listOfElement[0].Size() -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
etkFloat_t quadDist(coord2D_ts pos1, coord2D_ts pos2)
|
||||||
|
{
|
||||||
|
etkFloat_t tmpVal1 = pos1.x - pos2.x;
|
||||||
|
etkFloat_t tmpVal2 = pos1.y - pos2.y;
|
||||||
|
|
||||||
|
return tmpVal1*tmpVal1 + tmpVal2*tmpVal2;
|
||||||
|
}
|
@ -30,11 +30,15 @@
|
|||||||
#include <ewol/OObject/Sprite.h>
|
#include <ewol/OObject/Sprite.h>
|
||||||
#include <ewol/Widget.h>
|
#include <ewol/Widget.h>
|
||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
namespace ewol {
|
||||||
|
// declare the scene element before ...
|
||||||
|
class SceneElement;
|
||||||
|
|
||||||
class GameElement
|
class GameElement
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
int32_t m_group;
|
||||||
|
int32_t m_type;
|
||||||
bool m_visible;
|
bool m_visible;
|
||||||
coord2D_ts m_position;
|
coord2D_ts m_position;
|
||||||
coord2D_ts m_speed;
|
coord2D_ts m_speed;
|
||||||
@ -42,30 +46,78 @@ namespace ewol {
|
|||||||
etkFloat_t m_angle;
|
etkFloat_t m_angle;
|
||||||
etkFloat_t m_gravity;
|
etkFloat_t m_gravity;
|
||||||
public:
|
public:
|
||||||
GameElement(void);
|
/**
|
||||||
virtual ~GameElement(void);
|
* @brief Constructor : here are requested all the needed sprite and effect that can be used in the game
|
||||||
bool IsVisible(void) { return m_visible; };
|
* @param ---
|
||||||
void SetVisible(bool state) { m_visible = state; };
|
* @return ---
|
||||||
coord2D_ts PositionGet(void) { return m_position; };
|
*/
|
||||||
void PositionSet(coord2D_ts state) { m_position = state; };
|
GameElement(void);
|
||||||
void PositionSet(etkFloat_t xxx, etkFloat_t yyy) { m_position.x = xxx; m_position.y = yyy; };
|
/**
|
||||||
coord2D_ts SpeedGet(void) { return m_speed; };
|
* @brief Destructor : This does not remove the sprite requested, they will be supressed when the scene is removed ...
|
||||||
void SpeedSet(coord2D_ts state) { m_speed = state; };
|
* @param ---
|
||||||
void SpeedSet(etkFloat_t xxx, etkFloat_t yyy) { m_speed.x = xxx; m_speed.y = yyy; };
|
* @return ---
|
||||||
etkFloat_t SizeGet(void) { return m_size; };
|
*/
|
||||||
void SizeSet(etkFloat_t state) { m_size = state; };
|
virtual ~GameElement(void) { };
|
||||||
etkFloat_t AngleGet(void) { return m_angle; };
|
|
||||||
void AngleSet(etkFloat_t state) { m_angle = state; };
|
bool IsVisible(void) { return m_visible; };
|
||||||
etkFloat_t GravityGet(void) { return m_gravity; };
|
void SetVisible(bool state) { m_visible = state; };
|
||||||
void GravitySet(etkFloat_t state) { m_gravity = state; };
|
coord2D_ts PositionGet(void) { return m_position; };
|
||||||
virtual bool Process(int64_t time, int32_t deltaTime, etk::VectorType<ewol::GameElement*> & listOfElement);
|
void PositionSet(coord2D_ts state) { m_position = state; };
|
||||||
virtual void Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects);
|
void PositionSet(etkFloat_t xxx, etkFloat_t yyy) { m_position.x = xxx; m_position.y = yyy; };
|
||||||
virtual void RemoveElement(int32_t idOfElement);
|
coord2D_ts SpeedGet(void) { return m_speed; };
|
||||||
virtual bool HaveImpact(int32_t type, coord2D_ts position, etkFloat_t size) {return false;};
|
void SpeedSet(coord2D_ts state) { m_speed = state; };
|
||||||
virtual void Explosion(int32_t type, coord2D_ts position, etkFloat_t pxAtenuation, etkFloat_t power) { } ;
|
void SpeedSet(etkFloat_t xxx, etkFloat_t yyy) { m_speed.x = xxx; m_speed.y = yyy; };
|
||||||
int32_t LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, coord2D_ts maxSize);
|
etkFloat_t SizeGet(void) { return m_size; };
|
||||||
|
void SizeSet(etkFloat_t state) { m_size = state; };
|
||||||
|
etkFloat_t AngleGet(void) { return m_angle; };
|
||||||
|
void AngleSet(etkFloat_t state) { m_angle = state; };
|
||||||
|
etkFloat_t GravityGet(void) { return m_gravity; };
|
||||||
|
void GravitySet(etkFloat_t state) { m_gravity = state; };
|
||||||
|
|
||||||
|
int32_t GetType(void) { return m_type; };
|
||||||
|
int32_t GroupGet(void) { return m_group; };
|
||||||
|
void GroupSet(int32_t state) { m_group = state; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Periodicly this fuction will be call tu change property of all the dynamic obbjects
|
||||||
|
* @param[in] time Current game time (start at 0)
|
||||||
|
* @param[in] deltaTime delta time before the previous call
|
||||||
|
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
||||||
|
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
||||||
|
* @return true if the object must be remove
|
||||||
|
* @return false if the object must be keep
|
||||||
|
*/
|
||||||
|
virtual bool Process(int64_t time, int32_t deltaTime, ewol::SceneElement & sceneElement) { return false; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
||||||
|
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
||||||
|
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
||||||
|
* @return ---
|
||||||
|
*/
|
||||||
|
virtual void Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects) { };
|
||||||
|
/**
|
||||||
|
* @brief an element has been remove, just remove reference on it or ID on IT, it can be replace whith an other that have no link
|
||||||
|
* @param[in] idOfElement Id of the element that has been removed
|
||||||
|
* @return ---
|
||||||
|
*/
|
||||||
|
virtual void RemoveElement(int32_t idOfElement) { };
|
||||||
|
virtual bool HaveImpact(int32_t group, int32_t type, coord2D_ts position, etkFloat_t size) {return false;};
|
||||||
|
virtual void Explosion(int32_t group, int32_t type, coord2D_ts position, etkFloat_t pxAtenuation, etkFloat_t power) { } ;
|
||||||
|
/**
|
||||||
|
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
||||||
|
* @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one
|
||||||
|
* @param[in] fileName Sprite name
|
||||||
|
* @param[in] maxSize maximum size of the sprite
|
||||||
|
* @return the id of the sprite requested or -1 if it does not existed
|
||||||
|
*/
|
||||||
|
int32_t LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, coord2D_ts maxSize);
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#include <ewol/widget/Scene.h>
|
||||||
|
|
||||||
|
etkFloat_t quadDist(coord2D_ts pos1, coord2D_ts pos2);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -293,6 +293,9 @@ int32_t ewol::texture::Load(etk::UString tmpfileName, int32_t requestedWidth)
|
|||||||
if (false == fileName.Exist()) {
|
if (false == fileName.Exist()) {
|
||||||
EWOL_ERROR("File does not Exist ... " << fileName);
|
EWOL_ERROR("File does not Exist ... " << fileName);
|
||||||
} else {
|
} else {
|
||||||
|
// get the upper paw2 ot the size requested...
|
||||||
|
requestedWidth = nextP2(requestedWidth);
|
||||||
|
|
||||||
etk::UString fileExtention = fileName.GetExtention();
|
etk::UString fileExtention = fileName.GetExtention();
|
||||||
if (fileExtention == "bmp") {
|
if (fileExtention == "bmp") {
|
||||||
// create the bitmap texture
|
// create the bitmap texture
|
||||||
@ -313,8 +316,6 @@ int32_t ewol::texture::Load(etk::UString tmpfileName, int32_t requestedWidth)
|
|||||||
// removet the bitmap handle
|
// removet the bitmap handle
|
||||||
delete (myBitmap);
|
delete (myBitmap);
|
||||||
} else if (fileExtention == "svg") {
|
} else if (fileExtention == "svg") {
|
||||||
// get the upper paw2 ot the size requested...
|
|
||||||
//requestedWidth = nextP2(requestedWidth);
|
|
||||||
/*if (requestedWidth < 32) {
|
/*if (requestedWidth < 32) {
|
||||||
requestedWidth = 32;
|
requestedWidth = 32;
|
||||||
}*/
|
}*/
|
||||||
|
@ -252,6 +252,7 @@ void ewol::Widget::KeepFocus(void)
|
|||||||
/**
|
/**
|
||||||
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
||||||
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
||||||
|
* @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget
|
||||||
* @param ---
|
* @param ---
|
||||||
* @return ---
|
* @return ---
|
||||||
*/
|
*/
|
||||||
|
@ -407,10 +407,11 @@ namespace ewol {
|
|||||||
/**
|
/**
|
||||||
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
||||||
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
||||||
|
* @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget
|
||||||
* @param ---
|
* @param ---
|
||||||
* @return ---
|
* @return ---
|
||||||
*/
|
*/
|
||||||
void GenDraw(void);
|
virtual void GenDraw(void);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
||||||
|
@ -120,9 +120,10 @@ static void* BaseAppEntry(void* param)
|
|||||||
EWOL_DEBUG("==> Init BThread (END)");
|
EWOL_DEBUG("==> Init BThread (END)");
|
||||||
while(false == requestEndProcessing) {
|
while(false == requestEndProcessing) {
|
||||||
ewol::threadMsg::threadMsgContent_ts data;
|
ewol::threadMsg::threadMsgContent_ts data;
|
||||||
|
data.type = THREAD_JUST_DISPLAY;
|
||||||
ewol::threadMsg::WaitMessage(androidJniMsg, data);
|
ewol::threadMsg::WaitMessage(androidJniMsg, data);
|
||||||
|
countNbEvent++;
|
||||||
if (data.type != THREAD_JUST_DISPLAY) {
|
if (data.type != THREAD_JUST_DISPLAY) {
|
||||||
countNbEvent++;
|
|
||||||
//EWOL_DEBUG("EVENT");
|
//EWOL_DEBUG("EVENT");
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case THREAD_INIT:
|
case THREAD_INIT:
|
||||||
|
@ -97,21 +97,21 @@ void ewol::Scene::OnRegenerateDisplay(void)
|
|||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
if (true == NeedRedraw()) {
|
||||||
// clean elements
|
// clean elements
|
||||||
for (int32_t iii=0; iii<m_animated[m_currentCreateId].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.animated[m_currentCreateId].Size(); iii++) {
|
||||||
if (NULL != m_animated[m_currentCreateId][iii]) {
|
if (NULL != m_sceneElement.animated[m_currentCreateId][iii]) {
|
||||||
m_animated[m_currentCreateId][iii]->Clear();
|
m_sceneElement.animated[m_currentCreateId][iii]->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// clean effects
|
// clean effects
|
||||||
for (int32_t iii=0; iii<m_effects[m_currentCreateId].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.effects[m_currentCreateId].Size(); iii++) {
|
||||||
if (NULL != m_effects[m_currentCreateId][iii]) {
|
if (NULL != m_sceneElement.effects[m_currentCreateId][iii]) {
|
||||||
m_effects[m_currentCreateId][iii]->Clear();
|
m_sceneElement.effects[m_currentCreateId][iii]->Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements.Size(); iii++) {
|
||||||
if (NULL != m_listAnimatedElements[iii]) {
|
if (NULL != m_sceneElement.listAnimatedElements[iii]) {
|
||||||
// find an empty slot ...
|
// find an empty slot ...
|
||||||
m_listAnimatedElements[iii]->Draw(m_animated[m_currentCreateId], m_effects[m_currentCreateId]);
|
m_sceneElement.listAnimatedElements[iii]->Draw(m_sceneElement.animated[m_currentCreateId], m_sceneElement.effects[m_currentCreateId]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,35 +128,36 @@ void ewol::Scene::OnDraw(void)
|
|||||||
// draw background
|
// draw background
|
||||||
// TODO : ...
|
// TODO : ...
|
||||||
// draw elements
|
// draw elements
|
||||||
for (int32_t iii=0; iii<m_animated[m_currentDrawId].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.animated[m_currentDrawId].Size(); iii++) {
|
||||||
if (NULL != m_animated[m_currentDrawId][iii]) {
|
if (NULL != m_sceneElement.animated[m_currentDrawId][iii]) {
|
||||||
m_animated[m_currentDrawId][iii]->Draw();
|
m_sceneElement.animated[m_currentDrawId][iii]->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// draw effects
|
// draw effects
|
||||||
for (int32_t iii=0; iii<m_effects[m_currentDrawId].Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.effects[m_currentDrawId].Size(); iii++) {
|
||||||
if (NULL != m_effects[m_currentDrawId][iii]) {
|
if (NULL != m_sceneElement.effects[m_currentDrawId][iii]) {
|
||||||
m_effects[m_currentDrawId][iii]->Draw();
|
m_sceneElement.effects[m_currentDrawId][iii]->Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_needFlipFlop = true;
|
m_needFlipFlop = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Scene::AddElement(ewol::GameElement* newElement)
|
int32_t ewol::SceneElement::AddElement(ewol::GameElement* newElement)
|
||||||
{
|
{
|
||||||
if (NULL == newElement) {
|
if (NULL == newElement) {
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
for (int32_t iii=0; iii<listAnimatedElements.Size(); iii++) {
|
||||||
if (NULL == m_listAnimatedElements[iii]) {
|
if (NULL == listAnimatedElements[iii]) {
|
||||||
// find an empty slot ...
|
// find an empty slot ...
|
||||||
m_listAnimatedElements[iii] = newElement;
|
listAnimatedElements[iii] = newElement;
|
||||||
return;
|
return iii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//did not find empty slot :
|
//did not find empty slot :
|
||||||
m_listAnimatedElements.PushBack(newElement);
|
listAnimatedElements.PushBack(newElement);
|
||||||
|
return listAnimatedElements.Size()-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,12 +170,12 @@ void ewol::Scene::PeriodicCall(int64_t localTime)
|
|||||||
{
|
{
|
||||||
|
|
||||||
//EWOL_ERROR("Periodic Call ... " << localTime);
|
//EWOL_ERROR("Periodic Call ... " << localTime);
|
||||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
for (int32_t iii=0; iii<m_sceneElement.listAnimatedElements.Size(); iii++) {
|
||||||
if (NULL != m_listAnimatedElements[iii]) {
|
if (NULL != m_sceneElement.listAnimatedElements[iii]) {
|
||||||
// check if the element request an auto Kill ...
|
// check if the element request an auto Kill ...
|
||||||
if (true == m_listAnimatedElements[iii]->Process(localTime, 20000, m_listAnimatedElements) ) {
|
if (true == m_sceneElement.listAnimatedElements[iii]->Process(localTime, 20000, m_sceneElement) ) {
|
||||||
delete(m_listAnimatedElements[iii]);
|
delete(m_sceneElement.listAnimatedElements[iii]);
|
||||||
m_listAnimatedElements[iii] = NULL;
|
m_sceneElement.listAnimatedElements[iii] = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,14 +33,21 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ewol {
|
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...
|
||||||
|
int32_t AddElement(ewol::GameElement* newElement);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class Scene :public ewol::WidgetScrooled
|
class Scene :public ewol::WidgetScrooled
|
||||||
{
|
{
|
||||||
// TODO : Set it in private ...
|
// TODO : Set it in private ...
|
||||||
protected:
|
protected:
|
||||||
etk::VectorType<ewol::OObject*> m_backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
SceneElement m_sceneElement; //!< all element neede in the scene
|
||||||
etk::VectorType<ewol::Sprite*> m_animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
|
||||||
etk::VectorType<ewol::Sprite*> m_effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
|
||||||
etk::VectorType<ewol::GameElement*> m_listAnimatedElements; //!< generic element to display...
|
|
||||||
public:
|
public:
|
||||||
Scene(void);
|
Scene(void);
|
||||||
virtual ~Scene(void);
|
virtual ~Scene(void);
|
||||||
@ -73,7 +80,6 @@ namespace ewol {
|
|||||||
* @return ---
|
* @return ---
|
||||||
*/
|
*/
|
||||||
virtual void OnDraw(void);
|
virtual void OnDraw(void);
|
||||||
void AddElement(ewol::GameElement* newElement);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <ewol/OObject.h>
|
#include <ewol/OObject.h>
|
||||||
#include <ewol/WidgetManager.h>
|
#include <ewol/WidgetManager.h>
|
||||||
|
#include <ewol/importgl.h>
|
||||||
|
#include <ewol/ewol.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -35,6 +37,8 @@ ewol::WidgetScrooled::WidgetScrooled(void)
|
|||||||
m_originScrooled.y = 0;
|
m_originScrooled.y = 0;
|
||||||
m_pixelScrolling = 20;
|
m_pixelScrolling = 20;
|
||||||
m_highSpeedMode = SCROLL_DISABLE;
|
m_highSpeedMode = SCROLL_DISABLE;
|
||||||
|
m_scroollingMode = SCROLL_MODE_NORMAL;
|
||||||
|
m_zoom = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ewol::WidgetScrooled::~WidgetScrooled(void)
|
ewol::WidgetScrooled::~WidgetScrooled(void)
|
||||||
@ -115,6 +119,7 @@ void ewol::WidgetScrooled::OnRegenerateDisplay(void)
|
|||||||
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
|
bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
|
||||||
{
|
{
|
||||||
coord2D_ts relativePos = RelativePosition(pos);
|
coord2D_ts relativePos = RelativePosition(pos);
|
||||||
|
if (SCROLL_MODE_NORMAL == m_scroollingMode) {
|
||||||
#ifdef __MODE__Touch
|
#ifdef __MODE__Touch
|
||||||
if (1 == IdInput) {
|
if (1 == IdInput) {
|
||||||
EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
|
EWOL_VERBOSE("event 1 << " << (int32_t)typeEvent << "(" << x << "," << y << ")");
|
||||||
@ -162,7 +167,6 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||||
//EWOL_INFO("mouse-event GDK_SCROLL_UP");
|
|
||||||
m_originScrooled.y -= m_pixelScrolling;
|
m_originScrooled.y -= m_pixelScrolling;
|
||||||
if (m_originScrooled.y < 0) {
|
if (m_originScrooled.y < 0) {
|
||||||
m_originScrooled.y = 0;
|
m_originScrooled.y = 0;
|
||||||
@ -170,7 +174,6 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
|
|||||||
MarkToReedraw();
|
MarkToReedraw();
|
||||||
return true;
|
return true;
|
||||||
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||||
//EWOL_INFO("mouse-event GDK_SCROLL_DOWN");
|
|
||||||
m_originScrooled.y += m_pixelScrolling;
|
m_originScrooled.y += m_pixelScrolling;
|
||||||
if (m_maxSize.y < m_originScrooled.y) {
|
if (m_maxSize.y < m_originScrooled.y) {
|
||||||
m_originScrooled.y = m_maxSize.y;
|
m_originScrooled.y = m_maxSize.y;
|
||||||
@ -228,6 +231,69 @@ bool ewol::WidgetScrooled::OnEventInput(int32_t IdInput, ewol::eventInputType_te
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
} else if (SCROLL_MODE_CENTER == m_scroollingMode) {
|
||||||
|
#ifdef __MODE__Touch
|
||||||
|
// TODO ...
|
||||||
|
#else
|
||||||
|
etkFloat_t tmp1=ewol::GetCurrentHeight() / m_maxSize.y;
|
||||||
|
etkFloat_t tmp2=ewol::GetCurrentWidth() / m_maxSize.x;
|
||||||
|
//EWOL_INFO(" elements Zoom : " << tmp1 << " " << tmp2);
|
||||||
|
tmp1 = etk_min(tmp1, tmp2);
|
||||||
|
if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||||
|
m_zoom -= 0.1;
|
||||||
|
if (tmp1 < 1.0) {
|
||||||
|
m_zoom = etk_max(tmp1, m_zoom);
|
||||||
|
} else {
|
||||||
|
m_zoom = etk_max(1.0, m_zoom);
|
||||||
|
}
|
||||||
|
MarkToReedraw();
|
||||||
|
return true;
|
||||||
|
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
|
||||||
|
m_zoom += 0.1;
|
||||||
|
if (tmp1 > 1.0) {
|
||||||
|
m_zoom = etk_min(tmp1, m_zoom);
|
||||||
|
} else {
|
||||||
|
m_zoom = etk_min(1.0, m_zoom);
|
||||||
|
}
|
||||||
|
MarkToReedraw();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
EWOL_ERROR("Scrolling mode unknow ... " << m_scroollingMode );
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
||||||
|
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
||||||
|
* @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget
|
||||||
|
* @param ---
|
||||||
|
* @return ---
|
||||||
|
*/
|
||||||
|
void ewol::WidgetScrooled::GenDraw(void)
|
||||||
|
{
|
||||||
|
if (SCROLL_MODE_CENTER == m_scroollingMode) {
|
||||||
|
glPushMatrix();
|
||||||
|
// 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,
|
||||||
|
ewol::GetCurrentHeight() - m_size.y - m_origin.y,
|
||||||
|
m_size.x,
|
||||||
|
m_size.y);
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
glScalef(m_zoom, m_zoom, 1.0);
|
||||||
|
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
|
||||||
|
|
||||||
|
// Call the widget drawing methode
|
||||||
|
OnDraw();
|
||||||
|
glPopMatrix();
|
||||||
|
} else {
|
||||||
|
ewol::Widget::GenDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -41,12 +41,18 @@ namespace ewol {
|
|||||||
#endif
|
#endif
|
||||||
}highSpeedMode_te;
|
}highSpeedMode_te;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SCROLL_MODE_NORMAL, //!< No Zoom , can UP and down, left and right
|
||||||
|
SCROLL_MODE_CENTER, //!< Zoom enable, no move left and right
|
||||||
|
} scrollingMode_te;
|
||||||
class WidgetScrooled : public ewol::Widget
|
class WidgetScrooled : public ewol::Widget
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
coord2D_ts m_originScrooled;
|
coord2D_ts m_originScrooled;
|
||||||
coord2D_ts m_maxSize;
|
coord2D_ts m_maxSize;
|
||||||
|
etkFloat_t m_zoom; //!< current zoom on the display
|
||||||
private:
|
private:
|
||||||
|
scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling
|
||||||
etkFloat_t m_pixelScrolling;
|
etkFloat_t m_pixelScrolling;
|
||||||
coord2D_ts m_highSpeedStartPos;
|
coord2D_ts m_highSpeedStartPos;
|
||||||
highSpeedMode_te m_highSpeedMode;
|
highSpeedMode_te m_highSpeedMode;
|
||||||
@ -78,8 +84,17 @@ namespace ewol {
|
|||||||
* @return false the event is not used
|
* @return false the event is not used
|
||||||
*/
|
*/
|
||||||
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos);
|
virtual bool OnEventInput(int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos);
|
||||||
|
/**
|
||||||
|
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
|
||||||
|
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
|
||||||
|
* @note This function is virtual for the scrolled widget, and the more complicated OpenGl widget
|
||||||
|
* @param ---
|
||||||
|
* @return ---
|
||||||
|
*/
|
||||||
|
virtual void GenDraw(void);
|
||||||
protected:
|
protected:
|
||||||
void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; };
|
void SetScrollingSize(etkFloat_t nbPixel) { m_pixelScrolling = nbPixel; };
|
||||||
|
void ScroolingMode(scrollingMode_te newMode) { m_scroollingMode = newMode; };
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const char * const TYPE_EOBJECT_WIDGET_SCROOLED;
|
extern const char * const TYPE_EOBJECT_WIDGET_SCROOLED;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user