[DEV] Review THEME management to support sepatrated color from shader

This commit is contained in:
Edouard DUPIN 2014-01-17 22:49:11 +01:00
parent c2a6833037
commit 961415a05d
67 changed files with 740 additions and 250 deletions

View File

@ -11,6 +11,7 @@ uniform int EW_SoftEdge;
varying vec2 f_texcoord;
varying vec4 f_color;
varying float f_glyphLevel;
const float glyph_center = 0.50;
const float outline_center = 0.55;
@ -24,7 +25,7 @@ void main(void) {
vec4 color = texture2D(EW_texID, f_texcoord );
float dist = color.r;
float width = fwidth(dist);
float alpha = smoothstep(glyph_center-width, glyph_center+width, dist);
float alpha = smoothstep(f_glyphLevel-width, f_glyphLevel+width, dist);
// Smooth
gl_FragColor = vec4(f_color[0], f_color[1], f_color[2], f_color[3]*alpha);

View File

@ -7,11 +7,13 @@ precision mediump int;
attribute vec3 EW_coord3d;
attribute vec2 EW_texture2d;
attribute vec4 EW_color;
attribute float EW_glyphLevel;
uniform mat4 EW_MatrixTransformation;
// output :
varying vec4 f_color;
varying vec2 f_texcoord;
varying float f_glyphLevel;
void main(void) {
gl_Position = EW_MatrixTransformation * vec4(EW_coord3d, 1.0);
@ -19,6 +21,7 @@ void main(void) {
f_texcoord = EW_texture2d;
// set output color :
f_color = EW_color;
f_glyphLevel = EW_glyphLevel;
}

View File

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

View File

@ -0,0 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_border", color:"#FFFF" },
{ name:"EW_foreground", color:"#000A" },
]
}

View File

@ -0,0 +1,9 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_foreground", color:"#000A" },
{ name:"EW_foregroundSelected", color:"#FFF3" },
{ name:"EW_foregroundHover", color:"#00F2" },
{ name:"EW_border", color:"#000F" },
]
}

View File

@ -0,0 +1,6 @@
{
"color": [
{ name:"background", color:"#0000" },
{ name:"foreground", color:"#FFFF" }
]
}

View File

@ -0,0 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#000A" },
{ name:"EW_foreground", color:"#555A" },
{ name:"EW_border", color:"#FFFF" },
]
}

View File

@ -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:"#0A06" },
{ name:"EW_foregroundPressed", color:"#A006" },
]
}

View File

@ -0,0 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_border", color:"#000F" },
{ name:"EW_foreground", color:"#FFFA" },
]
}

View File

@ -0,0 +1,9 @@
{
"color": [
{ name:"EW_background", color:"#0000" },
{ name:"EW_foreground", color:"#FFFA" },
{ name:"EW_foregroundSelected", color:"#0005" },
{ name:"EW_foregroundHover", color:"#00F5" },
{ name:"EW_border", color:"#FFFF" },
]
}

View File

@ -0,0 +1,6 @@
{
"color": [
{ name:"background", color:"#0000" },
{ name:"foreground", color:"#000F" }
]
}

View File

@ -0,0 +1,7 @@
{
"color": [
{ name:"EW_background", color:"#888A" },
{ name:"EW_foreground", color:"#FFFA" },
{ name:"EW_border", color:"#FFFF" },
]
}

View File

@ -1,55 +0,0 @@
#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;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec4 v_colorTansition;
// internal :
vec4 S_colorFg[4];
void main(void) {
S_colorFg[0] = vec4(0.5,0.5,0.5,0.3);
S_colorFg[1] = vec4(0.7,0.0,0.0,0.4);
S_colorFg[2] = vec4(0.0,0.0,0.7,0.4);
S_colorFg[3] = vec4(0.0,0.7,0.0,0.4);
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
vec4 colorOld = S_colorFg[0];
if(EW_status.stateOld==1) {
colorOld = S_colorFg[1];
} else if(EW_status.stateOld==2) {
colorOld = S_colorFg[2];
} else if(EW_status.stateOld==3) {
colorOld = S_colorFg[3];
}
vec4 colorNew = S_colorFg[0];
if(EW_status.stateNew==1) {
colorNew = S_colorFg[1];
} else if(EW_status.stateNew==2) {
colorNew = S_colorFg[2];
} else if(EW_status.stateNew==3) {
colorNew = S_colorFg[3];
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld*(1.0-EW_status.transition)
+ colorNew*EW_status.transition;
}

View File

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

View File

@ -1,56 +0,0 @@
#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;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec4 v_colorTansition;
// internal :
vec4 S_colorFg[4];
void main(void) {
S_colorFg[0] = vec4(0.5,0.5,0.5,0.3);
S_colorFg[1] = vec4(0.7,0.0,0.0,0.4);
S_colorFg[2] = vec4(0.0,0.0,0.7,0.4);
S_colorFg[3] = vec4(0.0,0.7,0.0,0.4);
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
vec4 colorOld = S_colorFg[0];
if(EW_status.stateOld==1) {
colorOld = S_colorFg[1];
} else if(EW_status.stateOld==2) {
colorOld = S_colorFg[2];
} else if(EW_status.stateOld==3) {
colorOld = S_colorFg[3];
}
vec4 colorNew = S_colorFg[0];
if(EW_status.stateNew==1) {
colorNew = S_colorFg[1];
} else if(EW_status.stateNew==2) {
colorNew = S_colorFg[2];
} else if(EW_status.stateNew==3) {
colorNew = S_colorFg[3];
}
// note : int() is needed for the OpenGL ES platform
v_colorTansition = colorOld*(1.0-EW_status.transition)
+ colorNew*EW_status.transition;
}

View File

@ -6,7 +6,9 @@ ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=widgetContextMenu.prog
program=THEME:GUI:Button.prog
# the associated color theme
color=THEME:COLOR:Button.json

View File

@ -16,17 +16,17 @@ struct widgetStateProperty {
float transition;
};
uniform displayProperty EW_widgetProperty;
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
vec4 S_colorBg = vec4(0.0);
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; //==> this id for 1 px border
float S_roundedRatio = 10.0;
@ -57,12 +57,12 @@ void main(void) {
S_roundedRatio + S_sizeBorder*1.5,
tmpDist);
// set Background
gl_FragColor = S_colorBg;
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 + S_colorBorder*(1.0-tmpVal2);
gl_FragColor = gl_FragColor*tmpVal2 + v_colorBorder*(1.0-tmpVal2);
}

