Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

PanoLink 1.3

changed url variable from cam to view
removed autohide on panorama move
module scales its width with window
  • Loading branch information...
commit 5a45281855d5c3f7b317294ba78003d0131a6695 1 parent 2a271da
@mstandio authored
View
2  src/com/panozona/modules/panolink/PanoLink.as
@@ -32,7 +32,7 @@ package com.panozona.modules.panolink{
private var panoLinkData:PanoLinkData;
public function PanoLink(){
- super("PanoLink", "1.1", "http://openpano.org/links/saladoplayer/modules/panolink/");
+ super("PanoLink", "1.3", "http://openpano.org/links/saladoplayer/modules/panolink/");
moduleDescription.addFunctionDescription("setOpen", Boolean);
moduleDescription.addFunctionDescription("toggleOpen");
View
10 src/com/panozona/modules/panolink/controller/CloseController.as
@@ -37,7 +37,7 @@ package com.panozona.modules.panolink.controller {
_closeView = closeView;
_module = module;
- _closeView.panoLinkData.windowData.addEventListener(WindowEvent.CHANGED_SIZE, placeonWindow, false, 0, true);
+ _closeView.panoLinkData.windowData.addEventListener(WindowEvent.CHANGED_CURRENT_SIZE, placeonWindow, false, 0, true);
if (_closeView.panoLinkData.close.path == null) {
return;
@@ -67,16 +67,16 @@ package com.panozona.modules.panolink.controller {
if (_closeView.panoLinkData.close.align.horizontal == Align.LEFT) {
_closeView.x = 0;
}else if (_closeView.panoLinkData.close.align.horizontal == Align.RIGHT) {
- _closeView.x = _closeView.panoLinkData.windowData.size.width - _closeView.width;
+ _closeView.x = _closeView.panoLinkData.windowData.currentSize.width - _closeView.width;
}else { // CENTER
- _closeView.x = (_closeView.panoLinkData.windowData.size.width - _closeView.width) * 0.5;
+ _closeView.x = (_closeView.panoLinkData.windowData.currentSize.width - _closeView.width) * 0.5;
}
if (_closeView.panoLinkData.close.align.vertical == Align.TOP){
_closeView.y = 0;
}else if (_closeView.panoLinkData.close.align.vertical == Align.BOTTOM) {
- _closeView.y = _closeView.panoLinkData.windowData.size.height - _closeView.height;
+ _closeView.y = _closeView.panoLinkData.windowData.currentSize.height - _closeView.height;
}else { // MIDDLE
- _closeView.y = (_closeView.panoLinkData.windowData.size.height - _closeView.height) * 0.5;
+ _closeView.y = (_closeView.panoLinkData.windowData.currentSize.height - _closeView.height) * 0.5;
}
_closeView.x += _closeView.panoLinkData.close.move.horizontal;
_closeView.y += _closeView.panoLinkData.close.move.vertical;
View
404 src/com/panozona/modules/panolink/controller/LinkController.as
@@ -1,190 +1,214 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.controller{
-
- import com.panozona.modules.panolink.events.WindowEvent;
- import com.panozona.modules.panolink.view.LinkView;
- import com.panozona.player.module.Module;
- import flash.display.BitmapData;
- import flash.display.Loader;
- import flash.display.LoaderInfo;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.external.ExternalInterface;
- import flash.geom.Point;
- import flash.geom.Rectangle;
- import flash.net.URLRequest;
- import flash.system.ApplicationDomain;
-
- public class LinkController{
-
- private var paramsFirstClone:Object;
-
- private var _linkView:LinkView;
- private var _module:Module;
-
- public function LinkController(linkView:LinkView, module:Module){
-
- _linkView = linkView;
- _module = module;
-
- var recognizedValues:Object = recognizeURL(ExternalInterface.call("window.location.href.toString"));
- if (recognizedValues != null){
- var panoDataReference:Object = _module.saladoPlayer.managerData.getPanoramaDataById(recognizedValues.id);
- if (panoDataReference == null) {
- _module.printWarning("Panorama does not exist: " + recognizedValues.id);
- }else {
- var paramsReference:Object = panoDataReference.params;
- stashOriginalParams(recognizedValues.id);
- _module.saladoPlayer.managerData.allPanoramasData.firstPanorama = recognizedValues.id;
- if (!isNaN(recognizedValues.pan)) {
- paramsReference.pan = recognizedValues.pan;
- }
- if (!isNaN(recognizedValues.tilt)) {
- paramsReference.tilt = recognizedValues.tilt;
- }
- if (!isNaN(recognizedValues.fov)) {
- paramsReference.fov = recognizedValues.fov;
- }
- }
- }
- var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
- _module.saladoPlayer.manager.addEventListener(panoramaEventClass.PANORAMA_LOADED, onPanoramaLoaded, false, 0, true);
-
- _linkView.panoLinkData.windowData.addEventListener(WindowEvent.CHANGED_OPEN, onOpenChange, false, 0, true);
-
- var imageLoader:Loader = new Loader();
- imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imageLost, false, 0, true);
- imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true);
- imageLoader.load(new URLRequest(_linkView.panoLinkData.settings.path));
- }
-
- private function imageLost(error:IOErrorEvent):void {
- error.target.removeEventListener(IOErrorEvent.IO_ERROR, imageLost);
- error.target.removeEventListener(Event.COMPLETE, imageLoaded);
- _module.printError(error.text);
- }
-
- private function imageLoaded(e:Event):void {
- e.target.removeEventListener(IOErrorEvent.IO_ERROR, imageLost);
- e.target.removeEventListener(Event.COMPLETE, imageLoaded);
-
- var bitmapData:BitmapData = new BitmapData((e.target as LoaderInfo).width, (e.target as LoaderInfo).height, true, 0);
- bitmapData.draw((e.target as LoaderInfo).content);
-
- var butWidth:Number = bitmapData.width;
- var butHeight:Number = Math.ceil((bitmapData.height - 1) / 2);
- var bitmapDataPlain:BitmapData = new BitmapData(butWidth, butHeight, true, 0);
- bitmapDataPlain.copyPixels(bitmapData, new Rectangle(0, 0, butWidth, butHeight), new Point(0, 0), null, null, true);
- var bitmapDataActive:BitmapData = new BitmapData(butWidth, butHeight, true, 0);
- bitmapDataActive.copyPixels(bitmapData, new Rectangle(0, butHeight + 1, butWidth, butHeight), new Point(0, 0), null, null, true);
-
- _linkView.setBitmapsData(bitmapDataPlain, bitmapDataActive);
- }
-
- private function onPanoramaLoaded(loadPanoramaEvent:Object):void {
- var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
- _module.saladoPlayer.manager.removeEventListener(panoramaEventClass.PANORAMA_LOADED, onPanoramaLoaded);
- onOpenChange();
- setOriginalParams();
- }
-
- private function onOpenChange(WindowEvent:Object = null):void {
- if (_linkView.panoLinkData.windowData.open){
- _linkView.setText(getUrlLink(ExternalInterface.call("window.location.href.toString")));
- }
- }
-
- public function getUrlLink(url:String):String {
- var result:String = "";
- if (url.indexOf("?") > 0) {
- result += url.substr(0, url.indexOf("?") + 1);
- var params:Array = url.substring(url.indexOf("?") + 1, url.length).split("&");
- for each(var param:String in params) {
- if (!param.match(/^pano=.+/) && !param.match(/^cam=.+/)) {
- result += param +"&";
- }
- }
- }else {
- result = url;
- result += "?";
- }
- result += "pano=" + _module.saladoPlayer.manager.currentPanoramaData.id;
- result += "&cam=";
- result += Math.floor(_module.saladoPlayer.manager.pan as Number) + ",";
- result += Math.floor(_module.saladoPlayer.manager.tilt as Number) + ",";
- result += Math.floor(_module.saladoPlayer.manager.fieldOfView as Number);
- return result;
- }
-
- private function recognizeURL(url:String):Object {
- var id:String;
- var pan:Number;
- var tilt:Number;
- var fov:Number;
- if (url.indexOf("?") > 0) {
- url = url.slice(url.indexOf("?")+1, url.length);
- var params:Array = url.split("&");
- for each(var param:String in params) {
- var temp:Array = param.split("=");
- if(temp.length != 2) continue;
- if(temp[0] == "pano"){
- id = (temp[1]);
- }else if (temp[0] == "cam") {
-
- var values:Array = temp[1].split(",");
- try{
- pan = Number(values[0]);
- tilt = Number(values[1]);
- fov = Number(values[2]);
- }catch (e:Error){
- _module.printWarning("Invalid cam values: " + temp[1]);
- }
- }
- }
- }
- if (id != null){
- var result:Object = new Object();
- result.id = id;
- result.pan = pan;
- result.tilt = tilt;
- result.fov = fov;
- return result;
- }
- return null;
- }
-
- private function stashOriginalParams(panoramaId:String):void {
- var panoramaData:Object = _module.saladoPlayer.managerData.getPanoramaDataById(panoramaId);
- if (panoramaData == null) return;
- paramsFirstClone = panoramaData.params.clone();
- }
-
- private function setOriginalParams():void {
- if (_module.saladoPlayer.managerData.allPanoramasData.firstPanorama == null) return;
- var paramsReference:Object = _module.saladoPlayer.managerData.getPanoramaDataById(
- _module.saladoPlayer.managerData.allPanoramasData.firstPanorama).params;
- if (paramsReference != null && paramsFirstClone != null) {
- paramsReference.pan = paramsFirstClone.pan;
- paramsReference.tilt = paramsFirstClone.tilt;
- paramsReference.fov = paramsFirstClone.fov;
- }
- }
- }
-}
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.controller{
+
+ import com.panozona.modules.panolink.events.WindowEvent;
+ import com.panozona.modules.panolink.view.LinkView;
+ import com.panozona.player.module.data.property.Size;
+ import com.panozona.player.module.Module;
+ import flash.display.BitmapData;
+ import flash.display.Loader;
+ import flash.display.LoaderInfo;
+ import flash.events.Event;
+ import flash.events.IOErrorEvent;
+ import flash.external.ExternalInterface;
+ import flash.geom.Point;
+ import flash.geom.Rectangle;
+ import flash.net.URLRequest;
+ import flash.system.ApplicationDomain;
+
+ public class LinkController{
+
+ private var paramsFirstClone:Object;
+ private var currentLink:String;
+
+ private var _linkView:LinkView;
+ private var _module:Module;
+
+ public function LinkController(linkView:LinkView, module:Module){
+
+ _linkView = linkView;
+ _module = module;
+
+ var recognizedValues:Object = recognizeURL(ExternalInterface.call("window.location.href.toString"));
+ if (recognizedValues != null){
+ var panoDataReference:Object = _module.saladoPlayer.managerData.getPanoramaDataById(recognizedValues.id);
+ if (panoDataReference == null) {
+ _module.printWarning("Panorama does not exist: " + recognizedValues.id);
+ }else {
+ var paramsReference:Object = panoDataReference.params;
+ stashOriginalParams(recognizedValues.id);
+ _module.saladoPlayer.managerData.allPanoramasData.firstPanorama = recognizedValues.id;
+ if (!isNaN(recognizedValues.pan)) {
+ paramsReference.pan = recognizedValues.pan;
+ }
+ if (!isNaN(recognizedValues.tilt)) {
+ paramsReference.tilt = recognizedValues.tilt;
+ }
+ if (!isNaN(recognizedValues.fov)) {
+ paramsReference.fov = recognizedValues.fov;
+ }
+ }
+ }
+ var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
+ _module.saladoPlayer.manager.addEventListener(panoramaEventClass.PANORAMA_LOADED, onPanoramaLoaded, false, 0, true);
+
+ _linkView.panoLinkData.windowData.addEventListener(WindowEvent.CHANGED_OPEN, onOpenChange, false, 0, true);
+
+ var imageLoader:Loader = new Loader();
+ imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, imageLost, false, 0, true);
+ imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded, false, 0, true);
+ imageLoader.load(new URLRequest(_linkView.panoLinkData.settings.path));
+ }
+
+ private function imageLost(error:IOErrorEvent):void {
+ error.target.removeEventListener(IOErrorEvent.IO_ERROR, imageLost);
+ error.target.removeEventListener(Event.COMPLETE, imageLoaded);
+ _module.printError(error.text);
+ }
+
+ private function imageLoaded(e:Event):void {
+ e.target.removeEventListener(IOErrorEvent.IO_ERROR, imageLost);
+ e.target.removeEventListener(Event.COMPLETE, imageLoaded);
+
+ var bitmapData:BitmapData = new BitmapData((e.target as LoaderInfo).width, (e.target as LoaderInfo).height, true, 0);
+ bitmapData.draw((e.target as LoaderInfo).content);
+
+ var butWidth:Number = bitmapData.width;
+ var butHeight:Number = Math.ceil((bitmapData.height - 1) / 2);
+ var bitmapDataPlain:BitmapData = new BitmapData(butWidth, butHeight, true, 0);
+ bitmapDataPlain.copyPixels(bitmapData, new Rectangle(0, 0, butWidth, butHeight), new Point(0, 0), null, null, true);
+ var bitmapDataActive:BitmapData = new BitmapData(butWidth, butHeight, true, 0);
+ bitmapDataActive.copyPixels(bitmapData, new Rectangle(0, butHeight + 1, butWidth, butHeight), new Point(0, 0), null, null, true);
+
+ _linkView.setBitmapsData(bitmapDataPlain, bitmapDataActive);
+
+ _linkView.panoLinkData.windowData.addEventListener(WindowEvent.CHANGED_CURRENT_SIZE, handleWindowSizeChange, false, 0, true);
+
+ var maxSize:Size = new Size(_linkView.panoLinkData.settings.maxLength, _linkView.height);
+ var minSize:Size = new Size(_linkView.panoLinkData.settings.minLength, _linkView.height);
+
+ _linkView.panoLinkData.linkData.setMinMaxSize(minSize, maxSize);
+ }
+
+ private function handleWindowSizeChange(event:Event = null):void {
+ _linkView.draw();
+ onEnterFrame();
+ }
+
+ private function onPanoramaLoaded(loadPanoramaEvent:Object):void {
+ var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
+ _module.saladoPlayer.manager.removeEventListener(panoramaEventClass.PANORAMA_LOADED, onPanoramaLoaded);
+ onOpenChange();
+ setOriginalParams();
+ }
+
+ private function onOpenChange(WindowEvent:Object = null):void {
+ if (_linkView.panoLinkData.windowData.open){
+ _linkView.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
+ }else {
+ _linkView.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
+ }
+ }
+
+ private function onEnterFrame(e:Event = null):void {
+ var newLink:String = getUrlLink(ExternalInterface.call("window.location.href.toString"));
+ if (newLink != currentLink) {
+ _linkView.setText(newLink);
+ currentLink = newLink;
+ }
+ }
+
+ public function getUrlLink(url:String):String {
+ var result:String = "";
+ if (url.indexOf("?") > 0) {
+ result += url.substr(0, url.indexOf("?") + 1);
+ var params:Array = url.substring(url.indexOf("?") + 1, url.length).split("&");
+ for each(var param:String in params) {
+ if (!param.match(/^pano=.+/) && !param.match(/^view=.+/)) {
+ result += param +"&";
+ }
+ }
+ }else {
+ result = url;
+ result += "?";
+ }
+ result += "pano=" + _module.saladoPlayer.manager.currentPanoramaData.id;
+ result += "&view=";
+ result += Math.floor(_module.saladoPlayer.manager.pan as Number) + ",";
+ result += Math.floor(_module.saladoPlayer.manager.tilt as Number) + ",";
+ result += Math.floor(_module.saladoPlayer.manager.fieldOfView as Number);
+ return result;
+ }
+
+ private function recognizeURL(url:String):Object {
+ var id:String;
+ var pan:Number;
+ var tilt:Number;
+ var fov:Number;
+ if (url.indexOf("?") > 0) {
+ url = url.slice(url.indexOf("?")+1, url.length);
+ var params:Array = url.split("&");
+ for each(var param:String in params) {
+ var temp:Array = param.split("=");
+ if(temp.length != 2) continue;
+ if(temp[0] == "pano"){
+ id = (temp[1]);
+ }else if (temp[0] == "view") {
+
+ var values:Array = temp[1].split(",");
+ try{
+ pan = Number(values[0]);
+ tilt = Number(values[1]);
+ fov = Number(values[2]);
+ }catch (e:Error){
+ _module.printWarning("Invalid view values: " + temp[1]);
+ }
+ }
+ }
+ }
+ if (id != null){
+ var result:Object = new Object();
+ result.id = id;
+ result.pan = pan;
+ result.tilt = tilt;
+ result.fov = fov;
+ return result;
+ }
+ return null;
+ }
+
+ private function stashOriginalParams(panoramaId:String):void {
+ var panoramaData:Object = _module.saladoPlayer.managerData.getPanoramaDataById(panoramaId);
+ if (panoramaData == null) return;
+ paramsFirstClone = panoramaData.params.clone();
+ }
+
+ private function setOriginalParams():void {
+ if (_module.saladoPlayer.managerData.allPanoramasData.firstPanorama == null) return;
+ var paramsReference:Object = _module.saladoPlayer.managerData.getPanoramaDataById(
+ _module.saladoPlayer.managerData.allPanoramasData.firstPanorama).params;
+ if (paramsReference != null && paramsFirstClone != null) {
+ paramsReference.pan = paramsFirstClone.pan;
+ paramsReference.tilt = paramsFirstClone.tilt;
+ paramsReference.fov = paramsFirstClone.fov;
+ }
+ }
+ }
+}
View
472 src/com/panozona/modules/panolink/controller/WindowController.as
@@ -1,227 +1,247 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.controller {
-
- import caurina.transitions.Tweener;
- import com.panozona.modules.panolink.events.WindowEvent;
- import com.panozona.modules.panolink.view.WindowView;
- import com.panozona.player.module.data.property.Align;
- import com.panozona.player.module.data.property.Transition;
- import com.panozona.player.module.Module;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.system.ApplicationDomain;
-
- public class WindowController {
-
- private var _module:Module;
- private var _windowView:WindowView;
-
- private var _linkController:LinkController;
- private var _closeController:CloseController;
-
- public function WindowController(windowView:WindowView, module:Module) {
-
- _module = module;
- _windowView = windowView;
-
- _windowView.windowData.addEventListener(WindowEvent.CHANGED_OPEN, onOpenChange, false, 0, true);
- _windowView.windowData.addEventListener(WindowEvent.CHANGED_SIZE, handleResize, false, 0, true);
-
- _linkController = new LinkController(windowView.linkView, _module);
- _closeController = new CloseController(windowView.closeView, _module);
-
- var ViewEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panosalado.events.ViewEvent") as Class;
- _module.saladoPlayer.manager.addEventListener(ViewEventClass.BOUNDS_CHANGED, handleResize, false, 0, true);
- handleResize();
-
- var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
- _module.saladoPlayer.manager.addEventListener(panoramaEventClass.PANORAMA_STARTED_LOADING, onPanoramaStartedLoading, false, 0, true);
- }
-
- private function onPanoramaStartedLoading(loadPanoramaEvent:Object):void {
- var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
- _module.saladoPlayer.manager.removeEventListener(panoramaEventClass.PANORAMA_STARTED_LOADING, onPanoramaStartedLoading);
- if (_windowView.windowData.open){
- _module.saladoPlayer.manager.runAction(_windowView.panoLinkData.windowData.window.onOpen);
- }else {
- _module.saladoPlayer.manager.runAction(_windowView.panoLinkData.windowData.window.onClose);
- }
- _module.saladoPlayer.manager.addEventListener(panoramaEventClass.PANORAMA_STARTED_LOADING, handlePlayerClick, false, 0, true);
- }
-
- private function handleResize(event:Event = null):void {
- placeWindow();
- }
-
- private function handlePlayerClick(event:Event = null):void {
- _windowView.panoLinkData.windowData.open = false;
- }
-
- private function onOpenChange(e:Event):void {
- if (_windowView.windowData.open) {
- _module.saladoPlayer.managerData.controlData.autorotationCameraData.isAutorotating = false;
- _module.saladoPlayer.manager.runAction(_windowView.panoLinkData.windowData.window.onOpen);
- openWindow();
- }else {
- _module.saladoPlayer.manager.runAction(_windowView.panoLinkData.windowData.window.onClose);
- closeWindow();
- }
- }
-
- private function onEnterFrame(e:Event):void {
- if (Math.abs(_module.saladoPlayer.manager.pan - initPan) > 1 ||
- Math.abs(_module.saladoPlayer.manager.tilt - initTilt) > 1 ||
- Math.abs(_module.saladoPlayer.manager.fieldOfView - initFov) > 1) {
- _windowView.panoLinkData.windowData.open = false;
- _module.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
- }
- }
-
- private function openWindow():void {
- _windowView.visible = true;
- _windowView.mouseEnabled = true;
- _windowView.mouseChildren = true;
- var tweenObj:Object = new Object();
- tweenObj["time"] = _windowView.panoLinkData.windowData.window.openTween.time;
- tweenObj["transition"] = _windowView.panoLinkData.windowData.window.openTween.transition;
- tweenObj["onComplete"] = openWindowOnComplete;
- if (_windowView.panoLinkData.windowData.window.transition.type == Transition.FADE){
- tweenObj["alpha"] = 1;
- }else{
- tweenObj["x"] = getWindowOpenX();
- tweenObj["y"] = getWindowOpenY();
- }
- Tweener.addTween(_windowView, tweenObj);
- }
-
- private var initPan:Number;
- private var initTilt:Number;
- private var initFov:Number;
- private function openWindowOnComplete():void {
- _module.stage.addEventListener(Event.ENTER_FRAME, onEnterFrame, false, 0, true);
- initPan = _module.saladoPlayer.manager.pan;
- initTilt = _module.saladoPlayer.manager.tilt;
- initFov = _module.saladoPlayer.manager.fieldOfView;
- }
-
- private function closeWindow():void {
- var tweenObj:Object = new Object();
- tweenObj["time"] = _windowView.panoLinkData.windowData.window.closeTween.time;
- tweenObj["transition"] = _windowView.panoLinkData.windowData.window.closeTween.transition;
- tweenObj["onComplete"] = closeWindowOnComplete;
- if (_windowView.panoLinkData.windowData.window.transition.type == Transition.FADE) {
- tweenObj["alpha"] = 0;
- }else{
- tweenObj["x"] = getWindowCloseX();
- tweenObj["y"] = getWindowCloseY();
- }
- _windowView.mouseEnabled = false;
- _windowView.mouseChildren = false;
- Tweener.addTween(_windowView, tweenObj);
- }
-
- private function closeWindowOnComplete():void {
- _windowView.visible = false;
- _module.stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
- }
-
- private function placeWindow(e:Event = null):void {
- if (_windowView.windowData.open) {
- Tweener.addTween(_windowView, {x:getWindowOpenX(), y:getWindowOpenY()}); // no time parameter
- _windowView.alpha = 1;
- _windowView.visible = true;
- }else {
- Tweener.addTween(_windowView, {x:getWindowCloseX(), y:getWindowCloseY()}); // no time parameter
- if(_windowView.panoLinkData.windowData.window.transition.type == Transition.FADE){
- _windowView.alpha = 0;
- }
- _windowView.visible = false;
- }
- }
-
- private function getWindowOpenX():Number {
- var result:Number = 0;
- switch(_windowView.panoLinkData.windowData.window.align.horizontal) {
- case Align.RIGHT:
- result += _module.saladoPlayer.manager.boundsWidth
- - _windowView.panoLinkData.windowData.size.width
- + _windowView.panoLinkData.windowData.window.move.horizontal;
- break;
- case Align.LEFT:
- result += _windowView.panoLinkData.windowData.window.move.horizontal;
- break;
- default: // CENTER
- result += (_module.saladoPlayer.manager.boundsWidth
- - _windowView.panoLinkData.windowData.size.width) * 0.5
- + _windowView.panoLinkData.windowData.window.move.horizontal;
- }
- return result;
- }
-
- private function getWindowOpenY():Number{
- var result:Number = 0;
- switch(_windowView.panoLinkData.windowData.window.align.vertical) {
- case Align.TOP:
- result += _windowView.panoLinkData.windowData.window.move.vertical;
- break;
- case Align.BOTTOM:
- result += _module.saladoPlayer.manager.boundsHeight
- - _windowView.panoLinkData.windowData.size.height
- + _windowView.panoLinkData.windowData.window.move.vertical;
- break;
- default: // MIDDLE
- result += (_module.saladoPlayer.manager.boundsHeight
- - _windowView.panoLinkData.windowData.size.height) * 0.5
- + _windowView.panoLinkData.windowData.window.move.vertical;
- }
- return result;
- }
-
- private function getWindowCloseX():Number {
- var result:Number = 0;
- switch(_windowView.panoLinkData.windowData.window.transition.type){
- case Transition.SLIDE_RIGHT:
- result = _module.saladoPlayer.manager.boundsWidth;
- break;
- case Transition.SLIDE_LEFT:
- result = -_windowView.panoLinkData.windowData.size.width;
- break;
- default: //SLIDE_UP, SLIDE_DOWN
- result = getWindowOpenX();
- }
- return result;
- }
-
- private function getWindowCloseY():Number{
- var result:Number = 0;
- switch(_windowView.panoLinkData.windowData.window.transition.type){
- case Transition.SLIDE_UP:
- result = -_windowView.panoLinkData.windowData.size.height;
- break;
- case Transition.SLIDE_DOWN:
- result = _module.saladoPlayer.manager.boundsHeight;
- break;
- default: //SLIDE_LEFT, SLIDE_RIGHT
- result = getWindowOpenY();
- }
- return result;
- }
- }
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.controller {
+
+ import caurina.transitions.Tweener;
+ import com.panozona.modules.panolink.events.LinkEvent;
+ import com.panozona.modules.panolink.events.WindowEvent;
+ import com.panozona.modules.panolink.view.WindowView;
+ import com.panozona.player.module.data.property.Align;
+ import com.panozona.player.module.data.property.Move;
+ import com.panozona.player.module.data.property.Size;
+ import com.panozona.player.module.data.property.Transition;
+ import com.panozona.player.module.Module;
+ import flash.events.Event;
+ import flash.system.ApplicationDomain;
+
+ public class WindowController {
+ private var _module:Module;
+ private var _windowView:WindowView;
+
+ private var _linkController:LinkController;
+ private var _closeController:CloseController;
+
+ public function WindowController(windowView:WindowView, module:Module) {
+ _module = module;
+ _windowView = windowView;
+
+ _windowView.windowData.addEventListener(WindowEvent.CHANGED_OPEN, onOpenChange, false, 0, true);
+ _windowView.panoLinkData.linkData.addEventListener(LinkEvent.CHANGED_SIZE_LIMIT, handleResize, false, 0, true);
+
+ _linkController = new LinkController(windowView.linkView, _module);
+ _closeController = new CloseController(windowView.closeView, _module);
+
+ var ViewEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panosalado.events.ViewEvent") as Class;
+ _module.saladoPlayer.manager.addEventListener(ViewEventClass.BOUNDS_CHANGED, handleResize, false, 0, true);
+ handleResize();
+
+ var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
+ _module.saladoPlayer.manager.addEventListener(panoramaEventClass.PANORAMA_STARTED_LOADING, onPanoramaStartedLoading, false, 0, true);
+ }
+
+ private function onPanoramaStartedLoading(loadPanoramaEvent:Object):void {
+ var panoramaEventClass:Class = ApplicationDomain.currentDomain.getDefinition("com.panozona.player.manager.events.PanoramaEvent") as Class;
+ _module.saladoPlayer.manager.removeEventListener(panoramaEventClass.PANORAMA_STARTED_LOADING, onPanoramaStartedLoading);
+ if (_windowView.windowData.open){
+ _module.saladoPlayer.manager.runAction(_windowView.windowData.window.onOpen);
+ }else {
+ _module.saladoPlayer.manager.runAction(_windowView.windowData.window.onClose);
+ }
+ }
+
+ private function handleResize(event:Event = null):void {
+ var newSize:Size = new Size(0, 0);
+ var newMove:Move = new Move(0, 0);
+
+ newSize.width = _module.saladoPlayer.manager.boundsWidth
+ -(_windowView.windowData.window.margin.left + _windowView.windowData.window.margin.right);
+ if (newSize.width > _windowView.panoLinkData.linkData.maxSize.width) {
+ newSize.width = _windowView.panoLinkData.linkData.maxSize.width;
+ }
+ if (newSize.width < _windowView.panoLinkData.linkData.minSize.width) {
+ newSize.width = _windowView.panoLinkData.linkData.minSize.width;
+ }
+ newSize.height = _module.saladoPlayer.manager.boundsHeight
+ -(_windowView.windowData.window.margin.top + _windowView.windowData.window.margin.bottom);
+ if (newSize.height > _windowView.panoLinkData.linkData.maxSize.height) {
+ newSize.height = _windowView.panoLinkData.linkData.maxSize.height;
+ }
+ if (newSize.height < _windowView.panoLinkData.linkData.minSize.height) {
+ newSize.height = _windowView.panoLinkData.linkData.minSize.height;
+ }
+ if (_windowView.windowData.window.align.horizontal == Align.LEFT) {
+ newMove.horizontal = _windowView.windowData.window.margin.left;
+ } else if (_windowView.windowData.window.align.horizontal == Align.RIGHT) {
+ newMove.horizontal = -_windowView.windowData.window.margin.right;
+ } else if (_windowView.windowData.window.align.horizontal == Align.CENTER) {
+ var tmpHorizontal:Number = (_module.saladoPlayer.manager.boundsWidth - newSize.width) * 0.5;
+ if (tmpHorizontal + newSize.width > _module.saladoPlayer.manager.boundsWidth - _windowView.windowData.window.margin.right) {
+ newMove.horizontal = (_module.saladoPlayer.manager.boundsWidth - _windowView.windowData.window.margin.right) - (tmpHorizontal + newSize.width);
+ }
+ if (tmpHorizontal + newMove.horizontal < _windowView.windowData.window.margin.left) {
+ newMove.horizontal = _windowView.windowData.window.margin.left - tmpHorizontal;
+ }
+ }
+ if (_windowView.windowData.window.align.vertical == Align.TOP) {
+ newMove.vertical = _windowView.windowData.window.margin.top;
+ } else if (_windowView.windowData.window.align.vertical == Align.BOTTOM) {
+ newMove.vertical = -_windowView.windowData.window.margin.bottom;
+ } else if (_windowView.windowData.window.align.vertical == Align.MIDDLE) {
+ var tmpVertical:Number = (_module.saladoPlayer.manager.boundsHeight - newSize.height) * 0.5;
+ if (tmpVertical + newSize.height > _module.saladoPlayer.manager.boundsHeight - _windowView.windowData.window.margin.bottom) {
+ newMove.vertical = (tmpVertical + newSize.height) - (_module.saladoPlayer.manager.boundsHeight - _windowView.windowData.window.margin.bottom);
+ }
+ if (tmpVertical + newMove.vertical < _windowView.windowData.window.margin.top) {
+ newMove.vertical = _windowView.windowData.window.margin.top - tmpVertical;
+ }
+ }
+ _windowView.windowData.currentSize = newSize;
+ _windowView.windowData.currentMove = newMove;
+ placeWindow();
+ }
+
+ private function onOpenChange(e:Event):void {
+ if (_windowView.windowData.open) {
+ _module.saladoPlayer.manager.runAction(_windowView.windowData.window.onOpen);
+ openWindow();
+ }else {
+ _module.saladoPlayer.manager.runAction(_windowView.windowData.window.onClose);
+ closeWindow();
+ }
+ }
+
+ private function openWindow():void {
+ _windowView.visible = true;
+ _windowView.mouseEnabled = true;
+ _windowView.mouseChildren = true;
+ var tweenObj:Object = new Object();
+ tweenObj["time"] = _windowView.windowData.window.openTween.time;
+ tweenObj["transition"] = _windowView.windowData.window.openTween.transition;
+ if (_windowView.windowData.window.transition.type == Transition.FADE) {
+ tweenObj["alpha"] = _windowView.windowData.window.alpha;
+ }else{
+ tweenObj["x"] = getWindowOpenX();
+ tweenObj["y"] = getWindowOpenY();
+ }
+ Tweener.addTween(_windowView, tweenObj);
+ }
+
+ private function closeWindow():void {
+ var tweenObj:Object = new Object();
+ tweenObj["time"] = _windowView.windowData.window.closeTween.time;
+ tweenObj["transition"] = _windowView.windowData.window.closeTween.transition;
+ tweenObj["onComplete"] = closeWindowOnComplete;
+ if (_windowView.windowData.window.transition.type == Transition.FADE) {
+ tweenObj["alpha"] = 0;
+ }else{
+ tweenObj["x"] = getWindowCloseX();
+ tweenObj["y"] = getWindowCloseY();
+ }
+ _windowView.mouseEnabled = false;
+ _windowView.mouseChildren = false;
+ Tweener.addTween(_windowView, tweenObj);
+ }
+
+ private function closeWindowOnComplete():void {
+ _windowView.visible = false;
+ }
+
+ private function placeWindow(e:Event = null):void {
+ if (_windowView.windowData.open) {
+ Tweener.addTween(_windowView, {x:getWindowOpenX(), y:getWindowOpenY()}); // no time parameter
+ _windowView.alpha = _windowView.windowData.window.alpha;
+ _windowView.visible = true;
+ }else {
+ Tweener.addTween(_windowView, {x:getWindowCloseX(), y:getWindowCloseY()}); // no time parameter
+ if(_windowView.windowData.window.transition.type == Transition.FADE){
+ _windowView.alpha = 0;
+ }
+ _windowView.visible = false;
+ }
+ }
+
+ private function getWindowOpenX():Number {
+ var result:Number = 0;
+ switch(_windowView.windowData.window.align.horizontal) {
+ case Align.RIGHT:
+ result += _module.saladoPlayer.manager.boundsWidth
+ - _windowView.windowData.currentSize.width
+ + _windowView.windowData.currentMove.horizontal;
+ break;
+ case Align.LEFT:
+ result += _windowView.windowData.currentMove.horizontal;
+ break;
+ default: // CENTER
+ result += (_module.saladoPlayer.manager.boundsWidth
+ - _windowView.windowData.currentSize.width) * 0.5
+ + _windowView.windowData.currentMove.horizontal;
+ }
+ return result;
+ }
+
+ private function getWindowOpenY():Number{
+ var result:Number = 0;
+ switch(_windowView.windowData.window.align.vertical) {
+ case Align.TOP:
+ result += _windowView.windowData.currentMove.vertical;
+ break;
+ case Align.BOTTOM:
+ result += _module.saladoPlayer.manager.boundsHeight
+ - _windowView.windowData.currentSize.height
+ + _windowView.windowData.currentMove.vertical;
+ break;
+ default: // MIDDLE
+ result += (_module.saladoPlayer.manager.boundsHeight
+ - _windowView.windowData.currentSize.height) * 0.5
+ + _windowView.windowData.currentMove.vertical;
+ }
+ return result;
+ }
+
+ private function getWindowCloseX():Number {
+ var result:Number = 0;
+ switch(_windowView.windowData.window.transition.type){
+ case Transition.SLIDE_RIGHT:
+ result = _module.saladoPlayer.manager.boundsWidth;
+ break;
+ case Transition.SLIDE_LEFT:
+ result = -_windowView.windowData.currentSize.width;
+ break;
+ default: //SLIDE_UP, SLIDE_DOWN
+ result = getWindowOpenX();
+ }
+ return result;
+ }
+
+ private function getWindowCloseY():Number{
+ var result:Number = 0;
+ switch(_windowView.windowData.window.transition.type){
+ case Transition.SLIDE_UP:
+ result = -_windowView.windowData.currentSize.height;
+ break;
+ case Transition.SLIDE_DOWN:
+ result = _module.saladoPlayer.manager.boundsHeight;
+ break;
+ default: //SLIDE_LEFT, SLIDE_RIGHT
+ result = getWindowOpenY();
+ }
+ return result;
+ }
+ }
}
View
31 src/com/panozona/modules/panolink/events/LinkEvent.as
@@ -0,0 +1,31 @@
+/*
+Copyright 2013 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.events {
+
+ import flash.events.Event;
+
+ public class LinkEvent extends Event {
+
+ public static const CHANGED_SIZE_LIMIT:String = "changedSizeLimit";
+
+ public function LinkEvent(type:String){
+ super(type);
+ }
+ }
+}
View
63 src/com/panozona/modules/panolink/events/WindowEvent.as
@@ -1,32 +1,33 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.events {
-
- import flash.events.Event;
-
- public class WindowEvent extends Event{
-
- public static const CHANGED_OPEN:String = "changedOpen";
- public static const CHANGED_SIZE:String = "changedSize";
-
- public function WindowEvent(type:String){
- super(type);
- }
- }
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.events {
+
+ import flash.events.Event;
+
+ public class WindowEvent extends Event{
+
+ public static const CHANGED_OPEN:String = "changedOpen";
+ public static const CHANGED_CURRENT_SIZE:String = "changedCurrentSize";
+ public static const CHANGED_CURRENT_MOVE:String = "changedCurrentMove";
+
+ public function WindowEvent(type:String){
+ super(type);
+ }
+ }
}
View
38 src/com/panozona/modules/panolink/model/LinkData.as
@@ -0,0 +1,38 @@
+/*
+Copyright 2013 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.model {
+
+ import com.panozona.modules.panolink.events.LinkEvent;
+ import com.panozona.player.module.data.property.Size;
+ import flash.events.EventDispatcher;
+
+ public class LinkData extends EventDispatcher {
+
+ private var _minSize:Size = new Size(1, 1);
+ private var _maxSize:Size = new Size(1, 1);
+
+ public function get minSize():Size {return _minSize};
+ public function get maxSize():Size {return _maxSize};
+ public function setMinMaxSize(minSize:Size, maxSize:Size):void {
+ _minSize = minSize;
+ _maxSize = maxSize;
+ dispatchEvent(new LinkEvent(LinkEvent.CHANGED_SIZE_LIMIT));
+ }
+ }
+}
View
123 src/com/panozona/modules/panolink/model/PanoLinkData.as
@@ -1,62 +1,63 @@
-/*
-Copyright 2011 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.model {
-
- import com.panozona.modules.panolink.model.structure.Close;
- import com.panozona.modules.panolink.model.structure.Settings;
- import com.panozona.player.module.data.DataNode;
- import com.panozona.player.module.data.ModuleData;
- import com.panozona.player.module.utils.DataNodeTranslator;
-
- public class PanoLinkData {
-
- public const settings:Settings = new Settings();
- public const windowData:WindowData = new WindowData();
- public const close:Close = new Close();
-
- public function PanoLinkData(moduleData:ModuleData, saladoPlayer:Object) {
- var tarnslator:DataNodeTranslator = new DataNodeTranslator(saladoPlayer.managerData.debugMode);
- for each(var dataNode:DataNode in moduleData.nodes) {
- if (dataNode.name == "settings") {
- tarnslator.dataNodeToObject(dataNode, settings);
- }else if (dataNode.name == "window") {
- tarnslator.dataNodeToObject(dataNode, windowData.window);
- }else if (dataNode.name == "close") {
- tarnslator.dataNodeToObject(dataNode, close);
- }else{
- throw new Error("Invalid node name: " + dataNode.name);
- }
- }
-
- windowData.open = windowData.window.open;
-
- if (saladoPlayer.managerData.debugMode) {
- if (settings.path == null || !settings.path.match(/^(.+)\.(png|gif|jpg|jpeg)$/i)){
- throw new Error("Invalid bitmaps grid path: " + settings.path);
- }
- if (windowData.window.onOpen != null && saladoPlayer.managerData.getActionDataById(windowData.window.onOpen) == null) {
- throw new Error("Action does not exist: " + windowData.window.onOpen);
- }
- if (windowData.window.onClose != null && saladoPlayer.managerData.getActionDataById(windowData.window.onClose) == null) {
- throw new Error("Action does not exist: " + windowData.window.onClose);
- }
- }
- }
- }
+/*
+Copyright 2011 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.model {
+
+ import com.panozona.modules.panolink.model.structure.Close;
+ import com.panozona.modules.panolink.model.structure.Settings;
+ import com.panozona.player.module.data.DataNode;
+ import com.panozona.player.module.data.ModuleData;
+ import com.panozona.player.module.utils.DataNodeTranslator;
+
+ public class PanoLinkData {
+
+ public const settings:Settings = new Settings();
+ public const windowData:WindowData = new WindowData();
+ public const linkData:LinkData = new LinkData();
+ public const close:Close = new Close();
+
+ public function PanoLinkData(moduleData:ModuleData, saladoPlayer:Object) {
+ var tarnslator:DataNodeTranslator = new DataNodeTranslator(saladoPlayer.managerData.debugMode);
+ for each(var dataNode:DataNode in moduleData.nodes) {
+ if (dataNode.name == "settings") {
+ tarnslator.dataNodeToObject(dataNode, settings);
+ }else if (dataNode.name == "window") {
+ tarnslator.dataNodeToObject(dataNode, windowData.window);
+ }else if (dataNode.name == "close") {
+ tarnslator.dataNodeToObject(dataNode, close);
+ }else{
+ throw new Error("Invalid node name: " + dataNode.name);
+ }
+ }
+
+ windowData.open = windowData.window.open;
+
+ if (saladoPlayer.managerData.debugMode) {
+ if (settings.path == null || !settings.path.match(/^(.+)\.(png|gif|jpg|jpeg)$/i)){
+ throw new Error("Invalid bitmaps grid path: " + settings.path);
+ }
+ if (windowData.window.onOpen != null && saladoPlayer.managerData.getActionDataById(windowData.window.onOpen) == null) {
+ throw new Error("Action does not exist: " + windowData.window.onOpen);
+ }
+ if (windowData.window.onClose != null && saladoPlayer.managerData.getActionDataById(windowData.window.onClose) == null) {
+ throw new Error("Action does not exist: " + windowData.window.onClose);
+ }
+ }
+ }
+ }
}
View
117 src/com/panozona/modules/panolink/model/WindowData.as
@@ -1,55 +1,64 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.model{
-
- import com.panozona.modules.panolink.events.WindowEvent;
- import com.panozona.modules.panolink.model.structure.Window;
- import com.panozona.player.module.data.property.Size;
- import flash.events.EventDispatcher;
-
- public class WindowData extends EventDispatcher{
-
- private var _open:Boolean;
- private var _size:Size;
-
- public const window:Window = new Window();
-
- public function WindowData():void {
- _size = new Size(1, 1);
- }
-
- public function get open():Boolean{return _open}
- public function set open(value:Boolean):void {
- if (value == _open) return;
- _open = value;
- dispatchEvent(new WindowEvent(WindowEvent.CHANGED_OPEN));
- }
-
- public function get size():Size {return _size;}
- public function set size(value:Size):void {
- if (value.width > _size.width) {
- _size.width = value.width;
- }
- if (value.height > _size.height) {
- _size.height = value.height;
- }
- dispatchEvent(new WindowEvent(WindowEvent.CHANGED_SIZE));
- }
- }
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.model{
+
+ import com.panozona.modules.panolink.events.WindowEvent;
+ import com.panozona.modules.panolink.model.structure.Window;
+ import com.panozona.player.module.data.property.Move;
+ import com.panozona.player.module.data.property.Size;
+ import flash.events.EventDispatcher;
+
+ public class WindowData extends EventDispatcher{
+
+ public const window:Window = new Window();
+
+ private var _open:Boolean;
+ private var _currentSize:Size = new Size(1,1);
+ private var _currentMove:Move = new Move(1,1);
+
+ public function get open():Boolean {return _open;}
+ public function set open(value:Boolean):void {
+ if (value == _open) return;
+ _open = value;
+ dispatchEvent(new WindowEvent(WindowEvent.CHANGED_OPEN));
+ }
+
+ public function get currentSize():Size { return _currentSize };
+ public function set currentSize(value:Size):void {
+ if (value == null
+ || _currentSize.width == value.width
+ && _currentSize.height == value.height) {
+ return;
+ }
+ _currentSize = value;
+ dispatchEvent(new WindowEvent(WindowEvent.CHANGED_CURRENT_SIZE));
+ }
+
+ public function get currentMove():Move { return _currentMove };
+ public function set currentMove(value:Move):void {
+ if (value == null
+ || _currentMove.horizontal == value.horizontal
+ && _currentMove.vertical == value.vertical) {
+ return;
+ }
+ _currentMove = value;
+ dispatchEvent(new WindowEvent(WindowEvent.CHANGED_CURRENT_MOVE));
+ }
+ }
}
View
4 src/com/panozona/modules/panolink/model/structure/Settings.as
@@ -21,6 +21,10 @@ package com.panozona.modules.panolink.model.structure {
public class Settings {
public var path:String = null;
+
+ public var minLength:Number = 200;
+ public var maxLength:Number = 600;
+
public const style:Style = new Style();
}
}
View
2  src/com/panozona/modules/panolink/model/structure/Style.as
@@ -20,8 +20,6 @@ package com.panozona.modules.panolink.model.structure {
public class Style {
- public var width:Number = 330;
-
public var fontFamily:String = "Tahoma";
public var fontBold:Boolean = true;
public var fontSize:Number = 15;
View
82 src/com/panozona/modules/panolink/model/structure/Window.as
@@ -1,42 +1,42 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.model.structure{
-
- import caurina.transitions.Equations;
- import com.panozona.player.module.data.property.Align;
- import com.panozona.player.module.data.property.Move;
- import com.panozona.player.module.data.property.Transition;
- import com.panozona.player.module.data.property.Tween;
-
- public class Window {
-
- public var alpha:Number = 1;
-
- public var align:Align = new Align(Align.RIGHT, Align.TOP);
- public var move:Move = new Move(-20, 20);
-
- public var open:Boolean = false;
- public var onOpen:String = null;
- public var onClose:String = null;
-
- public var openTween:Tween = new Tween(Equations.easeNone, 0.5);
- public var closeTween:Tween = new Tween(Equations.easeNone, 0.5);
- public var transition:Transition = new Transition(Transition.SLIDE_UP);
- }
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.model.structure{
+
+ import caurina.transitions.Equations;
+ import com.panozona.player.module.data.property.Align;
+ import com.panozona.player.module.data.property.Margin;
+ import com.panozona.player.module.data.property.Transition;
+ import com.panozona.player.module.data.property.Tween;
+
+ public class Window {
+
+ public var alpha:Number = 1;
+
+ public const align:Align = new Align(Align.RIGHT, Align.TOP);
+ public const margin:Margin = new Margin(10, 10, 10, 10);
+
+ public var open:Boolean = false;
+ public var onOpen:String = null;
+ public var onClose:String = null;
+
+ public var openTween:Tween = new Tween(Equations.easeNone, 0.5);
+ public var closeTween:Tween = new Tween(Equations.easeNone, 0.5);
+ public var transition:Transition = new Transition(Transition.SLIDE_UP);
+ }
}
View
199 src/com/panozona/modules/panolink/view/LinkView.as
@@ -1,98 +1,103 @@
-/*
-Copyright 2012 Marek Standio.
-
-This file is part of SaladoPlayer.
-
-SaladoPlayer is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published
-by the Free Software Foundation, either version 3 of the License,
-or (at your option) any later version.
-
-SaladoPlayer is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty
-of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-See the GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
-*/
-package com.panozona.modules.panolink.view {
-
- import com.panozona.modules.panolink.model.PanoLinkData;
- import com.panozona.player.module.data.property.Size;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.SimpleButton;
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.system.System;
- import flash.text.TextField;
- import flash.text.TextFormat;
-
- public class LinkView extends Sprite {
-
- private var textField:TextField;
- private var textFormat:TextFormat;
-
- public const copyButton:SimpleButton = new SimpleButton();
-
- private var _panoLinkData:PanoLinkData;
-
- public function LinkView(panoLinkData:PanoLinkData) {
-
- _panoLinkData = panoLinkData;
-
- textFormat = new TextFormat();
- textFormat.size = _panoLinkData.settings.style.fontSize;
- textFormat.font = _panoLinkData.settings.style.fontFamily;
- textFormat.bold = _panoLinkData.settings.style.fontBold;
- textFormat.color = _panoLinkData.settings.style.fontColor;
-
- textField = new TextField();
- textField.background = true;
- textField.backgroundColor = _panoLinkData.settings.style.backgroundColor;
- textField.alwaysShowSelection = true;
- textField.width = _panoLinkData.settings.style.width;
- textField.height = _panoLinkData.settings.style.fontSize * 1.4;
- textField.defaultTextFormat = textFormat;
- textField.selectable = false;
- addChild(textField);
- }
-
- public function setBitmapsData(plainBitmapData:BitmapData, activeBitmapData:BitmapData):void {
- var copyPlainIcon:Sprite = new Sprite();
- copyPlainIcon.addChild(new Bitmap(plainBitmapData));
- var copyPressIcon:Sprite = new Sprite();
- copyPressIcon.addChild(new Bitmap(activeBitmapData));
- copyButton.upState = copyPlainIcon;
- copyButton.overState = copyPlainIcon;
- copyButton.downState = copyPressIcon;
- copyButton.hitTestState = copyPressIcon;
- copyButton.x = textField.width + 3;
- copyButton.y = (_panoLinkData.settings.style.fontSize * 1.4 - copyButton.height) * 0.5;
- copyButton.mouseEnabled = true;
-
- addChild(copyButton);
-
- _panoLinkData.windowData.size = new Size(this.width, this.height);
-
- copyButton.addEventListener(MouseEvent.CLICK, copyText, false, 0, true);
- }
-
- public function get panoLinkData():PanoLinkData {
- return _panoLinkData;
- }
-
- public function setText(value:String):void {
- textField.setSelection(0, 0);
- textField.text = value;
- textField.scrollH = textField.maxScrollH;
- }
-
- private function copyText(e:Event):void {
- textField.setSelection(0, textField.text.length);
- System.setClipboard(textField.text);
- }
- }
+/*
+Copyright 2012 Marek Standio.
+
+This file is part of SaladoPlayer.
+
+SaladoPlayer is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published
+by the Free Software Foundation, either version 3 of the License,
+or (at your option) any later version.
+
+SaladoPlayer is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty
+of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with SaladoPlayer. If not, see <http://www.gnu.org/licenses/>.
+*/
+package com.panozona.modules.panolink.view {
+
+ import com.panozona.modules.panolink.model.PanoLinkData;
+ import com.panozona.player.module.data.property.Size;
+ import flash.display.Bitmap;
+ import flash.display.BitmapData;
+ import flash.display.SimpleButton;
+ import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+ import flash.system.System;
+ import flash.text.TextField;
+ import flash.text.TextFormat;
+
+ public class LinkView extends Sprite {
+
+ private var textField:TextField;
+ private var textFormat:TextFormat;
+
+ public const copyButton:SimpleButton = new SimpleButton();
+
+ private var _panoLinkData:PanoLinkData;
+
+ public function LinkView(panoLinkData:PanoLinkData) {
+
+ _panoLinkData = panoLinkData;
+
+ textFormat = new TextFormat();
+ textFormat.size = _panoLinkData.settings.style.fontSize;
+ textFormat.font = _panoLinkData.settings.style.fontFamily;
+ textFormat.bold = _panoLinkData.settings.style.fontBold;
+ textFormat.color = _panoLinkData.settings.style.fontColor;
+
+ textField = new TextField();
+ textField.background = true;
+ textField.backgroundColor = _panoLinkData.settings.style.backgroundColor;
+ textField.alwaysShowSelection = true;
+ textField.defaultTextFormat = textFormat;
+ textField.selectable = false;
+ addChild(textField);
+
+ draw();
+ }
+
+ public function setBitmapsData(plainBitmapData:BitmapData, activeBitmapData:BitmapData):void {
+ var copyPlainIcon:Sprite = new Sprite();
+ copyPlainIcon.addChild(new Bitmap(plainBitmapData));
+ var copyPressIcon:Sprite = new Sprite();
+ copyPressIcon.addChild(new Bitmap(activeBitmapData));
+ copyButton.upState = copyPlainIcon;
+ copyButton.overState = copyPlainIcon;
+ copyButton.downState = copyPressIcon;
+ copyButton.hitTestState = copyPressIcon;
+ copyButton.mouseEnabled = true;
+ addChild(copyButton);
+ copyButton.addEventListener(MouseEvent.CLICK, copyText, false, 0, true);
+
+ draw();
+ }
+
+ public function draw():void {
+ textField.width = _panoLinkData.windowData.currentSize.width - copyButton.width;
+ textField.height = _panoLinkData.settings.style.fontSize * 1.4;
+ textField.scrollH = textField.maxScrollH;
+
+ copyButton.x = textField.width + 3;
+ copyButton.y = (_panoLinkData.settings.style.fontSize * 1.4 - copyButton.height) * 0.5;
+ }
+
+ public function get panoLinkData():PanoLinkData {
+ return _panoLinkData;
+ }
+
+ public function setText(value:String):void {
+ textField.setSelection(0, 0);
+ textField.text = value;
+ textField.scrollH = textField.maxScrollH;
+ }
+
+ private function copyText(e:Event):void {
+ textField.setSelection(0, textField.text.length);
+ System.setClipboard(textField.text);
+ }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.