From: GetAway Date: Sun, 1 Oct 2017 10:57:00 +0000 (+0200) Subject: - replace nearly all fixed position values with scaled values ... X-Git-Url: https://git.webhop.me/?a=commitdiff_plain;h=313f3ae368c9747da38ad3084cf20814c9c36494;p=shellexec.git - replace nearly all fixed position values with scaled values ... to get a smoother display in full-hd mode bump version 2.10 --- diff --git a/shellexec.c b/shellexec.c index 8da836b..a7d6e4b 100644 --- a/shellexec.c +++ b/shellexec.c @@ -12,7 +12,7 @@ #include "pngw.h" -#define SH_VERSION 2.03 +#define SH_VERSION 2.10 static char CFG_FILE[128]="/var/tuxbox/config/shellexec.conf"; @@ -85,8 +85,8 @@ char VFD[256]=""; char url[256]="time.fu-berlin.de"; char *line_buffer=NULL; char *trstr; -int paging=1, mtmo=120, radius=0, radius_small=0; -int ixw=600, iyw=680, xoffs=13, vfd=0; +int paging=1, mtmo=120, vfd=0, radius=0, radius_small=0; +int ixw, iyw, xoffs; char INST_FILE[]="/tmp/rc.locked"; int instance=0; int rclocked=0; @@ -170,6 +170,14 @@ char *strxchr(char *xstr, char srch) return NULL; } +int scale2res(int s) +{ + if (var_screeninfo.xres == 1920) + s += s/2; + + return s; +} + void TrimString(char *strg) { char *pt1=strg, *pt2=strg; @@ -543,8 +551,10 @@ int Check_Config(void) FSIZE_BIG=(FSIZE_MED*5)/4; FSIZE_SMALL=(FSIZE_MED*4)/5; TABULATOR=2*FSIZE_MED; - ixw=(ixw>(ex-sx))?(ex-sx):((ixw<400)?400:ixw); - iyw=(iyw>(ey-sy))?(ey-sy):((iyw<380)?380:iyw); + ixw=scale2res(ixw); + iyw=scale2res(iyw); + ixw=(ixw>(ex-sx))?(ex-sx):((ixw(ey-sy))?(ey-sy):((iywact_entry,tind=m->act_entry; - int sbw=(m->num_entrys>MAX_FUNCS)?15:0; // scrollbar width - int sbo=2; // inner scrollbar offset + int sbw=(m->num_entrys>MAX_FUNCS)?scale2res(15):0; // scrollbar width + int sbo=OFFSET_MIN; // inner scrollbar offset char tstr[BUFSIZE]={0}, *tptr; char dstr[BUFSIZE]={0}, *lcptr,*lcstr; - int dy, my, moffs, mh, toffs, soffs=4, oldx=startx, oldy=starty, sbar=0, nosel; + int dy, my, moffs, mh, toffs, soffs=OFFSET_SMALL/*4*/, oldx=startx, oldy=starty, sbar=0, nosel; PLISTENTRY pl; - moffs=iyw/(MAX_FUNCS+1)+5; + moffs=iyw/(MAX_FUNCS+1)+OFFSET_SMALL; mh=iyw-moffs; dy=mh/(MAX_FUNCS+1); toffs=dy/2; @@ -1336,7 +1346,7 @@ static void ShowInfo(MENU *m, int knew ) tind=index; //frame layout - RenderBox(6, 6, ixw+6, iyw+6, radius, COL_SHADOW_PLUS_0); + RenderBox(OFFSET_SMALL/*6*/, OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); RenderBox(0, 0, ixw, iyw, radius, CMC); // titlebar @@ -1364,7 +1374,7 @@ static void ShowInfo(MENU *m, int knew ) RenderBox(ixw-sbw + sbo, moffs + scrollbar_ofs + sbo, ixw - sbo, moffs + scrollbar_ofs + scrollbar_cor - sbo, radius, COL_MENUCONTENT_PLUS_3); } int iw,ih; - int offset, hoffs = (m->headermed[m->act_header]==1)?0:46; + int offset, hoffs = (m->headermed[m->act_header]==1)?0:50; int ioffs = xoffs+8; // + half standard icon if(m->icon[m->act_header]) { @@ -1437,11 +1447,11 @@ static void ShowInfo(MENU *m, int knew ) coffs=clh; } } - RenderString(dstr, 46, my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-65, LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT); + RenderString(dstr, 50, my+soffs-(dy-font_size)/2-coffs+2, ixw-sbw-scale2res(65), LEFT, font_type, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:(nosel)?CMCIT:CMCT); } if(pl->type==TYP_MENU) { - RenderString(">", 30, my+soffs-(dy-FSIZE_MED)/2+1, 65, LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT); + RenderString(">", 30, my+soffs-(dy-FSIZE_MED)/2+1, scale2res(65), LEFT, MED, (((loop%MAX_FUNCS) == (tind%MAX_FUNCS)) && (sbar) && (!nosel))?CMCST:CMCT); } if(pl->underline) { @@ -1478,7 +1488,7 @@ static void ShowInfo(MENU *m, int knew ) if(ccenter) { stlen=GetStringLen(xoffs, dstr, MED); - RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+15, my+soffs, FILL, CMC); + RenderBox(xoffs+(ixw-xoffs-sbw)/2-stlen/2, my+soffs-ldy, xoffs+(ixw-xoffs-sbw)/2+stlen/2+3*OFFSET_SMALL/*15*/, my+soffs, FILL, CMC); RenderString(dstr, xoffs, my+soffs-(dy-FSIZE_MED)/2, ixw-sbw, CENTER, MED, CMCIT); } } @@ -1497,7 +1507,7 @@ static void ShowInfo(MENU *m, int knew ) if(dloop<15) { sprintf(tstr,"%1d",(dloop-4)%10); - RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 15, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT)); + RenderString(tstr, xoffs, my+soffs-(dy-FSIZE_SMALL)/2+2, 3*OFFSET_SMALL, CENTER, SMALL, ((loop%MAX_FUNCS) == (tind%MAX_FUNCS))?CMCST:((pl->type==TYP_INACTIVE)?CMCIT:CMCT)); } break; } @@ -1587,6 +1597,31 @@ int main (int argc, char **argv) } } + //init framebuffer before 1st scale2res + fb = open(FB_DEVICE, O_RDWR); + if(fb == -1) + { + perror(__plugin__ " "); + exit(1); + } + if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) + { + perror(__plugin__ " \n"); + return -1; + } + if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) + { + perror(__plugin__ " \n"); + return -1; + } + if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_WRITE|PROT_READ, MAP_SHARED, fb, 0))) + { + perror(__plugin__ " \n"); + return -1; + } + + // read config + ixw=scale2res(600), iyw=scale2res(680), xoffs=scale2res(13); if((line_buffer=calloc(BUFSIZE+1, sizeof(char)))==NULL) { printf(NOMEM); @@ -1607,28 +1642,28 @@ int main (int argc, char **argv) else sprintf(trstr,"screen_StartX_%s_%d", spres[spr], resolution); if((sx=Read_Neutrino_Cfg(trstr))<0) - sx=100; + sx=scale2res(100); if (resolution == -1) sprintf(trstr,"screen_EndX_%s", spres[spr]); else sprintf(trstr,"screen_EndX_%s_%d", spres[spr], resolution); if((ex=Read_Neutrino_Cfg(trstr))<0) - ex=1180; + ex=scale2res(1180); if (resolution == -1) sprintf(trstr,"screen_StartY_%s", spres[spr]); else sprintf(trstr,"screen_StartY_%s_%d", spres[spr], resolution); if((sy=Read_Neutrino_Cfg(trstr))<0) - sy=100; + sy=scale2res(100); if (resolution == -1) sprintf(trstr,"screen_EndY_%s", spres[spr]); else sprintf(trstr,"screen_EndY_%s_%d", spres[spr], resolution); if((ey=Read_Neutrino_Cfg(trstr))<0) - ey=620; + ey=scale2res(620); for(index=CMCST; index<=CMH; index++) { @@ -1650,8 +1685,8 @@ int main (int argc, char **argv) } if(Read_Neutrino_Cfg("rounded_corners")>0) { - radius = 11; - radius_small = 7; + radius = scale2res(11); + radius_small = scale2res(5); } else radius = radius_small = 0; @@ -1688,33 +1723,9 @@ int main (int argc, char **argv) for (index = 0; index <= COL_SHADOW_PLUS_0; index++) bgra[index] = (tr[index] << 24) | (rd[index] << 16) | (gn[index] << 8) | bl[index]; - fb = open(FB_DEVICE, O_RDWR); - if(fb == -1) - { - perror(__plugin__ " "); - exit(1); - } - InitRC(); //InitVFD(); - //init framebuffer - if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1) - { - perror(__plugin__ " \n"); - return -1; - } - if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1) - { - perror(__plugin__ " \n"); - return -1; - } - if(!(lfb = (uint32_t*)mmap(0, fix_screeninfo.smem_len, PROT_WRITE|PROT_READ, MAP_SHARED, fb, 0))) - { - perror(__plugin__ " \n"); - return -1; - } - //init fontlibrary if((error = FT_Init_FreeType(&library))) { @@ -1788,9 +1799,22 @@ int main (int argc, char **argv) memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); //blit(); - startx = sx + (((ex-sx) - (fix_screeninfo.line_length-200))/2); - starty = sy + (((ey-sy) - (var_screeninfo.yres-150))/2); + startx = sx + (((ex-sx) - (fix_screeninfo.line_length-scale2res(200)))/2); + starty = sy + (((ey-sy) - (var_screeninfo.yres-scale2res(150)))/2); + + /* scale to resolution */ + FSIZE_BIG = scale2res(FSIZE_BIG); + FSIZE_MED = scale2res(FSIZE_MED); + FSIZE_SMALL = scale2res(FSIZE_SMALL); + + 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); signal(SIGQUIT, quit_signal); diff --git a/shellexec.h b/shellexec.h index 1223dea..adbe485 100644 --- a/shellexec.h +++ b/shellexec.h @@ -168,8 +168,13 @@ extern uint32_t *lfb, *lbb; extern int FSIZE_BIG; extern int FSIZE_MED; extern int FSIZE_SMALL; + extern int TABULATOR; +extern int OFFSET_MED; +extern int OFFSET_SMALL; +extern int OFFSET_MIN; + struct fb_fix_screeninfo fix_screeninfo; struct fb_var_screeninfo var_screeninfo; diff --git a/text.c b/text.c index 2d9661d..0c8bfa2 100644 --- a/text.c +++ b/text.c @@ -7,6 +7,10 @@ int FSIZE_MED=24; int FSIZE_SMALL=20; int TABULATOR=72; +int OFFSET_MED=10; +int OFFSET_SMALL=5; +int OFFSET_MIN=2; + //extern void blit(); static char *sc = "aouAOUzd", @@ -235,18 +239,18 @@ int RenderChar(FT_ULong currentchar, int _sx, int _sy, int _ex, int color) { if(color != -1) { - if (_sx + 10 < _ex) - RenderBox(_sx, _sy - 10, _sx + 10, _sy, GRID, color); + if (_sx + OFFSET_MED < _ex) + RenderBox(_sx, _sy - OFFSET_MED, _sx + OFFSET_MED, _sy, GRID, color); else return -1; } - return 10; + return OFFSET_MED; } if (currentchar == '\t') { /* simulate horizontal TAB */ - return 15; + return scale2res(15); } //load char @@ -343,7 +347,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: @@ -416,7 +420,7 @@ void RenderString(char *string, int _sx, int _sy, int maxwidth, int layout, int if(sscanf(rptr+1,"%4d",&i)==1) { rptr+=4; - _sx=i; + _sx=scale2res(i); } else { @@ -486,8 +490,8 @@ char *rmptr, *rmstr, *rmdptr; void ShowMessage(char *mtitle, char *message, int wait) { extern int radius, radius_small; - int ixw=420; - int iyw=wait?327:300; + int ixw=scale2res(420); + int iyw=wait?scale2res(327):scale2res(300); int lx=startx; //int ly=starty; char *tdptr; @@ -496,25 +500,25 @@ void ShowMessage(char *mtitle, char *message, int wait) //starty=sy; //layout - RenderBox(0+4, 178+4, ixw+4, iyw+4, radius, COL_SHADOW_PLUS_0); - RenderBox(0, 178, ixw, iyw, radius, CMC); - RenderBox(0, 178, ixw, 220, radius, CMH); + RenderBox(0+OFFSET_SMALL, scale2res(178)+OFFSET_SMALL, ixw+OFFSET_SMALL, iyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); + RenderBox(0, scale2res(178), ixw, iyw, radius, CMC); + RenderBox(0, scale2res(178), ixw, scale2res(220), radius, CMH); //message tdptr=strdup(mtitle); remove_tabs(tdptr); - RenderString(tdptr, 5, 215, ixw-10, CENTER, FSIZE_BIG, CMHT); + RenderString(tdptr, OFFSET_SMALL, scale2res(215), ixw-OFFSET_MED, CENTER, FSIZE_BIG, CMHT); free(tdptr); tdptr=strdup(message); remove_tabs(tdptr); - RenderString(tdptr, 5, 270, ixw-10, CENTER, FSIZE_MED, CMCT); + RenderString(tdptr, OFFSET_SMALL, scale2res(270), ixw-OFFSET_MED, CENTER, FSIZE_MED, CMCT); free(tdptr); if(wait) - { - RenderBox(ixw/2-35+4, 286+4, ixw/2+35+4, 310+4, radius_small, COL_SHADOW_PLUS_0); - RenderBox(ixw/2-35, 286, ixw/2+35, 310, radius_small, CMCS); - RenderString("OK", ixw/2-25, 312, 50, CENTER, FSIZE_MED, CMCT); + { int offs=2*OFFSET_MED+OFFSET_SMALL; // 35 + RenderBox(ixw/2-offs+OFFSET_SMALL, scale2res(286)+OFFSET_SMALL, ixw/2+offs+OFFSET_SMALL, scale2res(310)+OFFSET_SMALL, radius_small, COL_SHADOW_PLUS_0); + RenderBox(ixw/2-offs, scale2res(286), ixw/2+offs, scale2res(310), radius_small, CMCS); + RenderString("OK", ixw/2-scale2res(25), scale2res(312), scale2res(50), CENTER, FSIZE_MED, CMCT); } memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); diff --git a/text.h b/text.h index 83bafe3..0a70368 100644 --- a/text.h +++ b/text.h @@ -13,5 +13,6 @@ FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer requ void RenderString(char *string, int sx, int sy, int maxwidth, int layout, int size, int color); void ShowMessage(char *mtitle, char *message, int wait); void remove_tabs(char *src); +int scale2res(int s); #endif