home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.ui
- {
- import com.livebrush.data.GlobalSettings;
- import com.livebrush.events.UpdateEvent;
- import com.livebrush.utils.Update;
- import fl.controls.Button;
- import flash.geom.ColorTransform;
- import org.casalib.math.Percent;
- import org.casalib.util.ColorUtil;
-
- public class TitlebarView extends UIView
- {
- public var statusColors:Array;
-
- private var emptyCTF:ColorTransform;
-
- public var applyBtn:Button;
-
- public var brushPropsModel:BrushPropsModel;
-
- public var uiAsset:TitlebarAsset;
-
- public function TitlebarView(ui:UI)
- {
- this.statusColors = [12698049,6684416,16724736];
- super(ui);
- helpID = "main";
- this.brushPropsModel = ui.brushPropsModel;
- init();
- }
-
- override protected function createView() : void
- {
- this.uiAsset = new TitlebarAsset();
- this.uiAsset.cacheAsBitmap = true;
- this.applyBtn = this.uiAsset["applyBtn"];
- this.toggleApplyBtn();
- this.uiAsset.strokeBuffer.label = "Buffer";
- this.uiAsset.strokeBuffer.min = 1;
- UI.UI_HOLDER.addChild(this.uiAsset);
- this.emptyCTF = new ColorTransform();
- }
-
- private function _toggleDrawMode(mode:int) : void
- {
- if(mode == 0)
- {
- this.uiAsset.strokeBuffer.visible = false;
- this.uiAsset.drawVectorsBtn.gotoAndStop(2);
- this.uiAsset.drawPixelsBtn.gotoAndStop(1);
- this.uiAsset.drawVectorsBtn.mouseEnabled = this.uiAsset.drawVectorsBtn.enabled = this.uiAsset.drawVectorsBtn.mouseChildren = false;
- this.uiAsset.drawPixelsBtn.mouseEnabled = this.uiAsset.drawPixelsBtn.enabled = this.uiAsset.drawPixelsBtn.mouseChildren = true;
- }
- else if(mode == 1)
- {
- this.uiAsset.strokeBuffer.visible = true;
- this.uiAsset.drawVectorsBtn.gotoAndStop(1);
- this.uiAsset.drawPixelsBtn.gotoAndStop(2);
- this.uiAsset.drawVectorsBtn.mouseEnabled = this.uiAsset.drawVectorsBtn.enabled = this.uiAsset.drawVectorsBtn.mouseChildren = true;
- this.uiAsset.drawPixelsBtn.mouseEnabled = this.uiAsset.drawPixelsBtn.enabled = this.uiAsset.drawPixelsBtn.mouseChildren = false;
- }
- this.uiAsset.strokeBuffer.value = GlobalSettings.STROKE_BUFFER;
- }
-
- public function set style(s:String) : void
- {
- this.uiAsset.right._style.text = s;
- }
-
- public function set status(s:String) : void
- {
- this.uiAsset._status.text = s;
- this.setStatusColor(s);
- }
-
- private function setStatusColor(s:String = "Ready") : void
- {
- if(s == "Ready")
- {
- this.emptyCTF.color = this.statusColors[0];
- }
- else if(s == "Drawing")
- {
- this.emptyCTF.color = this.statusColors[1];
- }
- else if(s == "Busy" || s.indexOf("Saving") > -1)
- {
- this.emptyCTF.color = this.statusColors[2];
- }
- else
- {
- this.emptyCTF.color = this.statusColors[0];
- }
- this.uiAsset.statusBg.transform.colorTransform = ColorUtil.interpolateColor(new ColorTransform(),this.emptyCTF,new Percent(0.5));
- }
-
- public function toggleApplyBtn() : void
- {
- }
-
- public function set project(s:String) : void
- {
- this.uiAsset._project.text = s;
- }
-
- override public function update(update:Update = null) : void
- {
- var length:int = 0;
- if(update.type == UpdateEvent.WINDOW)
- {
- this.uiAsset.bg.width = UI.WIDTH - 0.7;
- this.uiAsset.right.x = UI.WIDTH - this.uiAsset.right.width;
- }
- else if(update.type == UpdateEvent.BRUSH_STYLE)
- {
- length = int(update.data.styleGroup.length);
- if(length > 1)
- {
- this.style = (length + " Styles Selected").toUpperCase();
- }
- else
- {
- this.style = update.data.styleGroup[0].name;
- }
- }
- else if(update.type == UpdateEvent.PROJECT)
- {
- this.project = update.data.project;
- }
- else if(update.type == UpdateEvent.DRAW_MODE)
- {
- this._toggleDrawMode(update.data.mode);
- }
- }
-
- override protected function createController() : void
- {
- controller = new TitlebarController(this);
- }
- }
- }
-
-