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 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.

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.


Best Regards,
Martin Heistermann



Index: src/player/Node.h
===================================================================
--- src/player/Node.h   (revision 2318)
+++ src/player/Node.h   (working copy)
@@ -78,10 +78,10 @@
         double getY() const;
         void setY(double Y);
         
-        double getWidth() const;
+        double getWidth();
         void setWidth(double width);
         
-        double getHeight() const;
+        double getHeight();
         void setHeight(double height);
         
         double getOpacity() const;
Index: src/player/Node.cpp
===================================================================
--- src/player/Node.cpp (revision 2318)
+++ src/player/Node.cpp (working copy)
@@ -154,7 +154,8 @@
     setViewport(-32767, y, -32767, -32767);
 }
 
-double Node::getWidth() const {
+double Node::getWidth() {
+    setViewport(-32767, -32767, -32767, -32767);
     return getRelViewport().Width();
 }
 
@@ -163,7 +164,8 @@
     setViewport(-32767, -32767, width, -32767);
 }
 
-double Node::getHeight() const {
+double Node::getHeight() {
+    setViewport(-32767, -32767, -32767, -32767);
     return getRelViewport().Height();
 }
 

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

Reply via email to