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 / TitlebarView.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  4.6 KB  |  143 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.data.GlobalSettings;
  4.    import com.livebrush.events.UpdateEvent;
  5.    import com.livebrush.utils.Update;
  6.    import fl.controls.Button;
  7.    import flash.geom.ColorTransform;
  8.    import org.casalib.math.Percent;
  9.    import org.casalib.util.ColorUtil;
  10.    
  11.    public class TitlebarView extends UIView
  12.    {
  13.       public var statusColors:Array;
  14.       
  15.       private var emptyCTF:ColorTransform;
  16.       
  17.       public var applyBtn:Button;
  18.       
  19.       public var brushPropsModel:BrushPropsModel;
  20.       
  21.       public var uiAsset:TitlebarAsset;
  22.       
  23.       public function TitlebarView(ui:UI)
  24.       {
  25.          this.statusColors = [12698049,6684416,16724736];
  26.          super(ui);
  27.          helpID = "main";
  28.          this.brushPropsModel = ui.brushPropsModel;
  29.          init();
  30.       }
  31.       
  32.       override protected function createView() : void
  33.       {
  34.          this.uiAsset = new TitlebarAsset();
  35.          this.uiAsset.cacheAsBitmap = true;
  36.          this.applyBtn = this.uiAsset["applyBtn"];
  37.          this.toggleApplyBtn();
  38.          this.uiAsset.strokeBuffer.label = "Buffer";
  39.          this.uiAsset.strokeBuffer.min = 1;
  40.          UI.UI_HOLDER.addChild(this.uiAsset);
  41.          this.emptyCTF = new ColorTransform();
  42.       }
  43.       
  44.       private function _toggleDrawMode(mode:int) : void
  45.       {
  46.          if(mode == 0)
  47.          {
  48.             this.uiAsset.strokeBuffer.visible = false;
  49.             this.uiAsset.drawVectorsBtn.gotoAndStop(2);
  50.             this.uiAsset.drawPixelsBtn.gotoAndStop(1);
  51.             this.uiAsset.drawVectorsBtn.mouseEnabled = this.uiAsset.drawVectorsBtn.enabled = this.uiAsset.drawVectorsBtn.mouseChildren = false;
  52.             this.uiAsset.drawPixelsBtn.mouseEnabled = this.uiAsset.drawPixelsBtn.enabled = this.uiAsset.drawPixelsBtn.mouseChildren = true;
  53.          }
  54.          else if(mode == 1)
  55.          {
  56.             this.uiAsset.strokeBuffer.visible = true;
  57.             this.uiAsset.drawVectorsBtn.gotoAndStop(1);
  58.             this.uiAsset.drawPixelsBtn.gotoAndStop(2);
  59.             this.uiAsset.drawVectorsBtn.mouseEnabled = this.uiAsset.drawVectorsBtn.enabled = this.uiAsset.drawVectorsBtn.mouseChildren = true;
  60.             this.uiAsset.drawPixelsBtn.mouseEnabled = this.uiAsset.drawPixelsBtn.enabled = this.uiAsset.drawPixelsBtn.mouseChildren = false;
  61.          }
  62.          this.uiAsset.strokeBuffer.value = GlobalSettings.STROKE_BUFFER;
  63.       }
  64.       
  65.       public function set style(s:String) : void
  66.       {
  67.          this.uiAsset.right._style.text = s;
  68.       }
  69.       
  70.       public function set status(s:String) : void
  71.       {
  72.          this.uiAsset._status.text = s;
  73.          this.setStatusColor(s);
  74.       }
  75.       
  76.       private function setStatusColor(s:String = "Ready") : void
  77.       {
  78.          if(s == "Ready")
  79.          {
  80.             this.emptyCTF.color = this.statusColors[0];
  81.          }
  82.          else if(s == "Drawing")
  83.          {
  84.             this.emptyCTF.color = this.statusColors[1];
  85.          }
  86.          else if(s == "Busy" || s.indexOf("Saving") > -1)
  87.          {
  88.             this.emptyCTF.color = this.statusColors[2];
  89.          }
  90.          else
  91.          {
  92.             this.emptyCTF.color = this.statusColors[0];
  93.          }
  94.          this.uiAsset.statusBg.transform.colorTransform = ColorUtil.interpolateColor(new ColorTransform(),this.emptyCTF,new Percent(0.5));
  95.       }
  96.       
  97.       public function toggleApplyBtn() : void
  98.       {
  99.       }
  100.       
  101.       public function set project(s:String) : void
  102.       {
  103.          this.uiAsset._project.text = s;
  104.       }
  105.       
  106.       override public function update(update:Update = null) : void
  107.       {
  108.          var length:int = 0;
  109.          if(update.type == UpdateEvent.WINDOW)
  110.          {
  111.             this.uiAsset.bg.width = UI.WIDTH - 0.7;
  112.             this.uiAsset.right.x = UI.WIDTH - this.uiAsset.right.width;
  113.          }
  114.          else if(update.type == UpdateEvent.BRUSH_STYLE)
  115.          {
  116.             length = int(update.data.styleGroup.length);
  117.             if(length > 1)
  118.             {
  119.                this.style = (length + " Styles Selected").toUpperCase();
  120.             }
  121.             else
  122.             {
  123.                this.style = update.data.styleGroup[0].name;
  124.             }
  125.          }
  126.          else if(update.type == UpdateEvent.PROJECT)
  127.          {
  128.             this.project = update.data.project;
  129.          }
  130.          else if(update.type == UpdateEvent.DRAW_MODE)
  131.          {
  132.             this._toggleDrawMode(update.data.mode);
  133.          }
  134.       }
  135.       
  136.       override protected function createController() : void
  137.       {
  138.          controller = new TitlebarController(this);
  139.       }
  140.    }
  141. }
  142.  
  143.