From: GetAway Date: Sun, 1 Oct 2017 14:05:00 +0000 (+0200) Subject: - replace nearly all fixed position values with scaled values ... X-Git-Url: https://git.webhop.me/?a=commitdiff_plain;h=94c4fbe15008e0b6ce6ad4ac345b2a9b24ec8430;p=input.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/input.c b/input.c index 4e62c8f..c5456c0 100644 --- a/input.c +++ b/input.c @@ -12,7 +12,7 @@ #define NCF_FILE "/var/tuxbox/config/neutrino.conf" #define BUFSIZE 1024 -#define I_VERSION 2.03 +#define I_VERSION 2.10 char FONT[128]="/share/fonts/neutrino.ttf"; @@ -132,6 +132,14 @@ int rv=-1; return rv; } +int scale2res(int s) +{ + if (var_screeninfo.xres == 1920) + s += s/2; + + return s; +} + void TrimString(char *strg) { char *pt1=strg, *pt2=strg; @@ -232,6 +240,31 @@ char rstr[512]={0}, *title=NULL, *format=NULL, *defstr=NULL, *aptr=NULL, *rptr=N return 0; } + //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_READ | PROT_WRITE, MAP_SHARED, fb, 0))) + { + perror(__plugin__ " \n"); + return -1; + } + + // read arguments dloop=0; for(tv=1; !dloop && tv0) - radius=11; + radius=scale2res(11); else radius = 0; - fb = open(FB_DEVICE, O_RDWR); - if(fb == -1) - { - perror(__plugin__ " "); - exit(1); - } - InitRC(); if((trstr=malloc(BUFSIZE))==NULL) @@ -454,24 +480,6 @@ char rstr[512]={0}, *title=NULL, *format=NULL, *defstr=NULL, *aptr=NULL, *rptr=N return -1; } - //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_READ | PROT_WRITE, MAP_SHARED, fb, 0))) - { - perror(__plugin__ " \n"); - return -1; - } //init fontlibrary @@ -547,6 +555,18 @@ char rstr[512]={0}, *title=NULL, *format=NULL, *defstr=NULL, *aptr=NULL, *rptr=N startx = sx; starty = sy; + /* 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(SIGQUIT, quit_signal); signal(SIGTERM, quit_signal); diff --git a/input.h b/input.h index c7557b2..6b8c182 100644 --- a/input.h +++ b/input.h @@ -137,6 +137,16 @@ extern uint32_t *lfb, *lbb, *obb; extern uint32_t bgra[]; extern int stride; +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/inputd.c b/inputd.c index 5aea372..0828dce 100644 --- a/inputd.c +++ b/inputd.c @@ -10,14 +10,14 @@ #include "pngw.h" -#define xbrd 25 -#define ybrd 25 -#define exsz 23 -#define eysz 38 -#define bxsz 60 -#define bysz 60 -#define hsz 50 -#define tys 30 +#define xbrd scale2res(25) +#define ybrd scale2res(25) +#define exsz scale2res(23) +#define eysz scale2res(38) +#define bxsz scale2res(60) +#define bysz scale2res(60) +#define hsz scale2res(50) +#define tys scale2res(30) #define NUM '#' #define ANUM '@' #define HEX '^' @@ -301,7 +301,7 @@ const char kalp[12][6]={"+-*/","abc format=form; estr=strdup(form); cnt=strlen(form); - tlen=i=GetStringLen(title, BIG)+10; + tlen=i=GetStringLen(title, BIG)+OFFSET_MED; j=((cnt>cols)?cols:cnt)*exsz; if(j>i) { @@ -316,7 +316,7 @@ const char kalp[12][6]={"+-*/","abc } } wxw=i+2*xbrd; - wxw=(keys==1 && wxw < 265) ? 265 : wxw; + wxw=(keys==1 && wxw < scale2res(265)) ? scale2res(265) : wxw; i=(((cnt-1)/cols)+1)*eysz; if(keys) @@ -360,18 +360,19 @@ const char kalp[12][6]={"+-*/","abc estr[i]=0; // icon & title - RenderBox(wxs+6, wys-hsz+6, wxs+wxw+6, wys+wyw+6, radius, COL_SHADOW_PLUS_0); + RenderBox(wxs+OFFSET_SMALL, wys-hsz+OFFSET_SMALL, wxs+wxw+OFFSET_SMALL, wys+wyw+OFFSET_SMALL, radius, COL_SHADOW_PLUS_0); RenderBox(wxs, wys-hsz, wxs+wxw, wys+wyw, radius, CMC); RenderBox(wxs, wys-hsz, wxs+wxw, wys, radius, CMH); png_getsize(ICON_KEYS, &icon_w, &icon_h); if(icon_w > 40 || icon_h > 40) icon_w = icon_h = xsize = ysize = 40; - paintIcon(ICON_KEYS, wxs+8, wys-hsz/2-icon_h/2, xsize, ysize, &iw, &ih); + int offw = OFFSET_SMALL+OFFSET_MIN; + paintIcon(ICON_KEYS, wxs+offw, wys-hsz/2-icon_h/2, xsize, ysize, &iw, &ih); int tstart, twide; - if(wxs+8+iw >= wxs+wxw-8-iw-tlen ) { - tstart = wxs+8+iw; - twide = wxw-8-iw; + if(wxs+offw+iw >= wxs+wxw-offw-iw-tlen ) { + tstart = wxs+offw+iw; + twide = wxw-offw-iw; } else { tstart = wxs; @@ -384,7 +385,7 @@ const char kalp[12][6]={"+-*/","abc if(keys == 1) { png_getsize(ICON_NUMERIC_PAD, &icon_w, &icon_h); - paintIcon(ICON_NUMERIC_PAD, wxs+wxw/2-icon_w/2, bys+10, 0, 0, &iw, &ih); + paintIcon(ICON_NUMERIC_PAD, wxs+wxw/2-scale2res(icon_w)/2, bys+OFFSET_MED, scale2res(icon_w), scale2res(icon_h), &iw, &ih); } if(keys == 2) { @@ -403,9 +404,9 @@ const char kalp[12][6]={"+-*/","abc { png_getsize(ICON_BUTTON_RED, &icon_w, &icon_h); paintIcon(ICON_BUTTON_RED, bxs-icon_w/2, wys+wyw-ybrd-2-icon_h/2, 0, 0, &iw, &ih); - RenderString("Groß/Klein", bxs+icon_w/2+5,wys+wyw-ybrd+10, 3*bxsz, LEFT, SMALL, CMCIT); - paintIcon(ICON_BUTTON_YELLOW, bxs+125-icon_w/2, wys+wyw-ybrd-2-icon_h/2, 0, 0, &iw, &ih); - RenderString("löschen", bxs+125+icon_w/2+5,wys+wyw-ybrd+10, 65, LEFT, SMALL, CMCIT); + RenderString("Groß/Klein", bxs+icon_w/2+OFFSET_SMALL/*5*/,wys+wyw-ybrd+OFFSET_MED/*10*/, 2*bxsz, LEFT, SMALL, CMCIT); + paintIcon(ICON_BUTTON_YELLOW, bxs+scale2res(125)-icon_w/2, wys+wyw-ybrd-2-icon_h/2, 0, 0, &iw, &ih); + RenderString("löschen", bxs+scale2res(125)+icon_w/2+OFFSET_SMALL,wys+wyw-ybrd+OFFSET_MED, bxsz, LEFT, SMALL, CMCIT); } while(run) @@ -416,12 +417,12 @@ const char kalp[12][6]={"+-*/","abc yp=i/cols; if(frame && IsInput(format[i])) { - RenderBox(exs+xp*exsz, eys+5+yp*eysz, exs+(xp+1)*exsz, eys+(yp+1)*eysz, 0/*radius*/, CMS); + RenderBox(exs+xp*exsz, eys+OFFSET_SMALL+yp*eysz, exs+(xp+1)*exsz, eys+(yp+1)*eysz, 0/*radius*/, CMS); } - RenderBox(exs+xp*exsz+1, eys+5+yp*eysz+1, exs+(xp+1)*exsz-1, eys+(yp+1)*eysz-1, 0/*radius*/, (epos==i)?CMCS:CMC); + RenderBox(exs+xp*exsz+1, eys+OFFSET_SMALL+yp*eysz+1, exs+(xp+1)*exsz-1, eys+(yp+1)*eysz-1, 0/*radius*/, (epos==i)?CMCS:CMC); *trnd=(mask && format[i]==NUM && IsNum(estr[i]))?'*':estr[i]; - RenderString(trnd, exs+xp*exsz, eys+yp*eysz+tys+7, exsz, CENTER, MED, (epos==i)?CMCST:(IsInput(format[i]))?CMCT:CMCIT); + RenderString(trnd, exs+xp*exsz, eys+yp*eysz+tys+OFFSET_SMALL/*7*/, exsz, CENTER, MED, (epos==i)?CMCST:(IsInput(format[i]))?CMCT:CMCIT); } memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres*sizeof(uint32_t)); diff --git a/text.c b/text.c index 7bf479c..d41ec26 100644 --- a/text.c +++ b/text.c @@ -7,6 +7,10 @@ int FSIZE_MED=24; int FSIZE_SMALL=20; int TABULATOR=300; +int OFFSET_MED=10; +int OFFSET_SMALL=5; +int OFFSET_MIN=2; + /****************************************************************************** * MyFaceRequester ******************************************************************************/ diff --git a/text.h b/text.h index 0043013..c949aa3 100644 --- a/text.h +++ b/text.h @@ -3,13 +3,10 @@ #include "input.h" -extern int FSIZE_BIG; -extern int FSIZE_MED; -extern int FSIZE_SMALL; - FT_Error MyFaceRequester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface); int RenderString(const char *string, int _sx, int _sy, int maxwidth, int layout, int size, int color); int GetStringLen(char *string, size_t size); void CatchTabs(char *text); +int scale2res(int s); #endif