diff --git a/data/theme/shape/round/Button.frag b/data/theme/shape/round/Button.frag index 8cc7961a..21e72456 100644 --- a/data/theme/shape/round/Button.frag +++ b/data/theme/shape/round/Button.frag @@ -3,66 +3,25 @@ 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; +varying vec2 v_propPos; +varying vec4 v_colorTansition; +uniform vec4 EW_border; +uniform vec4 EW_background; 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); + // vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); + float tmpDist = sqrt(dot(v_propPos,v_propPos)); // 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); + float tmpVal = smoothstep(0.6, 0.7, 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); - + gl_FragColor = mix(v_colorTansition, EW_background, tmpVal); + // Generate the internal rampe for the the imput drawing + float tmpValBorder = 0.7 - abs(tmpDist - 0.7); + float tmpBorder = smoothstep(0.5, 0.7, tmpValBorder); + // set Border + gl_FragColor = mix(gl_FragColor, EW_border, tmpBorder); } diff --git a/data/theme/shape/round/Button.json b/data/theme/shape/round/Button.json index b3bb5085..705d5e1c 100644 --- a/data/theme/shape/round/Button.json +++ b/data/theme/shape/round/Button.json @@ -1,8 +1,22 @@ { - padding-left:13, - padding-right:13, - padding-top:7, - padding-buttom:7, + mode:3, + display-outside:false, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:12, + border-right:12, + border-top:12, + border-buttom:12, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, + change-time:356, program:"THEME:GUI:Button.prog", color:"THEME:COLOR:Button.json" diff --git a/data/theme/shape/round/Button.vert b/data/theme/shape/round/Button.vert index 597a19aa..f421b12c 100644 --- a/data/theme/shape/round/Button.vert +++ b/data/theme/shape/round/Button.vert @@ -13,24 +13,20 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; 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 vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { @@ -52,6 +48,4 @@ void main(void) { // 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; } diff --git a/data/theme/shape/round/CheckBox.frag b/data/theme/shape/round/CheckBox.frag index cf87742a..a9df0692 100644 --- a/data/theme/shape/round/CheckBox.frag +++ b/data/theme/shape/round/CheckBox.frag @@ -3,13 +3,6 @@ precision mediump float; precision mediump int; #endif -struct displayProperty { - vec2 size; - vec2 origin; - vec2 insidePos; - vec2 insideSize; -}; - struct widgetStateProperty { int activate; int stateOld; @@ -17,12 +10,11 @@ struct widgetStateProperty { float transition; }; -uniform displayProperty EW_widgetProperty; - uniform widgetStateProperty EW_status; // transmit from the vertex shader varying vec2 v_position; // interpolated position ... +varying vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; diff --git a/data/theme/shape/round/CheckBox.vert b/data/theme/shape/round/CheckBox.vert index 8962207d..e1c5aae7 100644 --- a/data/theme/shape/round/CheckBox.vert +++ b/data/theme/shape/round/CheckBox.vert @@ -14,6 +14,7 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; uniform vec4 EW_border; uniform vec4 EW_background; @@ -24,6 +25,7 @@ uniform vec4 EW_foregroundPressed; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; @@ -33,6 +35,7 @@ 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { diff --git a/data/theme/shape/round/ContextMenu.frag b/data/theme/shape/round/ContextMenu.frag index 41b8cfeb..2c1052fd 100644 --- a/data/theme/shape/round/ContextMenu.frag +++ b/data/theme/shape/round/ContextMenu.frag @@ -3,65 +3,24 @@ 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; uniform vec4 EW_background; uniform vec4 EW_foreground; uniform vec4 EW_border; -varying vec2 v_position; // interpolated position ... - -// internal static define -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; - +varying vec2 v_propPos; 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); + // vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); + float tmpDist = sqrt(dot(v_propPos,v_propPos)); // 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); + float tmpVal = smoothstep(0.6, 0.7, tmpDist); // set Background - gl_FragColor = EW_background; - // set foreground - 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 + EW_border*(1.0-tmpVal2); - + gl_FragColor = mix(EW_foreground, EW_background, tmpVal); + // Generate the internal rampe for the the imput drawing + float tmpValBorder = 0.7 - abs(tmpDist - 0.7); + float tmpBorder = smoothstep(0.5, 0.7, tmpValBorder); + // set Border + gl_FragColor = mix(gl_FragColor, EW_border, tmpBorder); } diff --git a/data/theme/shape/round/ContextMenu.json b/data/theme/shape/round/ContextMenu.json index b4d28104..003a53a9 100644 --- a/data/theme/shape/round/ContextMenu.json +++ b/data/theme/shape/round/ContextMenu.json @@ -1,8 +1,22 @@ { - padding-left:13, - padding-right:13, - padding-top:7, - padding-buttom:7, + mode:3, + display-outside:false, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:12, + border-right:12, + border-top:12, + border-buttom:12, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, + change-time:356, program:"THEME:GUI:ContextMenu.prog", color:"THEME:COLOR:ContextMenu.json" diff --git a/data/theme/shape/round/ContextMenu.vert b/data/theme/shape/round/ContextMenu.vert index 1b0652d7..d4da54e6 100644 --- a/data/theme/shape/round/ContextMenu.vert +++ b/data/theme/shape/round/ContextMenu.vert @@ -5,13 +5,13 @@ precision mediump int; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; // output : -varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; } diff --git a/data/theme/shape/round/Entry.frag b/data/theme/shape/round/Entry.frag index ca6b9e5c..8544ce84 100644 --- a/data/theme/shape/round/Entry.frag +++ b/data/theme/shape/round/Entry.frag @@ -3,64 +3,26 @@ 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; -}; +// transmit from the vertex shader +varying vec2 v_propPos; -uniform displayProperty EW_widgetProperty; uniform vec4 EW_background; uniform vec4 EW_foreground; uniform vec4 EW_border; -uniform widgetStateProperty EW_status; - -// transmit from the vertex shader -varying vec2 v_position; // interpolated position ... - -// 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); + // vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); + float tmpDist = sqrt(dot(v_propPos,v_propPos)); // 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); + float tmpVal = smoothstep(0.6, 0.7, tmpDist); // set Background - gl_FragColor = EW_background; - // set foreground - 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 + EW_border*(1.0-tmpVal2); + gl_FragColor = mix(EW_foreground, EW_background, tmpVal); + // Generate the internal rampe for the the imput drawing + float tmpValBorder = 0.7 - abs(tmpDist - 0.7); + float tmpBorder = smoothstep(0.5, 0.7, tmpValBorder); + // set Border + gl_FragColor = mix(gl_FragColor, EW_border, tmpBorder); } diff --git a/data/theme/shape/round/Entry.json b/data/theme/shape/round/Entry.json index 306cddf4..74a540b4 100644 --- a/data/theme/shape/round/Entry.json +++ b/data/theme/shape/round/Entry.json @@ -1,8 +1,22 @@ { - padding-left:13, - padding-right:13, - padding-top:7, - padding-buttom:7, + mode:3, + display-outside:false, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:12, + border-right:12, + border-top:12, + border-buttom:12, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, + change-time:356, program:"THEME:GUI:Entry.prog", color:"THEME:COLOR:Entry.json" diff --git a/data/theme/shape/round/Entry.vert b/data/theme/shape/round/Entry.vert index 1b0652d7..d4da54e6 100644 --- a/data/theme/shape/round/Entry.vert +++ b/data/theme/shape/round/Entry.vert @@ -5,13 +5,13 @@ precision mediump int; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; // output : -varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; } diff --git a/data/theme/shape/round/PopUp.frag b/data/theme/shape/round/PopUp.frag index d166a9b5..cdf00b24 100644 --- a/data/theme/shape/round/PopUp.frag +++ b/data/theme/shape/round/PopUp.frag @@ -3,66 +3,24 @@ precision mediump float; precision mediump int; #endif -struct displayProperty { - vec2 size; - vec2 origin; - vec2 insidePos; - vec2 insideSize; -}; +// transmit from the vertex shader +varying vec2 v_propPos; -struct widgetStateProperty { - int stateOld; - int stateNew; - float transition; -}; - -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 -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; - - void main(void) { - // position form center : - vec2 ratio = EW_widgetProperty.insideSize / 2.0; - - // prevent origin moving ... - vec2 position = v_position - EW_widgetProperty.insidePos; - - /* 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); + // vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); + float tmpDist = sqrt(dot(v_propPos,v_propPos)); // 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); + float tmpVal = smoothstep(0.6, 0.7, tmpDist); // set Background - gl_FragColor = EW_background; - // set foreground - 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 + EW_border*(1.0-tmpVal2); - -} - + gl_FragColor = mix(EW_foreground, EW_background, tmpVal); + // Generate the internal rampe for the the imput drawing + float tmpValBorder = 0.7 - abs(tmpDist - 0.7); + float tmpBorder = smoothstep(0.5, 0.7, tmpValBorder); + // set Border + gl_FragColor = mix(gl_FragColor, EW_border, tmpBorder); +} \ No newline at end of file diff --git a/data/theme/shape/round/PopUp.json b/data/theme/shape/round/PopUp.json index 0d6bc7ca..7d268723 100644 --- a/data/theme/shape/round/PopUp.json +++ b/data/theme/shape/round/PopUp.json @@ -1,8 +1,22 @@ { - padding-left:13, - padding-right:13, - padding-top:7, - padding-buttom:7, + mode:3, + display-outside:false, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:12, + border-right:12, + border-top:12, + border-buttom:12, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, + change-time:356, program:"THEME:GUI:PopUp.prog", color:"THEME:COLOR:PopUp.json" diff --git a/data/theme/shape/round/PopUp.vert b/data/theme/shape/round/PopUp.vert index 1b0652d7..399e312b 100644 --- a/data/theme/shape/round/PopUp.vert +++ b/data/theme/shape/round/PopUp.vert @@ -5,13 +5,16 @@ precision mediump int; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; } diff --git a/data/theme/shape/round/WidgetScrolled.frag b/data/theme/shape/round/WidgetScrolled.frag index ee7577df..7c788f6c 100644 --- a/data/theme/shape/round/WidgetScrolled.frag +++ b/data/theme/shape/round/WidgetScrolled.frag @@ -3,25 +3,17 @@ 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 vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; diff --git a/data/theme/shape/round/WidgetScrolled.vert b/data/theme/shape/round/WidgetScrolled.vert index 782b798a..615f1885 100644 --- a/data/theme/shape/round/WidgetScrolled.vert +++ b/data/theme/shape/round/WidgetScrolled.vert @@ -13,6 +13,7 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; uniform vec4 EW_border; uniform vec4 EW_background; @@ -21,6 +22,7 @@ uniform vec4 EW_foregroundPressed; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; @@ -29,6 +31,7 @@ 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { diff --git a/data/theme/shape/square/Button.frag b/data/theme/shape/square/Button.frag index 4ee3c8c0..d8e7a968 100644 --- a/data/theme/shape/square/Button.frag +++ b/data/theme/shape/square/Button.frag @@ -2,50 +2,25 @@ 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; +varying vec2 v_propPos; +varying vec4 v_colorTansition; +uniform vec4 EW_border; +uniform vec4 EW_background; -// 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; - } + gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = v_colorTansition; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { + gl_FragColor = EW_background; } else { - gl_FragColor = v_colorBackground; + gl_FragColor = EW_border; } } diff --git a/data/theme/shape/square/Button.json b/data/theme/shape/square/Button.json index 9942fec0..17b716ef 100644 --- a/data/theme/shape/square/Button.json +++ b/data/theme/shape/square/Button.json @@ -1,18 +1,21 @@ { - extern-border-left:2, - extern-border-right:2, - extern-border-top:2, - extern-border-butom:2, + mode:2, + display-outside:false, - border-left:2, - border-right:2, - border-top:2, - border-buttom:2, + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, - padding-left:8, - padding-right:8, - padding-top:8, - padding-buttom:8, + border-left:1, + border-right:1, + border-top:1, + border-buttom:1, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, change-time:356, program:"THEME:GUI:Button.prog", diff --git a/data/theme/shape/square/Button.vert b/data/theme/shape/square/Button.vert index 597a19aa..7c66c3cc 100644 --- a/data/theme/shape/square/Button.vert +++ b/data/theme/shape/square/Button.vert @@ -13,24 +13,21 @@ 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; +attribute vec2 EW_widgetPropertyPos; +uniform mat4 EW_MatrixTransformation; +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; +varying vec2 v_propPos; +varying vec4 v_colorTansition; 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { @@ -52,6 +49,4 @@ void main(void) { // 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; } diff --git a/data/theme/shape/square/CheckBox.frag b/data/theme/shape/square/CheckBox.frag index 58a92398..3c11e093 100644 --- a/data/theme/shape/square/CheckBox.frag +++ b/data/theme/shape/square/CheckBox.frag @@ -2,59 +2,27 @@ 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 vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; varying vec4 v_colorInside; -// 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 = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = v_colorTansition; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { gl_FragColor = v_colorBackground; - } - position = v_position - EW_widgetProperty.insidePos; - if( position.x> 0.0 - && position.y> 0.0 - && position.x<= EW_widgetProperty.insideSize.x - && position.y<= EW_widgetProperty.insideSize.y - ) { - gl_FragColor = v_colorInside; + } else { + gl_FragColor = v_colorBorder; } } diff --git a/data/theme/shape/square/CheckBox.json b/data/theme/shape/square/CheckBox.json index 7e0969d9..0d737f70 100644 --- a/data/theme/shape/square/CheckBox.json +++ b/data/theme/shape/square/CheckBox.json @@ -1,10 +1,24 @@ { + mode:2, + display-outside:false, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:1, + border-right:1, + border-top:1, + border-buttom:1, + + padding-in-left:1, + padding-in-right:1, + padding-in-top:1, + padding-in-buttom:1, + box-size:20, box-inside:12, - padding-left:8, - padding-right:8, - padding-top:8, - padding-buttom:8, change-time:356, program:"THEME:GUI:CheckBox.prog", color:"THEME:COLOR:CheckBox.json" diff --git a/data/theme/shape/square/CheckBox.vert b/data/theme/shape/square/CheckBox.vert index 8962207d..e1c5aae7 100644 --- a/data/theme/shape/square/CheckBox.vert +++ b/data/theme/shape/square/CheckBox.vert @@ -14,6 +14,7 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; uniform vec4 EW_border; uniform vec4 EW_background; @@ -24,6 +25,7 @@ uniform vec4 EW_foregroundPressed; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; @@ -33,6 +35,7 @@ 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { diff --git a/data/theme/shape/square/ContextMenu.frag b/data/theme/shape/square/ContextMenu.frag index 2a789a16..8363c539 100644 --- a/data/theme/shape/square/ContextMenu.frag +++ b/data/theme/shape/square/ContextMenu.frag @@ -2,14 +2,6 @@ precision mediump float; precision mediump int; #endif -struct displayProperty { - vec2 size; - vec2 origin; - vec2 insidePos; - vec2 insideSize; -}; - -uniform displayProperty EW_widgetProperty; uniform vec4 EW_background; uniform vec4 EW_foreground; @@ -17,34 +9,19 @@ uniform vec4 EW_border; // transmit from the vertex shader varying vec2 v_position; // interpolated position ... - -// internal static define -float S_sizePadding = 1.0; -float S_sizeBorder = 3.0; +varying vec2 v_propPos; 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 = EW_border; - } else { - // note : int() is needed for the OpenGL ES platform - gl_FragColor = EW_foreground; - } - } else { + gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = EW_foreground; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { gl_FragColor = EW_background; + } else { + gl_FragColor = EW_border; } } diff --git a/data/theme/shape/square/ContextMenu.json b/data/theme/shape/square/ContextMenu.json index d0c1859a..d9c13822 100644 --- a/data/theme/shape/square/ContextMenu.json +++ b/data/theme/shape/square/ContextMenu.json @@ -1,8 +1,22 @@ { - padding-left:8, - padding-right:8, - padding-top:8, - padding-buttom:8, + mode:2, + display-outside:false, + + padding-out-left:2, + padding-out-right:2, + padding-out-top:2, + padding-out-buttom:2, + + border-left:3, + border-right:3, + border-top:3, + border-buttom:3, + + padding-in-left:2, + padding-in-right:2, + padding-in-top:2, + padding-in-buttom:2, + change-time:356, program:"THEME:GUI:ContextMenu.prog", color:"THEME:COLOR:ContextMenu.json" diff --git a/data/theme/shape/square/ContextMenu.vert b/data/theme/shape/square/ContextMenu.vert index f721d1fe..a75f3e8d 100644 --- a/data/theme/shape/square/ContextMenu.vert +++ b/data/theme/shape/square/ContextMenu.vert @@ -13,13 +13,16 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; } diff --git a/data/theme/shape/square/Entry.frag b/data/theme/shape/square/Entry.frag index 2a010c48..bf5d7f2e 100644 --- a/data/theme/shape/square/Entry.frag +++ b/data/theme/shape/square/Entry.frag @@ -2,53 +2,26 @@ precision mediump float; precision mediump int; #endif -struct displayProperty { - vec2 size; - vec2 origin; - vec2 insidePos; - vec2 insideSize; -}; - -uniform displayProperty EW_widgetProperty; uniform vec4 EW_background; uniform vec4 EW_border; // transmit from the vertex shader varying vec2 v_position; // interpolated position ... +varying vec2 v_propPos; varying vec4 v_colorTansition; -// 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 - ) { - // inside element - if( position.x<= specialBorder - || position.y<= specialBorder - || position.x> endStart.x - || position.y> endStart.y - ) { - // border ... - gl_FragColor = EW_border; - } else { - // note : int() is needed for the OpenGL ES platform - gl_FragColor = v_colorTansition; - } - } else { + gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = v_colorTansition; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { gl_FragColor = EW_background; + } else { + gl_FragColor = EW_border; } -} - +} \ No newline at end of file diff --git a/data/theme/shape/square/Entry.json b/data/theme/shape/square/Entry.json index df4c1628..8426b668 100644 --- a/data/theme/shape/square/Entry.json +++ b/data/theme/shape/square/Entry.json @@ -1,8 +1,22 @@ { - padding-left:8, - padding-right:8, - padding-top:8, - padding-buttom:8, + mode:2, + display-outside:false, + + padding-out-left:2, + padding-out-right:2, + padding-out-top:2, + padding-out-buttom:2, + + border-left:1, + border-right:1, + border-top:1, + border-buttom:1, + + padding-in-left:2, + padding-in-right:2, + padding-in-top:2, + padding-in-buttom:2, + change-time:356, program:"THEME:GUI:Entry.prog", color:"THEME:COLOR:Entry.json" diff --git a/data/theme/shape/square/Entry.vert b/data/theme/shape/square/Entry.vert index ddc0a95e..d02de342 100644 --- a/data/theme/shape/square/Entry.vert +++ b/data/theme/shape/square/Entry.vert @@ -11,6 +11,7 @@ struct widgetStateProperty { // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; uniform widgetStateProperty EW_status; uniform vec4 EW_foreground; @@ -19,6 +20,7 @@ uniform vec4 EW_foregroundHover; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; varying vec4 v_colorTansition; void main(void) { @@ -26,6 +28,7 @@ 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; diff --git a/data/theme/shape/square/PopUp.frag b/data/theme/shape/square/PopUp.frag index 92598a49..02b2f8e6 100644 --- a/data/theme/shape/square/PopUp.frag +++ b/data/theme/shape/square/PopUp.frag @@ -2,15 +2,6 @@ precision mediump float; precision mediump int; #endif -struct displayProperty { - vec2 size; - vec2 origin; - vec2 insidePos; - vec2 insideSize; -}; - - -uniform displayProperty EW_widgetProperty; uniform vec4 EW_background; uniform vec4 EW_foreground; uniform vec4 EW_border; @@ -18,34 +9,19 @@ uniform vec4 EW_border; // transmit from the vertex shader varying vec2 v_position; // interpolated position ... - -// internal static define -float S_sizePadding = 1.0; -float S_sizeBorder = 3.0; +varying vec2 v_propPos; void main(void) { // prevent origin moving ... - vec2 position = v_position - EW_widgetProperty.insidePos; - float specialBorder = S_sizeBorder+S_sizePadding; - vec2 endStart = EW_widgetProperty.insideSize - vec2(S_sizePadding) - vec2(S_sizeBorder); - vec2 endStop = EW_widgetProperty.insideSize - 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 = EW_border; - } else { - // note : int() is needed for the OpenGL ES platform - gl_FragColor = EW_foreground; - } - } else { + gl_FragColor = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = EW_foreground; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { gl_FragColor = EW_background; + } else { + gl_FragColor = EW_border; } } diff --git a/data/theme/shape/square/PopUp.json b/data/theme/shape/square/PopUp.json index 4aa82898..c669e557 100644 --- a/data/theme/shape/square/PopUp.json +++ b/data/theme/shape/square/PopUp.json @@ -1,8 +1,22 @@ { - padding-left:8, - padding-right:8, - padding-top:8, - padding-buttom:8, + mode:2, + display-outside:false, + + padding-out-left:2, + padding-out-right:2, + padding-out-top:2, + padding-out-buttom:2, + + border-left:3, + border-right:3, + border-top:3, + border-buttom:3, + + padding-in-left:2, + padding-in-right:2, + padding-in-top:2, + padding-in-buttom:2, + change-time:356, program:"THEME:GUI:PopUp.prog", color:"THEME:COLOR:PopUp.json" diff --git a/data/theme/shape/square/PopUp.vert b/data/theme/shape/square/PopUp.vert index f721d1fe..d4da54e6 100644 --- a/data/theme/shape/square/PopUp.vert +++ b/data/theme/shape/square/PopUp.vert @@ -3,23 +3,15 @@ precision mediump float; precision mediump int; #endif -struct widgetStateProperty { - int stateOld; - int stateNew; - float transition; -}; - -uniform widgetStateProperty EW_status; - // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; // output : -varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; 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; + v_propPos = EW_widgetPropertyPos; } diff --git a/data/theme/shape/square/WidgetScrolled.frag b/data/theme/shape/square/WidgetScrolled.frag index fdf11469..2b6f3ad4 100644 --- a/data/theme/shape/square/WidgetScrolled.frag +++ b/data/theme/shape/square/WidgetScrolled.frag @@ -2,50 +2,24 @@ 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 vec2 v_propPos; 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.insidePos; - float specialBorder = S_sizeBorder+S_sizePadding; - vec2 endStart = EW_widgetProperty.insideSize - vec2(S_sizePadding) - vec2(S_sizeBorder); - vec2 endStop = EW_widgetProperty.insideSize - 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 = vec4(v_propPos.y, v_propPos.x, 1.0, 1.0); + if( v_propPos.x == 1.0 + && v_propPos.y == 1.0) { + gl_FragColor = v_colorTansition; + } else if ( v_propPos.x == 0.0 + || v_propPos.y == 0.0) { gl_FragColor = v_colorBackground; + } else { + gl_FragColor = v_colorBorder; } } - diff --git a/data/theme/shape/square/WidgetScrolled.json b/data/theme/shape/square/WidgetScrolled.json index fb18df76..dbe3b1e3 100644 --- a/data/theme/shape/square/WidgetScrolled.json +++ b/data/theme/shape/square/WidgetScrolled.json @@ -1,8 +1,22 @@ { - padding-left:15, - padding-right:15, - padding-top:15, - padding-buttom:15, + mode:2, + display-outside:true, + + padding-out-left:1, + padding-out-right:1, + padding-out-top:1, + padding-out-buttom:1, + + border-left:1, + border-right:1, + border-top:1, + border-buttom:1, + + padding-in-left:3, + padding-in-right:3, + padding-in-top:3, + padding-in-buttom:3, + change-time:200, program:"THEME:GUI:WidgetScrolled.prog", color:"THEME:COLOR:WidgetScrolled.json" diff --git a/data/theme/shape/square/WidgetScrolled.vert b/data/theme/shape/square/WidgetScrolled.vert index af400a9a..4606c181 100644 --- a/data/theme/shape/square/WidgetScrolled.vert +++ b/data/theme/shape/square/WidgetScrolled.vert @@ -13,6 +13,7 @@ uniform widgetStateProperty EW_status; // Input : attribute vec2 EW_coord2d; +attribute vec2 EW_widgetPropertyPos; uniform mat4 EW_MatrixTransformation; uniform vec4 EW_border; uniform vec4 EW_background; @@ -21,6 +22,7 @@ uniform vec4 EW_foregroundPressed; // output : varying vec2 v_position; // This will be passed into the fragment shader. +varying vec2 v_propPos; varying vec4 v_colorTansition; varying vec4 v_colorBorder; varying vec4 v_colorBackground; @@ -29,6 +31,7 @@ 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; + v_propPos = EW_widgetPropertyPos; vec4 colorOld = EW_foreground; if(EW_status.stateOld == 1) { diff --git a/sources/ewol/Padding.cpp b/sources/ewol/Padding.cpp new file mode 100644 index 00000000..8f3f8bd1 --- /dev/null +++ b/sources/ewol/Padding.cpp @@ -0,0 +1,23 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD 3 clauses (see license file) + */ + +#include + +etk::CCout& ewol::operator <<(etk::CCout& _os, const ewol::Padding& _obj) { + _os << "{"; + _os << _obj.xLeft(); + _os << ","; + _os << _obj.yTop(); + _os << ","; + _os << _obj.xRight(); + _os << ","; + _os << _obj.yButtom(); + _os << "}"; + return _os; +} + diff --git a/sources/ewol/Padding.h b/sources/ewol/Padding.h index 7033cf57..d556c8ff 100644 --- a/sources/ewol/Padding.h +++ b/sources/ewol/Padding.h @@ -3,7 +3,7 @@ * * @copyright 2011, Edouard DUPIN, all right reserved * - * @license BSD v3 (see license file) + * @license BSD 3 clauses (see license file) */ #ifndef __EWOL_PADDING_H__ @@ -17,50 +17,70 @@ namespace ewol { */ class Padding { private: - float value[4]; //!< this represent the 4 padding value Left top right buttom (like css) + float m_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; - value[3] = _yb; + m_value[0] = _xl; + m_value[1] = _yt; + m_value[2] = _xr; + m_value[3] = _yb; } float x(void) const { - return value[0] + value[2]; + return m_value[0] + m_value[2]; } float y(void) const { - return value[1] + value[3]; + return m_value[1] + m_value[3]; } float xLeft(void) const { - return value[0]; + return m_value[0]; } void setXLeft(float _val) { - value[0] = _val; + m_value[0] = _val; } float xRight(void) const { - return value[2]; + return m_value[2]; } void setXRight(float _val) { - value[2] = _val; + m_value[2] = _val; } float yTop(void) const { - return value[1]; + return m_value[1]; } void setYTop(float _val) { - value[1] = _val; + m_value[1] = _val; } float yButtom(void) const { - return value[3]; + return m_value[3]; } void setYButtom(float _val) { - value[3] = _val; + m_value[3] = _val; } + /** + * @brief Add a vector to this one + * @param _v The vector to add to this one + */ + Padding& operator+=(const Padding& _v) { + m_value[0] += _v.m_value[0]; + m_value[1] += _v.m_value[1]; + m_value[2] += _v.m_value[2]; + m_value[3] += _v.m_value[3]; + return *this; + } + //! @previous + Padding operator+(const Padding& _v) { + return Padding(m_value[0] + _v.m_value[0], + m_value[1] + _v.m_value[1], + m_value[2] + _v.m_value[2], + m_value[3] + _v.m_value[3]); + } + }; + etk::CCout& operator <<(etk::CCout& _os, const ewol::Padding& _obj); }; #endif diff --git a/sources/ewol/compositing/Shaper.cpp b/sources/ewol/compositing/Shaper.cpp index 4dc51483..f0c6d829 100644 --- a/sources/ewol/compositing/Shaper.cpp +++ b/sources/ewol/compositing/Shaper.cpp @@ -16,10 +16,8 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) : m_name(_shaperName), m_config(NULL), - m_confIdPaddingLeft(-1), - m_confIdPaddingRight(-1), - m_confIdPaddingTop(-1), - m_confIdPaddingButtom(-1), + m_confIdMode(-1), + m_confIdDisplayOutside(-1), m_confIdChangeTime(-1), m_confProgramFile(-1), m_confColorFile(-1), @@ -27,9 +25,6 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) : m_GLprogram(NULL), m_GLPosition(-1), m_GLMatrix(-1), - m_GLPropertySize(-1), - m_GLPropertyInsidePos(-1), - m_GLPropertyInsideSize(-1), m_GLStateActivate(-1), m_GLStateOld(-1), m_GLStateNew(-1), @@ -43,9 +38,18 @@ ewol::compositing::Shaper::Shaper(const std::string& _shaperName) : m_stateActivate(0), m_stateOld(0), m_stateNew(0), - m_stateTransition(1.0) { + m_stateTransition(1.0), + m_nbVertexToDisplay(0) { + for (size_t iii=0; iiirequest("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"); + m_confIdMode = m_config->request("mode"); + m_confIdDisplayOutside = m_config->request("display-outside"); + m_confIdPaddingOut[shaperPosLeft] = m_config->request("padding-out-left"); + m_confIdPaddingOut[shaperPosRight] = m_config->request("padding-out-right"); + m_confIdPaddingOut[shaperPosTop] = m_config->request("padding-out-top"); + m_confIdPaddingOut[shaperPosButtom] = m_config->request("padding-out-buttom"); + m_confIdBorder[shaperPosLeft] = m_config->request("border-left"); + m_confIdBorder[shaperPosRight] = m_config->request("border-right"); + m_confIdBorder[shaperPosTop] = m_config->request("border-top"); + m_confIdBorder[shaperPosButtom] = m_config->request("border-buttom"); + m_confIdPaddingIn[shaperPosLeft] = m_config->request("padding-in-left"); + m_confIdPaddingIn[shaperPosRight] = m_config->request("padding-in-right"); + m_confIdPaddingIn[shaperPosTop] = m_config->request("padding-in-top"); + m_confIdPaddingIn[shaperPosButtom] = m_config->request("padding-in-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 != "") { @@ -101,17 +123,14 @@ void ewol::compositing::Shaper::loadProgram(void) { m_GLPosition = m_GLprogram->getAttribute("EW_coord2d"); m_GLMatrix = m_GLprogram->getUniform("EW_MatrixTransformation"); // Widget property == > for the Vertex shader - m_GLPropertySize = m_GLprogram->getUniform("EW_widgetProperty.size"); - m_GLPropertyOrigin = m_GLprogram->getUniform("EW_widgetProperty.origin"); - m_GLPropertyInsidePos = m_GLprogram->getUniform("EW_widgetProperty.insidePos"); - m_GLPropertyInsideSize = m_GLprogram->getUniform("EW_widgetProperty.insideSize"); + m_GLPropertyPos = m_GLprogram->getAttribute("EW_widgetPropertyPos"); // status property == > for the fragment shader - m_GLStateActivate = m_GLprogram->getUniform("EW_status.activate"); - m_GLStateOld = m_GLprogram->getUniform("EW_status.stateOld"); - m_GLStateNew = m_GLprogram->getUniform("EW_status.stateNew"); - m_GLStateTransition = m_GLprogram->getUniform("EW_status.transition"); + m_GLStateActivate = m_GLprogram->getUniform("EW_status.activate"); + m_GLStateOld = m_GLprogram->getUniform("EW_status.stateOld"); + m_GLStateNew = m_GLprogram->getUniform("EW_status.stateNew"); + m_GLStateTransition = m_GLprogram->getUniform("EW_status.transition"); // for the texture ID : - m_GLtexID = m_GLprogram->getUniform("EW_texID"); + m_GLtexID = m_GLprogram->getUniform("EW_texID"); } std::string basicImageFile = m_config->getString(m_confImageFile); if (basicImageFile != "") { @@ -168,12 +187,10 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) { m_GLprogram->uniformMatrix4fv(m_GLMatrix, 1, tmpMatrix.m_mat); // position : m_GLprogram->sendAttribute(m_GLPosition, 2/*x,y*/, m_coord); + // property + m_GLprogram->sendAttribute(m_GLPropertyPos, 2/*x,y*/, m_pos); // all entry parameters : - m_GLprogram->uniform2(m_GLPropertySize, m_propertySize); - m_GLprogram->uniform2(m_GLPropertyOrigin, m_propertyOrigin); - m_GLprogram->uniform2(m_GLPropertyInsidePos, m_propertyInsidePosition); - m_GLprogram->uniform2(m_GLPropertyInsideSize, m_propertyInsideSize); - m_GLprogram->uniform1i(m_GLStateActivate, m_stateActivate); + m_GLprogram->uniform1i(m_GLStateActivate, m_stateActivate); m_GLprogram->uniform1i(m_GLStateOld, m_stateOld); m_GLprogram->uniform1i(m_GLStateNew, m_stateNew); m_GLprogram->uniform1f(m_GLStateTransition, m_stateTransition); @@ -185,7 +202,8 @@ void ewol::compositing::Shaper::draw(bool _disableDepthTest) { m_GLprogram->setTexture0(m_GLtexID, m_resourceTexture->getId()); } // Request the draw of the elements : - ewol::openGL::drawArrays(GL_TRIANGLES, 0, 6); + //ewol::openGL::drawArrays(GL_TRIANGLES, 0, SHAPER_NB_MAX_VERTEX); + ewol::openGL::drawArrays(GL_TRIANGLE_STRIP, 0, m_nbVertexToDisplay); m_GLprogram->unUse(); } @@ -248,52 +266,322 @@ bool ewol::compositing::Shaper::periodicCall(const ewol::event::Time& _event) { return true; } -void ewol::compositing::Shaper::updateVertex(void) { - // set coord == > must be a static VBO ... - m_coord[0].setValue( m_propertyOrigin.x(), - m_propertyOrigin.y()+m_propertySize.y()); - m_coord[1].setValue( m_propertyOrigin.x(), - m_propertyOrigin.y()); - m_coord[2].setValue( m_propertyOrigin.x()+m_propertySize.x(), - m_propertyOrigin.y()); +//Create Line: +void ewol::compositing::Shaper::addVertexLine(float _yTop, + float _yButtom, + float _x1, + float _x2, + float _x3, + float _x4, + float _x5, + float _x6, + float _x7, + float _x8, + float _yValTop, + float _yValButtom, + const float* _table, + bool _displayOutside) { + if (m_nbVertexToDisplay != 0) { + // change line ... + m_coord[m_nbVertexToDisplay] = m_coord[m_nbVertexToDisplay-1]; + m_pos[m_nbVertexToDisplay] = m_pos[m_nbVertexToDisplay-1]; + m_nbVertexToDisplay++; + if (_displayOutside == true) { + m_coord[m_nbVertexToDisplay].setValue(_x1, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[0],_yValButtom); + m_nbVertexToDisplay++; + } else { + m_coord[m_nbVertexToDisplay].setValue(_x2, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[1],_yValButtom); + m_nbVertexToDisplay++; + } + } - m_coord[3].setValue( m_propertyOrigin.x()+m_propertySize.x(), - m_propertyOrigin.y()); - m_coord[4].setValue( m_propertyOrigin.x()+m_propertySize.x(), - m_propertyOrigin.y()+m_propertySize.y()); - m_coord[5].setValue( m_propertyOrigin.x(), - m_propertyOrigin.y()+m_propertySize.y()); -} - -void ewol::compositing::Shaper::setOrigin(const vec2& _newOri) { - if (m_propertyOrigin != _newOri) { - m_propertyOrigin = _newOri; - updateVertex(); + if (_displayOutside == true) { + // A + m_coord[m_nbVertexToDisplay].setValue(_x1, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[0],_yValButtom); + m_nbVertexToDisplay++; + m_coord[m_nbVertexToDisplay].setValue(_x1, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[0],_yValTop); + m_nbVertexToDisplay++; + m_coord[m_nbVertexToDisplay].setValue(_x2, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[1],_yValButtom); + m_nbVertexToDisplay++; + // B + m_coord[m_nbVertexToDisplay].setValue(_x2, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[1],_yValTop); + m_nbVertexToDisplay++; + + // C + m_coord[m_nbVertexToDisplay].setValue(_x3, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[2],_yValButtom); + m_nbVertexToDisplay++; + } else { + // C + m_coord[m_nbVertexToDisplay].setValue(_x2, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[1],_yValButtom); + m_nbVertexToDisplay++; + m_coord[m_nbVertexToDisplay].setValue(_x2, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[1],_yValTop); + m_nbVertexToDisplay++; + m_coord[m_nbVertexToDisplay].setValue(_x3, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[2],_yValButtom); + m_nbVertexToDisplay++; + } + // D + m_coord[m_nbVertexToDisplay].setValue(_x3, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[2],_yValTop); + m_nbVertexToDisplay++; + + // E + m_coord[m_nbVertexToDisplay].setValue(_x4, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[3],_yValButtom); + m_nbVertexToDisplay++; + // F + m_coord[m_nbVertexToDisplay].setValue(_x4, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[3],_yValTop); + m_nbVertexToDisplay++; + + // G + m_coord[m_nbVertexToDisplay].setValue(_x5, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[4],_yValButtom); + m_nbVertexToDisplay++; + // H + m_coord[m_nbVertexToDisplay].setValue(_x5, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[4],_yValTop); + m_nbVertexToDisplay++; + + // I + m_coord[m_nbVertexToDisplay].setValue(_x6, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[5],_yValButtom); + m_nbVertexToDisplay++; + // J + m_coord[m_nbVertexToDisplay].setValue(_x6, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[5],_yValTop); + m_nbVertexToDisplay++; + + // K + m_coord[m_nbVertexToDisplay].setValue(_x7, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[6],_yValButtom); + m_nbVertexToDisplay++; + // L + m_coord[m_nbVertexToDisplay].setValue(_x7, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[6],_yValTop); + m_nbVertexToDisplay++; + + if (_displayOutside == true) { + // M + m_coord[m_nbVertexToDisplay].setValue(_x8, _yButtom); + m_pos[m_nbVertexToDisplay].setValue(_table[7],_yValButtom); + m_nbVertexToDisplay++; + // N + m_coord[m_nbVertexToDisplay].setValue(_x8, _yTop); + m_pos[m_nbVertexToDisplay].setValue(_table[7],_yValTop); + m_nbVertexToDisplay++; } } +const float modeDisplay[][8] = { + /* !! 0 !! + * / ******* + * / ****** / + * ****** / + */ + { 0.0f, 0.0f, 0.5f, 0.5f, 0.5f, 0.5f, 1.0f, 1.0f }, + /* !! 1 !! + * ****** \ + * \ ****** \ + * \ ******* + */ + { 1.0f, 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.0f, 0.0f }, + /* !! 2 !! + * / ****** \ + * ****** / \ ******* + */ + { 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f }, + /* !! 3 !! + * ****** \ / ******* + * \ ****** / + */ + { 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f }, + /* !! 4 !! + * / ******* + * / ****** / + * ****** / + */ + { -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f }, + /* !! 5 !! + * ****** \ + * \ ****** \ + * \ ******* + */ + { 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, -1.0f }, + /* !! 6 !! + * / ****** \ + * ****** / \ ******* + */ + { -1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f }, + /* !! 7 !! + * ****** \ / ******* + * \ ****** / + */ + { 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, 1.0f } +}; -void ewol::compositing::Shaper::setSize(const vec2& _newSize) { - if (m_propertySize != _newSize) { - m_propertySize = _newSize; - updateVertex(); +void ewol::compositing::Shaper::setShape(const vec2& _origin, const vec2& _size, const vec2& _insidePos, const vec2& _insideSize) { + ewol::Padding borderTmp = getBorder(); + ewol::Padding paddingIn = getPaddingIn(); + //ewol::Padding paddingOut = getPaddingOut(); + ewol::Padding enveloppe(_origin.x(), + _origin.y() + _size.y(), + _origin.x() + _size.x(), + _origin.y()); + ewol::Padding inside(_insidePos.x(), + _insidePos.y() + _insideSize.y(), + _insidePos.x() + _insideSize.x(), + _insidePos.y()); + ewol::Padding insideBorder(inside.xLeft() - paddingIn.xLeft(), + inside.yTop() + paddingIn.yTop(), + inside.xRight() + paddingIn.xRight(), + inside.yButtom() - paddingIn.yButtom()); + ewol::Padding border(insideBorder.xLeft() - borderTmp.xLeft(), + insideBorder.yTop() + borderTmp.yTop(), + insideBorder.xRight() + borderTmp.xRight(), + insideBorder.yButtom() - borderTmp.yButtom()); + /* + EWOL_ERROR(" enveloppe = " << enveloppe); + EWOL_ERROR(" border = " << border); + EWOL_ERROR(" inside = " << inside); + */ + int32_t mode = 0; + if (m_config != NULL) { + mode = m_config->getNumber(m_confIdMode); + } + bool displayOutside = m_config->getBoolean(m_confIdDisplayOutside); + m_nbVertexToDisplay = 0; + if (displayOutside == true) { + addVertexLine(enveloppe.yTop(), border.yTop(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][7], modeDisplay[mode][6], + modeDisplay[mode], + displayOutside); + } + addVertexLine(border.yTop(), insideBorder.yTop(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][6], modeDisplay[mode][5], + modeDisplay[mode], + displayOutside); + addVertexLine(insideBorder.yTop(), inside.yTop(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][5], modeDisplay[mode][4], + modeDisplay[mode], + displayOutside); + addVertexLine(inside.yTop(), inside.yButtom(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][4], modeDisplay[mode][3], + modeDisplay[mode], + displayOutside); + addVertexLine(inside.yButtom(), insideBorder.yButtom(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][3], modeDisplay[mode][2], + modeDisplay[mode], + displayOutside); + addVertexLine(insideBorder.yButtom(), border.yButtom(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][2], modeDisplay[mode][1], + modeDisplay[mode], + displayOutside); + if (displayOutside == true) { + addVertexLine(border.yButtom(), enveloppe.yButtom(), + enveloppe.xLeft(), + border.xLeft(), + insideBorder.xLeft(), + inside.xLeft(), + inside.xRight(), + insideBorder.xRight(), + border.xRight(), + enveloppe.xRight(), + modeDisplay[mode][1], modeDisplay[mode][0], + modeDisplay[mode], + displayOutside); } -} - -void ewol::compositing::Shaper::setInsideSize(const vec2& _newInsideSize) { - m_propertyInsideSize = _newInsideSize; -} - -void ewol::compositing::Shaper::setInsidePos(const vec2& _newInsidePos) { - m_propertyInsidePosition = _newInsidePos; } ewol::Padding ewol::compositing::Shaper::getPadding(void) { + return getPaddingOut() + getBorder() + getPaddingIn(); +} + +ewol::Padding ewol::compositing::Shaper::getPaddingIn(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)); + padding.setValue(m_config->getNumber(m_confIdPaddingIn[shaperPosLeft]), + m_config->getNumber(m_confIdPaddingIn[shaperPosTop]), + m_config->getNumber(m_confIdPaddingIn[shaperPosRight]), + m_config->getNumber(m_confIdPaddingIn[shaperPosButtom])); + } + return padding; +} + +ewol::Padding ewol::compositing::Shaper::getPaddingOut(void) { + ewol::Padding padding(0,0,0,0); + if (m_config != NULL) { + padding.setValue(m_config->getNumber(m_confIdPaddingOut[shaperPosLeft]), + m_config->getNumber(m_confIdPaddingOut[shaperPosTop]), + m_config->getNumber(m_confIdPaddingOut[shaperPosRight]), + m_config->getNumber(m_confIdPaddingOut[shaperPosButtom])); + } + return padding; +} + +ewol::Padding ewol::compositing::Shaper::getBorder(void) { + ewol::Padding padding(0,0,0,0); + if (m_config != NULL) { + padding.setValue(m_config->getNumber(m_confIdBorder[shaperPosLeft]), + m_config->getNumber(m_confIdBorder[shaperPosTop]), + m_config->getNumber(m_confIdBorder[shaperPosRight]), + m_config->getNumber(m_confIdBorder[shaperPosButtom])); } return padding; } diff --git a/sources/ewol/compositing/Shaper.h b/sources/ewol/compositing/Shaper.h index 964f1b0c..fb6d666e 100644 --- a/sources/ewol/compositing/Shaper.h +++ b/sources/ewol/compositing/Shaper.h @@ -25,6 +25,16 @@ namespace ewol { renderBorder, //!< Render 4 squares for coiner, and renctangle for border, a big rentangle for background and 8 rectangle for the outside part renderOneBorder, }; + #define SHAPER_NB_MAX_QUAD (5*5) + #define SHAPER_NB_MAX_TRIANGLE (SHAPER_NB_MAX_QUAD*2) + #define SHAPER_NB_MAX_VERTEX (SHAPER_NB_MAX_TRIANGLE*3) + enum { + shaperPosLeft, + shaperPosRight, + shaperPosTop, + shaperPosButtom, + shaperPosCount, + }; /** * @brief the Shaper system is a basic theme configuration for every widget, it corespond at a background display described by a pool of files */ @@ -35,10 +45,12 @@ 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_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_confIdDisplayExternal; //!< Display external border + int32_t m_confIdPaddingOut[shaperPosCount]; //!< Padding out property : X-left X-right Y-top Y-buttom + int32_t m_confIdBorder[shaperPosCount]; //!< border property : X-left X-right Y-top Y-buttom + int32_t m_confIdPaddingIn[shaperPosCount]; //!< Padding in property : X-left X-right Y-top Y-buttom + int32_t m_confIdMode; //!< Display mode + int32_t m_confIdDisplayOutside; //!< Display outside of the shape... 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 @@ -47,10 +59,7 @@ namespace ewol { ewol::resource::Program* m_GLprogram; //!< pointer on the opengl display program int32_t m_GLPosition; //!< openGL id on the element (vertex buffer) int32_t m_GLMatrix; //!< openGL id on the element (transformation matrix) - int32_t m_GLPropertySize; //!< openGL id on the element (widget size) - int32_t m_GLPropertyOrigin; //!< openGL id on the element (widget origin) - int32_t m_GLPropertyInsidePos; //!< openGL id on the element (widget internal element position) - int32_t m_GLPropertyInsideSize; //!< openGL id on the element (widget internal element size) + int32_t m_GLPropertyPos; //!< openGL id on the element (simple ratio position in the widget : ____/-----\_____ on vec2(X,Y)) int32_t m_GLStateActivate; //!< openGL id on the element (activate state displayed) int32_t m_GLStateOld; //!< openGL id on the element (old state displayed) int32_t m_GLStateNew; //!< openGL id on the element (new state displayed) @@ -68,7 +77,9 @@ namespace ewol { int32_t m_stateOld; //!< previous state int32_t m_stateNew; //!< destination state float m_stateTransition; //!< working state between 2 states - vec2 m_coord[6]; //!< the double triangle coordonates + vec2 m_coord[SHAPER_NB_MAX_VERTEX]; //!< coordonate of the display ... + vec2 m_pos[SHAPER_NB_MAX_VERTEX]; //!< podition to display property + int32_t m_nbVertexToDisplay; // color management theme: ewol::resource::ColorFile* m_colorProperty; //!< input resource for color management std::vector m_listAssiciatedId; //!< Corellation ID between ColorProperty (Y) and OpenGL Program (X) @@ -135,31 +146,18 @@ namespace ewol { * @return false No need to request the periodic call. */ bool periodicCall(const ewol::event::Time& _event); - /** - * @brief set the widget origin (needed fot the display) - * @param[in] _newOri : the new widget origin - */ - void setOrigin(const vec2& _newOri); - /** - * @brief set the widget size (needed fot the display) - * @param[in] _newSize : the new widget size - */ - void setSize(const vec2& _newSize); - /** - * @brief set the internal widget size - * @param[in] _newInsidePos : the subelement size. - */ - void setInsideSize(const vec2& _newInsideSize); - /** - * @brief set the internal widget position - * @param[in] _newInsidePos : the subelement position - */ - void setInsidePos(const vec2& _newInsidePos); /** * @brief get the padding declared by the user in the config file * @return the padding property */ ewol::Padding getPadding(void); + ewol::Padding getPaddingIn(void); + ewol::Padding getPaddingOut(void); + /** + * @brief get the padding declared by the user in the config file + * @return the padding property + */ + ewol::Padding getBorder(void); /** * @brief change the shaper Source * @param[in] _newFile New file of the shaper @@ -177,11 +175,57 @@ namespace ewol { * @return the validity od the resources. */ bool hasSources(void); - private: + public: /** - * @brief update the internal vertex table. + * @brief set the shape property: + * + * ******************************************************************************** + * * _size * + * * * + * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * + * * * + * * | | * + * * *************************************************** * + * * | * * | * + * * * * * + * * | * * - - - - - - - - - - - - - - - - - - * * | * + * * * _insideSize * * + * * | * | | * | * + * * * * * + * * | * | | * | * + * * * * * + * * | * | | * | * + * * * * * + * * | * | | * | * + * * * * * + * * | * | | * | * + * * * * * + * * | * | | * | * + * * * _insidePos * * + * * | * * - - - - - - - - - - - - - - - - - - * * | * + * * * * * + * * | *************************************************** | * + * * * + * * | | * + * * * + * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * * + * * * + * * * + * ******************************************************************************** + * _origin + * + * + * @param[in] _origin Origin of the display + * @param[in] _size Size of the display + * @param[in] _insidePos Positin of the internal data + * @param[in] _insideSize Size of the internal data */ - void updateVertex(void); + void setShape(const vec2& _origin, const vec2& _size, const vec2& _insidePos, const vec2& _insideSize); + // @previous + void setShape(const vec2& _origin, const vec2& _size) { + ewol::Padding tmp = getPadding(); + setShape(_origin, _size, _origin+vec2(tmp.xLeft(), tmp.yButtom()), _size - vec2(tmp.x(), tmp.y())); + } public: /** * @brief Get an ID on the color instance element @@ -232,6 +276,21 @@ namespace ewol { void setActivateState(int32_t _status) { m_stateActivate = _status; } + private: + void addVertexLine(float _yTop, + float _yButtom, + float _x1, + float _x2, + float _x3, + float _x4, + float _x5, + float _x6, + float _x7, + float _x8, + float _yValTop, + float _yValButtom, + const float* _table, + bool _displayOutside); }; }; }; diff --git a/sources/ewol/resource/ConfigFile.cpp b/sources/ewol/resource/ConfigFile.cpp index ceb0955c..c2768b2d 100644 --- a/sources/ewol/resource/ConfigFile.cpp +++ b/sources/ewol/resource/ConfigFile.cpp @@ -92,7 +92,17 @@ const std::string& ewol::resource::ConfigFile::getString(int32_t _id) { return tmp->get(); } - +bool ewol::resource::ConfigFile::getBoolean(int32_t _id) { + if ( _id < 0 + || m_list[_id] == NULL) { + return false; + } + ejson::Boolean* tmp = m_list[_id]->toBoolean(); + if (tmp == NULL) { + return false; + } + return tmp->get(); +} ewol::resource::ConfigFile* ewol::resource::ConfigFile::keep(const std::string& _filename) { EWOL_INFO("KEEP : SimpleConfig : file : \"" << _filename << "\""); diff --git a/sources/ewol/resource/ConfigFile.h b/sources/ewol/resource/ConfigFile.h index da2bc04b..82fbe9d0 100644 --- a/sources/ewol/resource/ConfigFile.h +++ b/sources/ewol/resource/ConfigFile.h @@ -31,6 +31,7 @@ namespace ewol { double getNumber(int32_t _id); const std::string& getString(int32_t _id); + bool getBoolean(int32_t _id); public: /** * @brief keep the resource pointer. diff --git a/sources/ewol/resource/Shader.cpp b/sources/ewol/resource/Shader.cpp index 70e4cf5a..273480c5 100644 --- a/sources/ewol/resource/Shader.cpp +++ b/sources/ewol/resource/Shader.cpp @@ -114,7 +114,7 @@ void ewol::resource::Shader::removeContextToLate(void) { void ewol::resource::Shader::reload(void) { etk::FSNode file(m_name); if (false == file.exist()) { - EWOL_ERROR("File does not Exist : \"" << file << "\""); + EWOL_ERROR("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'"); return; } diff --git a/sources/ewol/widget/Button.cpp b/sources/ewol/widget/Button.cpp index 8359ac09..62370c9a 100644 --- a/sources/ewol/widget/Button.cpp +++ b/sources/ewol/widget/Button.cpp @@ -110,11 +110,10 @@ void ewol::widget::Button::onRegenerateDisplay(void) { return; } 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+vec2(padding.xLeft(),padding.yButtom()) )); - m_shaper.setInsideSize(vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) )); + m_shaper.setShape(vec2(0,0), + m_size, + vec2ClipInt32(m_selectableAreaPos+vec2(padding.xLeft(),padding.yButtom()) ), + vec2ClipInt32(m_selectableAreaSize-vec2(padding.x(),padding.y()) ) ); } void ewol::widget::Button::setLock(enum buttonLock _lock) { diff --git a/sources/ewol/widget/ButtonColor.cpp b/sources/ewol/widget/ButtonColor.cpp index ce002d6f..a2f4bce0 100644 --- a/sources/ewol/widget/ButtonColor.cpp +++ b/sources/ewol/widget/ButtonColor.cpp @@ -134,12 +134,11 @@ void ewol::widget::ButtonColor::onRegenerateDisplay(void) { // selection area : 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()) ); vec3 tmpp = m_text.calculateSize(label); - vec2 tmpp2(tmpp.x(), tmpp.y()); - m_shaper.setInsideSize(tmpp2); + m_shaper.setShape(m_selectableAreaPos, + m_selectableAreaSize, + vec2(tmpTextOrigin.x(), tmpTextOrigin.y()), + vec2(tmpp.x(), tmpp.y())); } diff --git a/sources/ewol/widget/CheckBox.cpp b/sources/ewol/widget/CheckBox.cpp index 0d19a9ab..b3674149 100644 --- a/sources/ewol/widget/CheckBox.cpp +++ b/sources/ewol/widget/CheckBox.cpp @@ -115,12 +115,12 @@ void ewol::widget::CheckBox::onRegenerateDisplay(void) { vec2 origin(m_selectableAreaPos + vec2(0, (m_selectableAreaSize.y() - (boxSize+padding.y()))*0.5f)); vec2 size = vec2(boxSize+padding.x(), boxSize+padding.y()); - m_shaper.setOrigin(vec2ClipInt32(origin)); - m_shaper.setSize(vec2ClipInt32(size)); - origin = m_selectableAreaPos + vec2((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); - size = vec2(boxInside+padding.x(), boxInside+padding.y()); - m_shaper.setInsidePos(vec2ClipInt32(origin+vec2(padding.xLeft(),padding.yButtom()) )); - m_shaper.setInsideSize(vec2ClipInt32(size-vec2(padding.x(),padding.y()) )); + vec2 origin2 = m_selectableAreaPos + vec2((boxSize-boxInside)*0.5f, (m_selectableAreaSize.y() - (boxInside+padding.y()))*0.5f); + vec2 size2 = vec2(boxInside+padding.x(), boxInside+padding.y()); + m_shaper.setShape(vec2ClipInt32(origin), + vec2ClipInt32(size), + vec2ClipInt32(origin2+vec2(padding.xLeft(),padding.yButtom()) ), + vec2ClipInt32(size2-vec2(padding.x(),padding.y()) )); } void ewol::widget::CheckBox::setValue(bool _val) { diff --git a/sources/ewol/widget/ContextMenu.cpp b/sources/ewol/widget/ContextMenu.cpp index 12c64dc7..d61888ca 100644 --- a/sources/ewol/widget/ContextMenu.cpp +++ b/sources/ewol/widget/ContextMenu.cpp @@ -210,10 +210,8 @@ void ewol::widget::ContextMenu::onRegenerateDisplay(void) { 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+vec2(padding.xLeft(), padding.yButtom()))); - m_shaper.setInsideSize(vec2ClipInt32(shaperSize-vec2(padding.x(), padding.y()))); + m_shaper.setShape(vec2ClipInt32(shaperOrigin), + vec2ClipInt32(shaperSize)); } bool ewol::widget::ContextMenu::onEventInput(const ewol::event::Input& _event) { diff --git a/sources/ewol/widget/Entry.cpp b/sources/ewol/widget/Entry.cpp index bace5216..28ca9bb2 100644 --- a/sources/ewol/widget/Entry.cpp +++ b/sources/ewol/widget/Entry.cpp @@ -193,8 +193,7 @@ void ewol::widget::Entry::onRegenerateDisplay(void) { } m_text.setClippingMode(false); - m_shaper.setOrigin(tmpOriginShaper); - m_shaper.setSize(tmpSizeShaper); + m_shaper.setShape(tmpOriginShaper, tmpSizeShaper, tmpOriginText, tmpSizeText); } } diff --git a/sources/ewol/widget/PopUp.cpp b/sources/ewol/widget/PopUp.cpp index 657f030c..57d3facd 100644 --- a/sources/ewol/widget/PopUp.cpp +++ b/sources/ewol/widget/PopUp.cpp @@ -136,10 +136,10 @@ void ewol::widget::PopUp::onRegenerateDisplay(void) { tmpSize.setMax(m_minSize); vec2 tmpOrigin = (m_size-tmpSize)/2.0f; - m_shaper.setOrigin(vec2(0,0)); - m_shaper.setSize(vec2ClipInt32(m_size)); - m_shaper.setInsidePos(vec2ClipInt32(tmpOrigin-vec2(padding.xLeft(), padding.yButtom()))); - m_shaper.setInsideSize(vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y()))); + m_shaper.setShape(vec2(0,0), + vec2ClipInt32(m_size), + vec2ClipInt32(tmpOrigin-vec2(padding.xLeft(), padding.yButtom())), + vec2ClipInt32(tmpSize + vec2(padding.x(), padding.y()))); } // SUBwIDGET GENERATION ... if (NULL != m_subWidget) { diff --git a/sources/ewol/widget/WidgetScrolled.cpp b/sources/ewol/widget/WidgetScrolled.cpp index bc17a8ea..97cbc7a6 100644 --- a/sources/ewol/widget/WidgetScrolled.cpp +++ b/sources/ewol/widget/WidgetScrolled.cpp @@ -44,31 +44,31 @@ void ewol::widget::WidgetScrolled::onRegenerateDisplay(void) { // nothing to do ... return; } + ewol::Padding paddingVert = m_shaperV.getPadding(); + ewol::Padding paddingHori = m_shaperH.getPadding(); if( m_size.y() < m_maxSize.y() || m_originScrooled.y()!=0) { - 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.xLeft(), m_size.y() - originScrollBar - lenScrollBar)); - m_shaperV.setInsideSize(vec2(padding.xLeft(), lenScrollBar)); + m_shaperV.setShape(vec2(m_size.x() - paddingVert.x(), 0), + vec2(paddingVert.x(), m_size.y()), + vec2(m_size.x() - paddingVert.xRight(), m_size.y() - originScrollBar - lenScrollBar), + vec2(0, lenScrollBar)); } if( m_size.x() < m_maxSize.x() || m_originScrooled.x()!=0) { - ewol::Padding padding = m_shaperH.getPadding(); - m_shaperH.setOrigin(vec2(0, 0)); - 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 lenScrollBar = (m_size.x()-paddingHori.xLeft())*(m_size.x()-paddingVert.x()) / m_maxSize.x(); + lenScrollBar = etk_avg(10, lenScrollBar, (m_size.x()-paddingVert.x())); 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.xRight()-lenScrollBar); - m_shaperH.setInsidePos(vec2(originScrollBar, 0)); - m_shaperH.setInsideSize(vec2(lenScrollBar, padding.yButtom())); + originScrollBar *= (m_size.x()-paddingHori.xRight()-lenScrollBar); + m_shaperH.setShape(vec2(0, 0), + vec2(m_size.x()-paddingVert.x(), paddingHori.y()), + vec2(originScrollBar, paddingHori.yButtom()), + vec2(lenScrollBar, 0)); } } diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index 8e0a82f8..893dbad0 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -22,6 +22,7 @@ def create(target): myModule.add_src_file([ 'ewol/ewol.cpp', 'ewol/debug.cpp', + 'ewol/Padding.cpp', 'ewol/Dimension.cpp' ])