[DEV] update conf in json file

This commit is contained in:
Edouard DUPIN 2014-01-24 21:44:38 +01:00
parent 0a441228f1
commit 5606728ae4
46 changed files with 556 additions and 408 deletions

@ -0,0 +1,10 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_border", color:"#FFF" },
{ name:"EW_foreground", color:"#000A" },
{ name:"EW_foregroundHover", color:"#0066" },
{ name:"EW_foregroundSelected", color:"#060A" },
{ name:"EW_foregroundPressed", color:"#6006" },
]
}

@ -0,0 +1,10 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_border", color:"#000" },
{ name:"EW_foreground", color:"#8884" },
{ name:"EW_foregroundHover", color:"#00A6" },
{ name:"EW_foregroundSelected", color:"#0A0A" },
{ name:"EW_foregroundPressed", color:"#A006" },
]
}

@ -1,17 +0,0 @@
# padding for the GUI
PaddingX=13
PaddingY=7
# change status in ms
ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=THEME:GUI:Button.prog
# the associated color theme
color=THEME:COLOR:Button.json

@ -0,0 +1,9 @@
{
padding-left:13,
padding-right:13,
padding-top:7,
padding-buttom:7,
change-time:356,
program:"THEME:GUI:Button.prog",
color:"THEME:COLOR:Button.json"
}

@ -0,0 +1,68 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct displayProperty {
vec2 size;
vec2 origin;
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 ...
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
// internal static define
float S_sizePadding = 3.0; // must not be NULL
float S_sizeBorder = 1.0; //==> this id for 1 px border
float S_roundedRatio = 10.0;
void main(void) {
// position form center :
vec2 ratio = EW_widgetProperty.size / 2.0;
// prevent origin moving ...
vec2 position = v_position - EW_widgetProperty.origin;
/* generate a central simetry
____ _____
\ /
\ /
\ /
-
*/
vec2 positionCenter = abs(position-ratio);
// This is a clip to remove center of the display of the widget
vec2 ratioLow = ratio - (S_roundedRatio+S_sizePadding);
vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding);
// Calculate the distance of the radius
float tmpDist = float(int(sqrt(dot(circleMode,circleMode))));
// Generate the internal rampe for the the imput drawing
float tmpVal = smoothstep(S_roundedRatio - S_sizeBorder*1.5,
S_roundedRatio + S_sizeBorder*1.5,
tmpDist);
// set Background
gl_FragColor = v_colorBackground;
// set foreground
gl_FragColor = gl_FragColor*tmpVal + v_colorTansition*(1.0-tmpVal);
// set border
float tmpVal2 = abs(tmpVal-0.5)*2.0;
gl_FragColor = gl_FragColor*tmpVal2 + v_colorBorder*(1.0-tmpVal2);
}

@ -0,0 +1,9 @@
{
padding-left:13,
padding-right:13,
padding-top:7,
padding-buttom:7,
change-time:356,
program:"THEME:GUI:CheckBox.prog",
color:"THEME:COLOR:CheckBox.json"
}

@ -0,0 +1,57 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct widgetStateProperty {
int stateOld;
int stateNew;
float transition;
};
uniform widgetStateProperty EW_status;
// Input :
attribute vec2 EW_coord2d;
uniform mat4 EW_MatrixTransformation;
uniform vec4 EW_border;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_foregroundHover;
uniform vec4 EW_foregroundSelected;
uniform vec4 EW_foregroundPressed;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
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;
vec4 colorOld = EW_foreground;
if(EW_status.stateOld == 1) {
colorOld = EW_foregroundPressed;
} else if(EW_status.stateOld == 2) {
colorOld = EW_foregroundHover;
} else if(EW_status.stateOld == 3) {
colorOld = EW_foregroundSelected;
}
vec4 colorNew = EW_foreground;
if(EW_status.stateNew == 1) {
colorNew = EW_foregroundPressed;
} else if(EW_status.stateNew == 2) {
colorNew = EW_foregroundHover;
} else if(EW_status.stateNew == 3) {
colorNew = EW_foregroundSelected;
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld * (1.0 - EW_status.transition)
+ colorNew * EW_status.transition;
v_colorBorder = EW_border;
v_colorBackground = EW_background;
}

@ -1,17 +0,0 @@
# padding for the GUI
PaddingX=13
PaddingY=7
# change status in ms
ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=THEME:GUI:ContextMenu.prog
# the associated color theme
color=THEME:COLOR:ContextMenu.json

@ -0,0 +1,9 @@
{
padding-left:13,
padding-right:13,
padding-top:7,
padding-buttom:7,
change-time:356,
program:"THEME:GUI:ContextMenu.prog",
color:"THEME:COLOR:ContextMenu.json"
}

@ -1,14 +0,0 @@
# padding for the GUI
PaddingX=13
PaddingY=7
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=THEME:GUI:Entry.prog
# the associated color theme
color=THEME:COLOR:Entry.json

@ -0,0 +1,9 @@
{
padding-left:13,
padding-right:13,
padding-top:7,
padding-buttom:7,
change-time:356,
program:"THEME:GUI:Entry.prog",
color:"THEME:COLOR:Entry.json"
}

@ -1,17 +0,0 @@
# padding for the GUI
PaddingX=13
PaddingY=7
# change status in ms
ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=THEME:GUI:PopUp.prog
# the associated color theme
color=THEME:COLOR:PopUp.json

@ -0,0 +1,9 @@
{
padding-left:13,
padding-right:13,
padding-top:7,
padding-buttom:7,
change-time:356,
program:"THEME:GUI:PopUp.prog",
color:"THEME:COLOR:PopUp.json"
}

@ -1,15 +0,0 @@
# padding for the GUI
PaddingX=16
PaddingY=16
# change status in ms
ChangeTime=200
# the associated openGL ES-2 program :
program=THEME:GUI:WidgetScrolled.prog
# the associated color theme
color=THEME:COLOR:WidgetScrolled.json

@ -0,0 +1,9 @@
{
padding-left:16,
padding-right:16,
padding-top:16,
padding-buttom:16,
change-time:200,
program:"THEME:GUI:WidgetScrolled.prog",
color:"THEME:COLOR:WidgetScrolled.json"
}

@ -1,16 +0,0 @@
# padding for the GUI
PaddingX=8
PaddingY=8
# change status in ms
ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=THEME:GUI:Button.prog
# the associated color theme
color=THEME:COLOR:Button.json

