]> git.webhop.me Git - tuxwetter.git/commitdiff
- replace nearly all fixed position values with scaled values ...
authorGetAway <get-away@t-online.de>
Thu, 5 Oct 2017 20:27:49 +0000 (22:27 +0200)
committerJacek Jendrzej <satbaby@kawaii.com>
Fri, 6 Oct 2017 06:14:29 +0000 (08:14 +0200)
to get a smoother display in full-hd mode
bump version to 4.10

php.c
text.c
text.h
tuxwetter.c
tuxwetter.h

diff --git a/php.c b/php.c
index 975784ee932d5a3cb70c8667fe426032b888677b..e3fa3ef829684ef05f321ee30b6c3d559cc8e84a 100644 (file)
--- a/php.c
+++ b/php.c
@@ -15,8 +15,8 @@ int fh_php_trans(const char *name, int _sx, int _sy, int dy, int cs, int line, i
 char tstr[BUFSIZE]={0},rstr[BUFSIZE]={0},*tptr=NULL,*xptr=NULL,cc,br3flag=0;
 int loop=1, j, first, aline=0, fx=_sx, fy=_sy, slen, deg=0;
 
-int wxw=ex-_sx-((preset)?120:30);              //box width
-int wyw=ey-_sy-((preset)?60:40);               //box height
+int wxw=ex-_sx-((preset)?scale2res(120):scale2res(30));                //box width
+int wyw=ey-_sy-((preset)?scale2res(60):scale2res(40));         //box height
 
 FILE *fh;
 
@@ -127,12 +127,6 @@ FILE *fh;
                                        if((loop>0) && (_sy<(fy+wyw/*420*/)))
                                        {
                                                rstr[j]=0;
-                                       //      printf(" # 1 # php.c %s \n",rstr);
-                                       //      char *t = (char *)alloca(j * 4 + 1);
-                                       //      memcpy(t, rstr, j + 1);
-                                       //      TranslateString(t, j * 4);
-                                       //      //strcpy(rstr, t);
-                                       //      printf(" # 2 # php.c %s \n",t);
                                                if(plot)
                                                {
 
@@ -142,7 +136,7 @@ FILE *fh;
                                                        }
                                                        else
                                                        {
-                                                               RenderString(rstr, _sx, fx+250, wxw/*619*/, CENTER, FSIZE_BIG, CMCT);
+                                                               RenderString(rstr, _sx, fx+scale2res(250), wxw/*619*/, CENTER, FSIZE_BIG, CMCT);
                                                        }
                                                        if(strlen(rstr))
                                                        {
@@ -166,7 +160,7 @@ FILE *fh;
                                }
                                if(plot)
                                {
-                                       int ssx = ((preset)?80:25);
+                                       int ssx = ((preset)?scale2res(82):scale2res(25));
                                        *cut=(_sy>=(fy+wyw/*420*/));
                                        if(line)
                                        {
diff --git a/text.c b/text.c
index abc3b90b58cd442405fd18224ca8b3c93361811b..129ceae1583e91ce904921585cb04c27d80ad65c 100644 (file)
--- a/text.c
+++ b/text.c
@@ -10,6 +10,10 @@ int FSIZE_SMALL=20;
 int FSIZE_VSMALL=16;
 int TABULATOR=72;
 
+int OFFSET_MED=10;
+int OFFSET_SMALL=5;
+int OFFSET_MIN=2;
+
 static char *sc = "aouAOUzd",
                        *su = "\xA4\xB6\xBC\x84\x96\x9C\x9F",
                        *tc = "\xE4\xF6\xFC\xC4\xD6\xDC\xDF\xB0";
@@ -222,18 +226,18 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color)
        {
                if(color != -1)
                {
-                       if (_sx + 10 < _ex)
-                               RenderBox(_sx, _sy - 16, _sx + 10, _sy - 6, GRID, color);
+                       if (_sx + OFFSET_MED < _ex)
+                               RenderBox(_sx, _sy - OFFSET_MED - OFFSET_SMALL, _sx + OFFSET_MED, _sy - OFFSET_SMALL, GRID, color);
                        else
                                return -1;
                }
-               return 10;
+               return OFFSET_MED;
        }
 
        if (currentchar == '\t')
        {
                /* simulate horizontal TAB */
-               return 15;
+               return scale2res(15);
        }
 
        //load char
@@ -332,7 +336,7 @@ int GetStringLen(int _sx, char *_string, size_t size)
                                stringlen=desc.width+TABULATOR*((int)(stringlen/TABULATOR)+1);
                        else if(*string=='T' && sscanf(string+1,"%4d",&i)==1) {
                                string+=5;
-                               stringlen=i-_sx;
+                               stringlen=scale2res(i)-_sx;
                        }
                        break;
                default:
@@ -403,7 +407,7 @@ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int s
                                case 'T':
                                        if(sscanf(rptr+1,"%4d",&i)==1) {
                                                rptr+=4;
-                                               _sx=i;
+                                               _sx=scale2res(i);
                                        }
                                        rptr++;
                                        continue;
@@ -424,7 +428,7 @@ int RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int s
 void ShowMessage(char *message, int wait)
 {
        extern int radius, radius_small;
-       int mxw=420, myw=120+40*wait, mhw=30;
+       int mxw=scale2res(420), myw=scale2res(120)+scale2res(40)*wait, mhw=scale2res(30);
        int msx,msy;
        char *tdptr;
 
@@ -432,24 +436,24 @@ void ShowMessage(char *message, int wait)
 
        //layout
 
-               RenderBox(msx+6, msy+6, mxw, myw, radius, CSP0);
+               RenderBox(msx+OFFSET_SMALL, msy+OFFSET_SMALL, mxw, myw, radius, CSP0);
                RenderBox(msx, msy, mxw, myw, radius, CMC);
                RenderBox(msx, msy, mxw, mhw, radius, CMH);
 
        //message
 
                tdptr=strdup("Tuxwetter Info");
-               RenderString(tdptr, msx+2, msy+mhw, mxw-4, CENTER, FSIZE_MED, CMHT);
+               RenderString(tdptr, msx+OFFSET_MIN, msy+mhw, mxw-2*OFFSET_MIN, CENTER, FSIZE_MED, CMHT);
                free(tdptr);
                tdptr=strdup(message);
-               RenderString(tdptr, msx+2, msy+mhw+2+((myw-mhw)/2)-FSIZE_MED/2+(!wait*15), mxw-4, CENTER, FSIZE_MED, CMCT);
+               RenderString(tdptr, msx+OFFSET_MIN, msy+mhw+((wait)?OFFSET_MED:OFFSET_SMALL)+((myw-mhw)/2)-FSIZE_MED/2+(!wait*scale2res(15)), mxw-2*OFFSET_MIN, CENTER, FSIZE_MED, CMCT);
                free(tdptr);
 
                if(wait)
                {
-                       RenderBox(msx+mxw/2-35+4, msy+myw-45+4, 70, FSIZE_SMALL*3/2, radius_small, CSP0);
-                       RenderBox(msx+mxw/2-35, msy+myw-45, 70, FSIZE_SMALL*3/2, radius_small, CMCS);
-                       RenderString("OK", msx+mxw/2-26, msy+myw-38+FSIZE_SMALL, 50, CENTER, FSIZE_SMALL, CMCT);
+                       RenderBox(msx+mxw/2-scale2res(35)+OFFSET_SMALL, msy+myw-scale2res(45)+OFFSET_SMALL, scale2res(70), FSIZE_SMALL*3/2, radius_small, CSP0);
+                       RenderBox(msx+mxw/2-scale2res(35), msy+myw-scale2res(45), scale2res(70), FSIZE_SMALL*3/2, radius_small, CMCS);
+                       RenderString("OK", msx+mxw/2-scale2res(26), msy+myw-scale2res(38)+FSIZE_SMALL, scale2res(50), CENTER, FSIZE_SMALL, CMCT);
                }
                blit();
 
diff --git a/text.h b/text.h
index 54c2c183f66ce4416b1a1f1ddda51fd1424676fd..a1bab9c1e527c2bb28e328c9198dd9b7f514f7ba 100644 (file)
--- a/text.h
+++ b/text.h
@@ -10,5 +10,6 @@ void TranslateString(char *src, size_t size);
 int GetStringLen(int _sx, char *string, size_t size);
 void CatchTabs(char *text);
 void ShowMessage(char *message, int wait);
+int scale2res(int s);
 
 #endif
index 1501f43ee58713e28998a6557bfafb257812281b..9b41bae5fc8bd8bb504f943c5c3222abdf990b26 100644 (file)
@@ -44,7 +44,7 @@
 #include "gifdecomp.h"
 #include "icons.h"
 
-#define P_VERSION "4.06"
+#define P_VERSION "4.10"
 #define S_VERSION ""
 
 
@@ -599,6 +599,13 @@ struct tm *tltime;
        return tret;
 }
 
+int scale2res(int s)
+{
+       if (var_screeninfo.xres == 1920)
+               s += s/2;
+
+       return s;
+}
 
 void TrimString(char *strg)
 {
@@ -1139,12 +1146,12 @@ void ShowInfo(MENU *m)
 {
        int iw, ih, icon_w=0, icon_h=0, xsize=0, ysize=0, loop;
        double scrollbar_len, scrollbar_ofs, scrollbar_cor;
-       int ix=m->act_entry,tind=m->act_entry, sbw=(m->num_entrys > LIST_STEP)?14:0;
+       int ix=m->act_entry,tind=m->act_entry, sbw=(m->num_entrys > LIST_STEP)?scale2res(14):0;
        char tstr[BUFSIZE]={0}, *tptr=NULL;
-       int moffs=35, roffs=8, ixw=400, iyw=(m->num_entrys < LIST_STEP)?((m->num_entrys+1)*30+moffs):375, dy, my, mh, toffs, soffs=4, isx, isy;
+       int moffs=scale2res(35), roffs=scale2res(8), ixw=scale2res(400), iyw=(m->num_entrys < LIST_STEP)?((m->num_entrys+1)*3*OFFSET_MED+moffs):scale2res(375), dy, my, mh, toffs, soffs=2*OFFSET_MIN, isx, isy;
 
-       mh=iyw-moffs-roffs-(radius?4:0);
-       dy=(m->num_entrys < LIST_STEP)?30:(mh/(LIST_STEP+1));
+       mh=iyw-moffs-roffs-(radius ? 2*OFFSET_MIN : 0);
+       dy=(m->num_entrys < LIST_STEP)?scale2res(30):(mh/(LIST_STEP+1));
        toffs=dy/2;
        my=moffs+dy+toffs;
        
@@ -1153,23 +1160,23 @@ void ShowInfo(MENU *m)
        tind=ix;
        
        //frame layout
-       RenderBox(isx+6, isy+6, ixw, iyw, radius, CSP0);
+       RenderBox(isx+OFFSET_SMALL, isy+OFFSET_SMALL, ixw, iyw, radius, CSP0);
        RenderBox(isx, isy, ixw, iyw, radius, CMC);
        // titlebar
        RenderBox(isx, isy, ixw, moffs+roffs, radius, CMH);
 
        //selectbar
-       RenderBox(isx+2, isy+moffs+toffs+soffs+(ix%10)*dy+2, ixw-sbw-2, dy+2, radius, CMCS);
+       RenderBox(isx+OFFSET_MIN, isy+moffs+toffs+soffs+(ix%10)*dy+OFFSET_MIN, ixw-sbw-OFFSET_MIN, dy+OFFSET_MIN, radius, CMCS);
 
        if(sbw)
        {
                //sliderframe
                RenderBox(isx+ixw-sbw, isy+moffs+roffs, sbw, mh, radius, CMCP1);
                //slider
-               scrollbar_len = (double)(mh-4) / (double)(((m->num_entrys-1)/LIST_STEP+1)*LIST_STEP);
+               scrollbar_len = (double)(mh-2*OFFSET_MIN/*4*/) / (double)(((m->num_entrys-1)/LIST_STEP+1)*LIST_STEP);
                scrollbar_ofs = scrollbar_len*(double)((ix/LIST_STEP)*LIST_STEP)+roffs;
                scrollbar_cor = scrollbar_len*(double)LIST_STEP;
-               RenderBox(isx+ixw-sbw+2, isy+moffs+scrollbar_ofs+2, sbw-4, scrollbar_cor, radius, CMCP3);
+               RenderBox(isx+ixw-sbw+OFFSET_MIN, isy+moffs+scrollbar_ofs+OFFSET_MIN, sbw-2*OFFSET_MIN, scrollbar_cor, radius, CMCP3);
        }
 
        png_getsize(TUX_ICON, &icon_w, &icon_h);
@@ -1179,10 +1186,10 @@ void ShowInfo(MENU *m)
                icon_h = ysize = 32;
        }
        multiple_pics=1;
-       paintIcon(TUX_ICON, isx+20-icon_w/2, (isy+dy-soffs-4)-icon_h/2, xsize, ysize, &iw, &ih);
+       paintIcon(TUX_ICON, isx+2*OFFSET_MED-icon_w/2, (isy+dy-soffs-2*OFFSET_MIN)-icon_h/2, xsize, ysize, &iw, &ih);
 
        // Title text
-       RenderString(m->headertxt[m->act_header], isx+47, isy+dy-soffs+11, ixw-sbw-45, LEFT, FSIZE_BIG, CMHT);
+       RenderString(m->headertxt[m->act_header], isx+scale2res(47), isy+dy-soffs+scale2res(11), ixw-sbw-scale2res(45), LEFT, FSIZE_BIG, CMHT);
 
        ix /= 10;
        //Show table of commands
@@ -1193,15 +1200,15 @@ void ShowInfo(MENU *m)
                {
                        *tptr=0;
                }
-               RenderString(tstr, isx+47, isy+my+7, ixw-sbw-65, LEFT, FSIZE_MED, ((loop%10) == (tind%10))?CMCST:CMCT);
+               RenderString(tstr, isx+scale2res(47), isy+my+OFFSET_SMALL+OFFSET_MIN, ixw-sbw-scale2res(65), LEFT, FSIZE_MED, ((loop%10) == (tind%10))?CMCST:CMCT);
                if(m->list[loop]->type==TYP_MENU)
                {
-                       RenderString(">", isx+32, isy+my+7, 65, LEFT, FSIZE_MED, ((loop%10) == (tind%10))?CMCST:CMCT);
+                       RenderString(">", isx+scale2res(32), isy+my+OFFSET_SMALL+OFFSET_MIN, scale2res(65), LEFT, FSIZE_MED, ((loop%10) == (tind%10))?CMCST:CMCT);
                }
                if(m->list[loop]->underline)
                {
-                       RenderBox(isx+10, isy+my+soffs+2, ixw-10-sbw, my+soffs+2, 0, CMCP3);
-                       RenderBox(isx+10, isy+my+soffs+3, ixw-10-sbw, my+soffs+3, 0, CMCP1);
+                       RenderBox(isx+OFFSET_MED, isy+my+soffs+OFFSET_MIN, ixw-OFFSET_MED-sbw, my+soffs+OFFSET_MIN, 0, CMCP3);
+                       RenderBox(isx+OFFSET_MED, isy+my+soffs+OFFSET_SMALL-OFFSET_MIN, ixw-OFFSET_MED-sbw, my+soffs+OFFSET_SMALL-OFFSET_MIN, 0, CMCP1);
                }
 
                icon_w = icon_h = 0;
@@ -1209,13 +1216,13 @@ void ShowInfo(MENU *m)
                //multiple_pics=1;
                switch(loop % 10)
                {
-                       case 0: paintIcon(ICON_BUTTON_RED,   isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break;
-                       case 1: paintIcon(ICON_BUTTON_GREEN, isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break;
-                       case 2: paintIcon(ICON_BUTTON_YELLOW,isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break;
-                       case 3: paintIcon(ICON_BUTTON_BLUE,  isx+18-icon_w/2, isy+my-8-(icon_h)/2, 0, 0, &iw, &ih); break;
+                       case 0: paintIcon(ICON_BUTTON_RED,   isx+9*OFFSET_MIN-icon_w/2, isy+my-4*OFFSET_MIN-(icon_h)/2, 0, 0, &iw, &ih); break;
+                       case 1: paintIcon(ICON_BUTTON_GREEN, isx+9*OFFSET_MIN-icon_w/2, isy+my-4*OFFSET_MIN-(icon_h)/2, 0, 0, &iw, &ih); break;
+                       case 2: paintIcon(ICON_BUTTON_YELLOW,isx+9*OFFSET_MIN-icon_w/2, isy+my-4*OFFSET_MIN-(icon_h)/2, 0, 0, &iw, &ih); break;
+                       case 3: paintIcon(ICON_BUTTON_BLUE,  isx+9*OFFSET_MIN-icon_w/2, isy+my-4*OFFSET_MIN-(icon_h)/2, 0, 0, &iw, &ih); break;
                        default:
                                sprintf(tstr,"%1d",(loop % 10)-3);
-                               RenderString(tstr, isx+10, isy+my+4, 15, CENTER, FSIZE_SMALL, ((loop%10) == (tind%10))?CMCST:CMCT);
+                               RenderString(tstr, isx+OFFSET_MED, isy+my+2*OFFSET_MIN, scale2res(15), CENTER, FSIZE_SMALL, ((loop%10) == (tind%10))?CMCST:CMCT);
                        break;
                }
                my += dy;
@@ -1281,34 +1288,34 @@ void show_data(int ix)
 #endif
 
 char vstr[512]={0},v2str[512]={0},rstr[512]={0},tstr[512]={0},icon[60]={0};
-int col1=40, vy=70;
-int col2=((preset)?340:300);
-
-int wxw=ex-sx-((preset)?120:30);  //box width
-int wyw=ey-sy-((preset)?60:20);   //box height
-int nc=10;                     //table columns
-int gys=vy;                    //table space top
-int gysf=34;                   //table space bottom
-int gxs=40;                    //table space left
+int col1=scale2res(40), vy=scale2res(70);
+int col2=((preset)?scale2res(380):scale2res(340));
+
+int wxw=ex-sx-((preset)?scale2res(120):scale2res(30));  //box width
+int wyw=ey-sy-((preset)?scale2res(60):scale2res(20));   //box height
+int nc=10;                   //table columns 10
+int gys=vy;                  //table space top
+int gysf=scale2res(34);      //table space bottom
+int gxs=4*OFFSET_MED;        //table space left
 //int gxw=((wxw-(gxs*2))/nc) * nc;     //table width
-int gicw=((wxw-(gxs*2))/nc);   //table data width
-int gxw=gicw*nc;               //table width
-int gywf=100;                  //table footer height
-int gyw=wyw-vy-gywf-gysf;      //table height
-//int gicw=gxw/nc;                     //table data width
+int gicw=((wxw-(gxs*2))/nc); //table data width
+int gxw=gicw*nc;             //table width
+int gywf=scale2res(100);     //table footer height
+int gyw=wyw-vy-gywf-gysf;    //table height
+//int gicw=gxw/nc;           //table data width
 int vxs=0,wsx,wsy;
 int prelate=0;
 int rcd;
-int HMED=((preset)?22:20);
-int dy=26;                     //linespace
-int slim=0;                    //using 720x576
+int HMED=((preset)?scale2res(22):scale2res(20));
+int dy=scale2res(26);        //linespace
+int slim=0;                  //using 720x576
 
 time_t atime;
 struct tm *sltime;
 char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
 
        //recalculate wigth
-       gicw += ((gicw%10) > 5 ? 10-(gicw%10) : -(gicw%10)); //rounded table data width, needing for smoothed curves
+       gicw += ((gicw%10) > OFFSET_SMALL ? OFFSET_MED-(gicw%10) : -(gicw%10)); //rounded table data width, needing for smoothed curves
        gxw=gicw*nc;
        gxs=(wxw-gxw)/2;
 
@@ -1323,14 +1330,14 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
        gyw+=wsy;
        col1+=wsx;
        col2+=wsx;
-       vy+=wsy+8;
+       vy+=wsy+4*OFFSET_MIN;
 
        //frame layout
        if(ix!=1)
        {
-               RenderBox(wsx+6, wsy+6, wxw, wyw, radius, CSP0);
+               RenderBox(wsx+OFFSET_SMALL, wsy+OFFSET_SMALL, wxw, wyw, radius, CSP0);
                RenderBox(wsx, wsy, wxw, wyw, radius, CMC);
-               RenderBox(wsx, wsy, wxw, 44, radius, CMH);
+               RenderBox(wsx, wsy, wxw, scale2res(44), radius, CMH);
        }
        else
        {
@@ -1355,9 +1362,9 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                int i;
                char grstr[XL+1]={'G'^XX,'r'^XX,'\xFC'^XX,'\xDF'^XX,'e'^XX,' '^XX,'v'^XX,'o'^XX,'m'^XX,' '^XX,'N'^XX,'e'^XX,'w'^XX,'-'^XX,'T'^XX,'u'^XX,'x'^XX,'w'^XX,'e'^XX,'t'^XX,'t'^XX,'e'^XX,'r'^XX,'-'^XX,'T'^XX,'e'^XX,'a'^XX,'m'^XX,'!'^XX,' '^XX,' '^XX,';'^XX,'-'^XX,')'^XX,' '^XX,' '^XX,'w'^XX,'w'^XX,'w'^XX,'.'^XX,'k'^XX,'e'^XX,'y'^XX,'w'^XX,'e'^XX,'l'^XX,'t'^XX,'-'^XX,'b'^XX,'o'^XX,'a'^XX,'r'^XX,'d'^XX,'.'^XX,'c'^XX,'o'^XX,'m'^XX,0};
 
-               dy = ((preset)?dy:22);
+               dy = ((preset)?dy:scale2res(22));
                sprintf(rstr,"Tuxwetter    Version %s%s",P_VERSION,S_VERSION);
-               RenderString(rstr, wsx, wsy+40, wxw, CENTER, FSIZE_BIG, CMHT);
+               RenderString(rstr, wsx, wsy+4*OFFSET_MED, wxw, CENTER, FSIZE_BIG, CMHT);
 
                sprintf(rstr,"%s",prs_translate("Steuertasten in den Menüs",CONVERT_LIST));
                RenderString(rstr, 0, vy, wxw, CENTER, HMED, GREEN);
@@ -1484,9 +1491,9 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                        double tstep=1, garr[nc*10], tv1, tv2, tv3;
 
                        RenderBox(wsx, wsy, wxw, wyw, radius, CMC);
-                       RenderBox(wsx, wsy, wxw, 44, radius, CMH);
+                       RenderBox(wsx, wsy, wxw, scale2res(44), radius, CMH);
                        sprintf(rstr,"%s %d %s",prs_translate("Trend für die kommende Woche",CONVERT_LIST),nc,prs_translate("Tage",CONVERT_LIST));
-                       RenderString(rstr, wsx, wsy+40, wxw, CENTER, FSIZE_BIG, CMHT);
+                       RenderString(rstr, wsx, wsy+4*OFFSET_MED, wxw, CENTER, FSIZE_BIG, CMHT);
                        RenderLine(gxs,gys,gxs,gys+gyw+gywf,CMCIT);
                        RenderLine(gxs+1,gys,gxs+1,gys+gyw+gywf,CMCIT);
                        for(i=0; i<nc; i++)
@@ -1543,7 +1550,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                        }
 #endif
                                        strcpy(rstr,prs_translate(vstr,CONVERT_LIST));
-                                       RenderString(rstr, gxs+i*gicw, gys+gyw+7+(FSIZE_BIG/2+gywf/2), gicw, CENTER, FSIZE_BIG, CMCT);//weekday
+                                       RenderString(rstr, gxs+i*gicw, gys+gyw+OFFSET_SMALL+(FSIZE_BIG/2+gywf/2), gicw, CENTER, FSIZE_BIG, CMCT);//weekday
                                }
                                RenderLine(gxs+(i+1)*gicw,gys,gxs+(i+1)*gicw,gys+gyw+gywf,CMCIT);
                        }
@@ -1561,8 +1568,8 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                        RenderLine(gxs,gys+gyw+gywf+1,gxs+gxw,gys+gyw+gywf+1,CMCIT);
                        RenderString((metric)? "°C":"°F", gxs-22, gys+3, 30, RIGHT, FSIZE_SMALL, CMCT);
                        RenderString((metric)? "°C":"°F", gxs+gxw-22, gys+3, 30, RIGHT, FSIZE_SMALL, CMCT);
-                       RenderString(prs_translate("Höchstwerte",CONVERT_LIST), gxs, gys+6, gxw/2, CENTER, FSIZE_SMALL, YELLOW);
-                       RenderString(prs_translate("Tiefstwerte",CONVERT_LIST), gxs+(gxw/2), gys+6, gxw/2, CENTER, FSIZE_SMALL, GREEN);
+                       RenderString(prs_translate("Höchstwerte",CONVERT_LIST), gxs, gys+5, gxw/2, CENTER, FSIZE_SMALL, YELLOW);
+                       RenderString(prs_translate("Tiefstwerte",CONVERT_LIST), gxs+(gxw/2), gys+5, gxw/2, CENTER, FSIZE_SMALL, GREEN);
 
                        for(i=1; i<=(5*(1+(int)((maxt-mint)/5))+1); i++)
                        {
@@ -1576,8 +1583,8 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                        RenderLine(gxs,gys+gyw-(i*tstep)-1,gxs+gxw,gys+gyw-(i*tstep)-1,CMCP3);
                                }
                                sprintf(vstr,"%d",mint+i-1);
-                               RenderString(vstr,gxs-35,gys+10+gyw-(i*tstep), 30, RIGHT, FSIZE_VSMALL, CMCT);
-                               RenderString(vstr,gxs+gxw+2,gys+10+gyw-(i*tstep), 30, RIGHT, FSIZE_VSMALL, CMCT);
+                               RenderString(vstr,gxs-scale2res(35),gys+OFFSET_MED+gyw-(i*tstep), scale2res(30), RIGHT, FSIZE_VSMALL, CMCT);
+                               RenderString(vstr,gxs+gxw+scale2res(2),gys+OFFSET_MED+gyw-(i*tstep), scale2res(30), RIGHT, FSIZE_VSMALL, CMCT);
                        }
                        RenderLine(gxs,gys+gyw-((i-1)*tstep)-3,gxs+gxw,gys+gyw-((i-1)*tstep)-3,((!(mint+i-1)))?CMCT:CMCIT);
 
@@ -1685,7 +1692,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                        if (HTTP_downloadFile(icon, ICON_FILE, 0, intype, ctmo, 2) == 0)
 #endif
                                        {
-                                               int picx=80,picy=80;
+                                               int picx=scale2res(80),picy=scale2res(80);
                                                pic_on_data(icon,sx+gxs+(i*gicw)+((gicw/2)-(picx/2)),sy+gys+gyw+((gywf/2)-(picy/2)), picx, picy, 5, (i)?((i==4)?1:0):2, 0, 0);
                                        }
 #ifdef WWEATHER
@@ -1695,7 +1702,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                        strcat(vstr,"_SIG");
 #endif
                                        strcpy(rstr,prs_translate(vstr,CONVERT_LIST));
-                                       RenderString(rstr, gxs+(i*gicw+17), gys+12+gyw+FSIZE_BIG, gicw, LEFT, FSIZE_BIG,CMCIT );//weekday
+                                       RenderString(rstr, gxs+(i*gicw+scale2res(17)), gys+scale2res(12)+gyw+FSIZE_BIG, gicw, LEFT, FSIZE_BIG,CMCIT );//weekday
                                }
                                multiple_pics=0;
                        }
@@ -1705,8 +1712,8 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                {
                        if(ix==0)
                        {
-                               dy=24;
-                               vy-=2;
+                               dy=scale2res(24);
+                               vy-=scale2res(2);
 
                                // show icon
                                prs_get_val(0, ACT_ICON, 0, vstr);
@@ -1729,7 +1736,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                }
 
                                sprintf(rstr,"%s",prs_translate("Aktuelles Wetter",CONVERT_LIST));
-                               RenderString(rstr, wsx, wsy+40, wxw, CENTER, FSIZE_BIG, CMHT);
+                               RenderString(rstr, wsx, wsy+4*OFFSET_MED, wxw, CENTER, FSIZE_BIG, CMHT);
 
                                sprintf(rstr,"%s",prs_translate("Standort:",CONVERT_LIST));
                                RenderString(rstr, col1, vy, col2-col1, LEFT, FSIZE_MED, GREEN);
@@ -1978,7 +1985,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                                pic_on_data(icon,col2+200, wsy+115, 80, 80, 5, 3, 0, 0);
 */
                                        if(!slim)
-                                               pic_on_data(icon,800, 270, 100, 100, 5, 3, 0, 0);
+                                               pic_on_data(icon,scale2res(800), scale2res(270), scale2res(100), scale2res(100), 5, 3, 0, 0);
                                        else
                                                pic_on_data(icon,540, 115, 80, 80, 5, 3, 0, 0);
                                }
@@ -2033,7 +2040,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
 #endif
                                }
                                sprintf(rstr,"%s %s",prs_translate("Vorschau für",CONVERT_LIST),vstr);
-                               RenderString(rstr, wsx, wsy+40, wxw, CENTER, FSIZE_BIG, CMHT);
+                               RenderString(rstr, wsx, wsy+4*OFFSET_MED, wxw, CENTER, FSIZE_BIG, CMHT);
 
                                sprintf(rstr,"%s",prs_translate("Standort:",CONVERT_LIST));
                                RenderString(rstr, col1, vy, col2-col1, LEFT, FSIZE_MED, GREEN);
@@ -2168,7 +2175,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                        prs_get_val2(ix-1, PRE_COND_M, 1, rstr);
                                else
                                        prs_get_val2(ix-1, PRE_COND, 1, rstr);
-                               vy=PaintWideString(dy, rstr, col2, vy, wxw-col2-50, LEFT, FSIZE_MED, CMCT);
+                               vy=PaintWideString(dy, rstr, col2, vy, wxw-col2-5*OFFSET_MED, LEFT, FSIZE_MED, CMCT);
                                vy+=dy;
 
                                sprintf(rstr,"%s",prs_translate("Regenrisiko:",CONVERT_LIST));
@@ -2239,7 +2246,7 @@ char tun[2]="C",sun[5]="km/h",dun[6]="km",pun[5]="hPa",iun[7]="mm", cun[20];
                                if(show_icons)
                                {
                                        //pic_on_data(icon, 540, 115, 100, 100, 5, 3, 0, 0);
-                                       pic_on_data(icon,slim?540:700, 115, 100, 100, 5, 3, 0, 0);
+                                       pic_on_data(icon,slim?540:scale2res(700), scale2res(115), scale2res(100), scale2res(100), 5, 3, 0, 0);
                                }
                                blit();
                        }
