mothra: fix wrong ascent calculation if text element is too large, fix image border layout
This commit is contained in:
parent
7b3c5d9257
commit
4590975312
1 changed files with 16 additions and 14 deletions
|
@ -9,7 +9,10 @@
|
||||||
#include <panel.h>
|
#include <panel.h>
|
||||||
#include "pldefs.h"
|
#include "pldefs.h"
|
||||||
#include "rtext.h"
|
#include "rtext.h"
|
||||||
#define LEAD 4 /* extra space between lines */
|
|
||||||
|
#define LEAD 4 /* extra space between lines */
|
||||||
|
#define BORD 2 /* extra border for images */
|
||||||
|
|
||||||
Rtext *pl_rtnew(Rtext **t, int space, int indent, Image *b, Panel *p, Font *f, char *s, int hot, void *user){
|
Rtext *pl_rtnew(Rtext **t, int space, int indent, Image *b, Panel *p, Font *f, char *s, int hot, void *user){
|
||||||
Rtext *new;
|
Rtext *new;
|
||||||
new=pl_emalloc(sizeof(Rtext));
|
new=pl_emalloc(sizeof(Rtext));
|
||||||
|
@ -80,9 +83,9 @@ int pl_rtfmt(Rtext *t, int wid){
|
||||||
tp=t;
|
tp=t;
|
||||||
for(;;){
|
for(;;){
|
||||||
if(tp->b){
|
if(tp->b){
|
||||||
a=tp->b->r.max.y-tp->b->r.min.y+2;
|
a=tp->b->r.max.y-tp->b->r.min.y+BORD;
|
||||||
d=0;
|
d=BORD;
|
||||||
w=tp->b->r.max.x-tp->b->r.min.x+4;
|
w=tp->b->r.max.x-tp->b->r.min.x+BORD*2;
|
||||||
}
|
}
|
||||||
else if(tp->p){
|
else if(tp->p){
|
||||||
/* what if plpack fails? */
|
/* what if plpack fails? */
|
||||||
|
@ -110,11 +113,11 @@ int pl_rtfmt(Rtext *t, int wid){
|
||||||
if(space) eline=tp;
|
if(space) eline=tp;
|
||||||
}
|
}
|
||||||
if(eline==t){ /* No progress! Force fit the first block! */
|
if(eline==t){ /* No progress! Force fit the first block! */
|
||||||
if(a>ascent) ascent=a;
|
if(tp==t){
|
||||||
if(d>descent) descent=d;
|
if(a>ascent) ascent=a;
|
||||||
if(tp==t)
|
if(d>descent) descent=d;
|
||||||
eline=tp->next;
|
eline=tp->next;
|
||||||
else
|
}else
|
||||||
eline=tp;
|
eline=tp;
|
||||||
}
|
}
|
||||||
topy=p.y;
|
topy=p.y;
|
||||||
|
@ -124,10 +127,9 @@ int pl_rtfmt(Rtext *t, int wid){
|
||||||
t->topy=topy;
|
t->topy=topy;
|
||||||
t->r.min.x=p.x;
|
t->r.min.x=p.x;
|
||||||
if(t->b){
|
if(t->b){
|
||||||
t->r.max.y=p.y;
|
t->r.max.y=p.y+BORD;
|
||||||
t->r.min.y=p.y-(t->b->r.max.y-t->b->r.min.y);
|
t->r.min.y=p.y-(t->b->r.max.y-t->b->r.min.y)-BORD;
|
||||||
p.x+=t->b->r.max.x-t->b->r.min.x+2;
|
p.x+=(t->b->r.max.x-t->b->r.min.x)+BORD*2;
|
||||||
t->r=rectaddpt(t->r, Pt(2, 2));
|
|
||||||
}
|
}
|
||||||
else if(t->p){
|
else if(t->p){
|
||||||
t->r.max.y=p.y;
|
t->r.max.y=p.y;
|
||||||
|
@ -168,8 +170,8 @@ void pl_rtdraw(Image *b, Rectangle r, Rtext *t, int yoffs){
|
||||||
if(dr.max.y>r.min.y
|
if(dr.max.y>r.min.y
|
||||||
&& dr.min.y<r.max.y){
|
&& dr.min.y<r.max.y){
|
||||||
if(t->b){
|
if(t->b){
|
||||||
draw(b, dr, t->b, 0, t->b->r.min);
|
draw(b, insetrect(dr, BORD), t->b, 0, t->b->r.min);
|
||||||
if(t->hot) border(b, insetrect(dr, -2), 1, display->black, ZP);
|
if(t->hot) border(b, dr, 1, display->black, ZP);
|
||||||
}
|
}
|
||||||
else if(t->p){
|
else if(t->p){
|
||||||
plmove(t->p, subpt(dr.min, t->p->r.min));
|
plmove(t->p, subpt(dr.min, t->p->r.min));
|
||||||
|
|
Loading…
Reference in a new issue