@ -0,0 +1,9 @@
{
padding-left:8,
padding-right:8,
padding-top:8,
padding-buttom:8,
change-time:356,
program:"THEME:GUI:Button.prog",
color:"THEME:COLOR:Button.json"
}

@ -0,0 +1,51 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct displayProperty {
vec2 size;
vec2 origin;
vec2 insidePos;
vec2 insideSize;
};
uniform displayProperty EW_widgetProperty;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
// internal static define
float S_sizePadding = 3.0;
float S_sizeBorder = 1.0;
void main(void) {
// prevent origin moving ...
vec2 position = v_position - EW_widgetProperty.origin;
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( position.x> S_sizePadding
&& position.y> S_sizePadding
&& position.x<= endStop.x
&& position.y<= endStop.y
) {
if( position.x<= specialBorder
|| position.y<= specialBorder
|| position.x> endStart.x
|| position.y> endStart.y
) {
gl_FragColor = v_colorBorder;
} else {
// note : int() is needed for the OpenGL ES platform
gl_FragColor = v_colorTansition;
}
} else {
gl_FragColor = v_colorBackground;
}
}

@ -0,0 +1,11 @@
{
element-size:50,
element-border:10,
padding-left:80,
padding-right:8,
padding-top:8,
padding-buttom:8,
change-time:356,
program:"THEME:GUI:CheckBox.prog",
color:"THEME:COLOR:CheckBox.json"
}

@ -0,0 +1,57 @@
#ifdef GL_ES
precision mediump float;
precision mediump int;
#endif
struct widgetStateProperty {
int stateOld;
int stateNew;
float transition;
};
uniform widgetStateProperty EW_status;
// Input :
attribute vec2 EW_coord2d;
uniform mat4 EW_MatrixTransformation;
uniform vec4 EW_border;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_foregroundHover;
uniform vec4 EW_foregroundSelected;
uniform vec4 EW_foregroundPressed;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec4 v_colorTansition;
varying vec4 v_colorBorder;
varying vec4 v_colorBackground;
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;
vec4 colorOld = EW_foreground;
if(EW_status.stateOld == 1) {
colorOld = EW_foregroundPressed;
} else if(EW_status.stateOld == 2) {
colorOld = EW_foregroundHover;
} else if(EW_status.stateOld == 3) {
colorOld = EW_foregroundSelected;
}
vec4 colorNew = EW_foreground;
if(EW_status.stateNew == 1) {
colorNew = EW_foregroundPressed;
} else if(EW_status.stateNew == 2) {
colorNew = EW_foregroundHover;
} else if(EW_status.stateNew == 3) {
colorNew = EW_foregroundSelected;
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld * (1.0 - EW_status.transition)
+ colorNew * EW_status.transition;
v_colorBorder = EW_border;
v_colorBackground = EW_background;
}

@ -1,10 +0,0 @@
# padding for the GUI
PaddingX=8
PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=THEME:GUI:ContextMenu.prog
# the associated color theme
color=THEME:COLOR:ContextMenu.json

@ -0,0 +1,9 @@
{
padding-left:8,
padding-right:8,
padding-top:8,
padding-buttom:8,
change-time:356,
program:"THEME:GUI:ContextMenu.prog",
color:"THEME:COLOR:ContextMenu.json"
}

@ -1,10 +0,0 @@
# padding for the GUI
PaddingX=8
PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=THEME:GUI:Entry.prog
# the associated color theme
color=THEME:COLOR:Entry.json

@ -0,0 +1,9 @@
{
padding-left:8,
padding-right:8,
padding-top:8,
padding-buttom:8,
change-time:356,
program:"THEME:GUI:Entry.prog",
color:"THEME:COLOR:Entry.json"
}

@ -1,10 +0,0 @@
# padding for the GUI
PaddingX=8
PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=THEME:GUI:PopUp.prog
# the associated color theme
color=THEME:COLOR:PopUp.json

@ -0,0 +1,9 @@
{
padding-left:8,
padding-right:8,
padding-top:8,
padding-buttom:8,
change-time:356,
program:"THEME:GUI:PopUp.prog",
color:"THEME:COLOR:PopUp.json"
}

@ -1,14 +0,0 @@
# padding for the GUI
PaddingX=15
PaddingY=15
# change status in ms
ChangeTime=200
# the associated openGL ES-2 program :
program=THEME:GUI:WidgetScrolled.prog
# the associated color theme
color=THEME:COLOR:WidgetScrolled.json

@ -0,0 +1,9 @@
{
padding-left:15,
padding-right:15,
padding-top:15,
padding-buttom:15,
change-time:200,
program:"THEME:GUI:WidgetScrolled.prog",
color:"THEME:COLOR:WidgetScrolled.json"
}

