new distance fieald display work corectly, need to work on the values

This commit is contained in:
Edouard DUPIN 2012-09-07 16:32:54 +02:00
parent 0a8b887984
commit e610df1f12
18 changed files with 377 additions and 36 deletions

View File

@ -60,6 +60,7 @@ namespace ewol
virtual void UpdateContext(void) { };
virtual void RemoveContext(void) { };
virtual void RemoveContextToLate(void) { };
virtual void Reload(void) {};
uint32_t GetUID(void) { return m_uniqueId; };
};
};

View File

@ -76,6 +76,28 @@ void ewol::resource::Display(void)
EWOL_INFO("Resources ---");
}
/**
* @brief Reloade file resources
* @note : Does not reload all resources !!!
* @param ---
* @return ---
*/
void ReLoadResources(void)
{
EWOL_INFO("------------- Resources re-loaded -------------");
// remove all resources ...
for (int32_t iii=l_resourceList.Size()-1; iii>=0; iii--) {
if (l_resourceList[iii] != NULL) {
const char * mode = "keep same";
if (etk::UString(l_resourceList[iii]->GetType()) == "ewol::Program") {
mode = "Reload ...";
l_resourceList[iii]->Reload();
}
EWOL_INFO(" [" << l_resourceList[iii]->GetUID() << "]="<< l_resourceList[iii]->GetType() << " ==> " << mode);
}
}
EWOL_INFO("------------- Resources -------------");
}
void ewol::resource::Update(ewol::Resource* object)
{

View File

@ -43,6 +43,9 @@ namespace ewol
void UnInit(void);
void Display(void);
// specific for the test ...
void ReLoadResources(void);
void Update(ewol::Resource* object);
// Specific to load or update the data in the openGl context ==> system use only
void UpdateContext(void);

View File

@ -56,6 +56,7 @@ static int32_t simpleSQRT(int32_t value)
}
#define SPECIAL_BORDER (5)
#define SPECIAL_UPSCALER (8)
ewol::DistantFieldFont::DistantFieldFont(etk::UString fontName) :
ewol::Texture(fontName),
@ -164,7 +165,7 @@ ewol::DistantFieldFont::DistantFieldFont(etk::UString fontName) :
CurrentLineHigh = 0;
}
// draw the glyph
m_font->DrawGlyph(tmpUpScaledImage, m_size*8, Vector2D<int32_t>(SPECIAL_BORDER*8,SPECIAL_BORDER*8), m_listElement[iii].property);
m_font->DrawGlyph(tmpUpScaledImage, m_size*SPECIAL_UPSCALER, Vector2D<int32_t>(SPECIAL_BORDER*SPECIAL_UPSCALER,SPECIAL_BORDER*SPECIAL_UPSCALER), m_listElement[iii].property);
// set video position
m_listElement[iii].posStart.u = (float)(glyphPosition.x) / (float)textureWidth;
m_listElement[iii].posStart.v = (float)(glyphPosition.y) / (float)textureHeight;
@ -178,12 +179,12 @@ ewol::DistantFieldFont::DistantFieldFont(etk::UString fontName) :
EWOL_DEBUG(" m_advance =" << m_listElement[iii].property.m_advance );
*/
// generate the distance field from this element ...
tmpUpScaledImage.DistanceField(Vector2D<int32_t>(0,0), m_listElement[iii].property.m_sizeTexture*Vector2D<int32_t>(8,8)+Vector2D<int32_t>(2*SPECIAL_BORDER*8,2*SPECIAL_BORDER*8));
tmpUpScaledImage.DistanceField(Vector2D<int32_t>(0,0), m_listElement[iii].property.m_sizeTexture*Vector2D<int32_t>(SPECIAL_UPSCALER,SPECIAL_UPSCALER)+Vector2D<int32_t>(2*SPECIAL_BORDER*SPECIAL_UPSCALER,2*SPECIAL_BORDER*SPECIAL_UPSCALER));
// copy data with downscaling : (subSampling)
Vector2D<int32_t> tmpPos(0,0);
for (tmpPos.y = 0; tmpPos.y<m_listElement[iii].property.m_sizeTexture.y+2*SPECIAL_BORDER; tmpPos.y++) {
for (tmpPos.x = 0; tmpPos.x<m_listElement[iii].property.m_sizeTexture.x+2*SPECIAL_BORDER; tmpPos.x++) {
m_data.Set(glyphPosition + tmpPos, tmpUpScaledImage.Get(tmpPos*Vector2D<int32_t>(8,8) + Vector2D<int32_t>(4,4)) );
m_data.Set(glyphPosition + tmpPos, tmpUpScaledImage.Get(tmpPos*Vector2D<int32_t>(SPECIAL_UPSCALER,SPECIAL_UPSCALER) + Vector2D<int32_t>(SPECIAL_UPSCALER/2,SPECIAL_UPSCALER/2)) );
}
}
@ -249,7 +250,7 @@ int32_t ewol::DistantFieldFont::Draw(Vector2D<float> textPos,
totalSize += ret;
}
#if 1
#if 0
// To display the texture ...
{
/* Bitmap position
@ -352,10 +353,10 @@ int32_t ewol::DistantFieldFont::Draw(Vector2D<float> textPos,
* | |
* yD *------*
*/
float dxA = posDrawX + m_listElement[charIndex].property.m_bearing.x;
float dxB = posDrawX + m_listElement[charIndex].property.m_bearing.x + m_listElement[charIndex].property.m_sizeTexture.x;
float dyC = textPos.y + m_listElement[charIndex].property.m_bearing.y + m_height - m_size;
float dyD = dyC - m_listElement[charIndex].property.m_sizeTexture.y;
float dxA = -SPECIAL_BORDER + posDrawX + m_listElement[charIndex].property.m_bearing.x;
float dxB = +SPECIAL_BORDER + posDrawX + m_listElement[charIndex].property.m_bearing.x + m_listElement[charIndex].property.m_sizeTexture.x;
float dyC = +SPECIAL_BORDER + textPos.y + m_listElement[charIndex].property.m_bearing.y + m_height - m_size;
float dyD = -SPECIAL_BORDER + dyC - m_listElement[charIndex].property.m_sizeTexture.y;
float tuA = m_listElement[charIndex].posStart.u;
float tuB = m_listElement[charIndex].posStop.u;

View File

@ -72,7 +72,7 @@ void ewol::OObject2DColored::Draw(void)
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// position :
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
// color :

View File

@ -138,7 +138,7 @@ void ewol::OObject2DTextColored::Draw(void)
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
// position :

View File

@ -31,6 +31,12 @@
#undef __class__
#define __class__ "ewol::OObject2DTextShader"
float DF_SoftEdge_min = 0.45;
float DF_SoftEdge_max = 0.55;
int32_t DF_SoftEdge = 0;
void ewol::OObject2DTextShader::SetFontProperty(etk::UString fontName, int32_t fontSize)
{
// remove old one
@ -81,6 +87,9 @@ ewol::OObject2DTextShader::OObject2DTextShader(etk::UString fontName, int32_t si
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
m_GLSoftEdgeMin = m_GLprogram->GetUniform("EW_SoftEdgeMin");
m_GLSoftEdgeMax = m_GLprogram->GetUniform("EW_SoftEdgeMax");
m_GLSoftEdge = m_GLprogram->GetUniform("EW_SoftEdge");
}
}
@ -100,6 +109,9 @@ ewol::OObject2DTextShader::OObject2DTextShader(void) :
m_GLtexture = m_GLprogram->GetAttribute("EW_texture2d");
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
m_GLtexID = m_GLprogram->GetUniform("EW_texID");
m_GLSoftEdgeMin = m_GLprogram->GetUniform("EW_SoftEdgeMin");
m_GLSoftEdgeMax = m_GLprogram->GetUniform("EW_SoftEdgeMax");
m_GLSoftEdge = m_GLprogram->GetUniform("EW_SoftEdge");
}
}
@ -131,7 +143,7 @@ void ewol::OObject2DTextShader::Draw(void)
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
m_GLprogram->SetTexture0(m_GLtexID, m_font->GetId());
// position :
@ -140,6 +152,10 @@ void ewol::OObject2DTextShader::Draw(void)
m_GLprogram->SendAttribute(m_GLtexture, 2/*u,v*/, &m_coordTex[0]);
// color :
m_GLprogram->SendAttribute(m_GLColor, 4/*r,g,b,a*/, &m_coordColor[0]);
// set some other specific properties :
m_GLprogram->Uniform1f(m_GLSoftEdgeMin, DF_SoftEdge_min);
m_GLprogram->Uniform1f(m_GLSoftEdgeMax, DF_SoftEdge_max);
m_GLprogram->Uniform1i(m_GLSoftEdge, DF_SoftEdge);
// Request the draw od the elements :
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
m_GLprogram->UnUse();

