home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / com / livebrush / ui / UI.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  30.8 KB  |  929 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.Main;
  4.    import com.livebrush.data.FileManager;
  5.    import com.livebrush.data.GlobalSettings;
  6.    import com.livebrush.data.Help;
  7.    import com.livebrush.data.Settings;
  8.    import com.livebrush.data.StateManager;
  9.    import com.livebrush.events.*;
  10.    import com.livebrush.graphics.canvas.Canvas;
  11.    import com.livebrush.graphics.canvas.CanvasManager;
  12.    import com.livebrush.graphics.canvas.Layer;
  13.    import com.livebrush.styles.StyleManager;
  14.    import com.livebrush.tools.*;
  15.    import com.livebrush.utils.Update;
  16.    import flash.display.Sprite;
  17.    import flash.display.StageAlign;
  18.    import flash.display.StageDisplayState;
  19.    import flash.display.StageScaleMode;
  20.    import flash.events.Event;
  21.    import flash.events.MouseEvent;
  22.    import flash.geom.Point;
  23.    
  24.    public class UI extends UIModel
  25.    {
  26.       public static var DIALOG_HOLDER:Sprite;
  27.       
  28.       public static var TOOLTIP_HOLDER:Sprite;
  29.       
  30.       public static var WINDOW_HOLDER:Sprite;
  31.       
  32.       public static var MAIN_UI:UI;
  33.       
  34.       public static var PREVIEW_HOLDER:Sprite;
  35.       
  36.       public static var TOP_UI_HOLDER:Sprite;
  37.       
  38.       public static var UI_HOLDER:Sprite;
  39.       
  40.       public static const WINDOW_MENU_HEIGHT:int = 19;
  41.       
  42.       public static const OPEN:int = 1;
  43.       
  44.       public static const CLOSED:int = 0;
  45.       
  46.       public static const CONSOL_DEPTH:int = 2;
  47.       
  48.       public static var HEIGHT:int = 1280;
  49.       
  50.       public static var WIDTH:int = 1024;
  51.       
  52.       public var titlebarView:TitlebarView;
  53.       
  54.       public var locked:Boolean = false;
  55.       
  56.       public var layersView:LayersView;
  57.       
  58.       private var onCanvas:Boolean = true;
  59.       
  60.       public var brushPropsView:BrushPropsView;
  61.       
  62.       public var transformPropsView:TransformPropsView;
  63.       
  64.       public var styleListView:StyleListView;
  65.       
  66.       public var canvasManager:CanvasManager;
  67.       
  68.       public var visibleState:Number = 0;
  69.       
  70.       public var registeredDialogIDList:Array;
  71.       
  72.       public var globalColorView:GlobalColorView;
  73.       
  74.       public var windowDialogHolder:Sprite;
  75.       
  76.       private var stylePreviewHolder:Sprite;
  77.       
  78.       public var bucketPropsView:BucketPropsView;
  79.       
  80.       public var emptyPropsView:EmptyPropsView;
  81.       
  82.       public var brushPropsModel:BrushPropsModel;
  83.       
  84.       public var toolPropsView:ToolPropsView;
  85.       
  86.       private var tooltipHolder:Sprite;
  87.       
  88.       private var _state:int;
  89.       
  90.       private var _stateManLocked:Boolean = true;
  91.       
  92.       public var newProjectView:NewProjectView;
  93.       
  94.       public var saveImageView:SaveImageView;
  95.       
  96.       public var globalSettingsView:GlobalSettingsView;
  97.       
  98.       private var holder:Sprite;
  99.       
  100.       public var contextMenu:ContextMenuView;
  101.       
  102.       public var samplePropsView:SamplePropsView;
  103.       
  104.       private var mainMenu:MainMenuView;
  105.       
  106.       public var main:Main;
  107.       
  108.       public var styleManager:StyleManager;
  109.       
  110.       private var activeTool:Tool;
  111.       
  112.       public var toolbarView:ToolbarView;
  113.       
  114.       public var projectLoadDialog:Dialog;
  115.       
  116.       public var consol:Consol;
  117.       
  118.       public var aboutView:BasicWindowView;
  119.       
  120.       public var panelState:int = 1;
  121.       
  122.       public var toolManager:ToolManager;
  123.       
  124.       public function UI(owner:Main)
  125.       {
  126.          super();
  127.          this.main = owner;
  128.          this.stylePreviewHolder = PREVIEW_HOLDER = Sprite(this.main.addChild(new Sprite()));
  129.          this.windowDialogHolder = DIALOG_HOLDER = WINDOW_HOLDER = Sprite(this.main.addChild(new Sprite()));
  130.          this.holder = Sprite(owner.addChild(new Sprite()));
  131.          TOP_UI_HOLDER = Sprite(this.main.addChild(new Sprite()));
  132.          this.tooltipHolder = TOOLTIP_HOLDER = Sprite(this.main.addChild(new Sprite()));
  133.          UI_HOLDER = this.holder;
  134.          MAIN_UI = this;
  135.          this.registeredDialogIDList = [];
  136.          this.init();
  137.       }
  138.       
  139.       public static function get windowCenter() : Point
  140.       {
  141.          return new Point(centerX,centerY);
  142.       }
  143.       
  144.       public static function get centerX() : Number
  145.       {
  146.          return UI.MAIN_UI.main.stage.stageWidth / 2;
  147.       }
  148.       
  149.       public static function get centerY() : Number
  150.       {
  151.          return UI.MAIN_UI.main.stage.stageHeight / 2;
  152.       }
  153.       
  154.       public static function setStatus(s:String) : void
  155.       {
  156.          UI.MAIN_UI.titlebarView.status = s;
  157.       }
  158.       
  159.       public function closeWindow(view:UIView) : void
  160.       {
  161.          this.toggle(true);
  162.          if(view == this.aboutView)
  163.          {
  164.             this.aboutView = null;
  165.          }
  166.          unregisterView(view);
  167.          view.die();
  168.       }
  169.       
  170.       public function newDialog(type:String, data:Object = null) : Dialog
  171.       {
  172.          var d:Dialog = null;
  173.          if(data.id == null || data.id != null && this.registeredDialogIDList.indexOf(data.id) == -1)
  174.          {
  175.             this.toggle(false);
  176.             d = new Dialog(type,data);
  177.             registerView(d.dialogView);
  178.             if(data.id != null)
  179.             {
  180.                this.registerDialog(d);
  181.             }
  182.          }
  183.          return d;
  184.       }
  185.       
  186.       private function init() : void
  187.       {
  188.          this.setupAppWindow();
  189.          Tooltip.getInstance();
  190.          this.holder.stage.addEventListener(Event.RESIZE,this.resizeListener);
  191.          this.brushPropsModel = new BrushPropsModel(this);
  192.          this.styleListView = StyleListView(registerView(new StyleListView(this)));
  193.          this.transformPropsView = TransformPropsView(registerView(new TransformPropsView(this)));
  194.          this.emptyPropsView = EmptyPropsView(registerView(new EmptyPropsView(this)));
  195.          this.bucketPropsView = BucketPropsView(registerView(new BucketPropsView(this)));
  196.          this.samplePropsView = SamplePropsView(registerView(new SamplePropsView(this)));
  197.          this.brushPropsView = BrushPropsView(registerView(this.brushPropsModel.brushPropsView));
  198.          this.toolPropsView = ToolPropsView(registerView(new ToolPropsView(this)));
  199.          this.layersView = LayersView(registerView(new LayersView(this)));
  200.          this.toolbarView = ToolbarView(registerView(new ToolbarView(this)));
  201.          this.titlebarView = TitlebarView(registerView(new TitlebarView(this)));
  202.          this.globalColorView = GlobalColorView(registerView(new GlobalColorView(this)));
  203.          this.mainMenu = MainMenuView(registerView(new MainMenuView(this)));
  204.          this.holder.addEventListener(MouseEvent.MOUSE_DOWN,this.guiMouseDown);
  205.          this.styleListView.panel.addEventListener(MouseEvent.MOUSE_DOWN,this.guiMouseDown);
  206.          setStatus("Loading...");
  207.          this.toggle(false);
  208.          this.resizeInterface();
  209.       }
  210.       
  211.       public function set state(s:int) : void
  212.       {
  213.          this._state = s;
  214.       }
  215.       
  216.       public function pushTransformProps(data:Settings) : void
  217.       {
  218.          this.updateViews(Update.transformUpdate(data));
  219.       }
  220.       
  221.       override protected function updateViews(update:Update) : void
  222.       {
  223.          super.updateViews(update);
  224.          this.brushPropsModel.update(update);
  225.       }
  226.       
  227.       public function updateDialogs(update:Update) : void
  228.       {
  229.          for(var i:int = 0; i < views.length; i++)
  230.          {
  231.             if(views[i] is DialogView)
  232.             {
  233.                views[i].update(update);
  234.             }
  235.          }
  236.       }
  237.       
  238.       public function showConsol() : void
  239.       {
  240.          this.holder.addChild(this.consol);
  241.       }
  242.       
  243.       public function showErrorDialog(data:Object = null) : Dialog
  244.       {
  245.          return this.newDialog(Dialog.NOTICE,data);
  246.       }
  247.       
  248.       public function showToolProps(toolProps:UIView) : void
  249.       {
  250.          if(toolProps != null)
  251.          {
  252.             this.toolPropsView.setContent(toolProps["uiAsset"]);
  253.          }
  254.       }
  255.       
  256.       public function showNewProject() : void
  257.       {
  258.          if(this.newProjectView == null)
  259.          {
  260.             this.newProjectView = NewProjectView(this.openWindow(NewProjectView));
  261.          }
  262.       }
  263.       
  264.       public function loadHelp(id:String) : void
  265.       {
  266.          if(id != "")
  267.          {
  268.             Help.loadHelp(id);
  269.          }
  270.       }
  271.       
  272.       public function toggleStylePreview() : void
  273.       {
  274.          this.canvasManager.stylePreviewLayer.toggle();
  275.          if(this.canvasManager.stylePreviewLayer.visible)
  276.          {
  277.             this.canvas.lockContent();
  278.          }
  279.          else
  280.          {
  281.             this.canvas.unlockContent(true);
  282.          }
  283.       }
  284.       
  285.       public function toggleFullScreen() : void
  286.       {
  287.          this.main.stage.displayState = this.main.stage.displayState == StageDisplayState.FULL_SCREEN_INTERACTIVE ? StageDisplayState.NORMAL : StageDisplayState.FULL_SCREEN_INTERACTIVE;
  288.       }
  289.       
  290.       public function toggle(b:Boolean, mainMenuToggle:Boolean = true, canvasToggle:Boolean = true, guiToggle:Boolean = true) : void
  291.       {
  292.          this.locked = !b;
  293.          try
  294.          {
  295.             if(canvasToggle)
  296.             {
  297.                this.canvasManager.canvas.mouseChildren = b;
  298.             }
  299.          }
  300.          catch(e:Error)
  301.          {
  302.          }
  303.          if(guiToggle)
  304.          {
  305.             TOP_UI_HOLDER.mouseChildren = b;
  306.             this.holder.mouseChildren = b;
  307.          }
  308.          if(mainMenuToggle)
  309.          {
  310.             this.mainMenu.toggle(b);
  311.          }
  312.          try
  313.          {
  314.          }
  315.          catch(e:Error)
  316.          {
  317.          }
  318.       }
  319.       
  320.       public function setProject(name:String) : void
  321.       {
  322.          this.updateViews(Update.projectUpdate({"project":name}));
  323.       }
  324.       
  325.       public function pushLayerProps(data:Settings) : void
  326.       {
  327.          this.updateViews(Update.layerUpdate(data));
  328.       }
  329.       
  330.       public function get canvas() : Canvas
  331.       {
  332.          return this.canvasManager.canvas;
  333.       }
  334.       
  335.       public function closeDialog(dialog:Dialog) : void
  336.       {
  337.          this.toggle(true);
  338.          unregisterView(dialog.dialogView);
  339.          var regIndex:int = int(this.registeredDialogIDList.indexOf(dialog.id));
  340.          if(regIndex > -1)
  341.          {
  342.             this.registeredDialogIDList.splice(regIndex,1);
  343.          }
  344.          dialog.dialogView.die();
  345.       }
  346.       
  347.       private function setupAppWindow() : void
  348.       {
  349.          this.main.stage.scaleMode = StageScaleMode.NO_SCALE;
  350.          this.main.stage.align = StageAlign.TOP_LEFT;
  351.          this.main.stage.nativeWindow.x = 50;
  352.          this.main.stage.nativeWindow.y = 40;
  353.          this.main.stage.nativeWindow.minSize = new Point(1100,700);
  354.       }
  355.       
  356.       public function createNewProject(sizeIndex:int) : void
  357.       {
  358.          this.main.newProject(sizeIndex);
  359.       }
  360.       
  361.       private function canvasMouseDown(e:MouseEvent) : void
  362.       {
  363.          if(!this.onCanvas)
  364.          {
  365.             this.onCanvas = true;
  366.             this.mainMenu.toggleEditShortcuts(this.onCanvas);
  367.          }
  368.       }
  369.       
  370.       public function toggleDrawMode(mode:int) : void
  371.       {
  372.          GlobalSettings.DRAW_MODE = mode;
  373.          update(Update.drawModeUpdate({"mode":mode}));
  374.       }
  375.       
  376.       public function closeDialogID(id:String) : void
  377.       {
  378.          var i:int;
  379.          var d:Dialog = null;
  380.          for(i = 0; i < views.length; i++)
  381.          {
  382.             if(views[i] is DialogView)
  383.             {
  384.                if(views[i].id == id)
  385.                {
  386.                   d = views[i].dialogModel;
  387.                }
  388.             }
  389.          }
  390.          try
  391.          {
  392.             this.closeDialog(d);
  393.          }
  394.          catch(e:Error)
  395.          {
  396.          }
  397.       }
  398.       
  399.       public function uiUpdate() : void
  400.       {
  401.          this.updateViews(Update.uiUpdate());
  402.       }
  403.       
  404.       public function pushColorProps(data:Settings) : void
  405.       {
  406.          this.styleManager.lockedColorSettings = this.globalColorView.settings;
  407.          this.styleManager.alphaLocked = this.styleManager.lockedColorSettings.alphaLocked;
  408.          this.updateViews(Update.colorUpdate(data));
  409.       }
  410.       
  411.       private function resizeListener(e:Event) : void
  412.       {
  413.          this.resizeInterface();
  414.       }
  415.       
  416.       public function alert(data:Object = null) : Dialog
  417.       {
  418.          return this.newDialog(Dialog.NOTICE,data);
  419.       }
  420.       
  421.       public function toggleGlobalColor() : void
  422.       {
  423.          this.globalColorView.toggle();
  424.       }
  425.       
  426.       public function showGlobalPrefs() : void
  427.       {
  428.          if(this.globalSettingsView == null)
  429.          {
  430.             this.globalSettingsView = GlobalSettingsView(this.openWindow(GlobalSettingsView));
  431.          }
  432.       }
  433.       
  434.       public function get state() : int
  435.       {
  436.          return this._state;
  437.       }
  438.       
  439.       public function showAbout() : void
  440.       {
  441.          if(this.aboutView == null)
  442.          {
  443.             this.aboutView = BasicWindowView(this.openWindow(BasicWindowView,{"message":Main.ABOUT_INFO}));
  444.          }
  445.       }
  446.       
  447.       public function showProcessDialog(data:Object = null) : Dialog
  448.       {
  449.          return this.newDialog(Dialog.PROCESS,data);
  450.       }
  451.       
  452.       public function fileIO(e:FileEvent) : void
  453.       {
  454.          var data:XML = null;
  455.          if(e.action == FileEvent.OPEN || e.action == FileEvent.BATCH_OPEN)
  456.          {
  457.             switch(e.fileType)
  458.             {
  459.                case FileManager.PROJECT:
  460.             }
  461.          }
  462.       }
  463.       
  464.       private function getToolPropsByName(toolName:String) : UIView
  465.       {
  466.          var toolProps:UIView = null;
  467.          switch(toolName)
  468.          {
  469.             case BrushTool.NAME:
  470.                toolProps = this.brushPropsView;
  471.                break;
  472.             case ColorLayerTool.NAME:
  473.                toolProps = this.bucketPropsView;
  474.                break;
  475.             case SampleTool.NAME:
  476.                toolProps = this.bucketPropsView;
  477.                break;
  478.             case TransformTool.NAME:
  479.                toolProps = this.transformPropsView;
  480.                break;
  481.             case PenTool.NAME:
  482.                toolProps = this.brushPropsView;
  483.          }
  484.          return toolProps;
  485.       }
  486.       
  487.       public function toolSelect(toolName:String) : void
  488.       {
  489.          this.toolManager.setToolByName(toolName);
  490.          this.showToolProps(this.getToolPropsByName(toolName));
  491.       }
  492.       
  493.       public function showLoadDialog(data:Object = null) : Dialog
  494.       {
  495.          return this.newDialog(Dialog.LOADING,data);
  496.       }
  497.       
  498.       public function selectTool(toolName:String) : void
  499.       {
  500.          this.toolbarView.toggleTool(this.toolbarView.getBtnByToolName(toolName).name);
  501.          this.showToolProps(this.getToolPropsByName(toolName));
  502.       }
  503.       
  504.       public function promptForNewVersion(e:FileEvent) : void
  505.       {
  506.          var message:String = "";
  507.          if(e.fileType == FileEvent.NEW_VERSION)
  508.          {
  509.             message = "There is a new major version of LiveBrush.\nWould you like more information?";
  510.             this.newDialog(Dialog.QUESTION,{
  511.                "message":message,
  512.                "yesFunction":function():*
  513.                {
  514.                   FileManager.getURL(Main.HOME_LINK);
  515.                }
  516.             });
  517.          }
  518.          else if(e.fileType == FileEvent.UPDATE_VERSION)
  519.          {
  520.             message = "There is a free update available (" + e.data.newVersion + ").\n" + "Your current version is: " + e.data.currentVersion;
  521.             message += "\nWould you like to download and install this update?";
  522.             this.newDialog(Dialog.QUESTION,{
  523.                "message":message,
  524.                "yesFunction":function():*
  525.                {
  526.                   FileManager.getURL(Main.UPDATE_LINK);
  527.                }
  528.             });
  529.          }
  530.          else if(e.fileType == FileEvent.CURRENT_VERSION)
  531.          {
  532.             message = "You have the most recent version of Livebrush\nVersion " + e.data.currentVersion;
  533.             this.newDialog(Dialog.NOTICE,{"message":message});
  534.          }
  535.       }
  536.       
  537.       public function mainMenuEvent(e:Event) : void
  538.       {
  539.          if((StateManager.state == StateManager.CLOSED && !this.toolManager.activeTool.isRunning || e.target.name == "togglePreview") && (this.registeredDialogIDList.length == 0 && !this.locked) || e.target.name == "stopAllBrushes" || e.target.name == "stopLastBrush")
  540.          {
  541.             switch(e.target.name)
  542.             {
  543.                case "new":
  544.                   this.main.saveFirst(this.main.newProject);
  545.                   break;
  546.                case "open":
  547.                   this.main.openProject();
  548.                   break;
  549.                case "save":
  550.                   this.main.saveProject();
  551.                   break;
  552.                case "saveAs":
  553.                   this.main.saveProjectAs();
  554.                   break;
  555.                case "saveImage":
  556.                   this.main.saveAsImage(0,true);
  557.                   break;
  558.                case "saveLayerImage":
  559.                   this.main.export(FileManager.LAYER_IMAGE);
  560.                   break;
  561.                case "revert":
  562.                   this.main.revertProject();
  563.                   break;
  564.                case "cleanup":
  565.                   this.confirmActionDialog({
  566.                      "message":"This action removes project assets that are not being used. This action cannot be undone.\nWould you like to continue?",
  567.                      "yesFunction":this.main.cleanupProject,
  568.                      "id":"cleanupConfirm"
  569.                   });
  570.                   break;
  571.                case "exit":
  572.                   this.main.exit();
  573.                   break;
  574.                case "importProject":
  575.                   this.confirmActionDialog({
  576.                      "message":"This action will also cause your undo-history to be reset.\n\nWould you like to continue?",
  577.                      "yesFunction":this.main.importToProject,
  578.                      "yesProps":[FileManager.PROJECT],
  579.                      "id":"importConfirm"
  580.                   });
  581.                   break;
  582.                case "importDeco":
  583.                   this.main.importToProject(FileManager.DECO);
  584.                   break;
  585.                case "importDecoSet":
  586.                   this.main.importToProject(FileManager.DECOSET);
  587.                   break;
  588.                case "importImage":
  589.                   this.confirmActionDialog({
  590.                      "message":"This action will also cause your undo-history to be reset.\n\nWould you like to continue?",
  591.                      "yesFunction":this.main.importToProject,
  592.                      "yesProps":[FileManager.LAYER_IMAGE],
  593.                      "id":"importConfirm"
  594.                   });
  595.                   break;
  596.                case "importStyle":
  597.                   this.main.importToProject(FileManager.STYLE);
  598.                   break;
  599.                case "importInputSWF":
  600.                   this.main.importInputSWF();
  601.                   break;
  602.                case "exportSVG":
  603.                   this.main.export(FileManager.SVG);
  604.                   break;
  605.                case "exportDecoSet":
  606.                   this.main.export(FileManager.DECOSET);
  607.                   break;
  608.                case "exportStyle":
  609.                   this.main.export(FileManager.STYLE);
  610.                   break;
  611.                case "exportLayer":
  612.                   this.main.export(FileManager.LAYER_IMAGE);
  613.                   break;
  614.                case "undo":
  615.                   this.activeTool = this.toolManager.activeTool;
  616.                   StateManager.stepBack();
  617.                   this.toolManager.setTool(this.activeTool);
  618.                   break;
  619.                case "redo":
  620.                   this.activeTool = this.toolManager.activeTool;
  621.                   StateManager.stepForward();
  622.                   this.toolManager.setTool(this.activeTool);
  623.                   break;
  624.                case "cut":
  625.                   this.canvasManager.copyContent(true);
  626.                   break;
  627.                case "copy":
  628.                   this.canvasManager.copyContent();
  629.                   break;
  630.                case "paste":
  631.                   this.canvasManager.pasteContent();
  632.                   break;
  633.                case "delete":
  634.                   this.canvasManager.deleteContent();
  635.                   break;
  636.                case "selectAll":
  637.                   this.canvasManager.selectAll();
  638.                   break;
  639.                case "deselectAll":
  640.                   this.canvasManager.deselectAll();
  641.                   break;
  642.                case "showGlobalPrefs":
  643.                   this.showGlobalPrefs();
  644.                   break;
  645.                case "flattenLayers":
  646.                   this.canvasManager.flattenLayers();
  647.                   break;
  648.                case "dupLayer":
  649.                   this.canvasManager.dupLayer(this.canvasManager.activeLayerDepth);
  650.                   break;
  651.                case "applyStyle":
  652.                   this.canvasManager.applyLineStyle();
  653.                   break;
  654.                case "simplifyLine":
  655.                   this.canvasManager.simplifyLine();
  656.                   break;
  657.                case "subdivideLine":
  658.                   this.canvasManager.subdivideLine();
  659.                   break;
  660.                case "toStraightLine":
  661.                   this.canvasManager.convertLine(false);
  662.                   break;
  663.                case "toSmoothLine":
  664.                   this.canvasManager.convertLine(true);
  665.                   break;
  666.                case "redrawLayers":
  667.                   this.canvasManager.refreshLayers();
  668.                   break;
  669.                case "copyEdgeDecos":
  670.                   this.confirmActionDialog({
  671.                      "message":"This action will also cause your undo-history to be reset.\nThe source layers will remain intact.\nWould you like to continue?",
  672.                      "yesFunction":this.canvasManager.detachEdgeDecosToLayers,
  673.                      "yesProps":[true],
  674.                      "id":"detachConfirm"
  675.                   });
  676.                   break;
  677.                case "removeEdgeDecos":
  678.                   this.canvasManager.removeEdgeDecos();
  679.                   break;
  680.                case "layerToDeco":
  681.                   this.canvasManager.layerToDeco(this.canvasManager.activeLayerDepth + 1,false,false);
  682.                   break;
  683.                case "copyLayerToDeco":
  684.                   this.canvasManager.layerToDeco(this.canvasManager.activeLayerDepth + 1,true,false);
  685.                   break;
  686.                case "iLayerToDeco":
  687.                   this.canvasManager.layerToDeco(this.canvasManager.activeLayerDepth + 1,false);
  688.                   break;
  689.                case "iCopyLayerToDeco":
  690.                   this.canvasManager.layerToDeco(this.canvasManager.activeLayerDepth + 1,true);
  691.                   break;
  692.                case "rotateClock":
  693.                   this.canvasManager.rotateLayer(90);
  694.                   break;
  695.                case "rotateCounter":
  696.                   this.canvasManager.rotateLayer(-90);
  697.                   break;
  698.                case "flipX":
  699.                   this.canvasManager.flipLayer(-1,1);
  700.                   break;
  701.                case "flipY":
  702.                   this.canvasManager.flipLayer(1,-1);
  703.                   break;
  704.                case "resetScale":
  705.                   this.canvasManager.resetLayerTransform(true,false,false);
  706.                   break;
  707.                case "resetRotation":
  708.                   this.canvasManager.resetLayerTransform(false,true,false);
  709.                   break;
  710.                case "resetSkew":
  711.                   this.canvasManager.resetLayerTransform(false,false,true);
  712.                   break;
  713.                case "resetTransform":
  714.                   this.canvasManager.resetLayerTransform();
  715.                   break;
  716.                case "styleDecoToLayer":
  717.                   this.canvasManager.styleDecoToLayer();
  718.                   break;
  719.                case "layersToDeco":
  720.                   this.canvasManager.layersToStyleDeco();
  721.                   break;
  722.                case "toggleStyleList":
  723.                   this.styleListView.toggle();
  724.                   this.uiUpdate();
  725.                   break;
  726.                case "stylePreview":
  727.                   this.toggleStylePreview();
  728.                   break;
  729.                case "toggleToolProps":
  730.                   this.toggleToolProps();
  731.                   break;
  732.                case "toggleLayerProps":
  733.                   this.layersView.toggle();
  734.                   this.uiUpdate();
  735.                   break;
  736.                case "toggleFullScreen":
  737.                   this.toggleFullScreen();
  738.                   break;
  739.                case "toggleUI":
  740.                   this.toggleUI();
  741.                   break;
  742.                case "stopAllBrushes":
  743.                   this.canvasManager.toolManager.brushTool.stopAllBrushes();
  744.                   break;
  745.                case "stopLastBrush":
  746.                   this.canvasManager.toolManager.brushTool.stopLastBrush();
  747.                   break;
  748.                case "shareStyles":
  749.                   FileManager.getURL(Main.FORUM_STYLES_LINK);
  750.                   break;
  751.                case "develop":
  752.                   FileManager.getURL(Main.FORUM_DEVELOP_LINK);
  753.                   break;
  754.                case "facebook":
  755.                   FileManager.getURL(Main.FACEBOOK_LINK);
  756.                   break;
  757.                case "twitter":
  758.                   FileManager.getURL(Main.TWITTER_LINK);
  759.                   break;
  760.                case "helpLink":
  761.                   this.loadHelp("main");
  762.                   break;
  763.                case "supportLink":
  764.                   FileManager.getURL(Main.SUPPORT_LINK);
  765.                   break;
  766.                case "feedbackLink":
  767.                   FileManager.getURL(Main.SUPPORT_LINK);
  768.                   break;
  769.                case "forumLink":
  770.                   FileManager.getURL(Main.FORUM_LINK);
  771.                   break;
  772.                case "homeLink":
  773.                   FileManager.getURL(Main.HOME_LINK);
  774.                   break;
  775.                case "checkForUpdates":
  776.                   FileManager.checkForUpdates(true);
  777.                   break;
  778.                case "about":
  779.                   this.showAbout();
  780.             }
  781.          }
  782.          else
  783.          {
  784.             this.busyAlert();
  785.          }
  786.       }
  787.       
  788.       public function toggleToolProps() : void
  789.       {
  790.          if(this.panelState == OPEN)
  791.          {
  792.             this.toolPropsView.toggle();
  793.          }
  794.          else
  795.          {
  796.             this.toolPropsView.toggle(true);
  797.          }
  798.          this.togglePropsPanel(true);
  799.          this.updateViews(Update.uiUpdate());
  800.       }
  801.       
  802.       private function registerDialog(d:Dialog) : void
  803.       {
  804.          this.registeredDialogIDList.push(d.id);
  805.       }
  806.       
  807.       public function initCanvasDependantViews() : void
  808.       {
  809.          this.contextMenu = ContextMenuView(registerView(new ContextMenuView(this)));
  810.          this.canvas.addEventListener(MouseEvent.MOUSE_DOWN,this.canvasMouseDown);
  811.          this.canvas.addEventListener(MouseEvent.MOUSE_OVER,this.canvasMouseDown);
  812.          this.pushColorProps(this.globalColorView.settings);
  813.       }
  814.       
  815.       public function saveImage() : void
  816.       {
  817.          if(this.saveImageView == null)
  818.          {
  819.             this.saveImageView = SaveImageView(this.openWindow(SaveImageView,{"allLayers":true}));
  820.          }
  821.       }
  822.       
  823.       public function openWindow(type:Class, data:Object = null) : UIView
  824.       {
  825.          this.toggle(false);
  826.          var v:UIView = new type(this,data);
  827.          registerView(v);
  828.          return v;
  829.       }
  830.       
  831.       public function busyAlert(generic:Boolean = false) : void
  832.       {
  833.          var message:String = null;
  834.          if(GlobalSettings.SHOW_BUSY_WARNINGS)
  835.          {
  836.             if(generic)
  837.             {
  838.                message = "This action cannot be performed at this time.";
  839.             }
  840.             else if(this.toolManager.activeTool == this.toolManager.brushTool)
  841.             {
  842.                message = "Brush Tool is busy. Please wait.\n\nUse CTRL+SHIFT+B to stop all brushes.";
  843.             }
  844.             else if(this.toolManager.activeTool == this.toolManager.penTool)
  845.             {
  846.                message = "Pen Tool is busy. Please wait.";
  847.             }
  848.             else if(this.toolManager.activeTool == this.toolManager.transformTool)
  849.             {
  850.                message = "Transform Tool is busy. Please wait.";
  851.             }
  852.             else
  853.             {
  854.                message = "Processing your last request. Please wait.";
  855.             }
  856.             this.alert({
  857.                "message":message,
  858.                "id":"busyAlert"
  859.             });
  860.          }
  861.       }
  862.       
  863.       public function resizeInterface() : void
  864.       {
  865.          WIDTH = this.holder.stage.stageWidth;
  866.          HEIGHT = this.holder.stage.stageHeight;
  867.          this.updateViews(Update.windowUpdate());
  868.       }
  869.       
  870.       public function saveLayerImage() : void
  871.       {
  872.          if(this.saveImageView == null)
  873.          {
  874.             this.saveImageView = SaveImageView(this.openWindow(SaveImageView,{"allLayers":false}));
  875.          }
  876.       }
  877.       
  878.       public function toggleUI() : void
  879.       {
  880.          this.holder.visible = !this.holder.visible;
  881.          this.globalColorView.visible = this.holder.visible;
  882.       }
  883.       
  884.       public function get activeLayer() : Layer
  885.       {
  886.          return this.canvasManager.activeLayer;
  887.       }
  888.       
  889.       private function guiMouseDown(e:MouseEvent) : void
  890.       {
  891.          if(this.onCanvas)
  892.          {
  893.             this.onCanvas = false;
  894.             this.mainMenu.toggleEditShortcuts(this.onCanvas);
  895.          }
  896.          if(!this.holder.mouseChildren)
  897.          {
  898.             this.busyAlert(true);
  899.          }
  900.       }
  901.       
  902.       public function togglePropsPanel(force:Boolean = false) : void
  903.       {
  904.          this.panelState = this.panelState == CLOSED || force ? OPEN : CLOSED;
  905.          this.toolPropsView.visible = this.panelState == OPEN;
  906.          this.layersView.visible = this.panelState == OPEN;
  907.          this.styleListView.visible = this.panelState == OPEN;
  908.          this.updateViews(Update.uiUpdate());
  909.       }
  910.       
  911.       public function pullToolProps(uiView:UIView) : void
  912.       {
  913.          this.toolManager.activeTool.settings = uiView.settings;
  914.          this.pushColorProps(uiView.settings);
  915.       }
  916.       
  917.       public function get activeLayers() : Array
  918.       {
  919.          return this.canvasManager.activeLayers;
  920.       }
  921.       
  922.       public function confirmActionDialog(data:Object) : Dialog
  923.       {
  924.          return this.newDialog(Dialog.QUESTION,data);
  925.       }
  926.    }
  927. }
  928.  
  929.