Darren's patch, reworked

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5451 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-10-21 00:15:48 +00:00
parent e4707d7f88
commit ebef7baa26
5 changed files with 29 additions and 13 deletions

View File

@ -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);
} }

View File

@ -165,8 +165,8 @@ public:
void toggleToggle(); void toggleToggle();
/// ///
void center(); void center();
/// /// scroll document by the given number of lines of default height
int scroll(long time); void scroll(int lines);
/// Scroll the view by a number of pixels /// Scroll the view by a number of pixels
void scrollDocView(int); void scrollDocView(int);

View File

@ -384,19 +384,25 @@ void BufferView::Pimpl::scrollDocView(int value)
} }
int BufferView::Pimpl::scroll(long time) void BufferView::Pimpl::scroll(int lines)
{ {
if (!buffer_) if (!buffer_) {
return 0; return;
}
LyXText const * t = bv_->text; LyXText const * t = bv_->text;
int const line_height = t->defaultHeight();
double const diff = t->defaultHeight() int const disp = lines * line_height;
+ double(time) * double(time) * 0.125;
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()); workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight());
return 0;
} }

View File

@ -60,8 +60,10 @@ struct BufferView::Pimpl : public boost::signals::trackable {
void updateScrollbar(); void updateScrollbar();
/// ///
void scrollDocView(int value); 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); void workAreaKeyPress(LyXKeySymPtr key, key_modifier::state state);
/// ///

View File

@ -1,3 +1,11 @@
2002-10-21 John Levon <levon@movementarian.org>
* 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 <dekelts@tau.ac.il> 2002-10-09 Dekel Tsur <dekelts@tau.ac.il>
* lyx_main.C (queryUserLyXDir): Fix automatic reconfiguration. * lyx_main.C (queryUserLyXDir): Fix automatic reconfiguration.