View File

@ -51,12 +51,19 @@ namespace ewol {
int32_t m_GLColor;
int32_t m_GLtexture;
int32_t m_GLtexID;
ewol::DistantFieldFont* m_font; //!< ewol font system
int32_t m_GLSoftEdgeMin;
int32_t m_GLSoftEdgeMax;
int32_t m_GLSoftEdge;
ewol::DistantFieldFont* m_font; //!< ewol font system
draw::Color m_color; //!< tmp text color ...
etk::Vector<Vector2D<float> > m_coord; //!< internal coord of the object
etk::Vector<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
etk::Vector<draw::Colorf> m_coordColor; //!< internal color of the different point
bool m_bold;
bool m_italic;
public:
void SetBold(bool newVal) { m_bold=newVal; };
void SetItalic(bool newVal) { m_italic=newVal; };
void SetFont(etk::UString fontName);
void SetSize(int32_t fontSize);
void SetFontProperty(etk::UString fontName, int32_t fontSize);

View File

@ -78,7 +78,7 @@ void ewol::OObject2DTextured::Draw(void)
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
// position :

View File

@ -78,7 +78,7 @@ void ewol::OObject3DTextured::Draw(void)
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->SendUniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// TextureID
m_GLprogram->SetTexture0(m_GLtexID, m_resource->GetId());
// position :

View File

@ -85,6 +85,7 @@ ewol::Program::Program(etk::UString& filename) :
}
ewol::Program::~Program(void)
{
for (int32_t iii=0; iii<m_shaderList.Size(); iii++) {
@ -100,6 +101,12 @@ ewol::Program::~Program(void)
m_hasTexture = false;
}
void ewol::Program::Reload(void)
{
// TODO ...
}
static void checkGlError(const char* op, int32_t localLine)
{
for (GLint error = glGetError(); error; error = glGetError()) {
@ -203,19 +210,244 @@ void ewol::Program::SendAttribute(int32_t idElem, int32_t nbElement, void* point
}
void ewol::Program::SendUniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Matrix _matrix)
void ewol::Program::UniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Matrix _matrix, bool transpose)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
// note : Android des not supported the transposition of the matrix, then we will done it oursef:
_matrix.Transpose();
if (true == transpose) {
_matrix.Transpose();
}
glUniformMatrix4fv(m_elementList[idElem].m_elementId, nbElement, GL_FALSE, _matrix.m_mat);
checkGlError("glUniformMatrix4fv", __LINE__);
}
void ewol::Program::Uniform1f(int32_t idElem, float value1)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform1f(m_elementList[idElem].m_elementId, value1);
checkGlError("glUniform1f", __LINE__);
}
void ewol::Program::Uniform2f(int32_t idElem, float value1, float value2)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform2f(m_elementList[idElem].m_elementId, value1, value2);
checkGlError("glUniform2f", __LINE__);
}
void ewol::Program::Uniform3f(int32_t idElem, float value1, float value2, float value3)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform3f(m_elementList[idElem].m_elementId, value1, value2, value3);
checkGlError("glUniform3f", __LINE__);
}
void ewol::Program::Uniform4f(int32_t idElem, float value1, float value2, float value3, float value4)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform4f(m_elementList[idElem].m_elementId, value1, value2, value3, value4);
checkGlError("glUniform4f", __LINE__);
}
void ewol::Program::Uniform1i(int32_t idElem, int32_t value1)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform1i(m_elementList[idElem].m_elementId, value1);
checkGlError("glUniform1i", __LINE__);
}
void ewol::Program::Uniform2i(int32_t idElem, int32_t value1, int32_t value2)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform2i(m_elementList[idElem].m_elementId, value1, value2);
checkGlError("glUniform2i", __LINE__);
}
void ewol::Program::Uniform3i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform3i(m_elementList[idElem].m_elementId, value1, value2, value3);
checkGlError("glUniform3i", __LINE__);
}
void ewol::Program::Uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
glUniform4i(m_elementList[idElem].m_elementId, value1, value2, value3, value4);
checkGlError("glUniform4i", __LINE__);
}
void ewol::Program::Uniform1fv(int32_t idElem, int32_t nbElement, float *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform1fv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform1fv", __LINE__);
}
void ewol::Program::Uniform2fv(int32_t idElem, int32_t nbElement, float *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform2fv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform2fv", __LINE__);
}
void ewol::Program::Uniform3fv(int32_t idElem, int32_t nbElement, float *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform3fv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform3fv", __LINE__);
}
void ewol::Program::Uniform4fv(int32_t idElem, int32_t nbElement, float *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform4fv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform4fv", __LINE__);
}
void ewol::Program::Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform1iv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform1fi", __LINE__);
}
void ewol::Program::Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform2iv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform2fi", __LINE__);
}
void ewol::Program::Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform3iv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform3fi", __LINE__);
}
void ewol::Program::Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value)
{
if (idElem<0 || idElem>m_elementList.Size()) {
EWOL_ERROR("idElem = " << idElem << " not in [0.." << (m_elementList.Size()-1) << "]");
return;
}
if (0==nbElement) {
EWOL_ERROR("No element to send at open GL ...");
return;
}
if (NULL==value) {
EWOL_ERROR("NULL Input pointer to send at open GL ...");
return;
}
glUniform4iv(m_elementList[idElem].m_elementId, nbElement, value);
checkGlError("glUniform4fi", __LINE__);
}
void ewol::Program::Use(void)
{
glUseProgram(m_program);

View File

@ -52,11 +52,34 @@
Program(etk::UString& filename);
virtual ~Program(void);
const char* GetType(void) { return "ewol::Program"; };
virtual void Reload(void);
bool CreateAndLink(void);
int32_t GetAttribute(etk::UString tmpElement);
void SendAttribute(int32_t idElem, int32_t nbElement, void* pointer, int32_t jumpBetweenSample=0);
int32_t GetUniform(etk::UString tmpElement);
void SendUniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Matrix pointer);
void UniformMatrix4fv(int32_t idElem, int32_t nbElement, etk::Matrix pointer, bool transpose=true);
void Uniform1f(int32_t idElem, float value1);
void Uniform2f(int32_t idElem, float value1, float value2);
void Uniform3f(int32_t idElem, float value1, float value2, float value3);
void Uniform4f(int32_t idElem, float value1, float value2, float value3, float value4);
void Uniform1i(int32_t idElem, int32_t value1);
void Uniform2i(int32_t idElem, int32_t value1, int32_t value2);
void Uniform3i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3);
void Uniform4i(int32_t idElem, int32_t value1, int32_t value2, int32_t value3, int32_t value4);
void Uniform1fv(int32_t idElem, int32_t nbElement, float *value);
void Uniform2fv(int32_t idElem, int32_t nbElement, float *value);
void Uniform3fv(int32_t idElem, int32_t nbElement, float *value);
void Uniform4fv(int32_t idElem, int32_t nbElement, float *value);
void Uniform1iv(int32_t idElem, int32_t nbElement, int32_t *value);
void Uniform2iv(int32_t idElem, int32_t nbElement, int32_t *value);
void Uniform3iv(int32_t idElem, int32_t nbElement, int32_t *value);
void Uniform4iv(int32_t idElem, int32_t nbElement, int32_t *value);
void Use(void);
void SetTexture0(int32_t idElem, GLint textureOpenGlID);
void UnUse(void);

