]> git.lyx.org Git - features.git/commitdiff
further work on updatescrollbar
authorLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 3 Jul 2001 22:44:37 +0000 (22:44 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Tue, 3 Jul 2001 22:44:37 +0000 (22:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2178 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog

index 81a5ab2d5bb677fb64225c6dc9923f68aa701853..542abbcd69625a707f7959a1f92616a44ae4454d 100644 (file)
@@ -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);
 }
 
 
index 42766b5512a3ebcd26a4aeff07c7fb252f5c119a..5d4c1f3f3985bdeb5ba09a3135b2e5bccac55b2b 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-04  Lars Gullik Bjønnes  <larsbj@birdstep.com>
+
+       * BufferView_pimpl.C (updateScrollbar): simplify further and
+       hopefully make it a bit faster.
+
 2001-07-03  Jean-Marc Lasgouttes  <Jean-Marc.Lasgouttes@inria.fr>
 
        * ColorHandler.C (LyXColorHandler): use GUIRunTime instead of