[DEV] add a basic theme changer and the config file for the button parameter ==> must work on it

This commit is contained in:
Edouard DUPIN 2012-11-06 22:35:00 +01:00
parent 1b7163e79c
commit efe4386c3a
16 changed files with 604 additions and 108 deletions

View File

@ -29,6 +29,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <etk/tool.h>
#include <etk/Vector.h>
extern "C" {
// file browsing ...
@ -569,10 +570,12 @@ void etk::FSNode::GenerateFileSystemPath(void)
basicName = m_userFileName.Extract(firstPos+1);
}
TK_DBG_MODE(" THEME party : \"" << themeName << "\" => \"" << basicName << "\"");
themeName = etk::theme::GetName(themeName);
TK_DBG_MODE(" ==> theme Folder \"" << themeName << "\"");
// search the corect folder :
if (themeName == "") {
TK_WARNING("no theme name detected : set it to \"default\"");
} else {
} else if (themeName != "default") {
// Selected theme :
// check in the user data :
m_systemFileName = baseFolderDataUser + "theme/" + themeName + "/" + basicName;
@ -1245,3 +1248,63 @@ bool etk::FSNode::FileSeek(long int offset, int origin)
}
}
// TODO : Add an INIT to reset all allocated parameter :
class tmpThemeElement
{
public:
etk::UString refName;
etk::UString folderName;
};
static etk::Vector<tmpThemeElement*> g_listTheme;
// set the Folder of a subset of a theme ...
void etk::theme::SetName(etk::UString refName, etk::UString folderName)
{
for(int32_t iii=0; iii<g_listTheme.Size(); iii++) {
if (NULL != g_listTheme[iii]) {
if (g_listTheme[iii]->refName==refName) {
g_listTheme[iii]->folderName = folderName;
// action done
return;
}
}
}
// we did not find it ...
tmpThemeElement* tmpp = new tmpThemeElement();
if (NULL==tmpp) {
TK_ERROR("pb to add a reference theme");
return;
}
tmpp->refName = refName;
tmpp->folderName = folderName;
g_listTheme.PushBack(tmpp);
}
// get the folder from a Reference theme
etk::UString etk::theme::GetName(etk::UString refName)
{
for(int32_t iii=0; iii<g_listTheme.Size(); iii++) {
if (NULL != g_listTheme[iii]) {
if (g_listTheme[iii]->refName==refName) {
return g_listTheme[iii]->folderName;
}
}
}
// We did not find the theme
return refName;
}
// get the list of all the theme folder availlable in the user Home/appl
etk::Vector<etk::UString> etk::theme::List(void)
{
etk::Vector<etk::UString> tmpp;
return tmpp;
// TODO :
}

View File

@ -228,7 +228,16 @@ namespace etk
void InitDefaultFolder(const char * applName);
etk::UString GetUserHomeFolder(void);
namespace theme
{
// TODO : Add an INIT ...
// set the Folder of a subset of a theme ...
void SetName(etk::UString refName, etk::UString folderName);
// get the folder from a Reference theme
etk::UString GetName(etk::UString refName);
// get the list of all the theme folder availlable in the user Home/appl
etk::Vector<etk::UString> List(void);
};
};
#endif

View File

@ -374,6 +374,24 @@ bool ewol::resource::Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& o
return true;
}
bool ewol::resource::Keep(etk::UString& filename, ewol::SimpleConfigFile*& object)
{
EWOL_INFO("KEEP : SimpleConfig : file : \"" << filename << "\"");
object = static_cast<ewol::SimpleConfigFile*>(LocalKeep(filename));
if (NULL != object) {
return true;
}
// this element create a new one every time ....
object = new ewol::SimpleConfigFile(filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??");
return false;
}
LocalAdd(object);
return true;
}
void ewol::resource::Release(ewol::Resource*& object)
{
@ -464,3 +482,10 @@ void ewol::resource::Release(ewol::MeshObj*& object)
Release(object2);
object = NULL;
}
void ewol::resource::Release(ewol::SimpleConfigFile*& object)
{
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
Release(object2);
object = NULL;
}