View File

@ -139,13 +139,13 @@ bool ewol::Slider::OnEventInput(ewol::inputType_te type, int32_t IdInput, eventI
|| ewol::EVENT_INPUT_TYPE_TRIPLE == typeEvent
|| ewol::EVENT_INPUT_TYPE_MOVE == typeEvent) {
// get the new position :
EWOL_DEBUG("Event on Slider (" << relativePos.x << "," << relativePos.y << ")");
EWOL_VERBOSE("Event on Slider (" << relativePos.x << "," << relativePos.y << ")");
int32_t oldValue = m_value;
m_value = m_min + (float)(relativePos.x - dotRadius) / (float)(m_size.x-2*dotRadius) * (float)(m_max-m_min);
m_value = etk_max(etk_min(m_value, m_max), m_min);
if (oldValue != m_value) {
EWOL_DEBUG(" new value : " << m_value << " in [" << m_min << ".." << m_max << "]");
GenerateEventId(ewolEventSliderChange);
GenerateEventId(ewolEventSliderChange, m_value);
MarkToRedraw();
}
return true;

View File

@ -100,6 +100,7 @@ ewol::Widget::Widget(void)
m_canFocus = false;
m_hasFocus = false;
m_hide = false;
m_zoom = 1.0;
}
@ -249,8 +250,9 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
m_size.y);
#ifdef __VIDEO__OPENGL_ES_2
etk::Matrix tmpTranslate = etk::matrix::Translate(-tmpclipX/2 - (tmpOriginX-m_origin.x), -m_size.y/2, -1.0);
etk::Matrix tmpScale = etk::matrix::Scale(m_zoom, m_zoom, 1.0);
etk::Matrix tmpProjection = etk::matrix::Perspective(-tmpclipX/2, tmpclipX/2, -m_size.y/2, m_size.y/2, -1, 1);
etk::Matrix tmpMat = tmpProjection * tmpTranslate;
etk::Matrix tmpMat = tmpProjection * tmpScale * tmpTranslate;
// set internal matrix system :
ewol::openGL::SetMatrix(tmpMat);
#else
@ -277,9 +279,9 @@ void ewol::Widget::GenDraw(DrawProperty displayProp)
#ifdef __VIDEO__OPENGL_ES_2
#if 1
etk::Matrix tmpTranslate = etk::matrix::Translate(-m_size.x/2, -m_size.y/2, -1.0);
/*etk::Matrix tmpScale = etk::matrix::Scale(5, 5, 1.0);*/
etk::Matrix tmpScale = etk::matrix::Scale(m_zoom, m_zoom, 1.0);
etk::Matrix tmpProjection = etk::matrix::Perspective(-m_size.x/2, m_size.x/2, -m_size.y/2, m_size.y/2, -1, 1);
etk::Matrix tmpMat = tmpProjection * /*tmpScale * */ tmpTranslate;
etk::Matrix tmpMat = tmpProjection * tmpScale * tmpTranslate;
#else
etk::Matrix tmpMat = etk::matrix::Perspective(0, m_size.x, 0, m_size.y, -1, 1);
#endif

