some other improvements on the resize window feature. still blinking sometimes

This commit is contained in:
Felipe Cecagno 2011-03-10 18:13:54 +00:00
parent 859176db78
commit bcbb108536
2 changed files with 98 additions and 44 deletions

View File

@ -60,8 +60,13 @@
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _nSavedVideoWidth:Number;
private var _nSavedVideoHeight:Number;
private var _minWidth:int = 166;
private var _minHeight:int = 149;
private var _nSavedVideoWidth:Number = 0;
private var _nSavedVideoHeight:Number = 0;
private var _nOldWindowWidth:Number = 0;
private var _nOldWindowHeight:Number = 0;
private function init():void{
currentState = "dispVideoOptionsControlBar";
@ -75,8 +80,8 @@
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
addEventListener(MDIWindowEvent.RESTORE, onRestore);
this.minWidth = 166;
this.minHeight = 149;
this.minWidth = _minWidth;
this.minHeight = _minHeight;
maximizeRestoreBtn.visible = false;
this.resizable = false;
}
@ -192,6 +197,28 @@
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
// prevent to show a video window bigger than the parent window
if (this.width > this.parent.width) {
video.width = this.parent.width - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height > this.parent.height) {
video.height = this.parent.height - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
if (this.width < _minWidth) {
video.width = _minWidth - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height < _minHeight) {
video.height = _minHeight - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
}
public function onResizeEvent(event:MDIWindowEvent):void {
@ -203,27 +230,26 @@
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
if (this.width > this.parent.width) {
this.width = this.parent.width;
this.height = Math.floor((this.width - 6) / _nAspectRatio) + 29;
}
if (this.height > this.parent.height) {
this.height = this.parent.height;
this.width = (this.height - 29) * _nAspectRatio + 6;
}
// make sure the size of the window is correct
resizeWindow();
adjustWindowSize();
}
}
private function resizeWindow():void {
// recalc size of video based on the width and height of the window
// make sure the video has a correct aspect ratio to avoid tall or flat faces
// prevent the window for blinking
if (this.width == _nOldWindowWidth && this.height == _nOldWindowHeight) {
adjustWindowSize();
return;
}
_nOldWindowWidth = this.width;
_nOldWindowHeight = this.height;
if (this.width == video.width + 6) {
// if it's a vertical resizing
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
// if it's a horizontal resizing
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}

View File

@ -24,7 +24,7 @@
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
implements="org.bigbluebutton.common.IBbbModuleWindow"
resizable="true" xmlns:mate="http://mate.asfusion.com/">
xmlns:mate="http://mate.asfusion.com/">
<mx:Script>
<![CDATA[
@ -51,8 +51,14 @@
private var _bResizePossible:Boolean = true;
private var _nAspectRatio:Number = 1;
private var _nSavedVideoWidth:Number;
private var _nSavedVideoHeight:Number;
private var _minWidth:int = 166;
private var _minHeight:int = 149;
private var _nSavedVideoWidth:Number = 0;
private var _nSavedVideoHeight:Number = 0;
private var _nOldWindowWidth:Number = 0;
private var _nOldWindowHeight:Number = 0;
private var _xPosition:int;
private var _yPosition:int;
@ -63,7 +69,7 @@
videoHolder = new UIComponent();
videoHolder.addChild(video);
this.addChild(videoHolder);
maximizeRestoreBtn.visible = true;
addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent);
addEventListener(MDIWindowEvent.RESIZE, onResizeEvent);
addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize);
@ -72,8 +78,8 @@
globalDispatcher = new Dispatcher();
this.minWidth = 166;
this.minHeight = 149;
this.minWidth = _minWidth;
this.minHeight = _minHeight;
maximizeRestoreBtn.visible = true;
this.resizable = true;
}
@ -100,10 +106,10 @@
video.height = this.height;
video.attachNetStream(ns);
ns.play(stream);
this.stream = stream;
this.width = video.width + 6;
this.height = video.height + 29;
this.stream = stream;
}
private function setVideoResolution(stream:String):void{
@ -165,6 +171,28 @@
videoHolder.height = video.height;
this.width = video.width + 6;
this.height = video.height + 29;
// prevent to show a video window bigger than the parent window
if (this.width > this.parent.width) {
video.width = this.parent.width - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height > this.parent.height) {
video.height = this.parent.height - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
if (this.width < _minWidth) {
video.width = _minWidth - 6;
video.height = Math.floor(video.width / _nAspectRatio);
adjustWindowSize();
}
if (this.height < _minHeight) {
video.height = _minHeight - 29;
video.width = Math.floor(video.height * _nAspectRatio);
adjustWindowSize();
}
}
public function onResizeEvent(event:MDIWindowEvent):void {
@ -176,30 +204,30 @@
_bResizePossible = true;
}
} else if (event.type == MDIWindowEvent.RESIZE_END) {
if (this.width > this.parent.width) {
this.width = this.parent.width;
this.height = Math.floor((this.width - 6) / _nAspectRatio) + 29;
}
if (this.height > this.parent.height) {
this.height = this.parent.height;
this.width = (this.height - 29) * _nAspectRatio + 6;
}
// make sure the size of the window is correct
resizeWindow();
adjustWindowSize();
}
}
private function resizeWindow():void {
// recalc size of video based on the width and height of the window
// make sure the video has a correct aspect ratio to avoid tall or flat faces
// prevent the window for blinking
if (this.width == _nOldWindowWidth && this.height == _nOldWindowHeight) {
adjustWindowSize();
return;
}
_nOldWindowWidth = this.width;
_nOldWindowHeight = this.height;
if (this.width == video.width + 6) {
// if it's a vertical resizing
video.height = this.height - 29;
video.width = video.height * _nAspectRatio;
} else {
// if it's a horizontal resizing
video.width = this.width - 6;
video.height = Math.floor (video.width / _nAspectRatio);
}
adjustWindowSize();
}