[DEV] add a basic theme changer and the config file for the button parameter ==> must work on it
This commit is contained in:
parent
1b7163e79c
commit
efe4386c3a
@ -29,6 +29,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <etk/tool.h>
|
#include <etk/tool.h>
|
||||||
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
// file browsing ...
|
// file browsing ...
|
||||||
@ -569,10 +570,12 @@ void etk::FSNode::GenerateFileSystemPath(void)
|
|||||||
basicName = m_userFileName.Extract(firstPos+1);
|
basicName = m_userFileName.Extract(firstPos+1);
|
||||||
}
|
}
|
||||||
TK_DBG_MODE(" THEME party : \"" << themeName << "\" => \"" << basicName << "\"");
|
TK_DBG_MODE(" THEME party : \"" << themeName << "\" => \"" << basicName << "\"");
|
||||||
|
themeName = etk::theme::GetName(themeName);
|
||||||
|
TK_DBG_MODE(" ==> theme Folder \"" << themeName << "\"");
|
||||||
// search the corect folder :
|
// search the corect folder :
|
||||||
if (themeName == "") {
|
if (themeName == "") {
|
||||||
TK_WARNING("no theme name detected : set it to \"default\"");
|
TK_WARNING("no theme name detected : set it to \"default\"");
|
||||||
} else {
|
} else if (themeName != "default") {
|
||||||
// Selected theme :
|
// Selected theme :
|
||||||
// check in the user data :
|
// check in the user data :
|
||||||
m_systemFileName = baseFolderDataUser + "theme/" + themeName + "/" + basicName;
|
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 :
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -228,7 +228,16 @@ namespace etk
|
|||||||
void InitDefaultFolder(const char * applName);
|
void InitDefaultFolder(const char * applName);
|
||||||
etk::UString GetUserHomeFolder(void);
|
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
|
#endif
|
||||||
|
@ -374,6 +374,24 @@ bool ewol::resource::Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& o
|
|||||||
return true;
|
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)
|
void ewol::resource::Release(ewol::Resource*& object)
|
||||||
{
|
{
|
||||||
@ -464,3 +482,10 @@ void ewol::resource::Release(ewol::MeshObj*& object)
|
|||||||
Release(object2);
|
Release(object2);
|
||||||
object = NULL;
|
object = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::resource::Release(ewol::SimpleConfigFile*& object)
|
||||||
|
{
|
||||||
|
ewol::Resource* object2 = static_cast<ewol::Resource*>(object);
|
||||||
|
Release(object2);
|
||||||
|
object = NULL;
|
||||||
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include <ewol/openGL/Shader.h>
|
#include <ewol/openGL/Shader.h>
|
||||||
#include <ewol/openGL/Program.h>
|
#include <ewol/openGL/Program.h>
|
||||||
#include <ewol/openGL/VirtualBufferObject.h>
|
#include <ewol/openGL/VirtualBufferObject.h>
|
||||||
|
#include <ewol/SimpleConfigFile.h>
|
||||||
#include <ewol/font/Font.h>
|
#include <ewol/font/Font.h>
|
||||||
#include <ewol/font/TexturedFont.h>
|
#include <ewol/font/TexturedFont.h>
|
||||||
#include <ewol/font/DistantFieldFont.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& filename, ewol::TextureFile*& object, etk::Vector2D<int32_t> size);
|
||||||
bool Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& object);
|
bool Keep(etk::UString& accesMode, ewol::VirtualBufferObject*& object);
|
||||||
bool Keep(etk::UString& filename, ewol::MeshObj*& 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::Resource*& object);
|
||||||
void Release(ewol::TexturedFont*& object);
|
void Release(ewol::TexturedFont*& object);
|
||||||
@ -78,6 +80,7 @@ namespace ewol
|
|||||||
void Release(ewol::TextureFile*& object);
|
void Release(ewol::TextureFile*& object);
|
||||||
void Release(ewol::VirtualBufferObject*& object);
|
void Release(ewol::VirtualBufferObject*& object);
|
||||||
void Release(ewol::MeshObj*& object);
|
void Release(ewol::MeshObj*& object);
|
||||||
|
void Release(ewol::SimpleConfigFile*& object);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
166
Sources/libewol/ewol/SimpleConfigFile.cpp
Normal file
166
Sources/libewol/ewol/SimpleConfigFile.cpp
Normal 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;
|
||||||
|
}
|
||||||
|
|
72
Sources/libewol/ewol/SimpleConfigFile.h
Normal file
72
Sources/libewol/ewol/SimpleConfigFile.h
Normal 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
|
||||||
|
|
@ -60,7 +60,7 @@ void ewol::Button::Init(void)
|
|||||||
AddEventId(ewolEventButtonLeave);
|
AddEventId(ewolEventButtonLeave);
|
||||||
m_hasAnImage = false;
|
m_hasAnImage = false;
|
||||||
m_alignement = ewol::TEXT_ALIGN_CENTER;
|
m_alignement = ewol::TEXT_ALIGN_CENTER;
|
||||||
|
/*
|
||||||
#ifdef __TARGET_OS__Android
|
#ifdef __TARGET_OS__Android
|
||||||
m_padding.y = 12;
|
m_padding.y = 12;
|
||||||
m_padding.x = 12;
|
m_padding.x = 12;
|
||||||
@ -68,24 +68,31 @@ void ewol::Button::Init(void)
|
|||||||
m_padding.y = 4;
|
m_padding.y = 4;
|
||||||
m_padding.x = 4;
|
m_padding.x = 4;
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
m_textColorFg = draw::color::black;
|
m_textColorFg = draw::color::black;
|
||||||
|
|
||||||
m_textColorBg = draw::color::black;
|
|
||||||
m_textColorBg.a = 0x3F;
|
|
||||||
SetCanHaveFocus(true);
|
SetCanHaveFocus(true);
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#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 :
|
// get the shader resource :
|
||||||
m_GLPosition = 0;
|
m_GLPosition = 0;
|
||||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
m_GLPosition = m_GLprogram->GetAttribute("EW_coord2d");
|
||||||
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
m_GLMatrix = m_GLprogram->GetUniform("EW_MatrixTransformation");
|
||||||
m_GLsizeBorder = m_GLprogram->GetUniform("EW_sizeBorder");
|
// Widget property ==> for the Vertex shader
|
||||||
m_GLsizePadding = m_GLprogram->GetUniform("EW_sizePadding");
|
m_GLwidgetProperty.m_size = m_GLprogram->GetUniform("EW_widgetProperty.size");
|
||||||
m_GLsize = m_GLprogram->GetUniform("EW_size");
|
m_GLwidgetProperty.m_insidePos = m_GLprogram->GetUniform("EW_widgetProperty.insidePos");
|
||||||
m_GLposText = m_GLprogram->GetUniform("EW_posText");
|
m_GLwidgetProperty.m_insideSize = m_GLprogram->GetUniform("EW_widgetProperty.insideSize");
|
||||||
m_GLstate = m_GLprogram->GetUniform("EW_state");
|
// 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
|
#endif
|
||||||
}
|
}
|
||||||
@ -119,22 +126,19 @@ void ewol::Button::SetImage(etk::UString imageName)
|
|||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::Button::SetPadding(etk::Vector2D<float> newPadding)
|
|
||||||
{
|
|
||||||
m_padding = newPadding;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ewol::Button::CalculateMinSize(void)
|
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);
|
etk::Vector2D<int32_t> minSize = m_oObjectText.GetSize(m_label);
|
||||||
m_minSize.x = m_padding.x*2 + minSize.x;
|
m_minSize.x = padding.x*2 + minSize.x;
|
||||||
m_minSize.y = m_padding.y*2 + minSize.y;
|
m_minSize.y = padding.y*2 + minSize.y;
|
||||||
// Add the image element ...
|
// Add the image element ...
|
||||||
if (true == m_hasAnImage) {
|
if (true == m_hasAnImage) {
|
||||||
//m_minSize.x += -m_padding.x + m_padding.y*2 + minHeight;
|
//m_minSize.x += -m_padding.x + m_padding.y*2 + minHeight;
|
||||||
//m_minSize.y += m_padding.y*2;
|
//m_minSize.y += m_padding.y*2;
|
||||||
m_minSize.x += m_padding.x + minSize.y;
|
m_minSize.x += padding.x + minSize.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkToRedraw();
|
MarkToRedraw();
|
||||||
@ -200,29 +204,32 @@ bool ewol::Button::GetValue(void)
|
|||||||
|
|
||||||
void ewol::Button::OnDraw(DrawProperty& displayProp)
|
void ewol::Button::OnDraw(DrawProperty& displayProp)
|
||||||
{
|
{
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
if (m_GLprogram==NULL) {
|
||||||
if (m_GLprogram==NULL) {
|
EWOL_ERROR("No shader ...");
|
||||||
EWOL_ERROR("No shader ...");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
//glScalef(m_scaling.x, m_scaling.y, 1.0);
|
||||||
//glScalef(m_scaling.x, m_scaling.y, 1.0);
|
m_GLprogram->Use();
|
||||||
m_GLprogram->Use();
|
// set Matrix : translation/positionMatrix
|
||||||
// set Matrix : translation/positionMatrix
|
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
||||||
etk::Matrix4 tmpMatrix = ewol::openGL::GetMatrix();
|
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
||||||
m_GLprogram->UniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat);
|
// position :
|
||||||
// position :
|
// Note : Must be all the time a [-1..1] square ...
|
||||||
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
// TODO : plop ...
|
||||||
// all entry parameters :
|
m_GLprogram->SendAttribute(m_GLPosition, 2/*x,y*/, &m_coord[0]);
|
||||||
m_GLprogram->Uniform1f(m_GLsizeBorder, 3);
|
// all entry parameters :
|
||||||
m_GLprogram->Uniform1f(m_GLsizePadding, m_padding.x);
|
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_size, 1, &m_size.x);
|
||||||
m_GLprogram->Uniform2fv(m_GLsize, 1, &m_size.x);
|
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_insidePos, 1, &m_widgetProperty.m_insidePos.x);
|
||||||
m_GLprogram->Uniform4fv(m_GLposText, 1, m_pos);
|
m_GLprogram->Uniform2fv(m_GLwidgetProperty.m_insideSize, 1, &m_widgetProperty.m_insideSize.x);
|
||||||
m_GLprogram->Uniform1i(m_GLstate, 0);
|
m_GLprogram->Uniform1i(m_GLstatus.m_stateOld, m_status.m_stateOld);
|
||||||
// Request the draw of the elements :
|
m_GLprogram->Uniform1i(m_GLstatus.m_stateNew, m_status.m_stateNew);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
m_GLprogram->Uniform1f(m_GLstatus.m_transition, m_status.m_transition);
|
||||||
m_GLprogram->UnUse();
|
|
||||||
#endif
|
// Request the draw of the elements :
|
||||||
m_oObjectDecoration.Draw();
|
glDrawArrays(GL_TRIANGLES, 0, m_coord.Size());
|
||||||
|
m_GLprogram->UnUse();
|
||||||
|
|
||||||
|
|
||||||
if (NULL != m_oObjectImage) {
|
if (NULL != m_oObjectImage) {
|
||||||
m_oObjectImage->Draw();
|
m_oObjectImage->Draw();
|
||||||
}
|
}
|
||||||
@ -232,7 +239,11 @@ void ewol::Button::OnDraw(DrawProperty& displayProp)
|
|||||||
void ewol::Button::OnRegenerateDisplay(void)
|
void ewol::Button::OnRegenerateDisplay(void)
|
||||||
{
|
{
|
||||||
if (true == NeedRedraw()) {
|
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();
|
m_oObjectText.Clear();
|
||||||
if (NULL != m_oObjectImage) {
|
if (NULL != m_oObjectImage) {
|
||||||
m_oObjectImage->Clear();
|
m_oObjectImage->Clear();
|
||||||
@ -242,24 +253,24 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
int32_t tmpOriginX = (m_size.x - m_minSize.x) / 2;
|
||||||
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
int32_t tmpOriginY = (m_size.y - m_minSize.y) / 2;
|
||||||
// no change for the text orogin :
|
// no change for the text orogin :
|
||||||
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + m_padding.x;
|
int32_t tmpTextOriginX = (m_size.x - m_minSize.x) / 2 + padding.x;
|
||||||
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + m_padding.y;
|
int32_t tmpTextOriginY = (m_size.y - m_minSize.y) / 2 + padding.y;
|
||||||
|
|
||||||
if (true==m_userFill.x) {
|
if (true==m_userFill.x) {
|
||||||
tmpSizeX = m_size.x;
|
tmpSizeX = m_size.x;
|
||||||
tmpOriginX = 0;
|
tmpOriginX = 0;
|
||||||
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
if (m_alignement == ewol::TEXT_ALIGN_LEFT) {
|
||||||
tmpTextOriginX = m_padding.x;
|
tmpTextOriginX = padding.x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (true==m_userFill.y) {
|
if (true==m_userFill.y) {
|
||||||
tmpSizeY = m_size.y;
|
tmpSizeY = m_size.y;
|
||||||
tmpOriginY = 0;
|
tmpOriginY = 0;
|
||||||
}
|
}
|
||||||
tmpOriginX += m_padding.x;
|
tmpOriginX += padding.x;
|
||||||
tmpOriginY += m_padding.y;
|
tmpOriginY += padding.y;
|
||||||
tmpSizeX -= 2*m_padding.x;
|
tmpSizeX -= 2*padding.x;
|
||||||
tmpSizeY -= 2*m_padding.y;
|
tmpSizeY -= 2*padding.y;
|
||||||
|
|
||||||
etk::Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
|
etk::Vector2D<float> textPos(tmpTextOriginX, tmpTextOriginY);
|
||||||
|
|
||||||
@ -274,23 +285,20 @@ void ewol::Button::OnRegenerateDisplay(void)
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
clipping_ts drawClipping;
|
clipping_ts drawClipping;
|
||||||
drawClipping.x = m_padding.x;
|
drawClipping.x = padding.x;
|
||||||
drawClipping.y = m_padding.y;
|
drawClipping.y = padding.y;
|
||||||
drawClipping.w = m_size.x - 2*m_padding.x;
|
drawClipping.w = m_size.x - 2*padding.x;
|
||||||
drawClipping.h = m_size.y - 2*m_padding.y;
|
drawClipping.h = m_size.y - 2*padding.y;
|
||||||
//EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
|
//EWOL_DEBUG("draw tex at pos : " <<textPos << "in element size:" << m_size);
|
||||||
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
m_oObjectText.Text(textPos/*, drawClipping*/, m_label);
|
||||||
|
|
||||||
#ifndef __VIDEO__OPENGL_ES_2
|
m_status.m_stateOld = 0;
|
||||||
m_oObjectDecoration.SetColor(m_textColorBg);
|
m_status.m_stateNew = 0;
|
||||||
tmpOriginX -= m_padding.x/2;
|
m_status.m_transition = 0;
|
||||||
tmpOriginY -= m_padding.y/2;
|
m_widgetProperty.m_insidePos = textPos;
|
||||||
tmpSizeX += m_padding.x/1;
|
m_widgetProperty.m_insideSize = m_oObjectText.GetSize(m_label);
|
||||||
tmpSizeY += m_padding.y/1;
|
|
||||||
m_oObjectDecoration.Rectangle( tmpOriginX, tmpOriginY, tmpSizeX, tmpSizeY);
|
Rectangle(0, 0, m_size.x, m_size.y);
|
||||||
#else
|
|
||||||
Rectangle(0, 0, m_size.x, m_size.y);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,42 @@ extern const char * const ewolEventButtonUp;
|
|||||||
extern const char * const ewolEventButtonEnter;
|
extern const char * const ewolEventButtonEnter;
|
||||||
extern const char * const ewolEventButtonLeave;
|
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 {
|
namespace ewol {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TEXT_ALIGN_LEFT,
|
TEXT_ALIGN_LEFT,
|
||||||
@ -45,31 +81,34 @@ namespace ewol {
|
|||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
ewol::Program* m_GLprogram;
|
// External theme config:
|
||||||
int32_t m_GLPosition;
|
ewol::SimpleConfigFile* m_config;
|
||||||
int32_t m_GLMatrix;
|
int32_t m_confIdPaddingX;
|
||||||
int32_t m_GLsizeBorder;
|
int32_t m_confIdPaddingY;
|
||||||
int32_t m_GLsizePadding;
|
int32_t m_confIdChangeTime;
|
||||||
int32_t m_GLsize;
|
// OpenGL shaders programs:
|
||||||
float m_pos[4];
|
ewol::Program* m_GLprogram;
|
||||||
int32_t m_GLposText;
|
int32_t m_GLPosition;
|
||||||
int32_t m_GLstate;
|
int32_t m_GLMatrix;
|
||||||
etk::Vector<etk::Vector2D<float> > m_coord; //!< internal coord of the object
|
// widget property
|
||||||
draw::Colorf m_color[3];
|
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 SetPoint(float x, float y);
|
||||||
void Rectangle(float x, float y, float w, float h);
|
void Rectangle(float x, float y, float w, float h);
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
ewol::OObject2DTextColored m_oObjectText;
|
ewol::OObject2DTextColored m_oObjectText;
|
||||||
ewol::OObject2DColored m_oObjectDecoration;
|
|
||||||
ewol::OObject2DTextured* m_oObjectImage;
|
ewol::OObject2DTextured* m_oObjectImage;
|
||||||
bool m_hasAnImage;
|
bool m_hasAnImage;
|
||||||
etk::UString m_imageSelected;
|
etk::UString m_imageSelected;
|
||||||
textAlignement_te m_alignement;
|
textAlignement_te m_alignement;
|
||||||
etk::Vector2D<float> m_padding;
|
|
||||||
etk::UString m_label;
|
etk::UString m_label;
|
||||||
draw::Color m_textColorFg; //!< Text color
|
draw::Color m_textColorFg; //!< Text color
|
||||||
draw::Color m_textColorBg; //!< Background color
|
|
||||||
public:
|
public:
|
||||||
Button(void);
|
Button(void);
|
||||||
Button(etk::UString newLabel);
|
Button(etk::UString newLabel);
|
||||||
@ -89,8 +128,6 @@ namespace ewol {
|
|||||||
void SetValue(bool val);
|
void SetValue(bool val);
|
||||||
bool GetValue(void);
|
bool GetValue(void);
|
||||||
void SetAlignement(textAlignement_te typeAlign);
|
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; };
|
void SetColorFg(draw::Color newColor) { m_textColorFg = newColor; };
|
||||||
public:
|
public:
|
||||||
virtual void OnRegenerateDisplay(void);
|
virtual void OnRegenerateDisplay(void);
|
||||||
|
@ -69,7 +69,7 @@ void ewol::Entry::Init(void)
|
|||||||
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
ShortCutAdd("ctrl+a", ewolEventEntrySelect, "ALL");
|
||||||
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
ShortCutAdd("ctrl+shift+a", ewolEventEntrySelect, "NONE");
|
||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
etk::UString tmpString("THEME:rounded:widgetEntry.prog");
|
etk::UString tmpString("THEME:GUI:widgetEntry.prog");
|
||||||
// get the shader resource :
|
// get the shader resource :
|
||||||
m_GLPosition = 0;
|
m_GLPosition = 0;
|
||||||
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
if (true == ewol::resource::Keep(tmpString, m_GLprogram) ) {
|
||||||
|
@ -4,7 +4,8 @@ FILE_LIST = ewol/ewol.cpp \
|
|||||||
ewol/ClipBoard.cpp \
|
ewol/ClipBoard.cpp \
|
||||||
ewol/Debug.cpp \
|
ewol/Debug.cpp \
|
||||||
ewol/ShortCutManager.cpp \
|
ewol/ShortCutManager.cpp \
|
||||||
ewol/ResourceManager.cpp
|
ewol/ResourceManager.cpp \
|
||||||
|
ewol/SimpleConfigFile.cpp
|
||||||
|
|
||||||
FILE_LIST+= ewol/openGL/openGL.cpp \
|
FILE_LIST+= ewol/openGL/openGL.cpp \
|
||||||
ewol/openGL/Shader.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.frag:theme/rounded/widgetEntry.frag \
|
||||||
../../share/theme/rounded/widgetEntry.vert:theme/rounded/widgetEntry.vert \
|
../../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.prog:theme/default/widgetButton.prog \
|
||||||
../../share/theme/default/widgetButton.frag:theme/default/widgetButton.frag \
|
../../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
|
||||||
|
|
||||||
|
11
share/theme/default/widgetButton.conf
Normal file
11
share/theme/default/widgetButton.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# padding for the GUI
|
||||||
|
PaddingX=11
|
||||||
|
PaddingY=11
|
||||||
|
# change status in ms
|
||||||
|
ChangeTime=356
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -3,37 +3,38 @@ precision mediump float;
|
|||||||
precision mediump int;
|
precision mediump int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uniform float EW_sizeBorder;
|
|
||||||
uniform float EW_sizePadding;
|
|
||||||
uniform vec2 EW_size;
|
|
||||||
uniform vec4 EW_posText;
|
|
||||||
uniform int EW_state;
|
|
||||||
/*
|
|
||||||
struct displayProperty {
|
struct displayProperty {
|
||||||
vec4 colorBackGround;
|
vec2 size;
|
||||||
vec4 colorForeGround;
|
vec2 insidePos;
|
||||||
vec4 colorBorder;
|
vec2 insideSize;
|
||||||
float sizeBorder;
|
|
||||||
vec2 sizePaddingOut;
|
|
||||||
vec2 sizePaddingIn;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
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
|
// transmit from the vertex shader
|
||||||
varying vec2 v_position; // interpolated position ...
|
varying vec2 v_position; // interpolated position ...
|
||||||
|
|
||||||
// internal static define
|
// internal static define
|
||||||
vec4 S_colorBg = vec4(0.0);
|
vec4 S_colorBg = vec4(0.0);
|
||||||
vec4 S_colorFg = vec4(0.5,0.5,0.5,0.8);
|
vec4 S_colorFg = vec4(0.5,0.5,0.5,0.8);
|
||||||
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
|
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) {
|
void main(void) {
|
||||||
float specialBorder = EW_sizeBorder+EW_sizePadding;
|
float specialBorder = S_sizeBorder+S_sizePadding;
|
||||||
vec2 endStart = EW_size - vec2(EW_sizePadding) - vec2(EW_sizeBorder);
|
vec2 endStart = EW_widgetProperty.size - vec2(S_sizePadding) - vec2(S_sizeBorder);
|
||||||
vec2 endStop = EW_size - vec2(EW_sizePadding);
|
vec2 endStop = EW_widgetProperty.size - vec2(S_sizePadding);
|
||||||
if( v_position.x> EW_sizePadding
|
if( v_position.x> S_sizePadding
|
||||||
&& v_position.y> EW_sizePadding
|
&& v_position.y> S_sizePadding
|
||||||
&& v_position.x<= endStop.x
|
&& v_position.x<= endStop.x
|
||||||
&& v_position.y<= endStop.y
|
&& v_position.y<= endStop.y
|
||||||
) {
|
) {
|
||||||
|
11
share/theme/rounded/widgetButton.conf
Normal file
11
share/theme/rounded/widgetButton.conf
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# padding for the GUI
|
||||||
|
PaddingX=14
|
||||||
|
PaddingY=14
|
||||||
|
# change status in ms
|
||||||
|
ChangeTime=356
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
64
share/theme/rounded/widgetButton.frag
Normal file
64
share/theme/rounded/widgetButton.frag
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
2
share/theme/rounded/widgetButton.prog
Normal file
2
share/theme/rounded/widgetButton.prog
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
widgetButton.vert
|
||||||
|
widgetButton.frag
|
17
share/theme/rounded/widgetButton.vert
Normal file
17
share/theme/rounded/widgetButton.vert
Normal 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;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user