View File

@ -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;
}

View File

@ -6,7 +6,9 @@ ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=widgetPopUp.prog
program=THEME:GUI:ContextMenu.prog
# the associated color theme
color=THEME:COLOR:ContextMenu.json

View File

@ -16,17 +16,16 @@ struct widgetStateProperty {
float transition;
};
uniform displayProperty EW_widgetProperty;
uniform displayProperty EW_widgetProperty;
uniform widgetStateProperty EW_status;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
vec4 S_colorBg = vec4(0.0);
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 3.0; // must not be NULL
float S_sizeBorder = 2.0; //==> this id for 1 px border
float S_roundedRatio = 10.0;
@ -57,12 +56,12 @@ void main(void) {
S_roundedRatio + S_sizeBorder*1.5,
tmpDist);
// set Background
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
// set foreground
gl_FragColor = gl_FragColor*tmpVal + S_colorFg*(1.0-tmpVal);
gl_FragColor = gl_FragColor*tmpVal + EW_foreground*(1.0-tmpVal);
// set border
float tmpVal2 = abs(tmpVal-0.5)*2.0;
gl_FragColor = gl_FragColor*tmpVal2 + S_colorBorder*(1.0-tmpVal2);
gl_FragColor = gl_FragColor*tmpVal2 + EW_border*(1.0-tmpVal2);
}

View File

@ -4,7 +4,9 @@ PaddingY=7
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=widgetEntry.prog
program=THEME:GUI:Entry.prog
# the associated color theme
color=THEME:COLOR:Entry.json

View File

@ -16,7 +16,10 @@ struct widgetStateProperty {
float transition;
};
uniform displayProperty EW_widgetProperty;
uniform displayProperty EW_widgetProperty;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
uniform widgetStateProperty EW_status;
@ -24,9 +27,6 @@ uniform widgetStateProperty EW_status;
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.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; //==> this id for 1 px border
float S_roundedRatio = 10.0;
@ -56,11 +56,11 @@ void main(void) {
S_roundedRatio + S_sizeBorder*1.5,
tmpDist);
// set Background
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
// set foreground
gl_FragColor = gl_FragColor*tmpVal + S_colorFg*(1.0-tmpVal);
gl_FragColor = gl_FragColor*tmpVal + EW_foreground*(1.0-tmpVal);
// set border
float tmpVal2 = abs(tmpVal-0.5)*2.0;
gl_FragColor = gl_FragColor*tmpVal2 + S_colorBorder*(1.0-tmpVal2);
gl_FragColor = gl_FragColor*tmpVal2 + EW_border*(1.0-tmpVal2);
}

View File

@ -6,7 +6,9 @@ ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=widgetButton.prog
program=THEME:GUI:PopUp.prog
# the associated color theme
color=THEME:COLOR:PopUp.json

View File

@ -19,14 +19,14 @@ struct widgetStateProperty {
uniform displayProperty EW_widgetProperty;
uniform widgetStateProperty EW_status;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
vec4 S_colorBg = vec4(0.5,0.5,0.5,0.8);
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 3.0; // must not be NULL
float S_sizeBorder = 2.0; //==> this id for 1 px border
float S_roundedRatio = 10.0;
@ -57,12 +57,12 @@ void main(void) {
S_roundedRatio + S_sizeBorder*1.5,
tmpDist);
// set Background
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
// set foreground
gl_FragColor = gl_FragColor*tmpVal + S_colorFg*(1.0-tmpVal);
gl_FragColor = gl_FragColor*tmpVal + EW_foreground*(1.0-tmpVal);
// set border
float tmpVal2 = abs(tmpVal-0.5)*2.0;
gl_FragColor = gl_FragColor*tmpVal2 + S_colorBorder*(1.0-tmpVal2);
gl_FragColor = gl_FragColor*tmpVal2 + EW_border*(1.0-tmpVal2);
}

View File

@ -6,7 +6,9 @@ ChangeTime=356
# if an image is needed :
#image=plop.png
# the associated openGL ES-2 program :
program=widgetButton.prog
program=THEME:GUI:Button.prog
# the associated color theme
color=THEME:COLOR:Button.json

View File

@ -16,10 +16,10 @@ 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
vec4 S_colorBg = vec4(0.0);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 3.0;
float S_sizeBorder = 1.0;
@ -39,13 +39,13 @@ void main(void) {
|| position.x> endStart.x
|| position.y> endStart.y
) {
gl_FragColor = S_colorBorder;
gl_FragColor = v_colorBorder;
} else {
// note : int() is needed for the OpenGL ES platform
gl_FragColor = v_colorTansition;
}
} else {
gl_FragColor = S_colorBg;
gl_FragColor = v_colorBackground;
}
}

View File

@ -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;
}

View File

@ -4,5 +4,7 @@ PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=widgetContextMenu.prog
program=THEME:GUI:ContextMenu.prog
# the associated color theme
color=THEME:COLOR:ContextMenu.json

View File

@ -9,17 +9,16 @@ struct displayProperty {
vec2 insideSize;
};
uniform displayProperty EW_widgetProperty;
uniform displayProperty EW_widgetProperty;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
vec4 S_colorBg = vec4(0.0);
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 1.0;
float S_sizeBorder = 3.0;
@ -39,13 +38,13 @@ void main(void) {
|| position.x> endStart.x
|| position.y> endStart.y
) {
gl_FragColor = S_colorBorder;
gl_FragColor = EW_border;
} else {
// note : int() is needed for the OpenGL ES platform
gl_FragColor = S_colorFg;
gl_FragColor = EW_foreground;
}
} else {
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
}
}

View File

@ -4,5 +4,7 @@ PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=widgetEntry.prog
program=THEME:GUI:Entry.prog
# the associated color theme
color=THEME:COLOR:Entry.json

View File

