Author Topic: Best practices for layout?  (Read 1992 times)

gregorypierce

  • Guest
Best practices for layout?
« on: December 18, 2012, 09:35:29 PM »
There aren't really any layout managers for the engine (outside of the border layout) so I'm wondering how does approach building out a GUI that will work across multiple devices if everything in NGUI is based on pixel dimensions? Something that looks great on one device ends up looking distorted on another.

Stretching screen backgrounds is fine, but suppose I want something that represents a 3 column layout? How would I build something like that in NGUI?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Best practices for layout?
« Reply #1 on: December 18, 2012, 11:01:15 PM »
You use anchors. Check the first example. :P

gregorypierce

  • Guest
Re: Best practices for layout?
« Reply #2 on: December 27, 2012, 04:34:12 AM »
That doesn't really help me though unless I want to have one anchored to the left, one to the middle, and one anchored to the right. Unless I want to use borderlayout I can't seem to find anything useful.

For example, suppose I have a Label anchored in the upper left. I now want to have a set of components right beneath it. How do I anchor that set of components to the Label? Or to make it even simpler, suppose I have a label already anchored on the screen and now I want to put 2 others below it? There doesn't appear to be a layout metaphor that says "label2.x = label1.x, label2.y = label1.y + label1.height + padding".

I'm trying to never define anything in pixel space so that the layout is fluid.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Best practices for layout?
« Reply #3 on: December 27, 2012, 12:03:09 PM »
You can anchor things to other widgets in the full version of NGUI. You can also use a UITable to automatically position things below or beside others (like a layout).