git: 9front

Download patch

ref: c5b462d3d98d36a362ec18ab98175023ac3fcb8c
parent: ae164be7142f0aff3563b213f20ef1f417611ee1
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Sat Apr 14 10:54:45 EDT 2012

mothra: plpack in any case, even if labels dont fit

--- a/sys/src/cmd/mothra/libpanel/pack.c
+++ b/sys/src/cmd/mothra/libpanel/pack.c
@@ -66,14 +66,8 @@
 }
 /*
  * Set the sizes and rectangles of p and its descendants, given their requested sizes.
- * Returns 1 if everything fit, 0 otherwise.
- * For now we punt in the case that the children don't all fit.
- * Possibly we should shrink all the children's sizereqs to fit,
- * by the same means used to do EXPAND, except clamping at some minimum size,
- * but that smacks of AI.
  */
-Panel *pl_toosmall;
-int pl_setrect(Panel *p, Point ul, Point avail){
+void pl_setrect(Panel *p, Point ul, Point avail){
 	Point space, newul, newspace, slack, share;
 	int l;
 	Panel *c;
@@ -80,10 +74,10 @@
 	p->size=subpt(p->sizereq, p->pad);
 	ul=addpt(ul, divpt(p->pad, 2));
 	avail=subpt(avail, p->pad);
-	if(p->size.x>avail.x || p->size.y>avail.y){
-		pl_toosmall=p;
-		return 0;	/* not enough space! */
-	}
+	if(p->size.x>avail.x)
+		p->size.x = avail.x;
+	if(p->size.y>avail.y)
+		p->size.y = avail.y;
 	if(p->flags&(FILLX|EXPAND)) p->size.x=avail.x;
 	if(p->flags&(FILLY|EXPAND)) p->size.y=avail.y;
 	switch(p->flags&PLACE){
@@ -127,34 +121,33 @@
 		case PACKN:
 			newul=Pt(ul.x, ul.y+c->sizereq.y);
 			newspace=Pt(space.x, space.y-c->sizereq.y);
-			if(!pl_setrect(c, ul, Pt(space.x, c->sizereq.y))) return 0;
+			pl_setrect(c, ul, Pt(space.x, c->sizereq.y));
 			break;
 		case PACKW:
 			newul=Pt(ul.x+c->sizereq.x, ul.y);
 			newspace=Pt(space.x-c->sizereq.x, space.y);
-			if(!pl_setrect(c, ul, Pt(c->sizereq.x, space.y))) return 0;
+			pl_setrect(c, ul, Pt(c->sizereq.x, space.y));
 			break;
 		case PACKS:
 			newul=ul;
 			newspace=Pt(space.x, space.y-c->sizereq.y);
-			if(!pl_setrect(c, Pt(ul.x, ul.y+space.y-c->sizereq.y),
-				Pt(space.x, c->sizereq.y))) return 0;
+			pl_setrect(c, Pt(ul.x, ul.y+space.y-c->sizereq.y),
+				Pt(space.x, c->sizereq.y));
 			break;
 		case PACKE:
 			newul=ul;
 			newspace=Pt(space.x-c->sizereq.x, space.y);
-			if(!pl_setrect(c, Pt(ul.x+space.x-c->sizereq.x, ul.y),
-				Pt(c->sizereq.x, space.y))) return 0;
+			pl_setrect(c, Pt(ul.x+space.x-c->sizereq.x, ul.y),
+				Pt(c->sizereq.x, space.y));
 			break;
 		}
 		ul=newul;
 		space=newspace;
 	}
-	return 1;
 }
-int plpack(Panel *p, Rectangle where){
+void plpack(Panel *p, Rectangle where){
 	pl_sizereq(p);
-	return pl_setrect(p, where.min, subpt(where.max, where.min));
+	pl_setrect(p, where.min, subpt(where.max, where.min));
 }
 /*
  * move an already-packed panel so that p->r=raddp(p->r, d)
--- a/sys/src/cmd/mothra/libpanel/panel.h
+++ b/sys/src/cmd/mothra/libpanel/panel.h
@@ -98,7 +98,7 @@
 #define	PRI_POPUP	1		/* popup menus */
 #define	PRI_SCROLLBAR	2		/* scroll bars */
 int plinit(int);			/* initialization */
-int plpack(Panel *, Rectangle);		/* figure out where to put the Panel & children */
+void plpack(Panel *, Rectangle);	/* figure out where to put the Panel & children */
 void plmove(Panel *, Point);		/* move an already-packed panel to a new location */
 void pldraw(Panel *, Image *);		/* display the panel on the bitmap */
 void plfree(Panel *);			/* give back space */
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -174,7 +174,7 @@
 			plscroll(list, 0, bar);
 		p=plgroup(root, PACKN|FILLX);
 			pllabel(p, PACKW, "Title:");
-			curttl=pllabel(p, PACKE|EXPAND, "Initializing");
+			curttl=pllabel(p, PACKE|EXPAND, "---");
 			plplacelabel(curttl, PLACEW);
 		p=plgroup(root, PACKN|FILLX);
 			pllabel(p, PACKW, "Url:");
@@ -445,14 +445,8 @@
 		exits("getwindow");
 	}
 	r=screen->r;
-	plinitlabel(curttl, PACKE|EXPAND, "---");
-	plinitlabel(cururl, PACKE|EXPAND, "---");
 	plpack(root, r);
 	plpack(alt, r);
-	if(current){
-		plinitlabel(curttl, PACKE|EXPAND, current->title);
-		plinitlabel(cururl, PACKE|EXPAND, current->url->fullname);
-	}
 	draw(screen, r, display->white, 0, ZP);
 	pldraw(root, screen);
 	unlockdisplay(display);
--