Merge pull request #4260 from capilkey/improve-client-annotation-edit
Improve client annotation editing speed
This commit is contained in:
commit
95ded61cbe
4
bigbluebutton-client/branding/default/style/css/V2Theme.css
Normal file → Executable file
4
bigbluebutton-client/branding/default/style/css/V2Theme.css
Normal file → Executable file
@ -1607,9 +1607,9 @@ whiteboard|WhiteboardTextToolbar {
|
||||
}
|
||||
|
||||
.multiUserWhiteboardOnButtonStyle {
|
||||
icon : Embed(source="assets/swf/v2_skin.swf", symbol="Icon_Whiteboard");
|
||||
icon : Embed(source="assets/swf/v2_skin.swf", symbol="Icon_Multi_Whiteboard");
|
||||
}
|
||||
|
||||
.multiUserWhiteboardOffButtonStyle {
|
||||
icon : Embed(source="assets/swf/v2_skin.swf", symbol="Icon_Multi_Whiteboard");
|
||||
icon : Embed(source="assets/swf/v2_skin.swf", symbol="Icon_Whiteboard");
|
||||
}
|
||||
|
@ -18,7 +18,8 @@
|
||||
*/
|
||||
package org.bigbluebutton.modules.whiteboard
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObject;
|
||||
|
||||
import org.as3commons.logging.api.ILogger;
|
||||
import org.as3commons.logging.api.getClassLogger;
|
||||
import org.bigbluebutton.core.UsersUtil;
|
||||
@ -42,7 +43,7 @@ package org.bigbluebutton.modules.whiteboard
|
||||
|
||||
private var whiteboardModel:WhiteboardModel;
|
||||
private var wbCanvas:WhiteboardCanvas;
|
||||
private var _annotationsList:Array = new Array();
|
||||
private var _annotationsMap:Object = new Object();
|
||||
private var _cursors:Object = new Object();
|
||||
private var shapeFactory:ShapeFactory = new ShapeFactory();
|
||||
private var textUpdateListener:TextUpdateListener = new TextUpdateListener();
|
||||
@ -71,140 +72,96 @@ package org.bigbluebutton.modules.whiteboard
|
||||
var gobj:GraphicObject;
|
||||
switch (o.status) {
|
||||
case AnnotationStatus.DRAW_START:
|
||||
createGraphic(o);
|
||||
createGraphic(o, false);
|
||||
break;
|
||||
case AnnotationStatus.DRAW_UPDATE:
|
||||
case AnnotationStatus.DRAW_END:
|
||||
for (var i:int = _annotationsList.length -1; i >= 0; i--) {
|
||||
gobj = _annotationsList[i] as GraphicObject;
|
||||
if (gobj != null && gobj.id == o.id) {
|
||||
gobj.updateAnnotation(o);
|
||||
return;
|
||||
}
|
||||
if (_annotationsMap.propertyIsEnumerable(o.id)) {
|
||||
(_annotationsMap[o.id] as GraphicObject).updateAnnotation(o);
|
||||
} else {
|
||||
createGraphic(o, false);
|
||||
}
|
||||
|
||||
createGraphic(o);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function createGraphic(o:Annotation):void {
|
||||
var gobj:GraphicObject = shapeFactory.makeGraphicObject(o, whiteboardModel);
|
||||
if (gobj != null) {
|
||||
gobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
wbCanvas.addGraphic(gobj as DisplayObject);
|
||||
_annotationsList.push(gobj);
|
||||
|
||||
if (o.type == AnnotationType.TEXT &&
|
||||
o.status != AnnotationStatus.DRAW_END &&
|
||||
o.userId == UsersUtil.getMyUserID()) {
|
||||
textUpdateListener.newTextObject(gobj as TextObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* the following three methods are used to remove any GraphicObjects (and its subclasses) if the id of the object to remove is specified. The latter
|
||||
two are convenience methods, the main one is the first of the three.
|
||||
*/
|
||||
private function removeGraphic(id:String):void {
|
||||
var gobjData:Array = getGobjInfoWithID(id);
|
||||
var removeIndex:int = gobjData[0];
|
||||
var gobjToRemove:GraphicObject = gobjData[1] as GraphicObject;
|
||||
wbCanvas.removeGraphic(gobjToRemove as DisplayObject);
|
||||
_annotationsList.splice(removeIndex, 1);
|
||||
|
||||
if (gobjToRemove.toolType == WhiteboardConstants.TYPE_TEXT) {
|
||||
textUpdateListener.removedTextObject(gobjToRemove as TextObject);
|
||||
}
|
||||
}
|
||||
|
||||
/* returns an array of the GraphicObject that has the specified id,
|
||||
and the index of that GraphicObject (if it exists, of course)
|
||||
*/
|
||||
private function getGobjInfoWithID(id:String):Array {
|
||||
var data:Array = new Array();
|
||||
for(var i:int = 0; i < _annotationsList.length; i++) {
|
||||
var currObj:GraphicObject = _annotationsList[i] as GraphicObject;
|
||||
if(currObj.id == id) {
|
||||
data.push(i);
|
||||
data.push(currObj);
|
||||
return data;
|
||||
private function createGraphic(o:Annotation, fromHistory:Boolean):void {
|
||||
var gobj:GraphicObject = shapeFactory.makeGraphicObject(o);
|
||||
if (gobj != null) {
|
||||
gobj.draw(o, shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
wbCanvas.addGraphic(gobj as DisplayObject);
|
||||
_annotationsMap[gobj.id] = gobj;
|
||||
|
||||
if (!fromHistory &&
|
||||
o.type == AnnotationType.TEXT &&
|
||||
o.status != AnnotationStatus.DRAW_END &&
|
||||
o.userId == UsersUtil.getMyUserID()) {
|
||||
textUpdateListener.newTextObject(gobj as TextObject);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private function removeLastGraphic():void {
|
||||
var gobj:GraphicObject = _annotationsList.pop();
|
||||
if (gobj.toolType == WhiteboardConstants.TYPE_TEXT) {
|
||||
textUpdateListener.removedTextObject(gobj as TextObject);
|
||||
private function removeGraphic(id:String):void {
|
||||
if (_annotationsMap.propertyIsEnumerable(id)) {
|
||||
var gobjToRemove:GraphicObject = _annotationsMap[id] as GraphicObject;
|
||||
wbCanvas.removeGraphic(gobjToRemove as DisplayObject);
|
||||
delete _annotationsMap[id];
|
||||
|
||||
if (gobjToRemove.toolType == WhiteboardConstants.TYPE_TEXT) {
|
||||
textUpdateListener.removedTextObject(gobjToRemove as TextObject);
|
||||
}
|
||||
}
|
||||
wbCanvas.removeGraphic(gobj as DisplayObject);
|
||||
}
|
||||
|
||||
public function clearBoard(userId:String=null):void {
|
||||
var gobj:GraphicObject;
|
||||
|
||||
if (userId) {
|
||||
for (var i:Number = _annotationsList.length-1; i >= 0; i--){
|
||||
var gobj:GraphicObject = _annotationsList[i] as GraphicObject;
|
||||
for each (gobj in _annotationsMap){
|
||||
if (gobj.userId == userId) {
|
||||
removeGraphic(_annotationsList[i].id);
|
||||
removeGraphic(gobj.id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var numGraphics:int = this._annotationsList.length;
|
||||
for (var j:Number = 0; j < numGraphics; j++){
|
||||
removeLastGraphic();
|
||||
for each (gobj in _annotationsMap){
|
||||
removeGraphic(gobj.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function undoAnnotation(annotation:Annotation):void {
|
||||
if (this._annotationsList.length > 0) {
|
||||
removeGraphic(annotation.id);
|
||||
}
|
||||
removeGraphic(annotation.id);
|
||||
}
|
||||
|
||||
public function receivedAnnotationsHistory(wbId:String):void {
|
||||
var annotations:Array = whiteboardModel.getAnnotations(wbId);
|
||||
for (var i:int = 0; i < annotations.length; i++) {
|
||||
var an:Annotation = annotations[i] as Annotation;
|
||||
var gobj:GraphicObject = shapeFactory.makeGraphicObject(an, whiteboardModel);
|
||||
if (gobj != null) {
|
||||
gobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
wbCanvas.addGraphic(gobj as DisplayObject);
|
||||
_annotationsList.push(gobj);
|
||||
}
|
||||
createGraphic(annotations[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
public function changeWhiteboard(wbId:String):void{
|
||||
textUpdateListener.canvasMouseDown();
|
||||
|
||||
// LogUtil.debug("**** CanvasDisplay changePage. Clearing page *****");
|
||||
clearBoard();
|
||||
|
||||
var annotations:Array = whiteboardModel.getAnnotations(wbId);
|
||||
// LogUtil.debug("**** CanvasDisplay changePage [" + annotations.length + "] *****");
|
||||
for (var i:int = 0; i < annotations.length; i++) {
|
||||
var an:Annotation = annotations[i] as Annotation;
|
||||
// LogUtil.debug("**** Drawing graphic from changePage [" + an.type + "] *****");
|
||||
var gobj:GraphicObject = shapeFactory.makeGraphicObject(an, whiteboardModel);
|
||||
if (gobj != null) {
|
||||
gobj.draw(an, shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
wbCanvas.addGraphic(gobj as DisplayObject);
|
||||
_annotationsList.push(gobj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function changeWhiteboard(wbId:String):void{
|
||||
textUpdateListener.canvasMouseDown();
|
||||
|
||||
//LogUtil.debug("**** CanvasDisplay changePage. Clearing page *****");
|
||||
clearBoard();
|
||||
|
||||
var annotations:Array = whiteboardModel.getAnnotations(wbId);
|
||||
//LogUtil.debug("**** CanvasDisplay changePage [" + annotations.length + "] *****");
|
||||
for (var i:int = 0; i < annotations.length; i++) {
|
||||
createGraphic(annotations[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
public function drawCursor(userId:String, xPercent:Number, yPercent:Number):void {
|
||||
if (!_cursors.hasOwnProperty(userId)) {
|
||||
var userName:String = UsersUtil.getUserName(userId);
|
||||
if (userName == null) userName = "Unknown";
|
||||
var newCursor:WhiteboardCursor = new WhiteboardCursor(userId, userName, xPercent, yPercent, shapeFactory.parentWidth, shapeFactory.parentHeight, presenterId == userId);
|
||||
wbCanvas.addCursor(newCursor);
|
||||
|
||||
_cursors[userId] = newCursor;
|
||||
if (userName) {
|
||||
var newCursor:WhiteboardCursor = new WhiteboardCursor(userId, userName, xPercent, yPercent, shapeFactory.parentWidth, shapeFactory.parentHeight, presenterId == userId);
|
||||
wbCanvas.addCursor(newCursor);
|
||||
|
||||
_cursors[userId] = newCursor;
|
||||
}
|
||||
} else {
|
||||
(_cursors[userId] as WhiteboardCursor).updatePosition(xPercent, yPercent);
|
||||
}
|
||||
@ -225,22 +182,18 @@ package org.bigbluebutton.modules.whiteboard
|
||||
}
|
||||
}
|
||||
|
||||
public function zoomCanvas(width:Number, height:Number):void{
|
||||
public function zoomCanvas(width:Number, height:Number):void {
|
||||
shapeFactory.setParentDim(width, height);
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
for (var i:int = 0; i < this._annotationsList.length; i++){
|
||||
redrawGraphic(this._annotationsList[i] as GraphicObject, i);
|
||||
for each (var gobj:GraphicObject in _annotationsMap) {
|
||||
gobj.redraw(shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
}
|
||||
|
||||
for(var j:String in _cursors) {
|
||||
(_cursors[j] as WhiteboardCursor).updateParentSize(width, height);
|
||||
}
|
||||
|
||||
for(var j:String in _cursors) {
|
||||
(_cursors[j] as WhiteboardCursor).updateParentSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
private function redrawGraphic(gobj:GraphicObject, objIndex:int):void {
|
||||
gobj.redraw(shapeFactory.parentWidth, shapeFactory.parentHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ package org.bigbluebutton.modules.whiteboard.business.shapes
|
||||
return _parentHeight;
|
||||
}
|
||||
|
||||
public function makeGraphicObject(a:Annotation, whiteboardModel:WhiteboardModel):GraphicObject{
|
||||
public function makeGraphicObject(a:Annotation):GraphicObject{
|
||||
if (a.type == AnnotationType.PENCIL) {
|
||||
return new Pencil(a.id, a.type, a.status, a.userId);
|
||||
} else if (a.type == AnnotationType.RECTANGLE) {
|
||||
|
@ -9,6 +9,7 @@ package org.bigbluebutton.modules.whiteboard.models
|
||||
private var _id:String;
|
||||
private var _historyLoaded:Boolean = false;
|
||||
private var _annotations:ArrayCollection = new ArrayCollection();
|
||||
private var _annotationsMap:Object = new Object();
|
||||
|
||||
public function Whiteboard(id:String) {
|
||||
_id = id;
|
||||
@ -28,10 +29,12 @@ package org.bigbluebutton.modules.whiteboard.models
|
||||
|
||||
public function addAnnotation(annotation:Annotation):void {
|
||||
_annotations.addItem(annotation);
|
||||
_annotationsMap[annotation.id] = annotation;
|
||||
}
|
||||
|
||||
public function addAnnotationAt(annotation:Annotation, index:int):void {
|
||||
_annotations.addItemAt(annotation, index);
|
||||
_annotationsMap[annotation.id] = annotation;
|
||||
}
|
||||
|
||||
public function updateAnnotation(annotation:Annotation):void {
|
||||
@ -48,42 +51,40 @@ package org.bigbluebutton.modules.whiteboard.models
|
||||
}
|
||||
|
||||
public function undo(id:String):Annotation {
|
||||
for (var i:int = _annotations.length-1; i >= 0; i--) {
|
||||
if ((_annotations.getItemAt(i) as Annotation).id == id) {
|
||||
return (_annotations.removeItemAt(i) as Annotation);
|
||||
}
|
||||
if (_annotationsMap.propertyIsEnumerable(id)) {
|
||||
var annotation:Annotation = _annotationsMap[id];
|
||||
delete _annotationsMap[id];
|
||||
_annotations.removeItem(annotation);
|
||||
return annotation;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function clearAll():void {
|
||||
_annotations.removeAll();
|
||||
_annotationsMap = new Object();
|
||||
}
|
||||
|
||||
public function clear(userId:String):void {
|
||||
for (var i:int = _annotations.length-1; i >= 0; i--) {
|
||||
if ((_annotations.getItemAt(i) as Annotation).userId == userId) {
|
||||
_annotations.removeItemAt(i);
|
||||
for each (var annotation:Annotation in _annotationsMap) {
|
||||
if (annotation.userId == userId) {
|
||||
delete _annotationsMap[annotation.id]
|
||||
_annotations.removeItem(annotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAnnotations():Array {
|
||||
var a:Array = new Array();
|
||||
for (var i:int = 0; i < _annotations.length; i++) {
|
||||
a.push(_annotations.getItemAt(i) as Annotation);
|
||||
}
|
||||
return a;
|
||||
return _annotations.toArray();
|
||||
}
|
||||
|
||||
public function getAnnotation(id:String):Annotation {
|
||||
for (var i:int = _annotations.length-1; i >= 0; i--) {
|
||||
if ((_annotations.getItemAt(i) as Annotation).id == id) {
|
||||
return _annotations.getItemAt(i) as Annotation;
|
||||
}
|
||||
if (_annotationsMap.propertyIsEnumerable(id)) {
|
||||
return _annotationsMap[id];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -84,7 +84,7 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
private var _hideToolbarTimer:Timer = new Timer(500, 1);
|
||||
|
||||
private function onCreationComplete():void {
|
||||
multiUserBtn.enabled = multiUserBtn.visible = UsersUtil.amIPresenter();
|
||||
multiUserBtn.enabled = multiUserBtn.visible = multiUserBtn.includeInLayout = UsersUtil.amIPresenter();
|
||||
|
||||
setToolType(WhiteboardConstants.TYPE_ZOOM, null);
|
||||
_hideToolbarTimer.addEventListener(TimerEvent.TIMER, onHideToolbarTimerComplete);
|
||||
@ -153,12 +153,12 @@ with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
|
||||
}
|
||||
|
||||
private function presenterMode(e:MadePresenterEvent):void {
|
||||
multiUserBtn.enabled = multiUserBtn.visible = true;
|
||||
multiUserBtn.enabled = multiUserBtn.visible = multiUserBtn.includeInLayout = true;
|
||||
checkVisibility();
|
||||
}
|
||||
|
||||
private function viewerMode(e:MadePresenterEvent):void {
|
||||
multiUserBtn.enabled = multiUserBtn.visible = false;
|
||||
multiUserBtn.enabled = multiUserBtn.visible = multiUserBtn.includeInLayout = false;
|
||||
checkToolReset();
|
||||
checkVisibility();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user