Angus Leeming wrote:
> Alfredo Braunstein wrote:
>
> Index: lyxtext.h
> + struct Pos {
> + int x;
> + int y;
> +};
> No default constructor to initialize these two? Brave man!
>
> + Pos pos_;
> If it's public, you can get rid of the trailing underscore.
I left it for two reasons: 1) pos is the most common tmp variable name in
text*.C, so it's really not an option. 2) in the end, it should be private,
and have accessors etc... For the moment I think it's more confortable to
have it public.
> Tell the world what 'pos_' is. Give it a nice little comment.
Ok.
>
> Index: text2.C
> +{
> + pos_.x = 0;
> + pos_.y = 0;
> +}
> Ah-haa! struct Pos does indeed need a default constructor!
I guess it's a matter of preferences... (I prefer to think them as two
simple variables grouped toghether in a struct for clarity.)
> Do you plan to go to absolute coordinates for everything? The stuff
In the end yes.
> below is a horrible mix of the two...
But it's absolutely not fault of the patch. The absolute coordinates were
needed, but absent. So it's all the rest that is at fault. We will have
this sort of stuff until all have absolute coords.
Basically, I cannot do (nor would be wise) all in one step (and I cannot do
it alone! it's a boring nightmare to do). This changes can be done more or
less automatically if you start with a working version (as in every step
you can check that all works well). We don't have that.
This path pretends to be a preliminary step to have a working version.
Why this particular piece is ugly:
in inset::draw we have screen coordinates x,y translated to absolute doc
coords (i.e. y += top_y)
in inset::edit we translate screen coordinates to lyxtext coordinates (x -=
txt.x , y += top_y - txt.y)
(see my coordinates status on the first mail)
Alfredo
> Index: insets/insettext.C
> ===================================================================
> RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
> retrieving revision 1.546
> diff -u -p -u -r1.546 insettext.C
> --- insets/insettext.C 17 Nov 2003 20:28:10 -0000 1.546
> +++ insets/insettext.C 18 Nov 2003 22:39:28 -0000
> @@ -257,6 +257,9 @@ void InsetText::draw(PainterInfo & pi, i
>
> x += TEXT_TO_INSET_OFFSET;
>
> + text_.pos_.x = x;
> + text_.pos_.y = y + bv->top_y();
> +
> paintTextInset(*bv, text_, x, y);
>
> if (drawFrame_ == ALWAYS || drawFrame_ == LOCKED)
> @@ -340,10 +343,8 @@ void InsetText::edit(BufferView * bv, in
> lyxerr << "InsetText::edit xy" << endl;
> old_par = -1;
> sanitizeEmptyText(bv);
> - text_.setCursorFromCoordinates(x, y + dim_.asc);
> - text_.cursor.x(text_.cursor.x());
> - bv->x_target(text_.cursor.x());
> -
> + text_.setCursorFromCoordinates(x - text_.pos_.x, y + bv->top_y()
> + - text_.pos_.y);
> text_.clearSelection();
> finishUndo();
>
>