Author Topic: Easiest way to grow a background with a UITable or UIGrid?  (Read 6513 times)

wishful_st

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Easiest way to grow a background with a UITable or UIGrid?
« on: August 08, 2014, 09:21:35 PM »
I am trying to have a background encapsulate a UITable with a dynamic number of elements (which includes both active and inactive objects, but UITable hides inactive objects).

What's the best way for me to add a background sprite that can underlay the expanse of the active UITable elements?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Easiest way to grow a background with a UITable or UIGrid?
« Reply #1 on: August 09, 2014, 05:09:38 PM »
You can have an element wrap itself around arbitrary amount of content by using the EnvelopContent script. You can add padding to your table's cells by using invisible widgets (ALT+SHIFT+W).

wishful_st

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Easiest way to grow a background with a UITable or UIGrid?
« Reply #2 on: August 10, 2014, 02:22:51 AM »
This is exactly what I'm looking for - I don't know how I lived without this, not just for tables, but for any sort of arbitrary grouping.  Thank you!

(I was going to calculate the bounds of a child objects, and then create a widget around that bounds, but it appears you have something that works already!)

You may/may not have heard this enough already, but I just wanted to say again NGUI is an awesome product, and the support you give to your users day in and day out is amazing - I can't imagine the patience you'd need to have to support newbies and experienced people alike, as well as continuing to be civil to the unappreciative.

Thanks Michael!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Easiest way to grow a background with a UITable or UIGrid?
« Reply #3 on: August 10, 2014, 05:03:59 PM »
Supporting NGUI has forced me to gradually improve myself over the years. If you only knew how big of a dick I was just a few years ago... Still am, to an extent -- but getting better. ;)

wishful_st

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: Easiest way to grow a background with a UITable or UIGrid?
« Reply #4 on: August 10, 2014, 08:13:21 PM »
Lol - can't fault you for getting a little tart when you're answering the same question for the nth time :).

I've been messing around with the EnvelopContent script for a bit, and initially, did what I expected it to do, but I then ran into some positioning problems with the envelope widget, but I think I figured out why, but just wanted to post here, in case others run into the same problem.

ArenMook mentioned that "You can add padding to your table's cells by using invisible widgets " - initially, I thought I didn't need it since the table/grid allows you to define padding.  But I suspect he specifically mentioned invisible widgets for padding because the EnvelopContent script does not take into account a table/grid's padding since it knows nothing about the grid/table, so even though the bounds calculated by the script is correct, the positioning of the envelope widget will be off by some factor proportional to the table/grid's offset amount.

In other words, if you're using EnvelopeContent to encapsulate the contents of a table/grid, you can't rely on the table/grid's padding; either add invisible widgets, or make your content widget larger to account for padding.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Easiest way to grow a background with a UITable or UIGrid?
« Reply #5 on: August 11, 2014, 11:45:59 PM »
Yup, exactly right.