Skip to content
Browse files

Resizing working

  • Loading branch information...
1 parent 6c7cb14 commit b810025c9c21c36267216ae4af5f84ac4aee6121 secoif committed Feb 16, 2010
View
14 src/com/comtaste/pantaste/behaviours/BehaviourBase.as
@@ -5,6 +5,8 @@ package com.comtaste.pantaste.behaviours {
import mx.core.UIComponent;
+ import org.osflash.signals.Signal;
+
public class BehaviourBase {
@@ -37,6 +39,9 @@ package com.comtaste.pantaste.behaviours {
} else {
this.dispatcher = target;
}
+ startTriggered = new Signal();
+ stepTriggered = new Signal();
+ stopTriggered = new Signal();
initialize();
}
@@ -138,16 +143,23 @@ package com.comtaste.pantaste.behaviours {
}
+ public var startTriggered:Signal;
+ public var stepTriggered:Signal;
+ public var stopTriggered:Signal;
+
protected function start():void {
+ startTriggered.dispatch();
if (modifiers.length == 0) {
return;
}
for each (var modifier:IBehaviourModifier in modifiers) {
modifier.start();
}
+
}
protected function step():void {
+ stepTriggered.dispatch();
if (modifiers.length == 0) {
return;
}
@@ -157,12 +169,14 @@ package com.comtaste.pantaste.behaviours {
}
protected function stop():void {
+
if (modifiers.length == 0) {
return;
}
for each (var modifier:IBehaviourModifier in modifiers) {
modifier.stop();
}
+ stopTriggered.dispatch()
}
}
}
View
13 src/com/comtaste/pantaste/behaviours/MoveBehaviour.as
@@ -171,10 +171,8 @@ package com.comtaste.pantaste.behaviours {
return;
}
showCursor();
- this.proxy.invalidateSnapshot();
- this.proxy.createSnapshot();
- this.proxy.scaleX = target.scaleX;
- this.proxy.scaleY = target.scaleY;
+ proxy.createSnapshot();
+
}
private function onMouseUp(event:MouseEvent):void {
@@ -218,24 +216,17 @@ package com.comtaste.pantaste.behaviours {
});
}
preparingToDrag = false;
-
-
-
proxyLayer.addElementAt(proxy, proxyLayer.numElements);
proxy.depth = target.depth + 1;
}
private function startMoving():void {
-
-
var triggerPosition:Point = new Point(triggeringEvent.stageX, triggeringEvent.stageY);
var targetPosition:Point = toCoordinateSpace(triggerPosition.x, triggerPosition.y, DisplayObject(proxyLayer));
proxy.x = target.x;
proxy.y = target.y;
- proxy.scaleX = target.scaleX;
- proxy.scaleY = target.scaleY;
originalPosition = new Point(target.x, target.y);
originalMousePosition = new Point(triggeringEvent.stageX, triggeringEvent.stageY);
View
41 src/com/comtaste/pantaste/behaviours/ResizeBehaviour.as
@@ -267,23 +267,23 @@ package com.comtaste.pantaste.behaviours {
private function startResizing():void {
start();
- isResizing = true;
+ /*isResizing = true;
//if (resizeMode == SCALE_MODE) {
proxy.mode = DashProxy.MODE_SNAPSHOT;
//} else {
proxy.mode = DashProxy.MODE_BOUNDS;
//}
-
+ if (!target.parent) {
+ throw new Error("No parent?!");
+ }
var proxyPosition:Point =
toCoordinateSpace(target.x, target.y, DisplayObject(proxyLayer),
target.parent);
proxy.x = proxyPosition.x;
proxy.y = proxyPosition.y;
-
-
originalSize.x = target.getLayoutBoundsWidth();
originalSize.y = target.getLayoutBoundsHeight();
@@ -293,16 +293,45 @@ package com.comtaste.pantaste.behaviours {
proxy.width = proxyDimensions.x;
proxy.height = proxyDimensions.y;
-
+ proxy.depth = 10;
+ //target.visible = false;
//proxy.scaleX = target.scaleX;
//proxy.scaleY = target.scaleY;
IVisualElement(FlexGlobals.topLevelApplication).
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
IVisualElement(FlexGlobals.topLevelApplication).
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
+ proxyLayer.addElementAt(proxy, proxyLayer.numElements);*/
+
+ isResizing = true;
+ if (resizeMode == SCALE_MODE) {
+ proxy.mode = DashProxy.MODE_SNAPSHOT;
+ } else {
+ proxy.mode = DashProxy.MODE_BOUNDS;
+ }
+
+ start();
+ //isMoving = true;
+ /*if (proxy.initialized) {
+ proxy.startDrag();
+ } else {
+ proxy.addEventListener(FlexEvent.CREATION_COMPLETE, function(event:Event):void {
+ proxy.removeEventListener(FlexEvent.CREATION_COMPLETE, arguments.callee);
+ proxy.startDrag();
+ });
+ }*/
+
+ IVisualElement(FlexGlobals.topLevelApplication).
+ addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
+ IVisualElement(FlexGlobals.topLevelApplication).
+ addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
proxyLayer.addElementAt(proxy, proxyLayer.numElements);
+
+ proxyLayer.addElement(proxy);
+ proxy.depth = target.depth + 1;
+
}
private function stopResizing():void {
@@ -311,7 +340,9 @@ package com.comtaste.pantaste.behaviours {
IVisualElement(FlexGlobals.topLevelApplication).
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove)
hideCursor();
+
resizeTarget(proxy.width, proxy.height);
+ //target.visible = true;
destroyProxy();
stop();
}
View
10 src/com/comtaste/pantaste/behaviours/TransformBehaviourBase.as
@@ -54,10 +54,12 @@ package com.comtaste.pantaste.behaviours {
//----------------------------------------------------------
protected function createProxy():void {
- proxy = new DashProxy();
- proxy.setStyle('skinClass', com.comtaste.pantaste.components.skins.DashProxySkin);
- proxy.targetElement = target;
- proxyLayer = IVisualElementContainer(target.parent);
+ if (!proxy) {
+ proxy = new DashProxy();
+ proxy.setStyle('skinClass', com.comtaste.pantaste.components.skins.DashProxySkin);
+ proxy.targetElement = target;
+ proxyLayer = IVisualElementContainer(target.parent);
+ }
}
protected function destroyProxy():void {
View
37 src/com/comtaste/pantaste/components/DashPanel.as
@@ -14,6 +14,8 @@ package com.comtaste.pantaste.components {
import mx.binding.utils.BindingUtils;
import mx.core.IVisualElement;
+ import mx.core.IVisualElementContainer;
+ import mx.core.UIComponent;
import mx.events.FlexEvent;
import mx.managers.DragManager;
@@ -371,36 +373,55 @@ package com.comtaste.pantaste.components {
override protected function getCurrentSkinState() : String {
- if (selectBehaviour.isSelected) {
- return 'selected';
- } else if (hovered && !(resizeBehaviour.isResizing || moveBehaviour.isMoving)) {
- return 'hover';
+ if (!(resizeBehaviour.isResizing || moveBehaviour.isMoving)) {
+ if (selectBehaviour.isSelected) {
+ return 'selected';
+ } else if (hovered) {
+ return 'hover';
+ }
}
+
return super.getCurrentSkinState();
}
override protected function partAdded(partName:String, instance:Object):void {
if (instance == titleBar) {
BindingUtils.bindProperty(titleBar.title, 'text', this, 'title');
} else if (instance == contentContainer) {
-
- addContent(contentToCreate);
+ /*contentToCreate.percentHeight = 100;
+ contentToCreate.percentWidth = 100;*/
+ //this.width = contentToCreate.width;
+ //this.height = contentToCreate.height;
+
BindingUtils.bindProperty(contentContainer, 'height', contentToCreate, 'height');
BindingUtils.bindProperty(contentContainer, 'width', contentToCreate, 'width');
hasContentToCreate = false;
+ addContent(contentToCreate);
moveBehaviour.proxy.snapshotTarget = contentContainer;
}
if (contentContainer && resizeHandle) {
//resizeBehaviour = new ResizeBehaviour(MouseEvent.MOUSE_DOWN, UIComponent(contentToCreate), resizeHandle);
- resizeBehaviour = new ResizeBehaviour(MouseEvent.MOUSE_DOWN, contentContainer, resizeHandle);
- //resizeBehaviour.proxyLayer = IVisualElementContainer(parent);
+ resizeBehaviour = new ResizeBehaviour(MouseEvent.MOUSE_DOWN, UIComponent(contentToCreate), resizeHandle);
+ //resizeBehaviour.proxy.snapshotTarget = contentContainer;
+ // resizeBehaviour.proxyLayer = IVisualElementContainer(this.parentApplication);
+ resizeBehaviour.startTriggered.add(onResizeTriggered);
+ resizeBehaviour.stopTriggered.add(onResizeStopped);
//resizeBehaviour.resizeMode = ResizeBehaviour.SCALE_MODE;
BindingUtils.bindProperty(resizeBehaviour, 'enabled', this, 'resizable');
+
}
}
+ private function onResizeTriggered():void {
+ this.invalidateSkinState();
+ }
+
+ private function onResizeStopped():void {
+ this.invalidateSkinState();
+ }
+
private var hasContentToCreate:Boolean = false;
private var contentToCreate:IVisualElement;
View
47 src/com/comtaste/pantaste/components/DashProxy.as
@@ -1,6 +1,7 @@
package com.comtaste.pantaste.components {
import com.comtaste.pantaste.components.skins.DashProxySkin;
+ import flash.system.Capabilities;
import flash.utils.ByteArray;
import mx.controls.SWFLoader;
@@ -87,7 +88,6 @@ package com.comtaste.pantaste.components {
// targetElement
//--------------------------------------
-
private var _targetElement:UIComponent;
public function get targetElement():UIComponent {
@@ -99,16 +99,17 @@ package com.comtaste.pantaste.components {
return;
}
+
_targetElement = value;
- this.width = _targetElement.measuredWidth;
- this.height = _targetElement.measuredHeight;
- this.scaleX = _targetElement.scaleX;
- this.scaleY = _targetElement.scaleY;
+ //this.width = _targetElement.measuredWidth;
+ //this.height = _targetElement.measuredHeight;
+ //this.scaleX = _targetElement.scaleX;
+ //this.scaleY = _targetElement.scaleY;
_targetElement.addEventListener(FlexEvent.UPDATE_COMPLETE,
onUpdateComplete);
- /*this.x = _targetElement.x;
- this.y = _targetElement.y;*/
+ //this.x = _targetElement.x;
+ // this.y = _targetElement.y;
this.addEventListener(FlexEvent.CREATION_COMPLETE,
onCreationComplete);
//this.depth = targetElement.depth + 1;
@@ -198,29 +199,41 @@ package com.comtaste.pantaste.components {
if (!swfLoader) {
swfLoader = new SWFLoader();
swfLoader.smoothBitmapContent = true;
+ swfLoader.cacheAsBitmap = true;
}
+
if (_snapshotTarget && _snapshotTarget.visible &&
_snapshotTarget.initialized) {
- try {
+ // try {
var imageSnap:ImageSnapshot =
- ImageSnapshot.captureImage(_snapshotTarget, 72, null, false);
-
+ ImageSnapshot.captureImage(_snapshotTarget, Capabilities.screenDPI, null, false);
+ //Capabilities.
var imageByteArray:ByteArray = ByteArray(imageSnap.data);
swfLoader.load(imageByteArray);
- swfLoader.cacheAsBitmap = true;
- snapshot.removeAllElements();
-
- snapshot.addElement(swfLoader);
- } catch (error:Error) {
- trace("Error taking snapshot!");
- }
+ if (snapshot) {
+ snapshot.removeAllElements();
+ snapshot.addElement(swfLoader);
+ }
+
+
+ //snapshot.addElement(swfLoader);
+
+ //} catch (error:Error) {
+ // trace("Error taking snapshot: " + error.message);
+ //}
}
_snapshotInvalidated = false;
}
+ override protected function partAdded(partName:String, instance:Object) : void {
+ if (instance == snapshot) {
+ snapshot.addElement(swfLoader);
+ }
+ }
+
private function onPreInitialize(event:FlexEvent):void {
removeEventListener(FlexEvent.PREINITIALIZE, onPreInitialize);
setStyle('skinClass',
View
8 src/com/comtaste/pantaste/components/skins/DashPanelSkin.mxml
@@ -5,8 +5,6 @@
xmlns:components="com.comtaste.pantaste.components.*"
minHeight="{hostComponent.minHeight}"
minWidth="{hostComponent.minWidth}"
- width="100%"
- height="100%"
clipAndEnableScrolling="false"
mouseEnabled="false"
autoLayout="true"
@@ -17,10 +15,6 @@
]]>
</fx:Script>
- <fx:Declarations>
- <!-- Place non-visual elements (e.g., services, value objects) here -->
- </fx:Declarations>
-
<fx:Metadata>
[HostComponent("com.comtaste.pantaste.components.DashPanel")]
</fx:Metadata>
@@ -66,7 +60,7 @@
</s:Rect>
</s:Group>
- <s:Group id="contentContainer" minWidth="{hostComponent.minHeight}" minHeight="{hostComponent.minHeight}" />
+ <s:Group id="contentContainer" verticalCenter="0" horizontalCenter="0" />
<!--</s:Group>-->
<components:DashPanelTitleBar id="titleBar"
View
3 src/com/comtaste/pantaste/components/skins/DashProxySkin.mxml
@@ -45,8 +45,9 @@
</s:Group>
<s:Group id="snapshot"
- includeIn="snapshot"
+ includeIn="bounds, snapshot"
width="100%"
+ visible.bounds="false"
height="100%"
alpha="{hostComponent.getStyle('proxyAlpha')}"
mouseEnabled="false"
View
2 src/com/comtaste/pantaste/components/skins/TitleBarSkin.mxml
@@ -48,7 +48,7 @@
</s:Group>
<s:Group width="100%" height="100%" mouseEnabled="false">
- <s:Label id="title" left="10" verticalCenter="0" />
+ <s:Label id="title" top="-10" color="0xFFFFFF" horizontalCenter="0" />
<components:DashPanelControls id="controls"
right="-5"

0 comments on commit b810025

Please sign in to comment.
Something went wrong with that request. Please try again.