- the presentation window when resized disappears, something broke on the last checkin...this will at least fix the disappearing window

git-svn-id: http://bigbluebutton.googlecode.com/svn/trunk@3277 af16638f-c34d-0410-8cfa-b39d5352b314
This commit is contained in:
Richard Alam 2010-01-10 22:07:40 +00:00
parent 5b3391dcf9
commit 04c6e76d8e
3 changed files with 151 additions and 54 deletions

View File

@ -0,0 +1,17 @@
package org.bigbluebutton.modules.present.events
{
import flash.events.Event;
public class WindowResizedEvent extends Event
{
public static const PRESENTATION_WINDOW_RESIZED_EVENT:String = "PRESENTATION_WINDOW_RESIZED_EVENT";
public var width:int = 450;
public var height:int = 450;
public function WindowResizedEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=true)
{
super(type, bubbles, cancelable);
}
}
}

View File

@ -46,6 +46,7 @@
<mx:Script>
<![CDATA[
import org.bigbluebutton.modules.present.events.WindowResizedEvent;
import org.bigbluebutton.modules.present.events.DisplaySlideEvent;
import org.bigbluebutton.main.events.MadePresenterEvent;
import org.bigbluebutton.modules.present.events.SlideEvent;
@ -91,8 +92,12 @@
private var _xPosition:int = 220;
private var _yPosition:int = 0;
private var currentSlideWidth:int = 0;
private var currentSlideHeight:int = 0;
[Bindable] private var CONTROL_BAR_HEIGHT:int = 45;
private static const TOP_WINDOW_BORDER:int = 20;
// Init to the size of the window.
private var currentSlideWidth:int = 450;
private var currentSlideHeight:int = 450;
private var mouseDown:Boolean = false;
[Bindable] private var isPresenter:Boolean = false;
@ -135,22 +140,46 @@
private function onResizeEndEvent(event:MDIWindowEvent):void {
if (event.window == this) {
fitSlideToWindowMaintainingAspectRatio();
// fitSlideToWindowMaintainingAspectRatio();
}
}
private function fitSlideToWindowMaintainingAspectRatio():void {
var aspectRatio:int = currentSlideWidth/currentSlideHeight;
// Initialize to snap to take the width of the window as the size of the slide.
var slideWidth:int = this.width;
var slideHeight:int = ((currentSlideHeight * slideWidth)/currentSlideWidth);
this.width = aspectRatio * this.height;
this.height = aspectRatio * this.width;
LogUtil.debug("fitSlideToWindowMaintainingAspectRatio");
// If the height is smaller than the width, we use the height as the base to determine
// the size of the slide.
if (this.height < this.width) {
slideHeight = this.height;
slideWidth = ((currentSlideWidth * slideHeight)/currentSlideHeight);
}
LogUtil.debug("before: fitSlideToWindowMaintainingAspectRatio " + this.width + "," + this.height);
this.width = slideWidth;
this.height = slideHeight + CONTROL_BAR_HEIGHT + TOP_WINDOW_BORDER;
LogUtil.debug("after: fitSlideToWindowMaintainingAspectRatio " + "," + this.width + "," + this.height);
// sendWindowResizedEvent(slideWidth, slideHeight);
}
/*
* Notify the slide container telling it the available dimensions to display the slide.
*/
private function sendWindowResizedEvent(slideWidth:int, slideHeight:int):void {
var dispatcher:Dispatcher = new Dispatcher();
var dispEvent:WindowResizedEvent = new WindowResizedEvent(WindowResizedEvent.PRESENTATION_WINDOW_RESIZED_EVENT);
dispEvent.width = slideWidth;
dispEvent.height = slideHeight;
dispatcher.dispatchEvent(dispEvent);
}
private function handleDisplaySlideEvent(event:DisplaySlideEvent):void {
currentSlideWidth = event.slideWidth;
currentSlideHeight = event.slideHeight;
fitSlideToWindowMaintainingAspectRatio();
}
private function onKeyUp(e:KeyboardEvent):void{
@ -361,27 +390,7 @@
presenterNameLabel.text = "";
presenterNameLabel.visible = false;
}
private function fitToActualSize():void{
/* if (videoIsSmallerThanWindow()) {
fitWindowToVideo();
} else {
video.width = videoWidth;
videoHolder.width = videoWidth;
video.height = videoHeight;
videoHolder.height = videoHeight;
}
*/ }
private function determineHowToDisplaySlide():void {
/* if (btnActualSize.selected) {
fitToActualSize();
btnActualSize.toolTip = "Fit to window";
} else {
fitToWindow();
btnActualSize.toolTip = "Display actual size";
}
*/ }
]]>
</mx:Script>
@ -396,7 +405,7 @@
verticalScrollPolicy="off" horizontalScrollPolicy="off" verticalCenter="top"/>
</mx:Canvas>
<mx:ApplicationControlBar id="presCtrlBar" width="100%" height="45">
<mx:ApplicationControlBar id="presCtrlBar" width="100%" height="{CONTROL_BAR_HEIGHT}">
<mx:Button id="uploadPres" icon="{uploadIcon}" visible="false" width="20" height="20"
toolTip="Upload a document for presentation." click="dispatchEvent(new UploadEvent(UploadEvent.OPEN_UPLOAD_WINDOW))"/>
<mx:Label id="presenterNameLabel" visible="false" text=""/>
@ -412,9 +421,6 @@
allowTrackClick="true" liveDragging="true" change="sliderZoom()" width="100" />
<mx:Button id="btnResetZoom" icon="{magnifierIcon}" visible="false" width="20" height="20"
toolTip="Reset Zoom" click="dispatchEvent(new PresenterCommands(PresenterCommands.RESET_ZOOM))"/>
<!--mx:Button id="btnActualSize" toggle="true" click="determineHowToDisplaySlide()"
height="90%" icon="{btnActualSize.selected ? fitToActualSizeIcon : fitToWidthIcon}"
toolTip="Display actual size" /-->
</mx:ApplicationControlBar>
<mate:Listener type="{AddHighligtherCanvasEvent.ADD_HIGHLIGHTER_CANVAS}" method="addHighlighter" />

