]> git.lyx.org Git - features.git/commitdiff
make all cached positions screen-absolute
authorAndré Pönitz <poenitz@gmx.net>
Sat, 14 Aug 2004 21:56:40 +0000 (21:56 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Sat, 14 Aug 2004 21:56:40 +0000 (21:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8936 a592a061-630c-0410-9148-cb99ea01b6c8

src/coordcache.h
src/insets/inset.C
src/paragraph.C
src/rowpainter.C
src/text.C
src/text2.C
src/text3.C

index ac89bd251e7bd8d06f1df2924653dd8750394be9..639563036db078a6b1fe53d264886927e28a371c 100644 (file)
@@ -63,6 +63,12 @@ public:
                return data_.find(thing) != data_.end();
        }
 
+//     T * find(int x, int y) const
+//     {
+//             T * 
+//             cache_type iter
+//     } 
+
 private:
        friend class CoordCache;
 
@@ -74,7 +80,8 @@ private:
                }
        }
 
-       std::map<T const *, Point> data_;
+       typedef std::map<T const *, Point> cache_type;
+       cache_type data_;
 };
 
 
index 0f8bbc739e611b613aa3ce294506b890ba923319..1f6014002595ee05dd85830a1b494c3409255767 100644 (file)
@@ -85,5 +85,5 @@ int InsetOld::scroll(bool) const
 void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const
 {
        //lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
-       theCoords.insets_.add(this, x, y + pi.base.bv->top_y());
+       theCoords.insets_.add(this, x, y);
 }
index 33c4eb1b8eaa72e57fda53d2e9c320f56f845889..1dd00d4deeb520761951b5d0a904078363a751c8 100644 (file)
@@ -1736,25 +1736,6 @@ void Paragraph::rejectChange(pos_type start, pos_type end)
 }
 
 
-//Paragraph::value_type Paragraph::getChar(pos_type pos) const
-//{
-//     // This is in the critical path!
-//     pos_type const siz = text_.size();
-//
-//     BOOST_ASSERT(0 <= pos);
-//     BOOST_ASSERT(pos <= siz);
-//
-//     if (pos == siz) {
-//             lyxerr << "getChar() on pos " << pos << " in par id "
-//                    << id() << " of size " << siz
-//                    << "  is a bit silly !" << endl;
-//             BOOST_ASSERT(false);
-//     }
-//
-//     return text_[pos];
-//}
-
-
 int Paragraph::id() const
 {
        return pimpl_->id_;
index 9f970230c3ffb6f0bce875cde810776043ece499..7c765847e3844d3ea7b0a1ceef5f332a2a0f53bd 100644 (file)
@@ -544,9 +544,9 @@ void RowPainter::paintDepthBar()
 
        for (Paragraph::depth_type i = 1; i <= depth; ++i) {
                int const w = nestMargin() / 5;
-               int x = xo_ + w * i;
-               // only consider the changebar space if we're drawing outer left
-               if (xo_ == 0)
+               int x = int(xo_) + w * i;
+               // only consider the changebar space if we're drawing outermost text
+               if (text_.isMainText())
                        x += changebarMargin();
 
                int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
index 23748129f595fd8a88f1e20a5a4b8910f9c586f5..7021b6929c1ab15322123e3de3d7d2ade44a24e9 100644 (file)
@@ -1680,26 +1680,6 @@ Paragraph & LyXText::getPar(par_type par) const
 }
 
 
-// y is relative to this LyXText's top
-Row const & LyXText::getRowNearY(int y, par_type & pit) const
-{
-       BOOST_ASSERT(!paragraphs().empty());
-       BOOST_ASSERT(!paragraphs().begin()->rows.empty());
-       par_type const pend = paragraphs().size() - 1;
-       pit = 0;
-       while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
-               ++pit;
-
-       RowList::iterator rit = pars_[pit].rows.end();
-       RowList::iterator const rbegin = pars_[pit].rows.begin();
-       do {
-               --rit;
-       } while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
-
-       return *rit;
-}
-
-
 Row const & LyXText::firstRow() const
 {
        return *paragraphs().front().rows.begin();
index f15294a1ee5961fa69d06bc9194aee3fa59fba91..2cf60136e73ec8d834e0cbd8426f5aaf0a0977cb 100644 (file)
@@ -113,6 +113,8 @@ InsetBase * LyXText::checkInsetHit(int x, int y) const
                       bv()->top_y() - yo_ + bv()->workHeight(),
                       pit, end);
 
+       // convert to screen-absolute y coordinate
+       y -= bv()->top_y();
        lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
        lyxerr << "  pit: " << pit << " end: " << end << endl;
        for (; pit != end; ++pit) {
@@ -1162,6 +1164,27 @@ pos_type LyXText::getColumnNearX(par_type pit,
 }
 
 
+// y is relative to this LyXText's top
+// this is only used in the two functions below
+Row const & LyXText::getRowNearY(int y, par_type & pit) const
+{
+       BOOST_ASSERT(!paragraphs().empty());
+       BOOST_ASSERT(!paragraphs().begin()->rows.empty());
+       par_type const pend = paragraphs().size() - 1;
+       pit = 0;
+       while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
+               ++pit;
+
+       RowList::iterator rit = pars_[pit].rows.end();
+       RowList::iterator const rbegin = pars_[pit].rows.begin();
+       do {
+               --rit;
+       } while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
+
+       return *rit;
+}
+
+
 // x,y are absolute coordinates
 // sets cursor only within this LyXText
 void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
index 0b230da156c4c545db65166b2b586e8955691fb3..869cda8b7bfcb87817bcd63cd30bea3fa6716976 100644 (file)
@@ -1129,25 +1129,24 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd)
 
                // ignore motions deeper nested than the real anchor
                LCursor & bvcur = cur.bv().cursor();
-               if (!bvcur.anchor_.hasPart(cur))
-                       break;
-               CursorSlice old = cur.top();
-               setCursorFromCoordinates(cur, cmd.x, cmd.y);
+               if (bvcur.anchor_.hasPart(cur)) {
+                       CursorSlice old = cur.top();
+                       setCursorFromCoordinates(cur, cmd.x, cmd.y);
+
+                       // This is to allow jumping over large insets
+                       // FIXME: shouldn't be top-text-specific
+                       if (isMainText() && cur.top() == old) {
+                               if (cmd.y - bv->top_y() >= bv->workHeight())
+                                       cursorDown(cur);
+                               else if (cmd.y - bv->top_y() < 0)
+                                       cursorUp(cur);
+                       }
 
-               // This is to allow jumping over large insets
-               // FIXME: shouldn't be top-text-specific
-               if (isMainText() && cur.top() == old) {
-                       if (cmd.y - bv->top_y() >= bv->workHeight())
-                               cursorDown(cur);
-                       else if (cmd.y - bv->top_y() < 0)
-                               cursorUp(cur);
+                       // don't set anchor_
+                       bv->cursor().setCursor(cur);
+                       bv->cursor().selection() = true;
+                       lyxerr << "MOTION: " << bv->cursor() << endl;
                }
-
-               // don't set anchor_
-               bv->cursor().setCursor(cur);
-               bv->cursor().selection() = true;
-               lyxerr << "MOTION: " << bv->cursor() << endl;
                break;
        }