Author Topic: Widget with fixed max size  (Read 3901 times)

Waliactico

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Widget with fixed max size
« on: February 25, 2014, 11:40:26 AM »
Hello all, I'm having trouble with the layout system trying to do the following:
I want a widget to have fixed width, UNLESS it doesn't fit in the screen. I mean, if the widget width is smaller than the screen width, them its width should remain fixed. But if the screen width is smaller, then the widget should resize to fit in the screen so it doesn't appear clipped.
Here are some screenshots showing this problem:
http://i.imgur.com/3GHOl9Z.png

I hope you can help me! I've been with this problems for days... Thank you so much!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget with fixed max size
« Reply #1 on: February 25, 2014, 01:11:01 PM »
For something like that you will need to write custom code. NGUI's layout system doesn't have any checks for whether something fits or not.

stepnoy

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Widget with fixed max size
« Reply #2 on: October 21, 2014, 03:15:01 PM »
For something like that you will need to write custom code. NGUI's layout system doesn't have any checks for whether something fits or not.

Can you please give me a directions where I had to make changes in code ?
Is it will be enough to just adding a new component to widget that in Update function will check a bounds of widget and correct it if necessary ? My widget is anchored to right side and center of container.

About my case. I have a right-side tool panel that is initially designed for 4:3 aspect ratio. I need to make sure that it will in will scale automatically all aspect ratios except an 16:9 one, when it must be a bit narrower that it does when scaling automatically.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Widget with fixed max size
« Reply #3 on: October 22, 2014, 05:25:09 AM »
Have a look at how UIBasicSprite.minWidth and minHeight properties are used. You would add maxWidth and maxHeight code in the same place.