scaling TWL UI in libgdx

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

scaling TWL UI in libgdx

Postby manifold » Tue Sep 20, 2011 9:17 pm

If you want to scale and transform entire TWL GUI using SpriteBatch's transformation matrix, you may notice that GdxRenderer doesn't take into account its scaling and translation, so:
Change method setClipRect in, compile and put it back in gdx-twl.jar.
Code: Select all
public void setClipRect (Rect rect) {
      if (rendering) batch.flush();
      if (rect == null) {;
         hasScissor = false;
      } else {
         Matrix4 transform = batch.getTransformMatrix();

         Vector3 tl = new Vector3(rect.getX(), rect.getY(), 0).mul(transform);
         Vector3 br = new Vector3(rect.getRight(), rect.getBottom(), 0).mul(transform);
         //, - rect.getBottom(), rect.getWidth(), rect.getHeight());, (int)br.y, (int)(br.x-tl.x), (int)(tl.y-br.y));
         if (!hasScissor) {
            hasScissor = true;

Now your TWL TextArea and ScrolPane should be ok. No more incorrect clipping!
Posts: 1
Joined: Tue Sep 20, 2011 9:08 pm

Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest