On Mon, Oct 21, 2002 at 05:42:10AM +0930, Darren Freeman wrote: > No I mean that as I turn the wheel, the scroll rate changes as I go > past, say, lots of headings or bigger writing.
Hold on to your hat: lyx cannot easily scroll by non-row based amounts. This is because we use setCursorByCoordinates() which works on a row-level not pixel level. Since Headings are tall rows, you end up scrolling "faster". This sucks and has sucked for a long long time. > I don't know why so many files are mentioned at the start of the diff, > but the files I actually changed are listed correctly. Just ignore that. > So now how do I refresh my view of the tree after you've sorted through > it? What do you mean ? Here's a quick review of your changes : int BufferView::scroll(long time) { - return pimpl_->scroll(time); + return pimpl_->scroll(time); // note that time is now called offsetLines - DF } Please put comments /above/ the source line not to the right. Also please change the paramter name here as well :) And in the header if appropriate. -int BufferView::Pimpl::scroll(long time) +// +// Wheel mouse scroll, move by offsetLines multiples of text->defaultHeight(). +// Observing hard-coded boundaries to prevent scrolling off the document. This comment should go in the header BufferView_pimpl.h, something like this : /** * Wheel mouse scroll, move by offsetLines multiples of * defaultHeight(), limited by the top/bottom of the document. */ int scroll(long offsetLines); +int BufferView::Pimpl::scroll(signed long offsetLines) Why add "signed" ? It is implicit. + if(!buffer_) + { return 0; + } LyX style dictates : if (!buffer_) { return 0; } + LyXText const *t = bv_->text; LyXText const * t ... + int lineHeight = t->defaultHeight(); int const ... + // + // Scroll by the desired displacement, observing the document limits. + // Why two empty comment lines ? + signed int newFirstY = t->first_y + disp; Not that you really displacing by pixels not "lines" here. I think - so you should change the comments/names to match this fact. - scrollDocView(int(diff)); + if(newFirstY < minFirstY) + { + newFirstY = minFirstY; + } again if (newFirstY < minFirstY) { newFirstY.. and you could use std::min/std::max + // + // Update the document scrollbar. + // + workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight()); This comment is pointless. What additional information does it give ? + + // + // Done. + // + return 0; Same here. } + /** + * Wheel mouse scroll, move by offsetLines multiples of text->defaultHeight(). + * Observing hard-coded boundaries to prevent scrolling off the document. + */ Oh OK. Then you don't need the duplicated description I mentioned above. I hope you don't think me too pedantic - it is quite important that new lyx code match the agreed-upon coding style as much as possible. This inevitably means compromises (there are some things I don't agree with in the style too, but I do them nonetheless). thanks john -- "It's a cardboard universe ... and if you lean too hard against it, you fall through." - Philip K. Dick