Author Topic: UITable pushing widgets down  (Read 1801 times)

laurentl

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 188
    • View Profile
    • McDROID
UITable pushing widgets down
« on: September 30, 2013, 09:34:25 PM »
I am using UITable to create dynamically a group of tabs that are aligned either horizontally or vertically.

Each tab is made up of about 5 sprites and a texture.

When a new item appears, the sprite that says "NEW" is enabled and that sprite appears above the tab.

When that happens, the NEW tab get's pushed on the Y axis like so:
https://www.youtube.com/watch?v=qZls9tT61MM

Why is that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable pushing widgets down
« Reply #1 on: October 01, 2013, 07:23:42 PM »
I vaguely remember there being a bug in the table with the "up" type table alignment. It supposed to be pushed up, not pushed down. I am not sure if it was ever fixed in 3.0, come to think of it...

Any particular reason you don't just use a UIGrid here instead?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITable pushing widgets down
« Reply #2 on: October 01, 2013, 08:06:11 PM »
Yup, confirmed to be still bugged in 3.0. Here's how to fix it. Open up UITable, line 125. The statement currently reads:
  1.                         if (direction == Direction.Down)
  2.                         {
  3.                                 pos.y = -yOffset - b.extents.y - b.center.y;
  4.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  5.                         }
  6.                         else
  7.                         {
  8.                                 pos.y = yOffset + b.extents.y - b.center.y;
  9.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  10.                         }
And it should be:
  1.                         if (direction == Direction.Down)
  2.                         {
  3.                                 pos.y = -yOffset - b.extents.y - b.center.y;
  4.                                 pos.y += (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  5.                         }
  6.                         else
  7.                         {
  8.                                 pos.y = yOffset + (b.extents.y - b.center.y);
  9.                                 pos.y -= (b.max.y - b.min.y - bc.max.y + bc.min.y) * 0.5f - padding.y;
  10.                         }