sam: make scroll wheel work outside scrollbar
This commit is contained in:
parent
ea0f580909
commit
87325403b0
2 changed files with 13 additions and 11 deletions
|
@ -100,7 +100,7 @@ threadmain(int argc, char *argv[])
|
|||
if(nwhich!=which)
|
||||
current(nwhich);
|
||||
else if(scr)
|
||||
scroll(which, 1);
|
||||
scroll(which, (mousep->buttons&8) ? 4 : 1);
|
||||
else{
|
||||
t=(Text *)which->user1;
|
||||
if(flselect(which)){
|
||||
|
@ -119,7 +119,7 @@ threadmain(int argc, char *argv[])
|
|||
menu2hit();
|
||||
}else if(mousep->buttons&(4|16)){
|
||||
if(scr)
|
||||
scroll(which, 3);
|
||||
scroll(which, (mousep->buttons&16) ? 5 : 3);
|
||||
else
|
||||
menu3hit();
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ scroll(Flayer *l, int but)
|
|||
in = abs(x-mousep->xy.x)<=FLSCROLLWID/2;
|
||||
if(oin && !in)
|
||||
scrunmark(l, r);
|
||||
if(in){
|
||||
if(but > 3 || in){
|
||||
scrmark(l, r);
|
||||
oy = y;
|
||||
my = mousep->xy.y;
|
||||
|
@ -131,9 +131,9 @@ scroll(Flayer *l, int but)
|
|||
my = s.min.y;
|
||||
if(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));
|
||||
if(but == 1){
|
||||
if(but == 1 || but == 4){
|
||||
p0 = l->origin-frcharofpt(&l->f, Pt(s.max.x, my));
|
||||
rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
|
||||
y = rt.min.y;
|
||||
|
@ -141,7 +141,7 @@ scroll(Flayer *l, int but)
|
|||
y = my;
|
||||
if(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));
|
||||
rt = scrpos(l->scroll, p0, p0+l->f.nchars, tot);
|
||||
y = rt.min.y;
|
||||
|
@ -152,19 +152,21 @@ scroll(Flayer *l, int but)
|
|||
scrmark(l, r);
|
||||
}
|
||||
}
|
||||
}while(button(but));
|
||||
if(in){
|
||||
}while(but <= 3 && button(but));
|
||||
if(but > 3 || in){
|
||||
h = s.max.y-s.min.y;
|
||||
scrunmark(l, r);
|
||||
p0 = 0;
|
||||
if(but == 1)
|
||||
if(but == 1 || but == 4){
|
||||
but = 1;
|
||||
p0 = (long)(my-s.min.y)/l->f.font->height+1;
|
||||
else if(but == 2){
|
||||
}else if(but == 2){
|
||||
if(tot > 1024L*1024L)
|
||||
p0 = ((tot>>10)*(y-s.min.y)/h)<<10;
|
||||
else
|
||||
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));
|
||||
if(p0 > tot)
|
||||
p0 = tot;
|
||||
|
|
Loading…
Reference in a new issue