diff options
| author | bhgv <bhgv.empire@gmail.com> | 2019-05-05 18:44:35 +0300 |
|---|---|---|
| committer | bhgv <bhgv.empire@gmail.com> | 2019-05-05 18:44:35 +0300 |
| commit | c76314f0f38f4ed028610a6db4452879a556b35f (patch) | |
| tree | 63754fc80ae254aafc018da9bd21cd520df52129 /appl/awm | |
| parent | a1ca1b6a61a5c9913cb82a903ef0962496c9fba4 (diff) | |
auto-select capacitive or resistive touchscreens. bigger toolbar, menu, keyboard and captions
Diffstat (limited to 'appl/awm')
| -rw-r--r-- | appl/awm/atoolbar.b | 49 | ||||
| -rw-r--r-- | appl/awm/keyboard.b | 8 |
2 files changed, 42 insertions, 15 deletions
diff --git a/appl/awm/atoolbar.b b/appl/awm/atoolbar.b index 0a0cda8..654b1a2 100644 --- a/appl/awm/atoolbar.b +++ b/appl/awm/atoolbar.b @@ -38,6 +38,8 @@ tb_fnt : ref Font; tb_h := 0; +is_hrz := (0 == 0); + # execute this if no menu items have been created # by the init script. defaultscript := @@ -243,13 +245,22 @@ iconify(id, label: string) label = condenselabel(label); padf := ".toolbar.sp"+id; - tk->cmd(tbtop, "frame " + padf + " -width 2"); - cmd(tbtop, "pack " + padf + " -side left -fill y"); + if (is_hrz) { + tk->cmd(tbtop, "frame " + padf + " -height 2"); + cmd(tbtop, "pack " + padf + " -side top -fill x"); + } else { + tk->cmd(tbtop, "frame " + padf + " -width 2"); + cmd(tbtop, "pack " + padf + " -side left -fill y"); + } e := tk->cmd(tbtop, "button .toolbar." +id+" -command {send task "+id+"} -takefocus 0"); - cmd(tbtop, ".toolbar." +id+" configure -font " + tb_fnt.name + " -text '" + label); - if(e[0] != '!') - cmd(tbtop, "pack .toolbar."+id+" -side left -fill y"); + cmd(tbtop, ".toolbar." +id+" configure -font " + tb_fnt.name + " -height " + string tb_h + " -text '" + label); + if (e[0] != '!') { + if (is_hrz) + cmd(tbtop, "pack .toolbar."+id+" -side top -fill x"); + else + cmd(tbtop, "pack .toolbar."+id+" -side left -fill y"); + } cmd(tbtop, "update"); } @@ -271,10 +282,18 @@ layout(top: ref Tk->Toplevel) h := tb_h; #60; #32; if(r.dy() < 480) h = tk->rect(top, ".b", Tk->Border|Tk->Required).dy(); - cmd(top, ". configure -x " + string r.min.x + + if (is_hrz) + cmd(top, ". configure -x " + string r.min.x + + " -y " + string r.min.y + #(r.max.y - h) + + " -width " + string h + + " -height " + string r.dy() + ); + else + cmd(top, ". configure -x " + string r.min.x + " -y " + string r.min.y + #(r.max.y - h) + " -width " + string r.dx() + - " -height " + string h); + " -height " + string h + ); cmd(top, "update"); tkclient->onscreen(tbtop, "exact"); } @@ -286,7 +305,9 @@ toolbar(ctxt: ref Draw->Context, startmenu: int, screenr = tbtop.screenr; - tb_h = screenr.dy() / 20; + tb_h = int (1.5 * real screenr.dy() / 20.0); + + is_hrz = (screenr.dx() > screenr.dy()); fnt_csz := int ( tb_h / 2); fnt_nm := FONT_TTF + "_" + string fnt_csz; @@ -307,10 +328,16 @@ toolbar(ctxt: ref Draw->Context, startmenu: int, cmd(tbtop, "menubutton .toolbar.start -menu .m -borderwidth 0 -bitmap :" + string int tb_h + ":vitabig.png"); - cmd(tbtop, "pack .toolbar.start -side left"); + if (is_hrz) + cmd(tbtop, "pack .toolbar.start -side top"); + else + cmd(tbtop, "pack .toolbar.start -side left"); } - cmd(tbtop, "pack .toolbar -fill x"); + if (is_hrz) + cmd(tbtop, "pack .toolbar -fill x"); + else + cmd(tbtop, "pack .toolbar -fill y"); cmd(tbtop, "menu .m"); return tbtop; } @@ -412,7 +439,7 @@ builtin_menu(nil: ref Context, nil: Sh, argv: list of ref Listnode): string primary := (hd tl argv).word; argv = tl tl argv; - h_mnu_itm := string int (screenr.dy() / 30); + h_mnu_itm := string int (tb_h); #screenr.dy() / 30); tb_fnt_nm := tb_fnt.name; diff --git a/appl/awm/keyboard.b b/appl/awm/keyboard.b index 8e14042..aff2704 100644 --- a/appl/awm/keyboard.b +++ b/appl/awm/keyboard.b @@ -40,7 +40,7 @@ SPECFONT_TTF: con "/fonts/ttf/FantasqueSansMono-Regular.ttf"; # size in pixels #KEYSIZE: con 16; -KEYSIZE: con 13; +KEYSIZE: con 16; #13; KEYSPACE: con 2; KEYBORDER: con 1; KEYGAP: con KEYSPACE - (2 * KEYBORDER); @@ -145,10 +145,10 @@ init(ctxt: ref Draw->Context, args: list of string) # sys->print("scrn WxH = %dx%d bsz=%d - %d\n", r.dx(), r.dy(), r.dx()/15, KEYBORDER); wkbd := r.dx(); if(wkbd > r.dy()) - wkbd = int wkbd/2; + wkbd = int (2*wkbd/3); KEYGAP_ := int wkbd/100; - KEYSIZE_ := int wkbd/15 - KEYGAP_; + KEYSIZE_ := int (wkbd/15) - KEYGAP_; specials[ Backslash ].size = KEYSIZE_; specials[ Esc ].size = KEYSIZE_; @@ -172,7 +172,7 @@ init(ctxt: ref Draw->Context, args: list of string) if(keys[0][i] != nil) cmd(t, sys->sprint("button .b%d -takefocus 0 -font %s -width %d -height %d -bd %d -activebackground %s -text {%s} -command 'send keypress %d", i, fnt_nm #FONT - , KEYSIZE_, int (KEYSIZE_ * 3/2), + , KEYSIZE_, KEYSIZE_, #int (KEYSIZE_ * 3/2), KEYBORDER, background, keys[0][i], keyvals[0][i])); for(i = 0; i < len specials; i++) { |
