On Thu, Nov 20, 2003 at 01:44:43PM +0000, Angus Leeming wrote:
> Andre Poenitz wrote:
> > One question: what should now be the meaning of y in  Inset::draw()?
> > 
> > Currently it is 'screen absolute' as far as I can tell. Do we change
> > that?
> > 
> > Going to 'doc absolute' would mean adding lots of  top_y() all over
> > the place when calling the low-level drawing routines.
> > 
> > Another option ('nicer' perhaps...) would be to do the top_y()
> > addition in all low-level routines (i.e.  Painter::line() ::rect()
> > etc)
> > 
> > Should we just do that?
> 
> Or perhaps the nicest of all would be to have a helper function that 
> took the absolute coordinate and returned a coordinate relative to 
> the top of the screen.
> 
> Since the 'top of the screen' is a BufferView property, why not:
> 
> class BufferView {
>         int y(int y_absolute) const { return y_absolute - top_y(); }
> };
> 
> Then the inset code would be
> 
> void InsetCommand::draw(PainterInfo & pi, int x, int y_abs) const
> {
>         BufferView const & bv = *pi.base.bv;
>         xo_ = x;
>         yo_ = y;
>         button_.draw(pi, x, bv.y(y_abs));
> }

But 

void InsetCommand::draw(PainterInfo & pi, int x, int y_abs) const
{
        BufferView const & bv = *pi.base.bv;
        xo_ = x;
        yo_ = y;
        button_.draw(pi, x, y)
}

still looks nicer. So if the translation could be done in the lower
levels and the upper levels simply work on a 'everything is doc absolute
and I am not even aware that LyX uses anything else' base. 

This is simpler than having any translation somewhere in the upper level
as this always raises the question 'are these values already translated
or not'.

Andre'

-- 
Those who desire to give up Freedom in order to gain Security, will not have,
nor do they deserve, either one.     (T. Jefferson or B. Franklin or both...)

Reply via email to