@ -12,12 +12,18 @@
#include <ewol/debug.h>
namespace ewol {
/**
* @breif Simple class to abstarct the padding porperty.
*/
class Padding {
private:
float value[4];
float value[4]; //!< this represent the 4 padding value Left top right buttom (like css)
public:
Padding(void) { }
Padding(float _xl, float _yt=0, float _xr=0, float _yb=0) {
setValue(_xl, _yt, _xr, _yb);
}
void setValue(float _xl, float _yt=0, float _xr=0, float _yb=0) {
value[0] = _xl;
value[1] = _yt;
value[2] = _xr;
@ -33,15 +39,27 @@ namespace ewol {
float xLeft(void) const {
return value[0];
}
void setXLeft(float _val) {
value[0] = _val;
}
float xRight(void) const {
return value[2];
}
void setXRight(float _val) {
value[2] = _val;
}
float yTop(void) const {
return value[1];
}
void setYTop(float _val) {
value[1] = _val;
}
float yButtom(void) const {
return value[3];
}
void setYButtom(float _val) {
value[3] = _val;
}
};
};

@ -16,8 +16,10 @@
ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
m_name(_shaperName),
m_config(NULL),
m_confIdPaddingX(-1),
m_confIdPaddingY(-1),
m_confIdPaddingLeft(-1),
m_confIdPaddingRight(-1),
m_confIdPaddingTop(-1),
m_confIdPaddingButtom(-1),
m_confIdChangeTime(-1),
m_confProgramFile(-1),
m_confColorFile(-1),
@ -53,8 +55,10 @@ void ewol::compositing::Shaper::unLoadProgram(void) {
ewol::resource::TextureFile::release(m_resourceTexture);
ewol::resource::ConfigFile::release(m_config);
ewol::resource::ColorFile::release(m_colorProperty);
m_confIdPaddingX = -1;
m_confIdPaddingY = -1;
m_confIdPaddingLeft = -1;
m_confIdPaddingRight = -1;
m_confIdPaddingTop = -1;
m_confIdPaddingButtom = -1;
m_confIdChangeTime = -1;
m_confProgramFile = -1;
m_confImageFile = -1;
@ -68,12 +72,14 @@ void ewol::compositing::Shaper::loadProgram(void) {
}
m_config = ewol::resource::ConfigFile::keep(m_name);
if (NULL != m_config) {
m_confIdPaddingX = m_config->request("PaddingX");
m_confIdPaddingY = m_config->request("PaddingY");
m_confIdChangeTime = m_config->request("ChangeTime");
m_confProgramFile = m_config->request("program");
m_confImageFile = m_config->request("image");
m_confColorFile = m_config->request("color");
m_confIdPaddingLeft = m_config->request("padding-left");
m_confIdPaddingRight = m_config->request("padding-right");
m_confIdPaddingTop = m_config->request("padding-top");
m_confIdPaddingButtom = m_config->request("padding-buttom");
m_confIdChangeTime = m_config->request("ChangeTime");
m_confProgramFile = m_config->request("program");
m_confImageFile = m_config->request("image");
m_confColorFile = m_config->request("color");
}
std::string basicShaderFile = m_config->getString(m_confProgramFile);
if (basicShaderFile != "") {
@ -229,7 +235,7 @@ bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) {
m_nextStatusRequested = -1;
}
}
float timeRelativity = m_config->getFloat(m_confIdChangeTime) / 1000.0;
float timeRelativity = m_config->getNumber(m_confIdChangeTime) / 1000.0;
m_stateTransition += _event.getDeltaCall() / timeRelativity;
//m_stateTransition += _event.getDeltaCall();
m_stateTransition = etk_avg(0.0f, m_stateTransition, 1.0f);
@ -277,11 +283,13 @@ void ewol::compositing::Shaper::setInsidePos(const vec2& _newInsidePos) {
m_propertyInsidePosition = _newInsidePos;
}
vec2 ewol::compositing::Shaper::getPadding(void) {
vec2 padding(0,0);
if (m_config!=NULL) {
padding.setValue(m_config->getFloat(m_confIdPaddingX),
m_config->getFloat(m_confIdPaddingY));
ewol::Padding ewol::compositing::Shaper::getPadding(void) {
ewol::Padding padding(0,0,0,0);
if (m_config != NULL) {
padding.setValue(m_config->getNumber(m_confIdPaddingLeft),
m_config->getNumber(m_confIdPaddingTop),
m_config->getNumber(m_confIdPaddingRight),
m_config->getNumber(m_confIdPaddingButtom));
}
return padding;
}

@ -16,6 +16,7 @@
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Image.h>
#include <ewol/event/Time.h>
#include <ewol/Padding.h>
namespace ewol {
namespace compositing {
@ -29,12 +30,14 @@ namespace ewol {
std::string m_name; //!< Name of the configuration of the shaper.
// External theme config:
ewol::resource::ConfigFile* m_config; //!< pointer on the config file resources
int32_t m_confIdPaddingX; //!< ConfigFile padding property X
int32_t m_confIdPaddingY; //!< ConfigFile padding property Y
int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property
int32_t m_confProgramFile; //!< ConfigFile opengGl program Name
int32_t m_confColorFile; //!< ConfigFile opengGl color file Name
int32_t m_confImageFile; //!< ConfigFile opengGl program Name
int32_t m_confIdPaddingLeft; //!< ConfigFile padding property X-left
int32_t m_confIdPaddingRight; //!< ConfigFile padding property X-right
int32_t m_confIdPaddingTop; //!< ConfigFile padding property Y-top
int32_t m_confIdPaddingButtom; //!< ConfigFile padding property Y-buttom
int32_t m_confIdChangeTime; //!< ConfigFile padding transition time property
int32_t m_confProgramFile; //!< ConfigFile opengGl program Name
int32_t m_confColorFile; //!< ConfigFile opengGl color file Name
int32_t m_confImageFile; //!< ConfigFile opengGl program Name
// openGL shaders programs:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
int32_t m_GLPosition; //!< openGL id on the element (vertex buffer)
@ -149,7 +152,7 @@ namespace ewol {
* @brief get the padding declared by the user in the config file
* @return the padding property
*/
vec2 getPadding(void);
ewol::Padding getPadding(void);
/**
* @brief change the shaper Source
* @param[in] _newFile New file of the shaper

@ -10,32 +10,15 @@
#include <ewol/debug.h>
#include <ewol/resource/ConfigFile.h>
#include <ewol/resource/Manager.h>
#include <ejson/ejson.h>
#include <ejson/Number.h>
#include <ejson/String.h>
#include <stdexcept>
#undef __class__
#define __class__ "resource::ConfigFile"
void ewol::resource::SimpleConfigElement::parse(const std::string& _value) {
m_value = _value;
#ifdef __EXCEPTIONS
try {
m_valueInt = std::stoi(_value);
m_valuefloat = std::stof(_value);
}
catch (const std::invalid_argument& ia) {
EWOL_VERBOSE(" invalid argument= " << ia.what() << "val='" << _value << "'");
m_valueInt = 0;
m_valuefloat = 0;
}
#else
m_valueInt = std::stoi(_value);
m_valuefloat = std::stof(_value);
#endif
}
ewol::resource::ConfigFile::ConfigFile(const std::string& _filename) :
ewol::Resource(_filename) {
addObjectType("ewol::ConfigFile");
@ -59,104 +42,58 @@ void ewol::resource::ConfigFile::reload(void) {
// reset all parameters
for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) {
m_list[iii]->parse("");
m_list[iii] = NULL;
}
}
// acess of the file :
etk::FSNode file(m_name);
m_doc.load(m_name);
if (false == file.exist()) {
EWOL_ERROR("File does not Exist : \"" << file << "\"");
return;
}
std::string fileExtention = file.fileGetExtention();
if (fileExtention != "conf") {
EWOL_ERROR("File does not have extention \".conf\" 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;
}
std::string tmpData2(tmpData);
std::string tmppp("#");
if (start_with(tmpData2, tmppp) == true) {
// comment ...
continue;
}
tmppp="//";
if (start_with(tmpData2, tmppp) == true) {
// comment ...
continue;
}
// get parameters :
size_t pos = tmpData2.find('=');
if (pos == 0){
//the element "=" is not find ...
continue;
}
std::string paramName = std::string(tmpData2, 0, pos);
std::string paramValue = std::string(tmpData2, pos+1, 0x7FFFF);
EWOL_DEBUG(" param name=\"" << paramName << "\" val=\"" << paramValue << "\"");
// check if the parameters existed :
bool findParam = false;
for (size_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::resource::SimpleConfigElement* tmpElement = new ewol::resource::SimpleConfigElement(paramName);
if (NULL == tmpElement) {
EWOL_DEBUG("error while allocation");
} else {
tmpElement->parse(paramValue);
m_list.push_back(tmpElement);
}
for (auto elementName : m_list.getKeys()) {
if (m_doc.exist(elementName) == true) {
m_list[elementName] = m_doc[elementName];
}
}
// close the file:
file.fileClose();
}
int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
// check if the parameters existed :
for (size_t iii=0; iii<m_list.size(); iii++){
if (NULL != m_list[iii]) {
if (m_list[iii]->m_paramName == _paramName) {
return iii;
}
}
if (m_list.exist(_paramName) == false) {
m_list.add(_paramName, NULL);
}
ewol::resource::SimpleConfigElement* tmpElement = new ewol::resource::SimpleConfigElement(_paramName);
if (NULL == tmpElement) {
EWOL_DEBUG("error while allocation");
} else {
m_list.push_back(tmpElement);
if (m_doc.exist(_paramName) == true) {
m_list[_paramName] = m_doc[_paramName];
}
return m_list.size()-1;
return m_list.getId(_paramName);
}
double ewol::resource::ConfigFile::getNumber(int32_t _id) {
if ( _id < 0
|| m_list[_id] == NULL) {
return 0.0;
}
ejson::Number* tmp = m_list[_id]->toNumber();
if (tmp == NULL) {
return 0.0;
}
return tmp->get();
}
const std::string& ewol::resource::ConfigFile::getString(int32_t _id) {
static const std::string& errorString("");
if ( _id < 0
|| m_list[_id] == NULL) {
return errorString;
}
ejson::String* tmp = m_list[_id]->toString();
if (tmp == NULL) {
return errorString;
}
return tmp->get();
}
ewol::resource::ConfigFile* ewol::resource::ConfigFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
ewol::resource::ConfigFile* object = NULL;

@ -11,44 +11,15 @@
#include <etk/types.h>
#include <ewol/debug.h>
#include <ejson/ejson.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace resource {
// TODO : Show if it is possible to integrate this in a json interface ==> simplify code ...
/**
* @not-in-doc
*/
class SimpleConfigElement {
public:
std::string m_paramName;
private:
std::string m_value;
int32_t m_valueInt;
float m_valuefloat;
public:
SimpleConfigElement(const std::string& _name) :
m_paramName(_name),
m_value(""),
m_valueInt(0),
m_valuefloat(0.0) { };
~SimpleConfigElement(void) { };
void parse(const std::string& value);
int32_t getInteger(void) {
return m_valueInt;
};
float getFloat(void) {
return m_valuefloat;
};
std::string& getString(void) {
return m_value;
};
};
class ConfigFile : public ewol::Resource {
private:
std::vector<ewol::resource::SimpleConfigElement*> m_list;
std::string m_errorString;
ejson::Document m_doc;
etk::Hash<ejson::Value*> m_list;
protected:
ConfigFile(const std::string& _filename);
virtual ~ConfigFile(void);
@ -57,24 +28,8 @@ namespace ewol {
int32_t request(const std::string& _paramName);
int32_t getInteger(int32_t _id) {
if (_id<0) {
return 0;
}
return m_list[_id]->getInteger();
};
float getFloat(int32_t _id) {
if (_id<0) {
return 0;
}
return m_list[_id]->getFloat();
};
std::string& getString(int32_t _id) {
if (_id<0) {
return m_errorString;
}
return m_list[_id]->getString();
};
double getNumber(int32_t _id);
const std::string& getString(int32_t _id);
public:
/**
* @brief keep the resource pointer.

@ -86,8 +86,8 @@ void ewol::widget::Button::setShaperName(const std::string& _shaperName) {
}
void ewol::widget::Button::calculateSize(const vec2& _availlable) {
vec2 padding = m_shaper.getPadding();
ewol::Padding ret = calculateSizePadded(_availlable, ewol::Padding(padding.x(), padding.y(), padding.x(), padding.y()));
ewol::Padding padding = m_shaper.getPadding();
ewol::Padding ret = calculateSizePadded(_availlable, padding);
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
m_selectableAreaPos = vec2(ret.xLeft(), ret.yButtom());
m_selectableAreaSize = m_size - (m_selectableAreaPos + vec2(ret.xRight(), ret.yTop()));
@ -95,8 +95,8 @@ void ewol::widget::Button::calculateSize(const vec2& _availlable) {
void ewol::widget::Button::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding();
calculateMinMaxSizePadded(ewol::Padding(padding.x(), padding.y(), padding.x(), padding.y()));
ewol::Padding padding = m_shaper.getPadding();
calculateMinMaxSizePadded(padding);
}
void ewol::widget::Button::onDraw(void) {
@ -107,12 +107,12 @@ void ewol::widget::Button::onDraw(void) {
void ewol::widget::Button::onRegenerateDisplay(void) {
ewol::widget::Container2::onRegenerateDisplay();
if (true == needRedraw()) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
m_shaper.clear();
m_shaper.setOrigin(vec2ClipInt32(m_selectableAreaPos));
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize));
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+padding));
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-padding*2.0f));
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ));
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ));
}
}

@ -54,7 +54,7 @@ namespace ewol {
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
Button(const std::string& _shaperName="THEME:GUI:Button.conf");
Button(const std::string& _shaperName="THEME:GUI:Button.json");
/**
* @brief Destructor
*/

@ -62,7 +62,7 @@ void ewol::widget::ButtonColor::setShaperName(std::string _shaperName) {
void ewol::widget::ButtonColor::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString();
vec3 minSize = m_text.calculateSize(label);
m_minSize.setX(padding.x()*2 + minSize.x() + 7);
@ -86,7 +86,7 @@ void ewol::widget::ButtonColor::onRegenerateDisplay(void) {
m_text.clear();
m_shaper.clear();
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
std::string label = m_textColorFg.getString();
@ -108,9 +108,9 @@ void ewol::widget::ButtonColor::onRegenerateDisplay(void) {
if (true == m_userFill.y()) {
localSize.setY(m_size.y());
}
tmpOrigin += vec3(padding.x(), padding.y(), 0);
tmpTextOrigin += vec3(padding.x(), padding.y(), 0);
localSize -= ivec2(2*padding.x(), 2*padding.y());
tmpOrigin += vec3(padding.xLeft(), padding.yButtom(), 0);
tmpTextOrigin += vec3(padding.xLeft(), padding.yButtom(), 0);
localSize -= ivec2(padding.x(), padding.y());
// clean the element
m_text.reset();
@ -128,12 +128,12 @@ void ewol::widget::ButtonColor::onRegenerateDisplay(void) {
if (true == m_userFill.y()) {
tmpOrigin.setY(padding.y());
tmpOrigin.setY(padding.yButtom());
}
// selection area :
m_selectableAreaPos = vec2(tmpOrigin.x()-padding.x(), tmpOrigin.y()-padding.y());
m_selectableAreaSize = localSize + vec2(2,2)*padding;
m_selectableAreaPos = vec2(tmpOrigin.x()-padding.xLeft(), tmpOrigin.y()-padding.yButtom());
m_selectableAreaSize = localSize + vec2(padding.x(),padding.y());
m_shaper.setOrigin(m_selectableAreaPos );
m_shaper.setSize(m_selectableAreaSize);
m_shaper.setInsidePos(vec2(tmpTextOrigin.x(), tmpTextOrigin.y()) );

@ -42,7 +42,7 @@ namespace ewol {
* @param[in] _baseColor basic displayed color.
* @param[in] _shaperName The new shaper filename.
*/
ButtonColor(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="THEME:GUI:widgetButton.conf");
ButtonColor(etk::Color<> _baseColor=etk::color::black, std::string _shaperName="THEME:GUI:widgetButton.json");
/**
* @brief Main destructor.
*/

@ -74,16 +74,16 @@ void ewol::widget::CheckBox::setShaperName(const std::string& _shaperName) {
}
void ewol::widget::CheckBox::calculateSize(const vec2& _availlable) {
vec2 padding = m_shaper.getPadding();
ewol::Padding ret = calculateSizePadded(_availlable, ewol::Padding(padding.x(), padding.y(), padding.x(), padding.y()));
ewol::Padding padding = m_shaper.getPadding();
ewol::Padding ret = calculateSizePadded(_availlable, padding);
//EWOL_DEBUG(" configuring : origin=" << origin << " size=" << subElementSize << "");
m_selectableAreaPos = vec2(ret.xLeft(), ret.yButtom());
m_selectableAreaSize = m_size - (m_selectableAreaPos + vec2(ret.xRight(), ret.yTop()));
}
void ewol::widget::CheckBox::calculateMinMaxSize(void) {
vec2 padding = m_shaper.getPadding();
calculateMinMaxSizePadded(ewol::Padding(padding.x(), padding.y(), padding.x(), padding.y()));
ewol::Padding padding = m_shaper.getPadding();
calculateMinMaxSizePadded(padding);
}
void ewol::widget::CheckBox::onDraw(void) {
@ -94,12 +94,12 @@ void ewol::widget::CheckBox::onDraw(void) {
void ewol::widget::CheckBox::onRegenerateDisplay(void) {
ewol::widget::Container2::onRegenerateDisplay();
if (true == needRedraw()) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
m_shaper.clear();
m_shaper.setOrigin(vec2ClipInt32(m_selectableAreaPos));
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize));
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+padding));
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-padding*2.0f));
m_shaper.setSize(vec2ClipInt32(m_selectableAreaSize - vec2(m_selectableAreaSize.x(), 0) + vec2(padding.xLeft(), 0)));
m_shaper.setInsidePos(vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(), padding.yButtom())));
m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x()+ m_selectableAreaSize.x(), padding.y())));
}
}

@ -43,7 +43,7 @@ namespace ewol {
* @brief Main checkbox constructor
* @param[in] _shaperName Shaper file properties
*/
CheckBox(const std::string& _shaperName="THEME:GUI:CheckBox.conf");
CheckBox(const std::string& _shaperName="THEME:GUI:CheckBox.json");
/**
* @brief main destructor.
*/
@ -81,6 +81,8 @@ namespace ewol {
void CheckStatus(void);
protected: // Derived function
virtual void onDraw(void);
virtual bool onSetConfig(const ewol::object::Config& _conf);
virtual bool onGetConfig(const char* _config, std::string& _result) const;
public: // Derived function
virtual void calculateMinMaxSize(void);
virtual void calculateSize(const vec2& _availlable);

@ -11,6 +11,7 @@
#include <ewol/widget/ContextMenu.h>
#include <ewol/compositing/Drawing.h>
#include <ewol/widget/Manager.h>
#include <ewol/Padding.h>
#undef __class__
#define __class__ "ContextMenu"
@ -66,7 +67,7 @@ void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
//EWOL_DEBUG("CalculateSize=" << availlable);
// pop-up fill all the display :
m_size = _availlable;
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
EWOL_VERBOSE("our origin=" << m_origin << " size=" << m_size);
if (NULL != m_subWidget) {
vec2 subWidgetSize;
@ -102,23 +103,23 @@ void ewol::widget::ContextMenu::calculateSize(const vec2& _availlable) {
break;
}
// set the widget position at the border of the screen
subWidgetOrigin.setX( (int32_t)( etk_max(0, (subWidgetOrigin.x()-padding.x()*2))
+ padding.x()*2) );
subWidgetOrigin.setY( (int32_t)( etk_max(0, (subWidgetOrigin.y()-padding.y()*2))
+ padding.y()*2) );
subWidgetOrigin.setX( (int32_t)( etk_max(0, (subWidgetOrigin.x()-padding.x()))
+ padding.x()) );
subWidgetOrigin.setY( (int32_t)( etk_max(0, (subWidgetOrigin.y()-padding.y()))
+ padding.y()) );
switch (m_arrawBorder)
{
default:
case markTop:
case markButtom:
if (m_arrowPos.x() <= m_offset ) {
subWidgetOrigin.setX(m_arrowPos.x()+padding.x());
subWidgetOrigin.setX(m_arrowPos.x()+padding.xLeft());
}
break;
case markRight:
case markLeft:
if (m_arrowPos.y() <= m_offset ) {
subWidgetOrigin.setY(m_arrowPos.y()+padding.y());
subWidgetOrigin.setY(m_arrowPos.y()+padding.yButtom());
}
break;
}
@ -134,7 +135,8 @@ void ewol::widget::ContextMenu::calculateMinMaxSize(void) {
// call main class to calculate the min size...
ewol::widget::Container::calculateMinMaxSize();
// add padding of the display
m_minSize += m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
m_minSize += vec2(padding.x(), padding.y());
//EWOL_DEBUG("CalculateMinSize=>>" << m_minSize);
markToRedraw();
}
@ -154,7 +156,7 @@ void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
}
m_compositing.clear();
m_shaper.clear();
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
if (m_subWidget == NULL) {
return;
@ -169,13 +171,13 @@ void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
m_compositing.setPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0.0f) );
m_compositing.addVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
float laking = m_offset - padding.y();
float laking = m_offset - padding.yTop();
m_compositing.setPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
m_compositing.addVertex();
m_compositing.setPos(vec3(m_arrowPos.x(), m_arrowPos.y()-laking, 0.0f) );
m_compositing.addVertex();
} else {
float laking = m_offset - padding.y();
float laking = m_offset - padding.yTop();
m_compositing.setPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()-laking, 0.0f) );
m_compositing.addVertex();
m_compositing.setPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()-laking, 0.0f) );
@ -186,13 +188,13 @@ void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
m_compositing.setPos(vec3(m_arrowPos.x(), m_arrowPos.y(), 0) );
m_compositing.addVertex();
if (m_arrowPos.x() <= tmpOrigin.x() ) {
int32_t laking = m_offset - padding.y();
int32_t laking = m_offset - padding.yTop();
m_compositing.setPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
m_compositing.addVertex();
m_compositing.setPos(vec3(m_arrowPos.x(), m_arrowPos.y()+laking, 0.0f) );
m_compositing.addVertex();
} else {
int32_t laking = m_offset - padding.y();
int32_t laking = m_offset - padding.yTop();
m_compositing.setPos(vec3(m_arrowPos.x()+laking, m_arrowPos.y()+laking, 0.0f) );
m_compositing.addVertex();
m_compositing.setPos(vec3(m_arrowPos.x()-laking, m_arrowPos.y()+laking, 0.0f) );
@ -206,12 +208,12 @@ void ewol::widget::ContextMenu::onRegenerateDisplay(void) {
break;
}
vec2 shaperOrigin = tmpOrigin-padding;
vec2 shaperSize = tmpSize+padding*2.0f;
vec2 shaperOrigin = tmpOrigin-vec2(padding.xLeft(), padding.yButtom());
vec2 shaperSize = tmpSize+vec2(padding.x(), padding.y());
m_shaper.setOrigin(vec2ClipInt32(shaperOrigin));
m_shaper.setSize(vec2ClipInt32(shaperSize));
m_shaper.setInsidePos(vec2ClipInt32(shaperOrigin+padding));
m_shaper.setInsideSize(vec2ClipInt32(shaperSize-padding*2.0f));
m_shaper.setInsidePos(vec2ClipInt32(shaperOrigin+vec2(padding.xLeft(), padding.yButtom())));
m_shaper.setInsideSize(vec2ClipInt32(shaperSize-vec2(padding.x(), padding.y())));
}
bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) {

@ -38,7 +38,7 @@ namespace ewol {
static const char* const configArrowMode;
static const char* const configShaper;
public:
ContextMenu(const std::string& _shaperName="THEME:GUI:ContextMenu.conf");
ContextMenu(const std::string& _shaperName="THEME:GUI:ContextMenu.json");
virtual ~ContextMenu(void);
private:
ewol::compositing::Shaper m_shaper; //!< Compositing theme.

@ -11,6 +11,7 @@
#include <ewol/widget/Manager.h>
#include <ewol/ewol.h>
#include <ewol/context/Context.h>
#include <ewol/Padding.h>
const char * const ewolEventEntryCut = "ewol-widget-entry-event-internal-cut";
@ -48,7 +49,7 @@ const char* const ewol::widget::Entry::configEmptyMessage = "emptytext";
const char* const ewol::widget::Entry::configValue = "value";
ewol::widget::Entry::Entry(std::string _newData) :
m_shaper("THEME:GUI:Entry.conf"),
m_shaper("THEME:GUI:Entry.json"),
m_data(""),
m_maxCharacter(0x7FFFFFFF),
m_regExp(".*"),
@ -107,11 +108,11 @@ void ewol::widget::Entry::calculateMinMaxSize(void) {
// call main class
ewol::Widget::calculateMinMaxSize();
// get generic padding
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
int32_t minHeight = m_text.calculateSize(char32_t('A')).y();
vec2 minimumSizeBase(20, minHeight);
// add padding :
minimumSizeBase += padding*2.0f;
minimumSizeBase += vec2(padding.x(), padding.y());
m_minSize.setMax(minimumSizeBase);
// verify the min max of the min size ...
checkMinSize();
@ -152,7 +153,7 @@ void ewol::widget::Entry::onRegenerateDisplay(void) {
m_text.setSelectionColor(m_shaper.getColor(m_colorIdSelection));
}
updateTextPosition();
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
vec2 tmpSizeShaper = m_minSize;
if (true == m_userFill.x()) {
@ -163,7 +164,7 @@ void ewol::widget::Entry::onRegenerateDisplay(void) {
}
vec2 tmpOriginShaper = (m_size - tmpSizeShaper) / 2.0f;
vec2 tmpSizeText = tmpSizeShaper - padding * 2.0f;
vec2 tmpSizeText = tmpSizeShaper - vec2(padding.x(), padding.y());
vec2 tmpOriginText = (m_size - tmpSizeText) / 2.0f;
// sometimes, the user define an height bigger than the real size needed == > in this case we need to center the text in the shaper ...
int32_t minHeight = m_text.calculateSize(char32_t('A')).y();
@ -199,16 +200,16 @@ void ewol::widget::Entry::onRegenerateDisplay(void) {
void ewol::widget::Entry::updateCursorPosition(const vec2& _pos, bool _selection) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
vec2 relPos = relativePosition(_pos);
relPos.setX(relPos.x()-m_displayStartPosition - padding.x());
relPos.setX(relPos.x()-m_displayStartPosition - padding.xLeft());
// try to find the new cursor position :
std::string tmpDisplay = std::string(m_data, 0, m_displayStartPosition);
int32_t displayHidenSize = m_text.calculateSize(tmpDisplay).x();
//EWOL_DEBUG("hidenSize : " << displayHidenSize);
int32_t newCursorPosition = -1;
int32_t tmpTextOriginX = padding.x();
int32_t tmpTextOriginX = padding.xLeft();
for (size_t iii=0; iii<m_data.size(); iii++) {
tmpDisplay = std::string(m_data, 0, iii);
int32_t tmpWidth = m_text.calculateSize(tmpDisplay).x() - displayHidenSize;
@ -513,13 +514,13 @@ void ewol::widget::Entry::updateTextPosition(void) {
if (false == m_needUpdateTextPos) {
return;
}
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
int32_t tmpSizeX = m_minSize.x();
if (true == m_userFill.x()) {
tmpSizeX = m_size.x();
}
int32_t tmpUserSize = tmpSizeX - 2*(padding.x());
int32_t tmpUserSize = tmpSizeX - padding.x();
int32_t totalWidth = m_text.calculateSize(m_data).x();
// Check if the data inside the display can be contain in the entry box
if (totalWidth < tmpUserSize) {

@ -66,20 +66,20 @@ void ewol::widget::PopUp::setShaperName(const std::string& _shaperName) {
void ewol::widget::PopUp::calculateSize(const vec2& _available) {
ewol::Widget::calculateSize(_available);
if (NULL != m_subWidget) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
vec2 subWidgetSize = m_subWidget->getCalculateMinSize();
if (true == m_subWidget->canExpand().x()) {
if (m_lockExpand.x() == true) {
subWidgetSize.setX(m_minSize.x());
} else {
subWidgetSize.setX(m_size.x()-padding.x());
subWidgetSize.setX(m_size.x()-padding.xLeft());
}
}
if (true == m_subWidget->canExpand().y()) {
if (m_lockExpand.y() == true) {
subWidgetSize.setY(m_minSize.y());
} else {
subWidgetSize.setY(m_size.y()-padding.y());
subWidgetSize.setY(m_size.y()-padding.yButtom());
}
}
// limit the size of the element :
@ -120,15 +120,15 @@ void ewol::widget::PopUp::onDraw(void) {
void ewol::widget::PopUp::onRegenerateDisplay(void) {
if (true == needRedraw()) {
m_shaper.clear();
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
vec2 tmpSize(0,0);
bvec2 expand = canExpand();
bvec2 fill = canFill();
if (fill.x()) {
tmpSize.setX(m_size.x()-padding.x()*2);
tmpSize.setX(m_size.x()-padding.x());
}
if (fill.y()) {
tmpSize.setY(m_size.y()-padding.y()*2);
tmpSize.setY(m_size.y()-padding.y());
}
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->getSize();
@ -138,8 +138,8 @@ void ewol::widget::PopUp::onRegenerateDisplay(void) {
m_shaper.setOrigin(vec2(0,0));
m_shaper.setSize(vec2ClipInt32(m_size));
m_shaper.setInsidePos(vec2ClipInt32(tmpOrigin-padding));
m_shaper.setInsideSize(vec2ClipInt32(tmpSize + padding*2.0f));
m_shaper.setInsidePos(vec2ClipInt32(tmpOrigin-vec2(padding.x(), padding.y())));
m_shaper.setInsideSize(vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y())));
}
// SUBwIDGET GENERATION ...
if (NULL != m_subWidget) {
@ -196,7 +196,7 @@ bool ewol::widget::PopUp::onGetConfig(const char* _config, std::string& _result)
bool ewol::widget::PopUp::onEventInput(const ewol::event::Input& _event) {
if (0 != _event.getId()) {
if (true == m_closeOutEvent) {
vec2 padding = m_shaper.getPadding();
ewol::Padding padding = m_shaper.getPadding();
vec2 tmpSize(0,0);
if (NULL != m_subWidget) {
vec2 tmpSize = m_subWidget->getSize();
@ -204,8 +204,8 @@ bool ewol::widget::PopUp::onEventInput(const ewol::event::Input& _event) {
tmpSize.setMax(m_minSize);
vec2 tmpOrigin = (m_size-tmpSize)/2.0f;
tmpOrigin-=padding;
tmpSize += padding*2.0f;
tmpOrigin -= vec2(padding.xLeft(), padding.yButtom());
tmpSize += vec2(padding.x(), padding.y());
vec2 pos = relativePosition(_event.getPos());
if( pos.x() < tmpOrigin.x()
|| pos.y() < tmpOrigin.y()

@ -37,7 +37,7 @@ namespace ewol {
* @brief Constructor
* @param[in] _shaperName Shaper file properties
*/
PopUp(const std::string& _shaperName="THEME:GUI:PopUp.conf");
PopUp(const std::string& _shaperName="THEME:GUI:PopUp.json");
/**
* @brief Destructor
*/

@ -37,7 +37,6 @@ ewol::widget::WidgetScrolled::~WidgetScrolled(void) {
}
void ewol::widget::WidgetScrolled::onRegenerateDisplay(void) {
m_shaperH.clear();
m_shaperV.clear();
@ -47,29 +46,29 @@ void ewol::widget::WidgetScrolled::onRegenerateDisplay(void) {
}
if( m_size.y() < m_maxSize.y()
|| m_originScrooled.y()!=0) {
vec2 padding = m_shaperV.getPadding();
m_shaperV.setOrigin(vec2(m_size.x()-padding.x(), 0));
m_shaperV.setSize(vec2(padding.x(), m_size.y()));
ewol::Padding padding = m_shaperV.getPadding();
m_shaperV.setOrigin(vec2(m_size.x()-padding.xLeft(), 0));
m_shaperV.setSize(vec2(padding.xLeft(), m_size.y()));
float lenScrollBar = m_size.y()*m_size.y() / m_maxSize.y();
lenScrollBar = etk_avg(10, lenScrollBar, m_size.y());
float originScrollBar = m_originScrooled.y() / (m_maxSize.y()-m_size.y()*m_limitScrolling);
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
originScrollBar *= (m_size.y()-lenScrollBar);
m_shaperV.setInsidePos(vec2(m_size.x()-padding.x(), m_size.y() - originScrollBar - lenScrollBar));
m_shaperV.setInsideSize(vec2(padding.x(), lenScrollBar));
m_shaperV.setInsidePos(vec2(m_size.x()-padding.xLeft(), m_size.y() - originScrollBar - lenScrollBar));
m_shaperV.setInsideSize(vec2(padding.xLeft(), lenScrollBar));
}
if( m_size.x() < m_maxSize.x()
|| m_originScrooled.x()!=0) {
vec2 padding = m_shaperH.getPadding();
ewol::Padding padding = m_shaperH.getPadding();
m_shaperH.setOrigin(vec2(0, 0));
m_shaperH.setSize(vec2(m_size.x()-padding.x(), padding.y()));
float lenScrollBar = (m_size.x()-padding.x())*(m_size.x()-padding.x()) / m_maxSize.x();
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-padding.x()));
m_shaperH.setSize(vec2(m_size.x()-padding.xLeft(), padding.yButtom()));
float lenScrollBar = (m_size.x()-padding.xLeft())*(m_size.x()-padding.xRight()) / m_maxSize.x();
lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-padding.xRight()));
float originScrollBar = m_originScrooled.x() / (m_maxSize.x()-m_size.x()*m_limitScrolling);
originScrollBar = etk_avg(0.0, originScrollBar, 1.0);
originScrollBar *= (m_size.x()-padding.x()-lenScrollBar);
originScrollBar *= (m_size.x()-padding.xRight()-lenScrollBar);
m_shaperH.setInsidePos(vec2(originScrollBar, 0));
m_shaperH.setInsideSize(vec2(lenScrollBar, padding.y()));
m_shaperH.setInsideSize(vec2(lenScrollBar, padding.yButtom()));
}
}
@ -78,8 +77,8 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
vec2 relativePos = relativePosition(_event.getPos());
// corection due to the open Gl invertion ...
relativePos.setY(m_size.y() - relativePos.y());
vec2 paddingV = m_shaperV.getPadding();
vec2 paddingH = m_shaperH.getPadding();
ewol::Padding paddingV = m_shaperV.getPadding();
ewol::Padding paddingH = m_shaperH.getPadding();
if (m_scroollingMode == scroolModeNormal) {
if ( _event.getType() == ewol::key::typeMouse
&& ( m_highSpeedType == ewol::key::typeUnknow
@ -87,30 +86,30 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
if ( _event.getId() == 1
&& _event.getStatus() == ewol::key::statusDown) {
// check if selected the scrolling position whth the scrolling bar ...
if (relativePos.x() >= (m_size.x()-paddingV.x())) {
if (relativePos.x() >= (m_size.x()-paddingV.xLeft())) {
if( m_size.y() < m_maxSize.y()
|| m_originScrooled.y() != 0) {
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableVertical;
m_highSpeedType = ewol::key::typeMouse;
m_highSpeedStartPos.setX(relativePos.x());
m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.y()*2));
m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.yButtom()*2));
m_highSpeedButton = 1;
// force direct scrolling in this case
m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.y()) / (m_size.y()-paddingV.y()*2)));
m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (m_size.y()-paddingV.yButtom()*2)));
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
markToRedraw();
return true;
}
} else if (relativePos.y() >= (m_size.y()-paddingH.y())) {
} else if (relativePos.y() >= (m_size.y()-paddingH.yButtom())) {
if( m_size.x() < m_maxSize.x()
|| m_originScrooled.x()!=0) {
m_highSpeedMode = ewol::widget::Scroll::speedModeEnableHorizontal;
m_highSpeedType = ewol::key::typeMouse;
m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingH.x()*2));
m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingH.xLeft()*2));
m_highSpeedStartPos.setY(relativePos.y());
m_highSpeedButton = 1;
// force direct scrolling in this case
m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.x()) / (m_size.x()-paddingH.x()*2)));
m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (m_size.x()-paddingH.xLeft()*2)));
m_originScrooled.setY(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
markToRedraw();
return true;
@ -241,9 +240,9 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
}
}
if (m_highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal) {
m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingV.x()*2));
m_highSpeedStartPos.setX(m_originScrooled.x() / m_maxSize.x() * (m_size.x()-paddingV.x()));
} else {
m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.y()*2));
m_highSpeedStartPos.setY(m_originScrooled.y() / m_maxSize.y() * (m_size.y()-paddingV.y()));
}
markToRedraw();
}
@ -252,14 +251,14 @@ bool ewol::widget::WidgetScrolled::onEventInput(const ewol::event::Input& _event
}
if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableHorizontal
&& _event.getStatus() == ewol::key::statusMove) {
m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.x()) / (m_size.x()-paddingH.x()*2)));
m_originScrooled.setX((int32_t)(m_maxSize.x() * (relativePos.x()-paddingH.xLeft()) / (m_size.x()-paddingH.x())));
m_originScrooled.setX(etk_avg(0, m_originScrooled.x(), (m_maxSize.x() - m_size.x()*m_limitScrolling)));
markToRedraw();
return true;
}
if ( m_highSpeedMode == ewol::widget::Scroll::speedModeEnableVertical
&& _event.getStatus() == ewol::key::statusMove) {
m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.y()) / (m_size.y()-paddingV.y()*2)));
m_originScrooled.setY((int32_t)(m_maxSize.y() * (relativePos.y()-paddingV.yButtom()) / (m_size.y()-paddingV.y())));
m_originScrooled.setY(etk_avg(0, m_originScrooled.y(), (m_maxSize.y() - m_size.y()*m_limitScrolling)));
markToRedraw();
return true;

@ -52,7 +52,7 @@ namespace ewol {
* @brief Scroll Widget main constructor to be herited from an other widget (this is not a stand-alone widget)
* @param[in] _shaperName Shaper name if the scrolled widget.
*/
WidgetScrolled(const std::string& _shaperName="THEME:GUI:WidgetScrolled.conf");
WidgetScrolled(const std::string& _shaperName="THEME:GUI:WidgetScrolled.json");
/**
* @brief Scroll widget destructor.
*/