switch from custom pop-up menu to modified combo box

This commit is contained in:
Chad Pilkey 2015-03-23 15:11:49 -07:00
parent 7a7619c311
commit 80f44e5f21
3 changed files with 40 additions and 230 deletions

View File

@ -0,0 +1,31 @@
package org.bigbluebutton.modules.whiteboard.views
{
import flash.events.Event;
import flash.events.FocusEvent;
import mx.controls.ComboBox;
public class CustomComboBox extends ComboBox
{
private var _allowClose:Boolean = true;
public function CustomComboBox()
{
super();
}
override protected function focusOutHandler(event:FocusEvent):void {
_allowClose = false;
super.focusOutHandler(event);
_allowClose = true;
}
override public function close(trigger:Event=null):void {
if (_allowClose) {
super.close(trigger);
}
}
}
}

View File

@ -1,201 +0,0 @@
/**
* 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 3.0 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/>.
*
*/
package org.bigbluebutton.modules.whiteboard.views
{
import flash.display.DisplayObject;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.ui.Keyboard;
import mx.controls.PopUpButton;
import mx.core.UIComponent;
import mx.core.UIComponentGlobals;
import mx.core.mx_internal;
import mx.effects.Tween;
import mx.events.InterManagerRequest;
import mx.managers.ISystemManager;
import mx.managers.PopUpManager;
use namespace mx_internal;
public class PopUpCombo extends PopUpButton
{
public var isOpen:Boolean = false;
protected var _inTween:Boolean = false;
protected var _tween:Tween;
private var _specificOpenDirection:String;
public static const OPEN_UP:String = "OPEN_UP";
public static const OPEN_DOWN:String = "OPEN_DOWN";
public function PopUpCombo()
{
super();
}
public function get specificOpenDirection():String
{
if(!_specificOpenDirection) _specificOpenDirection = PopUpCombo.OPEN_DOWN;
return _specificOpenDirection;
}
public function set specificOpenDirection(value:String):void
{
_specificOpenDirection = value;
}
override protected function clickHandler(event:MouseEvent):void
{
event.stopImmediatePropagation();
displayPopUp();
}
override protected function keyDownHandler(event:KeyboardEvent):void
{
super.keyDownHandler(event);
if (event.ctrlKey && event.keyCode == Keyboard.DOWN)
{
event.stopImmediatePropagation();
displayPopUp();
}
}
public function displayPopUp():void
{
var show:Boolean = !isOpen;
var popUpGap:Number = getStyle("popUpGap");
var point:Point = new Point(0, unscaledHeight + popUpGap);
point = localToGlobal(point);
var initY:Number;
var endY:Number;
var easingFunction:Function;
var duration:Number;
if (popUp.parent == null)
{
PopUpManager.addPopUp(popUp, this, false);
popUp.owner = this;
}
else
PopUpManager.bringToFront(popUp);
if(show)
{
if(specificOpenDirection == PopUpCombo.OPEN_UP)
{
point.y -= (unscaledHeight + popUp.height + 2*popUpGap);
initY = -popUp.height;
}
else
{
initY = popUp.height;
}
point.x = Math.min( point.x, visibleScreen.right - popUp.getExplicitOrMeasuredWidth());
point.x = Math.max( point.x, 0);
point = popUp.parent.globalToLocal(point);
if (popUp.x != point.x || popUp.y != point.y)
popUp.move(point.x, point.y);
popUp.scrollRect = new Rectangle(0, initY,
popUp.width, popUp.height);
if (!popUp.visible)
popUp.visible = true;
endY = 0;
isOpen = show;
duration = getStyle("openDuration");
easingFunction = getStyle("openEasingFunction") as Function;
}
else
{
isOpen = show;
if (popUp.parent == null)
return;
point = popUp.parent.globalToLocal(point);
endY = (specificOpenDirection == PopUpCombo.OPEN_UP) ? -popUp.height - 2 : popUp.height + 2;
initY = 0;
duration = getStyle("closeDuration")
easingFunction = getStyle("closeEasingFunction") as Function;
}
_inTween = true;
UIComponentGlobals.layoutManager.validateNow();
// Block all layout, responses from web service, and other background
// processing until the tween finishes executing.
UIComponent.suspendBackgroundProcessing();
_tween = new Tween(this, initY, endY, duration);
if (easingFunction != null)
_tween.easingFunction = easingFunction;
}
protected function get visibleScreen():Rectangle
{
var sm:ISystemManager = systemManager.topLevelSystemManager;
var sbRoot:DisplayObject = sm.getSandboxRoot();
var _screen:Rectangle;
if (sm != sbRoot)
{
var request:InterManagerRequest = new InterManagerRequest(InterManagerRequest.SYSTEM_MANAGER_REQUEST,
false, false,
"getVisibleApplicationRect");
sbRoot.dispatchEvent(request);
_screen = Rectangle(request.value);
}
else
_screen = sm.getVisibleApplicationRect();
return _screen;
}
override mx_internal function onTweenUpdate(value:Number):void
{
popUp.scrollRect =
new Rectangle(0, value, popUp.width, popUp.height);
}
override mx_internal function onTweenEnd(value:Number):void
{
popUp.scrollRect =
new Rectangle(0, value, popUp.width, popUp.height);
_inTween = false;
UIComponent.resumeBackgroundProcessing();
if (!isOpen)
{
popUp.visible = false;
popUp.scrollRect = null;
}
}
}
}

