9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] rio: resize border and scrollbar based on font
@ 2024-05-09 21:04 Romano
  2024-05-10  0:14 ` Jacob Moody
  0 siblings, 1 reply; 36+ messages in thread
From: Romano @ 2024-05-09 21:04 UTC (permalink / raw)
  To: 9front


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;

^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: [9front] [PATCH] rio: resize border and scrollbar based on font
@ 2024-05-10  6:13 Romano
  2024-05-10 13:27 ` Kristo
  2024-05-10 14:17 ` Jacob Moody
  0 siblings, 2 replies; 36+ messages in thread
From: Romano @ 2024-05-10  6:13 UTC (permalink / raw)
  To: 9front

Thanks for the feedback, moody.

While it may be a band-aid, it does improve things from where I sit.
When I drawterm from a mac w/2560x1664 resolution, it's unbearable
with the default font. So I'm currently using /n/ttf/unifont.ttf.32/font
which makes everything pretty usable. The one thing that bothered me
was the scrollbar, and then I noticed the border width was super thin
too so tweaked that.

If this just modified the scroll bar to account for the font size,
would that be more palatable to you?

I also can't imagine trying to go through all programs to see which
rely on a specific rio border-width. It would be nice to address that
along with magnification. But I think this is a start, and makes things
more bearable at least for me.

Anyway, what do you think about just modifying the scroll bars? And
do you have thoughts on how to do scaling generally?

- Romano

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2024-05-13  5:40 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-09 21:04 [9front] [PATCH] rio: resize border and scrollbar based on font Romano
2024-05-10  0:14 ` Jacob Moody
2024-05-10  0:34   ` sl
2024-05-10  6:20   ` Kurt H Maier
2024-05-10 14:10     ` Jacob Moody
2024-05-10 14:16       ` Stanley Lieber
2024-05-10 14:20         ` Jacob Moody
2024-05-10 14:23           ` Stanley Lieber
2024-05-10 14:21         ` ori
2024-05-10 14:33           ` Stanley Lieber
2024-05-10 14:37             ` Stanley Lieber
2024-05-10 14:58       ` Kurt H Maier
2024-05-10 15:28         ` Stuart Morrow
2024-05-10 16:11           ` Stanley Lieber
2024-05-10 16:43             ` Stuart Morrow
2024-05-10 16:50               ` Stuart Morrow
2024-05-11 16:36               ` hiro
2024-05-11 16:30             ` hiro
2024-05-11 16:27       ` hiro
2024-05-11 16:36         ` Jacob Moody
2024-05-10  6:13 Romano
2024-05-10 13:27 ` Kristo
2024-05-10 14:01   ` Stanley Lieber
2024-05-10 14:17 ` Jacob Moody
2024-05-10 18:43   ` Romano
2024-05-10 19:15     ` Jacob Moody
2024-05-10 19:40       ` ori
2024-05-11 16:45         ` hiro
2024-05-11  4:31       ` Romano
2024-05-11 15:00         ` Jacob Moody
2024-05-11 16:54           ` hiro
2024-05-13  5:18           ` Romano
2024-05-11 16:42       ` hiro
2024-05-10 21:00     ` sl
2024-05-11  4:34       ` Romano
2024-05-13  5:38         ` Romano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).