]> git.lyx.org Git - features.git/commitdiff
some fitcursor work
authorAlfredo Braunstein <abraunst@lyx.org>
Tue, 11 Nov 2003 09:06:41 +0000 (09:06 +0000)
committerAlfredo Braunstein <abraunst@lyx.org>
Tue, 11 Nov 2003 09:06:41 +0000 (09:06 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8074 a592a061-630c-0410-9148-cb99ea01b6c8

src/BufferView_pimpl.C
src/ChangeLog
src/cursor.C
src/cursor.h
src/frontends/ChangeLog
src/frontends/screen.C
src/insets/ChangeLog
src/insets/insetcollapsable.C
src/insets/insettext.C

index c99eb53632b379644fbc2c83778611cb578d223f..6f6d80c3ed4b3a372d0a3d791e8d6879aea81376 100644 (file)
@@ -343,9 +343,22 @@ void BufferView::Pimpl::buffer(Buffer * b)
 bool BufferView::Pimpl::fitCursor()
 {
        lyxerr << "BufferView::Pimpl::fitCursor." << endl;
-       bool ret;
 
-#ifndef LOCK
+       int x,y;
+       bv_->cursor().getPos(x, y);
+
+       if (y < top_y() || y > top_y() + workarea().workHeight()) {
+               int newtop = y - workarea().workHeight() / 2;
+               newtop = std::max(0, newtop);
+               top_y(newtop);
+               updateScrollbar();
+               return true;
+       }
+       return false;
+
+// dead code below
+       bool ret;
+#if 0  
        UpdatableInset * tli =
                static_cast<UpdatableInset *>(cursor_.innerInset());
        if (tli) {
@@ -354,7 +367,8 @@ bool BufferView::Pimpl::fitCursor()
        } else {
                ret = screen().fitCursor(bv_->text, bv_);
        }
-#else
+#endif
+#if 0
        ret = screen().fitCursor(bv_->text, bv_);
 #endif
 
@@ -958,7 +972,8 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                                case FINISHED_DOWN:
                                        theTempCursor.pop();
                                        bv_->cursor() = theTempCursor;
-                                       bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, cmd.y);
+                                       bv_->cursor().innerText()->setCursorFromCoordinates(cmd.x, top_y() + cmd.y);
+                                       bv_->fitCursor();
                                        return true;
                                default:
                                        lyxerr << "not dispatched by inner inset val: " << res.val() << endl;
@@ -969,13 +984,15 @@ bool BufferView::Pimpl::workAreaDispatch(FuncRequest const & cmd)
                // otherwise set cursor to surrounding LyXText
                if (!res.dispatched()) {
                        lyxerr << "cursor is: " << bv_->cursor() << endl;
-                       lyxerr << "dispatching " << cmd1 << " to surrounding LyXText "
-                               << bv_->cursor().innerText() << endl;
-                       theTempCursor.innerText()->dispatch(cmd1);
+                       lyxerr << "dispatching " << cmd1
+                              << " to surrounding LyXText "
+                              << bv_->cursor().innerText() << endl;
                        cursor_ = theTempCursor;
+                       theTempCursor.dispatch(cmd1);
                        //return DispatchResult(true, true);
                }
 
+               bv_->update();
                // see workAreaKeyPress
                cursor_timeout.restart();
                screen().showCursor(*bv_);
index 64ec3a1f7dfd80fc370eff856d9570a5e1601971..45864a67b33d711204448234d6f3ba596abbe989 100644 (file)
@@ -1,3 +1,9 @@
+2003-11-11  Alfredo Braunstein  <abraunst@libero.it>
+
+       * cursor.C (getPos): return absolute cached y coord
+
+       * BufferView_pimpl.C (fitCursor): new simplistic code
+       (workAreaDispatch): add a fitCursor call
 
 2003-11-10  André Pönitz  <poenitz@gmx.net>
 
index 3ca9d9b9cbaf303887455fea4daab8772d15b3d9..c3d7c950806215a5211c2498277ef4c8ed710094 100644 (file)
@@ -113,6 +113,7 @@ void LCursor::push(UpdatableInset * inset)
 {
        lyxerr << "LCursor::push()  inset: " << inset << endl;
        data_.push_back(CursorItem(inset));
+       cached_y_ = bv_->top_y() + inset->y();
 }
 
 
@@ -161,7 +162,7 @@ void LCursor::getPos(int & x, int & y) const
        if (data_.empty()) {
                x = bv_->text->cursor.x();
                y = bv_->text->cursor.y();
-               y -= bv_->top_y();
+//             y -= bv_->top_y();
        } else {
                // Would be nice to clean this up to make some understandable sense...
                UpdatableInset * inset = innerInset();
@@ -176,7 +177,7 @@ void LCursor::getPos(int & x, int & y) const
                //y = inset->insetInInsetY() + bv_->text->cursor.y();
                inset->getCursorPos(bv_, x, y);
                x += inset->x();
-               y += inset->y();
+               y += cached_y_;
        }
 }
 
