http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Snapshot.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/Snapshot.mxml b/Radii8Library/src/com/flexcapacitor/views/Snapshot.mxml new file mode 100644 index 0000000..66834bb --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/Snapshot.mxml @@ -0,0 +1,200 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:handlers="com.flexcapacitor.handlers.*" + xmlns:display="com.flexcapacitor.effects.display.*" + xmlns:bitmap="com.flexcapacitor.effects.bitmap.*" + xmlns:file="com.flexcapacitor.effects.file.*" + xmlns:core="com.flexcapacitor.effects.core.*" + xmlns:status="com.flexcapacitor.effects.status.*" + xmlns:popup="com.flexcapacitor.effects.popup.*" + xmlns:controls="com.flexcapacitor.controls.*" + + creationComplete="group1_creationCompleteHandler(event)" + width="400" + height="300" + > + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.utils.ClassUtils; + + import mx.events.FlexEvent; + public var radiate:Radiate = Radiate.instance; + + private var _target:DisplayObject; + + [Bindable] + public function get target():DisplayObject { + return _target; + } + + public function set target(value:DisplayObject):void { + _target = value as DisplayObject; + + if (rasterize.bitmapData) { + rasterize.bitmapData.dispose(); + rasterize.bitmapData = null; + } + + if (target) { + fileName = ClassUtils.getClassNameOrID(target); + } + else { + fileName = "Screenshot"; + } + + } + + + protected function group1_creationCompleteHandler(event:FlexEvent):void { + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler); + + if (radiate.target) { + target = radiate.target as DisplayObject; + } + + + } + + + protected function targetChangeHandler(event:RadiateEvent):void { + target = event.selectedItem as DisplayObject; + } + + protected function group1_pasteHandler(event:Event):void { + /*var clipboard:Clipboard = Clipboard.generalClipboard; + Radiate.log.info("Formats: " + clipboard.formats.join(",")); + Radiate.log.info("PASTED: " + clipboard.getData(ClipboardFormats.TEXT_FORMAT));*/ + /*var value:* = clipboard.getData(ClipboardFormats.BITMAP_FORMAT, ClipboardTransferMode.CLONE_ONLY); + var value1:* = clipboard.getData(ClipboardFormats.BITMAP_FORMAT, ClipboardTransferMode.CLONE_PREFERRED); + var value2:* = clipboard.getData(ClipboardFormats.BITMAP_FORMAT, ClipboardTransferMode.ORIGINAL_ONLY); + var value3:* = clipboard.getData(ClipboardFormats.BITMAP_FORMAT, ClipboardTransferMode.ORIGINAL_PREFERRED);*/ + } + + ]]> + </fx:Script> + + <fx:Declarations> + <fx:String id="fileName">screenshot</fx:String> + + <!-- TAKE SNAPSHOT --> + <handlers:EventHandler eventName="click" + target="{snapshotLabel}"> + + <display:Rasterize id="rasterize" target="{target}" source="{target}" + horizontalPadding="0" fillColor="#ff0000" absoluteBounds="true"> + <display:invalidTargetEffect> + <status:ShowStatusMessage message="Select a target"/> + </display:invalidTargetEffect> + <display:successEffect> + <status:ShowStatusMessage message="Snapshot captured"/> + </display:successEffect> + <display:errorEffect> + <status:ShowStatusMessage message="An error occurred. {rasterize.errorEvent}"/> + </display:errorEffect> + </display:Rasterize> + + + </handlers:EventHandler> + + + <!-- EXPORT SNAPSHOT --> + <handlers:EventHandler eventName="click" + target="{exportLabel}"> + + <bitmap:EncodeToPNG data="{rasterize.bitmapData}" /> + + <core:CopyPreviousToNext sourcePropertyName="byteArray" /> + + <file:PromptSaveAs fileName="{fileName}" + fileExtension="png" + targetAncestor="{this}"/> + + </handlers:EventHandler> + + <!-- PREVIEW --> + <handlers:EventHandler eventName="click" + target="{preview}"> + <popup:OpenPopUp id="openPopUp" + modalDuration="250" + showDropShadow="true" + popUpType="{ImagePreview}" + closeOnMouseDownInside="true" + data="{rasterize.bitmapData}"/> + </handlers:EventHandler> + + + <fx:Component className="ImagePreview"> + <s:ItemRenderer autoDrawBackground="false"> + <s:Rect width="100%" height="100%"> + <s:fill> + <s:SolidColor color="#ffffff"/> + </s:fill> + </s:Rect> + <s:Image source="{data}" top="5" right="5" left="5" bottom="5" /> + </s:ItemRenderer> + </fx:Component> + </fx:Declarations> + + <s:HGroup width="100%" typographicCase="uppercase" left="4" right="4"> + <s:Label id="snapshotLabel" + text="Capture Image" + fontSize="10" + buttonMode="true" + textAlign="center" + fontWeight="bold" + minWidth="{snapshotLabel.height}" + backgroundColor="#484848" + color="#eeeeee" + paddingBottom="4" paddingLeft="4" + paddingRight="4" paddingTop="4"/> + + <s:Label id="exportLabel" + text="Export" + buttonMode="true" + fontSize="10" + fontWeight="bold" + textAlign="center" + backgroundColor="#484848" + color="#eeeeee" + paddingBottom="4" paddingLeft="4" + paddingRight="4" paddingTop="4" + includeInLayout="{Boolean(rasterize.bitmapData)}" + visible="{Boolean(rasterize.bitmapData)}" + minWidth="{exportLabel.height}" + /> + + <s:Spacer width="100%" /> + + <!--<s:TextInput paste="group1_pasteHandler(event)"/>--> + <controls:ImageButton id="preview" + source="assets/images/components/Image.png" + includeInLayout="{Boolean(rasterize.bitmapData)}" + visible="{Boolean(rasterize.bitmapData)}" + /> +<!-- mouseUpEffect="{openPopUp}"--> + + </s:HGroup> + +</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Statistics.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/Statistics.mxml b/Radii8Library/src/com/flexcapacitor/views/Statistics.mxml new file mode 100644 index 0000000..6d1d3bc --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/Statistics.mxml @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:controls="com.flexcapacitor.controls.*" + xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:s="library://ns.adobe.com/flex/spark" + width="100%" + creationComplete="group1_creationCompleteHandler(event)" + > + + <!-- Width and height should be 100% --> + + <!--- If you change the current target then dispatch a selection event with the new target assigned to it --> + <fx:Metadata> + [Event(name="change", type="com.flexcapacitor.events.InspectorEvent")] + </fx:Metadata> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.events.InspectorEvent; + + import mx.core.UIComponent; + import mx.events.FlexEvent; + + + + private var _target:Object; + + public function get target():Object { + return _target; + } + + /** + * This is set automatically when a new target is selected + * This can be any type. You must disable this component if the + * type is not what you can process. + * */ + [Bindable] + public function set target(value:Object):void { + + // the target + if (value == null) { + _target = null; + enabled = false; + return; + } + else { + enabled = true; + } + + _target = value; + } + + /** + * Notify host components when we change the target + * */ + public function changeTarget(newTarget:Object):void { + var selectionChangeEvent:InspectorEvent = new InspectorEvent(InspectorEvent.CHANGE); + selectionChangeEvent.targetItem = newTarget; + dispatchEvent(selectionChangeEvent); + } + + + protected function group1_showHandler(event:FlexEvent):void { + trace("statistics panel. type = " + event.type); + } + + + //public var stats:Stats; + + /// UPDATE NEED TO ADD STATS IN LATER AS IT"S AN EXTERNAL CLASS + //public var stats:Stats; + public var stats:Object; + + protected function group1_creationCompleteHandler(event:FlexEvent):void { + stats = new Object(); + stats.width = container.width; + stats.height = container.height; + //container.addChild(stats); + container.addChild(stats as DisplayObject); + // UPDATE NEED TO ADD STATS IN LATER AS IT"S AN EXTERNAL CLASS + } + + override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { + super.updateDisplayList(unscaledWidth, unscaledHeight); + + stats.WIDTH = unscaledWidth; + stats.HEIGHT = unscaledHeight; + } + + + ]]> + </fx:Script> + + <fx:Declarations> + <!-- Place non-visual elements (e.g., services, value objects) here --> + </fx:Declarations> + + <mx:UIComponent id="container" + height="100%" width="100%"/> + + +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Tools.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/Tools.mxml b/Radii8Library/src/com/flexcapacitor/views/Tools.mxml new file mode 100644 index 0000000..fc35358 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/Tools.mxml @@ -0,0 +1,184 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + width="100" height="24" + + creationComplete="group1_creationCompleteHandler(event)"> + + + <!-- + + --> + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.tools.ITool; + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + import mx.events.FlexEvent; + + import spark.events.IndexChangeEvent; + + + /** + * + * */ + private var radiate:Radiate; + + /** + * + * */ + public var selectedTool:ITool; + + /** + * + * */ + protected function group1_creationCompleteHandler(event:FlexEvent):void { + radiate = Radiate.getInstance(); + radiate.addEventListener(RadiateEvent.TOOL_CHANGE, toolChangeHandler); + radiate.addEventListener(RadiateEvent.TOOLS_UPDATED, toolsUpdatedHandler); + + tools.dataProvider = Radiate.toolsDescriptions; + + if (radiate.selectedTool==null) { + tools.selectedIndex = 0; + updateTool(); + } + } + + /** + * + * */ + protected function toolChangeHandler(event:RadiateEvent):void + { + selectedTool = event.selectedItem as ITool; + } + + /** + * + * */ + protected function toolsUpdatedHandler(event:RadiateEvent):void + { + tools.dataProvider = Radiate.toolsDescriptions; + } + + /** + * + * */ + protected function tools_updateCompleteHandler(event:FlexEvent):void { + explicitHeight = tools.measuredHeight; + } + + /** + * Update tool. + * */ + protected function tools_changeHandler(event:IndexChangeEvent):void { + updateTool(); + } + + /** + * Update the tool + * */ + public function updateTool():void { + var item:ComponentDescription; + + radiate = Radiate.getInstance(); + + item = tools.selectedItem as ComponentDescription; + + if (item) { + radiate.setTool(item.instance as ITool); + } + } + + ]]> + </fx:Script> + + <s:List id="tools" + width="100%" + height="24" + minHeight="24" + labelField="name" + dragEnabled="false" + borderVisible="false" + interactionMode="mouse" + updateComplete="tools_updateCompleteHandler(event)" + change="tools_changeHandler(event)" + selectionColor="#C9C9C9" + rollOverColor="#D9D9D9" + > + <s:layout> + <s:TileLayout horizontalGap="2" verticalGap="2" /> + </s:layout> + + <s:itemRenderer> + <fx:Component> + <s:ItemRenderer width="24" height="24" minHeight="22" > + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + override public function set data(value:Object):void { + super.data = value; + var definition:ComponentDescription = value as ComponentDescription; + var path:String; + + + if (definition) { + if (definition.icon) { + iconImage.source = definition.icon; + } + else { + path = "assets/images/tools/" + definition.name + ".png"; + iconImage.source = path; + } + } + } + + protected function iconImage_ioErrorHandler(event:IOErrorEvent):void { + //iconImage.source = "assets/images/components/BorderContainer.png"; + } + + + ]]> + </fx:Script> + + <!--<s:Image id="iconImage" + contentLoader="{Radiate.contentCache}" + ioError="iconImage_ioErrorHandler(event)" + width="16" height="16"/>--> + <s:HGroup horizontalAlign="center" verticalAlign="middle"> + <s:Image id="iconImage" + contentLoader="{Radiate.contentCache}" + ioError="iconImage_ioErrorHandler(event)" + /> + </s:HGroup> + + </s:ItemRenderer> + </fx:Component> + + </s:itemRenderer> + </s:List> + +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/ZoomInspector.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/ZoomInspector.mxml b/Radii8Library/src/com/flexcapacitor/views/ZoomInspector.mxml new file mode 100644 index 0000000..79efc56 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/ZoomInspector.mxml @@ -0,0 +1,215 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:controls="com.flexcapacitor.graphics.*" + xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:filters="com.flexcapacitor.filters.*" + xmlns:c="com.flexcapacitor.controls.*" + + creationComplete="group1_creationCompleteHandler(event)" + > + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.tools.ITool; + import com.flexcapacitor.tools.Zoom; + import com.flexcapacitor.utils.supportClasses.ComponentDescription; + + + import mx.events.FlexEvent; + + import spark.events.IndexChangeEvent; + + public var radiate:Radiate; + + public var zoomTool:Zoom; + + public var toolDescription:ComponentDescription; + + /** + * Shows the show actual size button + * */ + [Bindable] + public var showActualSize:Boolean = true; + + protected function group1_creationCompleteHandler(event:FlexEvent):void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.SCALE_CHANGE, scaleChangedHandler, false, 0, true); + radiate.addEventListener(RadiateEvent.DOCUMENT_CHANGE, documentChangeHandler, false, 0, true); + + toolDescription = radiate.getToolByType(Zoom); + + zoomTool = toolDescription.instance as Zoom; + + + // temp to get reference + //if (!tool) tool = new Zoom(); + + updateTool(zoomTool); + } + + /** + * Update UI components to tool value + * */ + public function updateTool(tool:ITool):void { + var zoomValue:Number; + zoomValue = zoomTool.getScale(); + + updateZoomInComboBox(zoomValue); + } + + /** + * Zoom combo box change handler. Update zoom level. + * */ + protected function zoomComboBox_changeHandler(event:IndexChangeEvent):void { + + zoomTool.setScale(parseInt(zoomComboBox.selectedItem)/100); + } + + /** + * + * */ + protected function actualSize_clickHandler(event:MouseEvent):void { + + if (zoomTool) { + zoomTool.restoreDefaultScale(); + zoomComboBox.selectedItem = "100%"; + } + } + + /** + * Scale changed + * */ + protected function scaleChangedHandler(event:RadiateEvent):void { + var zoomValue:Number; + var zoomString:String; + + zoomValue = zoomTool.getScale(); + + updateZoomInComboBox(zoomValue); + } + + /** + * Format zoom value nicely. + * */ + public function updateZoomInComboBox(zoomValue:Number):void { + var zoomString:String; + + if (!isNaN(zoomValue)) { + + if (String(zoomValue*100).indexOf(".")!=-1) { + zoomString = Number(zoomValue*100).toFixed(1) + "%"; + } + else { + zoomString = Number(zoomValue*100) + "%"; + } + + if (zoomValue==1) { + zoomComboBox.selectedItem = "100%"; + } + else { + zoomComboBox.selectedItem = zoomString; + } + } + } + + /** + * Document changed + * */ + protected function documentChangeHandler(event:RadiateEvent):void { + // since we use this independently of the tool being selected we need to make sure + // the target application is set + // we'll move this later + var zoomValue:Number = zoomTool.getScale(); + + updateZoomInComboBox(zoomValue); + } + + /** + * Restore to 100% + * */ + protected function zoomComboBox_doubleClickHandler(event:MouseEvent):void { + + if (zoomTool) { + zoomTool.restoreDefaultScale(); + zoomComboBox.selectedItem = "100%"; + } + } + + ]]> + </fx:Script> + + <s:layout> + <s:HorizontalLayout paddingLeft="4" /> + </s:layout> + + <!--<s:CheckBox label="Scrub Zoom" />--> + <c:ImageButton id="actualSizeButton" + visible="{showActualSize}" + includeInLayout="{showActualSize}" + source="{Radii8LibraryAssets.actualSize}" + toolTip="Actual" + click="actualSize_clickHandler(event)" + height="100%" + /> + + <!--<s:Button id="fitSize" label="Fit Size" + visible="{showActualSize}" + includeInLayout="{showActualSize}" + click="actualSize_clickHandler(event)"/>--> + + <s:ComboBox id="zoomComboBox" + width="80" + height="100%" + focusAlpha="0" + selectedIndex="8" + change="zoomComboBox_changeHandler(event)" + openOnInput="true" arrowKeysWrapFocus="true" + doubleClickEnabled="true" + doubleClick="zoomComboBox_doubleClickHandler(event)" + > + <s:layout> + <s:VerticalLayout gap="0" + horizontalAlign="contentJustify" + requestedRowCount="10" /> + </s:layout> + <s:dataProvider> + <s:ArrayList> + <fx:String>600%</fx:String> + <fx:String>500%</fx:String> + <fx:String>400%</fx:String> + <fx:String>300%</fx:String> + <fx:String>200%</fx:String> + <fx:String>175%</fx:String> + <fx:String>150%</fx:String> + <fx:String>125%</fx:String> + <fx:String>100%</fx:String> + <fx:String>75%</fx:String> + <fx:String>50%</fx:String> + <fx:String>25%</fx:String> + <fx:String>10%</fx:String> + </s:ArrayList> + </s:dataProvider> + </s:ComboBox> + +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/editors/PropertyGridEditor.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/editors/PropertyGridEditor.mxml b/Radii8Library/src/com/flexcapacitor/views/editors/PropertyGridEditor.mxml new file mode 100644 index 0000000..fa0cd34 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/editors/PropertyGridEditor.mxml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:DefaultGridItemEditor xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + override public function set value(newValue:Object):void { + textArea.text = newValue as String; + } + + override public function get value():Object { + return textArea.text; + } + + override public function setFocus():void { + textArea.setFocus(); + } + ]]> + </fx:Script> + +</s:DefaultGridItemEditor> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/BasicBackgroundStyles.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/BasicBackgroundStyles.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/BasicBackgroundStyles.mxml new file mode 100644 index 0000000..8b8601a --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/BasicBackgroundStyles.mxml @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + + implements="com.flexcapacitor.views.IInspector" + styleName="inspectablePanel"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.model.StyleMetaData; + import com.flexcapacitor.utils.ClassUtils; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + radiate.removeEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + public function update():void { + var backgroundColor:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "backgroundColor"); + var backgroundAlpha:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "backgroundAlpha"); + + if (!backgroundColor) { + backgroundColor = ClassUtils.getMetaDataOfStyle(target, "contentBackgroundColor"); + } + + if (!backgroundAlpha) { + backgroundAlpha = ClassUtils.getMetaDataOfStyle(target, "contentBackgroundAlpha"); + } + + if (backgroundColor) { + backgroundColorRenderer.data = backgroundColor; + } + + if (backgroundAlpha) { + backgroundAlphaRenderer.data = backgroundAlpha; + } + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + + ]]> + </fx:Script> + + <s:layout> + <s:VerticalLayout /> + </s:layout> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Background Color" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ColorPickerRenderer id="backgroundColorRenderer" height="24" includeCopyIcon="false"/> + </s:HGroup> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Background Alpha" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="backgroundAlphaRenderer" height="24" /> + </s:HGroup> +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/BorderStyles.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/BorderStyles.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/BorderStyles.mxml new file mode 100644 index 0000000..a2f55f7 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/BorderStyles.mxml @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + xmlns:local="*" + + implements="com.flexcapacitor.views.IInspector" + styleName="inspectablePanel" + > + <!-- + + ArgumentError: Error #2004: One of the parameters is invalid. + be sure to add the style styleName="inspectablePanel" + + --> + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.model.StyleMetaData; + import com.flexcapacitor.utils.ClassUtils; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + radiate.removeEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + public function update():void { + var cornerRadius:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "cornerRadius"); + borderWeightRenderer.data = ClassUtils.getMetaDataOfStyle(target, "borderWeight"); + borderColorRenderer.data = ClassUtils.getMetaDataOfStyle(target, "borderColor"); + borderAlphaRenderer.data = ClassUtils.getMetaDataOfStyle(target, "borderAlpha"); + + + if (cornerRadius) { + cornerRadiusRenderer.data = cornerRadius; + } + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + ]]> + </fx:Script> + + <fx:Declarations> + + </fx:Declarations> + + <s:layout> + <s:VerticalLayout /> + </s:layout> + + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Corner Radius" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="cornerRadiusRenderer" height="24" /> + </s:HGroup> + + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Border Weight" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="borderWeightRenderer" height="24" /> + </s:HGroup> + + + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Border Alpha" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="borderAlphaRenderer" height="24" /> + </s:HGroup> + + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Border Color" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ColorPickerRenderer id="borderColorRenderer" height="24" includeCopyIcon="false"/> + </s:HGroup> + +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/FontStyles.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/FontStyles.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/FontStyles.mxml new file mode 100644 index 0000000..bae7a4d --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/FontStyles.mxml @@ -0,0 +1,311 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + implements="com.flexcapacitor.views.IInspector" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + styleName="inspectablePanel"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.model.StyleMetaData; + import com.flexcapacitor.utils.ClassUtils; + + + import mx.core.FlexGlobals; + import mx.core.UIComponent; + import mx.managers.ISystemManager; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + public var fonts:Array; + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + radiate.removeEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + + public function update():void { + var fontFamilyStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "fontFamily"); // font + var fontSizeStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "fontSize"); // size + var fontWeightStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "fontWeight"); // bold + var fontStyleStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "fontStyle"); // italic + var textDecorationStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "textDecoration"); // underline + var colorStyle:StyleMetaData = ClassUtils.getMetaDataOfStyle(target, "color"); // color + + if (fonts==null) { + fonts = getFontInformationDetails(target); + } + + fontFamilyStyle.enumeration = fonts; + //fontsRenderer.data = data; + fontsRenderer.data = fontFamilyStyle; + fontSizeRenderer.data = fontSizeStyle; + fontWeightRenderer.data = fontWeightStyle; + fontStyleRenderer.data = fontStyleStyle; + colorRenderer.data = colorStyle; + } + + + + /** + * Gets details about the embedded fonts + * */ + public function getFontInformationDetails(target:Object, showDeviceFontInformation:Boolean = true):Array { + var component:UIComponent = target as UIComponent; + var systemManager:ISystemManager = component ? component.systemManager : null; + var dictionary:Dictionary = new Dictionary(true); + var fontList:Array = Font.enumerateFonts(showDeviceFontInformation); + var length:int = fontList.length; + var output:String = ""; + var fontObject:Object; + var paddedName:String; + var name:String; + var font:Font; + + + if (systemManager==null && FlexGlobals.topLevelApplication.systemManager) { + output += systemManager==null ? "Warning: Target system manager is null. Using FlexGlobals top level application system manager\n" : ""; + systemManager = FlexGlobals.topLevelApplication.systemManager; + } + else if (systemManager==null) { + output += "Could not find system manager"; + return []; + } + + for (var i:int;i<length;i++) + { + font = Font(fontList[i]); + name = font.fontName; + if (dictionary[name]==1) continue; + dictionary[name] = 1; + + paddedName = name; //padString(name, minimumStyleNamePadding); + fontObject = getFontFamilyEmbedded(name, systemManager); + + //output += prespace + paddedName; + + if (fontObject.embeddedCFF.length>0) { + output += "Embedded CFF: " + fontObject.embeddedCFF.join(", "); + } + + if (fontObject.embedded.length>0) { + if (fontObject.embeddedCFF.length>0) { + output+= "; "; + output+= "Embedded : "; + } + else { + output+= "Embedded: "; + } + output += fontObject.embedded.join(", "); + } + + output += "\n"; + + } + + + return fontList; + } + + + + /** + * Returns an object that contains an array of embedding information for the font with the given name. + * Includes embedded and embeddedCFF information. If null then the font and that style of the font + * are not embedded.<br/><br/> + * Example, <br/> + * <pre> + * var object:Object = getFontFamilyEmbedded("MyFont", myButton.systemManager); + * trace(object); // {embedded:[regular, italic], embeddedCFF:[regular, bold, italic, boldItalic]} + * </pre> + **/ + public function getFontFamilyEmbedded(name:String, systemManager:ISystemManager):Object { + var textFormat:TextFormat = new TextFormat(); + var fontDescription:String = ""; + var embeddedCFF:Array = []; + var embedded:Array = []; + var boldItalic:Boolean; + var regular:Boolean; + var italic:Boolean; + var bold:Boolean; + + textFormat.font = name; + + // check for regular + regular = systemManager.isFontFaceEmbedded(textFormat); + if (regular) { + fontDescription = "regular"; + + if (isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embeddedCFF.push(fontDescription); + } + if (!isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embedded.push(fontDescription); + } + } + + // check for bold + textFormat.bold = true; + bold = systemManager.isFontFaceEmbedded(textFormat); + if (bold) { + fontDescription = "bold"; + if (isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embeddedCFF.push(fontDescription); + } + if (!isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embedded.push(fontDescription); + } + } + + // check for bold and italic + textFormat.italic = true; + boldItalic = systemManager.isFontFaceEmbedded(textFormat); + if (boldItalic) { + fontDescription = "boldItalic"; + if (isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embeddedCFF.push(fontDescription); + } + if (!isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embedded.push(fontDescription); + } + } + + // check for italic + textFormat.bold = false; + italic = systemManager.isFontFaceEmbedded(textFormat); + if (italic) { + fontDescription = "italic"; + if (isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embeddedCFF.push(fontDescription); + } + if (!isFontFaceEmbeddedCFF(textFormat, systemManager)) { + embedded.push(fontDescription); + } + } + + // there's probably alot of optimization that could go into this call + // but for now we are using this + + return {embedded:embedded, embeddedCFF:embeddedCFF}; + } + + + + /** + * Checks if font is embedded and is also embeddedCFF. + * Does not run all methods system manager function runs. + */ + public function isFontFaceEmbeddedCFF(textFormat:TextFormat, systemManager:ISystemManager):Boolean + { + var fontName:String = textFormat.font; + var bold:Boolean = textFormat.bold; + var italic:Boolean = textFormat.italic; + + var fontList:Array = Font.enumerateFonts(); + + var n:int = fontList.length; + for (var i:int = 0; i < n; i++) + { + var font:Font = Font(fontList[i]); + if (font.fontName == fontName) + { + var style:String = "regular"; + if (bold && italic) + style = "boldItalic"; + else if (bold) + style = "bold"; + else if (italic) + style = "italic"; + + if (font.fontStyle == style ) { + if (font.fontType=="embeddedCFF") { + return true; + } + else { + return false; + } + } + } + } + + return false; + + } + + ]]> + </fx:Script> + + <s:layout> + <s:VerticalLayout /> + </s:layout> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Font Family" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ComboBoxRenderer id="fontsRenderer" height="24" labelField="fontName" + valueIsField="true" fieldIsValue="true" + minWidth="180"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Font Weight" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:DropDownListRenderer id="fontWeightRenderer" height="24" /> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Font Size" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="fontSizeRenderer" height="24" showClearButton="true"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Font Style" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:DropDownListRenderer id="fontStyleRenderer" height="24"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Color" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ColorPickerRenderer id="colorRenderer" height="24" includeCopyIcon="false"/> + </s:HGroup> +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/Identity.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/Identity.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/Identity.mxml new file mode 100644 index 0000000..098a5b4 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/Identity.mxml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + implements="com.flexcapacitor.views.IInspector" + + styleName="inspectablePanel"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.utils.ClassUtils; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + radiate.removeEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + public function update():void { + data = ClassUtils.getMetaDataOfProperty(target, "id"); + textRenderer.data = data; + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + + ]]> + </fx:Script> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Identity" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:TextRenderer id="textRenderer" height="24"/> + </s:HGroup> +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/Image.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/Image.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/Image.mxml new file mode 100644 index 0000000..0e50baf --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/Image.mxml @@ -0,0 +1,117 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + implements="com.flexcapacitor.views.IInspector" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + styleName="inspectablePanel" + width="100%"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.utils.ClassUtils; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + public function update():void { + //var data:Object = ClassUtils.getMetaDataOfProperty(target, "source"); + sourceRenderer.data = ClassUtils.getMetaDataOfProperty(target, "source"); + alphaRenderer.data = ClassUtils.getMetaDataOfProperty(target, "alpha"); + smoothRenderer.data = ClassUtils.getMetaDataOfProperty(target, "smooth"); + scaleModeRenderer.data = ClassUtils.getMetaDataOfProperty(target, "scaleMode"); + fillModeRenderer.data = ClassUtils.getMetaDataOfProperty(target, "fillMode"); + contentLoaderGroupRenderer.data = ClassUtils.getMetaDataOfProperty(target, "contentLoaderGrouping"); + clearOnLoadRenderer.data = ClassUtils.getMetaDataOfProperty(target, "clearOnLoad"); + + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + + ]]> + </fx:Script> + + <s:layout> + <s:VerticalLayout /> + </s:layout> + <!--<s:Image scaleMode="" alpha="" smooth="" clearOnLoad="" contentLoader="" fillMode="" + enableLoadingState="" backgroundAlpha="" backgroundColor="" + smoothingQuality="" skinClass="" />--> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Source" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:TextRenderer id="sourceRenderer" height="24" width="100%"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Alpha" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:NumberRenderer id="alphaRenderer" height="24" /> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Smooth" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:BooleanRenderer id="smoothRenderer" height="24" showClearButton="true"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Scale Mode" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ComboBoxRenderer id="scaleModeRenderer" height="24"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Fill Mode" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:ComboBoxRenderer id="fillModeRenderer" height="24"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Content Grouping" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:TextRenderer id="contentLoaderGroupRenderer" height="24"/> + </s:HGroup> + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Clear on Load" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:BooleanRenderer id="clearOnLoadRenderer" height="24"/> + </s:HGroup> +</s:Group> http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/inspectors/TextInspector.mxml ---------------------------------------------------------------------- diff --git a/Radii8Library/src/com/flexcapacitor/views/inspectors/TextInspector.mxml b/Radii8Library/src/com/flexcapacitor/views/inspectors/TextInspector.mxml new file mode 100644 index 0000000..3bfdcd1 --- /dev/null +++ b/Radii8Library/src/com/flexcapacitor/views/inspectors/TextInspector.mxml @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +--> +<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + implements="com.flexcapacitor.views.IInspector" + xmlns:renderers="com.flexcapacitor.views.renderers.*" + styleName="inspectablePanel"> + + <fx:Script> + <![CDATA[ + import com.flexcapacitor.controller.Radiate; + import com.flexcapacitor.events.RadiateEvent; + import com.flexcapacitor.model.AccessorMetaData; + import com.flexcapacitor.utils.ClassUtils; + + public var radiate:Radiate; + public var target:Object; + public var data:Object; + + public var fonts:Array; + + public function activate():void { + radiate = Radiate.getInstance(); + + radiate.addEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange, false, 0, true); + radiate.addEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler, false, 0, true); + + if (radiate.target) { + target = radiate.target; + } + + update(); + } + + public function deactivate():void { + radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, handleTargetChange); + radiate.removeEventListener(RadiateEvent.PROPERTY_CHANGED, propertyChangeHandler); + } + + protected function handleTargetChange(event:RadiateEvent):void { + if (target!=event.selectedItem) { + target = event.selectedItem; + update(); + } + } + + public function update():void { + var textAccessor:AccessorMetaData = ClassUtils.getMetaDataOfProperty(target, "text"); + + textRenderer.data = textAccessor; + } + + protected function propertyChangeHandler(event:RadiateEvent):void { + callLater(update); + } + + ]]> + </fx:Script> + + <s:layout> + <s:VerticalLayout /> + </s:layout> + + <s:HGroup width="100%" verticalAlign="baseline" gap="{getStyle('gap')}"> + <s:Label text="Text" styleName="inspectablePanelLabel" width="{getStyle('labelWidth')}"/> + <renderers:TextRenderer id="textRenderer" height="24" /> + </s:HGroup> +</s:Group>