Skip to content

Conversation

elnabo
Copy link

@elnabo elnabo commented Jun 7, 2017

Add the possibility to put trees, which can be folded, in a ListView.

Tested on haxeui-html5 and haxeui-hxwidget (using Button instead of Label in the renderer see #137).

I'll try to add a screenshot later.

Example

class Main {

	public static function main() {

		Toolkit.theme = "native";
		var app = new HaxeUIApp();
		app.ready(function() {

			var main:Component = ComponentMacros.buildComponent("assets/ui/main.xml");
			var listview:ListView = main.findComponent("list");

			var subTransformer:IItemTransformer<String> = cast new NativeTypeTransformer();
	
			var dataSource = new ArrayDataSource<{label:String, data:DataSource<String>}>();
			var subDataSource = new ArrayDataSource<String>(subTransformer);
			subDataSource.add("1");
			subDataSource.add("2");
			dataSource.add({label:"a", data:subDataSource});

			subDataSource = new ArrayDataSource<String>(subTransformer);
			subDataSource.add("3");
			dataSource.add({label:"b", data:subDataSource});

			listview.itemRendererFunction = function(data:Dynamic) {
				return new ClassFactory<ItemRenderer>(
					cast Type.resolveClass("haxe.ui.core.TreeItemRenderer"),
					["data" => data]
				);
			}
			listview.dataSource = dataSource;
			app.addComponent(main);
			app.start();

		});
	}
}
<?xml version="1.0" encoding="utf-8"?>
<hbox id="main" width="100%" height="100%">
<style source="../css/main.css" />
    <listview id="list" width="30%" height="100%"/>

    <textarea id="chapter" width="70%" height="100%"/>
</hbox>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant