From ebef7baa265f097b3372ed6239495255c6b64e49 Mon Sep 17 00:00:00 2001 From: John Levon Date: Mon, 21 Oct 2002 00:15:48 +0000 Subject: [PATCH] Darren's patch, reworked git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5451 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView.C | 4 ++-- src/BufferView.h | 4 ++-- src/BufferView_pimpl.C | 20 +++++++++++++------- src/BufferView_pimpl.h | 6 ++++-- src/ChangeLog | 8 ++++++++ 5 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/BufferView.C b/src/BufferView.C index 514026d7f5..edc9f36393 100644 --- a/src/BufferView.C +++ b/src/BufferView.C @@ -258,9 +258,9 @@ bool BufferView::dispatch(FuncRequest const & ev) } -int BufferView::scroll(long time) +void BufferView::scroll(int lines) { - return pimpl_->scroll(time); + pimpl_->scroll(lines); } diff --git a/src/BufferView.h b/src/BufferView.h index 1bec27f90a..afe153561e 100644 --- a/src/BufferView.h +++ b/src/BufferView.h @@ -165,8 +165,8 @@ public: void toggleToggle(); /// void center(); - /// - int scroll(long time); + /// scroll document by the given number of lines of default height + void scroll(int lines); /// Scroll the view by a number of pixels void scrollDocView(int); diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 36b457694f..eeb0c4383a 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -384,19 +384,25 @@ void BufferView::Pimpl::scrollDocView(int value) } -int BufferView::Pimpl::scroll(long time) +void BufferView::Pimpl::scroll(int lines) { - if (!buffer_) - return 0; + if (!buffer_) { + return; + } LyXText const * t = bv_->text; + int const line_height = t->defaultHeight(); - double const diff = t->defaultHeight() - + double(time) * double(time) * 0.125; + int const disp = lines * line_height; - scrollDocView(int(diff)); + // Restrict to a valid value + int new_first_y = std::min(t->height - 4 * line_height, disp); + new_first_y = std::max(0, disp); + + scrollDocView(new_first_y); + + // Update the scrollbar. workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight()); - return 0; } diff --git a/src/BufferView_pimpl.h b/src/BufferView_pimpl.h index 369df9fc5f..9a77eba226 100644 --- a/src/BufferView_pimpl.h +++ b/src/BufferView_pimpl.h @@ -60,8 +60,10 @@ struct BufferView::Pimpl : public boost::signals::trackable { void updateScrollbar(); /// void scrollDocView(int value); - /// wheel mouse scroll - int scroll(long time); + /** + * Wheel mouse scroll, move by multiples of text->defaultHeight(). + */ + void scroll(int lines); /// void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state); /// diff --git a/src/ChangeLog b/src/ChangeLog index 6d7d0c5f74..1f6575f03b 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2002-10-21 John Levon + + * BufferView.h: + * BufferView.C: + * BufferView_pimpl.h: + * BufferView_pimpl.C: fix mouse wheel handling based on + patch from Darren Freeman + 2002-10-09 Dekel Tsur * lyx_main.C (queryUserLyXDir): Fix automatic reconfiguration. -- 2.39.2