John,

On Mon, 2002-10-21 at 02:09, John Levon wrote:
> On Sun, Oct 20, 2002 at 09:58:21PM +0930, Darren Freeman wrote:
> 
> > Basically my thoughts are that the code is really poorly documented and
> 
> Useful comments are most definitely wanted. We know about the poor
> documentation and are slowly trying to fix it.

I would like to help document the code. First I have to understand it
for myself. At the minimum I would be happy to go through some of it and
reformat it to the standards I learned while working for Motorola (which
I now choose to use all the time!)

This will have to wait a couple of weeks due to other commitments.

> > It seems to calculate the relative displacement from how long a button
> > is held down, then call scrollDocView() to jump by that much.
> 
> Hmm, is that true ?

BufferView_pimpl.C

---------8<------------8<--------------8<-----------------8<------------
int BufferView::Pimpl::scroll(long time)
{
        if (!buffer_)
                return 0;

        LyXText const * t = bv_->text;

        double const diff = t->defaultHeight()
                + double(time) * double(time) * 0.125;

        scrollDocView(int(diff));
        workarea().setScrollbarParams(t->height, t->first_y,
t->defaultHeight());
        return 0;
}
---------8<------------8<--------------8<-----------------8<------------


If I reverse-engineer correctly, the calling parameter "time" is the
time that a button has been pressed until now.

Each call to scroll() is then supposed to scroll down by one line plus
(1/8) * time^2

Hence it will accelerate the scroll if time is increasing at each call
to scroll() which is OK behaviour if it is responding to, say, a gadget
on the scrollbar. In that case, yes it would be nice if it accelerated
(up to a maximum speed though =).

But from my test of the code, it only scrolls to the first line, hence
my suspicion that scrollDocView accepts an _absolute_ value rather than
the relative displacement given.

My modification was to add t->first_y to int(diff) when calling. This
gave correct scroll down, even when the wheel was going up.

To me the code was never meant to handle a mouse wheel, it looks
specifically like it scrolls down only and the acceleration is
inappropriate. Although it works fine because the click takes a short
time and the acceleration isn't noticed. If someone ever did find a
weird scrollwheel which holds down a button to scroll, then the
acceleration might be appreciated. Dunno, never seen one.

> > scrollDocView(t->first_y + int(diff));  // changed by DF 20021019
> > 
> > The result is that I could scroll down, although it was a bit slow for
> > my liking. Would need something in the lyxrc file to control that as
> > everybody has a different taste.
> 
> That's what wheel_jump (should) does.

There's a wheel_jump()? =)

> > I couldn't scroll up, there doesn't seem to be any code for that.
> > Scrolling the wheel up scrolled down for obvious reasons. scroll(time)
> > only ever scrolls down.
> 
> scrolling up has a negative displacement.

but scroll(time) accepts a time, not a displacement. scroll() doesn't
really seem wheel-oriented at all. (or scrolling-up oriented)

> > Also, the code lets you scroll way past the bottom of the doc, would be
> > more reasonable to limit it when the last line is about to leave the
> > document (or is about to cross the middle of the window?).
> 
> Yes, it should do that.
> 
> > In addition, if this code really is specific to a mouse wheel as
> > commented in the header, then it's not written for any mouse wheel I've
> > ever seen.
> 
> which comment ?

BufferView_pimpl.h
---------8<------------8<--------------8<-----------------8<------------
        /// wheel mouse scroll
        int scroll(long time);
---------8<------------8<--------------8<-----------------8<------------

One of the few comments that aren't FIX_ME =)

> > Mouse wheels generate button clicks as the wheel turns. You feel the
> > notches in the wheel as it clicks. It's as if the user sits there
> > clicking the button fairly quickly. The code seems to expect the button
> > to be held down for a long time, and it accelerates the scroll the
> > longer it is held down. This will never happen on the mice I have ever
> > used, they can't hold down the pretend buttons that the wheel is
> > attached to, they are impulsive clicks only. You just keep turning the
> > wheel and the document should keep scrolling without acceleration, say 3
> > lines per click.
> 
> Where is your evidence of this "hold down" behaviour ?

See above.

> > Anyways, I'll let you sort it out, if scroll(value) is the function I'm
> 
> I can't sort it out because I can't test it...

Well IMHO it's not testworthy, it needs a rewrite. Once again, that's if
this was meant for wheel scrolling only, nothing else. But I haven't
looked beyond those two files because I was pointed to them for simple
tweaking. I don't think tweaking will help =)

And how will scroll(time) know if the wheel is going up? If it could
know that, it would be easy to make it usable (if only a kludge).

> thanks
> john

Well, I hope we sort this out soon as I'm eager to use the 1.3.0CVS
version.

Have fun,
Darren

Reply via email to