@@ -2333,7 +2340,7 @@ unsigned char *buffer=NULL;
                        }
                        else
                        {
-                               showBusy(startx+3,starty+3,10,0xff,00,00);
+                               showBusy(startx+OFFSET_SMALL-OFFSET_MIN,starty+OFFSET_SMALL-OFFSET_MIN,scale2res(10),0xff,00,00);
                                if(rcj==KEY_EXIT)
                                {
                                        rcj=KEY_OK;
@@ -2389,7 +2396,7 @@ unsigned char *buffer=NULL;
                        }
                        else
                        {
-                               showBusy(startx+3,starty+3,10,0xff,00,00);
+                               showBusy(startx+OFFSET_SMALL-OFFSET_MIN,starty+OFFSET_SMALL-OFFSET_MIN,scale2res(10),0xff,00,00);
                                if(rcn==KEY_EXIT)
                                {
                                        rcn=KEY_OK;
@@ -2474,7 +2481,7 @@ unsigned char *buffer=NULL;
                        }
                        else
                        {
-                               showBusy(startx+3,starty+3,10,0xff,00,00);
+                               showBusy(startx+OFFSET_SMALL-OFFSET_MIN,starty+OFFSET_SMALL-OFFSET_MIN,scale2res(10),0xff,00,00);
                                if(rcg==KEY_EXIT)
                                {
                                        rcg=KEY_OK;
@@ -2518,7 +2525,7 @@ unsigned char *buffer=NULL/*,*gbuf*/;
                        scale_pic(&buffer,x1,y1,xstart,ystart,xsize,ysize,&imx,&imy,&dxp,&dyp,&dxo,&dyo,center,0/*alpha*/);
                        if (rahmen >0)
                        {
-                               RenderBox(xstart+1-sx-rahmen, ystart-6-sy-rahmen,xstart+xsize+2-sx+rahmen,ystart+ysize-sy-6+rahmen, 0, CMCS);
+                               RenderBox(xstart+scale2res(1)-sx-rahmen, ystart-OFFSET_SMALL-sy-rahmen,xstart+xsize+OFFSET_MIN-sx+rahmen,ystart+ysize-sy-OFFSET_SMALL+rahmen, 0, CMCS);
                        }
 
                        if(single & 2)
@@ -2559,18 +2566,18 @@ int show_php(char *name, char *title, int plain, int highlite)
 {
 FILE *tfh;
 int x1,y1,cs,rcp,rv=-1,run=1,line=0,action=1,cut;
-int col1,ssy=0,dy=26,psx,psy;
-int pxw=ex-sx-((preset)?120:30);               //box width old 620
-int pyw=ey-sy-((preset)?60:20);                //box height old 510
+int col1,ssy=0,dy=scale2res(26),psx,psy;
+int pxw=ex-sx-((preset)?scale2res(120):scale2res(30));         //box width old 620
+int pyw=ey-sy-((preset)?scale2res(60):scale2res(20));          //box height old 510
 
        Center_Screen(pxw,pyw,&psx,&psy);
-       col1=psx+((preset)?60:40);
-       ssy=psy+78;
+       col1=psx+((preset)?scale2res(60):scale2res(40));
+       ssy=psy+scale2res(78);
        if((tfh=fopen(name,"r"))!=NULL)
        {
                fclose(tfh);
 
-               RenderString("X", psx+pxw/2, psy+pyw/2, 100, LEFT, FSIZE_SMALL, CMCT);
+               RenderString("X", psx+pxw/2, psy+pyw/2, scale2res(100), LEFT, FSIZE_SMALL, CMCT);
                if(fh_php_getsize(name, plain, &x1, &y1))
                {
                        printf("Tuxwetter <invalid PHP-Format>\n");
@@ -2589,10 +2596,10 @@ int pyw=ey-sy-((preset)?60:20);         //box height old 510
                        //frame layout
                        if(action)
                        {
-                               RenderBox(psx+6, psy+6, pxw, pyw, radius, CSP0);
+                               RenderBox(psx+OFFSET_SMALL, psy+OFFSET_SMALL, pxw, pyw, radius, CSP0);
                                RenderBox(psx, psy, pxw, pyw, radius, CMC);
-                               RenderBox(psx, psy, pxw, 44, radius, CMH);
-                               RenderString(title, psx, psy+40, pxw, CENTER, FSIZE_BIG, CMHT);
+                               RenderBox(psx, psy, pxw, scale2res(44), radius, CMH);
+                               RenderString(title, psx, psy+4*OFFSET_MED, pxw, CENTER, FSIZE_BIG, CMHT);
 
                                if(!(rv=fh_php_load(name, col1, ssy, dy, cs, line, highlite, plain, &cut)))
                                {
@@ -2785,7 +2792,7 @@ long flength = 0;
                                                                                                }
                                                                                                if(!dontsave)
                                                                                                {
-                                                                                                       if((*pt4==' ') && (flength>60))
+                                                                                                       if((*pt4==' ') && (flength > 60))
                                                                                                        {
                                                                                                                fprintf(fh2,"\n<br>");
                                                                                                                flength=0;
@@ -2967,8 +2974,30 @@ PLISTENTRY pl=&epl;
 
        }
 
-//     system("ping -c 2 google.com &");
+       //init framebuffer
+       fb = open(FB_DEVICE, O_RDWR);
+       if(fb == -1)
+       {
+               perror("tuxwetter <open framebuffer device>");
+               exit(1);
+       }
+       if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
+       {
+               perror("tuxwetter <FBIOGET_FSCREENINFO>\n");
+               return -1;
+       }
+       if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
+       {
+               perror("tuxwetter <FBIOGET_VSCREENINFO>\n");
+               return -1;
+       }
+       if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
+       {
+               perror("tuxwetter <mapping of Framebuffer>\n");
+               return -1;
+       }
 
+       // read config
        if((line_buffer=calloc(BUFSIZE+1, sizeof(char)))==NULL)
        {
                printf(NOMEM);
@@ -3028,10 +3057,10 @@ PLISTENTRY pl=&epl;
 
        read_neutrino_osd_conf(&ex,&sx,&ey, &sy);
        if((ex == -1) || (sx == -1) || (ey == -1) || (sy == -1)){
-               sx = 40;
-               ex = var_screeninfo.xres - 40;
-               sy = 40;
-               ey = var_screeninfo.yres - 40;
+               sx = scale2res(40);
+               ex = var_screeninfo.xres - scale2res(40);
+               sy = scale2res(40);
+               ey = var_screeninfo.yres - scale2res(40);
        }
        //printf("sx=%i, ex =%i, sy=%i, ey=%i \n", sx, ex, sy, ey);
 
@@ -3084,19 +3113,12 @@ PLISTENTRY pl=&epl;
                bgra[ix] = (tr[ix] << 24) | (rd[ix] << 16) | (gn[ix] << 8) | bl[ix];
 
        if(Read_Neutrino_Cfg("rounded_corners")>0) {
-               radius = 11;
-               radius_small = 7;
+               radius = scale2res(11);
+               radius_small = scale2res(5);
        }
        else
                radius = radius_small = 0;
 
-       fb = open(FB_DEVICE, O_RDWR);
-       if(fb == -1)
-       {
-               perror("tuxwetter <open framebuffer device>");
-               exit(1);
-       }
-
        InitRC();
 
        if((trstr=malloc(BUFSIZE))==NULL)
@@ -3105,24 +3127,6 @@ PLISTENTRY pl=&epl;
                return -1;
        }
 
-       //init framebuffer
-
-       if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
-       {
-               perror("tuxwetter <FBIOGET_FSCREENINFO>\n");
-               return -1;
-       }
-       if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
-       {
-               perror("tuxwetter <FBIOGET_VSCREENINFO>\n");
-               return -1;
-       }
-       if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
-       {
-               perror("tuxwetter <mapping of Framebuffer>\n");
-               return -1;
-       }
-
        //init fontlibrary
 
        if((error = FT_Init_FreeType(&library)))
@@ -3188,6 +3192,18 @@ PLISTENTRY pl=&epl;
        startx = sx;
        starty = sy;
 
+       /* scale to resolution */
+       FSIZE_BIG = scale2res(FSIZE_BIG);
+       FSIZE_MED = scale2res(FSIZE_MED);
+       FSIZE_SMALL = scale2res(FSIZE_SMALL);
+       FSIZE_VSMALL = scale2res(FSIZE_VSMALL);
+
+       TABULATOR = scale2res(TABULATOR);
+
+       OFFSET_MED = scale2res(OFFSET_MED);
+       OFFSET_SMALL = scale2res(OFFSET_SMALL);
+       OFFSET_MIN = scale2res(OFFSET_MIN);
+
        /* Set up signal handlers. */
        signal(SIGINT, quit_signal);
        signal(SIGTERM, quit_signal);
index 5151ab4aa6cc213010a62f6a7cca919d69bc88d3..1aab88e496529b343ae0d4ea1a8ae7421fdb1896 100644 (file)
@@ -147,8 +147,13 @@ extern int FSIZE_BIG;
 extern int FSIZE_MED;
 extern int FSIZE_SMALL;
 extern int FSIZE_VSMALL;
+
 extern int TABULATOR;
 
+extern int OFFSET_MED;
+extern int OFFSET_SMALL;
+extern int OFFSET_MIN;
+
 extern uint32_t bgra[];
 extern int swidth;
 extern uint32_t *lfb, *lbb;