The branch, str-metrics, has been updated.

- Log -----------------------------------------------------------------

commit 69117c39b6113a8d7e9e4a007d6970bde5b8864f
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Fri Dec 20 14:02:31 2013 +0100

    Change getColumnNearX to getPosNearX
    
    The semantics was bad: the old implementation would return pos - row.pos(), 
and then all user of the function had to re-add row.pos().

diff --git a/00README_STR_METRICS_BRANCH b/00README_STR_METRICS_BRANCH
index e38d4b6..1983dfe 100644
--- a/00README_STR_METRICS_BRANCH
+++ b/00README_STR_METRICS_BRANCH
@@ -17,7 +17,11 @@ What is done:
   metrics are computed. The list of elements is stored in the row
   object in visual ordering, not logical.
 
-* Re-implement cursorX and getColumnNearX using row elements.
+* rename getColumnNearX to getPosNearX (and change code accordingly).
+  It does not make sense to return a position relative to the start of
+  row, since nobody needs this.
+
+* Re-implement cursorX and getPosNearX using row elements.
 
 * Implement proper string metrics computation (with cache), when
   lyxrc.force_paint_single_char is false. In this case, remove also
@@ -34,10 +38,6 @@ Next steps:
   kept for comparison purpose, guarded with KEEP_OLD_METRICS_CODE in
   order to check computations.
 
-* rename getColumnNearX to getPosNearX or x2pos (and change code
-  accordingly). It does not make sense to return a position relative
-  to the start of row, since nobody needs this.
-
 * Re-implement row painting using row elements. This is not difficult
   in principle, but the code is intricate and needs some careful
   analysis. First thing that needs to be done is to break row elements
diff --git a/src/TextMetrics.cpp b/src/TextMetrics.cpp
index a6dd134..a7366b5 100644
--- a/src/TextMetrics.cpp
+++ b/src/TextMetrics.cpp
@@ -1115,7 +1115,7 @@ void TextMetrics::setRowHeight(Row & row, pit_type const 
pit,
 // x is an absolute screen coord
 // returns the column near the specified x-coordinate of the row
 // x is set to the real beginning of this column
-pos_type TextMetrics::getColumnNearX(pit_type const pit,
+pos_type TextMetrics::getPosNearX(pit_type const pit,
                Row const & row, int & x, bool & boundary) const
 {
 
@@ -1299,7 +1299,7 @@ pos_type TextMetrics::getColumnNearX(pit_type const pit,
 
        if (abs(x2 - x) > 0.1 || boundary != boundary
            || c != pos) {
-               lyxerr << "getColumnNearX(" << x_orig << "): new=(x=" << x - xo 
<< ", b=" << boundary << ", p=" << pos << "), "
+               lyxerr << "getPosNearX(" << x_orig << "): new=(x=" << x - xo << 
", b=" << boundary << ", p=" << pos << "), "
                       << "old=(x=" << x2 - xo << ", b=" << boundary2 << ", p=" 
<< c << "), " << row;
        }
 
@@ -1330,7 +1330,7 @@ pos_type TextMetrics::x2pos(pit_type pit, int row, int x) 
const
        LBUFERR(row < int(pm.rows().size()));
        bool bound = false;
        Row const & r = pm.rows()[row];
-       return r.pos() + getColumnNearX(pit, r, x, bound);
+       return getPosNearX(pit, r, x, bound);
 }
 
 
@@ -1483,10 +1483,9 @@ Inset * TextMetrics::editXY(Cursor & cur, int x, int y,
        int yy = y; // is modified by getPitAndRowNearY
        Row const & row = getPitAndRowNearY(yy, pit, assert_in_view, up);
 
-       bool bound = false; // is modified by getColumnNearX
-       int xx = x; // is modified by getColumnNearX
-       pos_type const pos = row.pos()
-               + getColumnNearX(pit, row, xx, bound);
+       bool bound = false; // is modified by getPosNearX
+       int xx = x; // is modified by getPosNearX
+       pos_type const pos = getPosNearX(pit, row, xx, bound);
        cur.pit() = pit;
        cur.pos() = pos;
        cur.boundary(bound);
@@ -1555,7 +1554,7 @@ void TextMetrics::setCursorFromCoordinates(Cursor & cur, 
int const x, int const
 
        bool bound = false;
        int xx = x;
-       pos_type const pos = row.pos() + getColumnNearX(pit, row, xx, bound);
+       pos_type const pos = getPosNearX(pit, row, xx, bound);
 
        LYXERR(Debug::DEBUG, "setting cursor pit: " << pit << " pos: " << pos);
 
diff --git a/src/TextMetrics.h b/src/TextMetrics.h
index e8cef83..ed8c064 100644
--- a/src/TextMetrics.h
+++ b/src/TextMetrics.h
@@ -144,10 +144,10 @@ private:
 
 // Temporary public:
 public:
-       /// returns the column near the specified x-coordinate of the row.
+       /// returns the position near the specified x-coordinate of the row.
        /// x is an absolute screen coord, it is set to the real beginning
        /// of this column.
-       pos_type getColumnNearX(pit_type pit, Row const & row, int & x,
+       pos_type getPosNearX(pit_type pit, Row const & row, int & x,
                bool & boundary) const;
 
        /// returns pos in given par at given x coord.
diff --git a/src/frontends/qt4/GuiWorkArea.cpp 
b/src/frontends/qt4/GuiWorkArea.cpp
index 024c680..072093e 100644
--- a/src/frontends/qt4/GuiWorkArea.cpp
+++ b/src/frontends/qt4/GuiWorkArea.cpp
@@ -1001,7 +1001,7 @@ void GuiWorkArea::generateSyntheticMouseEvent()
        // Find the position of the cursor
        bool bound;
        int x = d->synthetic_mouse_event_.cmd.x();
-       pos_type const pos = rit->pos() + tm.getColumnNearX(pit, *rit, x, 
bound);
+       pos_type const pos = tm.getPosNearX(pit, *rit, x, bound);
 
        // Set the cursor
        cur.pit() = pit;

-----------------------------------------------------------------------

Summary of changes:
 00README_STR_METRICS_BRANCH       |   10 +++++-----
 src/TextMetrics.cpp               |   15 +++++++--------
 src/TextMetrics.h                 |    4 ++--
 src/frontends/qt4/GuiWorkArea.cpp |    2 +-
 4 files changed, 15 insertions(+), 16 deletions(-)


hooks/post-receive
-- 
Repository for new features

Reply via email to