From: Lars Gullik Bjønnes Date: Tue, 3 Jul 2001 22:44:37 +0000 (+0000) Subject: further work on updatescrollbar X-Git-Tag: 1.6.10~21140 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d374682a5adb0cc2ab074a8dd2bce7809810766f;p=features.git further work on updatescrollbar git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2178 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index 81a5ab2d5b..542abbcd69 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -380,35 +380,29 @@ void BufferView::Pimpl::updateScrollbar() return; } - static unsigned long text_height; - static unsigned long work_height; + unsigned long const text_height = bv_->text->height; - unsigned long const tmp_text_height = bv_->text->height; - long const tmp_scrollbar_value = bv_->text->first; - - // check if anything has changed. - if (text_height == tmp_text_height - && work_height == workarea_.height() - && current_scrollbar_value == tmp_scrollbar_value) - return; // no - - // update values - text_height = tmp_text_height; - work_height = workarea_.height(); - current_scrollbar_value = tmp_scrollbar_value; + double const lineh = bv_->text->defaultHeight(); + double const slider_size = 1.0 / double(text_height); - long const height_diff = text_height - work_height; + static long old_text_height; + static double old_lineh; + static double old_slider_size; - if (height_diff <= 0) { - workarea_.setScrollbar(0, 1.0); - return; + if (text_height != old_text_height) { + workarea_.setScrollbarBounds(0, text_height - workarea_.height()); + old_text_height = text_height; + } + if (lineh != old_lineh) { + workarea_.setScrollbarIncrements(lineh); + old_lineh = lineh; + } + if (current_scrollbar_value != bv_->text->first + || slider_size != old_slider_size) { + current_scrollbar_value = bv_->text->first; + workarea_.setScrollbar(current_scrollbar_value, slider_size); + old_slider_size = slider_size; } - - workarea_.setScrollbarBounds(0, height_diff); - double const lineh = bv_->text->defaultHeight(); - workarea_.setScrollbarIncrements(lineh); - double const slider_size = 1.0 / (double(height_diff) + work_height); - workarea_.setScrollbar(current_scrollbar_value, slider_size); } diff --git a/src/ChangeLog b/src/ChangeLog index 42766b5512..5d4c1f3f39 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2001-07-04 Lars Gullik Bjønnes + + * BufferView_pimpl.C (updateScrollbar): simplify further and + hopefully make it a bit faster. + 2001-07-03 Jean-Marc Lasgouttes * ColorHandler.C (LyXColorHandler): use GUIRunTime instead of