Skip to content

Commit

Permalink
locking the participant windows when the session layout are locked
Browse files Browse the repository at this point in the history
  • Loading branch information
fcecagno committed Jun 15, 2012
1 parent cb96e55 commit 473468c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ package org.bigbluebutton.modules.layout.managers
import flash.utils.Timer;

import flexlib.mdi.containers.MDICanvas;
import flexlib.mdi.containers.MDIWindow;
import flexlib.mdi.events.MDIManagerEvent;

import mx.controls.Alert;
Expand Down Expand Up @@ -59,7 +60,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
*/
Expand Down Expand Up @@ -176,6 +176,7 @@ package org.bigbluebutton.modules.layout.managers
_canvas.windowManager.addEventListener(MDIManagerEvent.WINDOW_MAXIMIZE, onActionOverWindowFinished);
_canvas.windowManager.addEventListener(MDIManagerEvent.WINDOW_RESTORE, onActionOverWindowFinished);
_canvas.windowManager.addEventListener(MDIManagerEvent.WINDOW_ADD, function(e:MDIManagerEvent):void {
checkPermissionsOverWindow(e.window);
applyLayout(_currentLayout);
});
}
Expand Down Expand Up @@ -218,11 +219,29 @@ package org.bigbluebutton.modules.layout.managers
public function remoteLockLayout():void {
LogUtil.debug("LayoutManager: remote lock received");
_locked = true;
checkPermissionsOverWindow();
}

public function remoteUnlockLayout():void {
LogUtil.debug("LayoutManager: remote unlock received");
_locked = false;
checkPermissionsOverWindow();
}

private function checkPermissionsOverWindow(window:MDIWindow=null):void {
if (window != null) {
if (!UserManager.getInstance().getConference().amIModerator()
&& !LayoutDefinition.ignoreWindow(window)) {
window.draggable
= window.resizable
= window.showControls
= !_locked;
}
} else {
for each (window in _canvas.windowManager.windowList) {
checkPermissionsOverWindow(window);
}
}
}

private function onContainerResized(e:ResizeEvent):void {
Expand All @@ -245,6 +264,10 @@ package org.bigbluebutton.modules.layout.managers
// }

private function onActionOverWindowFinished(e:MDIManagerEvent):void {
if (LayoutDefinition.ignoreWindow(e.window))
return;

checkPermissionsOverWindow(e.window);
if (_detectContainerChange) {
_globalDispatcher.dispatchEvent(new LayoutEvent(LayoutEvent.INVALIDATE_LAYOUT_EVENT));
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ package org.bigbluebutton.modules.layout.model {
[Bindable] public var defaultLayout:Boolean = false;
[Bindable] private var windows:Dictionary = new Dictionary();
static private var _ignoredWindows:Array = new Array("PublishWindow",
"VideoWindow", "DesktopPublishWindow", "DesktopViewWindow");
"VideoWindow", "DesktopPublishWindow", "DesktopViewWindow",
"LogWindow");

public function load(vxml:XML):void {
if (vxml != null) {
Expand Down Expand Up @@ -76,20 +77,30 @@ package org.bigbluebutton.modules.layout.model {

public function applyToWindow(canvas:MDICanvas, window:MDIWindow):void {
var type:String = WindowLayout.getType(window);
if (!ignoreWindow(type))
if (!ignoreWindowByType(type))
WindowLayout.setLayout(canvas, window, windows[type]);
}

static private function ignoreWindow(type:String):Boolean {
return (type in _ignoredWindows);
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;
}

static public function ignoreWindow(window:MDIWindow):Boolean {
var type:String = WindowLayout.getType(window);
return ignoreWindowByType(type);
}

static public function getLayout(canvas:MDICanvas, name:String):LayoutDefinition {
var layoutDefinition:LayoutDefinition = new LayoutDefinition();
layoutDefinition.name = name;
for each (var window:MDIWindow in canvas.windowManager.windowList) {
var layout:WindowLayout = WindowLayout.getLayout(canvas, window);
if (!ignoreWindow(layout.name))
if (!ignoreWindowByType(layout.name))
layoutDefinition.windows[layout.name] = layout;
}
return layoutDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ package org.bigbluebutton.modules.layout.model {
}

private var _delayedEffects:Array = new Array();

private function delayEffect(canvas:MDICanvas, window:MDIWindow):void {
var obj:Object = {canvas:canvas, window:window};
_delayedEffects.push(obj);
Expand All @@ -111,44 +110,42 @@ package org.bigbluebutton.modules.layout.model {
}

public function applyToWindow(canvas:MDICanvas, window:MDIWindow):void {
var effect:Parallel = new Parallel();
effect.duration = EVENT_DURATION;
effect.target = window;

if (this.minimized) {
if (!window.minimized) window.minimize();
return;
} else if (this.maximized) {
if (!window.maximized) window.maximize();
return;
} else if (window.minimized && !this.minimized) {
} else if (window.minimized && !this.minimized && !this.hidden) {
window.unMinimize();
delayEffect(canvas, window);
return;
} else if (window.maximized && !this.maximized) {
} else if (window.maximized && !this.maximized && !this.hidden) {
window.maximizeRestore();
delayEffect(canvas, window);
return;
}

var effect:Parallel = new Parallel();
effect.duration = EVENT_DURATION;
effect.target = window;

if (!this.hidden) {
var newWidth:int = int(this.width * canvas.width);
var newHeight:int = int(this.height * canvas.height);
var newX:int = int(this.x * canvas.width);
var newY:int = int(this.y * canvas.height);

if (newX != window.x || newY != window.y) {
var mover:Move = new Move();
mover.xTo = newX;
mover.yTo = newY;
effect.addChild(mover);
}

if (newWidth != window.width || newHeight != window.height) {
var resizer:Resize = new Resize();
resizer.widthTo = newWidth;
resizer.heightTo = newHeight;
effect.addChild(resizer)
} else {
if (!this.hidden) {
var newWidth:int = int(this.width * canvas.width);
var newHeight:int = int(this.height * canvas.height);
var newX:int = int(this.x * canvas.width);
var newY:int = int(this.y * canvas.height);

if (newX != window.x || newY != window.y) {
var mover:Move = new Move();
mover.xTo = newX;
mover.yTo = newY;
effect.addChild(mover);
}

if (newWidth != window.width || newHeight != window.height) {
var resizer:Resize = new Resize();
resizer.widthTo = newWidth;
resizer.heightTo = newHeight;
effect.addChild(resizer)
}
}
}

Expand All @@ -170,7 +167,8 @@ package org.bigbluebutton.modules.layout.model {
effect.addChild(fader);
}

effect.play();
// if (effect.children.lenght > 0)
effect.play();
}

static public function getType(obj:Object):String {
Expand Down

0 comments on commit 473468c

Please sign in to comment.