aboutsummaryrefslogtreecommitdiff
path: root/include/smindicator.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/smindicator.hpp')
-rw-r--r--include/smindicator.hpp52
1 files changed, 45 insertions, 7 deletions
diff --git a/include/smindicator.hpp b/include/smindicator.hpp
index 5237a3b..0595dc8 100644
--- a/include/smindicator.hpp
+++ b/include/smindicator.hpp
@@ -2,7 +2,6 @@
/*
* Simple MultimEdia LiTerator(SMELT)
* by Chris Xiong 2015
- * api level 1
* Indicator header & implementation
*
* WARNING: This library is in development and interfaces would be very
@@ -14,16 +13,17 @@
#include "smelt.hpp"
#include "smmath.hpp"
#include "smcolor.hpp"
+#include "smentity.hpp"
#include "smgrid.hpp"
class indicatorCircular
{
private:
smGrid *circle;
- double value,radius,thickness;
+ float value,radius,thickness;
DWORD color;
BYTE alpha;
public:
- void init(double r,double thkns,BYTE a,SMTEX tex,smTexRect tr)
+ void init(float r,float thkns,BYTE a,SMTEX tex,smTexRect tr)
{
circle=new smGrid(1025,3);
circle->setTexture(tex);
@@ -31,8 +31,8 @@ public:
radius=r;thickness=thkns;alpha=a;color=0;
for(int i=0;i<=1024;++i)
{
- double tang,tx,ty;
- tang=(double)i/1024.*PI*2-PI/2;
+ float tang,tx,ty;
+ tang=(float)i/1024.*PI*2-PI/2;
tx=-cos(tang)*radius;ty=sin(tang)*radius;
circle->setPos(i,2,tx,ty,0.5,GRID_REFTOPLEFT);
tx=-cos(tang)*(radius-thickness);ty=sin(tang)*(radius-thickness);
@@ -43,7 +43,7 @@ public:
}
void overrideColor(DWORD col){color=col;}
void setAlpha(BYTE a){alpha=a;}
- void setValue(double v)
+ void setValue(float v)
{
value=v;
for(int i=0;i<=1024;++i)
@@ -55,7 +55,7 @@ public:
if(tc->v<0.85)tc->v=0.85;
tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha);
delete tc;
- if((double)i/1024.<=value)
+ if((float)i/1024.<=value)
{
circle->setColor(i,2,tcolor);
circle->setColor(i,1,SETA(0x00FFFFFF,alpha));
@@ -72,4 +72,42 @@ public:
void render(float x,float y){circle->render(x,y);}
void deinit(){delete circle;circle=NULL;}
};
+class indicatorLinear
+{
+private:
+ smEntity2D *upper,*lower;
+ float value,maxlength,thickness;
+ DWORD color;smTexRect trect;
+ BYTE alpha;
+public:
+ void init(float ml,float thkns,BYTE a,SMTEX tex,smTexRect tr)
+ {
+ upper=new smEntity2D(tex,tr.x,tr.y,tr.w,tr.h/2);
+ lower=new smEntity2D(tex,tr.x,tr.y+tr.h/2,tr.w,tr.h/2);
+ maxlength=ml;thickness=thkns;alpha=a;color=0;trect=tr;
+ }
+ void overrideColor(DWORD col){color=col;}
+ void setAlpha(BYTE a){alpha=a;}
+ void setValue(float v)
+ {
+ value=v;
+ int tr=(int)((1.0f-value)*255);
+ int tg=(int)(value*255);
+ DWORD tcolor=ARGB(alpha,tr,tg,0);
+ smColorHSVA *tc=new smColorHSVA(tcolor);
+ if(tc->v<0.85)tc->v=0.85;
+ tcolor=color?SETA(color,alpha):SETA(tc->getHWColor(),alpha);
+ delete tc;
+ upper->setColor(tcolor,0);upper->setColor(tcolor,1);
+ upper->setColor(0,2);upper->setColor(0,3);
+ lower->setColor(0,0);lower->setColor(0,1);
+ lower->setColor(tcolor,2);lower->setColor(tcolor,3);
+ }
+ void render(float x,float y)
+ {
+ upper->render(x,y,0,value*maxlength/trect.w,thickness/trect.h/2);
+ lower->render(x,y+thickness/2,0,value*maxlength/trect.w,thickness/trect.h/2);
+ }
+ void deinit(){delete upper;delete lower;upper=lower=NULL;}
+};
#endif