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

Adding support for Tree in Listview #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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