From 1acdc0a13b237f93864f0e7910bdffa9fb61d2a6 Mon Sep 17 00:00:00 2001 From: Lajellu Date: Fri, 15 Jul 2016 13:45:54 -0700 Subject: [PATCH 1/2] Adds cursor xy tracking --- .../ui/components/whiteboard/component.jsx | 10 +++ .../whiteboard/cursor/component.jsx | 67 +++++++++++++++++++ .../ui/components/whiteboard/service.js | 7 ++ 3 files changed, 84 insertions(+) diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx index b01dc3d0ae..d8bd8a6294 100755 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/component.jsx @@ -1,5 +1,6 @@ import React, { PropTypes } from 'react'; import WhiteboardShapeModel from './shape-factory/component.jsx'; +import Cursor from './cursor/component.jsx'; import { createContainer } from 'meteor/react-meteor-data'; import Slide from './slide/component.jsx'; import styles from './styles.scss'; @@ -62,6 +63,15 @@ export default class Whiteboard extends React.Component { /> ) : null } + diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx index e69de29bb2..bd65605e15 100755 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx @@ -0,0 +1,67 @@ +import React, { Component, PropTypes } from 'react'; +import WhiteboardService from '/imports/ui/components/whiteboard/service.js'; + +const propTypes = { + + //Defines the cursor x position + cx: PropTypes.number, + + //Defines the cursor y position + cy: PropTypes.number, + + /** + * Defines the cursor fill colour + * @defaultValue 'red' + */ + fill: PropTypes.string, + + /** + * Defines the cursor radius + * @defaultValue 5 + */ + radius: PropTypes.number, +}; + +const defaultProps = { + fill: 'red', + radius: 5, +}; + +export default class Cursor extends Component { + constructor(props) { + super(props); + } + + render() { + const { + viewBoxWidth, + viewBoxHeight, + viewBoxX, + viewBoxY, + widthRatio, + cursorX, + cursorY, + fill, + radius, + } = this.props; + + //Adjust the x,y cursor position according to zoom + let cx = (cursorX * viewBoxWidth) + viewBoxX; + let cy = (cursorY * viewBoxHeight) + viewBoxY; + + //Adjust the radius of the cursor according to zoom + let finalRadius = radius * widthRatio / 100; + + return ( + + ); + } +} + +Cursor.propTypes = propTypes; +Cursor.defaultProps = defaultProps; diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/service.js b/bigbluebutton-html5/imports/ui/components/whiteboard/service.js index e0a2fc09e9..636ac9926b 100755 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/service.js +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/service.js @@ -1,10 +1,12 @@ import Presentations from '/imports/api/presentations'; import Shapes from '/imports/api/shapes'; import Slides from '/imports/api/slides'; +import Cursor from '/imports/api/cursor'; let getWhiteboardData = () => { let currentSlide; let shapes; + let cursor; let currentPresentation = Presentations.findOne({ 'presentation.current': true, }); @@ -20,11 +22,16 @@ let getWhiteboardData = () => { shapes = Shapes.find({ whiteboardId: currentSlide.slide.id, }).fetch(); + + cursor = Cursor.find({ + meetingId: currentSlide.meetingId, + }).fetch(); } return { currentSlide: currentSlide, shapes: shapes, + cursor: cursor, }; }; From f1d79376ee85088e57a3cb2aa4c19f58c87b394d Mon Sep 17 00:00:00 2001 From: Lajellu Date: Mon, 18 Jul 2016 08:30:04 -0700 Subject: [PATCH 2/2] Fixes Cursor propTypes --- .../components/whiteboard/cursor/component.jsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx b/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx index bd65605e15..7dff0c75f5 100755 --- a/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/whiteboard/cursor/component.jsx @@ -2,12 +2,26 @@ import React, { Component, PropTypes } from 'react'; import WhiteboardService from '/imports/ui/components/whiteboard/service.js'; const propTypes = { + //Width of the view box + viewBoxWidth: PropTypes.number.isRequired, + + //Height of the view box + viewBoxHeight: PropTypes.number.isRequired, + + //x Position of the view box + viewBoxX: PropTypes.number.isRequired, + + //y Position of the view box + viewBoxY: PropTypes.number.isRequired, + + //Slide to view box width ratio + widthRatio: PropTypes.number.isRequired, //Defines the cursor x position - cx: PropTypes.number, + cursorX: PropTypes.number.isRequired, //Defines the cursor y position - cy: PropTypes.number, + cursorY: PropTypes.number.isRequired, /** * Defines the cursor fill colour