Le 07/09/13 17:32, Hashini Senaratne a écrit :
I am recently involved in horizontal scrolling of rows where I work with
Math insets. There I found that bv.getPos(cur).x_ is not getting updated
just after entering a Math inset from left or right corners.

The reason why it is not correct at first is because position is computed at draw time. From CoordCache.h:

/**
 * A BufferView dependent cache that allows us to come from an inset in
 * a document to a position point and dimension on the screen.
 * All points cached in this cache are only valid between subsequent
 * updates. (x,y) == (0,0) is the upper left screen corner, x increases
 * to the right, y increases downwords.
 * The dimension part is built in BufferView::updateMetrics() and the
 * diverse Inset::metrics() calls.
 * The individual points are added at drawing time in
 * BufferView::updateMetrics(). The math inset position are cached in
 * the diverse InsetMathXXX::draw() calls and the in-text inset position
 * are cached in RowPainter::paintInset().
 * FIXME: For mathed, it would be nice if the insets did not saves their
 * position themselves. That should be the duty of the containing math
 * array.
 */

So, until drawing has actually taken place, we do not know the position of the insets, only their size.

What happens is, the above attribute resets to the left most cursor position
of that row. And after few mouse movements, it gives the correct value.
These mouse movements calls drawing method of TextMetrics.cpp.

I think that mouse movement can trigger a DecorationUpdate. Do a
  git grep Update::Decoration src
to know where it happens.

Jean-Marc (my mentor) helped me a lot to figure out this error and mentioned
that this happens because that the positions of Math insets are calculated
while drawing. (Not before drawing) I failed to figure out the code segments
regarding this. When going reverse, it involves 'Point
BufferView::getPos(DocIterator const & dit) const', 'Point
BufferView::coordOffset(DocIterator const & dit) const'

Is the description pasted above clear enough to you?

Please, fellow developers, fell free to add your 2 cents.

JMarc

Reply via email to