From 4b239909d5878a87018734d791437a4b46f36328 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Sep 09 2023 05:09:50 +0000 Subject: fix layouting --- diff --git a/app.c b/app.c index d11c021..7459a47 100644 --- a/app.c +++ b/app.c @@ -31,10 +31,10 @@ int appInit(App *app) { LOGDBG("app: init: create window"); app->x = 0; - app->w = app->sw; - app->h = app->sh/4; + app->w = app->sw * WIDTH_SCALE; + app->h = app->sh * HEIGHT_SCALE; app->y = app->sh - app->h; - + XSetWindowAttributes attr = {}; #ifdef NOBORDER attr.override_redirect = 1; @@ -71,9 +71,15 @@ int appInit(App *app) { if (!wsh) { LOGWRN("app: init: XAllocSizeHints error"); } else { + #ifdef LOCK_SIZE + wsh->flags = PMinSize | PMaxSize; + wsh->min_width = wsh->max_width = app->w; + wsh->min_height = wsh->max_height = app->h; + #else wsh->flags = PMinSize; wsh->min_width = MIN_WIDTH; wsh->min_height = MIN_HEIGHT; + #endif XSetSizeHints(app->dpy, app->win, wsh, XA_WM_NORMAL_HINTS); XFree(wsh); } diff --git a/config.h b/config.h index cd17771..6eab52a 100644 --- a/config.h +++ b/config.h @@ -2,13 +2,18 @@ #define CONFIG_H -#define NOBORDER +//#define NOBORDER +#define LOCK_SIZE + +#define WIDTH_SCALE 1/1 // (nominator)/(denomitator) +#define HEIGHT_SCALE 1/3 + #define TITLE "coolkbd" #define MIN_WIDTH 200 #define MIN_HEIGHT 100 #define LONGPRESS_MS 1500 -#define FONTS { "Canada Sans:bold", "Canada Sans", "Canada", "DejaVu Sans:bold", "DejaVu Sans", "DejaVu" } +#define FONTS { "DejaVu Sans:bold", "DejaVu Sans", "DejaVu" } #define FONT_SIZES { 2, 3, 4, 6, 8, 10, 12, 16, 18, 24, 32, 40, 48 } #define FONT_MAX_SIZES 16 diff --git a/keyboard.c b/keyboard.c index 3900174..181acf6 100644 --- a/keyboard.c +++ b/keyboard.c @@ -57,7 +57,7 @@ void keyDraw(Key *k, int cx, int cy, int cw, int ch) { int h = k->h - 2*KEY_BORDER; graphDrawButton(&k->l->kbd->app->graph, k->x + KEY_BORDER, k->y + KEY_BORDER, w, h, active); - TextLayout *tl = &k->tl; + TextLayout *tl = &k->tl; TextLayout *tl2 = &k->tl2; if (inputChooseKeysym(app->input.modifiers, k->keySym, k->keySym2, k->isLetter, k->isKeypad)) tl = tl2, tl2 = &k->tl; // swap labels @@ -278,8 +278,8 @@ void layoutResize(Layout *l) { Key *k = &l->keys[i]; k->x = (int)(k->ox*kx + 0.5f); k->y = (int)(k->oy*ky + 0.5f); - k->w = (int)(k->ow*kx + 0.5f); - k->h = (int)(k->oh*ky + 0.5f); + k->w = (int)((k->ox + k->ow)*kx + 0.5f) - k->x; + k->h = (int)((k->oy + k->oh)*ky + 0.5f) - k->y; } } diff --git a/layout.defs.h b/layout.defs.h index 355b6d7..46c409f 100644 --- a/layout.defs.h +++ b/layout.defs.h @@ -5,14 +5,14 @@ #include "app.h" -#define X0 5 // left top corner -#define Y0 5 +#define X0 1 // left top corner +#define Y0 1 #define S 0 // spacing -#define S2 10 +#define S2 5 #define W 50 // width -#define W2 70 // more width +#define W2 50 // more width #define W3 80 // more #define W4 (W2+W+S) // and more #define W5 (12*W+11*S-4*W2-4*S) // space bar width @@ -31,8 +31,12 @@ #define HEADER(fw) \ { X0, Y0, fw-S-HH, HH, 0, 0, "::: coolkbd :::", "", KF_MOVE }, \ { N, 0, HH, 0, 0, 0, "[X]", "", KF_CLOSE }, - #define FOOTER(fw) \ - { X0, N2, fw, HH, 0, 0, "::: resize handle :::", "", KF_SIZE }, + #ifdef LOCK_SIZE + #define FOOTER(fw) + #else + #define FOOTER(fw) \ + { X0, N2, fw, HH, 0, 0, "::: resize handle :::", "", KF_SIZE }, + #endif #define Y1 (Y0+HH+S2) #else #define Y1 Y0 @@ -46,6 +50,5 @@ #define Y5 (Y1+4*(H+S)) // row 5 #define Y6 (Y1+5*(H+S)) // row 6 - - + #endif diff --git a/layout.en.full.inc.c b/layout.en.full.inc.c index 6c6adc5..d62cebb 100644 --- a/layout.en.full.inc.c +++ b/layout.en.full.inc.c @@ -5,9 +5,9 @@ #include "layout.defs.h" -#define LEF_COL2 (X0+FW+S+W/2) -#define LEF_COL3 (LEF_COL2+3*S+3*W+W/2) -#define LEF_FW (LEF_COL3-X0+3*S+4*W) +#define LEF_COL2 (X0+FW+S2) +#define LEF_COL3 (LEF_COL2+3*W+2*S+S2) +#define LEF_FW (LEF_COL3-X0+4*W+3*S) #define LEF_N (-1-(FW-14*W-11*S))