[libavg-devel] Div Node Rotations Patch

Nick Hebner hebnern at gmail.com
Sat Aug 18 20:44:57 CEST 2007


On 8/18/07, Ulrich von Zadow <uzadow at libavg.de> wrote:
>
> Hi Nick,
>
> as I already said in private email, this is something we've needed for a
> long time - very nice!
>
> Nick Hebner schrieb:
> > Hello All,
> >
> > First off, libavg is awesome! Thanks for the hard work!
> >
> > I have been working on a patch to support rotations on div nodes. I have
> > attached my working patch, but I have a few questions about how this
> > feature  should best be integrated. Currently, I have just added angle,
> > and pivot properties to the DivNode class. These are exactly the same as
> > those found in RasterNode, so I was wondering if angle and pivot should
> > just be integrated into Node, or whether another RotationNode class
> > should be made from which DivNode and RasterNode derive? Seems to me
> > that integration with Node is the right answer here.
>
> Right, duplicated code is not ok - all of the angle stuff should move to
> node. There are two node types for which this is an issue, though: <avg>
> and <panoimage>. For <avg>, we need to prevent angle and pivot from
> being set by overriding the appropriate functions etc., and
> <panoimage>... well actually, we should be able to make angle work for
> <panoimage> easily, right?
>
> (Not that this is perfect design, but it's good enough and I really
> don't have a better practical idea right now.)


Ok, I will move that stuff to Node. I was also wondering what PanoImage is
all about. What is the difference between it and Image?

> The only
> > outstanding issue with this patch is that the clip planes are not
> > rotated with the rest of the div, so the contents may be clipped if
> > rotated outside of the div. I believe that this could be fixed if the
> > angle stuff was a part of Node, and rotations were applied before the
> > clip planes.
>
> Sounds right :-).
>
> > I have also included a test script showing the rotations. You can click
> > to rotate the div, and mouse over the small image to see that element
> > selection of child nodes works correctly with rotations. Plop the test
> > scripts into the src/test dir to try them out.
>
> Works perfectly here.
>
> What we need before I check this in (other than fixes for the two issues
> you've already mentioned), is an automatic test so this doesn't break
> without us knowing. Attached is a patch for src/test that adds a test
> for correct image & mouse event handling, and an appropriate image to be
> placed in src/test/baseline.


Is the attached test enough or should I expand it?

Oh, and of course doc updates need to happen too.
>
> Cheers,
>
>    Uli
>
> --
>
> Ulrich von Zadow | +49-172-7872715 | cocacoder at jabber.berlin.ccc.de
>
>
> Index: Test.py
> ===================================================================
> --- Test.py     (revision 2234)
> +++ Test.py     (working copy)
> @@ -188,6 +188,31 @@
>      def delay():
>          pass
>
> +    def testRotate(self):
> +        def onOuterDown():
> +            self.onOuterDownCalled = True
> +        def fakeRotate():
> +            Player.getElementByID("outer").angle += 0.1
> +            Player.getElementByID("inner").angle -= 0.1
> +        def sendEvent(x, y):
> +            Helper = Player.getTestHelper()
> +            Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
> +                        x, y, 1)
> +
> +        Player.loadFile("rotate.avg")
> +        Player.getElementByID("outer").setEventHandler(
> +                avg.CURSORDOWN, avg.MOUSE, onOuterDown)
> +        self.onOuterDownCalled = False
> +        self.start(None,
> +                (lambda: self.compareImage("testRotate1", False),
> +                 fakeRotate,
> +                 lambda: self.compareImage("testRotate1", False),
> +                 lambda: sendEvent(85, 70),
> +                 lambda: self.assert_(not(self.onOuterDownCalled)),
> +                 lambda: sendEvent(85, 75),
> +                 lambda: self.assert_(self.onOuterDownCalled),
> +                 Player.stop))
> +
>      def testError(self):
>          Player.loadFile("image.avg")
>          Player.setTimeout(1, lambda: undefinedFunction)
> @@ -900,6 +925,7 @@
>      rmBrokenDir()
>      suite = unittest.TestSuite()
>      suite.addTest(PlayerTestCase("testImage", engine, bpp))
> +    suite.addTest(PlayerTestCase("testRotate", engine, bpp))
>      suite.addTest(PlayerTestCase("testError", engine, bpp))
>      suite.addTest(PlayerTestCase("testExceptionInTimeout", engine, bpp))
>      suite.addTest(PlayerTestCase("testInvalidImageFilename", engine,
> bpp))
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.datenhain.de/pipermail/libavg-devel/attachments/20070818/d8ac84a0/attachment.html


More information about the libavg-devel mailing list