sam: make scroll wheel work outside scrollbar

This commit is contained in:
cinap_lenrek 2013-01-27 12:57:51 +01:00
parent ea0f580909
commit 87325403b0
2 changed files with 13 additions and 11 deletions

View file

@ -100,7 +100,7 @@ threadmain(int argc, char *argv[])
if(nwhich!=which) if(nwhich!=which)
current(nwhich); current(nwhich);
else if(scr) else if(scr)
scroll(which, 1); scroll(which, (mousep->buttons&8) ? 4 : 1);
else{ else{
t=(Text *)which->user1; t=(Text *)which->user1;
if(flselect(which)){ if(flselect(which)){
@ -119,7 +119,7 @@ threadmain(int argc, char *argv[])
menu2hit(); menu2hit();
}else if(mousep->buttons&(4|16)){ }else if(mousep->buttons&(4|16)){
if(scr) if(scr)
scroll(which, 3); scroll(which, (mousep->buttons&16) ? 5 : 3);
else else
menu3hit(); menu3hit();
} }

View file

@ -123,7 +123,7 @@ scroll(Flayer *l, int but)
in = abs(x-mousep->xy.x)<=FLSCROLLWID/2; in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
if(oin && !in) if(oin && !in)
scrunmark(l, r); scrunmark(l, r);
if(in){ if(but > 3 || in){
scrmark(l, r); scrmark(l, r);
oy = y; oy = y;
my = mousep->xy.y; my = mousep->xy.y;
@ -131,9 +131,9 @@ scroll(Flayer *l, int but)
my = s.min.y; my = s.min.y;
if(my >= s.max.y) if(my >= s.max.y)
my = s.max.y; my = s.max.y;
if(!eqpt(mousep->xy, Pt(x, my))) if(in && !eqpt(mousep->xy, Pt(x, my)))
moveto(mousectl, Pt(x, my)); moveto(mousectl, Pt(x, my));
if(but == 1){ if(but == 1 || but == 4){
p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my)); p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my));
rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
y = rt.min.y; y = rt.min.y;
@ -141,7 +141,7 @@ scroll(Flayer *l, int but)
y = my; y = my;
if(y > s.max.y-2) if(y > s.max.y-2)
y = s.max.y-2; y = s.max.y-2;
}else if(but == 3){ }else if(but == 3 || but == 5){
p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot); rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
y = rt.min.y; y = rt.min.y;
@ -152,19 +152,21 @@ scroll(Flayer *l, int but)
scrmark(l, r); scrmark(l, r);
} }
} }
}while(button(but)); }while(but <= 3 && button(but));
if(in){ if(but > 3 || in){
h = s.max.y-s.min.y; h = s.max.y-s.min.y;
scrunmark(l, r); scrunmark(l, r);
p0 = 0; p0 = 0;
if(but == 1) if(but == 1 || but == 4){
but = 1;
p0 = (long)(my-s.min.y)/l->f.font->height+1; p0 = (long)(my-s.min.y)/l->f.font->height+1;
else if(but == 2){ }else if(but == 2){
if(tot > 1024L*1024L) if(tot > 1024L*1024L)
p0 = ((tot>>10)*(y-s.min.y)/h)<<10; p0 = ((tot>>10)*(y-s.min.y)/h)<<10;
else else
p0 = tot*(y-s.min.y)/h; p0 = tot*(y-s.min.y)/h;
}else if(but == 3){ }else if(but == 3 || but == 5){
but = 3;
p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my)); p0 = l->origin+frcharofpt(&l->f, Pt(s.max.x, my));
if(p0 > tot) if(p0 > tot)
p0 = tot; p0 = tot;