View File

@ -38,7 +38,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
import mx.events.MenuEvent;
import mx.events.MoveEvent;
import mx.events.ResizeEvent;
import mx.managers.FocusManager;
import mx.managers.FocusManager;
import org.bigbluebutton.common.Images;
import org.bigbluebutton.common.LogUtil;
import org.bigbluebutton.main.events.MadePresenterEvent;
@ -65,6 +66,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
private var normalAlpha:Number = 0.55;
private var focusedAlpha:Number = 1.0;
private var hasFocus:Boolean;
private var fontSizes:Array = ["12", "14", "16", "18", "22", "24", "32", "36"];
public function init():void {
this.alpha = normalAlpha;
@ -92,23 +94,8 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
this.alpha = focusedAlpha;
}
private function initTextSizeMenu(): void {
var m:Menu = new Menu();
m.variableRowHeight = true;
var textSizeMenuData:Object = [{label: "12"}, {label: "14"}, {label: "16"},
{label: "18"}, {label: "22"}, {label: "24"}, {label: "32"}, {label: "36"}];
m.dataProvider = textSizeMenuData;
m.addEventListener(MenuEvent.CHANGE, textSizeMenuClick);
m.showRoot = false;
textSizeMenu.popUp = m;
}
// Define the event listener for the Menu control's change event.
private function textSizeMenuClick(event:MenuEvent):void {
enableTextToolbar();
textSizeMenu.displayPopUp();
var newTextSize:Number = Number(event.label);
setTextSize(newTextSize);
private function onFontSizeChange():void {
setTextSize(Number(textSizeMenu.selectedItem));
}
/**
@ -156,7 +143,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
enableTextToolbar();
this.textSize = size;
LogUtil.debug("Text size set to: " + size);
textSizeMenu.label = String(this.textSize);
canvas.modifySelectedTextObject(textColor, backgroundVisible, bgColor, textSize);
}
@ -182,7 +168,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
this.textColor = ctextpik.selectedColor = tobj.textColor;
// this.bgColor = cbackpik.selectedColor = tobj.backgroundColor;
// this.backgroundVisible = btnToggleBackground.selected = tobj.background;
this.textSizeMenu.label = String(tobj.textSize);
this.textSizeMenu.selectedItem = String(tobj.textSize);
this.textSize = tobj.textSize;
}
@ -210,12 +196,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
// translate TextObject's coords to stage coords because TextToolbar is added to stage
if (tobj == null) tobj = currentlySelectedTextObject;
if (textSizeMenu.isOpen) {
LogUtil.debug("Text size menu is open...trying to close");
textSizeMenu.displayPopUp();
}
var loc:Point = canvas.localToGlobal(new Point(tobj.x, tobj.y));
this.x = loc.x;
this.y = loc.y - this.height - 45;
@ -272,7 +253,6 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
<mx:ColorPicker width="20" height="20" change="setTextColor(event)" id="ctextpik" selectedColor="0x000000"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.textColorPicker')}"/>
<views:PopUpCombo id="textSizeMenu" creationComplete="initTextSizeMenu()"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.textSizeMenu')}"
openAlways="true" specificOpenDirection="{PopUpCombo.OPEN_UP}" />
<views:CustomComboBox id="textSizeMenu" dataProvider="{fontSizes}" change="onFontSizeChange()" rowCount="8"
toolTip="{ResourceUtil.getInstance().getString('ltbcustom.bbb.highlighter.texttoolbar.textSizeMenu')}" />
</mx:HBox>