Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content of TextBlockTextRenderer may disappear when it is resized #1501

Closed
Klug76 opened this issue Nov 28, 2016 · 6 comments
Closed

content of TextBlockTextRenderer may disappear when it is resized #1501

Klug76 opened this issue Nov 28, 2016 · 6 comments
Labels
Milestone

Comments

@Klug76
Copy link

Klug76 commented Nov 28, 2016

The content of the TextBlockTextRenderer may disappear when it is resized. Sample to reproduce:

package
{
	import feathers.controls.Button;
	import feathers.controls.LayoutGroup;
	import feathers.controls.text.TextBlockTextRenderer;
	import feathers.layout.AnchorLayout;
	import feathers.layout.AnchorLayoutData;
	import feathers.themes.MetalWorksDesktopTheme;
	import flash.text.engine.ContentElement;
	import flash.text.engine.ElementFormat;
	import flash.text.engine.FontDescription;
	import flash.text.engine.GroupElement;
	import flash.text.engine.TextElement;
	import starling.core.Starling;
	import starling.events.Event;

	public class Test extends LayoutGroup
	{
		public function Test()
		{
			addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
		}

		protected function addedToStageHandler(event:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
			autoSizeMode = LayoutGroup.AUTO_SIZE_MODE_STAGE;
			new MetalWorksDesktopTheme();
			test1();
		}

		private function test1(): void
		{
			layout = new AnchorLayout();

			var fd: FontDescription = new FontDescription("Arial");
			var ef: ElementFormat = new ElementFormat(fd, 32, 0xffffff);

			var r1: TextBlockTextRenderer = new TextBlockTextRenderer();
			r1.elementFormat = ef;
			r1.wordWrap = true;
			r1.content = create_Content(ef);
			r1.layoutData = new AnchorLayoutData(100, 100, NaN, 100);
			addChild(r1);

			var r2: TextBlockTextRenderer = new TextBlockTextRenderer();
			r2.elementFormat = ef;
			r2.wordWrap = true;
			r2.content = create_Content(ef);
			r2.layoutData = new AnchorLayoutData(250, 100, 250, 100);//:cause bug
			//r2.layoutData = new AnchorLayoutData(250, 100, NaN, 100);//:cause no bug
			addChild(r2);

			var btn: Button = new Button();
			btn.label = "click me";
			btn.move(160, 20);
			addChild(btn);
			var nx: Number = 100;
			btn.addEventListener(Event.TRIGGERED, function(e: Event): void
			{
				nx = 400 - nx;
				Starling.juggler.tween(r1.layoutData, 0.6, { left: nx } );
				Starling.juggler.tween(r2.layoutData, 0.6, { left: nx } );
			});

		}

		private function create_Content(ef: ElementFormat): GroupElement
		{
			var v: Vector.<ContentElement> = new Vector.<ContentElement>();
			v.push(new TextElement("0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9", ef));
			return new GroupElement(v);
		}
	}
}

when you press the button - the second TextBlockTextRenderer mysteriously disappears.

@LicVit
Copy link

LicVit commented Dec 1, 2016

I can confirm it. The same happens for labels in List. The label width is calculated strangely. Only this resolves the issue: _list.layoutData = new AnchorLayoutData(0, 0, NaN, 0).
Seems like the bug has appeared in v.3.1 http://i.imgsafe.org/048d775102.png

@joshtynjala
Copy link
Member

joshtynjala commented Dec 1, 2016

@LicVit You are also using TextBlockTextRenderer and its content property?

@LicVit
Copy link

LicVit commented Dec 1, 2016

@joshtynjala I don't know exactly. Maybe it's another type of issue. I just set up list like this:`

_list = new List();
_list.isSelectable = false;
_list.layoutData = new VerticalLayoutData(100,100)
_list.clipContent = true;
_list.autoHideBackground = true;
_list.itemRendererProperties.layoutOrder = ItemRendererLayoutOrder.LABEL_ACCESSORY_ICON
_list.itemRendererProperties.iconPosition = RelativePosition.RIGHT
		
_list.itemRendererFactory = function():IListItemRenderer {
    const renderer:DefaultListItemRenderer = new DefaultListItemRenderer();
   renderer.defaultLabelProperties.wordWrap = true;
   return renderer;
};`

Full view class is here: http://licvit.by2.by/issues/ScreenTransformerDetails.as

@joshtynjala joshtynjala added the bug label Dec 1, 2016
@joshtynjala joshtynjala added this to the 3.2 milestone Dec 1, 2016
@joshtynjala
Copy link
Member

@Klug76 Thank you! I can reproduce, and I'm working on a fix.

@LicVit Based on my findings for the original issue reported by @Klug76, I think your issue is unrelated. It appears that the text in your item renderers is wrapping at a smaller width than expected, but I cannot say why. I tried to reproduce the issue, but I was unsuccessful. Please try to put together a simpler example that demonstrates the behavior, and open a new issue. Thanks!

@LicVit
Copy link

LicVit commented Dec 2, 2016

@joshtynjala I've resolved it. Looks like my themes (including Metal Works Mobile Theme) a bit outdated and incompatible with Feathers 3.1 and higher

upd. Since this commit MetalWorksMobileTheme displays labels in list properly with Feathers v3.1

@joshtynjala
Copy link
Member

@LicVit I think I figured out how to reproduce your issue thanks to some clues from another person. It should be fixed in commit 6f6c44e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants