start to develop an order manager, which would keep track of the z-order of the windows in the canvas

This commit is contained in:
Felipe Cecagno 2012-06-19 12:27:13 -03:00
parent b65ecad3b2
commit 5f2c4fc837
4 changed files with 175 additions and 26 deletions

View File

@ -27,6 +27,7 @@ package org.bigbluebutton.modules.layout.managers
import flash.net.FileReference;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.utils.Dictionary;
import flash.utils.Timer;
import flexlib.mdi.containers.MDICanvas;
@ -46,6 +47,7 @@ package org.bigbluebutton.modules.layout.managers
import org.bigbluebutton.modules.layout.model.LayoutDefinition;
import org.bigbluebutton.modules.layout.model.LayoutDefinitionFile;
import org.bigbluebutton.modules.layout.model.LayoutLoader;
import org.bigbluebutton.modules.layout.model.WindowLayout;
import org.bigbluebutton.modules.layout.events.RedefineLayoutEvent;
import org.bigbluebutton.util.i18n.ResourceUtil;
@ -60,9 +62,6 @@ package org.bigbluebutton.modules.layout.managers
private var _sendCurrentLayoutUpdateTimer:Timer = new Timer(500,1);
private var _applyCurrentLayoutTimer:Timer = new Timer(150,1);
private var _customLayoutsCount:int = 0;
/*
* \TODO investigate why it doesn't work
*/
private var _eventsToDelay:Array = new Array(MDIManagerEvent.WINDOW_RESTORE,
MDIManagerEvent.WINDOW_MINIMIZE,
MDIManagerEvent.WINDOW_MAXIMIZE);
@ -179,8 +178,15 @@ package org.bigbluebutton.modules.layout.managers
checkPermissionsOverWindow(e.window);
applyLayout(_currentLayout);
});
// _canvas.windowManager.addEventListener(MDIManagerEvent.WINDOW_FOCUS_START, function(e:MDIManagerEvent):void {
// OrderManager.getInstance().bringToFront(e.window);
// });
// for each (var window:MDIWindow in _canvas.windowManager.windowList.reverse()) {
// OrderManager.getInstance().bringToFront(window);
// }
}
public function applyDefaultLayout():void {
applyLayout(_layouts.getDefault());
sendLayoutUpdate(_currentLayout);
@ -274,9 +280,7 @@ package org.bigbluebutton.modules.layout.managers
* some events related to animated actions must be delayed because if it's not the
* current layout doesn't get properly updated
*/
if (e.type == MDIManagerEvent.WINDOW_RESTORE
|| e.type == MDIManagerEvent.WINDOW_MAXIMIZE
|| e.type == MDIManagerEvent.WINDOW_MINIMIZE) {
if (_eventsToDelay.indexOf(e.type) != -1) {
LogUtil.debug("LayoutManager: waiting the end of the animation to update the current layout");
_sendCurrentLayoutUpdateTimer.reset();
_sendCurrentLayoutUpdateTimer.start();

View File

@ -0,0 +1,110 @@
/**
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
*
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below).
*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation; either version 2.1 of the License, or (at your option) any later
* version.
*
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
*
* Author: Felipe Cecagno <felipe@mconf.org>
*/
package org.bigbluebutton.modules.layout.managers
{
import flash.utils.Dictionary;
import flexlib.mdi.containers.MDIWindow;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.layout.model.LayoutDefinition;
import org.bigbluebutton.modules.layout.model.WindowLayout;
public class OrderManager {
private static var _instance:OrderManager = null;
private var _windowsOrder:Dictionary = new Dictionary();
/**
* This class is a singleton. Please initialize it using the getInstance() method.
*
*/
public function OrderManager(enforcer:SingletonEnforcer) {
if (enforcer == null){
throw new Error("There can only be 1 OrderManager instance");
}
initialize();
}
private function initialize():void{
}
/**
* Return the single instance of the UserManager class
*/
public static function getInstance():OrderManager{
if (_instance == null){
_instance = new OrderManager(new SingletonEnforcer());
}
return _instance;
}
public function bringToFront(window:MDIWindow):void {
if (LayoutDefinition.ignoreWindow(window))
return;
var type:String = WindowLayout.getType(window);
var currentOrder:int = int.MAX_VALUE;
if (_windowsOrder.hasOwnProperty(type))
currentOrder = _windowsOrder[type].order;
for (var key:Object in _windowsOrder) {
var tmpOrder:int = _windowsOrder[key].order;
if (tmpOrder <= currentOrder)
_windowsOrder[key].order = tmpOrder + 1;
// LogUtil.debug("==========> " + key + " order: " + _windowsOrder[key].order);
}
_windowsOrder[type] = { order: 0 };
// if (_windowsOrder.length > window.windowManager.windowList.length) {
// var openWindows:Array = new Array();
// for each (var tmp:MDIWindow in window.windowManager.windowList) {
// openWindows.push(WindowLayout.getType(tmp));
// }
// for (key in _windowsOrder) {
// if (openWindows.indexOf(key) == -1) {
// LogUtil.debug("Removing order for " + key);
// delete _windowsOrder[key];
// }
// }
// }
// LogUtil.debug("Manipulating " + type);
// for (key in _windowsOrder) {
// LogUtil.debug("=====> " + key + " order: " + _windowsOrder[key].order);
// }
// window.windowManager.bringToFront(window);
}
public function getOrderByType(type:String):int {
if (_windowsOrder.hasOwnProperty(type))
return _windowsOrder[type].order;
else
return -1;
}
public function getOrderByRef(window:MDIWindow):int {
return getOrderByType(WindowLayout.getType(window));
}
}
}
class SingletonEnforcer{}

View File

@ -26,11 +26,12 @@ package org.bigbluebutton.modules.layout.model {
import flexlib.mdi.containers.MDIWindow;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.layout.managers.OrderManager;
[Bindable] public var name:String;
// default is a reserved word in actionscript
[Bindable] public var defaultLayout:Boolean = false;
[Bindable] private var windows:Dictionary = new Dictionary();
[Bindable] private var _windows:Dictionary = new Dictionary();
static private var _ignoredWindows:Array = new Array("PublishWindow",
"VideoWindow", "DesktopPublishWindow", "DesktopViewWindow",
"LogWindow");
@ -46,13 +47,13 @@ package org.bigbluebutton.modules.layout.model {
for each (var n:XML in vxml.window) {
var window:WindowLayout = new WindowLayout();
window.load(n);
windows[window.name] = window;
_windows[window.name] = window;
}
}
}
public function windowLayout(name:String):WindowLayout {
return windows[name];
return _windows[name];
}
public function toXml():XML {
@ -60,34 +61,59 @@ package org.bigbluebutton.modules.layout.model {
xml.@name = name;
if (defaultLayout)
xml.@default = true;
for each (var value:WindowLayout in windows) {
for each (var value:WindowLayout in _windows) {
xml.appendChild(value.toXml());
}
return xml;
}
private function adjustWindowsOrder(canvas:MDICanvas):void {
var orderList:Array = new Array();
var type:String;
var order:int;
for each (var window:MDIWindow in canvas.windowManager.windowList) {
type = WindowLayout.getType(window);
if (ignoreWindowByType(type) || !_windows.hasOwnProperty(type))
continue;
order = _windows[type].order;
// order == -1 means that there's no order defined for this window
if (order != -1)
orderList[order] = { window:window, order:order, type:type };
}
// only bring the focused window to front
for each (var obj:Object in orderList) {
if (obj != null) {
obj.window.windowManager.bringToFront(obj.window);
break;
}
}
}
public function applyToCanvas(canvas:MDICanvas):void {
if (canvas == null)
return;
return;
// adjustWindowsOrder(canvas);
for each (var window:MDIWindow in canvas.windowManager.windowList) {
applyToWindow(canvas, window);
}
}
public function applyToWindow(canvas:MDICanvas, window:MDIWindow):void {
var type:String = WindowLayout.getType(window);
public function applyToWindow(canvas:MDICanvas, window:MDIWindow, type:String=null):void {
if (type == null)
type = WindowLayout.getType(window);
if (!ignoreWindowByType(type))
WindowLayout.setLayout(canvas, window, windows[type]);
WindowLayout.setLayout(canvas, window, _windows[type]);
}
static private function ignoreWindowByType(type:String):Boolean {
var ignored:Boolean;
// ignored = _ignoredWindows.some(function(element:*, index:int, array:Array):Boolean {
// return (element == type);
// });
ignored = (_ignoredWindows.indexOf(type) != -1);
return ignored;
return (_ignoredWindows.indexOf(type) != -1);
}
static public function ignoreWindow(window:MDIWindow):Boolean {
@ -101,7 +127,7 @@ package org.bigbluebutton.modules.layout.model {
for each (var window:MDIWindow in canvas.windowManager.windowList) {
var layout:WindowLayout = WindowLayout.getLayout(canvas, window);
if (!ignoreWindowByType(layout.name))
layoutDefinition.windows[layout.name] = layout;
layoutDefinition._windows[layout.name] = layout;
}
return layoutDefinition;
}

View File

@ -37,6 +37,7 @@ package org.bigbluebutton.modules.layout.model {
import flash.utils.Timer;
import flash.events.TimerEvent;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.modules.layout.managers.OrderManager;
[Bindable] public var name:String;
[Bindable] public var width:Number;
@ -45,7 +46,9 @@ package org.bigbluebutton.modules.layout.model {
[Bindable] public var y:Number;
[Bindable] public var minimized:Boolean = false;
[Bindable] public var maximized:Boolean = false;
[Bindabla] public var hidden:Boolean = false;
[Bindable] public var hidden:Boolean = false;
[Bindable] public var order:int = -1;
static private var EVENT_DURATION:int = 500;
@ -75,6 +78,9 @@ package org.bigbluebutton.modules.layout.model {
if (vxml.@hidden != undefined) {
hidden = (vxml.@hidden.toString().toUpperCase() == "TRUE") ? true : false;
}
// if (vxml.@order != undefined) {
// order = int(vxml.@order);
// }
}
}
@ -88,6 +94,7 @@ package org.bigbluebutton.modules.layout.model {
layout.minimized = window.minimized;
layout.maximized = window.maximized;
layout.hidden = !window.visible;
// layout.order = OrderManager.getInstance().getOrderByRef(window);
return layout;
}
@ -168,7 +175,7 @@ package org.bigbluebutton.modules.layout.model {
effect.addChild(fader);
}
// if (effect.children.lenght > 0)
if (effect.children.length > 0)
effect.play();
}
@ -197,7 +204,8 @@ package org.bigbluebutton.modules.layout.model {
xml.@x = int(x * canvas.width);
xml.@y = int(y * canvas.height);
}
return xml;
// xml.@order = order;
return xml;
}
public function toXml():XML {
@ -215,6 +223,7 @@ package org.bigbluebutton.modules.layout.model {
xml.@x = x;
xml.@y = y;
}
// xml.@order = order;
return xml;
}
}