[DEV] add sprite properties
This commit is contained in:
parent
e12bea33e3
commit
47ea209279
@ -147,6 +147,9 @@ void ewol::Image::SetAngle(const vec3& _axes, float _angle)
|
||||
|
||||
void ewol::Image::Print(const vec2& _size)
|
||||
{
|
||||
#if 1
|
||||
PrintPart(_size, vec2(0,0), vec2(1,1));
|
||||
#else
|
||||
vec3 point(0,0,0);
|
||||
vec2 tex(0,1);
|
||||
|
||||
@ -189,13 +192,55 @@ void ewol::Image::Print(const vec2& _size)
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ewol::Image::PrintPart(const ivec2& _size,
|
||||
void ewol::Image::PrintPart(const vec2& _size,
|
||||
const vec2& _sourcePosStart,
|
||||
const vec2& _sourcePosStop)
|
||||
{
|
||||
|
||||
vec3 point(0,0,0);
|
||||
vec2 tex(_sourcePosStart.x(),_sourcePosStop.y());
|
||||
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
|
||||
|
||||
tex.setValue(_sourcePosStop.x(),_sourcePosStop.y());
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
|
||||
|
||||
tex.setValue(_sourcePosStop.x(),_sourcePosStart.y());
|
||||
point.setX(m_position.x() + _size.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
|
||||
tex.setValue(_sourcePosStart.x(),_sourcePosStart.y());
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y() + _size.y());
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
|
||||
tex.setValue(_sourcePosStart.x(),_sourcePosStop.y());
|
||||
point.setX(m_position.x());
|
||||
point.setY(m_position.y());
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coordColor.PushBack(m_color);
|
||||
}
|
||||
|
||||
void ewol::Image::SetSource(const etk::UString& _newFile, const vec2& _size)
|
||||
|
@ -52,7 +52,7 @@ namespace ewol
|
||||
/**
|
||||
* @brief generic destructor
|
||||
*/
|
||||
~Image(void);
|
||||
virtual ~Image(void);
|
||||
public:
|
||||
/**
|
||||
* @brief Draw All the refistered text in the current element on openGL
|
||||
@ -121,7 +121,7 @@ namespace ewol
|
||||
* @param[in] _sourcePosStart Start position in the image [0..1] (can be bigger but this repeate the image).
|
||||
* @param[in] _sourcePosStop Stop position in the image [0..1] (can be bigger but this repeate the image).
|
||||
*/
|
||||
void PrintPart(const ivec2& _size,
|
||||
void PrintPart(const vec2& _size,
|
||||
const vec2& _sourcePosStart,
|
||||
const vec2& _sourcePosStop);
|
||||
/**
|
||||
|
@ -34,7 +34,6 @@ ewol::Shaper::Shaper(const etk::UString& _shaperName) :
|
||||
m_GLStateTransition(-1),
|
||||
m_resourceTexture(NULL),
|
||||
m_nextStatusRequested(-1),
|
||||
m_time(-1),
|
||||
m_propertyOrigin(0,0),
|
||||
m_propertySize(0,0),
|
||||
m_propertyInsidePosition(0,0),
|
||||
@ -44,7 +43,7 @@ ewol::Shaper::Shaper(const etk::UString& _shaperName) :
|
||||
m_stateTransition(1.0)
|
||||
{
|
||||
LoadProgram();
|
||||
UpdateVectex();
|
||||
UpdateVertex();
|
||||
}
|
||||
|
||||
ewol::Shaper::~Shaper(void)
|
||||
@ -158,8 +157,15 @@ void ewol::Shaper::Clear(void)
|
||||
|
||||
bool ewol::Shaper::ChangeStatusIn(int32_t _newStatusId)
|
||||
{
|
||||
m_nextStatusRequested = _newStatusId;
|
||||
return true;
|
||||
if (_newStatusId != m_stateNew) {
|
||||
m_nextStatusRequested = _newStatusId;
|
||||
return true;
|
||||
}
|
||||
if( m_nextStatusRequested != -1
|
||||
|| m_stateNew != m_stateOld) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t ewol::Shaper::GetCurrentDisplayedStatus(void)
|
||||
@ -172,41 +178,48 @@ int32_t ewol::Shaper::GetNextDisplayedStatus(void)
|
||||
return m_nextStatusRequested;
|
||||
}
|
||||
|
||||
|
||||
bool ewol::Shaper::PeriodicCall(const ewol::EventTime& _event)
|
||||
{
|
||||
//EWOL_DEBUG("call=" << _event);
|
||||
// start :
|
||||
if (m_time == -1) {
|
||||
m_time = _event.GetTime();
|
||||
if (m_stateTransition>=1.0) {
|
||||
m_stateOld = m_stateNew;
|
||||
m_stateNew = m_nextStatusRequested;
|
||||
m_nextStatusRequested = -1;
|
||||
m_stateTransition = 0.0;
|
||||
EWOL_VERBOSE(" ##### START ##### ");
|
||||
}
|
||||
int64_t offset = _event.GetTime() - m_time;
|
||||
float timeRelativity = m_config->GetFloat(m_confIdChangeTime)*1000.0;
|
||||
if (offset > timeRelativity) {
|
||||
// check if no new state requested:
|
||||
if (m_nextStatusRequested != -1) {
|
||||
m_time =_event.GetTime();
|
||||
m_stateOld = m_stateNew;
|
||||
if( m_nextStatusRequested != -1
|
||||
&& m_nextStatusRequested != m_stateOld) {
|
||||
m_stateNew = m_nextStatusRequested;
|
||||
m_nextStatusRequested = -1;
|
||||
m_stateTransition = 0.0;
|
||||
//EWOL_DEBUG(" ##### START ##### ");
|
||||
} else {
|
||||
m_stateTransition = 1.0;
|
||||
EWOL_VERBOSE(" ##### STOP ##### ");
|
||||
m_nextStatusRequested = -1;
|
||||
// disable periodic call ...
|
||||
return false;
|
||||
m_time = -1;
|
||||
}
|
||||
} else {
|
||||
m_stateTransition = (float)offset / timeRelativity;
|
||||
EWOL_VERBOSE("time=" << offset << " in " << timeRelativity << " Transition : " << m_stateTransition);
|
||||
}
|
||||
if (m_stateTransition<1.0) {
|
||||
// check if no new state requested:
|
||||
if (m_nextStatusRequested != -1 && m_stateTransition<0.5) {
|
||||
// invert sources with destination
|
||||
int32_t tmppp = m_stateOld;
|
||||
m_stateOld = m_stateNew;
|
||||
m_stateNew = tmppp;
|
||||
m_stateTransition = 1.0 - m_stateTransition;
|
||||
if (m_nextStatusRequested == m_stateNew) {
|
||||
m_nextStatusRequested = -1;
|
||||
}
|
||||
}
|
||||
float timeRelativity = m_config->GetFloat(m_confIdChangeTime)/1000.0;
|
||||
m_stateTransition += _event.GetDeltaCall()/timeRelativity;
|
||||
//m_stateTransition += _event.GetDeltaCall();
|
||||
m_stateTransition = etk_avg(0.0f, m_stateTransition, 1.0f);
|
||||
//EWOL_DEBUG("relative=" << timeRelativity << " Transition : " << m_stateTransition);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ewol::Shaper::UpdateVectex(void)
|
||||
|
||||
void ewol::Shaper::UpdateVertex(void)
|
||||
{
|
||||
// set coord ==> must be a static VBO ...
|
||||
m_coord[0].setValue( m_propertyOrigin.x(),
|
||||
@ -228,7 +241,7 @@ void ewol::Shaper::SetOrigin(const vec2& _newOri)
|
||||
{
|
||||
if (m_propertyOrigin != _newOri) {
|
||||
m_propertyOrigin = _newOri;
|
||||
UpdateVectex();
|
||||
UpdateVertex();
|
||||
}
|
||||
|
||||
}
|
||||
@ -237,7 +250,7 @@ void ewol::Shaper::SetSize(const vec2& _newSize)
|
||||
{
|
||||
if (m_propertySize != _newSize) {
|
||||
m_propertySize = _newSize;
|
||||
UpdateVectex();
|
||||
UpdateVertex();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,6 @@ namespace ewol
|
||||
ewol::TextureFile* m_resourceTexture; //!< texture resources (for the image)
|
||||
// internal needed data :
|
||||
int32_t m_nextStatusRequested; //!< when status is changing, this represent the next step of it
|
||||
int64_t m_time; //!< The last time of the dispaly (-1 if nothing progressing)
|
||||
vec2 m_propertyOrigin; //!< widget origin
|
||||
vec2 m_propertySize; //!< widget size
|
||||
vec2 m_propertyInsidePosition; //!< internal subwidget position
|
||||
@ -153,7 +152,7 @@ namespace ewol
|
||||
/**
|
||||
* @brief Update the internal vertex table.
|
||||
*/
|
||||
void UpdateVectex(void);
|
||||
void UpdateVertex(void);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <tinyXML/tinyxml.h>
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/compositing/Sprite.h>
|
||||
#include <ewol/config.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "ewol::Sprite"
|
||||
|
||||
ewol::Sprite::Sprite(const etk::UString& _imageName, const ivec2& _nbSprite) :
|
||||
ewol::Image(_imageName),
|
||||
m_nbSprite(_nbSprite),
|
||||
m_unitarySpriteSize(0,0)
|
||||
{
|
||||
vec2 imageSize = GetRealSize();
|
||||
m_unitarySpriteSize.setValue(imageSize.x()/(float)m_nbSprite.x(),
|
||||
imageSize.y()/(float)m_nbSprite.y());
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ewol::Sprite::PrintSprite(const ivec2& _spriteID, const vec2& _size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,17 +10,20 @@
|
||||
#define __EWOL_COMPOSITING_SPRITE_H__
|
||||
|
||||
#include <ewol/debug.h>
|
||||
#include <ewol/compositing/Compositing.h>
|
||||
#include <ewol/compositing/Image.h>
|
||||
#include <ewol/renderer/ResourceManager.h>
|
||||
|
||||
namespace ewol
|
||||
{
|
||||
class Sprite : public ewol::Compositing
|
||||
class Sprite : public ewol::Image
|
||||
{
|
||||
protected:
|
||||
|
||||
ivec2 m_nbSprite; //!< number of sprite in vertical and horizontal
|
||||
vec2 m_unitarySpriteSize; //!< size of a unique sprite
|
||||
public:
|
||||
|
||||
Sprite(const etk::UString& _imageName, const ivec2& _nbSprite);
|
||||
virtual ~Sprite() {};
|
||||
void PrintSprite(const ivec2& _spriteID, const vec2& _size);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -46,11 +46,13 @@ namespace widget {
|
||||
* @param[in] _newLabel The displayed decorated text.
|
||||
*/
|
||||
void SetLabel(const etk::UString& _newLabel);
|
||||
inline void SetValue(const etk::UString& _newLabel) { SetLabel(_newLabel); };
|
||||
/**
|
||||
* @brief Get the current displayed label
|
||||
* @return The displayed decorated text.
|
||||
*/
|
||||
etk::UString GetLabel(void);
|
||||
inline etk::UString GetValue(void) { return GetLabel(); };
|
||||
protected: // Derived function
|
||||
virtual void OnDraw(void);
|
||||
public: // Derived function
|
||||
|
Loading…
x
Reference in New Issue
Block a user