Change the scene display methode
This commit is contained in:
parent
c824f361c2
commit
7e0a2c9fc3
@ -78,16 +78,22 @@ void ewol::audio::UnInit(void)
|
||||
musicFadingTime = 0;
|
||||
}
|
||||
|
||||
static float angle = 0;
|
||||
static ewol::audio::AudioCallback userLocalCallback = NULL;
|
||||
|
||||
void ewol::audio::GetData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels)
|
||||
{
|
||||
// TODO : set the real playing time ...
|
||||
currentTimePlaying += 10;
|
||||
if (nbChannels != 2) {
|
||||
EWOL_ERROR("TODO : Support the signal mono or more tha stereo ...");
|
||||
return;
|
||||
}
|
||||
// reset the current buffer
|
||||
memset(bufferInterlace, 0, nbSample*sizeof(int16_t)*nbChannels);
|
||||
// get user data ...
|
||||
if (NULL != userLocalCallback) {
|
||||
(*userLocalCallback)(bufferInterlace, nbSample, nbChannels);
|
||||
}
|
||||
// get background music :
|
||||
ewol::audio::music::GetData(bufferInterlace, nbSample, nbChannels);
|
||||
// add effects :
|
||||
@ -99,6 +105,11 @@ void ewol::audio::GetData(int16_t * bufferInterlace, int32_t nbSample, int32_t n
|
||||
}
|
||||
|
||||
|
||||
void ewol::audio::AddCallbackOutput(ewol::audio::AudioCallback userCallback)
|
||||
{
|
||||
userLocalCallback = userCallback;
|
||||
}
|
||||
|
||||
void ewol::audio::music::Fading(int32_t timeMs)
|
||||
{
|
||||
musicFadingTime = timeMs;
|
||||
|
@ -32,6 +32,10 @@ namespace ewol {
|
||||
namespace audio {
|
||||
void Init(void);
|
||||
void UnInit(void);
|
||||
|
||||
typedef void (*AudioCallback)(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels);
|
||||
void AddCallbackOutput(AudioCallback userCallback);
|
||||
|
||||
void GetData(int16_t * bufferInterlace, int32_t nbSample, int32_t nbChannels);
|
||||
|
||||
namespace music {
|
||||
|
@ -233,7 +233,7 @@ int16_t * ewol::audio::wav::LoadData(etk::UString filename, int8_t nbChan, int32
|
||||
return NULL;
|
||||
}
|
||||
EWOL_DEBUG(" dataSize : " << myHeader.dataSize);
|
||||
int32_t globalDataSize = myHeader.dataSize;
|
||||
//int32_t globalDataSize = myHeader.dataSize;
|
||||
int32_t nbSample = (myHeader.dataSize/((myHeader.waveFormat.bitsPerSample/8)*myHeader.waveFormat.channelCount));
|
||||
int32_t outputSize = nbChan*nbSample;
|
||||
int16_t * outputData = (int16_t*)malloc(outputSize*sizeof(int16_t));
|
||||
|
@ -22,6 +22,7 @@
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#include <ewol/ewol.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/Game/GameElement.h>
|
||||
#include <ewol/Game/GameElementLua.h>
|
||||
|
@ -271,7 +271,7 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
|
||||
int32_t tmpOriginY = etk_max(displayProp.m_origin.y, m_origin.y);
|
||||
tmppp1 = displayProp.m_origin.y + displayProp.m_size.y;
|
||||
tmppp2 = m_origin.y + m_size.y;
|
||||
int32_t tmpclipY = etk_min(tmppp1, tmppp2) - tmpOriginX;
|
||||
//int32_t tmpclipY = etk_min(tmppp1, tmppp2) - tmpOriginX;
|
||||
|
||||
glViewport( tmpOriginX,
|
||||
tmpOriginY,
|
||||
|
@ -174,7 +174,7 @@ namespace ewol {
|
||||
* @param[in] pos Absolute position that you request convertion
|
||||
* @return the relative position
|
||||
*/
|
||||
Vector2D<float> RelativePosition(Vector2D<float> pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; };
|
||||
virtual Vector2D<float> RelativePosition(Vector2D<float> pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; };
|
||||
/**
|
||||
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
|
||||
* By default this save the widget availlable size in the widget size
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include <ewol/OObject.h>
|
||||
#include <ewol/WidgetManager.h>
|
||||
#include <ewol/importgl.h>
|
||||
|
||||
/**
|
||||
* @brief Initilise the basic widget property ==> due to the android system
|
||||
@ -48,6 +49,7 @@ ewol::Scene::Scene(void)
|
||||
SetCanHaveFocus(true);
|
||||
PeriodicCallSet(true);
|
||||
m_lastCallTime = -1;
|
||||
m_zoom = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@ -137,4 +139,62 @@ void ewol::Scene::PeriodicCall(int64_t localTime)
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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::Scene::GenDraw(DrawProperty displayProp)
|
||||
{
|
||||
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,
|
||||
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, -100, 100);
|
||||
float ratio = m_size.x / m_size.y;
|
||||
//EWOL_INFO("ratio : " << ratio);
|
||||
if (ratio >= 0.0) {
|
||||
glOrthoEwol(-ratio, ratio, -1, 1, -1, 1);
|
||||
} else {
|
||||
ratio = 1.0/ratio;
|
||||
glOrthoEwol(-1, 1, -ratio, ratio, -1, 1);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
m_zoom = 1.0/1000.0;
|
||||
// Clear the screen with transparency ...
|
||||
glClearColor(0.0, 0.0, 0.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glScalef(m_zoom, m_zoom, m_zoom);
|
||||
//glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
|
||||
|
||||
// Call the widget drawing methode
|
||||
OnDraw(displayProp);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Convert the absolute position in the local Position (Relative)
|
||||
* @param[in] pos Absolute position that you request convertion
|
||||
* @return the relative position
|
||||
*/
|
||||
Vector2D<float> ewol::Scene::RelativePosition(Vector2D<float> pos)
|
||||
{
|
||||
pos.x -= m_origin.x;
|
||||
pos.y -= m_origin.y;
|
||||
pos.x -= m_size.x/2;
|
||||
pos.y -= m_size.y/2;
|
||||
pos.x *= m_zoom;
|
||||
pos.y *= m_zoom;
|
||||
|
||||
return pos;
|
||||
};
|
@ -33,7 +33,7 @@
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class Scene :public ewol::WidgetScrooled
|
||||
class Scene :public ewol::Widget
|
||||
{
|
||||
// TODO : Set it in private ...
|
||||
protected:
|
||||
@ -82,6 +82,14 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
void PauseToggle(void) { if(true==m_isRunning){ m_isRunning=false;}else{m_isRunning=true;} };
|
||||
/**
|
||||
* @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(DrawProperty displayProp);
|
||||
protected:
|
||||
/**
|
||||
* @brief Periodic call in the sub element timed
|
||||
@ -90,6 +98,26 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
virtual void ScenePeriodicCall(int64_t localTime, int32_t deltaTime) { };
|
||||
// camera properties :
|
||||
private:
|
||||
Vector3D<float> m_camRotation;
|
||||
Vector3D<float> m_camTranslation;
|
||||
float m_camAngleView;
|
||||
float m_camdistanceViewStart;
|
||||
float m_camdistanceViewStop;
|
||||
float m_zoom;
|
||||
public:
|
||||
void SetCamaraTranslation();
|
||||
void SetCamaraRotation();
|
||||
void SetCamaraAngleView();
|
||||
void SetCamaraDistanceViewStart();
|
||||
void SetCamaraDistanceViewStop();
|
||||
/**
|
||||
* @brief Convert the absolute position in the local Position (Relative)
|
||||
* @param[in] pos Absolute position that you request convertion
|
||||
* @return the relative position
|
||||
*/
|
||||
virtual Vector2D<float> RelativePosition(Vector2D<float> pos);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/SizerHori.cpp
|
||||
* @brief ewol hirisantal sizer widget system (Sources)
|
||||
* @brief ewol horisantal sizer widget system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/11/2011
|
||||
* @par Project
|
||||
@ -122,7 +122,7 @@ bool ewol::SizerHori::CalculateMinSize(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::SizerHori::SetMinSise(float x, float y)
|
||||
void ewol::SizerHori::SetMinSize(float x, float y)
|
||||
{
|
||||
EWOL_ERROR("Sizer can not have a user Minimum size (herited from under elements)");
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/widget/SizerHori.h
|
||||
* @brief ewol hirisantal sizer widget system (header)
|
||||
* @brief ewol horisantal sizer widget system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 07/11/2011
|
||||
* @par Project
|
||||
@ -46,7 +46,7 @@ namespace ewol {
|
||||
public:
|
||||
virtual bool CalculateSize(float availlableX, float availlableY); // this generate the current size ...
|
||||
virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer
|
||||
virtual void SetMinSise(float x=-1, float y=-1);
|
||||
virtual void SetMinSize(float x=-1, float y=-1);
|
||||
virtual void SetExpendX(bool newExpend=false);
|
||||
virtual bool CanExpentX(void);
|
||||
virtual void SetExpendY(bool newExpend=false);
|
||||
|
@ -125,7 +125,7 @@ bool ewol::SizerVert::CalculateMinSize(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::SizerVert::SetMinSise(float x, float y)
|
||||
void ewol::SizerVert::SetMinSize(float x, float y)
|
||||
{
|
||||
EWOL_ERROR("Sizer can not have a user Minimum size (herited from under elements)");
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ namespace ewol {
|
||||
public:
|
||||
virtual bool CalculateSize(float availlableX, float availlableY); // this generate the current size ...
|
||||
virtual bool CalculateMinSize(void); //update the min Size ... and the expend parameters for the sizer
|
||||
virtual void SetMinSise(float x=-1, float y=-1);
|
||||
virtual void SetMinSize(float x=-1, float y=-1);
|
||||
virtual void SetExpendX(bool newExpend=false);
|
||||
virtual bool CanExpentX(void);
|
||||
virtual void SetExpendY(bool newExpend=false);
|
||||
|
@ -55,33 +55,37 @@ ewol::WidgetScrooled::~WidgetScrooled(void)
|
||||
void ewol::WidgetScrooled::OnRegenerateDisplay(void)
|
||||
{
|
||||
ClearOObjectList();
|
||||
ewol::OObject2DColored* myOObjectsColored = NULL;
|
||||
if(m_size.y < m_maxSize.y || m_size.x < m_maxSize.x) {
|
||||
myOObjectsColored = new ewol::OObject2DColored();
|
||||
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.6);
|
||||
}
|
||||
if(m_size.y < m_maxSize.y) {
|
||||
//myOObjectsColored->Line(m_size.x-SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(m_size.x-(SCROLL_BAR_SPACE/2), SCROLL_BAR_SPACE, m_size.x-(SCROLL_BAR_SPACE/2), m_size.y, 1);
|
||||
float lenScrollBar = m_size.y*(m_size.y-SCROLL_BAR_SPACE) / m_maxSize.y;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.y-SCROLL_BAR_SPACE));
|
||||
float originScrollBar = m_originScrooled.y / (m_maxSize.y-m_size.y*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.y-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(m_size.x-SCROLL_BAR_SPACE, m_size.y - originScrollBar - lenScrollBar, SCROLL_BAR_SPACE, lenScrollBar);
|
||||
}
|
||||
if(m_size.x < m_maxSize.x) {
|
||||
//myOObjectsColored->Line(SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(0, (SCROLL_BAR_SPACE/2), m_size.x-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2), 1);
|
||||
float lenScrollBar = m_size.x*(m_size.x-SCROLL_BAR_SPACE) / m_maxSize.x;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x-SCROLL_BAR_SPACE));
|
||||
float originScrollBar = m_originScrooled.x / (m_maxSize.x-m_size.x*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.x-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(originScrollBar, 0, lenScrollBar, SCROLL_BAR_SPACE);
|
||||
}
|
||||
if (NULL!=myOObjectsColored) {
|
||||
AddOObject(myOObjectsColored);
|
||||
if (SCROLL_MODE_GAME == m_scroollingMode) {
|
||||
|
||||
} else {
|
||||
ewol::OObject2DColored* myOObjectsColored = NULL;
|
||||
if(m_size.y < m_maxSize.y || m_size.x < m_maxSize.x) {
|
||||
myOObjectsColored = new ewol::OObject2DColored();
|
||||
myOObjectsColored->SetColor(1.0, 0.0, 0.0, 0.6);
|
||||
}
|
||||
if(m_size.y < m_maxSize.y) {
|
||||
//myOObjectsColored->Line(m_size.x-SCROLL_BAR_SPACE, SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(m_size.x-(SCROLL_BAR_SPACE/2), SCROLL_BAR_SPACE, m_size.x-(SCROLL_BAR_SPACE/2), m_size.y, 1);
|
||||
float lenScrollBar = m_size.y*(m_size.y-SCROLL_BAR_SPACE) / m_maxSize.y;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.y-SCROLL_BAR_SPACE));
|
||||
float originScrollBar = m_originScrooled.y / (m_maxSize.y-m_size.y*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.y-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(m_size.x-SCROLL_BAR_SPACE, m_size.y - originScrollBar - lenScrollBar, SCROLL_BAR_SPACE, lenScrollBar);
|
||||
}
|
||||
if(m_size.x < m_maxSize.x) {
|
||||
//myOObjectsColored->Line(SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, m_size.x-SCROLL_BAR_SPACE, m_size.y-SCROLL_BAR_SPACE, 1);
|
||||
myOObjectsColored->Line(0, (SCROLL_BAR_SPACE/2), m_size.x-SCROLL_BAR_SPACE, (SCROLL_BAR_SPACE/2), 1);
|
||||
float lenScrollBar = m_size.x*(m_size.x-SCROLL_BAR_SPACE) / m_maxSize.x;
|
||||
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x-SCROLL_BAR_SPACE));
|
||||
float originScrollBar = m_originScrooled.x / (m_maxSize.x-m_size.x*m_limitScrolling);
|
||||
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
|
||||
originScrollBar *= (m_size.x-SCROLL_BAR_SPACE-lenScrollBar);
|
||||
myOObjectsColored->Rectangle(originScrollBar, 0, lenScrollBar, SCROLL_BAR_SPACE);
|
||||
}
|
||||
if (NULL!=myOObjectsColored) {
|
||||
AddOObject(myOObjectsColored);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,6 +297,8 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (SCROLL_MODE_GAME == m_scroollingMode) {
|
||||
|
||||
} else {
|
||||
EWOL_ERROR("Scrolling mode unknow ... " << m_scroollingMode );
|
||||
}
|
||||
@ -356,6 +362,24 @@ void ewol::WidgetScrooled::GenDraw(DrawProperty displayProp)
|
||||
glScalef(m_zoom, m_zoom, 1.0);
|
||||
glTranslatef(-m_maxSize.x/2, -m_maxSize.y/2, -1.0);
|
||||
|
||||
// Call the widget drawing methode
|
||||
OnDraw(displayProp);
|
||||
glPopMatrix();
|
||||
} if (SCROLL_MODE_GAME == 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,
|
||||
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(displayProp);
|
||||
glPopMatrix();
|
||||
@ -398,3 +422,19 @@ void ewol::WidgetScrooled::SetScrollingPositionDynamic(Vector2D<float> borderWid
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief Specify the mode of scrolling for this windows
|
||||
* @param[in] newMode the selected mode for the scrolling...
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::WidgetScrooled::ScroolingMode(scrollingMode_te newMode)
|
||||
{
|
||||
m_scroollingMode = newMode;
|
||||
if (SCROLL_MODE_GAME == m_scroollingMode) {
|
||||
// set the scene maximum size :
|
||||
m_maxSize.x = etk_max(ewol::GetCurrentHeight(), ewol::GetCurrentWidth());
|
||||
m_maxSize.y = m_maxSize.x;
|
||||
m_zoom = 1;
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ namespace ewol {
|
||||
typedef enum {
|
||||
SCROLL_MODE_NORMAL, //!< No Zoom , can UP and down, left and right
|
||||
SCROLL_MODE_CENTER, //!< Zoom enable, no move left and right
|
||||
SCROLL_MODE_GAME, //!< Zoom enable, no move left and right
|
||||
} scrollingMode_te;
|
||||
class WidgetScrooled : public ewol::Widget
|
||||
{
|
||||
@ -103,7 +104,7 @@ namespace ewol {
|
||||
* @param[in] newMode the selected mode for the scrolling...
|
||||
* @return ---
|
||||
*/
|
||||
void ScroolingMode(scrollingMode_te newMode) { m_scroollingMode = newMode; };
|
||||
void ScroolingMode(scrollingMode_te newMode);
|
||||
/**
|
||||
* @brief Set the specific mawimum size of the widget
|
||||
* @param[in] localSize new Maximum size
|
||||
|
Loading…
x
Reference in New Issue
Block a user