Add an (optional) dnd property to icon elements to override the standard image in...
authorAndy Allan <gravitystorm@gmail.com>
Mon, 14 Feb 2011 18:57:22 +0000 (18:57 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Mon, 14 Feb 2011 18:57:22 +0000 (18:57 +0000)
net/systemeD/potlatch2/TagViewer.mxml
net/systemeD/potlatch2/mapfeatures/Feature.as
resources/features/pois/transport_airport.n.24.png [new file with mode: 0644]
resources/map_features.xml
resources/map_features/transport.xml

index 239ea6f..18d60df 100644 (file)
@@ -44,7 +44,7 @@
                                                                DragManager.doDrag(dragInitiator, dragSource, event, dragProxy);
                                                        }
                                                ]]></mx:Script>
-                                               <mx:Image id="foo" source="{data.image}" height="24" width="24" mouseMove="dragPOI(event, data.tags)" toolTip="{data.name}" />
+                                               <mx:Image id="foo" source="{data.dndimage}" height="24" width="24" mouseMove="dragPOI(event, data.tags)" toolTip="{data.name}" />
                                        </mx:VBox>
                                </mx:Component>
                        </mx:itemRenderer>
index 7466e2e..e47ba40 100644 (file)
@@ -107,16 +107,34 @@ package net.systemeD.potlatch2.mapfeatures {
                        return null;
         }
 
+        /** Returns the icon defined for the feature.
+        * This uses the "image" property of the feature's icon element. If no image property is defined, returns a default "missing icon".
+        */
         [Bindable(event="imageChanged")]
-        /** An icon for the feature (from icons[0]/@image). If none is defined, return default "missing icon". */
         public function get image():ByteArray {
+            return getImage();
+        }
+
+        /** Returns the drag+drop override-icon defined for the feature.
+        * This uses the "dnd" property of the feature's icon element, or if there is no override-icon it falls back to the standard image.
+        */
+        [Bindable(event="imageChanged")]
+        public function get dndimage():ByteArray {
+            return getImage(true);
+        }
+
+        /** Fetches the feature's image, as defined by the icon element in the feature definition.
+        * @param dnd if true, overrides the normal image and returns the one defined by the dnd property instead. */
+        private function getImage(dnd:Boolean = false):ByteArray {
             var icon:XMLList = _xml.icon;
             var imageURL:String = null;
             var img:ByteArray;
 
-            
-            if ( icon.length() > 0 && icon[0].hasOwnProperty("@image") )
+            if ( dnd && icon.length() > 0 && icon[0].hasOwnProperty("@dnd") ) {
+                imageURL = icon[0].@dnd;
+            } else if ( icon.length() > 0 && icon[0].hasOwnProperty("@image") ) {
                 imageURL = icon[0].@image;
+            }
 
             if ( imageURL != null ) {
                 img = CachedDataLoader.loadData(imageURL, imageLoaded);
diff --git a/resources/features/pois/transport_airport.n.24.png b/resources/features/pois/transport_airport.n.24.png
new file mode 100644 (file)
index 0000000..4e6bddb
Binary files /dev/null and b/resources/features/pois/transport_airport.n.24.png differ
index db6a319..b9108c1 100644 (file)
@@ -10,6 +10,7 @@ Quick documentation:
   category: [ctext] corresponding to category id
   icon
     @image: path to .png file
+    @dnd: path to optional dnd-specific-override .png file
     @background: colour spec
     @foreground: colour spec
     (general html goes here?) Variables substituted with ${ref}
index 4ae06e4..98ac5f7 100644 (file)
     
       <feature name="Airport">
         <category>transport</category>
-        <icon image="features/aeroway__aerodrome.png"/>
+        <icon image="features/aeroway__aerodrome.png" dnd="features/pois/transport_airport.n.24.png"/>
         <tag k="aeroway" v="aerodrome"/>
         <area/>
         <point/>
     
       <feature name="Airport terminal">
         <category>transport</category>
-        <icon image="features/aeroway__terminal.png"/>
+        <icon image="features/aeroway__terminal.png" dnd="features/pois/transport_airport_terminal.n.24.png"/>
         <tag k="aeroway" v="terminal"/>
         <area/>
         <point/>