1 <?xml version="1.0" encoding="utf-8"?>
3 xmlns:mx="http://www.adobe.com/2006/mxml"
4 xmlns:halcyon="net.systemeD.halcyon.*">
6 <mx:HBox horizontalGap="0">
7 <mx:ToggleButtonBar height="100%" dataProvider="{categoryStack}" direction="vertical"/>
8 <mx:ViewStack id="categoryStack" width="100%" height="100%"
9 creationComplete="setSelectedFeature(_selectedType);">
10 <mx:Repeater id="catRep" dataProvider="{MapFeatures.getInstance().categories}">
11 <mx:VBox label="{catRep.currentItem.name}">
12 <mx:TileList dataProvider="{catRep.currentItem.features}"
13 width="100%" height="100%" change="itemSelected(event);"
14 creationComplete="ensureSelection();">
17 <mx:VBox width="100" height="75"
18 horizontalScrollPolicy="off" verticalScrollPolicy="off"
19 horizontalAlign="center" verticalGap="0">
20 <mx:Image source="{data.image}" height="100%" verticalAlign="middle"/>
21 <mx:Text text="{data.name}"/>
31 <!-- mx:Label id="hoverInfo" text="Hover Info goes here"/>-->
34 import net.systemeD.halcyon.connection.*;
35 import net.systemeD.potlatch2.mapfeatures.*;
38 import mx.containers.*;
40 private var settingSelection:Boolean = false;
41 private var _selectedType:Feature;
43 [Bindable(event="selectedType")]
44 public function get selectedType():Feature {
48 private function itemSelected(event:Event):void {
49 _selectedType = Feature(TileList(event.currentTarget).selectedItem);
50 if ( !settingSelection )
51 dispatchEvent(new Event("selectedType"));
55 * Set the selected feature displayed in the selector.
57 * The tab is switched to the first category the feature
61 public function setSelectedFeature(feature:Feature):void {
62 _selectedType = feature;
64 // check whether stack built yet, if not we get called again when it's made
65 if ( categoryStack == null )
68 if ( feature != null ) {
69 var primaryCategory:Category = feature.findFirstCategory();
71 // set the tab to the selected item's category
72 categoryStack.selectedIndex = primaryCategory.index;
75 // finalise the item selection
80 * Sets the selected feature on each category page to the current
81 * value of _selectedType. If there is no selected feature then all
82 * panels selection will be blanked.
84 * This function does not change the selected category tab.
86 * Called both from setSelectedFeature, and category tab completion
87 * (so that newly created tabs work as expected)
89 private function ensureSelection():void {
90 settingSelection = true;
91 for (var i:Number = 0; i < categoryStack.numChildren; i++) {
92 var box:Box = Box(categoryStack.getChildAt(i));
93 if ( box == null || box.numChildren == 0 )
95 var tileList:TileList = TileList(box.getChildAt(0));
96 var category:Category = Category(tileList.getRepeaterItem());
97 var selected:Boolean = false;
98 for each( var catFeature:Feature in category.features ) {
99 if ( catFeature == _selectedType ) {
100 tileList.selectedItem = _selectedType;
105 tileList.selectedItem = null;
107 settingSelection = false;