From d4d6ddc23ebeecfc41eaf3545a36de5870810a50 Mon Sep 17 00:00:00 2001 From: GetAway Date: Thu, 5 Oct 2017 22:27:49 +0200 Subject: [PATCH] - replace nearly all fixed position values with scaled values ... to get a smoother display in full-hd mode bump version to 4.10 --- php.c | 14 +--- text.c | 30 ++++--- text.h | 1 + tuxwetter.c | 226 ++++++++++++++++++++++++++++------------------------ tuxwetter.h | 5 ++ 5 files changed, 148 insertions(+), 128 deletions(-) diff --git a/php.c b/php.c index 975784e..e3fa3ef 100644 --- 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 abc3b90..129ceae 100644 --- 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 54c2c18..a1bab9c 100644 --- 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 diff --git a/tuxwetter.c b/tuxwetter.c index 1501f43..9b41bae 100644 --- a/tuxwetter.c +++ b/tuxwetter.c @@ -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; i0) { - 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 \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
"); 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 "); + exit(1); + } + if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) + { + perror("tuxwetter \n"); + return -1; + } + if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) + { + perror("tuxwetter \n"); + return -1; + } + if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0))) + { + perror("tuxwetter \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 "); - 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 \n"); - return -1; - } - if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) - { - perror("tuxwetter \n"); - return -1; - } - if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0))) - { - perror("tuxwetter \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); diff --git a/tuxwetter.h b/tuxwetter.h index 5151ab4..1aab88e 100644 --- a/tuxwetter.h +++ b/tuxwetter.h @@ -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; -- 2.39.5