From 11e08ebde21182b5689b87fbc86ed475dbabfff6 Mon Sep 17 00:00:00 2001 From: Richard Alam Date: Mon, 19 Sep 2011 16:40:18 -0400 Subject: [PATCH] Merge video docking module from mconf. There are minor bugs which may be due to using Flex 4.5 --- bigbluebutton-client/build.xml | 81 ++++- .../locale/en_US/bbbResources.properties | 5 + .../resources/config.xml.template | 6 + bigbluebutton-client/src/VideodockModule.mxml | 39 +++ .../src/org/bigbluebutton/common/Images.as | 12 + .../common/assets/images/arrow_in.png | Bin 0 -> 600 bytes .../common/assets/images/lock_close.png | Bin 0 -> 749 bytes .../common/assets/images/lock_open.png | Bin 0 -> 727 bytes .../common/assets/images/shape_handles.png | Bin 0 -> 538 bytes .../common/events/CloseWindowEvent.as | 2 +- .../common/events/DragWindowEvent.as | 44 +++ .../main/views/MainApplicationShell.mxml | 2 + .../bigbluebutton/main/views/MainCanvas.mxml | 26 +- .../modules/chat/views/ChatWindow.mxml | 2 +- .../videoconf/business/ButtonsOverlay.as | 55 +++ .../videoconf/business/VideoWindowItf.as | 322 ++++++++++++++++++ .../videoconf/events/OpenVideoWindowEvent.as | 44 +++ .../modules/videoconf/maps/VideoEventMap.mxml | 9 +- .../videoconf/views/PublishWindow.mxml | 247 ++++---------- .../modules/videoconf/views/VideoWindow.mxml | 256 ++++---------- .../videodock/maps/VideoDockEventMap.mxml | 51 +++ .../modules/videodock/views/VideoDock.mxml | 265 ++++++++++++++ .../bigbluebutton/util/i18n/ResourceUtil.as | 99 +++--- 23 files changed, 1125 insertions(+), 442 deletions(-) mode change 100644 => 100755 bigbluebutton-client/build.xml create mode 100755 bigbluebutton-client/src/VideodockModule.mxml create mode 100755 bigbluebutton-client/src/org/bigbluebutton/common/assets/images/arrow_in.png create mode 100755 bigbluebutton-client/src/org/bigbluebutton/common/assets/images/lock_close.png create mode 100755 bigbluebutton-client/src/org/bigbluebutton/common/assets/images/lock_open.png create mode 100755 bigbluebutton-client/src/org/bigbluebutton/common/assets/images/shape_handles.png mode change 100644 => 100755 bigbluebutton-client/src/org/bigbluebutton/common/events/CloseWindowEvent.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/common/events/DragWindowEvent.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/ButtonsOverlay.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/business/VideoWindowItf.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/events/OpenVideoWindowEvent.as create mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/videodock/maps/VideoDockEventMap.mxml create mode 100755 bigbluebutton-client/src/org/bigbluebutton/modules/videodock/views/VideoDock.mxml diff --git a/bigbluebutton-client/build.xml b/bigbluebutton-client/build.xml old mode 100644 new mode 100755 index 3927e5cc82..3db904aa6d --- a/bigbluebutton-client/build.xml +++ b/bigbluebutton-client/build.xml @@ -29,11 +29,24 @@ + + + + + + + + + + + + + @@ -45,6 +58,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @{locale} + 10.3.0 + + bbbResources + core + controls + + + + + @@ -110,7 +181,11 @@ - + + + + + @@ -127,7 +202,7 @@ @@ -309,7 +384,7 @@ to be compiled withouth being optimized by using the linker --> - diff --git a/bigbluebutton-client/locale/en_US/bbbResources.properties b/bigbluebutton-client/locale/en_US/bbbResources.properties index 8eb0d3f841..4b527d5c5d 100755 --- a/bigbluebutton-client/locale/en_US/bbbResources.properties +++ b/bigbluebutton-client/locale/en_US/bbbResources.properties @@ -122,6 +122,9 @@ bbb.publishVideo.title = Share your webcam bbb.publishVideo.startPublishBtn.toolTip = Start Sharing bbb.video.publish.close.tooltip = Stop sharing your video bbb.video.publish.close.label = Close +bbb.video.keepAspectBtn.tooltip = Keep window aspect +bbb.video.fitVideoBtn.tooltip = Fit video +bbb.video.originalSizeBtn.tooltip = Original size # Desktop Sharing bbb.desktopPublish.title = Desktop Sharing: Presenter's Preview @@ -183,3 +186,5 @@ bbb.settings.warning.label = Warning bbb.settings.warning.close = Close this Warning bbb.settings.noissues = No outstanding issues have been detected. bbb.settings.instructions = Accept the Flash prompt that asks you for camera permissions. If you can see yourself and hear yourself, your browser has been set up correctly. Other potentials issues are shown bellow. Click on each to find a possible solution. + +bbb.videodock.title = Video dock \ No newline at end of file diff --git a/bigbluebutton-client/resources/config.xml.template b/bigbluebutton-client/resources/config.xml.template index 60ab2daf79..a37bf7aab5 100755 --- a/bigbluebutton-client/resources/config.xml.template +++ b/bigbluebutton-client/resources/config.xml.template @@ -94,6 +94,12 @@ dependsOn="ViewersModule" /> + + - + resize="onResize()" + layout="absolute"> 1) showVideoControls(true); if (!isPresenter() && Camera.names.length == 1) startPublishing(); - addEventListener(MDIWindowEvent.RESIZE_END, onResizeEvent); - addEventListener(MDIWindowEvent.RESIZE, onResizeEvent); - addEventListener(MDIWindowEvent.MAXIMIZE, onMaximize); - addEventListener(MDIWindowEvent.RESTORE, onRestore); this.minWidth = _minWidth; this.minHeight = _minHeight; @@ -121,11 +111,7 @@ if (Camera.names[i] == webcam) cmbCameraSelector.selectedIndex = i; } } - - public function getPrefferedPosition():String{ - return MainCanvas.POPUP; - } - + private function startPublishing():void{ var camera:Camera = Camera.getCamera(cmbCameraSelector.selectedIndex.toString()); if (camera == null) return; @@ -136,13 +122,13 @@ camera.setMode(camWidth, camHeight, videoOptions.camModeFps); camera.setQuality(videoOptions.camQualityBandwidth, videoOptions.camQualityPicture); - video = new Video(camWidth, camHeight); + _video = new Video(camWidth, camHeight); //Next two lines may seem redundant but they're not. Do not delete. - video.width = camWidth; - video.height = camHeight; - adjustWindowSize(); - video.attachCamera(camera); - videoHolder.addChild(video); + _video.width = camWidth; + _video.height = camHeight; + onResize(); + _video.attachCamera(camera); + _videoHolder.addChild(_video); // addChild(videoHolder); var e:StartBroadcastEvent = new StartBroadcastEvent(); @@ -155,6 +141,22 @@ maximizeRestoreBtn.visible = true; this.resizable = true; + + addEventListener(MDIWindowEvent.RESIZE_START, onResizeStart); + addEventListener(MDIWindowEvent.RESIZE_END, onResizeEnd); + addEventListener(MDIWindowEvent.DRAG_START, onDragStart); + addEventListener(MDIWindowEvent.DRAG, onDrag); + addEventListener(MDIWindowEvent.DRAG_END, onDragEnd); + addEventListener(MouseEvent.MOUSE_OVER, showButtons); + addEventListener(MouseEvent.MOUSE_OUT, hideButtons); + addEventListener(MouseEvent.DOUBLE_CLICK, onDoubleClick); + + createButtons(); + + // this event will dock the window, if it's enabled + var openVideoEvent:OpenVideoWindowEvent = new OpenVideoWindowEvent(); + openVideoEvent.window = this; + dispatchEvent(openVideoEvent); } override public function close(event:MouseEvent=null):void{ @@ -163,28 +165,28 @@ } private function stopPublishing():void{ - if (video != null) { - video.attachCamera(null); - video.clear(); - video = null; + if (_video != null) { + _video.attachCamera(null); + _video.clear(); + _video = null; } var e:StopBroadcastEvent = new StopBroadcastEvent() - e.stream = this.streamName; + e.stream = streamName; dispatchEvent(e); } private function setResolution():void{ var res:Array = cmbResolution.selectedLabel.split( "x" ); - camWidth = Number(res[0]); - camHeight = Number(res[1]); - _nAspectRatio = (camWidth/camHeight); + camWidth = originalWidth = Number(res[0]); + camHeight = originalHeight = Number(res[1]); + setAspectRatio(camWidth, camHeight); /** * Add timestamp to create a unique stream name. This way we can record * stream without overwriting previously recorded streams. */ var curTime:Number = new Date().getTime(); - this.streamName = cmbResolution.selectedLabel.concat(this.streamName) + "-" + curTime; + this.streamName = cmbResolution.selectedLabel.concat(this.userId) + "-" + curTime; } public function set userrole(role:String):void{ @@ -198,6 +200,7 @@ private function showVideoControls(show:Boolean):void{ if (show){ + currentState = "dispVideoOptionsControlBar" videoOptionsBar.visible = true; btnStartPublish.visible = true; cmbCameraSelector.visible = true; @@ -206,6 +209,7 @@ btnStartPublish.visible = false; cmbCameraSelector.visible = false; videoOptionsBar.visible = false; + currentState = "dispVideo"; } } @@ -233,146 +237,27 @@ } } - private function adjustWindowSize():void{ - videoHolder.width = video.width; - videoHolder.height = video.height; - this.width = video.width + 6; - this.height = video.height + 74; - - // 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 - 74; - 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 - 74; - video.width = Math.floor(video.height * _nAspectRatio); - adjustWindowSize(); - } - } - - public function onResizeEvent(event:MDIWindowEvent):void { - if (event.type == MDIWindowEvent.RESIZE) { - // test if we are already resizing - if (_bResizePossible) { - _bResizePossible = false; - resizeWindow(); - _bResizePossible = true; - } - } else if (event.type == MDIWindowEvent.RESIZE_END) { - adjustWindowSize(); - } - } - - private function resizeWindow():void { - // 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 - 74; - 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(); - } - - public function onMaximize(event:MDIWindowEvent):void { - _nSavedVideoWidth = video.width; - _nSavedVideoHeight = video.height; - - - var tmpWidth:Number = this.parent.width - 6; - var tmpHeight:Number = this.parent.height - 74; - - if (tmpWidth > tmpHeight * _nAspectRatio) - tmpWidth = tmpHeight * _nAspectRatio; - if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio)) - tmpHeight = Math.floor(tmpWidth / _nAspectRatio); - - video.width = tmpWidth; - video.height = tmpHeight; - - video.x = Math.floor ((this.parent.width - 6 - video.width) / 2); - video.y = Math.floor ((this.parent.height - 74 - video.height) / 2); - } - - public function onRestore(event:MDIWindowEvent):void { - video.x = 0; - video.y = 0; - video.width = _nSavedVideoWidth; - video.height = _nSavedVideoHeight; - adjustWindowSize(); - } - - public function setWindowWidth(width:int):void { - if (video == null) return; - - video.width = width - 6; - video.height = Math.floor(video.width / _nAspectRatio); - adjustWindowSize(); - } - - static public function getMinWidth():int { - return _minWidth; - } - - static public function getMinHeight():int { - return _minHeight; - } - - static public function getWindowHeightByWidth(width:int, aspect:Number):int { - return Math.floor((width - 6) / aspect) + 74; - } - - static public function getWindowWidthByHeight(height:int, aspect:Number):int { - return Math.floor((height - 74) * aspect) + 6; - } override protected function resourcesChanged():void{ super.resourcesChanged(); - this.title = ResourceUtil.getInstance().getString('bbb.publishVideo.title'); - } - - private function localeChanged(e:LocaleChangeEvent):void{ - resourcesChanged(); - } - - private function onResize():void{ - setWindowWidth(this.width); - } - + // when the user starts to publish, the window title is your name + (you) + if (currentState == "dispVideoOptionsControlBar") + this.title = ResourceUtil.getInstance().getString('bbb.publishVideo.title'); + } ]]> + + + + + + + + + + + + - - - - - - - - - - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/views/VideoWindow.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/views/VideoWindow.mxml index e61ca42c3c..05308984e0 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/views/VideoWindow.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/videoconf/views/VideoWindow.mxml @@ -20,66 +20,50 @@ $Id: $ --> - + resize="onResize()" + layout="absolute"> 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 { - if (event.type == MDIWindowEvent.RESIZE) { - // test if we are already resizing - if (_bResizePossible) { - _bResizePossible = false; - resizeWindow(); - _bResizePossible = true; - } - } else if (event.type == MDIWindowEvent.RESIZE_END) { - adjustWindowSize(); - } - } - - private function resizeWindow():void { - // 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(); - } - - public function onMaximize(event:MDIWindowEvent):void { - _nSavedVideoWidth = video.width; - _nSavedVideoHeight = video.height; - - - var tmpWidth:Number = this.parent.width - 6; - var tmpHeight:Number = this.parent.height - 29; - - if (tmpWidth > tmpHeight * _nAspectRatio) - tmpWidth = tmpHeight * _nAspectRatio; - if (tmpHeight > Math.floor(tmpWidth / _nAspectRatio)) - tmpHeight = Math.floor(tmpWidth / _nAspectRatio); - - video.width = tmpWidth; - video.height = tmpHeight; - - video.x = Math.floor ((this.parent.width - 6 - video.width) / 2); - video.y = Math.floor ((this.parent.height - 29 - video.height) / 2); - } - - public function onRestore(event:MDIWindowEvent):void { - video.x = 0; - video.y = 0; - video.width = _nSavedVideoWidth; - video.height = _nSavedVideoHeight; - adjustWindowSize(); - } - - public function setWindowWidth(width:int):void { - if (video == null) return; - - video.width = width - 6; - video.height = Math.floor(video.width / _nAspectRatio); - adjustWindowSize(); - } - - static public function getMinWidth():int { - return _minWidth; - } - - static public function getMinHeight():int { - return _minHeight; - } - - private function onResize():void{ - setWindowWidth(this.width); - } - + ]]> - + diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/maps/VideoDockEventMap.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/maps/VideoDockEventMap.mxml new file mode 100755 index 0000000000..28b17f7750 --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/maps/VideoDockEventMap.mxml @@ -0,0 +1,51 @@ + + + + + + + + + + \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/views/VideoDock.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/views/VideoDock.mxml new file mode 100755 index 0000000000..4b9e09059a --- /dev/null +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/videodock/views/VideoDock.mxml @@ -0,0 +1,265 @@ + + + + + + + + desiredAR) + width = Math.floor(maxHeight * desiredAR); + else + height = Math.floor(maxWidth / desiredAR); + + if (width > childWidth) { + childWidth = width; + childHeight = height; + nRows = rows; + nColumns = columns; + } + } + + childWidth += VideoWindowItf.PADDING_HORIZONTAL; + childHeight += VideoWindowItf.PADDING_VERTICAL; + + for (var childIndex:int = 0; childIndex < numChildren; ++childIndex) { + var window:VideoWindowItf = children[childIndex]; + window.width = childWidth; + window.updateHeight(); + + if (window.height > childHeight) { + window.height = childHeight; + window.updateWidth(); + } + + var row:int = childIndex / nColumns; + var column:int = childIndex % nColumns; + + var borderTop:int = (availableHeight - nRows * childHeight - (nRows - 1) * verticalGap) / 2; + var borderLeft:int = (availableWidth - nColumns * childWidth - (nColumns - 1) * horizontalGap) / 2; + + window.y = row * (childHeight + verticalGap) + borderTop; + window.x = column * (childWidth + horizontalGap) + borderLeft; + } + } + + protected function onDoubleClick(event:MouseEvent = null):void { + this.maximizeRestore(); + } + + override protected function resourcesChanged():void{ + super.resourcesChanged(); + this.title = ResourceUtil.getInstance().getString('bbb.videodock.title'); + } + + ]]> + + + + + + \ No newline at end of file diff --git a/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as b/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as index a927baced0..6395b42810 100755 --- a/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as +++ b/bigbluebutton-client/src/org/bigbluebutton/util/i18n/ResourceUtil.as @@ -19,8 +19,6 @@ package org.bigbluebutton.util.i18n { import com.adobe.utils.StringUtil; - import com.asfusion.mate.events.Dispatcher; - import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; @@ -48,7 +46,7 @@ package org.bigbluebutton.util.i18n private static var BBB_RESOURCE_BUNDLE:String = 'bbbResources'; public static var DEFAULT_LANGUAGE:String = "en_US"; private static var currentLanguage:String = DEFAULT_LANGUAGE; - private var eventDispatcher:Dispatcher = new Dispatcher(); + private var eventDispatcher:IEventDispatcher; private var localeChain:Array = new Array(); private var resourceManager:IResourceManager; @@ -94,11 +92,23 @@ package org.bigbluebutton.util.i18n if (resourceManager.localeChain[0] == localeChain[i]) localeAvailable = true; } - //Locale not found, set default - changeLocale(DEFAULT_LANGUAGE); + /** + * http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/resources/IResourceManager.html#localeChain + * Always load the default language, so if the chosen language + * doesn't provide a resource, the default language resource is used + */ + load(DEFAULT_LANGUAGE); + if (!localeAvailable) + resourceManager.localeChain = [DEFAULT_LANGUAGE]; + changeLocale(resourceManager.localeChain[0]); } + private function load(language:String):IEventDispatcher { + var localeURI:String = 'locale/' + language + '_resources.swf'; + return resourceManager.loadResourceModule(localeURI, false); + } + public static function getInstance():ResourceUtil { if (instance == null) { LogUtil.debug("Setting up supported locales."); @@ -107,62 +117,41 @@ package org.bigbluebutton.util.i18n return instance; } - public function changeLocale(language:String):void{ - var localeURI:String = 'locale/' + language + '/bbbResources.properties'; - - var date:Date = new Date(); - var _urlLoader:URLLoader = new URLLoader(); - _urlLoader.addEventListener(Event.COMPLETE, handleLocaleLoaded); - _urlLoader.addEventListener(IOErrorEvent.IO_ERROR, handleResourceNotLoaded); - _urlLoader.load(new URLRequest(localeURI + "?a=" + date.time)); - - currentLanguage = language; - } - - private function handleLocaleLoaded(e:Event):void{ - var fulltext:String = (e.target.data as String); - fulltext = com.adobe.utils.StringUtil.remove(fulltext, "\r"); - - var allStrings:Array = fulltext.split("\n"); - for (var i:Number=0; i 0) + { + eventDispatcher = load(chain[0]); + localeChain = [chain[0]]; + eventDispatcher.addEventListener(ResourceEvent.COMPLETE, localeChangeComplete); + eventDispatcher.addEventListener(ResourceEvent.ERROR, handleResourceNotLoaded); - if (str.charAt(0) != '#'){ - var keyValue:Array = str.split("="); - var key:String = mx.utils.StringUtil.trim(keyValue[0] as String); - var value:String = mx.utils.StringUtil.trim(keyValue[1] as String); - currentLocalization[key] = value; - trace(key + "=" + value); - } + currentLanguage = chain[0]; } - - trace(currentLocalization['bbb.logout.usercommand']); - + } + + private function localeChangeComplete(event:ResourceEvent):void{ + if (localeChain[0] != DEFAULT_LANGUAGE) + localeChain.push(DEFAULT_LANGUAGE); + resourceManager.localeChain = localeChain; update(); } - - /** - * Defaults to DEFAULT_LANGUAGE when an error is thrown by the ResourceManager - * @param event - */ - private function handleResourceNotLoaded(event:ResourceEvent):void{ - currentLanguage = DEFAULT_LANGUAGE; - update(); - } - - public function update():void{ - eventDispatcher.dispatchEvent(new LocaleChangeEvent(LocaleChangeEvent.LOCALE_CHANGED)); - dispatchEvent(new Event(Event.CHANGE)); - } - - [Bindable("change")] - public function getString(resourceName:String, parameters:Array = null, locale:String = null):String{ - if (!parameters) return currentLocalization[resourceName]; //resourceManager.getString(BBB_RESOURCE_BUNDLE, resourceName, parameters, locale); - else return insertParameters(currentLocalization[resourceName], parameters); + + /** + * Defaults to DEFAULT_LANGUAGE when an error is thrown by the ResourceManager + * @param event + */ + private function handleResourceNotLoaded(event:ResourceEvent):void{ + resourceManager.localeChain = [DEFAULT_LANGUAGE]; + update(); } - private function insertParameters(text:String, parameters:Array):String{ - return mx.utils.StringUtil.substitute(text, parameters); + public function update():void{ + dispatchEvent(new Event(Event.CHANGE)); + } + + [Bindable("change")] + public function getString(resourceName:String, parameters:Array = null, locale:String = null):String{ + return resourceManager.getString(BBB_RESOURCE_BUNDLE, resourceName, parameters, locale); } public function getCurrentLanguageCode():String{