You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2014/09/03 02:17:46 UTC
[13/30] Radii8 code base as accepted by IP Clearance
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/LayersInspector.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/LayersInspector.mxml b/Radii8Library/src/com/flexcapacitor/views/LayersInspector.mxml
new file mode 100644
index 0000000..c06f9e3
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/LayersInspector.mxml
@@ -0,0 +1,693 @@
+<?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:views="com.flexcapacitor.views.*"
+ xmlns:c="com.flexcapacitor.controls.*"
+
+ width="200" height="100%"
+ creationComplete="creationCompleteHandler(event)"
+ implements="com.flexcapacitor.views.IInspector"
+ >
+
+ <fx:Script>
+ <![CDATA[
+ import com.flexcapacitor.controller.Radiate;
+ import com.flexcapacitor.events.RadiateEvent;
+ import com.flexcapacitor.model.IDocument;
+ import com.flexcapacitor.utils.DisplayObjectUtils;
+ import com.flexcapacitor.utils.supportClasses.ComponentDescription;
+ import com.flexcapacitor.views.renderers.LayersRenderer;
+ import com.flexcapacitor.views.supportClasses.LayersDataDescriptor;
+
+ import mx.collections.ArrayCollection;
+ import mx.core.mx_internal;
+ import mx.events.DragEvent;
+ import mx.events.FlexEvent;
+ import mx.events.ListEvent;
+ import mx.events.TreeEvent;
+ import mx.states.AddItems;
+
+ import spark.components.Application;
+
+ private var rootDisplayObject:DisplayObject;
+ private var displayList:Array = [];
+ private var radiate:Radiate;
+ private var designDocument:IEventDispatcher;
+
+ [Bindable]
+ public var components:ArrayCollection = new ArrayCollection();
+
+ private var _target:*;
+
+ public function get target():* {
+ return _target;
+ }
+
+ [Bindable]
+ public function set target(value:*):void {
+ _target = value;
+ }
+
+ public function activate():void {
+ radiate = Radiate.instance;
+ updateComponentDisplayList();
+
+ radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler, false, 0, true);
+ radiate.addEventListener(RadiateEvent.DOCUMENT_CHANGE, documentChangeHandler, false, 0, true);
+ radiate.addEventListener(RadiateEvent.ADD_ITEM, addItemChangeHandler, false, 0, true);
+ radiate.addEventListener(RadiateEvent.MOVE_ITEM, addItemChangeHandler, false, 0, true);
+ radiate.addEventListener(RadiateEvent.REMOVE_ITEM, addItemChangeHandler, false, 0, true);
+
+ if (radiate.target) {
+ updateTarget(radiate.target);
+ }
+ }
+
+ public function deactivate():void {
+ if (radiate) {
+
+ radiate.removeEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler);
+ radiate.removeEventListener(RadiateEvent.DOCUMENT_CHANGE, documentChangeHandler);
+ radiate.removeEventListener(RadiateEvent.ADD_ITEM, addItemChangeHandler);
+ radiate.removeEventListener(RadiateEvent.MOVE_ITEM, addItemChangeHandler);
+ radiate.removeEventListener(RadiateEvent.REMOVE_ITEM, addItemChangeHandler);
+
+ target = null;
+ }
+ }
+
+ /**
+ * Listen for any changes to the display list
+ * */
+ protected function creationCompleteHandler(event:FlexEvent):void {
+ /*radiate = Radiate.instance;
+ updateComponentDisplayList();
+
+ radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler);
+ radiate.addEventListener(RadiateEvent.DOCUMENT_CHANGE, documentChangeHandler);
+ radiate.addEventListener(RadiateEvent.ADD_ITEM, addItemChangeHandler);
+ radiate.addEventListener(RadiateEvent.MOVE_ITEM, addItemChangeHandler);
+ radiate.addEventListener(RadiateEvent.REMOVE_ITEM, addItemChangeHandler);
+
+ if (radiate.target) {
+ updateTarget(radiate.target);
+ }
+ */
+ }
+
+
+ /**
+ * Found on blog by Flex SDK developer (source).
+ * Not used. For reference.
+ */
+ public function sortDisplayByDepth(item:Object, parentItem:Object = null, depth:int = 0):void {
+
+
+ if (displayList.length <= depth) {
+ displayList.push(new ArrayCollection());
+ }
+
+
+ if ("numElements" in item) {
+ for (var i:int = 0; i < item.numElements; i++) {
+ var child:Object = item.getElementAt(i);
+ sortDisplayByDepth(child, parentItem, depth + 1);
+ displayList[depth].push(child);
+ }
+ }
+
+ }
+
+
+ private function labelFunction(data:Object):String {
+ return data.name;
+ }
+
+ /**
+ * When the target changes reselect it
+ * */
+ protected function targetChangeHandler(event:RadiateEvent):void {
+ updateTarget(event.selectedItem);
+ }
+
+ /**
+ *
+ * */
+ public function updateTarget(selectedItem:Object):void {
+ var item:ComponentDescription = displayListTree.selectedItem as ComponentDescription;
+ var collection:ArrayCollection = displayListTree.dataProvider as ArrayCollection;
+ var rootApplicationDescription:ComponentDescription;
+ var targetDescription:ComponentDescription;
+ var parent:ComponentDescription;
+
+ target = selectedItem;
+
+ if (item && target!=item.instance) {
+ //updateComponentDisplayList();
+ }
+
+ if (collection.length==0) {
+ updateComponentDisplayList();
+ collection = displayListTree.dataProvider as ArrayCollection;
+ }
+
+ if (target && collection.length) {
+ rootApplicationDescription = collection.getItemAt(0) as ComponentDescription;
+
+ if (rootApplicationDescription) {
+ targetDescription = DisplayObjectUtils.getTargetInComponentDisplayList(target, rootApplicationDescription);
+
+ if (targetDescription) {
+
+ parent = targetDescription.parent;
+
+ while (parent) {
+
+ // open item if not open
+ if (!displayListTree.isItemOpen(parent)) {
+ displayListTree.expandItem(parent, true, false, false);
+ displayListTree.validateNow();
+ }
+
+ parent = parent.parent;
+ }
+
+
+ // NOTE: IMPORTANT: READ: the open items can't be reassigned references. they have to be actual items
+ // ALSO we are resetting the dataProvider so it's not going to find the items
+ for (var i:int;i<length;i++) {
+ //displayListTree.expandItem(openItems[i], true, false, false);
+ //trace("expanding");
+ }
+
+ displayListTree.selectedItem = targetDescription;
+ }
+ }
+ }
+
+ //openAllItems();
+ updateTreeHeight();
+ scrollIntoView();
+ }
+
+ /**
+ * Open all items
+ * */
+ public function openAllItems():void {
+ var item:ComponentDescription = displayListTree.selectedItem as ComponentDescription;
+ var collection:ArrayCollection = displayListTree.dataProvider as ArrayCollection;
+ var rootApplicationDescription:ComponentDescription;
+ var targetDescription:ComponentDescription;
+ var parent:ComponentDescription;
+
+ if (item && target!=item.instance) {
+ //updateComponentDisplayList();
+ }
+
+ if (collection.length==0) {
+ collection = displayListTree.dataProvider as ArrayCollection;
+ }
+
+ if (collection.length<1) return;
+ rootApplicationDescription = collection.getItemAt(0) as ComponentDescription;
+
+ for (var i:int;i<rootApplicationDescription.children.length;i++) {
+ displayListTree.expandChildrenOf(rootApplicationDescription.children[i], true);
+ displayListTree.validateNow();
+ }
+
+ }
+
+ /**
+ * Close all items
+ * */
+ public function closeAllItems():void {
+ var item:ComponentDescription = displayListTree.selectedItem as ComponentDescription;
+ var collection:ArrayCollection = displayListTree.dataProvider as ArrayCollection;
+ var rootApplicationDescription:ComponentDescription;
+ var targetDescription:ComponentDescription;
+ var parent:ComponentDescription;
+
+ if (item && target!=item.instance) {
+ //updateComponentDisplayList();
+ }
+
+ if (collection.length==0) {
+ collection = displayListTree.dataProvider as ArrayCollection;
+ }
+
+ if (collection.length<1) return;
+ rootApplicationDescription = collection.getItemAt(0) as ComponentDescription;
+
+ for (var i:int;i<rootApplicationDescription.children.length;i++) {
+ displayListTree.expandChildrenOf(rootApplicationDescription.children[i], false);
+ displayListTree.validateNow();
+ }
+
+ }
+
+ /**
+ *
+ * */
+ protected function documentChangeHandler(event:Event):void {
+ if (designDocument!=radiate.selectedDocument) {
+ updateComponentDisplayList(false);
+ }
+ }
+
+ /**
+ * Select target
+ * */
+ protected function displayListTree_changeHandler(event:ListEvent):void {
+ var item:ComponentDescription = displayListTree.selectedItem as ComponentDescription;
+
+ if (item) {
+ radiate.setTarget(item.instance as IEventDispatcher, true);
+ }
+ /*
+ if (!preventChange) {
+ }
+ else {
+ displayListTree.selectable
+ }
+
+ preventChange = false; */
+ }
+
+ /**
+ * Recreate the display list and open all items.
+ * */
+ private function updateComponentDisplayList(preserveOpenItems:Boolean = true):void {
+ var openItems:Object = displayListTree.openItems;
+ var document:IDocument = radiate.selectedDocument;
+ var display:Object;
+ var length:int;
+
+
+ if (!document) return;
+
+ // we need to create a list of the instances of open items
+ // componentDescription.instance not componentDescription
+
+ // we could check for the target and update that branch
+ display = document.componentDescription;
+ displayListTree.dataProvider = display;
+
+ //
+ //DisplayObjectUtils.walkDownTree(application as IVisualElement, traceTree);
+
+
+ if (preserveOpenItems) {
+ displayListTree.validateNow();
+
+ /* for each (var item:ComponentDescription in openItems) {
+ displayListTree.expandItem(item, true, false, false);
+ //trace("expanding");
+ }
+ */
+ length = openItems.length;
+
+ // NOTE: IMPORTANT: READ: the open items can't be reassigned references. they have to be actual items
+ // ALSO we are resetting the dataProvider so it's not going to find the items if we do that
+ for (var i:int;i<length;i++) {
+ if (!displayListTree.isItemOpen(openItems[i])) {
+ displayListTree.expandItem(openItems[i], true, false, false);
+ }
+ //trace("expanding");
+ }
+ }
+ }
+
+ public function traceTree(element:Object):void {
+ //trace("element="+NameUtil.getUnqualifiedClassName(element));
+ }
+
+ /**
+ *
+ * */
+ private function findTargetInDisplayList(target:Object, parentItem:ComponentDescription, depth:int = 0):ComponentDescription {
+ var length:int = parentItem.children ? parentItem.children.length : 0;
+ var possibleItem:ComponentDescription;
+ var item:ComponentDescription;
+ var itemFound:Boolean;
+
+ for (var i:int; i < length; i++) {
+ item = parentItem.children.getItemAt(i) as ComponentDescription;
+
+ if (item && item.instance==target) {
+ itemFound = true;
+ break;
+ }
+
+ if (item.children) {
+ possibleItem = findTargetInDisplayList(target, item, depth + 1);
+
+ if (possibleItem) {
+ itemFound = true;
+ item = possibleItem;
+ break;
+ }
+ }
+
+ }
+
+ if (itemFound) return item;
+
+ return null;
+ }
+
+ /**
+ * Add item handler
+ * */
+ protected function addItemChangeHandler(event:RadiateEvent):void {
+ updateComponentDisplayList();
+ }
+
+
+ /**
+ * Move item handler
+ * */
+ protected function moveItemChangeHandler(event:RadiateEvent):void {
+ updateComponentDisplayList();
+ }
+
+ /**
+ * Item open handler
+ * */
+ protected function displayListTree_itemOpenHandler(event:TreeEvent):void {
+ updateTreeHeight()
+ }
+
+ /**
+ *
+ * */
+ public function getTotalRowCount(item:ComponentDescription, count:int = 0):int {
+
+ if (item.children && item.children.length>0) {
+ // NOTE: IMPORTANT: READ: the open items can't be reassigned references. they have to be actual items
+ // ALSO we are resetting the dataProvider so it's not going to find the items if we do that
+ for (var i:int;i<item.children.length;i++) {
+ count++;
+ if (displayListTree.isItemOpen(item.children[i])) {
+ count = getTotalRowCount(item.children[i] as ComponentDescription, count);
+ }
+ }
+ }
+ return count;
+ }
+
+ /**
+ * Resize the tree to be as high as all open items
+ * */
+ public function updateTreeHeight():void {
+ var newHeight:int = displayListTree.rowCount * displayListTree.rowHeight;
+ var numChildren:int = displayListTree.numChildren;
+ var openItems:Object = displayListTree.openItems;
+ var openItemsLength:int = displayListTree.openItems.length;
+ var dataProvider:Object = displayListTree.dataProvider;
+ var dataProviderLength:int = displayListTree.dataProvider.length;
+ var item:ComponentDescription;
+ var count:int = 2; // application plus one for easier drop on last row
+
+ var newCount:int = getTotalRowCount(dataProvider[0] as ComponentDescription, count);
+
+ newHeight = newCount * displayListTree.rowHeight;
+ // ArgumentError: Error #2004: One of the parameters is invalid.
+ // at flash.display::Graphics/drawRect()
+ //displayListTree.setActualSize(NaN, newHeight);
+ //displayListTree.height = newHeight;
+ displayListTree.explicitHeight = newHeight;
+ }
+
+ // THIS IS ALL TO HANDLE SCROLLING INSIDE ANOTHER SCROLLER THAT HAS TOUCH INTERACTION
+ // SPARK COMPONENTS DON'T HAVE THIS PROBLEM
+ private var mouseDownLocation:int;
+ public var preventChange:Boolean;
+
+ protected function displayListTree_mouseDownHandler(event:MouseEvent):void {
+ mouseDownLocation = event.stageY;
+ stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler, false, 0, true);
+ stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 0, true);
+ }
+
+ protected function mouseMoveHandler(event:MouseEvent):void {
+
+ var diff:int = Math.abs(event.stageY - mouseDownLocation);
+
+ if (diff>10) {
+ displayListTree.selectable = false;
+ }
+ }
+
+ protected function mouseUpHandler(event:MouseEvent):void {
+ stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
+ stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+ displayListTree.selectable = true;
+ }
+
+ protected function displayListTree_itemCloseHandler(event:TreeEvent):void {
+ updateTreeHeight();
+ }
+
+ private function scrollIntoView():void {
+
+ if (displayListTree.selectedIndex>-1) {
+ displayListTree.scrollToIndex(displayListTree.selectedIndex);
+ }
+ }
+
+ /**
+ *
+ * */
+ protected function displayListTree_dragDropHandler(event:DragEvent):void {
+ //Radiate.log.info("Drag drop handler");
+ event.draggedItem;
+ event.target;
+ event.relatedObject;
+
+ /*
+ Pay attention at mx_internal namespace :
+ Behaviour could change in the next flex version.
+ Drop data structure.
+ _dropData = {
+ parent: parent,
+ index: index,
+ localX: event.localX,
+ localY: event.localY,
+ emptyFolder: emptyFolder,
+ rowHeight: rowHeight,
+ rowIndex: rowNum };
+ */
+ var dropData:Object = displayListTree.mx_internal::_dropData;
+ var dropParent:Object = dropData.parent;
+ var dropIndex:int = dropData.index;
+ var rowIndex:int = dropData.rowIndex;
+ var draggedElement:Object = (event.dragSource.dataForFormat("treeItems") as Array)[0];
+ var draggedElementParent:Object = draggedElement.parent;
+ var canDragOutOfParent:Boolean = !displayListTree.showRoot;
+ var currentIndex:int;
+
+ if (!canDragOutOfParent &&
+ draggedElementParent != dropParent) {
+
+ // element is an item and parent is different => can not drop
+ event.preventDefault();
+ displayListTree.hideDropFeedback(event);
+ return;
+ }
+
+ // you can also play with
+ //var dropIndex:int = displayListTree.calculateDropIndex(event);
+ //var itemIndex:int = displayListTree.getItemIndex(dropIndex);
+
+ // but it is a little more complicated to find
+ // the real parent because we haven't drop indicator
+ // information (child or parent position).
+
+ // I did not use xml element id but it is also possible
+ // parent.id != draggedElement.parent().id
+
+ // some reason there is a bug when on the application
+ // we have to subtract one from the drop index if it's lower than it's current index
+ if (dropParent &&
+ draggedElement.parent == dropParent &&
+ dropParent.instance is Application) {
+ currentIndex = ComponentDescription(dropParent).children.getItemIndex(draggedElement);
+
+ // when dragging to an index after our index we have to subtract one
+ if (currentIndex<dropIndex) {
+ dropIndex--;
+ //Radiate.log.info("Lowering index");
+ }
+ }
+
+
+ // make sure application can't be dropped into itself
+ if (draggedElement.instance is Application) {
+ event.preventDefault();
+ displayListTree.hideDropFeedback(event);
+ return;
+ }
+
+ // make sure container can't be dropped into child container
+ if (draggedElement.instance is DisplayObjectContainer &&
+ dropParent &&
+ dropParent.instance is DisplayObjectContainer &&
+ DisplayObjectContainer(draggedElement.instance).contains(dropParent.instance)) {
+
+ event.preventDefault();
+ displayListTree.hideDropFeedback(event);
+ return;
+ }
+
+ if (dropParent) {
+ /*
+ Radiate.log.info("drop index:"+ dropIndex);
+ Radiate.log.info("row index:" + rowIndex);
+ Radiate.log.info("item index:" + droppingIndex);*/
+
+ Radiate.moveElement(draggedElement.instance, dropParent.instance, [], [], null,
+ RadiateEvent.MOVE_ITEM, AddItems.LAST, null, dropIndex);
+
+ radiate.setTarget(draggedElement.instance);
+ }
+ else {
+
+ // if not showing root then allow drop
+ if (canDragOutOfParent && dropParent==null) {
+ dropParent = ArrayCollection(displayListTree.dataProvider).getItemAt(0);
+ currentIndex = ComponentDescription(dropParent).children.getItemIndex(draggedElement);
+
+ // when dragging to an index after our index we have to subtract one
+ if (currentIndex<dropIndex && dropParent.instance==draggedElement.parent.instance) {
+ dropIndex--;
+ //Radiate.log.info("Lowering index");
+ }
+
+ Radiate.moveElement(draggedElement.instance, dropParent.instance, [], [], null,
+ RadiateEvent.MOVE_ITEM, AddItems.LAST, null, dropIndex);
+ }
+ else {
+
+ // element is an item and parent is different => can not drop
+ event.preventDefault();
+ displayListTree.hideDropFeedback(event);
+ }
+ }
+
+ }
+
+ protected function displayListTree_dragCompleteHandler(event:DragEvent):void {
+
+ }
+
+ /**
+ * Handle when dragging just outside of tree
+ * */
+ protected function displayListTree_dragOverHandler(event:DragEvent):void {
+
+ var dropData:Object = displayListTree.mx_internal::_dropData;
+ var dropParent:Object = dropData.parent;
+
+ // dragging outside of tree
+ if (dropParent==null) {
+ // prevents dragging from working after this point
+ //event.preventDefault();
+ //displayListTree.hideDropFeedback(event);
+ }
+ }
+
+ protected function expandAllNodes_clickHandler(event:MouseEvent):void {
+ openAllItems();
+ }
+
+ protected function closeAllNodes_clickHandler(event:MouseEvent):void {
+ closeAllItems();
+ }
+
+ ]]>
+ </fx:Script>
+
+ <s:layout>
+ <s:VerticalLayout gap="0"/>
+ </s:layout>
+ <!--
+ <views:BlendMode height="20" width="50%" />-->
+
+ <s:Scroller id="scroller" width="100%" height="100%"
+ top="0"
+ bottom="0">
+ <s:Group width="100%" height="100%">
+ <mx:Tree id="displayListTree"
+ width="100%"
+ focusAlpha="0"
+ minHeight="50"
+ itemOpen="displayListTree_itemOpenHandler(event)"
+ itemClose="displayListTree_itemCloseHandler(event)"
+ change="displayListTree_changeHandler(event)"
+ showRoot="false"
+ dataProvider="{components}"
+ labelFunction="labelFunction"
+ verticalScrollPolicy="off"
+ horizontalScrollPolicy="auto"
+ rollOverColor="#ffffff"
+ selectionColor="#d8d8d8"
+ useRollOver="false"
+ borderVisible="false"
+ indentation="16"
+ dragEnabled="true"
+ dropEnabled="true"
+ dragMoveEnabled="true"
+ itemRenderer="com.flexcapacitor.views.renderers.LayersRenderer"
+ mouseDown="displayListTree_mouseDownHandler(event)"
+ dragOver="displayListTree_dragOverHandler(event)"
+ dragDrop="displayListTree_dragDropHandler(event)"
+ dragComplete="displayListTree_dragCompleteHandler(event)"
+ dataDescriptor="{new LayersDataDescriptor()}"
+ >
+
+
+ </mx:Tree>
+ </s:Group>
+ </s:Scroller>
+
+
+ <s:HGroup width="100%"
+ height="24"
+ minHeight="24"
+ verticalAlign="middle"
+ paddingRight="8"
+ >
+ <s:Spacer width="100%"/>
+ <c:ImageButton id="closeAllNodes"
+ source="{Radii8LibraryAssets.treeViewClosed}"
+ toolTip="Expand All"
+ click="closeAllNodes_clickHandler(event)"
+ />
+ <c:ImageButton id="expandAllNodes"
+ source="{Radii8LibraryAssets.treeView}"
+ toolTip="Expand All"
+ click="expandAllNodes_clickHandler(event)"
+ />
+ </s:HGroup>
+
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/MeasureBox.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/MeasureBox.mxml b/Radii8Library/src/com/flexcapacitor/views/MeasureBox.mxml
new file mode 100644
index 0000000..b00fee5
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/MeasureBox.mxml
@@ -0,0 +1,49 @@
+<?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"
+ minWidth="40" minHeight="20"
+ xmlns:handlers="com.flexcapacitor.handlers.*"
+ xmlns:debugging="com.flexcapacitor.effects.debugging.*"
+ xmlns:core="com.flexcapacitor.effects.core.*">
+
+ <!--
+
+ Sortof a marquee type of tool. Select this tool and
+ then you can draw a box around something and it shows the dimensions
+
+ -->
+
+ <fx:Declarations>
+ <handlers:EventHandler eventName="click" target="{redrawButton}">
+ <core:ToggleProperty target="{redrawButton}"
+ targetPropertyName="selected"
+ updateTargetProperty="false"
+ toggleValues="{[true, false]}">
+ <core:effects>
+ <debugging:ShowRedrawRegions />
+ <debugging:HideRedrawRegions />
+ </core:effects>
+ </core:ToggleProperty>
+ </handlers:EventHandler>
+ </fx:Declarations>
+
+ <s:ToggleButton id="redrawButton" label="Show Redraw Regions" />
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Memory.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/Memory.mxml b/Radii8Library/src/com/flexcapacitor/views/Memory.mxml
new file mode 100644
index 0000000..4fd4b91
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/Memory.mxml
@@ -0,0 +1,165 @@
+<?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"
+ creationComplete="group1_creationCompleteHandler(event)">
+
+ <fx:Script>
+ <![CDATA[
+ import flash.utils.getTimer;
+
+ import mx.events.FlexEvent;
+
+ // THESE VALUES ARE DIFFERENT FOR FLASH PLAYER IN THE BROWSER VS AIR
+ // TODO: Update descriptions
+
+ /**
+ * TODO: How often to update the display
+ * */
+ private var updateInterval:int;
+ private var message:String;
+
+ /**
+ * I don't know what this is really telling me
+ * */
+ public var showAvailablePlayerMemory:Boolean;
+
+ /**
+ * I don't know what this is really telling me
+ * */
+ public var showCurrentlyUsedPlayerMemory:Boolean;
+
+ /**
+ * I don't know what this is really telling me
+ * */
+ public var showTotalAllocatedMemoryOfAIRApplication:Boolean;
+
+ /**
+ * I don't know what this is really telling me
+ * */
+ public var showTotalAllocatedMemoryOfAllFlashInstancesRunningInTheBrowser:Boolean = true;
+
+ /**
+ * Not sure if this is accurate
+ * */
+ public var showTotalAllocatedPlayerMemory:Boolean;
+
+ private var _wrapCharacter:String = "\n";
+ private var wrapCharacter:String = "";
+ private var _wrap:Boolean;
+
+ /**
+ * With multiple values indicates to wrap to next line.
+ * */
+ public function set wrap(value:Boolean):void {
+ wrapCharacter = value ? _wrapCharacter : "";
+ _wrap = value;
+ }
+
+ public function get wrap():Boolean {
+ return _wrap;
+ }
+
+ protected function enterFrameHandler(event:TimerEvent):void {
+
+ // add update interval support
+
+
+ message = showTotalAllocatedPlayerMemory ? " " + getTotalAllocatedPlayerMemory() + wrapCharacter : "";
+ message += showAvailablePlayerMemory ? getSystemFreeMemory() + wrapCharacter : "";
+ message += showCurrentlyUsedPlayerMemory ? " " + getCurrentlyUsedPlayerMemory() + wrapCharacter : "";
+ message += showTotalAllocatedMemoryOfAIRApplication ? " " + getTotalAllocatedApplicationMemory() + wrapCharacter : "";
+ message += showTotalAllocatedMemoryOfAllFlashInstancesRunningInTheBrowser ? " " + getTotalAllocatedMemoryOfAllFlashInstancesRunningInTheBrowser() + wrapCharacter : "";
+ statistic.text = message;
+ }
+
+ /**
+ * The amount of memory (in bytes) that is allocated to Adobe® Flash® Player
+ * or Adobe® AIR® and that is not in use. This unused portion of allocated
+ * memory (System.totalMemory) fluctuates as garbage collection takes place.
+ * Use this property to monitor garbage collection.
+ *
+ * getAvailablePlayerMemory
+ * */
+ protected function getSystemFreeMemory():String {
+ return getPrecision(System.freeMemory);
+ }
+
+ /**
+ * The amount of memory (in bytes) currently in use that has been directly
+ * allocated by Flash Player or AIR. This property does not return all memory
+ * used by an Adobe AIR application or by the application (such as a browser)
+ * containing Flash Player content. The browser or operating system may consume
+ * other memory. The System.privateMemory property reflects all memory used by
+ * an application.
+ * */
+ protected function getCurrentlyUsedPlayerMemory():String {
+ return getPrecision(System.totalMemoryNumber);
+ }
+
+ /**
+ * The entire amount of memory (in bytes) used by an application. This is the
+ * amount of resident private memory for the entire process. AIR developers should
+ * use this property to determine the entire memory consumption of an application.
+ *
+ * Results of this value for Flash Player in the browser are vague. Use alternative method
+ * */
+ protected function getTotalAllocatedApplicationMemory():String {
+ return getPrecision(System.privateMemory);
+ }
+
+ /**
+ * The entire amount of memory (in bytes) used by a Flash application including the memory
+ * used by a container application, such as the web browser.
+ * */
+ protected function getTotalAllocatedMemoryOfAllFlashInstancesRunningInTheBrowser():String {
+
+ return getPrecision(System.privateMemory);
+ }
+
+ /**
+ * Total Allocated Player Memory. Not accurate??
+ * */
+ protected function getTotalAllocatedPlayerMemory():String {
+
+ // this can't be right
+ return getPrecision(System.freeMemory + System.totalMemoryNumber);
+ }
+
+
+ private function getPrecision(memory:Number, format:String = "MB"):String {
+ return Number(memory / 1000000).toPrecision(3) + format;
+ }
+
+ private var timer:Timer;
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+
+ timer = new Timer(5000);
+ timer.addEventListener(TimerEvent.TIMER, enterFrameHandler, false, 0, true);
+ timer.start();
+ }
+
+ ]]>
+ </fx:Script>
+
+ <s:Label id="statistic" width="100%"/>
+
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/RedrawRegions.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/RedrawRegions.mxml b/Radii8Library/src/com/flexcapacitor/views/RedrawRegions.mxml
new file mode 100644
index 0000000..894072e
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/RedrawRegions.mxml
@@ -0,0 +1,73 @@
+<?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:debugging="com.flexcapacitor.effects.debugging.*"
+ xmlns:core="com.flexcapacitor.effects.core.*"
+ xmlns:filters="com.flexcapacitor.filters.*"
+
+ minWidth="22" minHeight="22"
+ >
+
+
+ <fx:Declarations>
+ <handlers:EventHandler eventName="click"
+ target="{redrawButton}">
+ <core:ToggleEffects >
+ <core:effects>
+ <s:Sequence>
+ <core:SetAction target="{fill}" property="filters"
+ value="{selectFiltersOn}"/>
+ <debugging:ShowRedrawRegions />
+ </s:Sequence>
+ <s:Sequence>
+ <debugging:HideRedrawRegions />
+ <core:SetAction target="{fill}" property="filters"
+ value="{selectFiltersOff}"/>
+ </s:Sequence>
+ </core:effects>
+ </core:ToggleEffects>
+ </handlers:EventHandler>
+
+ <fx:Array id="selectFiltersOn">
+ <s:DropShadowFilter distance="1" blurX="2" blurY="2" strength=".8" inner="true" knockout="false"/>
+ </fx:Array>
+ <fx:Array id="selectFiltersOff">
+ <filters:BlackAndWhiteFilter />
+ </fx:Array>
+ </fx:Declarations>
+
+ <s:Group id="redrawButton"
+ width="20" height="20"
+ minHeight="16" minWidth="16"
+ left="4">
+ <s:Rect id="fill" width="100%" height="100%" filters="{selectFiltersOff}" verticalCenter="0">
+ <s:fill>
+ <s:SolidColor color="#ff0000"/>
+ </s:fill>
+ </s:Rect>
+ <s:Rect id="stroke" top="2" left="2" right="2" bottom="2">
+ <s:stroke>
+ <s:SolidColorStroke color="#FFFFFF" />
+ </s:stroke>
+ </s:Rect>
+ </s:Group>
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/SearchExpression.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/SearchExpression.mxml b/Radii8Library/src/com/flexcapacitor/views/SearchExpression.mxml
new file mode 100644
index 0000000..c9e0784
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/SearchExpression.mxml
@@ -0,0 +1,222 @@
+<?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.
+
+-->
+<!---
+
+ Creates a Regular Expression pattern that can be used in eclipse's Find in Files search dialog.
+ Usually this is all you need to find the exact element you're looking for.
+ The document that the item is declared in can be used to narrow your search
+
+ To Use: Set the target. When set it will show the document that it is in and pattern to find it.
+ Press the copy button and open Find in Files (ctrl + h). Paste the expression in the search
+ field and select RegExp match. Click Search. A list of matches will appear. If there are many
+ matches use the document info shown to narrow it down.
+
+-->
+<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:filters="com.flexcapacitor.filters.*"
+ xmlns:controls="com.flexcapacitor.controls.*"
+ xmlns:inspectors="com.flexcapacitor.inspectors.*"
+
+ implements="com.flexcapacitor.views.Inspector"
+
+ creationComplete="group1_creationCompleteHandler(event)" xmlns:handlers="com.flexcapacitor.handlers.*" xmlns:clipboard="com.flexcapacitor.effects.clipboard.*" xmlns:status="com.flexcapacitor.effects.status.*"
+ >
+
+ <s:layout>
+ <s:VerticalLayout/>
+ </s:layout>
+
+ <fx:Script>
+ <![CDATA[
+ import com.flexcapacitor.controller.Radiate;
+ import com.flexcapacitor.events.RadiateEvent;
+ import com.flexcapacitor.utils.InspectorUtils;
+
+ import mx.core.FlexSprite;
+ import mx.core.UIComponent;
+ import mx.events.FlexEvent;
+
+ private var _target:DisplayObject;
+
+ public var targetParentDocument:String;
+
+ public function get target():* {
+ 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:*):void {
+
+ var classAndPackage:Array;
+
+ // we only create patterns for MXML display objects at this time
+ // would like to know how to check if the target was declared with an MXML tag
+ if (!(value is DisplayObject)) {
+ _target = null;
+ enabled = false;
+ return;
+ }
+ else {
+ _target = DisplayObject(value);
+ enabled = true;
+ }
+
+ searchPattern = InspectorUtils.getRegExpSearchPattern(DisplayObject(target));
+
+ classAndPackage = target is UIComponent ? InspectorUtils.getClassNameAndPackage(UIComponent(target).parentDocument) : [];
+
+ if (classAndPackage.length>0) {
+ targetParentDocument = classAndPackage[0];
+ }
+
+ searchPatternText.text = searchPattern
+
+ }
+
+ /**
+ * Will be called by InspectorManager when window is closed
+ * */
+ public function close():void {
+
+ }
+
+ /**
+ * Copies the search pattern to the clipboard
+ * Does not copy the parent document name
+ * */
+ public function copy():void {
+ if (searchPattern) {
+ InspectorUtils.copyToClipboard(searchPattern);
+ }
+ }
+
+ /**
+ * Copies the search pattern to the clipboard
+ * Does not copy the parent document name
+ * */
+ public function copyDocument():void {
+ if (searchPattern) {
+ InspectorUtils.copyToClipboard(searchPattern);
+ }
+ }
+
+ /**
+ * Regular Expression pattern that can be used in eclipse's Find in Files search dialog.
+ * */
+ [Bindable]
+ public var searchPattern:String;
+
+ public var radiate:Radiate = Radiate.instance;
+
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+ radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeEvent, false, 0, true);
+
+ if (radiate.target) {
+ target = radiate.target;
+
+ updateTarget(target);
+ }
+ }
+
+ protected function targetChangeEvent(event:RadiateEvent):void {
+ target = event.selectedItem;
+
+ updateTarget(target);
+ }
+
+ public function updateTarget(target:Object):void {
+ // if null then clear the component
+ if (!target) {
+ searchPatternText.text = "";
+ }
+ }
+
+ ]]>
+ </fx:Script>
+ <fx:Declarations>
+ <fx:Array id="selectFiltersOn">
+ <filters:BlackAndWhiteFilter />
+ <s:DropShadowFilter distance="1" blurX="3" blurY="3" strength=".8" inner="true" knockout="false"/>
+ </fx:Array>
+ <fx:Array id="selectFiltersOff">
+ <filters:BlackAndWhiteFilter />
+ </fx:Array>
+
+
+ <!-- COPY TO THE CLIPBOARD -->
+ <handlers:EventHandler eventName="click" target="{copyIcon}" setTriggerEvent="true">
+
+ <clipboard:CopyToClipboard data="{searchPattern}" targetAncestor="{this}" allowNullData="true">
+ <clipboard:successEffect>
+ <status:ShowStatusMessage message="Search pattern copied to the clipboard"/>
+ </clipboard:successEffect>
+ <clipboard:noDataEffect>
+ <status:ShowStatusMessage message="Nothing to copy to the clipboard"/>
+ </clipboard:noDataEffect>
+ <clipboard:errorEffect>
+ <status:ShowStatusMessage message="An error occurred while attempting to copy to the clipboard"/>
+ </clipboard:errorEffect>
+ </clipboard:CopyToClipboard>
+
+ </handlers:EventHandler>
+ </fx:Declarations>
+
+
+ <s:states>
+ <s:State name="document"/>
+ <s:State name="package"/>
+ </s:states>
+
+
+ <s:HGroup width="100%"
+ verticalAlign="middle"
+ paddingRight="4"
+ paddingLeft="4">
+
+ <s:TextArea id="searchPatternText"
+ alpha=".8"
+ editable="false"
+ heightInLines="2"
+ borderVisible="false"
+ width="100%"
+ verticalScrollPolicy="off"
+ verticalAlign="middle"/>
+
+ <!--<s:Spacer width="100%"/>-->
+
+ <controls:ImageButton id="copyIcon"
+ source="{Radii8LibraryAssets.copy}"
+ filters="{selectFiltersOff}"
+ toolTip="Copy the search pattern to the Clipboard"/>
+
+ </s:HGroup>
+
+ <!--<s:Group width="100%">
+ <inspectors:Description target="{target}" x="0" y="5" width="100%" currentState="document"
+ includedItems="{['document','package']}"/>
+ </s:Group>-->
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/SelectedToolToolBar.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/SelectedToolToolBar.mxml b/Radii8Library/src/com/flexcapacitor/views/SelectedToolToolBar.mxml
new file mode 100644
index 0000000..e301585
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/SelectedToolToolBar.mxml
@@ -0,0 +1,104 @@
+<?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: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.utils.supportClasses.ComponentDescription;
+
+ import mx.core.UIComponent;
+ import mx.events.FlexEvent;
+
+ /**
+ * Reference to Radiate
+ * */
+ public var radiate:Radiate;
+
+ public var componentDescription:ComponentDescription;
+
+ private var _tool:ITool;
+
+ public function get tool():ITool {
+ return _tool;
+ }
+
+ [Bindable]
+ public function set tool(value:ITool):void {
+
+ _tool = value;
+
+ if (_tool) {
+
+ }
+ else {
+
+ }
+ }
+
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+ radiate = Radiate.getInstance();
+ radiate.addEventListener(RadiateEvent.TOOL_CHANGE, handleToolChange);
+
+ if (radiate.selectedTool) {
+ updateTool(radiate.selectedTool);
+ }
+ }
+
+ protected function handleToolChange(event:RadiateEvent):void {
+
+ updateTool(event.tool);
+ }
+
+
+ public function updateTool(newTool:ITool):void {
+ var inspectorInstance:UIComponent;
+
+ if (tool!=newTool) {
+ removeAllElements();
+ }
+
+ tool = newTool;
+
+ if (tool) {
+ componentDescription = Radiate.getInstance().getToolDescription(tool);
+ inspectorInstance = componentDescription.getInspectorInstance();
+
+ if (inspectorInstance) {
+ addElement(inspectorInstance);
+ }
+ }
+ }
+ ]]>
+ </fx:Script>
+
+
+</s:Group>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/SelectionInspector.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/SelectionInspector.mxml b/Radii8Library/src/com/flexcapacitor/views/SelectionInspector.mxml
new file mode 100644
index 0000000..136c15c
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/SelectionInspector.mxml
@@ -0,0 +1,112 @@
+<?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.*"
+
+ creationComplete="group1_creationCompleteHandler(event)">
+
+ <fx:Script>
+ <![CDATA[
+ import com.flexcapacitor.controller.Radiate;
+ import com.flexcapacitor.tools.ITool;
+ import com.flexcapacitor.tools.Selection;
+ import com.flexcapacitor.utils.supportClasses.ComponentDescription;
+
+ import mx.events.FlexEvent;
+
+ public var radiate:Radiate;
+ public var tool:ITool;
+
+ [Bindable]
+ public var selectionTool:Selection;
+
+ [Bindable]
+ public var showDropLocation:Boolean;
+
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+ radiate = Radiate.getInstance();
+
+
+ tool = radiate.selectedTool;
+
+ updateTool(tool);
+ }
+
+ /**
+ * Update UI components to tool value
+ * */
+ public function updateTool(tool:ITool):void {
+ var toolDescription:ComponentDescription = radiate.getToolDescription(tool);
+
+ if (toolDescription && toolDescription.instance
+ && toolDescription.instance is Selection) {
+ selectionTool = Selection(toolDescription.instance);
+ showSelection.selected = selectionTool.showSelection;
+ showLabel.selected = selectionTool.showSelectionLabel;
+
+ }
+ }
+
+ /**
+ * Show selection checkbox change handler
+ * */
+ protected function showSelection_changeHandler(event:Event):void {
+ var toolDescription:ComponentDescription = radiate.getToolDescription(tool);
+ var selectedTool:ITool = tool;
+
+
+ if (toolDescription.instance) {
+ var selectionTool:Selection = Selection(toolDescription.instance);
+ selectionTool.showSelection = showSelection.selected;
+ }
+
+ }
+
+ /**
+ * Show label change handler
+ * */
+ protected function showLabel_changeHandler(event:Event):void {
+ var toolDescription:ComponentDescription = radiate.getToolDescription(tool);
+ var selectedTool:ITool = tool;
+
+ if (toolDescription.instance) {
+ var selectionTool:Selection = Selection(toolDescription.instance);
+ selectionTool.showSelectionLabel = showLabel.selected;
+ }
+
+
+ }
+
+ ]]>
+ </fx:Script>
+
+ <s:layout>
+ <s:HorizontalLayout paddingLeft="4" verticalAlign="baseline"/>
+ </s:layout>
+
+
+ <s:CheckBox id="showSelection" label="Show Selection" change="showSelection_changeHandler(event)"/>
+ <s:CheckBox id="showLabel" label="Show Label" change="showLabel_changeHandler(event)"/>
+ <s:Label text="Drop Location: " paddingLeft="4" visible="{showDropLocation}" includeInLayout="{showDropLocation}"/>
+ <s:Label id="dropLocation" text="{selectionTool.dragLocation}" visible="{showDropLocation}" includeInLayout="{showDropLocation}"/>
+
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/SelectionOld.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/SelectionOld.mxml b/Radii8Library/src/com/flexcapacitor/views/SelectionOld.mxml
new file mode 100644
index 0000000..bce6b5a
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/SelectionOld.mxml
@@ -0,0 +1,392 @@
+<?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"
+ minWidth="40"
+ minHeight="20"
+ creationComplete="group1_creationCompleteHandler(event)"
+ xmlns:filters="com.flexcapacitor.filters.*">
+
+
+ <fx:Script>
+ <![CDATA[
+ import com.flexcapacitor.controller.Radiate;
+ import com.flexcapacitor.events.RadiateEvent;
+ import com.flexcapacitor.utils.ClassUtils;
+ import com.flexcapacitor.utils.DisplayObjectUtils;
+ import com.flexcapacitor.utils.supportClasses.ComponentDescription;
+
+ import mx.collections.ArrayCollection;
+ import mx.core.UIComponent;
+ import mx.events.FlexEvent;
+ import mx.utils.NameUtil;
+
+ import spark.components.Group;
+
+
+ public var backgroundFillAlpha:Number = 0;
+ public var backgroundFillColor:uint = 0x000000;
+ public var lineAlpha:Number = .8;
+ public var lineColor:uint = 0x00FF00;
+ public var horizontalOffset:int = -5;
+ public var verticalOffset:int = -5;
+ public var lineThickness:int = 1;
+ public var group:Group;
+
+ public var radiate:Radiate;
+
+ [Bindable]
+ public var dataProviderList:ArrayCollection = new ArrayCollection();
+
+ public var mouseCurrentTarget:DisplayObject;
+
+ public var mouseTarget:DisplayObject;
+
+ [Bindable]
+ public var itemDescription:String;
+
+ [Bindable]
+ public var parentDocumentName:String;
+
+ private var _stage:Stage;
+
+ private var _target:Object;
+
+ /**
+ * This prevents the click event from ever reaching the target
+ * It may be causing an I beam after clicking on text controls - remove mouse up listener?
+ * */
+ public function cancelMouseEvent(target:Object):void {
+ DisplayObject(target).addEventListener(MouseEvent.CLICK, cancelClickEvent, false, 10000);
+ DisplayObject(target).addEventListener(MouseEvent.MOUSE_UP, cancelMouseUpEvent, false, 10000);
+ }
+
+ public function cancelClickEvent(e:MouseEvent):void {
+ e.preventDefault();
+ e.stopPropagation();
+ e.stopImmediatePropagation();
+ e.target.removeEventListener(MouseEvent.CLICK, cancelClickEvent);
+ }
+
+ public function cancelMouseUpEvent(e:MouseEvent):void {
+ e.preventDefault();
+ e.stopPropagation();
+ e.stopImmediatePropagation();
+ e.target.removeEventListener(MouseEvent.MOUSE_UP, cancelMouseUpEvent);
+ }
+
+ /**
+ * WTF am I doing here?
+ * */
+ public function findClickHandler(event:MouseEvent):void {
+ InteractiveObject(event.target).removeEventListener(MouseEvent.CLICK, findClickHandler, false);
+ }
+
+ /**
+ * Gets the ID of the target Object
+ * If no ID is specified returns null
+ * */
+ public function getIdentifier(element:Object):String {
+ var id:String;
+
+ if (element is UIComponent && element.id) {
+ id = UIComponent(element).id;
+ }
+ else if (element.hasOwnProperty("id") && element.id) {
+ id = element.id;
+ }
+ return id;
+ }
+
+ /**
+ * If the target is a display object we get the unqualified class name and if available the ID
+ * If the target is an object we get the unqualified class name only
+ * level is the number of parents to get
+ * */
+ public function getItemDescription(targetObject:Object, level:int = 0, description:String = ""):String {
+
+ if (targetObject is DisplayObject) {
+ var name:String = NameUtil.displayObjectToString(DisplayObject(targetObject));
+ if (name == null) {
+ return description != "" ? NameUtil.getUnqualifiedClassName(targetObject) + "\n" + description : NameUtil.getUnqualifiedClassName(targetObject);
+ }
+ var nameArray:Array = (name.length > 0) ? name.split(".") : [ "undefined" ];
+ var id:String = nameArray.pop();
+ var className:String = NameUtil.getUnqualifiedClassName(targetObject);
+ className = id ? className + " (" + id + ")" : className;
+
+ if (level > 0 && targetObject.parent) {
+ description = description != "" ? className + "\n" + description : className;
+ description = getItemDescription(targetObject.parent, --level, description);
+ }
+ else {
+ description = description != "" ? className + "\n" + description : className;
+ }
+
+ return description;
+ }
+ else {
+ return NameUtil.getUnqualifiedClassName(targetObject);
+ }
+ }
+
+ public function get target():* {
+ 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:*):void {
+
+ // the target
+ if (value == null) {
+ _target = null;
+
+ if (label) {
+ label.text = "";
+ }
+ return;
+ }
+
+ _target = value;
+
+ }
+
+ protected var displayList:ComponentDescription;
+
+ protected function findButtonHandler(event:MouseEvent):void {
+ _stage = systemManager.stage;
+ displayList = DisplayObjectUtils.getComponentDisplayList2(mainDocument);
+ addMouseHandlers();
+ clearSelection(target, true);
+ selectButton.filters = selectFiltersOn;
+ systemManager.deployMouseShields(true);
+ }
+
+ protected function clearButtonHandler(event:MouseEvent):void {
+ _stage = systemManager.stage;
+ removeMouseHandlers();
+ clearSelection(target, true);
+ }
+
+ protected function cancelButtonHandler(event:MouseEvent):void {
+ removeMouseHandlers();
+ clearSelection(target, true);
+ radiate.dispatchTargetClearEvent();
+ target = null;
+ label.text = "";
+ }
+
+ private function addMouseHandlers():void {
+ // I don't know how to create a handler that will cancel the event to a button underneath
+ // possibly look at code in FlexibleWindow
+ // possibly use system managers mouse shield???
+ // or Drag manager
+ //
+ _stage.addEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseCapture, true, 10000);
+ //_stage.addEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseCapturePriority, true, 10000);
+ _stage.addEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseBubble, false, 10000);
+ _stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true, 10000);
+ _stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, false, 10000);
+ }
+
+ private function clearSelection(target:Object, remove:Boolean = false):void {
+ ClassUtils.clearSelection(target, systemManager);
+ }
+
+ private function drawSelection(target:DisplayObject):void {
+ ClassUtils.drawSelection(target, systemManager);
+ }
+
+ private function getItemUnderMouseBubble(event:MouseEvent):void {
+ itemDescription = getItemDescription(event.target, 2);
+ }
+
+ private function getItemUnderMouseCapture(event:MouseEvent):void {
+ // we need the target to be draggable if we want to allow move
+ var isDraggable:Boolean = event.target as Sprite;
+ var isParentDraggable:Boolean = (event.target.parent != null && event.target.parent is Sprite);
+
+ mouseTarget = DisplayObject(event.target);
+ mouseCurrentTarget = DisplayObject(event.currentTarget);
+
+ /* if (mouseTarget.width != 0) {
+ // we need to draw on objects parented by the system manager
+ drawSelection(mouseTarget);
+ label.text = ClassUtils.getClassName(mouseTarget);
+ } */
+ var point:Point = new Point(event.stageX, event.stageY);
+ var objects:Array = stage.getObjectsUnderPoint(point);
+ var length:int = objects.length;
+ var object:Object;
+ var description:ComponentDescription;
+
+
+
+ // loop through items under point until we find one on the *component* tree
+ for (var i:int;i<length;i++) {
+ object = objects[i];
+
+ description = DisplayObjectUtils.getTargetInComponentDisplayList(object, displayList);
+ if (description) {
+ trace("found " + NameUtil.getUnqualifiedClassName(object));
+ break;
+ }
+ }
+
+ if (description) {
+ // we need to draw on objects parented by the system manager
+ drawSelection(description.instance as DisplayObject);
+ label.text = description.className;
+ }
+
+ /* itemDescription = getItemDescription(mouseTarget, 2);
+ displayItems = InspectorUtils.getVisualElementsArray(DisplayObject(mouseTarget), displayItems, 2);
+ displayItems.reverse();
+ dataProviderList.source = displayItems;
+ dataProviderList.refresh(); */
+ }
+
+ private function getItemUnderMouseCapturePriority(event:MouseEvent):void {
+ var itemDescription:String;
+ }
+
+ private function mouseUpHandler(event:MouseEvent):void {
+ var isDraggable:Boolean = event.target as Sprite;
+ var isParentDraggable:Boolean = (event.target.parent != null && event.target.parent is Sprite);
+
+ clearSelection(target, true);
+
+ // this prevents the click event from ever reaching the target
+ // this isn't working sometimes for some reason. it used to work.
+ cancelMouseEvent(event.target);
+
+ InteractiveObject(event.target).addEventListener(MouseEvent.CLICK, findClickHandler, false, 1000, true);
+
+ radiate.dispatchTargetChangeEvent(event.target);
+
+ removeMouseHandlers();
+
+ selectButton.filters = selectFiltersOff;
+
+ systemManager.deployMouseShields(false);
+ }
+
+
+ private function removeMouseHandlers():void {
+ if (_stage==null) return;
+ _stage.removeEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseCapture, true);
+ //_stage.removeEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseCapturePriority, true);
+ _stage.removeEventListener(MouseEvent.MOUSE_MOVE, getItemUnderMouseBubble);
+ _stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler, true);
+ _stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
+ }
+
+ /**
+ *
+ * */
+ public function close():void {
+ clearSelection(target, true);
+ label.text = "";
+ target = null;
+ }
+
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+ radiate.addEventListener(RadiateEvent.TARGET_CHANGE, targetChangeHandler);
+ radiate.addEventListener(RadiateEvent.DOCUMENT_CHANGE, documentChangeHandler);
+ }
+
+ protected function targetChangeHandler(event:RadiateEvent):void {
+ target = event.selectedItem;
+ label.text = ClassUtils.getClassName(target);
+ }
+
+ protected function documentChangeHandler(event:RadiateEvent):void {
+ mainDocument = event.selectedItem;
+
+ }
+ public var mainDocument:Object;
+ ]]>
+ </fx:Script>
+
+ <fx:Declarations>
+ <fx:Array id="selectFiltersOn">
+ <filters:BlackAndWhiteFilter />
+ <s:DropShadowFilter distance="1" blurX="3" blurY="3" strength=".8" inner="true" knockout="false"/>
+ </fx:Array>
+ <fx:Array id="selectFiltersOff">
+ <filters:BlackAndWhiteFilter />
+ <s:DropShadowFilter distance="1" blurX="2" blurY="2" strength=".4" knockout="false"/>
+ </fx:Array>
+ </fx:Declarations>
+
+
+ <s:HGroup gap="10" width="100%" verticalAlign="middle">
+
+ <s:Image id="selectButton" x="14" y="14"
+ width="18" height="18"
+ horizontalAlign="center"
+ scaleMode="letterbox"
+ smooth="true"
+ source="{Radii8LibraryAssets.selection}"
+ toolTip="Find Element"
+ filters="{selectFiltersOff}"
+ click="findButtonHandler(event)"
+ verticalAlign="middle"/>
+
+ <s:Image x="14" y="14"
+ width="18" height="18"
+ horizontalAlign="center"
+ scaleMode="letterbox"
+ smooth="true"
+ filters="{selectFiltersOff}"
+ source="{Radii8LibraryAssets.selection}"
+ toolTip="Hide selection outline"
+ click="clearButtonHandler(event)"
+ alpha=".5"
+ verticalAlign="middle"
+ includeInLayout="false"
+ visible="false"/>
+
+ <s:Image x="14" y="14"
+ width="16" height="16"
+ horizontalAlign="center"
+ scaleMode="letterbox"
+ smooth="true"
+ filters="{selectFiltersOff}"
+ source="{Radii8LibraryAssets.cancel}"
+ toolTip="Cancel Selection"
+ click="cancelButtonHandler(event)"
+ alpha="1"
+ enabled="{target}"
+ verticalAlign="middle">
+ </s:Image>
+
+ <s:Label id="label" color="#444444" />
+
+ </s:HGroup>
+
+
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Settings.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/Settings.mxml b/Radii8Library/src/com/flexcapacitor/views/Settings.mxml
new file mode 100644
index 0000000..5de3a3b
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/Settings.mxml
@@ -0,0 +1,272 @@
+<?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:c="com.flexcapacitor.controls.*"
+ xmlns:handlers="com.flexcapacitor.handlers.*"
+ xmlns:settings="com.flexcapacitor.effects.settings.*"
+ xmlns:core="com.flexcapacitor.effects.core.*"
+ xmlns:form="com.flexcapacitor.effects.form.*"
+ xmlns:form1="com.flexcapacitor.form.*"
+ xmlns:vo="com.flexcapacitor.form.vo.*"
+ xmlns:view="com.flexcapacitor.effects.view.*"
+ xmlns:states="com.flexcapacitor.effects.states.*"
+ xmlns:debugging="com.flexcapacitor.effects.debugging.*"
+ xmlns:components="components.*"
+ creationComplete="group1_creationCompleteHandler(event)">
+
+ <fx:Script>
+ <![CDATA[
+ import mx.events.FlexEvent;
+
+ protected function group1_creationCompleteHandler(event:FlexEvent):void {
+ var info:Object = systemManager.info();
+ }
+
+ /**
+ * Applies the settings
+ * */
+ public function updateSettings():void {
+ settingsData = settingsEffect.data;
+ liveDragging = settingsData.liveDragging;
+ showLevelsGraph = settingsData.showLevelsGraph;
+ showFullScreen = settingsData.launchInFullScreen;
+ showFontList = settingsData.showFontList;
+ showLevelsControls = settingsData.showLevelsControls;
+ showResolutionScale = settingsData.showResolutionScale;
+ showPerformanceInfo = settingsData.showMetrics;
+ showReadTutorial = settingsData.showReadTutorial==null ? true : false;
+ }
+ ]]>
+ </fx:Script>
+
+ <fx:Declarations>
+ <fx:Object id="settingsData"/>
+ <fx:Boolean id="liveDragging">false</fx:Boolean>
+ <fx:Boolean id="showReadTutorial">true</fx:Boolean>
+ <fx:Boolean id="showResolutionScale">false</fx:Boolean>
+ <fx:Boolean id="showLevelsControls">false</fx:Boolean>
+ <fx:Boolean id="showLevelsGraph">true</fx:Boolean>
+ <fx:Boolean id="showFullScreen">false</fx:Boolean>
+ <fx:Boolean id="showFontList">false</fx:Boolean>
+ <fx:Boolean id="showPerformanceInfo">false</fx:Boolean>
+
+
+ <handlers:EventHandler eventName="settingsUpdated"
+ target="{IEventDispatcher(parentApplication)}">
+
+ <core:PlayEffect target="{settingsEffect}"/>
+ <core:CallMethod method="updateSettings"/>
+
+ </handlers:EventHandler>
+
+
+ <!-- GET SETTINGS -->
+ <handlers:EventHandler id="getSettingsHandler"
+ target="{this}"
+ eventNames="{[
+ 'creationComplete',
+ 'settingsUpdated']}"
+ >
+
+ <settings:GetSettings id="settingsEffect" >
+ <settings:valueNotSetEffect>
+ <s:Sequence>
+ <core:Cancel cancelAncestorEffects="true"/>
+ </s:Sequence>
+ </settings:valueNotSetEffect>
+ <settings:valueSetEffect>
+ <s:Sequence>
+ <core:CallMethod method="updateSettings"/>
+ </s:Sequence>
+ </settings:valueSetEffect>
+ </settings:GetSettings>
+
+ </handlers:EventHandler>
+
+ <!-- GET SETTINGS -->
+ <handlers:EventHandler eventName="creationComplete" target="{this}">
+
+ <settings:GetSettings />
+
+ <core:CopyPreviousToNext />
+
+ <form:SetFormValues formAdapter="{formAdapter}" useDefaultValues="true"/>
+
+ </handlers:EventHandler>
+
+
+ <!-- UPDATE SETTINGS -->
+ <handlers:EventHandler eventName="change"
+ targets="{[
+ liveDraggingSupportForm,
+ showLevelsControlsForm,
+ showFontListForm,
+ showLevelsGraphForm,
+ showResolutionScaleForm,
+ showMetricsForm]}"
+ redispatchToTarget="{parentApplication as IEventDispatcher}"
+ dispatchName="settingsUpdated"
+ redispatchDuring="after"
+ bubbles="true">
+
+ <form:GetFormElementsValues formAdapter="{formAdapter}" />
+
+ <core:CopyPreviousToNext />
+
+ <settings:SaveSettings saveImmediately="true"/>
+
+ <!--<debugging:Trace message="end of settings sequence"/>-->
+
+ </handlers:EventHandler>
+
+
+ <!-- FEEDBACK VIEW -->
+ <!--<handlers:EventHandler eventName="click"
+ target="{feedbackButton}">
+ <states:ChangeStates target="{ownerComponent}" state="feedback"/>
+ </handlers:EventHandler>-->
+
+ <!--
+ * TO SET THE FORM COMPONENTS TO DATA
+ *
+ * Add form adapter in declarations
+ * Add form elements to form adapter default tag
+ * Add form components
+ *
+ * In the form elements set
+ * - target component - id of UI Component, such as myTextInput
+ * - target component property - property on target component that contains the property value, such as "text"
+ * - data - is the variable that has the object that will be edited (set in form adapter)
+ * - data property - name of property on the data object that the target component gets the value from and sets its own value to
+ * - default value, default index, default selected - default value if target data is null
+ *
+ * Call "Set form values" effect
+ -->
+ <form1:FormAdapter id="formAdapter">
+
+ <vo:FormElement targetComponent="{liveDraggingSupportForm}"
+ targetComponentProperty="selected"
+ dataProperty="liveDragging"
+ defaultSelected="false"/>
+ <vo:FormElement targetComponent="{showLevelsGraphForm}"
+ targetComponentProperty="selected"
+ dataProperty="showLevelsGraph"
+ defaultSelected="true"/>
+ <vo:FormElement targetComponent="{showFontListForm}"
+ targetComponentProperty="selected"
+ dataProperty="showFontList"
+ defaultSelected="false"/>
+ <vo:FormElement targetComponent="{showLevelsControlsForm}"
+ targetComponentProperty="selected"
+ dataProperty="showLevelsControls"
+ defaultSelected="false"/>
+ <vo:FormElement targetComponent="{showResolutionScaleForm}"
+ targetComponentProperty="selected"
+ dataProperty="showResolutionScale"
+ defaultSelected="false"/>
+ <vo:FormElement targetComponent="{showMetricsForm}"
+ targetComponentProperty="selected"
+ dataProperty="showMetrics"
+ defaultSelected="false"/>
+ </form1:FormAdapter>
+
+ <!--
+ * TO GET FORM COMPONENTS VALUES
+ *
+ * Add form components
+ * Add form adapter in declarations
+ * Add form elements to form adapter default tag
+ *
+ * - target component - id of UI Component, such as TextInput
+ * - target component property - property on target component that contains the property value, such as "text"
+ * - data - is the variable that has the object that will be edited (set in form adapter or effect)
+ * - data property - name of property on the data object that the target component gets the value from and sets its own value to
+ * - default value, default index, default selected - default value if any of target UI component
+ *
+ * Add "Get form values" effect
+ * Set effect data property to data object
+ -->
+
+ <fx:Object id="ownerComponent"/>
+ <c:SimpleFormLayout id="simpleFormLayout"/>
+ </fx:Declarations>
+
+ <s:states>
+ <s:State name="landscape" />
+ <s:State name="portrait" />
+ </s:states>
+
+ <s:layout>
+ <s:VerticalLayout paddingLeft="0" paddingRight="0" />
+ </s:layout>
+
+
+ <s:Scroller id="adjustmentsScroller"
+ width="100%" height="100%"
+ left="20">
+
+ <s:VGroup width="100%" height="100%" paddingLeft="20" paddingTop="10" gap="12">
+
+ <c:FormItemComponent id="liveDraggingSupportForm"
+ label="Live Dragging"
+ helpLabelPosition="vertical"
+ helpLabel="Changes are applied as you move the sliders."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ <c:FormItemComponent id="showLevelsGraphForm"
+ label="Show Levels Graph"
+ helpLabelPosition="vertical"
+ helpLabel="Shows a histogram of the image levels."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ <c:FormItemComponent id="showLevelsControlsForm"
+ label="Show Levels Controls"
+ helpLabelPosition="vertical"
+ helpLabel="Shows an alternate level control."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ <c:FormItemComponent id="showResolutionScaleForm"
+ label="Show Resolution Scale"
+ helpLabelPosition="vertical"
+ helpLabel="Shows slider to adjust height."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ <c:FormItemComponent id="showFontListForm"
+ label="Show Font List"
+ helpLabelPosition="vertical"
+ helpLabel="Shows a list of available fixed width fonts."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ <c:FormItemComponent id="showMetricsForm"
+ label="Show Metrics"
+ helpLabelPosition="vertical"
+ helpLabel="Shows performance metrics."
+ simpleFormLayout="{simpleFormLayout}"
+ />
+
+ </s:VGroup>
+ </s:Scroller>
+</s:Group>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/Size.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/Size.mxml b/Radii8Library/src/com/flexcapacitor/views/Size.mxml
new file mode 100644
index 0000000..4799267
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/Size.mxml
@@ -0,0 +1,37 @@
+<?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">
+
+ <fx:Script>
+ <![CDATA[
+ public function activate():void {
+
+ }
+
+ public function deactivate():void {
+
+ }
+ ]]>
+ </fx:Script>
+ <s:Label text="Size"/>
+</s:Group>
http://git-wip-us.apache.org/repos/asf/flex-radii8/blob/f370bfcf/Radii8Library/src/com/flexcapacitor/views/SizesInspector.mxml
----------------------------------------------------------------------
diff --git a/Radii8Library/src/com/flexcapacitor/views/SizesInspector.mxml b/Radii8Library/src/com/flexcapacitor/views/SizesInspector.mxml
new file mode 100644
index 0000000..f8dab42
--- /dev/null
+++ b/Radii8Library/src/com/flexcapacitor/views/SizesInspector.mxml
@@ -0,0 +1,337 @@
+<?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.model.Device;
+ import com.flexcapacitor.model.IDocument;
+ import com.flexcapacitor.tools.ITool;
+
+ import mx.events.FlexEvent;
+
+ import spark.events.IndexChangeEvent;
+
+ public var radiate:Radiate;
+
+
+ /**
+ * Shows the show actual size button
+ * */
+ [Bindable]
+ public var showRestoreSize:Boolean = true;
+
+ /**
+ * Shows the show center button
+ * */
+ [Bindable]
+ public var showCenterButton:Boolean = true;
+
+ /**
+ * Shows devices list
+ * */
+ [Bindable]
+ public var showDevicesList:Boolean = false;
+
+ /**
+ * Shows the show fit size button
+ * */
+ [Bindable]
+ public var showFitSize: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);
+ radiate.addEventListener(RadiateEvent.DOCUMENT_SIZE_CHANGE, documentSizeChangeHandler, 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);*/
+ }
+
+ /**
+ * Size combo box change handler. Update size.
+ * */
+ protected function sizeComboBox_changeHandler(event:IndexChangeEvent):void {
+ updateDocumentSize();
+ //zoomTool.setScale(parseInt(sizesComboBox.selectedItem)/100);
+ }
+
+ /**
+ *
+ * */
+ protected function actualSize_clickHandler(event:MouseEvent):void {
+ radiate.restoreDefaultScale();
+
+ }
+
+ /**
+ * Size changed
+ * */
+ protected function sizeChangedHandler(event:RadiateEvent):void {
+ /*var zoomValue:Number;
+ var zoomString:String;
+
+ zoomValue = zoomTool.getScale();
+
+ updateZoomInComboBox(zoomValue);*/
+ }
+
+ /**
+ * Format size value.
+ * */
+ public function updateSizeInComboBox(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) {
+ sizesComboBox.selectedItem = "100%";
+ }
+ else {
+ sizesComboBox.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();
+
+ updateSizeInComboBox(zoomValue);*/
+
+ updatePortraitCheckbox();
+
+ }
+
+ /**
+ * Restore
+ * */
+ protected function sizeComboBox_doubleClickHandler(event:MouseEvent):void {
+ /*
+ if (zoomTool) {
+ zoomTool.restoreDefaultScale();
+ sizesComboBox.selectedItem = "100%";
+ }*/
+ }
+
+ public function labelFunction(item:Object):String {
+ var device:Device = Device(item);
+
+ if (device.type=="device" || device.type=="screen") {
+ return device.name;
+ }
+
+ return device.name + device.width + "x" + device.height;
+ }
+
+ protected function changeOrientation_changeHandler(event:Event):void {
+ updateDocumentSize();
+ }
+
+ /**
+ *
+ * */
+ public var properties:Array = ["width", "height"];
+
+ /**
+ * Update portrait setting
+ * */
+ public function updatePortraitCheckbox():void {
+ var document:IDocument = radiate.selectedDocument;
+ var documentInstance:DisplayObject = document ? document.instance as DisplayObject : null;
+ var portrait:Boolean;
+
+ if (documentInstance &&
+ documentInstance.width<documentInstance.height) {
+ portraitEnabledCheckbox.selected= true;
+ portraitEnabledCheckbox.enabled = true;
+ }
+ else if (documentInstance && documentInstance.width==documentInstance.height) {
+ portraitEnabledCheckbox.enabled = false;
+ }
+ else {
+ portraitEnabledCheckbox.selected= false;
+ portraitEnabledCheckbox.enabled = true;
+ }
+
+ }
+
+ /**
+ *
+ * */
+ public function updateDocumentSize():void {
+ var document:IDocument = radiate.selectedDocument;
+ var device:Device = sizesComboBox.selectedItem as Device;
+ var object:Object = {};
+ var applied:Boolean;
+ var displayObject:DisplayObject = document ? document.instance as DisplayObject : null;
+
+
+ if (!showDevicesList) {
+ var values:Object = {width:displayObject.height, height:displayObject.width};
+ Radiate.setProperties(displayObject, properties, values);
+ return;
+ }
+
+
+
+
+ if (device.type=="screen") {
+ object.width = device.resolutionWidth;
+ object.height = device.resolutionHeight;
+
+ applied = Radiate.setProperties(displayObject, properties, object);
+ }
+ else {
+ if (portraitEnabledCheckbox.selected) {
+ object.width = device.usableWidthPortrait;
+ object.height = device.usableHeightPortrait;
+
+ applied = Radiate.setProperties(displayObject, properties, object, device.name);
+ }
+ else {
+ object.width = device.usableWidthLandscape;
+ object.height = device.usableHeightLandscape;
+
+ applied = Radiate.setProperties(displayObject, properties, object, device.name);
+ }
+ }
+ }
+
+ protected function fitSizeButton_clickHandler(event:MouseEvent):void {
+ radiate.scaleToFit(true);
+ radiate.centerApplication(true, true);
+ }
+
+ protected function centerButton_clickHandler(event:MouseEvent):void {
+ radiate.centerApplication(true, true);
+ }
+
+ protected function documentSizeChangeHandler(event:RadiateEvent):void {
+ updatePortraitCheckbox();
+ }
+
+ ]]>
+ </fx:Script>
+
+ <fx:Declarations>
+ <s:ArrayCollection id="sizesCollection">
+
+ </s:ArrayCollection>
+ </fx:Declarations>
+
+ <s:layout>
+ <s:HorizontalLayout paddingLeft="4" verticalAlign="baseline"/>
+ </s:layout>
+
+ <s:ToggleButton id="portraitEnabledCheckbox"
+ label="Portrait"
+ selected="true"
+ change="changeOrientation_changeHandler(event)"
+ skinClass="com.flexcapacitor.views.skins.OrientationButton"
+ useHandCursor="true"
+ buttonMode="true"
+ />
+ <s:Spacer width="1"/>
+ <s:DropDownList id="sizesComboBox"
+ width="180"
+ focusAlpha="0"
+ selectedIndex="8"
+ visible="{showDevicesList}"
+ includeInLayout="{showDevicesList}"
+ arrowKeysWrapFocus="false"
+ doubleClickEnabled="true"
+ labelFunction="labelFunction"
+ dataProvider="{Radiate.deviceCollections}"
+ change="sizeComboBox_changeHandler(event)"
+ doubleClick="sizeComboBox_doubleClickHandler(event)"
+ >
+ <s:layout>
+ <s:VerticalLayout gap="0"
+ horizontalAlign="contentJustify"
+ requestedRowCount="10" />
+ </s:layout>
+ </s:DropDownList>
+
+ <c:ImageButton id="centerButton"
+ toolTip="Center"
+ visible="{showCenterButton}"
+ includeInLayout="{showCenterButton}"
+ source="{Radii8LibraryAssets.centerAlignment}"
+ click="centerButton_clickHandler(event)"
+ />
+
+ <c:ImageButton id="fitSizeButton"
+ toolTip="Fit"
+ visible="{showFitSize}"
+ includeInLayout="{showFitSize}"
+ source="{Radii8LibraryAssets.zoomToFit}"
+ click="fitSizeButton_clickHandler(event)"
+ />
+
+ <c:ImageButton id="actualSizeButton"
+ toolTip="Actual"
+ visible="{showRestoreSize}"
+ includeInLayout="{showRestoreSize}"
+ source="{Radii8LibraryAssets.actualSize}"
+ click="actualSize_clickHandler(event)"
+ />
+
+
+</s:Group>