Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added Toolbar

  • Loading branch information...
commit 4847bc1dca57a9a0b405e6abd4b9d2bd20246aad 1 parent 77b0e8f
Jonnie Hallman destroytoday authored
BIN  libs/DestroyFramework.swc
Binary file not shown
BIN  libs/GTween_V2_01.swc
Binary file not shown
7 src/Dwarf-app.xml
@@ -3,11 +3,16 @@
3 3 <id>com.destroytoday.dwarf</id>
4 4 <filename>Dwarf</filename>
5 5 <name>Dwarf</name>
6   - <version>1.0.0 Build 20100126.0</version>
  6 + <version>1.0.0 Build 20100127.1</version>
7 7 <description>Dwarf is a screen toolbox.</description>
8 8 <copyright>Copyright © 2010 Jonnie Hallman</copyright>
9 9 <initialWindow>
10 10 <content>[This value will be overwritten by Flash Builder in the output app.xml]</content>
  11 + <systemChrome>none</systemChrome>
  12 + <transparent>true</transparent>
  13 + <title>Dwarf</title>
  14 + <maximizable>false</maximizable>
  15 + <minimizable>false</minimizable>
11 16 </initialWindow>
12 17 <icon>
13 18 <image16x16>icons/16.png</image16x16>
37 src/Dwarf.as
... ... @@ -1,28 +1,61 @@
1 1 package {
  2 + import com.destroytoday.display.Group;
2 3 import com.destroytoday.dwarf.contexts.ApplicationContext;
3 4 import com.destroytoday.dwarf.views.ruler.RulerView;
  5 + import com.destroytoday.dwarf.views.toolbar.ToolbarView;
  6 + import com.gskinner.motion.GTween;
4 7
5 8 import flash.display.Sprite;
  9 + import flash.display.StageAlign;
  10 + import flash.display.StageScaleMode;
  11 + import flash.geom.Point;
6 12 import flash.ui.Multitouch;
7 13 import flash.ui.MultitouchInputMode;
8 14
  15 + import mx.effects.easing.Quartic;
  16 +
  17 + [SWF(backgroundColor="#222222")]
  18 +
9 19 /**
10 20 * The Dwarf class is the application class.
11 21 * @author Jonnie Hallman
12 22 */
13   - public class Dwarf extends Sprite {
  23 + public class Dwarf extends Group {
14 24 /**
15 25 * The context of the application.
16 26 */
17 27 public var context:ApplicationContext;
18 28
19 29 /**
  30 + * The toolbar for managing tools.
  31 + */
  32 + public var toolbarView:ToolbarView;
  33 +
  34 + /**
20 35 * Constructs the Dwarf instance.
21 36 */
22 37 public function Dwarf() {
23   - context = new ApplicationContext(this);
  38 + GTween.defaultEase = Quartic.easeInOut;
  39 +
  40 + stage.scaleMode = StageScaleMode.NO_SCALE;
  41 + stage.align = StageAlign.TOP_LEFT;
24 42
  43 + stage.nativeWindow.minSize = new Point(0, 0);
25 44 stage.frameRate = 50.0; //TODO - integrate framerate throttler
  45 +
  46 + context = new ApplicationContext(this);
  47 +
  48 + toolbarView = addChild(new ToolbarView()) as ToolbarView;
  49 +
  50 + measureChildren = false;
  51 +
  52 + left = 0.0;
  53 + top = 0.0;
  54 + right = 0.0;
  55 + bottom = 0.0;
  56 +
  57 + updateListeners();
  58 + stage.nativeWindow.activate();
26 59 }
27 60 }
28 61 }
7 src/com/destroytoday/dwarf/assets/Assets.as
@@ -19,8 +19,11 @@ package com.destroytoday.dwarf.assets {
19 19 */
20 20 public static const INTERSTATE_REGULAR_FONT:String = "Interstate-Regular";
21 21
22   - [Embed(source="icons/16.png", mimeType="image/png")]
23   - public static const ICON_16X16:Class;
  22 + /**
  23 + * The System Tray icon (PC only)
  24 + */
  25 + [Embed(source="icons/32.png", mimeType="image/png")]
  26 + public static const ICON_32X32:Class;
24 27
25 28 /**
26 29 * @private
9 src/com/destroytoday/dwarf/assets/Color.as
... ... @@ -1,5 +1,14 @@
1 1 package com.destroytoday.dwarf.assets {
2 2 public class Color {
  3 + // interface colors
  4 + public static const GREY_2:uint = 0x222222;
  5 + public static const GREY_2B:uint = 0x2B2B2B;
  6 + public static const GREY_3:uint = 0x333333;
  7 + public static const GREY_42:uint = 0x424242;
  8 + public static const GREY_A:uint = 0xAAAAAA;
  9 + public static const GREY_C3C6C8:uint = 0xC3C6C8;
  10 +
  11 + // tool colors
3 12 public static const WHITE:uint = 0xFFFFFF;
4 13 public static const BLACK:uint = 0x000000;
5 14 public static const RED:uint = 0xCA3430;
11 src/com/destroytoday/dwarf/constants/ToolbarState.as
... ... @@ -0,0 +1,11 @@
  1 +package com.destroytoday.dwarf.constants {
  2 + public class ToolbarState {
  3 + public static const NORMAL:String = "ToolbarState:normal";
  4 +
  5 + public static const RULER:String = "ToolbarState:ruler";
  6 +
  7 + public function ToolbarState() {
  8 + throw Error("The ToolbarState class cannot be instantiated.");
  9 + }
  10 + }
  11 +}
9 src/com/destroytoday/dwarf/contexts/ApplicationContext.as
@@ -2,12 +2,14 @@ package com.destroytoday.dwarf.contexts {
2 2 import com.destroytoday.dwarf.controllers.AddRulerCommand;
3 3 import com.destroytoday.dwarf.controllers.ToolController;
4 4 import com.destroytoday.dwarf.desktop.IconMenu;
  5 + import com.destroytoday.dwarf.desktop.MacToolbar;
5 6 import com.destroytoday.dwarf.desktop.RulerMenu;
6   - import com.destroytoday.dwarf.desktop.Toolbar;
7 7 import com.destroytoday.dwarf.mediators.RulerMediator;
  8 + import com.destroytoday.dwarf.mediators.ToolbarMediator;
8 9 import com.destroytoday.dwarf.models.ToolModel;
9 10 import com.destroytoday.dwarf.signals.AddRulerSignal;
10 11 import com.destroytoday.dwarf.views.ruler.RulerView;
  12 + import com.destroytoday.dwarf.views.toolbar.ToolbarView;
11 13 import com.destroytoday.util.ApplicationUtil;
12 14
13 15 import flash.display.DisplayObjectContainer;
@@ -35,14 +37,14 @@ package com.destroytoday.dwarf.contexts {
35 37 override public function startup():void {
36 38 injector.mapSingleton(ToolController);
37 39 injector.mapSingleton(ToolModel);
38   - injector.mapSingleton(Toolbar);
  40 + injector.mapSingleton(MacToolbar);
39 41 injector.mapSingleton(IconMenu);
40 42 injector.mapSingleton(RulerMenu);
41 43
42 44 injector.mapValue(AddRulerSignal, signalCommandMap.mapSignalClass(AddRulerSignal, AddRulerCommand));
43 45
44 46 if (ApplicationUtil.mac) {
45   - var toolbar:Toolbar = new Toolbar();
  47 + var toolbar:MacToolbar = new MacToolbar();
46 48
47 49 injector.injectInto(toolbar);
48 50
@@ -53,6 +55,7 @@ package com.destroytoday.dwarf.contexts {
53 55 injector.injectInto(iconMenu);
54 56 iconMenu.setup();
55 57
  58 + mediatorMap.mapView(ToolbarView, ToolbarMediator);
56 59 mediatorMap.mapView(RulerView, RulerMediator);
57 60 }
58 61 }
4 src/com/destroytoday/dwarf/core/ITool.as
... ... @@ -1,4 +1,6 @@
1 1 package com.destroytoday.dwarf.core {
  2 + import flash.display.NativeWindow;
  3 +
2 4 import org.osflash.signals.Signal;
3 5
4 6 public interface ITool {
@@ -11,6 +13,8 @@ package com.destroytoday.dwarf.core {
11 13 function get colorChangeSignal():Signal;
12 14 function get alphaChangeSignal():Signal;
13 15
  16 + function get window():NativeWindow;
  17 +
14 18 function open():void;
15 19 function close():void;
16 20 function maximize():void;
31 src/com/destroytoday/dwarf/desktop/IconMenu.as
@@ -2,13 +2,16 @@ package com.destroytoday.dwarf.desktop {
2 2 import com.destroytoday.desktop.NativeMenuPlus;
3 3 import com.destroytoday.dwarf.assets.Assets;
4 4 import com.destroytoday.dwarf.controllers.ToolController;
  5 + import com.destroytoday.dwarf.models.ToolModel;
5 6 import com.destroytoday.util.ApplicationUtil;
  7 + import com.destroytoday.util.WindowUtil;
6 8
7 9 import flash.desktop.DockIcon;
8 10 import flash.desktop.Icon;
9 11 import flash.desktop.NativeApplication;
10 12 import flash.desktop.SystemTrayIcon;
11 13 import flash.display.NativeMenuItem;
  14 + import flash.events.ScreenMouseEvent;
12 15 import flash.net.URLRequest;
13 16 import flash.net.navigateToURL;
14 17 import flash.ui.Keyboard;
@@ -17,6 +20,9 @@ package com.destroytoday.dwarf.desktop {
17 20 [Inject]
18 21 public var toolController:ToolController;
19 22
  23 + [Inject]
  24 + public var toolModel:ToolModel;
  25 +
20 26 public function IconMenu() {
21 27 }
22 28
@@ -31,19 +37,23 @@ package com.destroytoday.dwarf.desktop {
31 37 <item name="newRuler" label="New Ruler" />
32 38 <separator />
33 39 <item name="closeTool" label="Close Tool" />
  40 + <item name="quit" label="Quit" />
34 41 </menu>;
35 42 } else {
36 43 var icon:SystemTrayIcon = NativeApplication.nativeApplication.icon as SystemTrayIcon;
37 44
38   - icon.bitmaps = [new Assets.ICON_16X16()];
  45 + icon.bitmaps = [new Assets.ICON_32X32()];
39 46 icon.menu = this;
40 47
41 48 data =
42 49 <menu>
43   - <item name="newRuler" keyEquivalentModifiers="control" keyEquivalent="r" label="New Ruler" />
  50 + <item name="newRuler" label="New Ruler" />
44 51 <separator />
45   - <item name="closeTool" keyEquivalentModifiers="control" keyEquivalent="w" label="Close Tool" />
  52 + <item name="closeTool" label="Close Tool" />
  53 + <item name="quit" label="Quit" />
46 54 </menu>;
  55 +
  56 + icon.addEventListener(ScreenMouseEvent.CLICK, iconClickHandler, false, 0, true);
47 57 }
48 58
49 59 //add listeners
@@ -66,6 +76,21 @@ package com.destroytoday.dwarf.desktop {
66 76 case "closeTool":
67 77 toolController.removeCurrentTool();
68 78 break;
  79 + case "quit":
  80 + WindowUtil.closeAll(true);
  81 + break;
  82 + }
  83 + }
  84 +
  85 + /**
  86 + * @private
  87 + * @param event
  88 + */
  89 + protected function iconClickHandler(event:ScreenMouseEvent):void {
  90 + if (toolModel.currentTool.window) {
  91 + NativeApplication.nativeApplication.activate(toolModel.currentTool.window);
  92 + } else {
  93 + NativeApplication.nativeApplication.activate(NativeApplication.nativeApplication.openedWindows[0]);
69 94 }
70 95 }
71 96 }
4 src/com/destroytoday/dwarf/desktop/Toolbar.as → src/com/destroytoday/dwarf/desktop/MacToolbar.as
@@ -17,7 +17,7 @@ package com.destroytoday.dwarf.desktop {
17 17 * The Toolbar class represents the desktop toolbar on Mac.
18 18 * @author Jonnie Hallman
19 19 */
20   - public class Toolbar extends Actor {
  20 + public class MacToolbar {
21 21 [Inject]
22 22 public var toolController:ToolController;
23 23
@@ -57,7 +57,7 @@ package com.destroytoday.dwarf.desktop {
57 57 /**
58 58 * Constructs the Toolbar instance.
59 59 */
60   - public function Toolbar() {
  60 + public function MacToolbar() {
61 61 }
62 62
63 63 /**
62 src/com/destroytoday/dwarf/desktop/RulerMenu.as
... ... @@ -0,0 +1,62 @@
  1 +package com.destroytoday.dwarf.desktop {
  2 + import com.destroytoday.desktop.NativeMenuPlus;
  3 + import com.destroytoday.dwarf.assets.Color;
  4 + import com.destroytoday.dwarf.models.ToolModel;
  5 + import com.destroytoday.dwarf.views.ruler.RulerView;
  6 +
  7 + import flash.display.NativeMenuItem;
  8 + import flash.display.Stage;
  9 + import flash.events.Event;
  10 +
  11 + public class RulerMenu extends NativeMenuPlus {
  12 + [Inject]
  13 + public var toolModel:ToolModel;
  14 +
  15 + public function RulerMenu() {
  16 + setup();
  17 + }
  18 +
  19 + public function setup():void {
  20 + data =
  21 + <menu>
  22 + <item name="800x600" label="800x600" />
  23 + <item name="1024x768" label="1024x768" />
  24 + <separator />
  25 + <item name="red" label="Red" />
  26 + <item name="orange" label="Orange" />
  27 + <item name="yellow" label="Yellow" />
  28 + <item name="green" label="Green" />
  29 + <item name="blue" label="Blue" />
  30 + <item name="black" label="Black" />
  31 + </menu>;
  32 + }
  33 +
  34 + override public function display(stage:Stage, stageX:Number, stageY:Number):void {
  35 + var ruler:RulerView = toolModel.currentTool as RulerView;
  36 +
  37 + for each(var color:String in Color.names) {
  38 + getItemByName(color).checked = ruler.platform.fillColor == Color[color.toUpperCase()];
  39 + }
  40 +
  41 + super.display(stage, stageX, stageY);
  42 + }
  43 +
  44 + override protected function itemSelectHandler(event:Event):void {
  45 + var ruler:RulerView = toolModel.currentTool as RulerView;
  46 + var item:NativeMenuItem = event.currentTarget as NativeMenuItem;
  47 +
  48 + switch(item.name) {
  49 + case "800x600":
  50 + ruler.stage.nativeWindow.width = 800.0;
  51 + ruler.stage.nativeWindow.height = 600.0;
  52 + break;
  53 + case "1024x768":
  54 + ruler.stage.nativeWindow.width = 1024.0;
  55 + ruler.stage.nativeWindow.height = 768.0;
  56 + break;
  57 + default:
  58 + ruler.platform.fillColor = Color[item.name.toUpperCase()];
  59 + }
  60 + }
  61 + }
  62 +}
34 src/com/destroytoday/dwarf/mediators/ToolbarMediator.as
... ... @@ -0,0 +1,34 @@
  1 +package com.destroytoday.dwarf.mediators {
  2 + import com.destroytoday.dwarf.controllers.ToolController;
  3 + import com.destroytoday.dwarf.views.toolbar.ToolbarView;
  4 +
  5 + import flash.events.MouseEvent;
  6 + import flash.net.URLRequest;
  7 + import flash.net.navigateToURL;
  8 +
  9 + import org.robotlegs.mvcs.Mediator;
  10 +
  11 + public class ToolbarMediator extends Mediator {
  12 + [Inject]
  13 + public var toolController:ToolController;
  14 +
  15 + [Inject]
  16 + public var view:ToolbarView;
  17 +
  18 + public function ToolbarMediator() {
  19 + }
  20 +
  21 + override public function onRegister():void {
  22 + eventMap.mapListener(view.applicationButton, MouseEvent.CLICK, applicationButtonClickHandler, MouseEvent);
  23 + eventMap.mapListener(view.rulerButton, MouseEvent.CLICK, rulerButtonClickHandler, MouseEvent);
  24 + }
  25 +
  26 + protected function applicationButtonClickHandler(event:MouseEvent):void {
  27 + navigateToURL(new URLRequest("http://github.com/destroytoday/Dwarf"));
  28 + }
  29 +
  30 + protected function rulerButtonClickHandler(event:MouseEvent):void {
  31 + toolController.addRuler();
  32 + }
  33 + }
  34 +}
6 src/com/destroytoday/dwarf/views/ruler/RulerSizeText.as
... ... @@ -1,8 +1,10 @@
1 1 package com.destroytoday.dwarf.views.ruler {
2 2 import com.destroytoday.display.Group;
3 3 import com.destroytoday.dwarf.assets.Assets;
  4 + import com.destroytoday.dwarf.assets.Color;
4 5 import com.destroytoday.text.TextFieldPlus;
5 6
  7 + import flash.text.AntiAliasType;
6 8 import flash.text.TextFieldAutoSize;
7 9 import flash.text.TextFormat;
8 10
@@ -30,9 +32,11 @@ package com.destroytoday.dwarf.views.ruler {
30 32
31 33 // set components' properties
32 34 textfield.embedFonts = true;
33   - textfield.defaultTextFormat = new TextFormat(Assets.INTERSTATE_REGULAR_FONT, 11, 0xFFFFFF);
  35 + textfield.defaultTextFormat = new TextFormat(Assets.INTERSTATE_REGULAR_FONT, 11, Color.WHITE);
34 36 textfield.selectable = false;
35 37 textfield.autoSize = TextFieldAutoSize.LEFT;
  38 + textfield.antiAliasType = AntiAliasType.ADVANCED;
  39 + textfield.thickness = -100.0;
36 40
37 41 // set instance's properties
38 42 measureChildren = false;
8 src/com/destroytoday/dwarf/views/ruler/RulerView.as
@@ -134,6 +134,14 @@ package com.destroytoday.dwarf.views.ruler {
134 134 }
135 135
136 136 /**
  137 + * Returns the Ruler's native window.
  138 + * @return
  139 + */
  140 + public function get window():NativeWindow {
  141 + return stage.nativeWindow;
  142 + }
  143 +
  144 + /**
137 145 * The color of the Ruler's platform.
138 146 * @return
139 147 */
101 src/com/destroytoday/dwarf/views/toolbar/TextButton.as
... ... @@ -0,0 +1,101 @@
  1 +package com.destroytoday.dwarf.views.toolbar {
  2 + import com.destroytoday.display.Group;
  3 + import com.destroytoday.dwarf.assets.Assets;
  4 + import com.destroytoday.dwarf.assets.Color;
  5 + import com.destroytoday.text.TextFieldPlus;
  6 +
  7 + import flash.display.CapsStyle;
  8 + import flash.display.Sprite;
  9 + import flash.events.MouseEvent;
  10 + import flash.text.AntiAliasType;
  11 + import flash.text.TextFieldAutoSize;
  12 + import flash.text.TextFormat;
  13 +
  14 + import org.osmf.display.ScaleMode;
  15 +
  16 + public class TextButton extends Group {
  17 + public var textfield:TextFieldPlus;
  18 +
  19 + protected var _maxWidth:Number = Number.MAX_VALUE;
  20 +
  21 + protected var _fillColor:uint = Color.GREY_3;
  22 +
  23 + public function TextButton() {
  24 + textfield = addChild(new TextFieldPlus()) as TextFieldPlus;
  25 +
  26 + textfield.embedFonts = true;
  27 + textfield.defaultTextFormat = new TextFormat(Assets.INTERSTATE_REGULAR_FONT, 11, Color.GREY_C3C6C8);
  28 + textfield.selectable = false;
  29 + textfield.autoSize = TextFieldAutoSize.LEFT;
  30 + textfield.antiAliasType = AntiAliasType.ADVANCED;
  31 +
  32 + textfield.x = 4.0;
  33 + textfield.y = 5.0;
  34 +
  35 + measureChildren = false;
  36 + buttonMode = true;
  37 + mouseChildren = false;
  38 +
  39 + height = 25.0;
  40 +
  41 + draw();
  42 +
  43 + addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
  44 + addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
  45 + }
  46 +
  47 + public function get maxWidth():Number {
  48 + return _maxWidth;
  49 + }
  50 +
  51 + public function set maxWidth(value:Number):void {
  52 + _maxWidth = value;
  53 +
  54 + width = Math.min(_maxWidth, width);
  55 +
  56 + draw();
  57 + }
  58 +
  59 + public function get text():String {
  60 + return textfield.text;
  61 + }
  62 +
  63 + public function set text(value:String):void {
  64 + textfield.text = value;
  65 +
  66 + width = Math.min(_maxWidth, Math.round(textfield.width + 9.0));
  67 +
  68 + draw();
  69 + }
  70 +
  71 + public function get fillColor():uint {
  72 + return _fillColor;
  73 + }
  74 +
  75 + public function set fillColor(value:uint):void {
  76 + _fillColor = value;
  77 +
  78 + draw();
  79 + }
  80 +
  81 + public function draw():void {
  82 + graphics.clear();
  83 + graphics.beginFill(fillColor);
  84 + graphics.drawRect(0.0, 0.0, width, height);
  85 + graphics.endFill();
  86 + graphics.lineStyle(0.0, Color.GREY_2, 1.0, false, ScaleMode.NONE, CapsStyle.SQUARE);
  87 + graphics.moveTo(0.0, 0.0);
  88 + graphics.lineTo(0.0, height - 1.0);
  89 + graphics.moveTo(width - 1.0, 0.0);
  90 + graphics.lineTo(width - 1.0, height - 1.0);
  91 + }
  92 +
  93 + protected function mouseOverHandler(event:MouseEvent):void {
  94 + fillColor = Color.GREY_42;
  95 + }
  96 +
  97 + protected function mouseOutHandler(event:MouseEvent):void {
  98 + fillColor = Color.GREY_3;
  99 + }
  100 + }
  101 +}
133 src/com/destroytoday/dwarf/views/toolbar/ToolbarView.as
... ... @@ -0,0 +1,133 @@
  1 +package com.destroytoday.dwarf.views.toolbar {
  2 + import com.destroytoday.display.Group;
  3 + import com.destroytoday.display.GroupAlignType;
  4 + import com.destroytoday.dwarf.assets.Color;
  5 + import com.destroytoday.dwarf.constants.ToolbarState;
  6 + import com.gskinner.motion.GTween;
  7 +
  8 + import flash.desktop.NativeApplication;
  9 + import flash.display.NativeWindow;
  10 + import flash.display.NativeWindowInitOptions;
  11 + import flash.display.NativeWindowSystemChrome;
  12 + import flash.display.Screen;
  13 + import flash.display.Stage;
  14 + import flash.events.Event;
  15 + import flash.events.NativeWindowBoundsEvent;
  16 + import flash.geom.Rectangle;
  17 +
  18 + public class ToolbarView extends Group {
  19 + public var applicationButton:TextButton;
  20 + public var rulerButton:TextButton;
  21 +
  22 + protected var positionTween:GTween;
  23 +
  24 + protected var bounds:Rectangle;
  25 +
  26 + protected var _state:String = ToolbarState.NORMAL;
  27 +
  28 + public function ToolbarView() {
  29 + applicationButton = addChild(new TextButton()) as TextButton;
  30 + rulerButton = addChild(new TextButton()) as TextButton;
  31 +
  32 + applicationButton.paddingRight = 2.0;
  33 + applicationButton.maxWidth = 27.0;
  34 + applicationButton.text = "Dw";
  35 + applicationButton.textfield.x = 2.0;
  36 + applicationButton.textfield.textColor = Color.RED;
  37 +
  38 + rulerButton.text = "Ruler";
  39 +
  40 + positionTween = new GTween(this, 0.75);
  41 +
  42 + measureChildren = false;
  43 + align = GroupAlignType.LEFT;
  44 + gap = 1.0;
  45 +
  46 + left = 0.0;
  47 + right = 0.0;
  48 + height = 25.0;
  49 +
  50 + scrollRect = bounds = new Rectangle(0.0, height, 0.0, height);
  51 +
  52 + positionTween.onInit = positionTweenInitHandler;
  53 + positionTween.onComplete = positionTweenCompleteHandler;
  54 + }
  55 +
  56 + override public function get y():Number {
  57 + return (bounds) ? bounds.y : 0.0;
  58 + }
  59 +
  60 + override public function set y(value:Number):void {
  61 + if (bounds) {
  62 + bounds.y = value;
  63 +
  64 + scrollRect = bounds;
  65 + }
  66 + }
  67 +
  68 + public function resize():void {
  69 + var screen:Rectangle = Screen.mainScreen.visibleBounds;
  70 +
  71 + stage.nativeWindow.x = screen.x;
  72 + stage.nativeWindow.y = screen.y;
  73 + stage.nativeWindow.width = Screen.mainScreen.bounds.width;
  74 + stage.nativeWindow.height = height;
  75 + }
  76 +
  77 + public function get state():String {
  78 + return _state;
  79 + }
  80 +
  81 + public function set state(value:String):void {
  82 + _state = value;
  83 + }
  84 +
  85 + override protected function updateBounds():void {
  86 + super.updateBounds();
  87 +
  88 + if (bounds) {
  89 + bounds.width = width;
  90 +
  91 + scrollRect = bounds;
  92 + }
  93 +
  94 + graphics.clear();
  95 + graphics.beginFill(Color.GREY_2B);
  96 + graphics.drawRect(0.0, 0.0, width, height);
  97 + graphics.endFill();
  98 + }
  99 +
  100 + override protected function addedToStageHandler(event:Event):void {
  101 + super.addedToStageHandler(event);
  102 +
  103 + resize();
  104 +
  105 + if (stage.nativeWindow.active) {
  106 + positionTween.setValue('y', 0.0);
  107 + }
  108 +
  109 + NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, applicationActivateHandler, false, 0, true);
  110 + NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, applicationDeactivateHandler, false, 0, true);
  111 + }
  112 +
  113 + protected function applicationActivateHandler(event:Event):void {
  114 + positionTween.setValue('y', 0.0);
  115 + }
  116 +
  117 + protected function applicationDeactivateHandler(event:Event):void {
  118 + positionTween.setValue('y', height);
  119 + }
  120 +
  121 + protected function positionTweenInitHandler(tween:GTween):void {
  122 + if (y == height) {
  123 + stage.nativeWindow.visible = true;
  124 + }
  125 + }
  126 +
  127 + protected function positionTweenCompleteHandler(tween:GTween):void {
  128 + if (y == height) {
  129 + stage.nativeWindow.visible = false;
  130 + }
  131 + }
  132 + }
  133 +}

0 comments on commit 4847bc1

Please sign in to comment.
Something went wrong with that request. Please try again.