trollicious wrote:
> Hello,
> Is there any way to access a node's current width/height attributes
> after changing an attribute that alter its size?
>
> In my case, I set a words' text attribute and need to access the width
> of the text - but it seems like it is only updated after being drawn.

The width attribute should always reflect the current width on the screen.
If it isn't updated immediately, that's a bug in libavg. I'll look into it
next week, when I'm back in Berlin. In the meantime, it would be great if
you could write a simple test case that shows what's happening.

> The way I understand player/Node.cpp, Node::setViewport needs to be
> called with -32767 as width/height params, so it gets the correct values
> from getPreferredMediaSize, which in the Words' case is calculated from
> the actual text.

The code that depends on the hard-coded value of -32767 is an ugly wart
and will probably disappear at some point.

> As a workaround, I use node.x=-32767 (or node.x=node.x) - the Node setX
> function updates the viewport. (This doesnt work 100% clean here for
> some reason, but that is most probably the fault of my own code)
>
> Is there any better way in doing this? Would changing the code to
> recalculate the viewport upon width/height access be appropiate? If so,
> I attached a patch doing that.

That goes in the right direction, but I think there's a speed issue here:
Figuring out how wide text is involves rendering the text into a bitmap,
and that takes quite a bit of time, so it shouldn't be done needlessly.

(But I'm writing this from an internet cafe and have no access to other
computers right now - as I said, I'll look into it when I'm back.)

Regards,

  Uli


_______________________________________________
libavg-users mailing list
[email protected]
https://mail.datenhain.de/mailman/listinfo/libavg-users

Reply via email to