ref: 8ed428d2e5a3d87b0ee8d1d98d8718e6bade0801
parent: a6ca06673411ccadb43b08b5d400f72324960bca
author: telephil9 <[email protected]>
date: Wed Apr 29 02:33:02 EDT 2020
Make toolbar buttons borderless. Modified libpanel to allow for borderless buttons. Hidden in this commit is also a fix to text rendering!
--- a/gopher.c
+++ b/gopher.c
@@ -151,12 +151,14 @@
n = 0;
for(;;){
c = Bgetc(bp);
- if(c<0 || c=='.')
+ if(c<0)
break;
else if(c=='\r' || c=='\n'){
if(c=='\r' && Bgetc(bp)!='\n')
Bungetc(bp);
buf[n] = 0;
+ if(n==1 && buf[0]=='.')
+ break;
plrtstr(&m->text, 1000000, 8, 0, font, strdup(buf), 0, 0);
n = 0;
}else if(c=='\t'){
@@ -548,8 +550,8 @@
p = plgroup(root, PACKN|FILLX);
statusp = pllabel(p, PACKN|FILLX, "gopher!");
plplacelabel(statusp, PLACEW);
- plbutton(p, PACKW|BITMAP, backi, backhit);
- plbutton(p, PACKW|BITMAP, fwdi, nexthit);
+ plbutton(p, PACKW|BITMAP|NOBORDER, backi, backhit);
+ plbutton(p, PACKW|BITMAP|NOBORDER, fwdi, nexthit);
pllabel(p, PACKW, "Go:");
entryp = plentry(p, PACKN|FILLX, 0, "", entryhit);
p = plgroup(root, PACKN|FILLX);
--- a/libpanel/button.c
+++ b/libpanel/button.c
@@ -25,7 +25,7 @@
Rectangle r;
Button *bp;
bp=p->data;
- r=pl_box(p->b, p->r, p->state);
+ r=pl_boxf(p->b, p->r, p->flags, p->state);
switch(bp->btype){
case CHECK:
r=pl_check(p->b, r, bp->check);
--- a/libpanel/draw.c
+++ b/libpanel/draw.c
@@ -114,6 +114,40 @@
Rectangle pl_box(Image *b, Rectangle r, int style){
return pl_boxoutline(b, r, style, 1);
}
+Rectangle pl_boxoutlinef(Image *b, Rectangle r, int flags, int style, int fill){
+ switch(style){
+ case UP:
+ draw(b, r, pl_light, 0, ZP);
+ if(!(flags&NOBORDER))
+ border(b, r, 1, pl_black, ZP);
+ break;
+ case DOWN:
+ case DOWN1:
+ case DOWN2:
+ case DOWN3:
+ if(!(flags&NOBORDER))
+ pl_relief(b, pl_black, pl_white, r, BWID);
+ r=insetrect(r, BWID);
+ if(fill) draw(b, r, pl_dark, 0, ZP);
+ else if(!(flags&NOBORDER)) border(b, r, SPACE, pl_black, ZP);
+ break;
+ case PASSIVE:
+ if(fill) draw(b, r, pl_light, 0, ZP);
+ r=insetrect(r, PWID);
+ if(!fill) border(b, r, SPACE, pl_white, ZP);
+ break;
+ case FRAME:
+ border(b, r, 1, pl_black, ZP);
+ break;
+ }
+ return insetrect(r, SPACE);
+}
+Rectangle pl_outlinef(Image *b, Rectangle r, int flags, int style){
+ return pl_boxoutlinef(b, r, flags, style, 0);
+}
+Rectangle pl_boxf(Image *b, Rectangle r, int flags, int style){
+ return pl_boxoutlinef(b, r, flags, style, 1);
+}
Point pl_boxsize(Point interior, int state){
switch(state){
case UP:
--- a/libpanel/panel.h
+++ b/libpanel/panel.h
@@ -87,6 +87,7 @@
#define MAXX 0x1000 /* make x size as big as biggest sibling's */
#define MAXY 0x2000 /* make y size as big as biggest sibling's */
#define BITMAP 0x4000 /* text argument is a bitmap, not a string */
+#define NOBORDER 0x8000
/* pldefs.h flags 0x08000-0x40000 */
#define IGNORE 0x080000 /* ignore this panel totally */
#define USERFL 0x100000 /* start of user flag */
--- a/libpanel/pldefs.h
+++ b/libpanel/pldefs.h
@@ -53,6 +53,7 @@
*/
int pl_drawinit(int);
Rectangle pl_box(Image *, Rectangle, int);
+Rectangle pl_boxf(Image *b, Rectangle r, int flags, int style);
Rectangle pl_outline(Image *, Rectangle, int);
Point pl_boxsize(Point, int);
void pl_interior(int, Point *, Point *);