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.StrokeStyle;
- import com.livebrush.utils.Update;
- import fl.controls.List;
-
- public class LineStyleView extends UIView
- {
- public static const EDGE_ANGLE_TYPES:Array = [{
- "label":"Fixed",
- "data":StrokeStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":StrokeStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":StrokeStyle.WIDTH
- },{
- "label":"Stroke Direction",
- "data":StrokeStyle.DIR
- },{
- "label":"Oscillate",
- "data":StrokeStyle.OSC
- },{
- "label":"Rotate",
- "data":StrokeStyle.ROTATE
- },{
- "label":"Random",
- "data":StrokeStyle.RANDOM
- }];
-
- public static const STROKE_TYPES:Array = [{
- "label":"Solid",
- "data":StrokeStyle.SOLID_STROKE
- },{
- "label":"Rake",
- "data":StrokeStyle.RAKE_STROKE
- },{
- "label":"Path",
- "data":StrokeStyle.PATH_STROKE
- },{
- "label":"None",
- "data":StrokeStyle.NONE
- }];
-
- public static const WIDTH_TYPES:Array = [{
- "label":"Fixed",
- "data":StrokeStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":StrokeStyle.SPEED
- },{
- "label":"Oscillate",
- "data":StrokeStyle.OSC
- },{
- "label":"Random",
- "data":StrokeStyle.RANDOM
- }];
-
- public static const COLOR_TYPES:Array = [{
- "label":"Fixed",
- "data":StrokeStyle.FIXED
- },{
- "label":"Multiple",
- "data":StrokeStyle.LIST
- },{
- "label":"Brush Position",
- "data":StrokeStyle.SAMPLE_BRUSH
- },{
- "label":"Mouse Position",
- "data":StrokeStyle.SAMPLE
- },{
- "label":"Random",
- "data":StrokeStyle.RANDOM
- },{
- "label":"None",
- "data":StrokeStyle.NONE
- }];
-
- public static const ALPHA_TYPES:Array = [{
- "label":"Fixed",
- "data":StrokeStyle.FIXED
- },{
- "label":"Draw Speed",
- "data":StrokeStyle.SPEED
- },{
- "label":"Stroke Width",
- "data":StrokeStyle.WIDTH
- },{
- "label":"Oscillate",
- "data":StrokeStyle.OSC
- },{
- "label":"Random",
- "data":StrokeStyle.RANDOM
- }];
-
- public static const LINE_TYPES:Array = [{
- "label":"Smooth",
- "data":StrokeStyle.SMOOTH
- },{
- "label":"Straight",
- "data":StrokeStyle.STRAIGHT
- }];
-
- private var _colorInputs:SequenceList;
-
- public var brushPropsModel:BrushPropsModel;
-
- public var uiAsset:LineStyleUI;
-
- public function LineStyleView(brushPropsModel:BrushPropsModel)
- {
- super(brushPropsModel.ui);
- this.brushPropsModel = brushPropsModel;
- init();
- }
-
- override protected function createView() : void
- {
- this.uiAsset = new LineStyleUI();
- this.uiAsset.lineTypeHead.label.text = "Line Type".toUpperCase();
- this.uiAsset.lineType.dataProvider = Settings.arrayToDataProvider(LINE_TYPES);
- this.uiAsset.strokeTypeHead.label.text = "Edge Type".toUpperCase();
- this.uiAsset.strokeInputs.label1 = "Lines";
- this.uiAsset.strokeInputs.label2 = "Weight";
- this.uiAsset.strokeInputs.list = STROKE_TYPES;
- this.uiAsset.strokeInputs.toggleInput(2,false);
- this.uiAsset.lineWidthHead.label.text = "Width".toUpperCase();
- this.uiAsset.widthInputs.list = WIDTH_TYPES;
- this.uiAsset.lineAngleHead.label.text = "Angle".toUpperCase();
- this.uiAsset.angleInputs.list = EDGE_ANGLE_TYPES;
- this._colorInputs = new SequenceList(this.uiAsset.colorInputs,ColorListItem);
- this.uiAsset.lineColorHead.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.lineAlphaHead.label.text = "Opacity".toUpperCase();
- this.uiAsset.alphaInputs.list = ALPHA_TYPES;
- this.uiAsset.strokeInputs.setMinMax(1,500);
- this.uiAsset.strokeInputs._input1.min = 0.25;
- this.uiAsset.strokeInputs._input1.max = 16;
- this.uiAsset.widthInputs.setMinMax(0,1000,1,1000);
- this.uiAsset.angleInputs.setMinMax(0,360,1,360);
- this.uiAsset.alphaInputs.setMinMax(0,100,1,100);
- 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");
- }
-
- public function applyProps() : void
- {
- try
- {
- this.uiAsset.strokeInputs._input0._input.enabled = this.uiAsset.strokeInputs.type == StrokeStyle.RAKE_STROKE || this.uiAsset.strokeInputs.type == StrokeStyle.PATH_STROKE;
- this.uiAsset.strokeInputs._input1._input.enabled = this.uiAsset.strokeInputs._input0._input.enabled;
- this.uiAsset.widthInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.widthInputs.type);
- this.uiAsset.angleInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.angleInputs.type);
- this.uiAsset.alphaInputs.speedEnabled = typeInputIsAutomatic(this.uiAsset.alphaInputs.type);
- this._colorInputs.speedEnabled = StrokeStyle.LIST == String(this._colorInputs.type);
- }
- catch(e:Error)
- {
- }
- }
-
- override public function get settings() : Settings
- {
- var settings:Settings = new Settings();
- settings.smoothing = this.uiAsset.lineType.selectedIndex == 0;
- settings.strokeType = this.uiAsset.strokeInputs.type;
- settings.lines = this.uiAsset.strokeInputs.input0;
- settings.weight = this.uiAsset.strokeInputs.input1;
- settings.angleType = this.uiAsset.angleInputs.type;
- settings.minAngle = this.uiAsset.angleInputs.min;
- settings.maxAngle = this.uiAsset.angleInputs.max;
- settings.angleSpeed = this.uiAsset.angleInputs.speed;
- settings.widthType = this.uiAsset.widthInputs.type;
- settings.minWidth = this.uiAsset.widthInputs.min;
- settings.maxWidth = this.uiAsset.widthInputs.max;
- settings.widthSpeed = this.uiAsset.widthInputs.speed / 100;
- settings.colorType = this._colorInputs.type;
- settings.colorObjList = this._colorInputs.list;
- settings.colorSteps = this._colorInputs.speed;
- settings.colorHold = this._colorInputs.holdInput.value;
- 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;
- return settings;
- }
-
- 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.line as Settings;
- }
- }
- }
-
- override public function set settings(settings:Settings) : void
- {
- this.uiAsset.lineType.selectedIndex = !!settings.smoothing ? 0 : 1;
- this.uiAsset.strokeInputs.type = settings.strokeType;
- this.uiAsset.strokeInputs.input0 = settings.lines;
- this.uiAsset.strokeInputs.input1 = settings.weight;
- this.uiAsset.angleInputs.type = settings.angleType;
- this.uiAsset.angleInputs.min = settings.minAngle;
- this.uiAsset.angleInputs.max = settings.maxAngle;
- this.uiAsset.angleInputs.speed = settings.angleSpeed;
- this.uiAsset.widthInputs.type = settings.widthType;
- this.uiAsset.widthInputs.min = settings.minWidth;
- this.uiAsset.widthInputs.max = settings.maxWidth;
- this.uiAsset.widthInputs.speed = settings.widthSpeed * 100;
- this._colorInputs.type = settings.colorType;
- this._colorInputs.dataProvider = settings.colorObjList;
- this._colorInputs.speed = settings.colorSteps;
- this._colorInputs.holdInput.value = settings.colorHold;
- 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.applyProps();
- }
-
- public function get list() : List
- {
- return this.uiAsset.styleList;
- }
-
- override protected function createController() : void
- {
- controller = new LineStyleController(this);
- }
- }
- }
-
-