From b35988ef891b7a7566859f75b9b8417e8a7a3243 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sat, 25 May 2013 10:56:57 +0200 Subject: [PATCH] [DEV] better display of the rounded theme --- data/theme/rounded/widgetButton.frag | 2 +- data/theme/rounded/widgetContextMenu.frag | 2 +- data/theme/rounded/widgetEntry.frag | 42 +++++++++++++---------- data/theme/rounded/widgetPopUp.frag | 2 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/data/theme/rounded/widgetButton.frag b/data/theme/rounded/widgetButton.frag index c4839040..be037b57 100644 --- a/data/theme/rounded/widgetButton.frag +++ b/data/theme/rounded/widgetButton.frag @@ -51,7 +51,7 @@ void main(void) { vec2 ratioLow = ratio - (S_roundedRatio+S_sizePadding); vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = sqrt(dot(circleMode,circleMode)); + float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); // Generate the internal rampe for the the imput drawing float tmpVal = smoothstep(S_roundedRatio - S_sizeBorder*1.5, S_roundedRatio + S_sizeBorder*1.5, diff --git a/data/theme/rounded/widgetContextMenu.frag b/data/theme/rounded/widgetContextMenu.frag index f48577eb..c9349775 100644 --- a/data/theme/rounded/widgetContextMenu.frag +++ b/data/theme/rounded/widgetContextMenu.frag @@ -51,7 +51,7 @@ void main(void) { vec2 ratioLow = ratio - (S_roundedRatio+S_sizePadding); vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = sqrt(dot(circleMode,circleMode)); + float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); // Generate the internal rampe for the the imput drawing float tmpVal = smoothstep(S_roundedRatio - S_sizeBorder*1.5, S_roundedRatio + S_sizeBorder*1.5, diff --git a/data/theme/rounded/widgetEntry.frag b/data/theme/rounded/widgetEntry.frag index 12e505a9..e05d3f7a 100644 --- a/data/theme/rounded/widgetEntry.frag +++ b/data/theme/rounded/widgetEntry.frag @@ -38,25 +38,29 @@ void main(void) { // prevent origin moving ... vec2 position = v_position - EW_widgetProperty.origin; + /* generate a central simetry + ____ _____ + \ / + \ / + \ / + - + */ vec2 positionCenter = abs(position-ratio); - vec2 ratioHight = ratio - S_sizePadding; - vec2 ratioLow = ratioHight - (S_sizeBorder+S_roundedRatio); - vec2 circleMode = smoothstep(ratioLow, ratioHight, positionCenter); - float tmpDist = sqrt(dot(circleMode,circleMode)); - - //float distanceInternal = (S_roundedRatio-S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder); - //float distanceExternal = (S_roundedRatio+S_sizeBorder/2.0)/(S_roundedRatio-S_sizeBorder);; - if(tmpDist <= 0.7 ) { - gl_FragColor = S_colorFg; - } else if(tmpDist <= 0.9) { - float tmpVal = smoothstep(0.7, 0.9, tmpDist); - if (tmpVal<=0.5) { - gl_FragColor = S_colorBorder*(tmpVal*2.0) + S_colorFg*(1.0-tmpVal*2.0); - } else { - gl_FragColor = S_colorBorder*(1.0-(tmpVal-0.5)*2.0) + S_colorBg*((tmpVal-0.5)*2.0); - } - } else { - gl_FragColor = S_colorBg; - } + // This is a clip to remove center of the display of the widget + vec2 ratioLow = ratio - (S_roundedRatio+S_sizePadding); + vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); + // Calculate the distance of the radius + float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); + // Generate the internal rampe for the the imput drawing + float tmpVal = smoothstep(S_roundedRatio - S_sizeBorder*1.5, + S_roundedRatio + S_sizeBorder*1.5, + tmpDist); + // set Background + gl_FragColor = S_colorBg; + // set foreground + gl_FragColor = gl_FragColor*tmpVal + S_colorFg*(1.0-tmpVal); + // set border + float tmpVal2 = abs(tmpVal-0.5)*2.0; + gl_FragColor = gl_FragColor*tmpVal2 + S_colorBorder*(1.0-tmpVal2); } diff --git a/data/theme/rounded/widgetPopUp.frag b/data/theme/rounded/widgetPopUp.frag index 0cfb9bba..bd19d820 100644 --- a/data/theme/rounded/widgetPopUp.frag +++ b/data/theme/rounded/widgetPopUp.frag @@ -51,7 +51,7 @@ void main(void) { vec2 ratioLow = ratio - (S_roundedRatio+S_sizePadding); vec2 circleMode = smoothstep(ratioLow, ratio, positionCenter)*(S_roundedRatio+S_sizePadding); // Calculate the distance of the radius - float tmpDist = sqrt(dot(circleMode,circleMode)); + float tmpDist = float(int(sqrt(dot(circleMode,circleMode)))); // Generate the internal rampe for the the imput drawing float tmpVal = smoothstep(S_roundedRatio - S_sizeBorder*1.5, S_roundedRatio + S_sizeBorder*1.5,