From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <9front-bounces@9front.inri.net> X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from 9front.inri.net (9front.inri.net [168.235.81.73]) by inbox.vuxu.org (Postfix) with ESMTP id DE9F425750 for ; Fri, 10 May 2024 02:03:44 +0200 (CEST) Received: from pb-smtp1.pobox.com ([64.147.108.70]) by 9front; Thu May 9 20:01:02 -0400 2024 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id C99B829480 for <9front@9front.org>; Thu, 9 May 2024 20:00:58 -0400 (EDT) (envelope-from unobe@cpan.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=pobox.com; h=message-id :from:date:subject:to:mime-version:content-type :content-transfer-encoding; s=sasl; bh=EUn3XsXw9oEe7eLIsJBnp0HnT YzeH041Ts3ruuod4rg=; b=o2xeIBF9c416/phv+Ben8khIGpr+gdYOVKeh6UiEl 5sUqC0Aup3iVMMx0P3agkYmTa/NXOXBranZ/NRz/mdcUoDUoCONAB+IvEk+O3U/P BG35wkS+WfI8rDLs/W89YxdN6ZgSYK3EKB7u3vw2GqBAJ+KMZHqWTUw4+4eJEOaT 04= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id C153C2947F for <9front@9front.org>; Thu, 9 May 2024 20:00:58 -0400 (EDT) (envelope-from unobe@cpan.org) Received: from strider.localdomain (unknown [47.37.156.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id E45C12947E for <9front@9front.org>; Thu, 9 May 2024 20:00:57 -0400 (EDT) (envelope-from unobe@cpan.org) Message-ID: From: Romano Date: Thu, 09 May 2024 21:04:32 +0000 To: 9front@9front.org MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Pobox-Relay-ID: 61169FC0-0E60-11EF-9719-78DCEB2EC81B-09620299!pb-smtp1.pobox.com List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: CMS-scale firewall Subject: [9front] [PATCH] rio: resize border and scrollbar based on font Reply-To: 9front@9front.org Precedence: bulk when using large fonts the scroll bar is aberrantly small, as is the border size. initialize the border widths and scroll widths based on the font size. set a minimum value based on existing hard-coded values. --- diff 025a2d172ebfe36bc0da32f5712dd250916c73f1 e51d4aa069548de51d0e88a6d621d278e9138cd0 --- a/sys/src/cmd/rio/dat.h +++ b/sys/src/cmd/rio/dat.h @@ -46,11 +46,11 @@ enum { - Selborder = 4, /* border of selected window */ - Unselborder = 1, /* border of unselected window */ - Scrollwid = 12, /* width of scroll bar */ - Scrollgap = 4, /* gap right of scroll bar */ - BIG = 3, /* factor by which window dimension can exceed screen */ + Minselborder = 4, /* minimum border of selected window */ + Minunselborder = 1, /* minimum border of unselected window */ + Minscrollwid = 12, /* minimum width of scroll bar */ + Minscrollgap = 4, /* minimum gap right of scroll bar */ + BIG = 3, /* factor by which window dimension can exceed screen */ TRUE = 1, FALSE = 0, }; @@ -341,3 +341,8 @@ int messagesize; /* negotiated in 9P version setup */ int shiftdown; int debug; +int Borderwid; /* border width of window */ +int Selborder; /* border of selected window */ +int Unselborder; /* border of unselected window */ +int Scrollwid; /* width of scroll bar */ +int Scrollgap; /* gap right of scroll bar */ --- a/sys/src/cmd/rio/data.c +++ b/sys/src/cmd/rio/data.c @@ -185,6 +185,16 @@ }; void +fontinit(void) +{ + Borderwid = ceil(stringwidth(font, "0") / 4) > Borderwidth ? ceil(stringwidth(font, "0") / 4) : Borderwidth; + Selborder = ceil(stringwidth(font, "0") / 2) > Minselborder ? ceil(stringwidth(font, "0") / 2) : Minselborder; + Unselborder = ceil(stringwidth(font, "0") / 8) > Minunselborder ? ceil(stringwidth(font, "0") / 8) : Minunselborder; + Scrollwid = ceil(stringwidth(font, "0") * 1.5) > Minscrollwid ? ceil(stringwidth(font, "0") * 1.5) : Minscrollwid; + Scrollgap = ceil(stringwidth(font, "0") / 2) > Minscrollgap ? ceil(stringwidth(font, "0") / 2) : Minscrollgap; +} + +void iconinit(void) { background = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF); --- a/sys/src/cmd/rio/fns.h +++ b/sys/src/cmd/rio/fns.h @@ -16,6 +16,7 @@ void error(char*); void killprocs(void); int shutdown(void*, char*); +void fontinit(void); void iconinit(void); void *erealloc(void*, uint); void *emalloc(uint); --- a/sys/src/cmd/rio/rio.c +++ b/sys/src/cmd/rio/rio.c @@ -182,6 +182,7 @@ fprint(2, "rio: can't open display: %r\n"); exits("display open"); } + fontinit(); iconinit(); exitchan = chancreate(sizeof(int), 0); @@ -951,10 +952,10 @@ } if(col != nil){ r = canonrect(r); - drawedge(&b[0], col, Rect(r.min.x, r.min.y, r.min.x+Borderwidth, r.max.y)); - drawedge(&b[1], col, Rect(r.min.x+Borderwidth, r.min.y, r.max.x-Borderwidth, r.min.y+Borderwidth)); - drawedge(&b[2], col, Rect(r.max.x-Borderwidth, r.min.y, r.max.x, r.max.y)); - drawedge(&b[3], col, Rect(r.min.x+Borderwidth, r.max.y-Borderwidth, r.max.x-Borderwidth, r.max.y)); + drawedge(&b[0], col, Rect(r.min.x, r.min.y, r.min.x+Borderwid, r.max.y)); + drawedge(&b[1], col, Rect(r.min.x+Borderwid, r.min.y, r.max.x-Borderwid, r.min.y+Borderwid)); + drawedge(&b[2], col, Rect(r.max.x-Borderwid, r.min.y, r.max.x, r.max.y)); + drawedge(&b[3], col, Rect(r.min.x+Borderwid, r.max.y-Borderwid, r.max.x-Borderwid, r.max.y)); } lastcol = col; } --- a/sys/src/cmd/rio/wctl.c +++ b/sys/src/cmd/rio/wctl.c @@ -100,13 +100,13 @@ * that includes the border on each side with an extra pixel * so that the text is still drawn */ - if(Dx(r) < 100 || Dy(r) < 2*(Borderwidth+1)+font->height) + if(Dx(r) < 100 || Dy(r) < 2*(Borderwid+Unselborder)+font->height) return 0; /* window must be on screen */ if(!rectXrect(screen->r, r)) return 0; /* must have some screen and border visible so we can move it out of the way */ - if(rectinrect(screen->r, insetrect(r, Borderwidth))) + if(rectinrect(screen->r, insetrect(r, Borderwid))) return 0; return 1; } @@ -148,8 +148,8 @@ static int i = 0; int minx, miny, dx, dy; - dx = min(600, Dx(screen->r) - 2*Borderwidth); - dy = min(400, Dy(screen->r) - 2*Borderwidth); + dx = min(600, Dx(screen->r) - 2*Borderwid); + dy = min(400, Dy(screen->r) - 2*Borderwid); minx = 32 + 16*i; miny = 32 + 16*i; i++; --- a/sys/src/cmd/rio/wind.c +++ b/sys/src/cmd/rio/wind.c @@ -353,7 +353,7 @@ w->i = i; w->mc.image = i; - r = insetrect(i->r, Selborder+1); + r = insetrect(i->r, Selborder+Unselborder); w->scrollr = r; w->scrollr.max.x = r.min.x+Scrollwid; w->lastsr = ZR; @@ -1249,7 +1249,7 @@ w = emalloc(sizeof(Window)); w->screenr = i->r; - r = insetrect(i->r, Selborder+1); + r = insetrect(i->r,Selborder+Unselborder); w->i = i; w->mc = *mc; w->ck = ck;