9front - general discussion about 9front
 help / color / mirror / Atom feed
From: phil9 <telephil9@gmail.com>
To: 9front@9front.org
Subject: [9front] [PATCH] mothra: make scrollbar style consistent with other applications
Date: Wed, 06 Apr 2022 16:46:58 +0000	[thread overview]
Message-ID: <9B11E8183922BC560845D6EBBB590E78@gmail.com> (raw)


	Scrollbar was drawn using a wide dark gutter over a white background
	whereas other applications (window, sam, ...) use a thinner scrollbar with an
	inverse colorscheme.
	This makes the scrollbar more consistent with other 9front applications.
---
diff 887366a22c1bc50c238668af61664112259a4365 c2a652e38079bbb0ab747af7c060e6d10e8b8042
--- a/sys/src/cmd/mothra/libpanel/draw.c	Wed Apr  6 17:29:41 2022
+++ b/sys/src/cmd/mothra/libpanel/draw.c	Wed Apr  6 18:46:58 2022
@@ -13,12 +13,13 @@
 #define	CKWID	1	/* width of frame around check mark */
 #define	CKINSET	1	/* space around check mark frame */
 #define	CKBORDER 2	/* space around X inside frame */
-static Image *pl_light, *pl_dark, *pl_tick, *pl_hilit;
+static Image *pl_light, *pl_dark, *pl_scrl, *pl_tick, *pl_hilit;
 Image *pl_blue, *pl_white, *pl_black;
 int pl_drawinit(void){
 	pl_white=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xFFFFFFFF);
 	pl_light=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0xFFFFFFFF);
 	pl_dark=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x777777FF);
+	pl_scrl=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x999999FF);
 	pl_black=allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x000000FF);
 	pl_hilit=allocimage(display, Rect(0,0,1,1), CHAN1(CAlpha,8), 1, 0x80);
 	pl_blue=allocimage(display, Rect(0,0,1,1), RGB24, 1, 0x0000FFFF);
@@ -28,7 +29,7 @@
 		draw(pl_tick, Rect(0, 0, TICKW, TICKW), pl_black, nil, ZP);
 		draw(pl_tick, Rect(0, font->height-TICKW, TICKW, font->height), pl_black, nil, ZP);
 	}
-	if(pl_white==0 || pl_light==0 || pl_black==0 || pl_dark==0 || pl_blue==0 || pl_tick==0) sysfatal("allocimage: %r");
+	if(pl_white==0 || pl_light==0 || pl_black==0 || pl_dark==0 || pl_scrl==0 || pl_blue==0 || pl_tick==0) sysfatal("allocimage: %r");
 	return 1;
 }
 Rectangle pl_boxoutline(Image *b, Rectangle r, int style, int fill){
@@ -205,6 +206,19 @@
 	draw(b, r1, pl_light, 0, ZP);
 	draw(b, r2, pl_dark, 0, ZP);
 	draw(b, r3, pl_light, 0, ZP);
+}
+void pl_scrollupd(Image *b, Rectangle r, int lo, int hi)
+{
+	Rectangle sr;
+	if(lo<0) lo=0;
+	if(hi<=lo) hi=lo+1;
+	sr=r;
+	sr.min.y+=lo;
+	sr.max.x-=1;
+	sr.max.y=sr.min.y+hi;
+	if(sr.max.y>r.max.y) sr.max.y=r.max.y;
+	draw(b, r, pl_scrl, 0, ZP);
+	draw(b, sr, pl_light, 0, ZP);
 }
 void pl_draw1(Panel *p, Image *b);
 void pl_drawall(Panel *p, Image *b){
--- a/sys/src/cmd/mothra/libpanel/pldefs.h	Wed Apr  6 17:29:41 2022
+++ b/sys/src/cmd/mothra/libpanel/pldefs.h	Wed Apr  6 18:46:58 2022
@@ -68,6 +68,7 @@
 Rectangle pl_radio(Image *, Rectangle, int);
 int pl_ckwid(void);
 void pl_sliderupd(Image *, Rectangle, int, int, int);
+void pl_scrollupd(Image *, Rectangle, int, int);
 void pl_invis(Panel *, int);
 Point pl_iconsize(int, Icon *);
 void pl_highlight(Image *, Rectangle);
--- a/sys/src/cmd/mothra/libpanel/scrollbar.c	Wed Apr  6 17:29:41 2022
+++ b/sys/src/cmd/mothra/libpanel/scrollbar.c	Wed Apr  6 18:46:58 2022
@@ -12,12 +12,12 @@
 	Rectangle interior;
 	Point minsize;
 };
-#define	SBWID	15	/* should come from draw.c? */
+#define	SBWID	8	/* should come from draw.c? */
 void pl_drawscrollbar(Panel *p){
 	Scrollbar *sp;
 	sp=p->data;
 	sp->interior=pl_outline(p->b, p->r, SUP); /* SUP was p->state */
-	pl_sliderupd(p->b, sp->interior, sp->dir, sp->lo, sp->hi);
+	pl_scrollupd(p->b, sp->interior, sp->lo, sp->hi);
 }
 int pl_hitscrollbar(Panel *g, Mouse *m){
 	int oldstate, pos, len, dy;
@@ -49,8 +49,7 @@
 		switch(m->buttons){
 		case 1:
 			dy=pos*(sp->hi-sp->lo)/len;
-			pl_sliderupd(g->b, sp->interior, sp->dir, sp->lo-dy,
-				sp->hi-dy);
+			pl_scrollupd(g->b, sp->interior, sp->lo-dy, sp->hi-dy);
 			break;
 		case 2:
 			if(g->scrollee && g->scrollee->scroll)
@@ -59,8 +58,7 @@
 			break;
 		case 4:
 			dy=pos*(sp->hi-sp->lo)/len;
-			pl_sliderupd(g->b, sp->interior, sp->dir, sp->lo+dy,
-				sp->hi+dy);
+			pl_scrollupd(g->b, sp->interior, sp->lo+dy, sp->hi+dy);
 			break;
 		}
 	}
@@ -94,7 +92,6 @@
 	sp=p->data;
 	ul=p->r.min;
 	size=subpt(p->r.max, p->r.min);
-	pl_interior(p->state, &ul, &size);
 	mylen=sp->dir==HORIZ?size.x:size.y;
 	if(len==0) len=1;
 	sp->lo=lo*mylen/len;

                 reply	other threads:[~2022-04-06 17:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9B11E8183922BC560845D6EBBB590E78@gmail.com \
    --to=telephil9@gmail.com \
    --cc=9front@9front.org \
    --subject='Re: [9front] [PATCH] mothra: make scrollbar style consistent with other applications' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).