PageRenderTime 2213ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/fp10/src/com/furusystems/dconsole2/core/gui/maindisplay/ConsoleView.as

http://doomsdayconsole.googlecode.com/
ActionScript | 689 lines | 591 code | 74 blank | 24 comment | 24 complexity | 54c275ac42c80063405bf04dd122cdd7 MD5 | raw file
  1. package com.furusystems.dconsole2.core.gui.maindisplay
  2. {
  3. //{
  4. import com.furusystems.dconsole2.core.animation.ConsoleTweener;
  5. import com.furusystems.dconsole2.core.animation.EasingTween;
  6. import com.furusystems.dconsole2.core.gui.DockingGuides;
  7. import com.furusystems.dconsole2.core.gui.layout.HorizontalSplit;
  8. import com.furusystems.dconsole2.core.gui.layout.IContainable;
  9. import com.furusystems.dconsole2.core.gui.layout.ILayoutContainer;
  10. import com.furusystems.dconsole2.core.gui.maindisplay.assistant.Assistant;
  11. import com.furusystems.dconsole2.core.gui.maindisplay.filtertabrow.FilterTabRow;
  12. import com.furusystems.dconsole2.core.gui.maindisplay.input.InputField;
  13. import com.furusystems.dconsole2.core.gui.maindisplay.output.OutputField;
  14. import com.furusystems.dconsole2.core.gui.maindisplay.sections.HeaderSection;
  15. import com.furusystems.dconsole2.core.gui.maindisplay.sections.InspectorSection;
  16. import com.furusystems.dconsole2.core.gui.maindisplay.sections.MainSection;
  17. import com.furusystems.dconsole2.core.gui.maindisplay.toolbar.ConsoleToolbar;
  18. import com.furusystems.dconsole2.core.gui.ScaleHandle;
  19. import com.furusystems.dconsole2.core.inspector.Inspector;
  20. import com.furusystems.dconsole2.core.Notifications;
  21. import com.furusystems.dconsole2.core.style.Colors;
  22. import com.furusystems.dconsole2.core.style.GUIUnits;
  23. import com.furusystems.dconsole2.DConsole;
  24. import com.furusystems.messaging.pimp.MessageData;
  25. import com.furusystems.messaging.pimp.PimpCentral;
  26. import flash.display.Bitmap;
  27. import flash.display.BitmapData;
  28. import flash.display.BitmapDataChannel;
  29. import flash.display.BlendMode;
  30. import flash.display.DisplayObject;
  31. import flash.display.GradientType;
  32. import flash.display.Shape;
  33. import flash.display.Sprite;
  34. import flash.events.Event;
  35. import flash.events.MouseEvent;
  36. import flash.filters.BlurFilter;
  37. import flash.filters.DisplacementMapFilter;
  38. import flash.filters.DisplacementMapFilterMode;
  39. import flash.geom.ColorTransform;
  40. import flash.geom.Matrix;
  41. import flash.geom.Point;
  42. import flash.geom.Rectangle;
  43. import flash.ui.Mouse;
  44. import flash.ui.MouseCursor;
  45. //}
  46. /**
  47. * Root level of the console main view
  48. * @author Andreas Roenning
  49. */
  50. public class ConsoleView extends Sprite implements IContainable,ILayoutContainer
  51. {
  52. static public const SHOW_TIME:Number = 0.4;
  53. private var _console:DConsole;
  54. private var _rect:Rectangle;
  55. private var _mainSection:MainSection; //section containing main console io
  56. private var _inspectorSection:InspectorSection; //section containing display list inspector
  57. private var _headerSection:HeaderSection; //section containing toolbar
  58. private var _children:Array = [];
  59. private var _mainSplit:HorizontalSplit;
  60. private var _mainSplitDragBar:Sprite;
  61. private var _mainSplitClickOffset:Number;
  62. private var _mainSplitToggled:Boolean;
  63. private var _inspector:Inspector;
  64. private var _isDragging:Boolean;
  65. private var _scalePreview:Shape = new Shape();
  66. private var _tempScaleRect:Rectangle = new Rectangle();
  67. private var _prevSplitPos:int = -1;
  68. private var _texture:BitmapData;
  69. private var _bg:Sprite = new Sprite();
  70. private var _inspectorVisible:Boolean = false;
  71. private var _scaleHandle:ScaleHandle;
  72. private var _prevRect:Rectangle;
  73. private var _firstRun:Boolean;
  74. public function get input():InputField { return _mainSection.input; };
  75. public function get output():OutputField { return _mainSection.output; };
  76. public function get filtertabs():FilterTabRow { return _mainSection.filterTabs; };
  77. public function get assistant():Assistant { return _mainSection.assistant; };
  78. public function get inspector():Inspector { return _inspectorSection.inspector; };
  79. public function get toolbar():ConsoleToolbar { return _headerSection.toolBar; };
  80. public function get scaleHandle():ScaleHandle { return _scaleHandle; };
  81. public function ConsoleView(console:DConsole = null)
  82. {
  83. _scaleHandle = new ScaleHandle(console);
  84. visible = false;
  85. _console = console;
  86. _texture = new BitmapData(3, 3, true, 0);
  87. _texture.setPixel32(0, 0, 0xCC000000);
  88. tabEnabled = tabChildren = false;
  89. _mainSection = new MainSection(console);
  90. _inspectorSection = new InspectorSection(console);
  91. _headerSection = new HeaderSection(console);
  92. //_bg.cacheAsBitmap = true;
  93. addChild(_bg);
  94. addChild(_headerSection);
  95. _mainSplitDragBar = new Sprite();
  96. _mainSplit = new HorizontalSplit();
  97. _mainSplit.leftCell.addChild(_inspectorSection);
  98. _mainSplit.rightCell.addChild(_mainSection);
  99. _mainSplitDragBar.alpha = 0;
  100. _mainSplit.splitRatio = 0.2;
  101. addChild(_mainSplit);
  102. addChild(_mainSplitDragBar);
  103. addChild(_scaleHandle);
  104. _mainSplitDragBar.addEventListener(MouseEvent.MOUSE_DOWN, beginMainSplitDrag);
  105. _mainSplitDragBar.addEventListener(MouseEvent.MOUSE_OVER, onMainsplitMouseOver);
  106. _mainSplitDragBar.addEventListener(MouseEvent.MOUSE_OUT, onMainsplitMouseOut);
  107. _mainSplitDragBar.addEventListener(MouseEvent.DOUBLE_CLICK, toggleMainSplit);
  108. _mainSplitDragBar.doubleClickEnabled = true;
  109. _mainSplitDragBar.buttonMode = true;
  110. //filters = [Filters.CONSOLE_DROPSHADOW];
  111. scaleHandle.addEventListener(MouseEvent.MOUSE_DOWN, beginScaleDrag);
  112. scaleHandle.addEventListener(MouseEvent.DOUBLE_CLICK, onScaleDoubleclick);
  113. addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
  114. tabEnabled = tabChildren = false;
  115. _console.messaging.addCallback(Notifications.INSPECTOR_VIEW_REMOVED, onInspectorViewCountChange);
  116. _console.messaging.addCallback(Notifications.INSPECTOR_VIEW_ADDED, onInspectorViewCountChange);
  117. _console.messaging.addCallback(Notifications.TOOLBAR_DRAG_START, onToolbarDrag);
  118. _console.messaging.addCallback(Notifications.TOOLBAR_DRAG_STOP, onToolbarDrag);
  119. _console.messaging.addCallback(Notifications.TOOLBAR_DRAG_UPDATE, onToolbarDrag);
  120. _console.messaging.addCallback(Notifications.CORNER_DRAG_START, onCornerScale);
  121. _console.messaging.addCallback(Notifications.CORNER_DRAG_STOP, onCornerScale);
  122. _console.messaging.addCallback(Notifications.CORNER_DRAG_UPDATE, onCornerScale);
  123. setupBloom();
  124. //addChild(bloom);
  125. }
  126. private function setupBloom():void
  127. {
  128. addEventListener(Event.ENTER_FRAME, updateBloom);
  129. scanlinePattern.setPixel32(0, 0, 0xFF808080);
  130. scanlinePattern.setPixel32(0, 1, 0xFFeeeeee);
  131. }
  132. public function toggleBloom():void
  133. {
  134. bloomEnabled = !bloomEnabled;
  135. if (!bloomEnabled) {
  136. if (contains(bloom)) removeChild(bloom);
  137. if (contains(scanlines)) removeChild(scanlines);
  138. }
  139. }
  140. private function onCornerScale(md:MessageData):void
  141. {
  142. switch(md.message) {
  143. case Notifications.CORNER_DRAG_START:
  144. Mouse.cursor = MouseCursor.HAND;
  145. break;
  146. case Notifications.CORNER_DRAG_STOP:
  147. Mouse.cursor = MouseCursor.AUTO;
  148. break;
  149. case Notifications.CORNER_DRAG_UPDATE:
  150. _tempScaleRect.height = Math.round(Math.max(GUIUnits.SQUARE_UNIT * 5, Math.min(stage.stageHeight - GUIUnits.SQUARE_UNIT, (stage.mouseY -y))) / GUIUnits.SQUARE_UNIT) * GUIUnits.SQUARE_UNIT; //TODO: This is messy as hell!
  151. _tempScaleRect.width = stage.mouseX - x;
  152. var r:Rectangle = rect;
  153. r.height = _tempScaleRect.height;
  154. r.width = _tempScaleRect.width;
  155. r.width = Math.ceil(Math.max(150, Math.min(r.width, stage.stageWidth - x)));
  156. rect = r;
  157. break;
  158. }
  159. }
  160. override public function get x():Number
  161. {
  162. return super.x;
  163. }
  164. override public function set x(value:Number):void
  165. {
  166. super.x = _console.persistence.consoleX = value;
  167. }
  168. override public function get y():Number
  169. {
  170. return super.y;
  171. }
  172. override public function set y(value:Number):void
  173. {
  174. super.y = _console.persistence.consoleY = value;
  175. }
  176. override public function get height():Number { return _console.persistence.consoleHeight; }
  177. override public function set height(value:Number):void
  178. {
  179. _console.persistence.consoleHeight = value;
  180. rect = _console.persistence.rect;
  181. }
  182. override public function get width():Number { return _console.persistence.consoleWidth; }
  183. override public function set width(value:Number):void
  184. {
  185. _console.persistence.consoleWidth = value;
  186. rect = _console.persistence.rect;
  187. }
  188. private function onToolbarDrag(md:MessageData):void
  189. {
  190. switch(md.message) {
  191. case Notifications.TOOLBAR_DRAG_START:
  192. Mouse.cursor = MouseCursor.HAND;
  193. break;
  194. case Notifications.TOOLBAR_DRAG_STOP:
  195. Mouse.cursor = MouseCursor.AUTO;
  196. _console.messaging.send(Notifications.HIDE_DOCKING_GUIDE, null, this);
  197. updateDocking();
  198. break;
  199. case Notifications.TOOLBAR_DRAG_UPDATE:
  200. x += md.data.x;
  201. y += md.data.y;
  202. x = int(Math.max(0, Math.min(x, stage.stageWidth - _rect.width)));
  203. y = int(Math.max(0, Math.min(y, stage.stageHeight - _rect.height)));
  204. scaleHandle.visible = true;
  205. if (y <= 2) {
  206. _console.messaging.send(Notifications.SHOW_DOCKING_GUIDE, DockingGuides.TOP, this);
  207. _console.persistence.dockState.value = DConsole.DOCK_TOP;
  208. _scaleHandle.y = _rect.height;
  209. }else if (y >= stage.stageHeight - _rect.height-2) {
  210. _console.messaging.send(Notifications.SHOW_DOCKING_GUIDE, DockingGuides.BOT, this);
  211. _console.persistence.dockState.value = DConsole.DOCK_BOT;
  212. _scaleHandle.y = -scaleHandle.height;
  213. }else {
  214. _console.messaging.send(Notifications.HIDE_DOCKING_GUIDE, null, this);
  215. _console.persistence.dockState.value = DConsole.DOCK_WINDOWED;
  216. scaleHandle.visible = false;
  217. }
  218. assistant.cornerHandle.visible = !scaleHandle.visible;
  219. break;
  220. }
  221. }
  222. private function onInspectorViewCountChange(md:MessageData):void
  223. {
  224. _mainSplit.splitRatio = _console.persistence.verticalSplitRatio.value;
  225. doLayout();
  226. }
  227. private function onAddedToStage(e:Event):void
  228. {
  229. _firstRun = true;
  230. removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
  231. initFromPersistence();
  232. switch(dockingMode) {
  233. case DConsole.DOCK_BOT:
  234. y = stage.stageHeight + 10;
  235. break;
  236. case DConsole.DOCK_TOP:
  237. y = -height;
  238. break;
  239. }
  240. onParentUpdate(_rect);
  241. _firstRun = false;
  242. }
  243. private function initFromPersistence():void
  244. {
  245. _mainSplit.splitRatio = _console.persistence.verticalSplitRatio.value;
  246. inspector.enabled = _mainSplit.splitRatio > 0;
  247. rect = _console.persistence.rect;
  248. x = _console.persistence.consoleX;
  249. y = _console.persistence.consoleY;
  250. }
  251. public function get splitRatio():Number {
  252. return _mainSplit.splitRatio;
  253. }
  254. public function set splitRatio(n:Number):void {
  255. _mainSplit.splitRatio = n;
  256. }
  257. private function onScaleDoubleclick(e:MouseEvent):void
  258. {
  259. var r:Rectangle = rect;
  260. if (r.height < 50) {
  261. r.height = stage.stageHeight * .8;
  262. }else {
  263. r.height = 0;
  264. }
  265. rect = r;
  266. }
  267. private function beginScaleDrag(e:MouseEvent):void
  268. {
  269. Mouse.cursor = MouseCursor.HAND;
  270. scaleHandle.dragging = true;
  271. _scalePreview.visible = true;
  272. stage.addEventListener(MouseEvent.MOUSE_MOVE, onScaleUpdate);
  273. stage.addEventListener(MouseEvent.MOUSE_UP, completeScale);
  274. onScaleUpdate(e);
  275. }
  276. private function completeScale(e:MouseEvent):void
  277. {
  278. Mouse.cursor = MouseCursor.AUTO;
  279. scaleHandle.dragging = false;
  280. /*if (!scaleHandle.rect.containsPoint(new Point(mouseX, mouseY))) {
  281. scaleHandle.alpha = 0;
  282. }*/
  283. stage.removeEventListener(MouseEvent.MOUSE_MOVE, onScaleUpdate);
  284. stage.removeEventListener(MouseEvent.MOUSE_UP, completeScale);
  285. //rect.height = tempScaleRect.height;
  286. doLayout();
  287. }
  288. private function onScaleUpdate(e:MouseEvent):void
  289. {
  290. Mouse.cursor = MouseCursor.HAND;
  291. var r:Rectangle = rect;
  292. switch(dockingMode) {
  293. case DConsole.DOCK_BOT:
  294. _tempScaleRect.height = Math.round(Math.max(GUIUnits.SQUARE_UNIT * 1, Math.min(stage.stageHeight - GUIUnits.SQUARE_UNIT, stage.stageHeight - stage.mouseY - 8)) / GUIUnits.SQUARE_UNIT) * GUIUnits.SQUARE_UNIT;
  295. if(r.height!=_tempScaleRect.height){
  296. r.height = height = _tempScaleRect.height;
  297. rect = r;
  298. y = stage.stageHeight - r.height;
  299. }
  300. break;
  301. default:
  302. _tempScaleRect.height = Math.round(Math.max(GUIUnits.SQUARE_UNIT * 1, Math.min(stage.stageHeight - GUIUnits.SQUARE_UNIT, stage.mouseY - 8)) / GUIUnits.SQUARE_UNIT) * GUIUnits.SQUARE_UNIT;
  303. if(r.height!=_tempScaleRect.height){
  304. r.height = height = _tempScaleRect.height;
  305. rect = r;
  306. }
  307. }
  308. }
  309. private function showInspector():void {
  310. if (!_inspectorVisible || _firstRun) {
  311. _mainSplit.setSplitPos(_prevSplitPos);
  312. _inspectorVisible = true;
  313. inspector.enabled = _prevSplitPos > 0;
  314. }
  315. }
  316. private function hideInspector():void {
  317. if (_inspectorVisible || _firstRun) {
  318. _inspectorVisible = inspector.enabled = false;
  319. _prevSplitPos = _mainSplit.getSplitPos();
  320. _mainSplit.setSplitPos(0);
  321. }
  322. }
  323. public function setHeaderText(text:String):void {
  324. _headerSection.toolBar.setTitle(text);
  325. }
  326. private function doLayout():void
  327. {
  328. //if (_prevRect) {
  329. //if (_prevRect.equals(_rect)) return;
  330. //}
  331. var r:Rectangle = _rect.clone();
  332. _prevRect = r.clone();
  333. _headerSection.onParentUpdate(r);
  334. if (_headerSection.visible) {
  335. r.y = GUIUnits.SQUARE_UNIT;
  336. r.height -= GUIUnits.SQUARE_UNIT;
  337. }else { //if there is no header, move us up a spot
  338. }
  339. _mainSplit.rect = r;
  340. _mainSplitDragBar.graphics.clear();
  341. if (rect.height < 128 || !inspector.viewsAdded) {
  342. hideInspector();
  343. _mainSplit.setSplitPos(0);
  344. }else {
  345. showInspector();
  346. _mainSplitDragBar.graphics.beginFill(0,0.1);
  347. _mainSplitDragBar.graphics.drawRect(0, 0, 8, r.height);
  348. _mainSplitDragBar.x = int(_mainSplit.splitRatio * r.width-4);
  349. _mainSplitDragBar.y = _mainSplit.y;
  350. }
  351. r.height = GUIUnits.SQUARE_UNIT;
  352. switch(dockingMode) {
  353. case DConsole.DOCK_BOT:
  354. r.y = -scaleHandle.height;
  355. scaleHandle.onParentUpdate(r);
  356. break;
  357. default:
  358. r.y = _rect.height;
  359. scaleHandle.onParentUpdate(r);
  360. break;
  361. }
  362. }
  363. private function onMainsplitMouseOut(e:MouseEvent):void
  364. {
  365. if (_isDragging) return;
  366. _mainSplitDragBar.alpha = 0;
  367. _mainSplitDragBar.blendMode = BlendMode.NORMAL;
  368. Mouse.cursor = MouseCursor.AUTO;
  369. }
  370. private function onMainsplitMouseOver(e:MouseEvent):void
  371. {
  372. if (_isDragging) return;
  373. _mainSplitDragBar.alpha = 1;
  374. _mainSplitDragBar.blendMode = BlendMode.INVERT;
  375. Mouse.cursor = MouseCursor.HAND;
  376. }
  377. private function toggleMainSplit(e:MouseEvent):void
  378. {
  379. if (_mainSplit.getSplitPos() > 30) {
  380. _inspectorVisible = false;
  381. _prevSplitPos = _mainSplit.getSplitPos();
  382. _mainSplit.setSplitPos(0);
  383. hideInspector();
  384. }else {
  385. _inspectorVisible = true;
  386. _mainSplit.setSplitPos(_prevSplitPos = 300);
  387. showInspector();
  388. }
  389. doLayout();
  390. }
  391. private function beginMainSplitDrag(e:MouseEvent):void
  392. {
  393. _isDragging = true;
  394. _mainSplitDragBar.alpha = 1;
  395. stage.addEventListener(MouseEvent.MOUSE_MOVE, updateMainSplitDrag);
  396. stage.addEventListener(MouseEvent.MOUSE_UP, stopMainSplitDrag);
  397. }
  398. private function stopMainSplitDrag(e:MouseEvent):void
  399. {
  400. _isDragging = false;
  401. _mainSplitDragBar.alpha = 0;
  402. stage.removeEventListener(MouseEvent.MOUSE_MOVE, updateMainSplitDrag);
  403. stage.removeEventListener(MouseEvent.MOUSE_UP, stopMainSplitDrag);
  404. Mouse.cursor = MouseCursor.AUTO;
  405. }
  406. private function updateMainSplitDrag(e:MouseEvent):void
  407. {
  408. Mouse.cursor = MouseCursor.HAND;
  409. var p:int = Math.max(0, Math.min(_rect.width / 2, mouseX));
  410. if (p < 30) p = 0;
  411. inspector.enabled = p > 0;
  412. _mainSplit.setSplitPos(p);
  413. _console.persistence.verticalSplitRatio.value = _mainSplit.splitRatio;
  414. doLayout();
  415. }
  416. override public function addChild(child:DisplayObject):DisplayObject
  417. {
  418. children.push(child);
  419. return super.addChild(child);
  420. }
  421. /* INTERFACE com.furusystems.dconsole2.core.gui.layout.IContainable */
  422. public function onParentUpdate(allotedRect:Rectangle):void
  423. {
  424. allotedRect.height = Math.floor(allotedRect.height);
  425. allotedRect.width = Math.round(allotedRect.width);
  426. rect = allotedRect;
  427. }
  428. public function show():void {
  429. visible = true;
  430. switch(dockingMode) {
  431. case DConsole.DOCK_WINDOWED:
  432. onShown();
  433. break;
  434. case DConsole.DOCK_BOT:
  435. ConsoleTweener.tween(this, "y", stage.stageHeight-height, SHOW_TIME, onShown, EasingTween);
  436. break;
  437. case DConsole.DOCK_TOP:
  438. default:
  439. ConsoleTweener.tween(this, "y", 0, SHOW_TIME, onShown, EasingTween);
  440. break;
  441. }
  442. }
  443. private function onShown():void
  444. {
  445. _console.messaging.send(Notifications.CONSOLE_VIEW_TRANSITION_COMPLETE, true);
  446. }
  447. public function hide():void {
  448. if (!stage) {
  449. onHidden();
  450. return;
  451. }
  452. switch(dockingMode) {
  453. case DConsole.DOCK_WINDOWED:
  454. onHidden();
  455. break;
  456. case DConsole.DOCK_BOT:
  457. ConsoleTweener.tween(this, "y", stage.stageHeight+10, SHOW_TIME, onHidden, EasingTween);
  458. break;
  459. case DConsole.DOCK_TOP:
  460. default:
  461. ConsoleTweener.tween(this, "y", -height, SHOW_TIME, onHidden, EasingTween);
  462. break;
  463. }
  464. }
  465. public function maximize():void
  466. {
  467. var r:Rectangle;
  468. switch(dockingMode) {
  469. case DConsole.DOCK_WINDOWED:
  470. dockingMode = DConsole.DOCK_TOP;
  471. maximize();
  472. break;
  473. default:
  474. r = _rect;
  475. r.height = int(stage.stageHeight-GUIUnits.SQUARE_UNIT);
  476. r.width = int(stage.stageWidth);
  477. rect = r;
  478. updateDocking();
  479. output.drawMessages();
  480. break;
  481. }
  482. }
  483. public function minimize():void
  484. {
  485. var r:Rectangle = _rect;
  486. switch(dockingMode) {
  487. case DConsole.DOCK_WINDOWED:
  488. r.height = 5 * GUIUnits.SQUARE_UNIT;
  489. rect = r;
  490. break;
  491. default:
  492. r.height = GUIUnits.SQUARE_UNIT;
  493. //r.width = stage.stageWidth;
  494. updateDocking();
  495. rect = r;
  496. }
  497. output.drawMessages();
  498. }
  499. public function consolidateView():void
  500. {
  501. var r:Rectangle = _console.persistence.rect;
  502. x = r.x;
  503. y = r.y;
  504. width = r.width;
  505. height = r.height;
  506. updateDocking();
  507. }
  508. private function onHidden():void
  509. {
  510. visible = false;
  511. _console.messaging.send(Notifications.CONSOLE_VIEW_TRANSITION_COMPLETE,false);
  512. }
  513. public function get children():Array
  514. {
  515. return _children;
  516. }
  517. /* INTERFACE com.furusystems.dconsole2.core.gui.layout.ILayoutContainer */
  518. public function set rect(r:Rectangle):void
  519. {
  520. //if (_rect) {
  521. //if (_rect.equals(r)) return;
  522. //} //TODO: why does this shit break everything? haha. God we need a rewrite.
  523. _rect = r;
  524. _rect.x = _rect.y = 0;
  525. _rect.height = Math.floor(Math.max(minHeight, _rect.height) / GUIUnits.SQUARE_UNIT) * GUIUnits.SQUARE_UNIT;
  526. _rect.width = int(Math.max(minWidth, _rect.width));
  527. _bg.graphics.clear();
  528. _bg.graphics.lineStyle(0, Colors.CORE);
  529. //_bg.graphics.beginBitmapFill(_texture, null, true);
  530. _bg.graphics.drawRect(0, 0, _rect.width, _rect.height);
  531. _bg.graphics.endFill();
  532. //scrollRect = _rect;
  533. _console.persistence.consoleWidth = _rect.width;
  534. _console.persistence.consoleHeight = _rect.height;
  535. doLayout();
  536. }
  537. public function get rect():Rectangle
  538. {
  539. return _console.persistence.rect;
  540. }
  541. public function get minHeight():Number
  542. {
  543. return 32;
  544. }
  545. public function get minWidth():Number
  546. {
  547. return 0;
  548. }
  549. public function get mainSection():MainSection { return _mainSection; }
  550. public function get dockingMode():int { return _console.persistence.dockState.value; }
  551. public function set dockingMode(value:int):void
  552. {
  553. _console.persistence.dockState.value = value;
  554. updateDocking();
  555. }
  556. private function updateDocking():void
  557. {
  558. scaleHandle.visible = true;
  559. switch(dockingMode) {
  560. case DConsole.DOCK_TOP:
  561. _rect.width = stage.stageWidth;
  562. rect = _rect;
  563. x = 0;
  564. y = 0;
  565. break;
  566. case DConsole.DOCK_BOT:
  567. _rect.width = stage.stageWidth;
  568. _scaleHandle.y = -scaleHandle.height;
  569. rect = _rect;
  570. y = stage.stageHeight - _rect.height;
  571. x = 0;
  572. break;
  573. case DConsole.DOCK_WINDOWED:
  574. rect = _rect;
  575. scaleHandle.visible = false;
  576. break;
  577. }
  578. assistant.cornerHandle.visible = !scaleHandle.visible;
  579. }
  580. private var bloomBmp:BitmapData;
  581. private var bloom:Bitmap = new Bitmap();
  582. private var scanlines:Shape = new Shape();
  583. private var scanlinePattern:BitmapData = new BitmapData(1, 3, true, 0);
  584. private var bloomEnabled:Boolean = false;
  585. private function updateBloom(e:Event = null):void
  586. {
  587. if (!bloomEnabled) return;
  588. scanlines.graphics.clear();
  589. scanlines.graphics.beginBitmapFill(scanlinePattern, null, true, false);
  590. scanlines.graphics.drawRect(0, 0, output.width, output.height);
  591. scanlines.graphics.endFill();
  592. scanlines.blendMode = BlendMode.MULTIPLY;
  593. if (bloomBmp) {
  594. bloomBmp.dispose();
  595. }
  596. if (contains(bloom)) removeChild(bloom);
  597. if (contains(scanlines)) removeChild(scanlines);
  598. bloom.blendMode = BlendMode.ADD;
  599. bloomBmp = new BitmapData(output.width, output.height, true, 0);
  600. bloomBmp.lock();
  601. bloomBmp.draw(output);
  602. bloomBmp.applyFilter(bloomBmp, bloomBmp.rect, new Point(), new BlurFilter(16, 16, 1));
  603. bloomBmp.applyFilter(bloomBmp, bloomBmp.rect, new Point(), new BlurFilter(16, 16, 1));
  604. bloomBmp.colorTransform(bloomBmp.rect, new ColorTransform(1, 2, 1));
  605. bloomBmp.unlock();
  606. bloom.bitmapData = bloomBmp;
  607. addChild(bloom);
  608. addChild(scanlines);
  609. var p:Point = new Point(output.x, output.y);
  610. p = output.parent.localToGlobal(p);
  611. bloom.x = scanlines.x = p.x - x;
  612. bloom.y = scanlines.y = p.y - y
  613. }
  614. }
  615. }