index ce5fb19d779f398ce73767f19708e54d8044d33d..a7f981b31e3a8a57fcf53b6163efd86364f9a8ba 100644 (file)
@@ -82,6 +82,9 @@ public:
        std::vector<CursorItem> data_;
        ///
        BufferView * bv_;
+private:
+       ///
+       int cached_y_;
 };
 
 #endif // LYXCURSOR_H
index 4a52910086166db12b89b6f479255f60d3263708..fad235d0d5dad4370c0d5b1a9c64fa3786a1227b 100644 (file)
@@ -1,3 +1,6 @@
+2003-11-11  Alfredo Braunstein  <abraunst@libero.it>
+
+       * screen.C (showCursor): use absolute coords form LCursor
 
 2003-11-10  André Pönitz  <poenitz@gmx.net>
 
index 6e8e43fd1e5ac92fe69c71629e4384a94232927d..fc8540e09a21781c1e4d3b58f9b3a2fa5d1f329f 100644 (file)
@@ -173,7 +173,7 @@ void LyXScreen::showCursor(BufferView & bv)
        int x = 0;
        int y = 0;
        bv.cursor().getPos(x, y);
-       y -= ascent;
+       y -= ascent + bv.top_y();
        //lyxerr << "LyXScreen::showCursor x: " << x << " y: " << y << endl;
 
        // if it doesn't fit entirely on the screen, don't try to show it
index 7c6dab1af8e276691bf2166721f5a0b543e49484..4f730fa10c54753af1ba49fc45835cf15626265f 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-11  Alfredo Braunstein  <abraunst@libero.it>
+
+       * insettext.C (updateLocal, insertInset, setFont): remove 
+       fitCursor calls
 
 2003-11-10  André Pönitz  <poenitz@gmx.net>
 
index 88cfedffbca5a155240f665675b8820069730f2e..6b9367c989b8ff845fb14b9eabfc2089b6c5ec5a 100644 (file)
@@ -268,9 +268,9 @@ bool InsetCollapsable::hitButton(FuncRequest const & cmd) const
 void InsetCollapsable::edit(BufferView * bv, bool left)
 {
        lyxerr << "InsetCollapsable: edit left/right" << endl;
-       bv->cursor().push(this);
        inset.edit(bv, left);
        open(bv);
+       bv->cursor().push(this);
 }
 
 
@@ -288,8 +288,7 @@ void InsetCollapsable::edit(BufferView * bv, int x, int y)
                if (y <= button_dim.y2)
                        inset.edit(bv, x, 0);
                else
-                       inset.edit(bv, x,
-                               ascent() + y - height_collapsed() + inset.ascent());
+                       inset.edit(bv, x, ascent() + y - height_collapsed() + inset.ascent());
        }
        bv->cursor().push(this);
 }
index 85dc75e69a8c4b8dee9aad056a15d0cfd9a08446..bdc65b83cd8a638b543693af7a309304660f35cb 100644 (file)
@@ -289,7 +289,7 @@ void InsetText::updateLocal(BufferView * bv, bool /*mark_dirty*/)
        if (!text_.selection.set())
                text_.selection.cursor = text_.cursor;
 
-       bv->fitCursor();
+//     bv->fitCursor();
        bv->update();
        bv->owner()->view_state_changed();
        bv->owner()->updateMenubar();
@@ -780,7 +780,7 @@ bool InsetText::insertInset(BufferView * bv, InsetOld * inset)
 {
        inset->setOwner(this);
        text_.insertInset(inset);
-       bv->fitCursor();
+//     bv->fitCursor();
        updateLocal(bv, true);
        return true;
 }
@@ -847,7 +847,7 @@ void InsetText::setFont(BufferView * bv, LyXFont const & font, bool toggleall,
        if (selectall)
                text_.clearSelection();
 
-       bv->fitCursor();
+//     bv->fitCursor();
        updateLocal(bv, true);
 }