View File

@ -31,6 +31,7 @@
#include <ewol/openGL/Shader.h>
#include <ewol/openGL/Program.h>
#include <ewol/openGL/VirtualBufferObject.h>
#include <ewol/SimpleConfigFile.h>
#include <ewol/font/Font.h>
#include <ewol/font/TexturedFont.h>
#include <ewol/font/DistantFieldFont.h>
@ -65,6 +66,7 @@ namespace ewol
bool Keep(etk::UString& filename, ewol::TextureFile*& object, etk::Vector2D<int32_t> size);
bool Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& object);
bool Keep(etk::UString& filename, ewol::MeshObj*& object);
bool Keep(etk::UString& filename, ewol::SimpleConfigFile*& object);
void Release(ewol::Resource*& object);
void Release(ewol::TexturedFont*& object);
@ -78,6 +80,7 @@ namespace ewol
void Release(ewol::TextureFile*& object);
void Release(ewol::VirtualBufferObject*& object);
void Release(ewol::MeshObj*& object);
void Release(ewol::SimpleConfigFile*& object);
}
};

View File

@ -0,0 +1,166 @@
/**
*******************************************************************************
* @file ewol/impleConfigFile.cpp
* @brief ewol basic file configuration system (Sources)
* @author Edouard DUPIN
* @date 06/11/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/os/FSNode.h>
#include <ewol/Debug.h>
#include <ewol/SimpleConfigFile.h>
void ewol::SimpleConfigElement::Parse(etk::UString value)
{
char* tmp = value.c_str();
m_valueInt = 0;
m_valuefloat = 0;
sscanf(tmp, "%d", &m_valueInt);
sscanf(tmp, "%f", &m_valuefloat);
}
ewol::SimpleConfigFile::SimpleConfigFile(etk::UString& filename):
ewol::Resource(filename)
{
EWOL_DEBUG("SFP : load \"" << filename << "\"");
Reload();
}
ewol::SimpleConfigFile::~SimpleConfigFile(void)
{
// remove all element
for (int32_t iii=0; iii<m_list.Size(); iii++){
if (NULL != m_list[iii]) {
delete(m_list[iii]);
m_list[iii] = NULL;
}
}
m_list.Clear();
}
void ewol::SimpleConfigFile::Reload(void)
{
// Reset all parameters
for (int32_t iii=0; iii<m_list.Size(); iii++){
if (NULL != m_list[iii]) {
m_list[iii]->Parse("");
}
}
// acess of the file :
etk::FSNode file(m_name);
if (false == file.Exist()) {
EWOL_ERROR("File does not Exist : \"" << file << "\"");
return;
}
etk::UString fileExtention = file.FileGetExtention();
if (fileExtention != "conf") {
EWOL_ERROR("File does not have extention \".prog\" for program but : \"" << fileExtention << "\"");
return;
}
if (false == file.FileOpenRead()) {
EWOL_ERROR("Can not open the file : " << file);
return;
}
#define MAX_LINE_SIZE (2048)
char tmpData[MAX_LINE_SIZE];
while (file.FileGets(tmpData, MAX_LINE_SIZE) != NULL) {
int32_t len = strlen(tmpData);
if( tmpData[len-1] == '\n'
|| tmpData[len-1] == '\r') {
tmpData[len-1] = '\0';
len--;
}
//EWOL_DEBUG(" Read data : \"" << tmpData << "\"");
if (len == 0) {
continue;
}
etk::UString tmpData2(tmpData);
etk::UString tmppp("#");
if (true == tmpData2.StartWith(tmppp)) {
// comment ...
continue;
}
tmppp="//";
if (true == tmpData2.StartWith(tmppp)) {
// comment ...
continue;
}
// get parameters :
int32_t pos = tmpData2.FindForward('=');
if (pos == -1){
//the element "=" is not find ...
continue;
}
etk::UString paramName = tmpData2.Extract(0, pos);
etk::UString paramValue = tmpData2.Extract(pos+1, 0x7FFFF);
EWOL_DEBUG(" param name=\"" << paramName << "\" val=\"" << paramValue << "\"");
// check if the parameters existed :
bool findParam = false;
for (int32_t iii=0; iii<m_list.Size(); iii++){
if (NULL != m_list[iii]) {
if (m_list[iii]->m_paramName == paramName) {
m_list[iii]->Parse(paramValue);
findParam = true;
// stop parsing ...
break;
}
}
}
if (false == findParam) {
ewol::SimpleConfigElement* tmpElement = new ewol::SimpleConfigElement(paramName);
if (NULL == tmpElement) {
EWOL_DEBUG("error while allocation");
} else {
tmpElement->Parse(paramValue);
m_list.PushBack(tmpElement);
}
}
}
// close the file:
file.FileClose();
}
int32_t ewol::SimpleConfigFile::Request(etk::UString paramName)
{
// check if the parameters existed :
for (int32_t iii=0; iii<m_list.Size(); iii++){
if (NULL != m_list[iii]) {
if (m_list[iii]->m_paramName == paramName) {
return iii;
}
}
}
ewol::SimpleConfigElement* tmpElement = new ewol::SimpleConfigElement(paramName);
if (NULL == tmpElement) {
EWOL_DEBUG("error while allocation");
} else {
m_list.PushBack(tmpElement);
}
return m_list.Size()-1;
}

View File

@ -0,0 +1,72 @@
/**
*******************************************************************************
* @file ewol/impleConfigFile.h
* @brief ewol basic file configuration system (header)
* @author Edouard DUPIN
* @date 06/11/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __SIMPLE_CONFIG_FILE_H__
#define __SIMPLE_CONFIG_FILE_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/Resource.h>
namespace ewol
{
class SimpleConfigElement
{
public:
etk::UString m_paramName;
private:
etk::UString m_value;
int32_t m_valueInt;
float m_valuefloat;
public:
SimpleConfigElement(etk::UString name) :
m_paramName(name),
m_value(""),
m_valueInt(0),
m_valuefloat(0.0) { };
~SimpleConfigElement(void) { };
void Parse(etk::UString value);
int32_t GetInteger(void) { return m_valueInt; };
float GetFloat(void) { return m_valuefloat; };
etk::UString& GetString(void) { return m_value; };
};
class SimpleConfigFile : public ewol::Resource
{
private:
etk::Vector<ewol::SimpleConfigElement*> m_list;
public:
SimpleConfigFile(etk::UString& filename);
virtual ~SimpleConfigFile(void);
const char* GetType(void) { return "ewol::SimpleConfigFile"; };
void Reload(void);
int32_t Request(etk::UString paramName);
int32_t GetInteger(int32_t id) { return m_list[id]->GetInteger(); };
float GetFloat(int32_t id) { return m_list[id]->GetFloat(); };
etk::UString& GetString(int32_t id) { return m_list[id]->GetString(); };
};
};
#endif

View File

@ -60,7 +60,7 @@ void ewol::Button::Init(void)
AddEventId(ewolEventButtonLeave);
m_hasAnImage = false;
m_alignement = ewol::TEXT_ALIGN_CENTER;
/*
#ifdef __TARGET_OS__Android
m_padding.y = 12;
m_padding.x = 12;
@ -68,24 +68,31 @@ void ewol::Button::Init(void)
m_padding.y = 4;
m_padding.x = 4;
#endif
*/
m_textColorFg = draw::color::black;
m_textColorBg = draw::color::black;
m_textColorBg.a = 0x3F;
SetCanHaveFocus(true);
#ifdef __VIDEO__OPENGL_ES_2
etk::UString tmpString("THEME:rounded:widgetButton.prog");
etk::UString tmpString("THEME:GUI:widgetButton.conf");
if (true == ewol::resource::Keep(tmpString, m_config) ) {
m_confIdPaddingX = m_config->Request("PaddingX");
m_confIdPaddingY = m_config->Request("PaddingY");
m_confIdChangeTime = m_config->Request("ChangeTime");
}
tmpString ="THEME:GUI:widgetButton.prog";
// get the shader resource :
m_GLPosition = 0;
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
m_GLsizeBorder = m_GLprogram->GetUniform("EW_sizeBorder");
m_GLsizePadding = m_GLprogram->GetUniform("EW_sizePadding");
m_GLsize = m_GLprogram->GetUniform("EW_size");
m_GLposText = m_GLprogram->GetUniform("EW_posText");
m_GLstate = m_GLprogram->GetUniform("EW_state");
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
// Widget property ==> for the Vertex shader
m_GLwidgetProperty.m_size = m_GLprogram->GetUniform("EW_widgetProperty.size");
m_GLwidgetProperty.m_insidePos = m_GLprogram->GetUniform("EW_widgetProperty.insidePos");
m_GLwidgetProperty.m_insideSize = m_GLprogram->GetUniform("EW_widgetProperty.insideSize");
// status property ==> for the fragment shader
m_GLstatus.m_stateOld = m_GLprogram->GetUniform("EW_status.stateOld");
m_GLstatus.m_stateNew = m_GLprogram->GetUniform("EW_status.stateNew");
m_GLstatus.m_transition = m_GLprogram->GetUniform("EW_status.transition");
}
#endif
}
@ -119,22 +126,19 @@ void ewol::Button::SetImage(etk::UString imageName)
MarkToRedraw();
}
void ewol::Button::SetPadding(etk::Vector2D<float> newPadding)
{
m_padding = newPadding;
}
bool ewol::Button::CalculateMinSize(void)
{
etk::Vector2D<int32_t> padding;
padding.x = m_config->GetInteger(m_confIdPaddingX);
padding.y = m_config->GetInteger(m_confIdPaddingY);
etk::Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
m_minSize.x = m_padding.x*2 + minSize.x;
m_minSize.y = m_padding.y*2 + minSize.y;
m_minSize.x = padding.x*2 + minSize.x;
m_minSize.y = padding.y*2 + minSize.y;
// Add the image element ...
if (true == m_hasAnImage) {
//m_minSize.x += -m_padding.x + m_padding.y*2 + minHeight;
//m_minSize.y += m_padding.y*2;
m_minSize.x += m_padding.x + minSize.y;
m_minSize.x += padding.x + minSize.y;
}
MarkToRedraw();
@ -200,29 +204,32 @@ bool ewol::Button::GetValue(void)
void ewol::Button::OnDraw(DrawProperty& displayProp)
{
#ifdef __VIDEO__OPENGL_ES_2
if (m_GLprogram==NULL) {
EWOL_ERROR("No shader ...");
return;
}
//glScalef(m_scaling.x, m_scaling.y, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// position :
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
// all entry parameters :
m_GLprogram->Uniform1f(m_GLsizeBorder, 3);
m_GLprogram->Uniform1f(m_GLsizePadding, m_padding.x);
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
m_GLprogram->Uniform1i(m_GLstate, 0);
// Request the draw of the elements :
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
m_GLprogram->UnUse();
#endif
m_oObjectDecoration.Draw();
if (m_GLprogram==NULL) {
EWOL_ERROR("No shader ...");
return;
}
//glScalef(m_scaling.x, m_scaling.y, 1.0);
m_GLprogram->Use();
// set Matrix : translation/positionMatrix
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
// position :
// Note : Must be all the time a [-1..1] square ...
// TODO : plop ...
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
// all entry parameters :
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_size, 1, &m_size.x);
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_insidePos, 1, &m_widgetProperty.m_insidePos.x);
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_insideSize, 1, &m_widgetProperty.m_insideSize.x);
m_GLprogram->Uniform1i(m_GLstatus.m_stateOld, m_status.m_stateOld);
m_GLprogram->Uniform1i(m_GLstatus.m_stateNew, m_status.m_stateNew);
m_GLprogram->Uniform1f(m_GLstatus.m_transition, m_status.m_transition);
// Request the draw of the elements :
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
m_GLprogram->UnUse();
if (NULL != m_oObjectImage) {
m_oObjectImage->Draw();
}
@ -232,7 +239,11 @@ void ewol::Button::OnDraw(DrawProperty& displayProp)
void ewol::Button::OnRegenerateDisplay(void)
{
if (true == NeedRedraw()) {
m_oObjectDecoration.Clear();
etk::Vector2D<int32_t> padding;
padding.x = m_config->GetInteger(m_confIdPaddingX);
padding.y = m_config->GetInteger(m_confIdPaddingY);
m_oObjectText.Clear();
if (NULL != m_oObjectImage) {
m_oObjectImage->Clear();
@ -242,24 +253,24 @@ void ewol::Button::OnRegenerateDisplay(void)
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
// no change for the text orogin :
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + m_padding.x;
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + m_padding.y;
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + padding.x;
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + padding.y;
if (true==m_userFill.x) {
tmpSizeX = m_size.x;
tmpOriginX = 0;
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
tmpTextOriginX = m_padding.x;
tmpTextOriginX = padding.x;
}
}
if (true==m_userFill.y) {
tmpSizeY = m_size.y;
tmpOriginY = 0;
}
tmpOriginX += m_padding.x;
tmpOriginY += m_padding.y;
tmpSizeX -= 2*m_padding.x;
tmpSizeY -= 2*m_padding.y;
tmpOriginX += padding.x;
tmpOriginY += padding.y;
tmpSizeX -= 2*padding.x;
tmpSizeY -= 2*padding.y;
etk::Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
@ -274,23 +285,20 @@ void ewol::Button::OnRegenerateDisplay(void)
}
*/
clipping_ts drawClipping;
drawClipping.x = m_padding.x;
drawClipping.y = m_padding.y;
drawClipping.w = m_size.x - 2*m_padding.x;
drawClipping.h = m_size.y - 2*m_padding.y;
drawClipping.x = padding.x;
drawClipping.y = padding.y;
drawClipping.w = m_size.x - 2*padding.x;
drawClipping.h = m_size.y - 2*padding.y;
//EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
#ifndef __VIDEO__OPENGL_ES_2
m_oObjectDecoration.SetColor(m_textColorBg);
tmpOriginX -= m_padding.x/2;
tmpOriginY -= m_padding.y/2;
tmpSizeX += m_padding.x/1;
tmpSizeY += m_padding.y/1;
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
#else
Rectangle(0, 0, m_size.x, m_size.y);
#endif
m_status.m_stateOld = 0;
m_status.m_stateNew = 0;
m_status.m_transition = 0;
m_widgetProperty.m_insidePos = textPos;
m_widgetProperty.m_insideSize = m_oObjectText.GetSize(m_label);
Rectangle(0, 0, m_size.x, m_size.y);
}
}

