further work on updatescrollbar

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2178 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Lars Gullik Bjønnes 2001-07-03 22:44:37 +00:00
parent 13ae124f46
commit d374682a5a
2 changed files with 26 additions and 27 deletions

View File

@ -380,35 +380,29 @@ void BufferView::Pimpl::updateScrollbar()
return; return;
} }
static unsigned long text_height; unsigned long const text_height = bv_->text->height;
static unsigned long work_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;
long const height_diff = text_height - work_height;
if (height_diff <= 0) {
workarea_.setScrollbar(0, 1.0);
return;
}
workarea_.setScrollbarBounds(0, height_diff);
double const lineh = bv_->text->defaultHeight(); double const lineh = bv_->text->defaultHeight();
double const slider_size = 1.0 / double(text_height);
static long old_text_height;
static double old_lineh;
static double old_slider_size;
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); workarea_.setScrollbarIncrements(lineh);
double const slider_size = 1.0 / (double(height_diff) + work_height); 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); workarea_.setScrollbar(current_scrollbar_value, slider_size);
old_slider_size = slider_size;
}
} }

View 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> 2001-07-03 Jean-Marc Lasgouttes <Jean-Marc.Lasgouttes@inria.fr>
* ColorHandler.C (LyXColorHandler): use GUIRunTime instead of * ColorHandler.C (LyXColorHandler): use GUIRunTime instead of