home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.ui
- {
- import com.livebrush.data.Settings;
- import com.livebrush.events.UpdateEvent;
- import com.livebrush.styles.DecoStyle;
- import com.livebrush.utils.Update;
- import fl.controls.List;
-
- public class DecoStyleView extends UIView
- {
- public static const ORDER_TYPES:Array = [{
- "label":"Sequence",
- "data":DecoStyle.SEQUENCE_DECO
- },{
- "label":"Fixed",
- "data":DecoStyle.FIXED_DECO
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM_DECO
- }];
-
- public static const POS_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"(A) Edge",
- "data":DecoStyle.A
- },{
- "label":"(B) Edge",
- "data":DecoStyle.B
- },{
- "label":"Center",
- "data":DecoStyle.CENTER
- },{
- "label":"Alternate",
- "data":DecoStyle.ALT
- },{
- "label":"Draw Speed",
- "data":DecoStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":DecoStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":DecoStyle.OSC
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- },{
- "label":"Scatter",
- "data":DecoStyle.SCATTER
- },{
- "label":"Orbit",
- "data":DecoStyle.ORBIT
- }];
-
- public static const ANGLE_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"Stroke Direction",
- "data":DecoStyle.DIR
- },{
- "label":"Draw Speed",
- "data":DecoStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":DecoStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":DecoStyle.OSC
- },{
- "label":"Rotate",
- "data":DecoStyle.ROTATE
- },{
- "label":"Point At Position",
- "data":DecoStyle.POS_DIR
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- },{
- "label":"No Change",
- "data":DecoStyle.NONE
- }];
-
- public static const SIZE_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":DecoStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":DecoStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":DecoStyle.OSC
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- },{
- "label":"No Change",
- "data":DecoStyle.NONE
- }];
-
- public static const COLOR_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"Multiple",
- "data":DecoStyle.LIST
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- },{
- "label":"No Change",
- "data":DecoStyle.NONE
- },{
- "label":"Stroke Color",
- "data":DecoStyle.STROKE
- }];
-
- public static const ALPHA_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":DecoStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":DecoStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":DecoStyle.OSC
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- },{
- "label":"Stroke Opacity",
- "data":DecoStyle.STROKE
- }];
-
- public static const TINT_TYPES:Array = [{
- "label":"Fixed",
- "data":DecoStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":DecoStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":DecoStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":DecoStyle.OSC
- },{
- "label":"Random",
- "data":DecoStyle.RANDOM
- }];
-
- public static const ALIGN_TYPES:Array = [{
- "label":"Bottom Left",
- "data":DecoStyle.ALIGN_CORNER
- },{
- "label":"Center",
- "data":DecoStyle.ALIGN_CENTER
- }];
-
- private var _positionType:String = "";
-
- private var _colorInputs:SequenceList;
-
- public var brushPropsModel:BrushPropsModel;
-
- private var _decoInputs:SequenceList;
-
- public var uiAsset:DecoStyleUI;
-
- public function DecoStyleView(brushPropsModel:BrushPropsModel)
- {
- super(brushPropsModel.ui);
- this.brushPropsModel = brushPropsModel;
- init();
- }
-
- override protected function createView() : void
- {
- this.uiAsset = new DecoStyleUI();
- this.uiAsset.decoListHead.label.text = "Decorations".toUpperCase();
- this._decoInputs = new SequenceList(this.uiAsset.decoInputs,DecoListItem);
- this._decoInputs.allowMultipleSelection = false;
- this._decoInputs.speedLabel = "#";
- this._decoInputs.typeList = ORDER_TYPES;
- this._decoInputs.holdInput.label = "Hold";
- this._decoInputs.holdInput.min = 1;
- this.uiAsset.decoPositionHead.label.text = "Position".toUpperCase();
- this.uiAsset.positionInputs.list = POS_TYPES;
- this.uiAsset.decoAngleHead.label.text = "Angle".toUpperCase();
- this.uiAsset.angleInputs.list = ANGLE_TYPES;
- this.uiAsset.decoSizeHead.label.text = "Scale".toUpperCase();
- this.uiAsset.sizeInputs.list = SIZE_TYPES;
- this._colorInputs = new SequenceList(this.uiAsset.colorInputs,ColorListItem);
- this.uiAsset.decoColorHead.label.text = "Color".toUpperCase();
- this._colorInputs.speedLabel = "Tween";
- this._colorInputs.typeList = COLOR_TYPES;
- this._colorInputs.holdInput.label = "Hold";
- this._colorInputs.holdInput.min = 0;
- this.uiAsset.decoTintHead.label.text = "Color Amount".toUpperCase();
- this.uiAsset.tintInputs.list = TINT_TYPES;
- this.uiAsset.decoAlphaHead.label.text = "Opacity".toUpperCase();
- this.uiAsset.alphaInputs.list = ALPHA_TYPES;
- this.uiAsset.decoAlignHead.label.text = "Align".toUpperCase();
- this.uiAsset.alignInputs.list = ALIGN_TYPES;
- this.uiAsset.alignInputs.toggleInput(0,false);
- this.uiAsset.alignInputs.toggleInput(1,false);
- this.uiAsset.alignInputs.toggleInput(2,false);
- this.uiAsset.positionInputs.setMinMax(-100,200);
- this.uiAsset.angleInputs.setMinMax(0,360,1,360);
- this.uiAsset.sizeInputs.setMinMax(1,1000,1,100);
- this.uiAsset.tintInputs.setMinMax(0,100,1,100);
- this.uiAsset.alphaInputs.setMinMax(0,100,1,100);
- Tooltip.addTip(this.uiAsset.decoInputs._listEditor.addBtn,"Import deco");
- Tooltip.addTip(this.uiAsset.decoInputs._listEditor.removeBtn,"Remove selected deco");
- Tooltip.addTip(this.uiAsset.decoInputs._listEditor.upBtn,"Move deco up");
- Tooltip.addTip(this.uiAsset.decoInputs._listEditor.downBtn,"Move deco down");
- Tooltip.addTip(this.uiAsset.colorInputs._listEditor.addBtn,"Duplicate selected color");
- Tooltip.addTip(this.uiAsset.colorInputs._listEditor.removeBtn,"Remove selected color");
- Tooltip.addTip(this.uiAsset.colorInputs._listEditor.upBtn,"Move color up");
- Tooltip.addTip(this.uiAsset.colorInputs._listEditor.downBtn,"Move color down");
- }
-
- override public function get settings() : Settings
- {
- var settings:Settings = new Settings();
- settings.decos = this._decoInputs.list;
- settings.selectedDecoIndex = this._decoInputs.selectedIndex;
- settings.orderType = this._decoInputs.type;
- settings.decoNum = this._decoInputs.speed;
- settings.decoHold = this._decoInputs.holdInput.value;
- settings.persist = this.uiAsset.persist.selected;
- settings.posType = this.uiAsset.positionInputs.type;
- if(this.uiAsset.positionInputs.type == DecoStyle.SCATTER || this.uiAsset.positionInputs.type == DecoStyle.ORBIT)
- {
- settings.minPos = this.uiAsset.positionInputs.min;
- settings.maxPos = this.uiAsset.positionInputs.max;
- }
- else
- {
- settings.minPos = this.uiAsset.positionInputs.min / 100;
- settings.maxPos = this.uiAsset.positionInputs.max / 100;
- }
- settings.posSpeed = this.uiAsset.positionInputs.speed / 100;
- settings.angleType = this.uiAsset.angleInputs.type;
- settings.autoFlip = this.uiAsset.autoFlip.selected;
- settings.minAngle = this.uiAsset.angleInputs.min;
- settings.maxAngle = this.uiAsset.angleInputs.max;
- settings.angleSpeed = this.uiAsset.angleInputs.speed;
- settings.colorType = this._colorInputs.type;
- settings.colorObjList = this._colorInputs.list;
- settings.colorSteps = this._colorInputs.speed;
- settings.colorHold = this._colorInputs.holdInput.value;
- settings.tintType = this.uiAsset.tintInputs.type;
- settings.minTint = this.uiAsset.tintInputs.min / 100;
- settings.maxTint = this.uiAsset.tintInputs.max / 100;
- settings.tintSpeed = this.uiAsset.tintInputs.speed / 100;
- settings.sizeType = this.uiAsset.sizeInputs.type;
- settings.minSize = this.uiAsset.sizeInputs.min / 100;
- settings.maxSize = this.uiAsset.sizeInputs.max / 100;
- settings.sizeSpeed = this.uiAsset.sizeInputs.speed / 100;
- settings.alphaType = this.uiAsset.alphaInputs.type;
- settings.minAlpha = this.uiAsset.alphaInputs.min / 100;
- settings.maxAlpha = this.uiAsset.alphaInputs.max / 100;
- settings.alphaSpeed = this.uiAsset.alphaInputs.speed / 100;
- settings.alignType = this.uiAsset.alignInputs.type;
- return settings;
- }
-
- override public function set settings(settings:Settings) : void
- {
- this._decoInputs.dataProvider = settings.decos;
- this._decoInputs.selectedIndex = settings.selectedDecoIndex;
- this._decoInputs.typeInput.selectedIndex = Settings.idToIndex(settings.orderType,ORDER_TYPES,"data");
- this._decoInputs.speed = settings.decoNum;
- this._decoInputs.holdInput.value = settings.decoHold;
- this.uiAsset.persist.selected = settings.persist;
- this.uiAsset.positionInputs.type = settings.posType;
- this._positionType = settings.posType;
- if(settings.posType == DecoStyle.SCATTER || settings.posType == DecoStyle.ORBIT)
- {
- this.uiAsset.positionInputs.min = settings.minPos;
- this.uiAsset.positionInputs.max = settings.maxPos;
- }
- else
- {
- this.uiAsset.positionInputs.min = settings.minPos * 100;
- this.uiAsset.positionInputs.max = settings.maxPos * 100;
- }
- this.uiAsset.positionInputs.speed = settings.posSpeed * 100;
- this.uiAsset.angleInputs.type = settings.angleType;
- this.uiAsset.autoFlip.selected = settings.autoFlip;
- this.uiAsset.angleInputs.min = settings.minAngle;
- this.uiAsset.angleInputs.max = settings.maxAngle;
- this.uiAsset.angleInputs.speed = settings.angleSpeed;
- this.uiAsset.sizeInputs.type = settings.sizeType;
- this.uiAsset.sizeInputs.min = settings.minSize * 100;
- this.uiAsset.sizeInputs.max = settings.maxSize * 100;
- this.uiAsset.sizeInputs.speed = settings.sizeSpeed * 100;
- this._colorInputs.type = settings.colorType;
- this._colorInputs.dataProvider = settings.colorObjList;
- this._colorInputs.speed = settings.colorSteps;
- this._colorInputs.holdInput.value = settings.colorHold;
- this.uiAsset.tintInputs.type = settings.tintType;
- this.uiAsset.tintInputs.min = settings.minTint * 100;
- this.uiAsset.tintInputs.max = settings.maxTint * 100;
- this.uiAsset.tintInputs.speed = settings.tintSpeed * 100;
- this.uiAsset.alphaInputs.type = settings.alphaType;
- this.uiAsset.alphaInputs.min = settings.minAlpha * 100;
- this.uiAsset.alphaInputs.max = settings.maxAlpha * 100;
- this.uiAsset.alphaInputs.speed = settings.alphaSpeed * 100;
- this.uiAsset.alignInputs.type = settings.alignType;
- if(settings.decos.length > 0)
- {
- 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;
- }
- else
- {
- 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;
- }
- this.applyProps();
- }
-
- public function applyProps() : void
- {
- try
- {
- if(this.uiAsset.positionInputs.type == DecoStyle.SCATTER || this.uiAsset.positionInputs.type == DecoStyle.ORBIT)
- {
- this.uiAsset.positionInputs.label1 = "Angle";
- this.uiAsset.positionInputs.label2 = "Radius";
- this.uiAsset.positionInputs.toggleInput(2,false);
- this.uiAsset.positionInputs._input0.min = 0;
- this.uiAsset.positionInputs._input0.max = 360;
- this.uiAsset.positionInputs._input1.min = 0;
- this.uiAsset.positionInputs._input1.max = 1000;
- }
- else
- {
- this.uiAsset.positionInputs.label1 = "Min";
- this.uiAsset.positionInputs.label2 = "Max";
- this.uiAsset.positionInputs.toggleInput(2,true);
- this.uiAsset.positionInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.positionInputs.type);
- this.uiAsset.positionInputs.setMinMax(-100,200);
- }
- this.uiAsset.persist.enabled = this._decoInputs.speed > 1;
- this.uiAsset.angleInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.angleInputs.type);
- this.uiAsset.alphaInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.alphaInputs.type);
- this.uiAsset.tintInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.tintInputs.type);
- this.uiAsset.sizeInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.sizeInputs.type);
- this._colorInputs.speedEnabled = DecoStyle.LIST == String(this._colorInputs.type);
- }
- catch(e:Error)
- {
- }
- }
-
- public function get colorInputs() : SequenceList
- {
- return this._colorInputs;
- }
-
- override public function update(update:Update = null) : void
- {
- if(!(update.type == UpdateEvent.WINDOW || update.type == UpdateEvent.UI))
- {
- if(update.type == UpdateEvent.BRUSH_STYLE)
- {
- this.settings = update.data.deco as Settings;
- }
- }
- }
-
- public function get decoInputs() : SequenceList
- {
- return this._decoInputs;
- }
-
- public function get list() : List
- {
- return this.uiAsset.styleList;
- }
-
- override protected function createController() : void
- {
- controller = new DecoStyleController(this);
- }
- }
- }
-
-