View File

@ -25,9 +25,9 @@
xmlns:panzoom="com.adobe.wheelerstreet.fig.panzoom.*"
xmlns:local="*"
width="100%" height="100%"
horizontalAlign="center" paddingBottom="5"
horizontalAlign="center" paddingBottom="5" resize="resizeSlideMaintainingAspectRatio()"
creationComplete="init()" verticalScrollPolicy="off" horizontalScrollPolicy="off"
resize="fitSlideToWindow()" rollOut="hideCursor()">
rollOut="hideCursor()">
<mate:Listener type="{ZoomEvent.ZOOM}" method="handleZoomEvent" />
<mate:Listener type="{ZoomEvent.RESTORE}" method="handleRestoreSlideSizeEvent" />
@ -37,7 +37,7 @@
<mate:Listener type="{MadePresenterEvent.SWITCH_TO_VIEWER_MODE}" method="handleSwitchToViewerEvent" />
<mate:Listener type="{CursorEvent.UPDATE_CURSOR}" method="handleUpdateCursorEvent" />
<mate:Listener type="{ZoomEvent.RESIZE}" method="handleResizeSlideEvent" />
<mate:Listener type="{WindowResizedEvent.PRESENTATION_WINDOW_RESIZED_EVENT}" method="handleWindowResizeEvent"/>
<mx:Script>
<![CDATA[
@ -49,6 +49,7 @@
import org.bigbluebutton.modules.present.events.SlideEvent;
import org.bigbluebutton.modules.present.events.MoveEvent;
import org.bigbluebutton.modules.present.events.ZoomEvent;
import org.bigbluebutton.modules.present.events.WindowResizedEvent;
import org.bigbluebutton.modules.present.events.PresenterCommands;
import mx.controls.Button;
import mx.collections.ArrayCollection;
@ -67,6 +68,8 @@
private var slideRealWidth:int;
private var slideRealHeight:int;
private var makeSlideFitToWindow:Boolean = true;
private var cursor:Shape;
//The following few variables concern text selection
@ -125,35 +128,69 @@
removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}
public function fitSlideToWindow():void{
private function handleWindowResizeEvent(event:WindowResizedEvent):void {
LogUtil.debug("before: handleWindowResizeEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY()+ ")]");
slideCanvas.width = event.width;
slideCanvas.height = event.height;
swfSlideLoader.width = swfSlideLoader.content.width = canvasWidth();
swfSlideLoader.height = swfSlideLoader.content.height = canvasHeight();
LogUtil.debug("after: handleWindowResizeEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
}
public function resizeSlideMaintainingAspectRatio():void{
if (swfSlideLoader.content == null) return;
LogUtil.debug("before: onResize[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
LogUtil.debug("before: resizeSlideMaintainingAspectRatio[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY()+ ")]");
// if ((swfSlideLoader.width < slideCanvasWidth()) || (swfSlideLoader.height < slideCanvasHeight())) {
swfSlideLoader.width = swfSlideLoader.content.width = slideCanvasWidth();
swfSlideLoader.height = swfSlideLoader.content.height = slideCanvasHeight();
// if (makeSlideFitToWindow) {
fitSlideToWindow();
// }
var dispatcher:Dispatcher = new Dispatcher();
var dispEvent:DisplaySlideEvent = new DisplaySlideEvent(DisplaySlideEvent.DISPLAY_SLIDE_EVENT);
dispEvent.slideWidth = slideRealWidth;
dispEvent.slideHeight = slideRealHeight;
dispatcher.dispatchEvent(dispEvent);
LogUtil.debug("after: onResize[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
// var dispatcher:Dispatcher = new Dispatcher();
// var dispEvent:DisplaySlideEvent = new DisplaySlideEvent(DisplaySlideEvent.DISPLAY_SLIDE_EVENT);
// dispEvent.slideWidth = slideRealWidth;
// dispEvent.slideHeight = slideRealHeight;
// dispatcher.dispatchEvent(dispEvent);
LogUtil.debug("after: resizeSlideMaintainingAspectRatio[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
}
public function fitSlideToWindow():void{
if (swfSlideLoader.content == null) return;
LogUtil.debug("before: fitSlideToWindow[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY()+ ")]");
// slideCanvas.height = ((slideRealHeight * canvasWidth())/slideRealWidth);
swfSlideLoader.width = swfSlideLoader.content.width = canvasWidth();
swfSlideLoader.height = swfSlideLoader.content.height = canvasHeight();
// var dispatcher:Dispatcher = new Dispatcher();
// var dispEvent:DisplaySlideEvent = new DisplaySlideEvent(DisplaySlideEvent.DISPLAY_SLIDE_EVENT);
// dispEvent.slideWidth = canvasWidth();
// dispEvent.slideHeight = canvasHeight();
// dispatcher.dispatchEvent(dispEvent);
LogUtil.debug("after: fitSlideToWindow[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
}
private function handleZoomEvent(e:ZoomEvent):void{
LogUtil.debug("before: handleZoomEvent[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
LogUtil.debug("before: handleZoomEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
swfSlideLoader.content.scaleX += e.zoomPercentage;
swfSlideLoader.content.scaleY += e.zoomPercentage;
swfSlideLoader.width = slideWidth();
swfSlideLoader.height = slideHeight();
LogUtil.debug("after: handleZoomEvent[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
LogUtil.debug("after: handleZoomEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
}
@ -167,7 +204,7 @@
private function handleMoveEvent(e:MoveEvent):void{
if (swfSlideLoader.content == null) return;
LogUtil.debug("before: handleMoveEvent[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
LogUtil.debug("before: handleMoveEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
var newX:Number = e.slideXPosition * slideCanvas.width;
@ -176,7 +213,7 @@
if (newX <= 0) swfSlideLoader.content.x = newX;
if (newY <= 0) swfSlideLoader.content.y = newY;
LogUtil.debug("after: handleMoveEvent[canvas:("+ slideCanvasWidth() + "," + slideCanvasHeight() + "," + canvasX() + "," + canvasY()
LogUtil.debug("after: handleMoveEvent[canvas:("+ canvasWidth() + "," + canvasHeight() + "," + canvasX() + "," + canvasY()
+ ")content(" + slideWidth() + "," + slideHeight() + "," + slideX() + "," + slideY()
+ ")loader(" + swfSlideLoader.width + "," + swfSlideLoader.height + "," + loaderX() + "," + loaderY() + ")]");
}
@ -241,6 +278,36 @@
}
/***********************************************************************
* Bounds helper functions
***********************************************************************/
private function isRightEdgeAligned():Boolean {
return ((Math.abs(slideX()) + canvasWidth()) >= slideWidth());
}
private function isTopEdgeAligned():Boolean {
return slideY() == canvasY();
}
private function isBottomEdgeAligned():Boolean {
return ((Math.abs(slideY()) + canvasHeight()) >= slideHeight());
}
private function isLeftEdgeAligned():Boolean {
return slideX() == canvasX();
}
private function snapSlideToTopOfCanvas():void {
swfSlideLoader.y = swfSlideLoader.content.y = canvasY();
}
private function snapSlideToLeftSideOfCanvas():void {
swfSlideLoader.x = swfSlideLoader.content.x = canvasX();
}
/*
* Fire an event when a single slide has been loaded.
*/
private function listenForSlideLoadedCompleteEvent():void {
swfSlideLoader.addEventListener(Event.COMPLETE, handleSlideLoadedCompleteEvent);
}
@ -249,8 +316,15 @@
slideRealWidth = slideWidth();
slideRealHeight = slideHeight();
LogUtil.debug("handleSlideLoadCompleteEvent[" + slideRealWidth + "," + slideRealHeight + "]");
makeSlideFitToWindow = true;
fitSlideToWindow();
// var dispatcher:Dispatcher = new Dispatcher();
// var dispEvent:DisplaySlideEvent = new DisplaySlideEvent(DisplaySlideEvent.DISPLAY_SLIDE_EVENT);
// dispEvent.slideWidth = slideRealWidth;
// dispEvent.slideHeight = slideRealHeight;
// dispatcher.dispatchEvent(dispEvent);
}
/*****************************************
@ -281,11 +355,11 @@
return swfSlideLoader.y;
}
private function slideCanvasWidth():int {
private function canvasWidth():int {
return slideCanvas.width;
}
private function slideCanvasHeight():int {
private function canvasHeight():int {
return slideCanvas.height;
}
@ -379,7 +453,7 @@
</mx:Script>
<mx:Canvas id="slideCanvas" width="100%" height="100%" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:SWFLoader id="swfSlideLoader" width="100%" height="100%"
<mx:SWFLoader id="swfSlideLoader" width="100%" height="100%" creationComplete="listenForSlideLoadedCompleteEvent()"
scaleContent="false" maintainAspectRatio="true" showBusyCursor="true" completeEffect="Fade"/>
</mx:Canvas>