summaryrefslogtreecommitdiffstats
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/flashdictator.swfbin27052 -> 31528 bytes
-rw-r--r--src/com/bit101/components/FixedList.as496
-rw-r--r--src/de/polcin/as3/flashdictator/ctrl/DB.as8
-rw-r--r--src/de/polcin/as3/flashdictator/ctrl/SndCtrl.as4
-rw-r--r--src/de/polcin/as3/flashdictator/event/AppDataEvent.as63
-rw-r--r--src/de/polcin/as3/flashdictator/view/HelpWindow.as5
-rw-r--r--src/de/polcin/as3/flashdictator/view/MainPanel.as79
-rw-r--r--src/de/polcin/as3/flashdictator/view/ProjectsOverviewWindow.as121
8 files changed, 715 insertions, 61 deletions
diff --git a/bin/flashdictator.swf b/bin/flashdictator.swf
index 5e9f4e4..78b7006 100644
--- a/bin/flashdictator.swf
+++ b/bin/flashdictator.swf
Binary files differ
diff --git a/src/com/bit101/components/FixedList.as b/src/com/bit101/components/FixedList.as
new file mode 100644
index 0000000..c2cb30b
--- a/dev/null
+++ b/src/com/bit101/components/FixedList.as
@@ -0,0 +1,496 @@
1/**
2 * List.as
3 * Keith Peters
4 * version 0.9.10
5 *
6 * A scrolling list of selectable items.
7 *
8 * Copyright (c) 2011 Keith Peters
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 * THE SOFTWARE.
27 */
28
29package com.bit101.components
30{
31 import flash.display.DisplayObjectContainer;
32 import flash.display.Sprite;
33 import flash.events.Event;
34 import flash.events.MouseEvent;
35
36 [Event(name="select", type="flash.events.Event")]
37 public class FixedList extends Component
38 {
39 protected var _items:Array;
40 protected var _itemHolder:Sprite;
41 protected var _panel:Panel;
42 protected var _listItemHeight:Number = 20;
43 protected var _listItemClass:Class =ListItem;
44 protected var _scrollbar:VScrollBar;
45 protected var _selectedIndex:int = -1;
46 protected var _defaultColor:uint = Style.LIST_DEFAULT;
47 protected var _alternateColor:uint = Style.LIST_ALTERNATE;
48 protected var _selectedColor:uint = Style.LIST_SELECTED;
49 protected var _rolloverColor:uint = Style.LIST_ROLLOVER;
50 protected var _alternateRows:Boolean = false;
51
52 /**
53 * Constructor
54 * @param parent The parent DisplayObjectContainer on which to add this List.
55 * @param xpos The x position to place this component.
56 * @param ypos The y position to place this component.
57 * @param items An array of items to display in the list. Either strings or objects with label property.
58 */
59 public function FixedList(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, items:Array=null)
60 {
61 if(items != null)
62 {
63 _items = items;
64 }
65 else
66 {
67 _items = new Array();
68 }
69 super(parent, xpos, ypos);
70 }
71
72 /**
73 * Initilizes the component.
74 */
75 protected override function init() : void
76 {
77 super.init();
78 setSize(100, 100);
79 addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
80 addEventListener(Event.RESIZE, onResize);
81 makeListItems();
82 fillItems();
83 }
84
85 /**
86 * Creates and adds the child display objects of this component.
87 */
88 protected override function addChildren() : void
89 {
90 super.addChildren();
91 _panel = new Panel(this, 0, 0);
92 _panel.color = _defaultColor;
93 _itemHolder = new Sprite();
94 _panel.content.addChild(_itemHolder);
95 _scrollbar = new VScrollBar(this, 0, 0, onScroll);
96 _scrollbar.setSliderParams(0, 0, 0);
97 }
98
99 /**
100 * Creates all the list items based on data.
101 */
102 protected function makeListItems():void
103 {
104 var item:ListItem;
105 while(_itemHolder.numChildren > 0)
106 {
107 item = ListItem(_itemHolder.getChildAt(0));
108 item.removeEventListener(MouseEvent.CLICK, onSelect);
109 _itemHolder.removeChildAt(0);
110 }
111
112 var numItems:int = Math.ceil(_height / _listItemHeight);
113 numItems = Math.min(numItems, _items.length);
114 numItems = Math.max(numItems, 1);
115 for(var i:int = 0; i < numItems; i++)
116 {
117
118 item = new _listItemClass(_itemHolder, 0, i * _listItemHeight);
119 item.setSize(width, _listItemHeight);
120 item.defaultColor = _defaultColor;
121
122 item.selectedColor = _selectedColor;
123 item.rolloverColor = _rolloverColor;
124 item.addEventListener(MouseEvent.CLICK, onSelect);
125 }
126 }
127
128 protected function fillItems():void
129 {
130 var offset:int = _scrollbar.value;
131 var numItems:int = Math.ceil(_height / _listItemHeight);
132 numItems = Math.min(numItems, _items.length);
133 for(var i:int = 0; i < numItems; i++)
134 {
135 var item:ListItem = _itemHolder.getChildAt(i) as ListItem;
136 if(offset + i < _items.length)
137 {
138 item.data = _items[offset + i];
139 }
140 else
141 {
142 item.data = "";
143 }
144 if(_alternateRows)
145 {
146 item.defaultColor = ((offset + i) % 2 == 0) ? _defaultColor : _alternateColor;
147 }
148 else
149 {
150 item.defaultColor = _defaultColor;
151 }
152 if(offset + i == _selectedIndex)
153 {
154 item.selected = true;
155 }
156 else
157 {
158 item.selected = false;
159 }
160 }
161 }
162
163 /**
164 * If the selected item is not in view, scrolls the list to make the selected item appear in the view.
165 */
166 protected function scrollToSelection():void
167 {
168 var numItems:int = Math.ceil(_height / _listItemHeight);
169 if(_selectedIndex != -1)
170 {
171 if(_scrollbar.value > _selectedIndex)
172 {
173// _scrollbar.value = _selectedIndex;
174 }
175 else if(_scrollbar.value + numItems < _selectedIndex)
176 {
177 _scrollbar.value = _selectedIndex - numItems + 1;
178 }
179 }
180 else
181 {
182 _scrollbar.value = 0;
183 }
184 fillItems();
185 }
186
187
188
189 ///////////////////////////////////
190 // public methods
191 ///////////////////////////////////
192
193 /**
194 * Draws the visual ui of the component.
195 */
196 public override function draw() : void
197 {
198 super.draw();
199
200 _selectedIndex = Math.min(_selectedIndex, _items.length - 1);
201
202
203 // panel
204 _panel.setSize(_width, _height);
205 _panel.color = _defaultColor;
206 _panel.draw();
207
208 // scrollbar
209 _scrollbar.x = _width - 10;
210 var contentHeight:Number = _items.length * _listItemHeight;
211 _scrollbar.setThumbPercent(_height / contentHeight);
212 var pageSize:Number = Math.floor(_height / _listItemHeight);
213 _scrollbar.maximum = Math.max(0, _items.length - pageSize);
214 _scrollbar.pageSize = pageSize;
215 _scrollbar.height = _height;
216 _scrollbar.draw();
217 scrollToSelection();
218 }
219
220 /**
221 * Adds an item to the list.
222 * @param item The item to add. Can be a string or an object containing a string property named label.
223 */
224 public function addItem(item:Object):void
225 {
226 _items.push(item);
227 invalidate();
228 makeListItems();
229 fillItems();
230 }
231
232 /**
233 * Adds an item to the list at the specified index.
234 * @param item The item to add. Can be a string or an object containing a string property named label.
235 * @param index The index at which to add the item.
236 */
237 public function addItemAt(item:Object, index:int):void
238 {
239 index = Math.max(0, index);
240 index = Math.min(_items.length, index);
241 _items.splice(index, 0, item);
242 invalidate();
243 makeListItems();
244 fillItems();
245 }
246
247 /**
248 * Removes the referenced item from the list.
249 * @param item The item to remove. If a string, must match the item containing that string. If an object, must be a reference to the exact same object.
250 */
251 public function removeItem(item:Object):void
252 {
253 var index:int = _items.indexOf(item);
254 removeItemAt(index);
255 }
256
257 /**
258 * Removes the item from the list at the specified index
259 * @param index The index of the item to remove.
260 */
261 public function removeItemAt(index:int):void
262 {
263 if(index < 0 || index >= _items.length) return;
264 _items.splice(index, 1);
265 invalidate();
266 makeListItems();
267 fillItems();
268 }
269
270 /**
271 * Removes all items from the list.
272 */
273 public function removeAll():void
274 {
275 _items.length = 0;
276 invalidate();
277 makeListItems();
278 fillItems();
279 }
280
281
282
283
284
285 ///////////////////////////////////
286 // event handlers
287 ///////////////////////////////////
288
289 /**
290 * Called when a user selects an item in the list.
291 */
292 protected function onSelect(event:Event):void
293 {
294 if(! (event.target is ListItem)) return;
295
296 var offset:int = _scrollbar.value;
297
298 for(var i:int = 0; i < _itemHolder.numChildren; i++)
299 {
300 if(_itemHolder.getChildAt(i) == event.target) _selectedIndex = i + offset;
301 ListItem(_itemHolder.getChildAt(i)).selected = false;
302 }
303 ListItem(event.target).selected = true;
304 dispatchEvent(new Event(Event.SELECT));
305 }
306
307 /**
308 * Called when the user scrolls the scroll bar.
309 */
310 protected function onScroll(event:Event):void
311 {
312 fillItems();
313 }
314
315 /**
316 * Called when the mouse wheel is scrolled over the component.
317 */
318 protected function onMouseWheel(event:MouseEvent):void
319 {
320 _scrollbar.value -= event.delta;
321 fillItems();
322 }
323
324 protected function onResize(event:Event):void
325 {
326 makeListItems();
327 fillItems();
328 }
329 ///////////////////////////////////
330 // getter/setters
331 ///////////////////////////////////
332
333 /**
334 * Sets / gets the index of the selected list item.
335 */
336 public function set selectedIndex(value:int):void
337 {
338 if(value >= 0 && value < _items.length)
339 {
340 _selectedIndex = value;
341 // _scrollbar.value = _selectedIndex;
342 }
343 else
344 {
345 _selectedIndex = -1;
346 }
347 invalidate();
348 dispatchEvent(new Event(Event.SELECT));
349 }
350 public function get selectedIndex():int
351 {
352 return _selectedIndex;
353 }
354
355 /**
356 * Sets / gets the item in the list, if it exists.
357 */
358 public function set selectedItem(item:Object):void
359 {
360 var index:int = _items.indexOf(item);
361 // if(index != -1)
362 // {
363 selectedIndex = index;
364 invalidate();
365 dispatchEvent(new Event(Event.SELECT));
366 // }
367 }
368 public function get selectedItem():Object
369 {
370 if(_selectedIndex >= 0 && _selectedIndex < _items.length)
371 {
372 return _items[_selectedIndex];
373 }
374 return null;
375 }
376
377 /**
378 * Sets/gets the default background color of list items.
379 */
380 public function set defaultColor(value:uint):void
381 {
382 _defaultColor = value;
383 invalidate();
384 }
385 public function get defaultColor():uint
386 {
387 return _defaultColor;
388 }
389
390 /**
391 * Sets/gets the selected background color of list items.
392 */
393 public function set selectedColor(value:uint):void
394 {
395 _selectedColor = value;
396 invalidate();
397 }
398 public function get selectedColor():uint
399 {
400 return _selectedColor;
401 }
402
403 /**
404 * Sets/gets the rollover background color of list items.
405 */
406 public function set rolloverColor(value:uint):void
407 {
408 _rolloverColor = value;
409 invalidate();
410 }
411 public function get rolloverColor():uint
412 {
413 return _rolloverColor;
414 }
415
416 /**
417 * Sets the height of each list item.
418 */
419 public function set listItemHeight(value:Number):void
420 {
421 _listItemHeight = value;
422 makeListItems();
423 invalidate();
424 }
425 public function get listItemHeight():Number
426 {
427 return _listItemHeight;
428 }
429
430 /**
431 * Sets / gets the list of items to be shown.
432 */
433 public function set items(value:Array):void
434 {
435 _items = value;
436 invalidate();
437 }
438 public function get items():Array
439 {
440 return _items;
441 }
442
443 /**
444 * Sets / gets the class used to render list items. Must extend ListItem.
445 */
446 public function set listItemClass(value:Class):void
447 {
448 _listItemClass = value;
449 makeListItems();
450 invalidate();
451 }
452 public function get listItemClass():Class
453 {
454 return _listItemClass;
455 }
456
457 /**
458 * Sets / gets the color for alternate rows if alternateRows is set to true.
459 */
460 public function set alternateColor(value:uint):void
461 {
462 _alternateColor = value;
463 invalidate();
464 }
465 public function get alternateColor():uint
466 {
467 return _alternateColor;
468 }
469
470 /**
471 * Sets / gets whether or not every other row will be colored with the alternate color.
472 */
473 public function set alternateRows(value:Boolean):void
474 {
475 _alternateRows = value;
476 invalidate();
477 }
478 public function get alternateRows():Boolean
479 {
480 return _alternateRows;
481 }
482
483 /**
484 * Sets / gets whether the scrollbar will auto hide when there is nothing to scroll.
485 */
486 public function set autoHideScrollBar(value:Boolean):void
487 {
488 _scrollbar.autoHide = value;
489 }
490 public function get autoHideScrollBar():Boolean
491 {
492 return _scrollbar.autoHide;
493 }
494
495 }
496} \ No newline at end of file
diff --git a/src/de/polcin/as3/flashdictator/ctrl/DB.as b/src/de/polcin/as3/flashdictator/ctrl/DB.as
index c39c1dc..c04d778 100644
--- a/src/de/polcin/as3/flashdictator/ctrl/DB.as
+++ b/src/de/polcin/as3/flashdictator/ctrl/DB.as
@@ -33,5 +33,11 @@ package de.polcin.as3.flashdictator.ctrl {
33 so.flush(); 33 so.flush();
34 return value; 34 return value;
35 } 35 }
36
37 public function deleteKey(key:String):void {
38 so.data[key] = null;
39 delete(so.data[key]);
40 so.flush();
41 }
36 } 42 }
37} \ No newline at end of file 43}
diff --git a/src/de/polcin/as3/flashdictator/ctrl/SndCtrl.as b/src/de/polcin/as3/flashdictator/ctrl/SndCtrl.as
index 0d57ede..c63b2f5 100644
--- a/src/de/polcin/as3/flashdictator/ctrl/SndCtrl.as
+++ b/src/de/polcin/as3/flashdictator/ctrl/SndCtrl.as
@@ -15,8 +15,8 @@ package de.polcin.as3.flashdictator.ctrl {
15 * @author christoph-polcin.com 15 * @author christoph-polcin.com
16 */ 16 */
17 public class SndCtrl extends EventDispatcher { 17 public class SndCtrl extends EventDispatcher {
18 public static const CHUNK_DURATION_KEY:String = 'CHUNK_DURATION'; 18 public static const CHUNK_DURATION_KEY:String = 'SndCtrl.CHUNK_DURATION_KEY';
19 public static const BREAK_DURATION_KEY:String = 'BREAK_DURATION'; 19 public static const BREAK_DURATION_KEY:String = 'SndCtrl.BREAK_DURATION_KEY';
20 private var snd:Sound; 20 private var snd:Sound;
21 private var sndTransform:SoundTransform = new SoundTransform(); 21 private var sndTransform:SoundTransform = new SoundTransform();
22 private var sndChannel:SoundChannel; 22 private var sndChannel:SoundChannel;
diff --git a/src/de/polcin/as3/flashdictator/event/AppDataEvent.as b/src/de/polcin/as3/flashdictator/event/AppDataEvent.as
index 766c57c..88d200f 100644
--- a/src/de/polcin/as3/flashdictator/event/AppDataEvent.as
+++ b/src/de/polcin/as3/flashdictator/event/AppDataEvent.as
@@ -1,32 +1,33 @@
1package de.polcin.as3.flashdictator.event { 1package de.polcin.as3.flashdictator.event {
2 import flash.events.Event; 2 import flash.events.Event;
3 3
4 /** 4 /**
5 * ... 5 * @author christoph-polcin.com
6 * @author christoph-polcin.com 6 */
7 */ 7 public class AppDataEvent extends Event {
8 public class AppDataEvent extends Event { 8 static public const FILE_OPEN:String = 'AppDataEvent.FILE_OPEN';
9 static public const FILE_OPEN:String = 'AppDataEvent.FILE_OPEN'; 9 static public const SOUND_LOADED:String = 'AppDataEvent.SOUND_LOADED';
10 static public const SOUND_LOADED:String = 'AppDataEvent.SOUND_LOADED'; 10 static public const SOUND_READY:String = 'AppDataEvent.SOUND_READY';
11 static public const SOUND_READY:String = 'AppDataEvent.SOUND_READY'; 11 static public const SOUND_CLOSE:String = 'AppDataEvent.SOUND_CLOSE';
12 static public const SOUND_CLOSE:String = 'AppDataEvent.SOUND_CLOSE'; 12 static public const SOUND_TOGGLE_PLAY:String = 'AppDataEvent.SOUND_TOGGLE_PLAY';
13 static public const SOUND_TOGGLE_PLAY:String = 'AppDataEvent.SOUND_TOGGLE_PLAY'; 13 static public const SOUND_STATE_PLAY:String = 'AppDataEvent.SOUND_STATE_PLAY';
14 static public const SOUND_STATE_PLAY:String = 'AppDataEvent.SOUND_STATE_PLAY'; 14 static public const SOUND_STATE_PAUSE:String = 'AppDataEvent.SOUND_STATE_PAUSE';
15 static public const SOUND_STATE_PAUSE:String = 'AppDataEvent.SOUND_STATE_PAUSE'; 15 static public const SOUND_SEEK:String = 'AppDataEvent.SOUND_SEEK';
16 static public const SOUND_SEEK:String = 'AppDataEvent.SOUND_SEEK'; 16 static public const SOUND_REWIND:String = 'AppDataEvent.SOUND_REWIND';
17 static public const SOUND_REWIND:String = 'AppDataEvent.SOUND_REWIND'; 17 static public const SOUND_FORWARD:String = 'AppDataEvent.SOUND_FORWARD';
18 static public const SOUND_FORWARD:String = 'AppDataEvent.SOUND_FORWARD'; 18 static public const CONFIG_PAUSE_DURATION:String = 'AppDataEvent.CONFIG_PAUSE_DURATION';
19 static public const CONFIG_PAUSE_DURATION:String = 'AppDataEvent.CONFIG_PAUSE_DURATION'; 19 static public const CONFIG_PLAY_DURATION:String = 'AppDataEvent.CONFIG_PLAY_DURATION';
20 static public const CONFIG_PLAY_DURATION:String = 'AppDataEvent.CONFIG_PLAY_DURATION'; 20 static public const DISPLAY_TEXT_RO:String = 'AppDataEvent.SHOW_PROJECT_RO';
21 public var data:*; 21
22 22 public var data:*;
23 public function AppDataEvent(type:String, data:*=null):void { 23
24 super(type, false, true); 24 public function AppDataEvent(type:String, data:*=null):void {
25 this.data = data; 25 super(type, false, true);
26 } 26 this.data = data;
27 27 }
28 override public function clone():Event { 28
29 return new AppDataEvent(type, data); 29 override public function clone():Event {
30 } 30 return new AppDataEvent(type, data);
31 } 31 }
32 }
32} \ No newline at end of file 33} \ No newline at end of file
diff --git a/src/de/polcin/as3/flashdictator/view/HelpWindow.as b/src/de/polcin/as3/flashdictator/view/HelpWindow.as
index ce04b87..8f93a0a 100644
--- a/src/de/polcin/as3/flashdictator/view/HelpWindow.as
+++ b/src/de/polcin/as3/flashdictator/view/HelpWindow.as
@@ -12,7 +12,8 @@ package de.polcin.as3.flashdictator.view {
12 * @author christoph 12 * @author christoph
13 */ 13 */
14 public class HelpWindow extends Window { 14 public class HelpWindow extends Window {
15 private var ta:TextArea; 15 protected var ta:TextArea;
16
16 public function HelpWindow(parent:DisplayObjectContainer = null) { 17 public function HelpWindow(parent:DisplayObjectContainer = null) {
17 super(parent, 0, 0, t("Help")); 18 super(parent, 0, 0, t("Help"));
18 hasCloseButton = true; 19 hasCloseButton = true;
@@ -33,7 +34,7 @@ package de.polcin.as3.flashdictator.view {
33 addHeadline(ta, 'Keyboard Shortcuts'); 34 addHeadline(ta, 'Keyboard Shortcuts');
34 addHeadline(ta, '----------------------'); 35 addHeadline(ta, '----------------------');
35 addKeyBind(ta, "F1", "Toggle Help"); 36 addKeyBind(ta, "F1", "Toggle Help");
36 addKeyBind(ta, "F2", "Open Projects"); 37 addKeyBind(ta, "F2", "Project List");
37 addKeyBind(ta, "F4", "Save"); 38 addKeyBind(ta, "F4", "Save");
38 addKeyBind(ta, "F5", "Toggle Play"); 39 addKeyBind(ta, "F5", "Toggle Play");
39 addKeyBind(ta, "F8", "Rewind"); 40 addKeyBind(ta, "F8", "Rewind");
diff --git a/src/de/polcin/as3/flashdictator/view/MainPanel.as b/src/de/polcin/as3/flashdictator/view/MainPanel.as
index ba8d207..4b19a32 100644
--- a/src/de/polcin/as3/flashdictator/view/MainPanel.as
+++ b/src/de/polcin/as3/flashdictator/view/MainPanel.as
@@ -12,6 +12,7 @@ package de.polcin.as3.flashdictator.view {
12 import com.bit101.components.Style; 12 import com.bit101.components.Style;
13 import com.bit101.components.VBox; 13 import com.bit101.components.VBox;
14 14
15 import flash.display.DisplayObject;
15 import flash.display.DisplayObjectContainer; 16 import flash.display.DisplayObjectContainer;
16 import flash.events.ContextMenuEvent; 17 import flash.events.ContextMenuEvent;
17 import flash.events.Event; 18 import flash.events.Event;
@@ -40,6 +41,7 @@ package de.polcin.as3.flashdictator.view {
40 private var textA:InputTextArea; 41 private var textA:InputTextArea;
41 private var sndInfoData:SoundInfoData; 42 private var sndInfoData:SoundInfoData;
42 private var helpWnd:HelpWindow; 43 private var helpWnd:HelpWindow;
44 private var projectsWnd:ProjectsOverviewWindow;
43 45
44 public function MainPanel(parent:DisplayObjectContainer, db:DB):void { 46 public function MainPanel(parent:DisplayObjectContainer, db:DB):void {
45 this.db = db; 47 this.db = db;
@@ -83,6 +85,7 @@ package de.polcin.as3.flashdictator.view {
83 85
84 addContextMenu(); 86 addContextMenu();
85 87
88 projectsWnd = new ProjectsOverviewWindow(this, db);
86 helpWnd = new HelpWindow(this); 89 helpWnd = new HelpWindow(this);
87 90
88 addEventListener(Event.ADDED_TO_STAGE, addedToStage); 91 addEventListener(Event.ADDED_TO_STAGE, addedToStage);
@@ -114,39 +117,47 @@ package de.polcin.as3.flashdictator.view {
114 stage.addEventListener(Event.RESIZE, onResizeHndl); 117 stage.addEventListener(Event.RESIZE, onResizeHndl);
115 stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpHndl); 118 stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUpHndl);
116 helpWnd.addEventListener(Event.CLOSE, onToggleHelpWindowHndl); 119 helpWnd.addEventListener(Event.CLOSE, onToggleHelpWindowHndl);
120 projectsWnd.addEventListener(Event.CLOSE, onToggleProjectWindoHndl);
121 projectsWnd.addEventListener(AppDataEvent.DISPLAY_TEXT_RO, onDisplayTextReadOnlyHndl);
117 122
118 onResizeHndl(); 123 onResizeHndl();
119 } 124 }
120 125
121 private function onResizeHndl(e:Event = null):void { 126 protected function onDisplayTextReadOnlyHndl(event:AppDataEvent):void {
122 setSize(stage.stageWidth, stage.stageHeight); 127 if (sndInfoData || !event.data)
128 return;
129
130 textA.editable = false;
131 textA.enabled = true;
132 textA.text = event.data;
123 } 133 }
124 134
135
125 public function onPauseDurationHndl(e:Event):void { 136 public function onPauseDurationHndl(e:Event):void {
126 dispatchEvent(new AppDataEvent(AppDataEvent.CONFIG_PAUSE_DURATION, pauseDurT.value)); 137 dispatchEvent(new AppDataEvent(AppDataEvent.CONFIG_PAUSE_DURATION, pauseDurT.value));
127 } 138 }
128 139
129 private function onPlayDurationHndl(e:Event):void { 140 protected function onPlayDurationHndl(e:Event):void {
130 dispatchEvent(new AppDataEvent(AppDataEvent.CONFIG_PLAY_DURATION, playDurT.value)); 141 dispatchEvent(new AppDataEvent(AppDataEvent.CONFIG_PLAY_DURATION, playDurT.value));
131 } 142 }
132 143
133 private function onRewindHndl(e:Event = null):void { 144 protected function onRewindHndl(e:Event = null):void {
134 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_REWIND)); 145 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_REWIND));
135 } 146 }
136 147
137 private function onForwardHndl(e:Event = null):void { 148 protected function onForwardHndl(e:Event = null):void {
138 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_FORWARD)); 149 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_FORWARD));
139 } 150 }
140 151
141 private function onTogglePlayHndl(e:Event = null):void { 152 protected function onTogglePlayHndl(e:Event = null):void {
142 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_TOGGLE_PLAY)); 153 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_TOGGLE_PLAY));
143 } 154 }
144 155
145 private function onSeekHndl(e:Event):void { 156 protected function onSeekHndl(e:Event):void {
146 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_SEEK, seek.value)); 157 dispatchEvent(new AppDataEvent(AppDataEvent.SOUND_SEEK, seek.value));
147 } 158 }
148 159
149 private function onFileOpenHndl(e:Event):void { 160 protected function onFileOpenHndl(e:Event):void {
150 dispatchEvent(new AppDataEvent(AppDataEvent.FILE_OPEN)); 161 dispatchEvent(new AppDataEvent(AppDataEvent.FILE_OPEN));
151 } 162 }
152 163
@@ -157,6 +168,7 @@ package de.polcin.as3.flashdictator.view {
157 forwardBtn.enabled = true; 168 forwardBtn.enabled = true;
158 playDurT.enabled = true; 169 playDurT.enabled = true;
159 pauseDurT.enabled = true; 170 pauseDurT.enabled = true;
171 textA.editable = true;
160 textA.enabled = true; 172 textA.enabled = true;
161 173
162 sndInfoData = SoundInfoData(e.data); 174 sndInfoData = SoundInfoData(e.data);
@@ -175,7 +187,9 @@ package de.polcin.as3.flashdictator.view {
175 forwardBtn.enabled = false; 187 forwardBtn.enabled = false;
176 playDurT.enabled = false; 188 playDurT.enabled = false;
177 pauseDurT.enabled = false; 189 pauseDurT.enabled = false;
190
178 textA.clear(); 191 textA.clear();
192 textA.editable = false;
179 textA.enabled = false; 193 textA.enabled = false;
180 sndInfoData = null; 194 sndInfoData = null;
181 } 195 }
@@ -194,18 +208,6 @@ package de.polcin.as3.flashdictator.view {
194 seek.value = e.bytesLoaded; 208 seek.value = e.bytesLoaded;
195 } 209 }
196 210
197 override public function setSize(w:Number, h:Number):void {
198 var maxW:int = 660;
199 x = ((w > maxW) ? ((w - maxW) >> 1) : 0) + BORDER;
200 w = maxW - BORDER2;
201 h = (h < 500) ? 500 - BORDER2 - BORDER - BORDER : h - BORDER2 - BORDER;
202
203 super.setSize(w, h);
204 seek.setSize(topBar.width - 20, 20);
205
206 textA.setSize(w - BORDER2, h - 60 - BORDER);
207 }
208
209 protected function onKeyUpHndl(e:KeyboardEvent):void { 211 protected function onKeyUpHndl(e:KeyboardEvent):void {
210 if (e.keyCode < 111 || e.keyCode > 120) 212 if (e.keyCode < 111 || e.keyCode > 120)
211 return; 213 return;
@@ -214,7 +216,7 @@ package de.polcin.as3.flashdictator.view {
214 onToggleHelpWindowHndl(); 216 onToggleHelpWindowHndl();
215 return; 217 return;
216 } else if (e.keyCode === 113) { /* F2 */ 218 } else if (e.keyCode === 113) { /* F2 */
217 // TODO show file list 219 onToggleProjectWindoHndl();
218 return; 220 return;
219 } 221 }
220 222
@@ -241,10 +243,37 @@ package de.polcin.as3.flashdictator.view {
241 } 243 }
242 } 244 }
243 245
244 private function onToggleHelpWindowHndl(e:Event=null):void { 246 protected function onToggleHelpWindowHndl(e:Event=null):void {
245 helpWnd.x = (this.width >> 1) - (helpWnd.width >> 1); 247 centerAndToggleVisibility(helpWnd);
246 helpWnd.y = (this.height >> 1) - (helpWnd.height >> 1) - BORDER2; 248 }
247 helpWnd.visible = !helpWnd.visible; 249
250 protected function onToggleProjectWindoHndl(event:Event=null):void {
251 projectsWnd.enableShow = !Boolean(sndInfoData);
252 centerAndToggleVisibility(projectsWnd);
248 } 253 }
254
255 protected function centerAndToggleVisibility(w:DisplayObject):void {
256 w.x = (this.width >> 1) - (w.width >> 1);
257 w.y = (this.height >> 1) - (w.height >> 1) - BORDER2;
258 w.visible = !w.visible;
259 }
260
261 protected function onResizeHndl(e:Event = null):void {
262 setSize(stage.stageWidth, stage.stageHeight);
263 }
264
265 override public function setSize(w:Number, h:Number):void {
266 var maxW:int = 660;
267 x = ((w > maxW) ? ((w - maxW) >> 1) : 0) + BORDER;
268 w = maxW - BORDER2;
269 h = (h < 500) ? 500 - BORDER2 - BORDER - BORDER : h - BORDER2 - BORDER;
270
271 super.setSize(w, h);
272 seek.setSize(topBar.width - 20, 20);
273
274 textA.setSize(w - BORDER2, h - 60 - BORDER);
275 }
276
277
249 } 278 }
250} 279}
diff --git a/src/de/polcin/as3/flashdictator/view/ProjectsOverviewWindow.as b/src/de/polcin/as3/flashdictator/view/ProjectsOverviewWindow.as
new file mode 100644
index 0000000..399c2ab
--- a/dev/null
+++ b/src/de/polcin/as3/flashdictator/view/ProjectsOverviewWindow.as
@@ -0,0 +1,121 @@
1package de.polcin.as3.flashdictator.view {
2 import de.polcin.as3.flashdictator.ctrl.DB;
3 import de.polcin.as3.flashdictator.ctrl.SndCtrl;
4 import de.polcin.as3.flashdictator.event.AppDataEvent;
5
6 import com.bit101.components.FixedList;
7 import com.bit101.components.HBox;
8 import com.bit101.components.PushButton;
9 import com.bit101.components.VBox;
10 import com.bit101.components.Window;
11
12 import flash.display.DisplayObjectContainer;
13 import flash.events.Event;
14 import flash.net.FileReference;
15
16 /**
17 * http://www.christoph-polcin.com
18 *
19 * @author christoph
20 */
21 public class ProjectsOverviewWindow extends Window {
22 protected var db:DB;
23 protected var list:FixedList;
24 protected var vb:VBox;
25 protected var btnshow:PushButton;
26
27 public function ProjectsOverviewWindow(parent:DisplayObjectContainer, db:DB) {
28 this.db = db;
29 super(parent, 0, 0, t("Projects"));
30
31 hasCloseButton = true;
32 hasMinimizeButton = false;
33 shadow = true;
34 draggable = false;
35
36 setSize(500, 350);
37 visible = false;
38 }
39
40 override protected function addChildren():void {
41 super.addChildren();
42 vb = new VBox(this, MainPanel.BORDER, MainPanel.BORDER);
43 list = new FixedList(vb);
44 list.alternateRows = true;
45 list.autoHideScrollBar = true;
46
47 var hb:HBox = new HBox(vb);
48 hb.spacing = MainPanel.BORDER2 << 1;
49 hb.alignment = HBox.MIDDLE;
50 btnshow = new PushButton(hb, 0, 0, t('Show'), onShowProjectHndl);
51 new PushButton(hb, 0, 0, t('Export'), onExportProjectHndl);
52 new PushButton(hb, 0, 0, t('Delete'), onDeleteProjectHndl);
53 new PushButton(hb, 0, 0, t('Close'), onCloseProjectHndl);
54 refreshList();
55 }
56
57 protected function onShowProjectHndl(doNotUse:Event=null):void {
58 if (!list.selectedItem || !list.selectedItem.label)
59 return;
60
61 dispatchEvent(new AppDataEvent(AppDataEvent.DISPLAY_TEXT_RO, db.getValue(list.selectedItem.label, null)));
62 onCloseProjectHndl();
63 }
64
65 protected function onExportProjectHndl(e:Event=null):void {
66 if (!list.selectedItem || !list.selectedItem.label)
67 return;
68
69 var txt:String = db.getValue(list.selectedItem.label, null);
70 if (!txt || !txt.length)
71 return;
72
73 var f:FileReference = new FileReference();
74 f.save(txt, list.selectedItem.label + '.txt');
75 }
76
77 protected function onDeleteProjectHndl(e:Event=null):void {
78 if (!list.selectedItem || !list.selectedItem.label)
79 return;
80
81 db.deleteKey(list.selectedItem.label);
82 refreshList();
83 }
84
85 protected function onCloseProjectHndl(e:Event=null):void {
86 this.dispatchEvent(new Event(Event.CLOSE));
87 }
88
89 override public function setSize(w:Number, h:Number):void {
90 super.setSize(w, h);
91 list.setSize(w - MainPanel.BORDER2, h - MainPanel.BORDER2 - 45);
92 vb.setSize(w - MainPanel.BORDER2, h - MainPanel.BORDER2 - 20);
93 }
94
95 protected function refreshList():void {
96 this.list.removeAll();
97 list.selectedItem = null;
98 var lst:Array = db.getKeys();
99
100 if (lst.length) {
101 var key:String;
102 for each(key in lst) {
103 if (key === SndCtrl.BREAK_DURATION_KEY || key === SndCtrl.CHUNK_DURATION_KEY)
104 continue;
105 list.addItem({label: key});
106 }
107 }
108 }
109
110 override public function set visible(value:Boolean):void {
111 if (value)
112 refreshList();
113
114 super.visible = value;
115 }
116
117 public function set enableShow(value:Boolean):void {
118 btnshow.enabled = value;
119 }
120 }
121}