]> git.lyx.org Git - features.git/commitdiff
fix to #241 and #300 from John
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 25 Mar 2002 17:00:04 +0000 (17:00 +0000)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 25 Mar 2002 17:00:04 +0000 (17:00 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3827 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/CutAndPaste.C

index 05c59edf11d8d5ab07c1d826c5c38508ae648306..18c7167bd996912986a9532c35317e10a589dd9b 100644 (file)
@@ -397,10 +397,8 @@ void BufferView::Pimpl::updateScreen()
 
 void BufferView::Pimpl::updateScrollbar()
 {
-       /* If the text is smaller than the working area, the scrollbar
-        * maximum must be the working area height. No scrolling will
-        * be possible */
        if (!bv_->text) {
+               lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
                workarea_.setScrollbar(0, 1.0);
                return;
        }
@@ -408,42 +406,36 @@ void BufferView::Pimpl::updateScrollbar()
        long const text_height = bv_->text->height;
        long const work_height = workarea_.height();
 
+       double const lineh = bv_->text->defaultHeight();
+       double const slider_size =
+               (text_height == 0) ? 1.0 : 1.0 / double(text_height);
+
+       lyxerr[Debug::GUI] << "text_height now " << text_height << endl;
+       lyxerr[Debug::GUI] << "work_height " << work_height << endl;
+       /* If the text is smaller than the working area, the scrollbar
+        * maximum must be the working area height. No scrolling will
+        * be possible */
        if (text_height <= work_height) {
+               lyxerr[Debug::GUI] << "doc smaller than workarea !" << endl;
                workarea_.setScrollbarBounds(0.0, 0.0);
                current_scrollbar_value = bv_->text->first_y;
                workarea_.setScrollbar(current_scrollbar_value, 1.0);
                return;
        }
 
-       double const lineh = bv_->text->defaultHeight();
-       double const slider_size =
-               (text_height == 0) ? 1.0 : 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.0,
-                                            text_height - work_height);
-               old_text_height = text_height;
-       }
-       if (lineh != old_lineh) {
-               workarea_.setScrollbarIncrements(lineh);
-               old_lineh = lineh;
-       }
-       if (current_scrollbar_value != bv_->text->first_y
-           || slider_size != old_slider_size) {
-               current_scrollbar_value = bv_->text->first_y;
-               workarea_.setScrollbar(current_scrollbar_value, slider_size);
-               old_slider_size = slider_size;
-       }
+       workarea_.setScrollbarBounds(0.0, text_height - work_height);
+       workarea_.setScrollbarIncrements(lineh);
+       current_scrollbar_value = bv_->text->first_y;
+       workarea_.setScrollbar(current_scrollbar_value, slider_size);
 }
 
 
 // Callback for scrollbar slider
 void BufferView::Pimpl::scrollCB(double value)
 {
+       lyxerr[Debug::GUI] << "scrollCB of " << value << endl;
        if (!buffer_) return;
 
        current_scrollbar_value = long(value);
index 0aa02389ce10ee6b8bed17a8c6d4a27c3c95a0e9..4b19ac89aa193663bd23854ce9e0e7c1be35d05c 100644 (file)
@@ -1,7 +1,17 @@
+2002-03-25  John Levon  <moz@compsoc.man.ac.uk>
+
+       * BufferView_pimpl.C (updateScrollbar): update on buffer switch
+         properly
+2002-03-19  John Levon  <moz@compsoc.man.ac.uk>
+
+       * CutAndPaste.C: change layouts earlier on paste
+         to avoid crashing when calling getFont()
 2002-03-22  Angus Leeming  <a.leeming@ic.ac.uk>
 
-       * PrinterParams.h: #include "lyxrc.h" and remove that bloody irritating
-       #error.
+       * PrinterParams.h: #include "lyxrc.h" and remove that bloody
+       irritating #error.
 
 2002-03-21  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
index c6eec1d8b6d811425c08e833f1d395ce9b3fd798..d5306afd315e153d959a6ce4765c403075a11cff 100644 (file)
@@ -283,7 +283,13 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                // temporary set *par as previous of tmpbuf as we might have to realize
                // the font.
                tmpbuf->previous(*par);
+               // make sure there is no class difference
+               SwitchLayoutsBetweenClasses(textclass, tc, tmpbuf,
+                                           current_view->buffer()->params);
+               
                Paragraph::depth_type max_depth = (*par)->getMaxDepthAfter(current_view->buffer());
                while(tmpbuf) {
                        // if we have a negative jump so that the depth would go below
                        // 0 depth then we have to redo the delta to this new max depth
@@ -322,10 +328,6 @@ bool CutAndPaste::pasteSelection(Paragraph ** par, Paragraph ** endpar,
                // now reset it to 0
                buf->previous(0);
 
-               // make sure there is no class difference
-               SwitchLayoutsBetweenClasses(textclass, tc, buf,
-                                           current_view->buffer()->params);
-
                // make the buf exactly the same layout than
                // the cursor paragraph
                buf->makeSameLayout(*par);