Angus Leeming wrote:
> On Monday 08 July 2002 4:36 pm, Juergen Vigna wrote:
> 
>>Ok. No we don't have a isVisible function right now and I don't think
>>this is easy to make as the "visibility" depends on the x,baseline
>>values passed as parameters to draw, which could change if I have to
>>rebreak the text after the loading. You could have a look at the
>>tabular.C or insettext.C draw functions. I just draw the visible
>>parts there, but for a graphics file with a fixed hight it could
>>be as easy as "if baseline+graphics_height > 0 then draw".

I forgot here obviously that it should be < screen height!

> Excuse me if I'm being dumn, but do you do have this info to hand because you 
> only call Inset::draw for a small set of Insets at a time. All you need to do 
> is cache this info. Something like:
> 
> vector<Inset *> visible_insets;
> 
> void Your_Main_Draw_Routine () {
>       visible_insets.clear();
>       for (some group of insets) {
>               inset->draw(...);
>               visible_insets.push_back(inset);
>       }
> }
> 
> bool isVisible(Inset * inset) {
>       vector<Inset *>::const_iterator it = visible_insets.begin();
>       vector<Inset *>::const_iterator end = visible_insets.end();
>       it = std::find(it, end, inset);
>       return it != end;
> }
> 
> Am I wrong?

Yes we could do that, but what happens if we have a rebreaking
of the rows (and we most surely will have if sizes change). Then
the above information is not valid anymore and you have to ask
the single insets again. But on the other hand we don't care if we
load one or 2 insets too much the important part is that the
row rebreaking is good afterwards.

bool SomeInset::loadGraphics()
{
     if (graphicsAvailable())
         return loadGraphics_setDimensions();
     return false;
}

bool SomeInset::loadGraphics_setDimensions();
{
     if (!graphicsAvailable())
         return false;
     loadGraphics();
     setDimensions();
     if (dimesions_changed)
          return true;
     return false;
}

I guess somewhere in BufferView:

...
bool do_rebreak = false;
for in in all_visible_insets(); do
     do_rebreak = in->loadGraphics() || do_rebreak;
done
if (do_rebreak)
     rebreakLyXText(par_of_first_vis_inset, par_of_last_vis_inset);
redrawScreenIfNeeded(); (== update() call ;)
...

Do you think something like this would work?

          Jug

-- 
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._
Dr. Jürgen Vigna        E-Mail:  [EMAIL PROTECTED]
Kravoglstrasse 4        Tel/Fax: +39 0471 564172 -  +39 0471 564122
I-39100 Bozen           Web:     http://www.lyx.org/~jug
-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._-._

Reply via email to