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 239ea6f884b85f37a3a0c91c23d2a5aecca3b449..18d60dfaf6238d65ec6280416da92e5661f3770c 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 7466e2e76817e3c246249a91289db4f70f662341..e47ba408bdc55ff01e366a5653ee769abd43fa45 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 db6a319303faf3ca601f2d453d8129ee8263edce..b9108c1603094e82e0ffde8332f87fcca5a75635 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 4ae06e4a101d8537aaaba72b64dce278ef1b8656..98ac5f70403d450350345d6868ee0be21985141e 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/>