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 / DecoStyleView.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  15.5 KB  |  398 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.data.Settings;
  4.    import com.livebrush.events.UpdateEvent;
  5.    import com.livebrush.styles.DecoStyle;
  6.    import com.livebrush.utils.Update;
  7.    import fl.controls.List;
  8.    
  9.    public class DecoStyleView extends UIView
  10.    {
  11.       public static const ORDER_TYPES:Array = [{
  12.          "label":"Sequence",
  13.          "data":DecoStyle.SEQUENCE_DECO
  14.       },{
  15.          "label":"Fixed",
  16.          "data":DecoStyle.FIXED_DECO
  17.       },{
  18.          "label":"Random",
  19.          "data":DecoStyle.RANDOM_DECO
  20.       }];
  21.       
  22.       public static const POS_TYPES:Array = [{
  23.          "label":"Fixed",
  24.          "data":DecoStyle.FIXED
  25.       },{
  26.          "label":"(A) Edge",
  27.          "data":DecoStyle.A
  28.       },{
  29.          "label":"(B) Edge",
  30.          "data":DecoStyle.B
  31.       },{
  32.          "label":"Center",
  33.          "data":DecoStyle.CENTER
  34.       },{
  35.          "label":"Alternate",
  36.          "data":DecoStyle.ALT
  37.       },{
  38.          "label":"Draw Speed",
  39.          "data":DecoStyle.SPEED
  40.       },{
  41.          "label":"Stroke Width",
  42.          "data":DecoStyle.WIDTH
  43.       },{
  44.          "label":"Oscillate",
  45.          "data":DecoStyle.OSC
  46.       },{
  47.          "label":"Random",
  48.          "data":DecoStyle.RANDOM
  49.       },{
  50.          "label":"Scatter",
  51.          "data":DecoStyle.SCATTER
  52.       },{
  53.          "label":"Orbit",
  54.          "data":DecoStyle.ORBIT
  55.       }];
  56.       
  57.       public static const ANGLE_TYPES:Array = [{
  58.          "label":"Fixed",
  59.          "data":DecoStyle.FIXED
  60.       },{
  61.          "label":"Stroke Direction",
  62.          "data":DecoStyle.DIR
  63.       },{
  64.          "label":"Draw Speed",
  65.          "data":DecoStyle.SPEED
  66.       },{
  67.          "label":"Stroke Width",
  68.          "data":DecoStyle.WIDTH
  69.       },{
  70.          "label":"Oscillate",
  71.          "data":DecoStyle.OSC
  72.       },{
  73.          "label":"Rotate",
  74.          "data":DecoStyle.ROTATE
  75.       },{
  76.          "label":"Point At Position",
  77.          "data":DecoStyle.POS_DIR
  78.       },{
  79.          "label":"Random",
  80.          "data":DecoStyle.RANDOM
  81.       },{
  82.          "label":"No Change",
  83.          "data":DecoStyle.NONE
  84.       }];
  85.       
  86.       public static const SIZE_TYPES:Array = [{
  87.          "label":"Fixed",
  88.          "data":DecoStyle.FIXED
  89.       },{
  90.          "label":"Draw Speed",
  91.          "data":DecoStyle.SPEED
  92.       },{
  93.          "label":"Stroke Width",
  94.          "data":DecoStyle.WIDTH
  95.       },{
  96.          "label":"Oscillate",
  97.          "data":DecoStyle.OSC
  98.       },{
  99.          "label":"Random",
  100.          "data":DecoStyle.RANDOM
  101.       },{
  102.          "label":"No Change",
  103.          "data":DecoStyle.NONE
  104.       }];
  105.       
  106.       public static const COLOR_TYPES:Array = [{
  107.          "label":"Fixed",
  108.          "data":DecoStyle.FIXED
  109.       },{
  110.          "label":"Multiple",
  111.          "data":DecoStyle.LIST
  112.       },{
  113.          "label":"Random",
  114.          "data":DecoStyle.RANDOM
  115.       },{
  116.          "label":"No Change",
  117.          "data":DecoStyle.NONE
  118.       },{
  119.          "label":"Stroke Color",
  120.          "data":DecoStyle.STROKE
  121.       }];
  122.       
  123.       public static const ALPHA_TYPES:Array = [{
  124.          "label":"Fixed",
  125.          "data":DecoStyle.FIXED
  126.       },{
  127.          "label":"Draw Speed",
  128.          "data":DecoStyle.SPEED
  129.       },{
  130.          "label":"Stroke Width",
  131.          "data":DecoStyle.WIDTH
  132.       },{
  133.          "label":"Oscillate",
  134.          "data":DecoStyle.OSC
  135.       },{
  136.          "label":"Random",
  137.          "data":DecoStyle.RANDOM
  138.       },{
  139.          "label":"Stroke Opacity",
  140.          "data":DecoStyle.STROKE
  141.       }];
  142.       
  143.       public static const TINT_TYPES:Array = [{
  144.          "label":"Fixed",
  145.          "data":DecoStyle.FIXED
  146.       },{
  147.          "label":"Draw Speed",
  148.          "data":DecoStyle.SPEED
  149.       },{
  150.          "label":"Stroke Width",
  151.          "data":DecoStyle.WIDTH
  152.       },{
  153.          "label":"Oscillate",
  154.          "data":DecoStyle.OSC
  155.       },{
  156.          "label":"Random",
  157.          "data":DecoStyle.RANDOM
  158.       }];
  159.       
  160.       public static const ALIGN_TYPES:Array = [{
  161.          "label":"Bottom Left",
  162.          "data":DecoStyle.ALIGN_CORNER
  163.       },{
  164.          "label":"Center",
  165.          "data":DecoStyle.ALIGN_CENTER
  166.       }];
  167.       
  168.       private var _positionType:String = "";
  169.       
  170.       private var _colorInputs:SequenceList;
  171.       
  172.       public var brushPropsModel:BrushPropsModel;
  173.       
  174.       private var _decoInputs:SequenceList;
  175.       
  176.       public var uiAsset:DecoStyleUI;
  177.       
  178.       public function DecoStyleView(brushPropsModel:BrushPropsModel)
  179.       {
  180.          super(brushPropsModel.ui);
  181.          this.brushPropsModel = brushPropsModel;
  182.          init();
  183.       }
  184.       
  185.       override protected function createView() : void
  186.       {
  187.          this.uiAsset = new DecoStyleUI();
  188.          this.uiAsset.decoListHead.label.text = "Decorations".toUpperCase();
  189.          this._decoInputs = new SequenceList(this.uiAsset.decoInputs,DecoListItem);
  190.          this._decoInputs.allowMultipleSelection = false;
  191.          this._decoInputs.speedLabel = "#";
  192.          this._decoInputs.typeList = ORDER_TYPES;
  193.          this._decoInputs.holdInput.label = "Hold";
  194.          this._decoInputs.holdInput.min = 1;
  195.          this.uiAsset.decoPositionHead.label.text = "Position".toUpperCase();
  196.          this.uiAsset.positionInputs.list = POS_TYPES;
  197.          this.uiAsset.decoAngleHead.label.text = "Angle".toUpperCase();
  198.          this.uiAsset.angleInputs.list = ANGLE_TYPES;
  199.          this.uiAsset.decoSizeHead.label.text = "Scale".toUpperCase();
  200.          this.uiAsset.sizeInputs.list = SIZE_TYPES;
  201.          this._colorInputs = new SequenceList(this.uiAsset.colorInputs,ColorListItem);
  202.          this.uiAsset.decoColorHead.label.text = "Color".toUpperCase();
  203.          this._colorInputs.speedLabel = "Tween";
  204.          this._colorInputs.typeList = COLOR_TYPES;
  205.          this._colorInputs.holdInput.label = "Hold";
  206.          this._colorInputs.holdInput.min = 0;
  207.          this.uiAsset.decoTintHead.label.text = "Color Amount".toUpperCase();
  208.          this.uiAsset.tintInputs.list = TINT_TYPES;
  209.          this.uiAsset.decoAlphaHead.label.text = "Opacity".toUpperCase();
  210.          this.uiAsset.alphaInputs.list = ALPHA_TYPES;
  211.          this.uiAsset.decoAlignHead.label.text = "Align".toUpperCase();
  212.          this.uiAsset.alignInputs.list = ALIGN_TYPES;
  213.          this.uiAsset.alignInputs.toggleInput(0,false);
  214.          this.uiAsset.alignInputs.toggleInput(1,false);
  215.          this.uiAsset.alignInputs.toggleInput(2,false);
  216.          this.uiAsset.positionInputs.setMinMax(-100,200);
  217.          this.uiAsset.angleInputs.setMinMax(0,360,1,360);
  218.          this.uiAsset.sizeInputs.setMinMax(1,1000,1,100);
  219.          this.uiAsset.tintInputs.setMinMax(0,100,1,100);
  220.          this.uiAsset.alphaInputs.setMinMax(0,100,1,100);
  221.          Tooltip.addTip(this.uiAsset.decoInputs._listEditor.addBtn,"Import deco");
  222.          Tooltip.addTip(this.uiAsset.decoInputs._listEditor.removeBtn,"Remove selected deco");
  223.          Tooltip.addTip(this.uiAsset.decoInputs._listEditor.upBtn,"Move deco up");
  224.          Tooltip.addTip(this.uiAsset.decoInputs._listEditor.downBtn,"Move deco down");
  225.          Tooltip.addTip(this.uiAsset.colorInputs._listEditor.addBtn,"Duplicate selected color");
  226.          Tooltip.addTip(this.uiAsset.colorInputs._listEditor.removeBtn,"Remove selected color");
  227.          Tooltip.addTip(this.uiAsset.colorInputs._listEditor.upBtn,"Move color up");
  228.          Tooltip.addTip(this.uiAsset.colorInputs._listEditor.downBtn,"Move color down");
  229.       }
  230.       
  231.       override public function get settings() : Settings
  232.       {
  233.          var settings:Settings = new Settings();
  234.          settings.decos = this._decoInputs.list;
  235.          settings.selectedDecoIndex = this._decoInputs.selectedIndex;
  236.          settings.orderType = this._decoInputs.type;
  237.          settings.decoNum = this._decoInputs.speed;
  238.          settings.decoHold = this._decoInputs.holdInput.value;
  239.          settings.persist = this.uiAsset.persist.selected;
  240.          settings.posType = this.uiAsset.positionInputs.type;
  241.          if(this.uiAsset.positionInputs.type == DecoStyle.SCATTER || this.uiAsset.positionInputs.type == DecoStyle.ORBIT)
  242.          {
  243.             settings.minPos = this.uiAsset.positionInputs.min;
  244.             settings.maxPos = this.uiAsset.positionInputs.max;
  245.          }
  246.          else
  247.          {
  248.             settings.minPos = this.uiAsset.positionInputs.min / 100;
  249.             settings.maxPos = this.uiAsset.positionInputs.max / 100;
  250.          }
  251.          settings.posSpeed = this.uiAsset.positionInputs.speed / 100;
  252.          settings.angleType = this.uiAsset.angleInputs.type;
  253.          settings.autoFlip = this.uiAsset.autoFlip.selected;
  254.          settings.minAngle = this.uiAsset.angleInputs.min;
  255.          settings.maxAngle = this.uiAsset.angleInputs.max;
  256.          settings.angleSpeed = this.uiAsset.angleInputs.speed;
  257.          settings.colorType = this._colorInputs.type;
  258.          settings.colorObjList = this._colorInputs.list;
  259.          settings.colorSteps = this._colorInputs.speed;
  260.          settings.colorHold = this._colorInputs.holdInput.value;
  261.          settings.tintType = this.uiAsset.tintInputs.type;
  262.          settings.minTint = this.uiAsset.tintInputs.min / 100;
  263.          settings.maxTint = this.uiAsset.tintInputs.max / 100;
  264.          settings.tintSpeed = this.uiAsset.tintInputs.speed / 100;
  265.          settings.sizeType = this.uiAsset.sizeInputs.type;
  266.          settings.minSize = this.uiAsset.sizeInputs.min / 100;
  267.          settings.maxSize = this.uiAsset.sizeInputs.max / 100;
  268.          settings.sizeSpeed = this.uiAsset.sizeInputs.speed / 100;
  269.          settings.alphaType = this.uiAsset.alphaInputs.type;
  270.          settings.minAlpha = this.uiAsset.alphaInputs.min / 100;
  271.          settings.maxAlpha = this.uiAsset.alphaInputs.max / 100;
  272.          settings.alphaSpeed = this.uiAsset.alphaInputs.speed / 100;
  273.          settings.alignType = this.uiAsset.alignInputs.type;
  274.          return settings;
  275.       }
  276.       
  277.       override public function set settings(settings:Settings) : void
  278.       {
  279.          this._decoInputs.dataProvider = settings.decos;
  280.          this._decoInputs.selectedIndex = settings.selectedDecoIndex;
  281.          this._decoInputs.typeInput.selectedIndex = Settings.idToIndex(settings.orderType,ORDER_TYPES,"data");
  282.          this._decoInputs.speed = settings.decoNum;
  283.          this._decoInputs.holdInput.value = settings.decoHold;
  284.          this.uiAsset.persist.selected = settings.persist;
  285.          this.uiAsset.positionInputs.type = settings.posType;
  286.          this._positionType = settings.posType;
  287.          if(settings.posType == DecoStyle.SCATTER || settings.posType == DecoStyle.ORBIT)
  288.          {
  289.             this.uiAsset.positionInputs.min = settings.minPos;
  290.             this.uiAsset.positionInputs.max = settings.maxPos;
  291.          }
  292.          else
  293.          {
  294.             this.uiAsset.positionInputs.min = settings.minPos * 100;
  295.             this.uiAsset.positionInputs.max = settings.maxPos * 100;
  296.          }
  297.          this.uiAsset.positionInputs.speed = settings.posSpeed * 100;
  298.          this.uiAsset.angleInputs.type = settings.angleType;
  299.          this.uiAsset.autoFlip.selected = settings.autoFlip;
  300.          this.uiAsset.angleInputs.min = settings.minAngle;
  301.          this.uiAsset.angleInputs.max = settings.maxAngle;
  302.          this.uiAsset.angleInputs.speed = settings.angleSpeed;
  303.          this.uiAsset.sizeInputs.type = settings.sizeType;
  304.          this.uiAsset.sizeInputs.min = settings.minSize * 100;
  305.          this.uiAsset.sizeInputs.max = settings.maxSize * 100;
  306.          this.uiAsset.sizeInputs.speed = settings.sizeSpeed * 100;
  307.          this._colorInputs.type = settings.colorType;
  308.          this._colorInputs.dataProvider = settings.colorObjList;
  309.          this._colorInputs.speed = settings.colorSteps;
  310.          this._colorInputs.holdInput.value = settings.colorHold;
  311.          this.uiAsset.tintInputs.type = settings.tintType;
  312.          this.uiAsset.tintInputs.min = settings.minTint * 100;
  313.          this.uiAsset.tintInputs.max = settings.maxTint * 100;
  314.          this.uiAsset.tintInputs.speed = settings.tintSpeed * 100;
  315.          this.uiAsset.alphaInputs.type = settings.alphaType;
  316.          this.uiAsset.alphaInputs.min = settings.minAlpha * 100;
  317.          this.uiAsset.alphaInputs.max = settings.maxAlpha * 100;
  318.          this.uiAsset.alphaInputs.speed = settings.alphaSpeed * 100;
  319.          this.uiAsset.alignInputs.type = settings.alignType;
  320.          if(settings.decos.length > 0)
  321.          {
  322.             this.uiAsset.autoFlip.enabled = this.uiAsset.positionInputs.enabled = this.uiAsset.angleInputs.enabled = this.uiAsset.tintInputs.enabled = this.uiAsset.alignInputs.enabled = this.uiAsset.alphaInputs.enabled = this.uiAsset.sizeInputs.enabled = this._colorInputs.enabled = true;
  323.          }
  324.          else
  325.          {
  326.             this.uiAsset.autoFlip.enabled = this.uiAsset.positionInputs.enabled = this.uiAsset.angleInputs.enabled = this.uiAsset.tintInputs.enabled = this.uiAsset.alignInputs.enabled = this.uiAsset.alphaInputs.enabled = this.uiAsset.sizeInputs.enabled = this._colorInputs.enabled = false;
  327.          }
  328.          this.applyProps();
  329.       }
  330.       
  331.       public function applyProps() : void
  332.       {
  333.          try
  334.          {
  335.             if(this.uiAsset.positionInputs.type == DecoStyle.SCATTER || this.uiAsset.positionInputs.type == DecoStyle.ORBIT)
  336.             {
  337.                this.uiAsset.positionInputs.label1 = "Angle";
  338.                this.uiAsset.positionInputs.label2 = "Radius";
  339.                this.uiAsset.positionInputs.toggleInput(2,false);
  340.                this.uiAsset.positionInputs._input0.min = 0;
  341.                this.uiAsset.positionInputs._input0.max = 360;
  342.                this.uiAsset.positionInputs._input1.min = 0;
  343.                this.uiAsset.positionInputs._input1.max = 1000;
  344.             }
  345.             else
  346.             {
  347.                this.uiAsset.positionInputs.label1 = "Min";
  348.                this.uiAsset.positionInputs.label2 = "Max";
  349.                this.uiAsset.positionInputs.toggleInput(2,true);
  350.                this.uiAsset.positionInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.positionInputs.type);
  351.                this.uiAsset.positionInputs.setMinMax(-100,200);
  352.             }
  353.             this.uiAsset.persist.enabled = this._decoInputs.speed > 1;
  354.             this.uiAsset.angleInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.angleInputs.type);
  355.             this.uiAsset.alphaInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.alphaInputs.type);
  356.             this.uiAsset.tintInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.tintInputs.type);
  357.             this.uiAsset.sizeInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.sizeInputs.type);
  358.             this._colorInputs.speedEnabled = DecoStyle.LIST == String(this._colorInputs.type);
  359.          }
  360.          catch(e:Error)
  361.          {
  362.          }
  363.       }
  364.       
  365.       public function get colorInputs() : SequenceList
  366.       {
  367.          return this._colorInputs;
  368.       }
  369.       
  370.       override public function update(update:Update = null) : void
  371.       {
  372.          if(!(update.type == UpdateEvent.WINDOW || update.type == UpdateEvent.UI))
  373.          {
  374.             if(update.type == UpdateEvent.BRUSH_STYLE)
  375.             {
  376.                this.settings = update.data.deco as Settings;
  377.             }
  378.          }
  379.       }
  380.       
  381.       public function get decoInputs() : SequenceList
  382.       {
  383.          return this._decoInputs;
  384.       }
  385.       
  386.       public function get list() : List
  387.       {
  388.          return this.uiAsset.styleList;
  389.       }
  390.       
  391.       override protected function createController() : void
  392.       {
  393.          controller = new DecoStyleController(this);
  394.       }
  395.    }
  396. }
  397.  
  398.