Author Topic: UILabel Set Width and Shrink to Fit  (Read 12986 times)

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
UILabel Set Width and Shrink to Fit
« on: October 21, 2013, 12:38:38 PM »
Did the ability to set the max width and enabling Shrink to Fit get removed or am I just not seeing it?   
I am talking about having it so when you input more than the max width so it shrinks the content to compensate.
If it is indeed removed, is there any specific reason? It was an incredibly useful option  :-\
Example settings of 2.7 vs 3.0
 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #1 on: October 21, 2013, 01:25:20 PM »
Dimensions contain both width and height.

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #2 on: October 21, 2013, 01:42:25 PM »
Dimensions contain both width and height.

I have the width/height set to the size of the Label that I want it to fit to but the input is being cut off instead of shrinking to fit the Label dimensions. 

Edit:  I am trying to make it shrink to one line.   (Max Line: 1)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #3 on: October 21, 2013, 01:44:08 PM »
Input as in UIInput? If so, then yes, input forces the label to be clamped in 3.0.2.

Otherwise, max lines setting being non-zero is what would make shrink content stop working in labels.

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #4 on: October 21, 2013, 01:47:57 PM »
Input as in UIInput? If so, then yes, input forces the label to be clamped in 3.0.2.

Otherwise, max lines setting being non-zero is what would make shrink content stop working in labels.
(By input I meant the string inside the label)
To clarify, at moment NGUI doesn't have a preset function to shrink the content of a Label to 1 line?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #5 on: October 21, 2013, 01:50:18 PM »
It does, if you reduce the height down to a height of 1 line. Forget the "max lines" property.

LightSky

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 2
  • Posts: 56
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #6 on: October 21, 2013, 02:21:49 PM »
Settings the height only shrinks it to one line for a short time. As seen in my very artistic mock-up
Any advice?  I am probably missing something obvious  ???
The NGUI ~2.7 inspector I showed in my first post replicated this perfectly.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #7 on: October 21, 2013, 04:55:31 PM »
Yeah, short version? You can't do what you're trying to do until I change the logic a bit. So either ignore it for now and move on to the next task assuming it will be possible in a future version, or hack it yourself.

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #8 on: October 22, 2013, 01:57:33 AM »
I have the same problem, Shrink to fit, has disappeared? I do not understand, it was a very important function for me, I have Ngui Pro 3.0.2 and can not find a way to scale text automatically ...

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #9 on: October 23, 2013, 03:36:56 AM »
Bump!

I need this función, any help?

best regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #10 on: October 23, 2013, 10:03:30 PM »
Huh? Shrink option is still there. Check the Overflow handling.

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #11 on: October 24, 2013, 02:05:42 AM »
Yes, I have selected Shrink content, but does not adjust the text size automatically ...

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #12 on: October 24, 2013, 05:35:16 AM »
Ok I solved my problem,  the problem is that when you touch the input to add text, Maxline automatically switches to 1, I went to class UIInput and in line 229 change label.maxLineCount = 0, and now works perfect. regards

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #13 on: October 25, 2013, 12:15:53 AM »
Ah, that has already been fixed in 3.0.3.

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Set Width and Shrink to Fit
« Reply #14 on: October 25, 2013, 02:56:28 AM »
great!