View File

@ -139,6 +139,7 @@ namespace ewol {
bool m_hide; //!< hide a widget on the display
protected:
// internal element calculated by the system
float m_zoom; //!< generic widget zoom
Vector2D<float> m_origin; //!< internal ... I do not really known how i can use it ...
Vector2D<float> m_size; //!< internal : current size of the widget
Vector2D<float> m_minSize; //!< user define the minimum size of the widget
@ -149,6 +150,18 @@ namespace ewol {
bool m_userFillX;
bool m_userFillY;
public:
/**
* @brief Set the zoom property of the widget
* @param[in] newVal newZoom value
* @return ---
*/
void SetZoom(float newVal) { m_zoom = newVal; MarkToRedraw(); };
/**
* @brief Get the zoom property of the widget
* @param ---
* @return the current zoom value
*/
float GetZoom(void) { return m_zoom; };
/**
* @brief Set origin at the widget (must be an parrent widget that set this parameter).
* This represent the absolute origin in the program windows

View File

@ -39,7 +39,6 @@ ewol::WidgetScrooled::WidgetScrooled(void)
m_highSpeedMode = SCROLL_DISABLE;
m_scroollingMode = SCROLL_MODE_NORMAL;
m_highSpeedType = ewol::INPUT_TYPE_UNKNOW;
m_zoom = 1.0;
m_highSpeedButton = -1;
m_limitScrolling = 0.5;
}
@ -137,18 +136,30 @@ bool ewol::WidgetScrooled::OnEventInput(ewol::inputType_te type, int32_t IdInput
}
return false;
} else if (4 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
if(m_size.y < m_maxSize.y) {
m_originScrooled.y -= m_pixelScrolling;
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
MarkToRedraw();
return true;
if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*1.1;
zoom = etk_avg(0.1, zoom, 5000);
SetZoom(zoom);
} else {
if(m_size.y < m_maxSize.y) {
m_originScrooled.y -= m_pixelScrolling;
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
MarkToRedraw();
return true;
}
}
} else if (5 == IdInput && ewol::EVENT_INPUT_TYPE_UP == typeEvent) {
if(m_size.y < m_maxSize.y) {
m_originScrooled.y += m_pixelScrolling;
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
MarkToRedraw();
return true;
if (true == ewol::IsSetCtrl()) {
float zoom = GetZoom()*0.9;
zoom = etk_avg(0.1, zoom, 5000);
SetZoom(zoom);
} else {
if(m_size.y < m_maxSize.y) {
m_originScrooled.y += m_pixelScrolling;
m_originScrooled.y = etk_avg(0, m_originScrooled.y, (m_maxSize.y - m_size.y*m_limitScrolling));
MarkToRedraw();
return true;
}
}
}else if (2 == IdInput) {
if (ewol::EVENT_INPUT_TYPE_DOWN == typeEvent) {

View File

@ -53,7 +53,6 @@ namespace ewol {
protected:
Vector2D<float> m_originScrooled;
Vector2D<float> m_maxSize;
float m_zoom; //!< current zoom on the display
float m_limitScrolling;
private:
scrollingMode_te m_scroollingMode; //!< mode of management of the scrooling

View File

@ -5,6 +5,9 @@ precision mediump int;
// Input :
uniform sampler2D EW_texID;
uniform float EW_SoftEdgeMin;
uniform float EW_SoftEdgeMax;
uniform int EW_SoftEdge;
varying vec2 f_texcoord;
varying vec4 f_color;
@ -24,7 +27,15 @@ void main(void) {
}
*/
outColor = f_color;// * tmpcolor[3];
outColor[3] = smoothstep(0.45, 0.55, tmpcolor[3]);
if (1==EW_SoftEdge) {
outColor[3] = smoothstep(EW_SoftEdgeMin, EW_SoftEdgeMax, tmpcolor[3]);
} else {
if (tmpcolor[3]>0.5) {
outColor[3] = 1.0;
} else {
outColor[3] = 0.0;
}
}
//outColor = vec4(0,0,0,0);
//outColor[3] = tmpcolor[3];
gl_FragColor = outColor;