feathersui / feathersui-starling

User interface components for Starling Framework and Adobe AIR
https://feathersui.com/learn/as3-starling/
Other
914 stars 386 forks source link

Label is cut off when using padding #1038

Closed SamYStudiO closed 9 years ago

SamYStudiO commented 9 years ago

Hi Josh,

When using padding with autosized label, text may be cut off, looks like padding is not set to textrenderer in autoSizeIfNeeded method and so autosize is compute without padding.

joshtynjala commented 9 years ago

I cannot reproduce this issue. This code works for me:

var label:Label = new Label();
label.backgroundSkin = new Quad(10, 10, 0x999999);
label.text = "Good afternoon";
label.padding = 50;
this.addChild(label);

I also double-checked the Label class, and padding is applied in autoSizeIfNeeded() here and here. Maybe you're not using the latest commit?

SamYStudiO commented 9 years ago

In fact it's a bit more specific you need to set explicitly width OR height and not set the other one. In that case textRenderer will also set explicity the same width or height without subtracting padding (line 666 and line 669) to measure text. I will try to add an exemple tomorrow (can't do it at home), but if you set explicitly width in your exemple with a longer text you should be able to reproduce it.

joshtynjala commented 9 years ago

Everything seems to be working as expected when I set the width or the height, but not both. I will wait for your example. Please try to attach a screenshot too.

SamYStudiO commented 9 years ago

Hey Josh,

Here is an exemple, I use to change Metalworks theme with TextfieldtextRenderer and others things so i revert everything with your default metalworks theme so you can grab and test quickly this :

_label = new Label();
_label.styleProvider = null;
_label.width = 400;
_label.text = "Soutenez le reboisement et l’appui aux communautés locales à Madagascar test d’ajout d’une 4e ligne";
_label.padding = 40;
_label.textRendererProperties.truncateToFit = false;
_label.textRendererProperties.wordWrap = true;

var fd : FontDescription = new FontDescription( "SourceSansPro" , FontWeight.NORMAL , FontPosture.NORMAL , FontLookup.EMBEDDED_CFF , RenderingMode.CFF , CFFHinting.NONE );
_label.textRendererProperties.elementFormat = new ElementFormat( fd , 40 );

Hope you may see the missing text at the end. Replacing actual 666 and 669 lines with

this.textRenderer.width = this.explicitWidth - ( _paddingLeft + _paddingTop );
this.textRenderer.height = this.explicitHeight - ( _paddingTop + _paddingBottom );

fix it. Hope this help!

SamYStudiO commented 9 years ago

Sorry forgot the screenshot, here it is: label_shot

joshtynjala commented 9 years ago

Thank you. I can now reproduce the issue.

aleks-fofanov commented 9 years ago

Josh, I've got exactly the same issue, but also, I would like to mention that any label with paddings should respect the the maxWidth and maxHeight properties. I mean, when applying maxWidth and maxHeight properties to the textRenderer the paddings also must be subtracted. Thanks.

joshtynjala commented 9 years ago

Yes, I'll be adjusting the text renderer's min/max dimensions too. Thanks for pointing it out, though. That's easy to miss sometimes.