@ -11,6 +11,8 @@ struct displayProperty {
uniform displayProperty EW_widgetProperty;
uniform vec4 EW_background;
uniform vec4 EW_border;
// transmit from the vertex shader
@ -18,8 +20,6 @@ varying vec2 v_position; // interpolated position ...
varying vec4 v_colorTansition;
// internal static define
vec4 S_colorBg = vec4(0.0);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 3.0;
float S_sizeBorder = 1.0;
@ -42,13 +42,13 @@ void main(void) {
|| position.y> endStart.y
) {
// border ...
gl_FragColor = S_colorBorder;
gl_FragColor = EW_border;
} else {
// note : int() is needed for the OpenGL ES platform
gl_FragColor = v_colorTansition;
}
} else {
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
}
}

View File

@ -11,37 +11,34 @@ struct widgetStateProperty {
// Input :
attribute vec2 EW_coord2d;
uniform mat4 EW_MatrixTransformation;
uniform mat4 EW_MatrixTransformation;
uniform widgetStateProperty EW_status;
uniform vec4 EW_foreground;
uniform vec4 EW_foregroundSelected;
uniform vec4 EW_foregroundHover;
// output :
varying vec2 v_position; // This will be passed into the fragment shader.
varying vec4 v_colorTansition;
// internal :
vec4 S_colorFg[3];
void main(void) {
S_colorFg[0] = vec4(1.0,1.0,1.0,0.8);
S_colorFg[1] = vec4(1.0,1.0,1.0,0.4);
S_colorFg[2] = vec4(0.0,0.0,1.0,0.1);
gl_Position = EW_MatrixTransformation * vec4(EW_coord2d, 0.0, 1.0);
// transmit position of the curent element (intermolated ...)
v_position = EW_coord2d;
vec4 colorOld = S_colorFg[0];
vec4 colorOld = EW_foreground;
if(EW_status.stateOld==1) {
colorOld = S_colorFg[1];
colorOld = EW_foregroundSelected;
} else if(EW_status.stateOld==2) {
colorOld = S_colorFg[2];
colorOld = EW_foregroundHover;
}
vec4 colorNew = S_colorFg[0];
vec4 colorNew = EW_foreground;
if(EW_status.stateNew==1) {
colorNew = S_colorFg[1];
colorNew = EW_foregroundSelected;
} else if(EW_status.stateNew==2) {
colorNew = S_colorFg[2];
colorNew = EW_foregroundHover;
}
// note : int() is needed for the OpenGL ES platform

View File

@ -4,5 +4,7 @@ PaddingY=8
# change status in ms
ChangeTime=356
# the associated openGL ES-2 program :
program=widgetPopUp.prog
program=THEME:GUI:PopUp.prog
# the associated color theme
color=THEME:COLOR:PopUp.json

View File

@ -11,15 +11,15 @@ struct displayProperty {
uniform displayProperty EW_widgetProperty;
uniform vec4 EW_background;
uniform vec4 EW_foreground;
uniform vec4 EW_border;
// transmit from the vertex shader
varying vec2 v_position; // interpolated position ...
// internal static define
vec4 S_colorBg = vec4(0.5,0.5,0.5,0.8);
vec4 S_colorFg = vec4(1.0,1.0,1.0,0.8);
vec4 S_colorBorder = vec4(0.0,0.0,0.0,1.0);
float S_sizePadding = 1.0;
float S_sizeBorder = 3.0;
@ -39,13 +39,13 @@ void main(void) {
|| position.x> endStart.x
|| position.y> endStart.y
) {
gl_FragColor = S_colorBorder;
gl_FragColor = EW_border;
} else {
// note : int() is needed for the OpenGL ES platform
gl_FragColor = S_colorFg;
gl_FragColor = EW_foreground;
}
} else {
gl_FragColor = S_colorBg;
gl_FragColor = EW_background;
}
}

2
external/etk vendored

@ -1 +1 @@
Subproject commit 8c3d0e0fcf81a60db60c447ec2abd0239274ef47
Subproject commit 7d28c888f7d4d9b3aa92274db82ffeaa63a6a681

View File

@ -20,6 +20,8 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) :
m_confIdPaddingY(-1),
m_confIdChangeTime(-1),
m_confProgramFile(-1),
m_confColorFile(-1),
m_confImageFile(-1),
m_GLprogram(NULL),
m_GLPosition(-1),
m_GLMatrix(-1),
@ -50,11 +52,13 @@ void ewol::compositing::Shaper::unLoadProgram(void) {
ewol::resource::Program::release(m_GLprogram);
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_confIdChangeTime = -1;
m_confProgramFile = -1;
m_confImageFile = -1;
m_listAssiciatedId.clear();
}
void ewol::compositing::Shaper::loadProgram(void) {
@ -69,17 +73,23 @@ void ewol::compositing::Shaper::loadProgram(void) {
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!="") {
// get the relative position of the current file ...
etk::FSNode file(m_name);
std::string tmpFilename = file.getRelativeFolder() + basicShaderFile;
EWOL_DEBUG("Shaper try load shader : " << tmpFilename << " with base : " << basicShaderFile);
if (basicShaderFile != "") {
std::string tmpFilename(basicShaderFile);
if (tmpFilename.find(':') == std::string::npos) {
// get the relative position of the current file ...
etk::FSNode file(m_name);
tmpFilename = file.getRelativeFolder() + basicShaderFile;
EWOL_DEBUG("Shaper try load shader : '" << tmpFilename << "' with base : '" << basicShaderFile << "'");
} else {
EWOL_DEBUG("Shaper try load shader : '" << tmpFilename << "'");
}
// get the shader resource :
m_GLPosition = 0;
m_GLprogram = ewol::resource::Program::keep(tmpFilename);
if (NULL !=m_GLprogram) {
if (m_GLprogram != NULL) {
m_GLPosition = m_GLprogram->getAttribute("EW_coord2d");
m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation");
// Widget property == > for the Vertex shader
@ -96,11 +106,41 @@ void ewol::compositing::Shaper::loadProgram(void) {
}
std::string basicImageFile = m_config->getString(m_confImageFile);
if (basicImageFile != "") {
tmpFilename = file.getRelativeFolder() + basicImageFile;
std::string tmpFilename(basicImageFile);
if (tmpFilename.find(':') == std::string::npos) {
// get the relative position of the current file ...
etk::FSNode file(m_name);
tmpFilename = file.getRelativeFolder() + basicImageFile;
EWOL_DEBUG("Shaper try load shaper image : '" << tmpFilename << "' with base : '" << basicImageFile << "'");
} else {
EWOL_DEBUG("Shaper try load shaper image : '" << tmpFilename << "'");
}
ivec2 size(64,64);
m_resourceTexture = ewol::resource::TextureFile::keep(tmpFilename, size);
}
}
std::string basicColorFile = m_config->getString(m_confColorFile);
if (basicColorFile != "") {
std::string tmpFilename(basicColorFile);
if (tmpFilename.find(':') == std::string::npos) {
// get the relative position of the current file ...
etk::FSNode file(m_name);
tmpFilename = file.getRelativeFolder() + basicColorFile;
EWOL_DEBUG("Shaper try load colorFile : '" << tmpFilename << "' with base : '" << basicColorFile << "'");
} else {
EWOL_DEBUG("Shaper try load colorFile : '" << tmpFilename << "'");
}
m_colorProperty = ewol::resource::ColorFile::keep(tmpFilename);
if ( m_GLprogram != NULL
&& m_colorProperty != NULL) {
std::vector<std::string> listColor = m_colorProperty->getColors();
for (auto tmpColor : listColor) {
int32_t glId = m_GLprogram->getUniform(tmpColor);
int32_t colorID = m_colorProperty->request(tmpColor);
m_listAssiciatedId.push_back(ivec2(glId, colorID));
}
}
}
}
void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
@ -127,7 +167,9 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) {
m_GLprogram->uniform1i(m_GLStateOld, m_stateOld);
m_GLprogram->uniform1i(m_GLStateNew, m_stateNew);
m_GLprogram->uniform1f(m_GLStateTransition, m_stateTransition);
for (auto element : m_listAssiciatedId) {
m_GLprogram->uniform(element.x(), m_colorProperty->get(element.y()));
}
if (NULL!=m_resourceTexture) {
// TextureID
m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId());

View File

@ -13,6 +13,7 @@
#include <ewol/compositing/Compositing.h>
#include <ewol/resource/Program.h>
#include <ewol/resource/ConfigFile.h>
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Image.h>
#include <ewol/event/Time.h>
@ -32,6 +33,7 @@ namespace ewol {
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
// openGL shaders programs:
ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program
@ -57,6 +59,9 @@ namespace ewol {
int32_t m_stateNew; //!< destination state
float m_stateTransition; //!< working state between 2 states
vec2 m_coord[6]; //!< the double triangle coordonates
// color management theme:
ewol::resource::ColorFile* m_colorProperty; //!< input resource for color management
std::vector<ivec2> m_listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X)
private:
/**
* @brief load the openGL program and get all the ID needed

View File

@ -15,11 +15,13 @@
#define __class__ "ewol::compositing::TextBase"
ewol::compositing::TextBase::TextBase(const std::string& _shaderName) :
ewol::compositing::TextBase::TextBase(const std::string& _shaderName, bool _loadProgram) :
m_position(0.0, 0.0, 0.0),
m_clippingPosStart(0.0, 0.0, 0.0),
m_clippingPosStop(0.0, 0.0, 0.0),
m_clippingEnable(false),
m_defaultColorFg(etk::color::black),
m_defaultColorBg(etk::color::none),
m_color(etk::color::black),
m_colorBg(etk::color::none),
m_colorCursor(etk::color::black),
@ -38,7 +40,9 @@ ewol::compositing::TextBase::TextBase(const std::string& _shaderName) :
m_GLtexID(-1),
m_selectionStartPos(-100),
m_cursorPos(-100) {
loadProgram(_shaderName);
if (_loadProgram == true) {
loadProgram(_shaderName);
}
}
@ -97,8 +101,8 @@ void ewol::compositing::TextBase::reset(void) {
m_sizeDisplayStop = m_position;
m_nbCharDisplayed = 0;
m_clippingEnable = false;
m_color = etk::color::black;
m_colorBg = etk::color::none;
m_color = m_defaultColorFg;
m_colorBg = m_defaultColorBg;
m_mode = ewol::font::Regular;
m_previousCharcode = 0;
m_startTextpos = 0;
@ -351,8 +355,8 @@ void ewol::compositing::TextBase::printHTML(const std::string& _text) {
exml::Document doc;
// reset parameter :
m_htmlDecoTmp.m_colorBg = etk::color::none;
m_htmlDecoTmp.m_colorFg = etk::color::black;
m_htmlDecoTmp.m_colorBg = m_defaultColorBg;
m_htmlDecoTmp.m_colorFg = m_defaultColorFg;
m_htmlDecoTmp.m_mode = ewol::font::Regular;
if (doc.parse(_text) == false) {
@ -379,8 +383,8 @@ void ewol::compositing::TextBase::printHTML(const std::u32string& _text) {
exml::Document doc;
// reset parameter :
m_htmlDecoTmp.m_colorBg = etk::color::none;
m_htmlDecoTmp.m_colorFg = etk::color::black;
m_htmlDecoTmp.m_colorBg = m_defaultColorBg;
m_htmlDecoTmp.m_colorFg = m_defaultColorFg;
m_htmlDecoTmp.m_mode = ewol::font::Regular;
// TODO : Create an instance of xml parser to manage std::u32string...
if (doc.parse(std::to_string(_text)) == false) {

View File

@ -60,6 +60,9 @@ namespace ewol {
vec3 m_clippingPosStart; //!< Clipping start position
vec3 m_clippingPosStop; //!< Clipping stop position
bool m_clippingEnable; //!< true if the clipping must be activated
protected:
etk::Color<> m_defaultColorFg; //!< The text foreground color
etk::Color<> m_defaultColorBg; //!< The text background color
protected:
etk::Color<> m_color; //!< The text foreground color
etk::Color<> m_colorBg; //!< The text background color
@ -93,12 +96,12 @@ namespace ewol {
/**
* @brief load the openGL program and get all the ID needed
*/
void loadProgram(const std::string& _shaderName);
virtual void loadProgram(const std::string& _shaderName);
public:
/**
* @brief generic constructor
*/
TextBase(const std::string& _shaderName="DATA:text.prog");
TextBase(const std::string& _shaderName = "DATA:text.prog", bool _loadProgram = true);
/**
* @brief generic destructor
*/
@ -165,11 +168,27 @@ namespace ewol {
inline void setRelPos(const vec2& _pos) {
setRelPos(vec3(_pos.x(),_pos.y(),0));
};
/**
* @brief set the default background color of the font (when reset, set this value ...)
* @param[in] _color Color to set on background
*/
void setDefaultColorBg(const etk::Color<>& _color) {
m_defaultColorBg = _color;
}
/**
* @brief set the default Foreground color of the font (when reset, set this value ...)
* @param[in] _color Color to set on foreground
*/
void setDefaultColorFg(const etk::Color<>& _color) {
m_defaultColorFg = _color;
}
/**
* @brief set the Color of the current foreground font
* @param[in] _color Color to set on foreground (for next print)
*/
void setColor(const etk::Color<>& _color) { m_color = _color; };
void setColor(const etk::Color<>& _color) {
m_color = _color;
};
/**
* @brief set the background color of the font (for selected Text (not the global BG))
* @param[in] _color Color to set on background (for next print)

View File

@ -16,11 +16,12 @@
ewol::compositing::TextDF::TextDF(const std::string& _fontName, int32_t _fontSize) :
ewol::compositing::TextBase("DATA:fontDistanceField/font1.prog"),
ewol::compositing::TextBase("", false),
m_fontDF(NULL),
m_GLglyphLevel(-1),
m_size(12.0) {
setFont(_fontName, _fontSize);
// TODO : Reset size .... when reset ...
loadProgram("DATA:fontDistanceField/font1.prog");
}
@ -33,7 +34,6 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
// draw BG in any case:
m_vectorialDraw.draw();
EWOL_WARNING("draw DF...");
if (m_coord.size() <= 0 || m_fontDF == NULL) {
//EWOL_WARNING("Nothink to draw...");
return;
@ -59,12 +59,10 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x());
// position :
m_GLprogram->sendAttribute(m_GLPosition, m_coord);
// Texture :
m_GLprogram->sendAttribute(m_GLtexture, m_coordTex);
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel);
// Request the draw od the elements :
ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
m_GLprogram->unUse();
@ -75,7 +73,6 @@ void ewol::compositing::TextDF::drawMT(const mat4& _transformationMatrix, bool _
void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
EWOL_WARNING("draw DF.2.");
// draw BG in any case:
m_vectorialDraw.draw();
@ -100,17 +97,27 @@ void ewol::compositing::TextDF::drawD(bool _disableDepthTest) {
m_GLprogram->setTexture0(m_GLtexID, m_fontDF->getId());
m_GLprogram->uniform1i(m_GLtextWidth, m_fontDF->getOpenGlSize().x());
m_GLprogram->uniform1i(m_GLtextHeight, m_fontDF->getOpenGlSize().x());
// position :
m_GLprogram->sendAttribute(m_GLPosition, m_coord);
// Texture :
m_GLprogram->sendAttribute(m_GLtexture, m_coordTex);
// color :
m_GLprogram->sendAttribute(m_GLColor, m_coordColor);
m_GLprogram->sendAttribute(m_GLglyphLevel, m_glyphLevel);
// Request the draw od the elements :
ewol::openGL::drawArrays(GL_TRIANGLES, 0, m_coord.size());
m_GLprogram->unUse();
}
void ewol::compositing::TextDF::clear(void) {
ewol::compositing::TextBase::clear();
m_glyphLevel.clear();
}
void ewol::compositing::TextDF::loadProgram(const std::string& _shaderName) {
ewol::compositing::TextBase::loadProgram(_shaderName);
if (m_GLprogram != NULL) {
m_GLglyphLevel = m_GLprogram->getAttribute("EW_glyphLevel");
}
}
float ewol::compositing::TextDF::getHeight(void) {
if (m_fontDF == NULL) {
EWOL_WARNING("no font...");
@ -167,6 +174,9 @@ void ewol::compositing::TextDF::setFontMode(enum ewol::font::mode _mode) {
m_mode = _mode;
}
//#define ANGLE_OF_ITALIC (tan(0.4))
#define ANGLE_OF_ITALIC (0.00698143f)
void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
// get a pointer on the glyph property :
@ -189,7 +199,21 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
}
}
// 0x01 == 0x20 == ' ';
if (_charcode != 0x01) {
if ( _charcode != 0x01
&& _charcode != 0x20) {
float glyphLevel = 0.5f;
if ( m_mode == ewol::font::BoldItalic
|| m_mode == ewol::font::Bold) {
glyphLevel = 0.41f;
}
float italicMove = 0.0f;
if ( m_mode == ewol::font::BoldItalic
|| m_mode == ewol::font::Italic) {
// This is a simple version of Italic mode, in theory we need to move the up and the down...
italicMove = (float)myGlyph->m_sizeTexture.y() * factorDisplay * ANGLE_OF_ITALIC;
// TODO : pb on the clipper...
}
/* Bitmap position
* xA xB
* yC *------*
@ -287,8 +311,8 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
*/
if (m_needDisplay == true) {
vec3 bitmapDrawPos[4];
bitmapDrawPos[0].setValue(dxA, dyC, 0);
bitmapDrawPos[1].setValue(dxB, dyC, 0);
bitmapDrawPos[0].setValue(dxA+italicMove, dyC, 0);
bitmapDrawPos[1].setValue(dxB+italicMove, dyC, 0);
bitmapDrawPos[2].setValue(dxB, dyD, 0);
bitmapDrawPos[3].setValue(dxA, dyD, 0);
/* texture Position :
@ -323,6 +347,9 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
m_coordColor.push_back(m_color);
m_coordColor.push_back(m_color);
m_coordColor.push_back(m_color);
m_glyphLevel.push_back(glyphLevel);
m_glyphLevel.push_back(glyphLevel);
m_glyphLevel.push_back(glyphLevel);
/* Step 2 :
*
* **
@ -342,6 +369,9 @@ void ewol::compositing::TextDF::printChar(const char32_t& _charcode) {
m_coordColor.push_back(m_color);
m_coordColor.push_back(m_color);
m_coordColor.push_back(m_color);
m_glyphLevel.push_back(glyphLevel);
m_glyphLevel.push_back(glyphLevel);
m_glyphLevel.push_back(glyphLevel);
}
}
}

View File

@ -24,6 +24,9 @@ namespace ewol {
class TextDF : public ewol::compositing::TextBase {
protected:
ewol::resource::DistanceFieldFont* m_fontDF; //!< Font resources
std::vector<float> m_glyphLevel; //!< Level of display of the glyph (notmal : 0.50, bold : 0.40, super bold : 0.30 ...)
protected:
int32_t m_GLglyphLevel; //!< openGL Id on the glyph level display
public:
/**
* @brief generic constructor
@ -36,6 +39,7 @@ namespace ewol {
*/
virtual ~TextDF(void);
public:
virtual void clear(void);
virtual void drawD(bool _disableDepthTest);
virtual void drawMT(const mat4& _transformationMatrix, bool _enableDepthTest);
protected:
@ -48,6 +52,7 @@ namespace ewol {
virtual ewol::GlyphProperty * getGlyphPointer(char32_t _charcode);
public:
virtual void loadProgram(const std::string& _shaderName);
virtual void setFontSize(int32_t _fontSize);
virtual void setFontName(const std::string& _fontName);
virtual void setFont(std::string _fontName, int32_t _fontSize);

View File

@ -291,6 +291,9 @@ ewol::Context::Context(int32_t _argc, const char* _argv[]) :
EWOL_INFO(" == > Ewol system init (BEGIN)");
// set the curent interface :
lockContext();
// By default we set 2 themes (1 color and 1 shape ...) :
etk::theme::setNameDefault("GUI", "shape/square/");
etk::theme::setNameDefault("COLOR", "color/black/");
// parse the debug level:
for(int32_t iii = 0; iii < m_commandLine.size() ; ++iii) {
if (m_commandLine.get(iii) == "-l0") {

View File

@ -0,0 +1,112 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#include <etk/os/FSNode.h>
#include <ewol/debug.h>
#include <ewol/resource/ColorFile.h>
#include <ewol/resource/Manager.h>
#include <ejson/ejson.h>
#include <stdexcept>
#undef __class__
#define __class__ "resource::ColorFile"
ewol::resource::ColorFile::ColorFile(const std::string& _filename) :
ewol::Resource(_filename),
m_errorColor(etk::color::orange) {
addObjectType("ewol::ColorFile");
EWOL_DEBUG("CF : load \"" << _filename << "\"");
reload();
EWOL_DEBUG("List of all color : " << m_list.getKeys());
}
ewol::resource::ColorFile::~ColorFile(void) {
// remove all element
m_list.clear();
}
void ewol::resource::ColorFile::reload(void) {
// remove all previous set of value :
for (int32_t iii = 0; iii < m_list.size() ; ++iii) {
m_list[iii] = m_errorColor;
}
// open and read all json elements:
ejson::Document doc;
if (false == doc.load(m_name)) {
EWOL_ERROR("Can not load file : '" << m_name << "' = " << etk::FSNode(m_name).getFileSystemName());
return;
}
ejson::Array* baseArray = doc.getArray("color");
if (baseArray == NULL) {
EWOL_ERROR("Can not get basic array : 'color'");
return;
}
for (int32_t iii = 0; iii < baseArray->size(); ++iii) {
ejson::Object* tmpObj = baseArray->getObject(iii);
if (tmpObj == NULL) {
EWOL_DEBUG(" can not get object in 'color' id=" << iii);
continue;
}
std::string name = tmpObj->getStringValue("name", "");
std::string color = tmpObj->getStringValue("color", m_errorColor.getHexString());
EWOL_DEBUG("find new color : '" << name << "' color='" << color << "'");
if (name.size() == 0) {
EWOL_ERROR("Drop an empty name");
continue;
}
m_list.add(name, etk::Color<float>(color));
}
}
int32_t ewol::resource::ColorFile::request(const std::string& _paramName) {
// check if the parameters existed :
if (m_list.exist(_paramName) == false) {
m_list.add(_paramName, m_errorColor);
}
return m_list.getId(_paramName);
}
ewol::resource::ColorFile* ewol::resource::ColorFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : ColorFile : file : \"" << _filename << "\"");
ewol::resource::ColorFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::ColorFile*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}
// this element create a new one every time ....
object = new ewol::resource::ColorFile(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : " << _filename);
return NULL;
}
getManager().localAdd(object);
return object;
}
void ewol::resource::ColorFile::release(ewol::resource::ColorFile*& _object) {
if (NULL == _object) {
return;
}
ewol::Resource* object2 = static_cast<ewol::Resource*>(_object);
getManager().release(object2);
_object = NULL;
}

View File

@ -0,0 +1,89 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __SIMPLE_COLOR_FILE_H__
#define __SIMPLE_COLOR_FILE_H__
#include <etk/types.h>
#include <etk/Color.h>
#include <etk/Hash.h>
#include <ewol/debug.h>
#include <ewol/resource/Resource.h>
namespace ewol {
namespace resource {
/**
* @brief ColorFile is a Resource designed to be specific with the theme (for example black, or white or orange ...)
*/
class ColorFile : public ewol::Resource {
private:
etk::Hash<etk::Color<float> > m_list; //!< List of all color in the file
etk::Color<float> m_errorColor; //!< Error returned color
protected:
/**
* @brief Constructor of the color property file
* @param[in] _filename Name of the file needed
*/
ColorFile(const std::string& _filename);
/**
* @brief Simple Destructor of this class (nothing specific ...)
*/
virtual ~ColorFile(void);
public:
/**
* @brief Set the error color.
* @param[in] _errorColor Color that might be set when not finding a color
*/
void setErrorColor(const etk::Color<float>& _errorColor) {
m_errorColor = _errorColor;
}
/**
* @brief Request the presence of a specific color.
* @param[in] _paramName Name of the color.
* @return A unique ID of the color (or -1 if an error occured).
*/
int32_t request(const std::string& _paramName);
/**
* @brief Get the associated color of the ID.
* @param[in] _Id Id of the color.
* @return The requested color.
*/
const etk::Color<float>& get(int32_t _id) {
if (_id<0) {
return m_errorColor;
}
return m_list[_id];
};
/**
* @brief Get All color name
* @return list of all color existing
*/
std::vector<std::string> getColors(void) const {
return m_list.getKeys();
}
public: // herited function:
void reload(void);
public:
/**
* @brief keep the resource pointer.
* @note Never free this pointer by your own...
* @param[in] _filename Name of the configuration file.
* @return pointer on the resource or NULL if an error occured.
*/
static ewol::resource::ColorFile* keep(const std::string& _filename);
/**
* @brief release the keeped resources
* @param[in,out] reference on the object pointer
*/
static void release(ewol::resource::ColorFile*& _object);
};
};
};
#endif

View File

@ -160,7 +160,7 @@ ewol::resource::Colored3DObject* ewol::resource::Colored3DObject::keep(void) {
// need to crate a new one ...
ewol::resource::Colored3DObject* object = new ewol::resource::Colored3DObject();
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : Colored3DObject ");
EWOL_ERROR("allocation error of a resource : ???Colored3DObject??? ");
return NULL;
}
getManager().localAdd(object);

View File

@ -159,14 +159,22 @@ int32_t ewol::resource::ConfigFile::request(const std::string& _paramName) {
ewol::resource::ConfigFile* ewol::resource::ConfigFile::keep(const std::string& _filename) {
EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\"");
ewol::resource::ConfigFile* object = static_cast<ewol::resource::ConfigFile*>(getManager().localKeep(_filename));
ewol::resource::ConfigFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::ConfigFile*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}
// this element create a new one every time ....
object = new ewol::resource::ConfigFile(_filename);
if (NULL == object) {
EWOL_ERROR("allocation error of a resource : ??Mesh.obj??");
EWOL_ERROR("allocation error of a resource : '" << _filename << "'");
return NULL;
}
getManager().localAdd(object);

View File

@ -15,6 +15,7 @@
namespace ewol {
namespace resource {
// TODO : Show if it is possible to integrate this in a json interface ==> simplify code ...
/**
* @not-in-doc
*/
@ -32,10 +33,16 @@ namespace ewol {
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; };
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 {

View File

@ -330,7 +330,15 @@ ewol::GlyphProperty* ewol::resource::DistanceFieldFont::getGlyphPointer(const ch
ewol::resource::DistanceFieldFont* ewol::resource::DistanceFieldFont::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : DistanceFieldFont : file : '" << _filename << "'");
ewol::resource::DistanceFieldFont* object = static_cast<ewol::resource::DistanceFieldFont*>(getManager().localKeep(_filename));
ewol::resource::DistanceFieldFont* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::DistanceFieldFont*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -389,7 +389,15 @@ void ewol::resource::FontFreeType::display(void) {
ewol::resource::FontBase* ewol::resource::FontFreeType::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Font : file : \"" << _filename << "\"");
ewol::resource::FontBase* object = static_cast<ewol::resource::FontBase*>(getManager().localKeep(_filename));
ewol::resource::FontBase* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::FontBase*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -97,7 +97,15 @@ ewol::resource::TextureFile* ewol::resource::TextureFile::keep(const std::string
}
EWOL_VERBOSE("KEEP: TextureFile: '" << TmpFilename << "' new size=" << _size);
ewol::resource::TextureFile* object = static_cast<ewol::resource::TextureFile*>(getManager().localKeep(TmpFilename));
ewol::resource::TextureFile* object = NULL;
ewol::Resource* object2 = getManager().localKeep(TmpFilename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::TextureFile*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << TmpFilename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -310,11 +310,12 @@ void ewol::resource::Program::sendAttribute(int32_t _idElem,
if (0 == m_program) {
return;
}
if (_idElem<0 || (size_t)_idElem>m_elementList.size()) {
if ( _idElem < 0
|| (size_t)_idElem > m_elementList.size()) {
EWOL_ERROR("idElem = " << _idElem << " not in [0.." << (m_elementList.size()-1) << "]");
return;
}
if (false == m_elementList[_idElem].m_isLinked) {
if (m_elementList[_idElem].m_isLinked == false) {
return;
}
glVertexAttribPointer(m_elementList[_idElem].m_elementId, // attribute ID of openGL
@ -776,7 +777,15 @@ void ewol::resource::Program::unUse(void) {
ewol::resource::Program* ewol::resource::Program::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Program : file : \"" << _filename << "\"");
ewol::resource::Program* object = static_cast<ewol::resource::Program*>(getManager().localKeep(_filename));
ewol::resource::Program* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::Program*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -98,6 +98,9 @@ namespace ewol {
inline void sendAttribute(int32_t _idElem, const std::vector<etk::Color<float> >& _data) {
sendAttribute(_idElem, 4/*r,g,b,a*/, &_data[0]);
}
inline void sendAttribute(int32_t _idElem, const std::vector<float>& _data) {
sendAttribute(_idElem, 1, &_data[0]);
}
/**
* @brief User request an Uniform on this program.
* @note uniform value is availlable for all the fragment shader in the program (only one value for all)
@ -113,6 +116,11 @@ namespace ewol {
* @param[in] _transpose Transpose the matrix (needed all the taime in the normal openGl access (only not done in the openGL-ES2 due to the fact we must done it ourself)
*/
void uniformMatrix4fv(int32_t _idElem, int32_t _nbElement, mat4 _pointer, bool _transpose=true);
inline void uniform(int32_t _idElem, const etk::Color<float>& _value) {
uniform4f(_idElem, _value.r(), _value.g(), _value.b(), _value.a());
}
/**
* @brief Send 1 float uniform element to the spefified ID (not send if does not really exist in the openGL program)
* @param[in] _idElem Id of the uniform that might be sended.

View File

@ -151,7 +151,15 @@ void ewol::resource::Shader::reload(void) {
ewol::resource::Shader* ewol::resource::Shader::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : Simpleshader : file : \"" << _filename << "\"");
ewol::resource::Shader* object = static_cast<ewol::resource::Shader*>(getManager().localKeep(_filename));
ewol::resource::Shader* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::Shader*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -338,7 +338,15 @@ ewol::GlyphProperty* ewol::resource::TexturedFont::getGlyphPointer(const char32_
ewol::resource::TexturedFont* ewol::resource::TexturedFont::keep(const std::string& _filename) {
EWOL_VERBOSE("KEEP : TexturedFont : file : '" << _filename << "'");
ewol::resource::TexturedFont* object = static_cast<ewol::resource::TexturedFont*>(getManager().localKeep(_filename));
ewol::resource::TexturedFont* object = NULL;
ewol::Resource* object2 = getManager().localKeep(_filename);
if (NULL != object2) {
object = dynamic_cast<ewol::resource::TexturedFont*>(object2);
if (NULL == object) {
EWOL_CRITICAL("Request resource file : '" << _filename << "' With the wrong type (dynamic cast error)");
return NULL;
}
}
if (NULL != object) {
return object;
}

View File

@ -190,14 +190,14 @@ void ewol::widget::Button::systemDraw(const ewol::DrawProperty& _displayProp) {
}
ewol::Widget::systemDraw(_displayProp);
// draw the widget that need something ...
if( false == m_toggleMode
|| false == m_value
|| NULL == m_subWidget[1]) {
if (NULL!=m_subWidget[0]) {
if( m_toggleMode == false
|| m_value == false
|| m_subWidget[1] == NULL) {
if (m_subWidget[0] != NULL) {
m_subWidget[0]->systemDraw(_displayProp);
}
} else {
if (NULL!=m_subWidget[1]) {
if (m_subWidget[1] != NULL) {
m_subWidget[1]->systemDraw(_displayProp);
}
}

View File

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

View File

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

View File

@ -48,7 +48,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:widgetEntry.conf"),
m_shaper("THEME:GUI:Entry.conf"),
m_data(""),
m_maxCharacter(0x7FFFFFFF),
m_regExp(".*"),

View File

@ -25,9 +25,17 @@ static ewol::Widget* create(void) {
void ewol::widget::Label::init(ewol::widget::Manager& _widgetManager) {
_widgetManager.addWidgetCreator(__class__,&create);
}
ewol::widget::Label::Label(std::string _newLabel) {
// TODO : Remove the label name in the constructor ...
ewol::widget::Label::Label(std::string _newLabel) :
m_colorProperty(NULL),
m_colorDefaultFgText(-1),
m_colorDefaultBgText(-1){
addObjectType("ewol::widget::Label");
m_colorProperty = ewol::resource::ColorFile::keep("THEME:COLOR:Label.json");
if (m_colorProperty != NULL) {
m_colorDefaultFgText = m_colorProperty->request("foreground");
m_colorDefaultBgText = m_colorProperty->request("background");
}
m_label = std::to_u32string(_newLabel);
addEventId(eventPressed);
setCanHaveFocus(false);
@ -111,6 +119,12 @@ void ewol::widget::Label::onRegenerateDisplay(void) {
// clean the element
m_text.reset();
if (m_colorProperty != NULL) {
EWOL_DEBUG("set FG : " << m_colorProperty->get(m_colorDefaultFgText));
EWOL_DEBUG("set BG : " << m_colorProperty->get(m_colorDefaultBgText));
m_text.setDefaultColorFg(m_colorProperty->get(m_colorDefaultFgText));
m_text.setDefaultColorBg(m_colorProperty->get(m_colorDefaultBgText));
}
m_text.setPos(tmpTextOrigin);
EWOL_VERBOSE("[" << getId() << "] {" << m_label << "} display at pos : " << tmpTextOrigin);
m_text.setTextAlignement(tmpTextOrigin.x(), tmpTextOrigin.x()+localSize.x(), ewol::compositing::alignLeft);

View File

@ -14,6 +14,7 @@
#include <ewol/compositing/Text.h>
#include <ewol/widget/Widget.h>
#include <ewol/widget/Manager.h>
#include <ewol/resource/ColorFile.h>
namespace ewol {
namespace widget {
@ -33,6 +34,9 @@ namespace ewol {
private:
ewol::compositing::Text m_text; //!< Compositing text element.
std::u32string m_label; //!< decorated text to display.
ewol::resource::ColorFile* m_colorProperty; //!< theme color proterty
int32_t m_colorDefaultFgText; //!< Default color of the text
int32_t m_colorDefaultBgText; //!< Default Background color of the text
public:
/**
* @brief Constructor

View File

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

View File

@ -103,6 +103,7 @@ def create(target):
# resources :
myModule.add_src_file([
'ewol/resource/Colored3DObject.cpp',
'ewol/resource/ColorFile.cpp',
'ewol/resource/ConfigFile.cpp',
'ewol/resource/FontFreeType.cpp',
'ewol/resource/Image.cpp',
@ -153,14 +154,10 @@ def create(target):
'ewol/widget/WSlider.cpp',
])
myModule.copy_folder('../data/theme/default/widgetEntry.*','theme/default')
myModule.copy_folder('../data/theme/rounded/widgetEntry.*','theme/rounded')
myModule.copy_folder('../data/theme/default/widgetButton.*','theme/default')
myModule.copy_folder('../data/theme/rounded/widgetButton.*','theme/rounded')
myModule.copy_folder('../data/theme/default/widgetContextMenu.*','theme/default')
myModule.copy_folder('../data/theme/rounded/widgetContextMenu.*','theme/rounded')
myModule.copy_folder('../data/theme/default/widgetPopUp.*','theme/default')
myModule.copy_folder('../data/theme/rounded/widgetPopUp.*','theme/rounded')
myModule.copy_folder('../data/theme/shape/square/*','theme/shape/square')
myModule.copy_folder('../data/theme/shape/round/*','theme/shape/round')
myModule.copy_folder('../data/theme/color/black/*','theme/color/black')
myModule.copy_folder('../data/theme/color/white/*','theme/color/white')
myModule.copy_folder('../data/textured.*','')
myModule.copy_folder('../data/texturedNoMaterial.*','')
myModule.copy_folder('../data/text.*','')