View File

@ -36,6 +36,42 @@ extern const char * const ewolEventButtonUp;
extern const char * const ewolEventButtonEnter;
extern const char * const ewolEventButtonLeave;
namespace ewol {
class WidgetPosProperty
{
public:
etk::Vector2D<float> m_insidePos;
etk::Vector2D<float> m_insideSize;
};
class GLWidgetPosProperty
{
public:
int32_t m_size;
int32_t m_insidePos;
int32_t m_insideSize;
};
// DATA
class WidgetStateProperty
{
public:
int32_t m_stateOld;
int32_t m_stateNew;
float m_transition;
};
// ID of the UNIFORM element
class GLWidgetStateProperty
{
public:
int32_t m_stateOld;
int32_t m_stateNew;
int32_t m_transition;
};
};
namespace ewol {
typedef enum {
TEXT_ALIGN_LEFT,
@ -45,31 +81,34 @@ namespace ewol {
{
private:
#ifdef __VIDEO__OPENGL_ES_2
ewol::Program* m_GLprogram;
int32_t m_GLPosition;
int32_t m_GLMatrix;
int32_t m_GLsizeBorder;
int32_t m_GLsizePadding;
int32_t m_GLsize;
float m_pos[4];
int32_t m_GLposText;
int32_t m_GLstate;
etk::Vector<etk::Vector2D<float> > m_coord; //!< internal coord of the object
draw::Colorf m_color[3];
// External theme config:
ewol::SimpleConfigFile* m_config;
int32_t m_confIdPaddingX;
int32_t m_confIdPaddingY;
int32_t m_confIdChangeTime;
// OpenGL shaders programs:
ewol::Program* m_GLprogram;
int32_t m_GLPosition;
int32_t m_GLMatrix;
// widget property
ewol::GLWidgetPosProperty m_GLwidgetProperty; // id of the uniform
ewol::WidgetPosProperty m_widgetProperty; // structure of this uniform
// state property
ewol::GLWidgetStateProperty m_GLstatus;
ewol::WidgetStateProperty m_status;
etk::Vector<etk::Vector2D<float> > m_coord; //!< internal coord of the object
void SetPoint(float x, float y);
void Rectangle(float x, float y, float w, float h);
#endif
private:
ewol::OObject2DTextColored m_oObjectText;
ewol::OObject2DColored m_oObjectDecoration;
ewol::OObject2DTextured* m_oObjectImage;
bool m_hasAnImage;
etk::UString m_imageSelected;
textAlignement_te m_alignement;
etk::Vector2D<float> m_padding;
etk::UString m_label;
draw::Color m_textColorFg; //!< Text color
draw::Color m_textColorBg; //!< Background color
public:
Button(void);
Button(etk::UString newLabel);
@ -89,8 +128,6 @@ namespace ewol {
void SetValue(bool val);
bool GetValue(void);
void SetAlignement(textAlignement_te typeAlign);
void SetPadding(etk::Vector2D<float> newPadding);
void SetColorBg(draw::Color newColor) { m_textColorBg = newColor; };
void SetColorFg(draw::Color newColor) { m_textColorFg = newColor; };
public:
virtual void OnRegenerateDisplay(void);

View File

@ -69,7 +69,7 @@ void ewol::Entry::Init(void)
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
#ifdef __VIDEO__OPENGL_ES_2
etk::UString tmpString("THEME:rounded:widgetEntry.prog");
etk::UString tmpString("THEME:GUI:widgetEntry.prog");
// get the shader resource :
m_GLPosition = 0;
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {

View File

@ -4,7 +4,8 @@ FILE_LIST = ewol/ewol.cpp \
ewol/ClipBoard.cpp \
ewol/Debug.cpp \
ewol/ShortCutManager.cpp \
ewol/ResourceManager.cpp
ewol/ResourceManager.cpp \
ewol/SimpleConfigFile.cpp
FILE_LIST+= ewol/openGL/openGL.cpp \
ewol/openGL/Shader.cpp \
@ -110,7 +111,13 @@ LOCAL_COPY_FILES := ../../share/textured3D.prog:textured3D.prog \
../../share/theme/rounded/widgetEntry.frag:theme/rounded/widgetEntry.frag \
../../share/theme/rounded/widgetEntry.vert:theme/rounded/widgetEntry.vert \
\
../../share/theme/default/widgetButton.conf:theme/default/widgetButton.conf \
../../share/theme/default/widgetButton.prog:theme/default/widgetButton.prog \
../../share/theme/default/widgetButton.frag:theme/default/widgetButton.frag \
../../share/theme/default/widgetButton.vert:theme/default/widgetButton.vert
../../share/theme/default/widgetButton.vert:theme/default/widgetButton.vert \
\
../../share/theme/rounded/widgetButton.conf:theme/rounded/widgetButton.conf \
../../share/theme/rounded/widgetButton.prog:theme/rounded/widgetButton.prog \
../../share/theme/rounded/widgetButton.frag:theme/rounded/widgetButton.frag \
../../share/theme/rounded/widgetButton.vert:theme/rounded/widgetButton.vert

View File

@ -0,0 +1,11 @@
# padding for the GUI
PaddingX=11
PaddingY=11
# change status in ms
ChangeTime=356

View File

@ -3,37 +3,38 @@ precision mediump float;
precision mediump int;
#endif
uniform float EW_sizeBorder;
uniform float EW_sizePadding;
uniform vec2 EW_size;
uniform vec4 EW_posText;
uniform int EW_state;
/*
struct displayProperty {
vec4 colorBackGround;
vec4 colorForeGround;
vec4 colorBorder;
float sizeBorder;
vec2 sizePaddingOut;
vec2 sizePaddingIn;
vec2 size;
vec2 insidePos;
vec2 insideSize;
};
uniform displayProperty EW_buttonProperty;
*/
struct widgetStateProperty {
int stateOld;
int stateNew;
float transition;
};
uniform displayProperty EW_widgetProperty;
uniform widgetStateProperty EW_status;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
vec4 S_colorBg = vec4(0.0);
vec4 S_colorFg = vec4(0.5,0.5,0.5,0.8);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 5.0;
float S_sizeBorder = 1.0;
void main(void) {
float specialBorder = EW_sizeBorder+EW_sizePadding;
vec2 endStart = EW_size - vec2(EW_sizePadding) - vec2(EW_sizeBorder);
vec2 endStop = EW_size - vec2(EW_sizePadding);
if( v_position.x> EW_sizePadding
&& v_position.y> EW_sizePadding
float specialBorder = S_sizeBorder+S_sizePadding;
vec2 endStart = EW_widgetProperty.size - vec2(S_sizePadding) - vec2(S_sizeBorder);
vec2 endStop = EW_widgetProperty.size - vec2(S_sizePadding);
if( v_position.x> S_sizePadding
&& v_position.y> S_sizePadding
&& v_position.x<= endStop.x
&& v_position.y<= endStop.y
) {

View File

@ -0,0 +1,11 @@
# padding for the GUI
PaddingX=14
PaddingY=14
# change status in ms
ChangeTime=356

View File

@ -0,0 +1,64 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct displayProperty {
vec2 size;
vec2 insidePos;
vec2 insideSize;
};
struct widgetStateProperty {
int stateOld;
int stateNew;
float transition;
};
uniform displayProperty EW_widgetProperty;
uniform widgetStateProperty EW_status;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
float S_roundedRatio = 10.0;
vec4 S_colorBg = vec4(0.0);
vec4 S_colorFg = vec4(0.5,0.5,0.5,0.3);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 3.0; // must not be NULL
float S_sizeBorder = 1.0;
void main(void) {
// position form center :
vec2 ratio = EW_widgetProperty.size / 2.0;
vec2 positionCenter = v_position-ratio;
if(positionCenter.x<0.0) {
positionCenter.x = -1.0*positionCenter.x;
}
if(positionCenter.y<0.0) {
positionCenter.y = -1.0*positionCenter.y;
}
vec2 ratioHight = ratio - S_sizePadding;
vec2 ratioLow = ratioHight - (S_sizeBorder+S_roundedRatio);
vec2 circleMode = smoothstep(ratioLow, ratioHight, positionCenter);
float tmpDist = sqrt(circleMode.x*circleMode.x + circleMode.y*circleMode.y);
//float distanceInternal = (S_roundedRatio-S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder);
//float distanceExternal = (S_roundedRatio+S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder);;
if(tmpDist <= 0.6 ) {
gl_FragColor = S_colorFg;
} else if(tmpDist <= 0.9) {
float tmpVal = smoothstep(0.7, 0.9, tmpDist);
if (tmpVal<=0.5) {
gl_FragColor = S_colorBorder*(tmpVal*2.0) + S_colorFg*(1.0-tmpVal*2.0);
} else {
gl_FragColor = S_colorBorder*(1.0-(tmpVal-0.5)*2.0) + S_colorBg*((tmpVal-0.5)*2.0);
}
} else {
gl_FragColor = S_colorBg;
}
}

View File

@ -0,0 +1,2 @@
widgetButton.vert
widgetButton.frag

View File

@ -0,0 +1,17 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
// Input :
attribute vec2 EW_coord2d;
uniform mat4 EW_MatrixTransformation;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
void main(void) {
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
}