2017-06-08 05:25:47 +08:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-04-19 08:54:51 +08:00
|
|
|
import styles from './styles.scss';
|
|
|
|
import Button from '/imports/ui/components/button/component';
|
|
|
|
import cx from 'classnames';
|
2017-06-03 08:41:39 +08:00
|
|
|
import { findDOMNode } from 'react-dom';
|
2017-02-23 08:10:30 +08:00
|
|
|
|
2017-04-19 08:54:51 +08:00
|
|
|
export default class WhiteboardToolbar extends Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2017-05-03 08:05:41 +08:00
|
|
|
//a variable to control which list is currently open
|
2017-04-19 08:54:51 +08:00
|
|
|
currentSubmenuOpen: '',
|
2017-05-03 08:05:41 +08:00
|
|
|
|
|
|
|
//variables to keep current selected draw settings
|
|
|
|
annotationSelected: {
|
|
|
|
icon: 'hand',
|
|
|
|
sessionValue: 'Hand',
|
|
|
|
},
|
2017-05-04 22:33:16 +08:00
|
|
|
thicknessSelected: {
|
|
|
|
iconRadius: 6,
|
|
|
|
sessionRadius: 6,
|
|
|
|
},
|
2017-04-19 08:54:51 +08:00
|
|
|
colorSelected: '#000000',
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizeSelected: 18,
|
2017-05-03 08:05:41 +08:00
|
|
|
|
2017-06-03 08:41:39 +08:00
|
|
|
//keeping the previous color and the thickness icon's radius selected for svg animation
|
|
|
|
prevColorSelected: '#000000',
|
|
|
|
prevIconRadius: 6,
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//lists of tools/thickness/colors are not direct children of main toolbar buttons
|
|
|
|
//and we want the list to close when onBlur fires at the main toolbar button
|
|
|
|
//(click anywhere on the screen) thus we have to control the blur manually by disabling it
|
|
|
|
//when you hover over the buttons in the list and enabling when the mouse leaves the list
|
2017-04-19 08:54:51 +08:00
|
|
|
onBlurEnabled: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
this.displaySubMenu = this.displaySubMenu.bind(this);
|
|
|
|
this.closeSubMenu = this.closeSubMenu.bind(this);
|
|
|
|
this.handleUndo = this.handleUndo.bind(this);
|
2017-04-22 02:01:52 +08:00
|
|
|
this.handleClearAll = this.handleClearAll.bind(this);
|
2017-04-19 08:54:51 +08:00
|
|
|
this.handleAnnotationChange = this.handleAnnotationChange.bind(this);
|
|
|
|
this.handleThicknessChange = this.handleThicknessChange.bind(this);
|
2017-06-03 07:46:02 +08:00
|
|
|
this.handleFontSizeChange = this.handleFontSizeChange.bind(this);
|
2017-04-19 08:54:51 +08:00
|
|
|
this.handleColorChange = this.handleColorChange.bind(this);
|
|
|
|
this.disableOnBlur = this.disableOnBlur.bind(this);
|
|
|
|
this.enableOnBlur = this.enableOnBlur.bind(this);
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
componentWillMount() {
|
|
|
|
|
|
|
|
//setting default or resetting current drawing settings in the session
|
2017-06-03 07:46:02 +08:00
|
|
|
const { annotationSelected, thicknessSelected, colorSelected, fontSizeSelected } = this.state;
|
2017-05-04 22:33:16 +08:00
|
|
|
this.props.setWhiteboardToolbarValues(
|
|
|
|
annotationSelected.sessionValue,
|
|
|
|
thicknessSelected.sessionRadius,
|
|
|
|
this.HEXToINTColor(colorSelected),
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizeSelected,
|
2017-05-04 22:33:16 +08:00
|
|
|
);
|
2017-05-03 08:05:41 +08:00
|
|
|
}
|
|
|
|
|
2017-04-19 08:54:51 +08:00
|
|
|
componentDidMount() {
|
|
|
|
//to let the whiteboard know that the presentation area's size has changed
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
2017-06-07 07:47:31 +08:00
|
|
|
|
|
|
|
if(this.state.annotationSelected.sessionValue != "Text") {
|
|
|
|
//trigger initial animation on the thickness circle, otherwise it stays at 0
|
|
|
|
var node = findDOMNode(this.thicknessListIconRadius);
|
|
|
|
node.beginElement();
|
|
|
|
}
|
2017-04-19 08:54:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
//to let the whiteboard know that the presentation area's size has changed
|
|
|
|
window.dispatchEvent(new Event('resize'));
|
|
|
|
}
|
|
|
|
|
2017-06-03 08:41:39 +08:00
|
|
|
componentDidUpdate(prevProps, prevState) {
|
2017-06-08 05:40:15 +08:00
|
|
|
// if color or thickness were changed
|
|
|
|
// we might need to trigger svg animation for Color and Thickness icons
|
|
|
|
this.animateSvgIcons(prevState);
|
|
|
|
}
|
|
|
|
|
|
|
|
animateSvgIcons(prevState) {
|
|
|
|
// if Text tool is selected - we only need to update the Color icon with the new color
|
|
|
|
if(this.state.annotationSelected.sessionValue == "Text") {
|
|
|
|
if(this.state.colorSelected != prevState.colorSelected) {
|
|
|
|
const node = findDOMNode(this.colorListIconColor);
|
|
|
|
node.beginElement();
|
|
|
|
}
|
|
|
|
// if any other tool except Text is selected - we might potentially update:
|
|
|
|
// 1) Color icon with the new color; 2) Thickness icon with the new radius and color
|
|
|
|
} else {
|
|
|
|
if(this.state.colorSelected != prevState.colorSelected) {
|
|
|
|
const node = findDOMNode(this.colorListIconColor);
|
|
|
|
const node2 = findDOMNode(this.thicknessListIconColor);
|
|
|
|
node.beginElement();
|
|
|
|
node2.beginElement();
|
|
|
|
} else if(this.state.thicknessSelected.iconRadius != prevState.thicknessSelected.iconRadius) {
|
|
|
|
const node = findDOMNode(this.thicknessListIconRadius);
|
|
|
|
node.beginElement();
|
|
|
|
}
|
2017-06-03 08:41:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//open a submenu
|
2017-04-19 08:54:51 +08:00
|
|
|
displaySubMenu(listName) {
|
|
|
|
this.setState({
|
|
|
|
currentSubmenuOpen: this.state.currentSubmenuOpen == listName ? '' : listName,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//close a current submenu (fires onBlur only, when you click anywhere on the screen)
|
2017-04-19 08:54:51 +08:00
|
|
|
closeSubMenu() {
|
|
|
|
if(this.state.onBlurEnabled) {
|
|
|
|
this.setState({
|
|
|
|
currentSubmenuOpen: undefined,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//undo annotation
|
2017-04-19 08:54:51 +08:00
|
|
|
handleUndo() {
|
2017-05-11 02:59:17 +08:00
|
|
|
this.props.undoAnnotation(this.props.whiteboardId);
|
2017-04-19 08:54:51 +08:00
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//clear all annotations
|
2017-04-22 02:01:52 +08:00
|
|
|
handleClearAll() {
|
2017-05-11 02:59:17 +08:00
|
|
|
this.props.clearWhiteboard(this.props.whiteboardId);
|
2017-04-19 08:54:51 +08:00
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//changes a current selected annotation both in the state and in the session
|
|
|
|
//and closes the annotation list
|
2017-04-19 08:54:51 +08:00
|
|
|
handleAnnotationChange(annotation) {
|
2017-06-03 07:46:02 +08:00
|
|
|
const { thicknessSelected, colorSelected, fontSizeSelected } = this.state;
|
2017-05-04 22:33:16 +08:00
|
|
|
this.props.setWhiteboardToolbarValues(
|
|
|
|
annotation.sessionValue,
|
|
|
|
thicknessSelected.sessionRadius,
|
|
|
|
this.HEXToINTColor(colorSelected),
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizeSelected,
|
2017-05-04 22:33:16 +08:00
|
|
|
);
|
2017-05-03 08:05:41 +08:00
|
|
|
|
2017-04-19 08:54:51 +08:00
|
|
|
this.setState({
|
|
|
|
annotationSelected: annotation,
|
|
|
|
onBlurEnabled: true,
|
|
|
|
currentSubmenuOpen: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//changes a current selected thickness both in the state and in the session
|
|
|
|
//and closes the thickness list
|
2017-05-04 22:33:16 +08:00
|
|
|
handleThicknessChange(thicknessObj) {
|
2017-06-03 07:46:02 +08:00
|
|
|
const { annotationSelected, colorSelected, fontSizeSelected } = this.state;
|
2017-05-04 22:33:16 +08:00
|
|
|
this.props.setWhiteboardToolbarValues(
|
|
|
|
annotationSelected.sessionValue,
|
|
|
|
thicknessObj.sessionRadius,
|
|
|
|
this.HEXToINTColor(colorSelected),
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizeSelected,
|
2017-05-04 22:33:16 +08:00
|
|
|
);
|
2017-05-03 08:05:41 +08:00
|
|
|
|
2017-04-19 08:54:51 +08:00
|
|
|
this.setState({
|
2017-06-03 08:41:39 +08:00
|
|
|
prevIconRadius: this.state.thicknessSelected.iconRadius,
|
2017-05-04 22:33:16 +08:00
|
|
|
thicknessSelected: thicknessObj,
|
2017-04-19 08:54:51 +08:00
|
|
|
onBlurEnabled: true,
|
|
|
|
currentSubmenuOpen: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-03 07:46:02 +08:00
|
|
|
handleFontSizeChange(fontSizeObj) {
|
|
|
|
const { annotationSelected, colorSelected, thicknessSelected } = this.state;
|
|
|
|
|
|
|
|
this.props.setWhiteboardToolbarValues(
|
|
|
|
annotationSelected.sessionValue,
|
|
|
|
thicknessSelected.sessionRadius,
|
|
|
|
this.HEXToINTColor(colorSelected),
|
|
|
|
fontSizeObj.fontSize,
|
|
|
|
);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
fontSizeSelected: fontSizeObj.fontSize,
|
|
|
|
onBlurEnabled: true,
|
|
|
|
currentSubmenuOpen: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//changes a current selected color both in the state and in the session
|
|
|
|
//and closes the color list
|
2017-04-19 08:54:51 +08:00
|
|
|
handleColorChange(color) {
|
2017-06-03 07:46:02 +08:00
|
|
|
const { annotationSelected, thicknessSelected, fontSizeSelected } = this.state;
|
2017-05-04 22:33:16 +08:00
|
|
|
this.props.setWhiteboardToolbarValues(
|
|
|
|
annotationSelected.sessionValue,
|
|
|
|
thicknessSelected.sessionRadius,
|
|
|
|
this.HEXToINTColor(color),
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizeSelected
|
2017-05-04 22:33:16 +08:00
|
|
|
);
|
2017-04-19 08:54:51 +08:00
|
|
|
this.setState({
|
2017-06-03 08:41:39 +08:00
|
|
|
prevColorSelected: this.state.colorSelected,
|
2017-04-19 08:54:51 +08:00
|
|
|
colorSelected: color,
|
|
|
|
onBlurEnabled: true,
|
|
|
|
currentSubmenuOpen: '',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-04 22:33:16 +08:00
|
|
|
HEXToINTColor(hexColor) {
|
|
|
|
var _rrggbb = hexColor.slice(1);
|
|
|
|
var rrggbb = _rrggbb.substr(0, 2) + _rrggbb.substr(2, 2) + _rrggbb.substr(4, 2);
|
|
|
|
return parseInt(rrggbb, 16);
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//disabling onBlur flag when mouse is over the items in the lists
|
2017-04-19 08:54:51 +08:00
|
|
|
disableOnBlur() {
|
|
|
|
this.setState({
|
|
|
|
onBlurEnabled: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-03 08:05:41 +08:00
|
|
|
//enabling the onBlur flag when the mouse leaving the lists
|
2017-04-19 08:54:51 +08:00
|
|
|
enableOnBlur() {
|
|
|
|
this.setState({
|
|
|
|
onBlurEnabled: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
renderAnnotationList() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={cx(styles.annotationList, styles.toolbarList)}>
|
2017-05-03 08:05:41 +08:00
|
|
|
{ this.props.annotations? this.props.annotations.map((annotation, index) =>
|
2017-04-19 08:54:51 +08:00
|
|
|
<Button
|
|
|
|
label="Annotation"
|
|
|
|
hideLabel={true}
|
|
|
|
color={'default'}
|
2017-05-03 08:05:41 +08:00
|
|
|
icon={annotation.icon}
|
2017-04-19 08:54:51 +08:00
|
|
|
size={'md'}
|
2017-05-04 22:33:16 +08:00
|
|
|
className={cx(styles.toolbarListButton, this.state.annotationSelected.sessionValue == annotation.sessionRadius ? styles.selectedListButton : '')}
|
2017-04-19 08:54:51 +08:00
|
|
|
onClick={this.handleAnnotationChange.bind(null, annotation)}
|
|
|
|
onMouseEnter={this.disableOnBlur}
|
|
|
|
onMouseLeave={this.enableOnBlur}
|
2017-05-03 08:05:41 +08:00
|
|
|
key={index}
|
2017-04-19 08:54:51 +08:00
|
|
|
role="button"
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-06-03 07:46:02 +08:00
|
|
|
renderFontSizeList() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={cx(styles.fontSizeList, styles.toolbarList)}>
|
|
|
|
{this.props.fontSizes ? this.props.fontSizes.map((fontSizeObj, index) =>
|
|
|
|
<Button
|
|
|
|
hideLabel={true}
|
|
|
|
label="Radius"
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
|
|
|
className={cx(styles.toolbarListButton, styles.fontSizeListButton, this.state.fontSizeSelected == fontSizeObj.fontSize ? styles.selectedListButton : '')}
|
|
|
|
onClick={this.handleFontSizeChange.bind(null, fontSizeObj)}
|
|
|
|
onMouseEnter={this.disableOnBlur}
|
|
|
|
onMouseLeave={this.enableOnBlur}
|
|
|
|
key={index}
|
|
|
|
customIcon={
|
|
|
|
<p className={styles.textThickness} style={{fontSize: fontSizeObj.fontSize}}>
|
|
|
|
Aa
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
</Button>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-19 08:54:51 +08:00
|
|
|
renderThicknessList() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={cx(styles.thicknessList, styles.toolbarList)}>
|
2017-05-04 22:33:16 +08:00
|
|
|
{this.props.thicknessRadiuses ? this.props.thicknessRadiuses.map((thicknessObj, index) =>
|
2017-04-19 08:54:51 +08:00
|
|
|
<Button
|
|
|
|
label="Radius"
|
|
|
|
hideLabel={true}
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
2017-05-04 22:33:16 +08:00
|
|
|
className={cx(styles.toolbarListButton, this.state.thicknessSelected.sessionRadius == thicknessObj.sessionRadius ? styles.selectedListButton : '')}
|
|
|
|
onClick={this.handleThicknessChange.bind(null, thicknessObj)}
|
2017-04-19 08:54:51 +08:00
|
|
|
onMouseEnter={this.disableOnBlur}
|
|
|
|
onMouseLeave={this.enableOnBlur}
|
2017-06-03 07:46:02 +08:00
|
|
|
customIcon={
|
2017-04-19 08:54:51 +08:00
|
|
|
<svg className={styles.customSvgIcon}>
|
2017-05-04 22:33:16 +08:00
|
|
|
<circle cx="50%" cy="50%" r={thicknessObj.iconRadius} fill="#F3F6F9"/>
|
2017-04-19 08:54:51 +08:00
|
|
|
</svg>
|
|
|
|
}
|
2017-05-04 22:33:16 +08:00
|
|
|
key={index}
|
2017-04-19 08:54:51 +08:00
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
renderColorList() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={cx(styles.colorList, styles.toolbarList)}>
|
|
|
|
{this.props.colors ? this.props.colors.map((color) =>
|
|
|
|
<Button
|
|
|
|
label="Color"
|
|
|
|
hideLabel={true}
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
|
|
|
className={cx(styles.toolbarListButton, this.state.colorSelected == color ? styles.selectedListButton : '')}
|
|
|
|
onClick={this.handleColorChange.bind(null, color)}
|
|
|
|
onMouseEnter={this.disableOnBlur}
|
|
|
|
onMouseLeave={this.enableOnBlur}
|
2017-06-03 07:46:02 +08:00
|
|
|
customIcon={
|
2017-04-19 08:54:51 +08:00
|
|
|
<svg className={styles.customSvgIcon}>
|
|
|
|
<rect x="20%" y="20%" width="60%" height="60%" fill={color}/>
|
|
|
|
</svg>
|
|
|
|
}
|
|
|
|
key={color}
|
|
|
|
role="button"
|
|
|
|
aria-labelledby={`${color}Label`}
|
|
|
|
aria-describedby={`${color}Descrip`}
|
|
|
|
/>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.toolbarContainer} style={{height: this.props.height}}>
|
|
|
|
<div className={styles.toolbarWrapper}>
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Tools"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
2017-05-03 08:05:41 +08:00
|
|
|
icon={this.state.annotationSelected.icon}
|
2017-04-19 08:54:51 +08:00
|
|
|
size={'md'}
|
|
|
|
onClick={this.displaySubMenu.bind(null, "annotationList")}
|
|
|
|
onBlur={this.closeSubMenu}
|
2017-05-03 08:05:41 +08:00
|
|
|
className={cx(styles.toolbarButton, this.state.currentSubmenuOpen == "annotationList" ? '' : styles.notActive)}
|
2017-04-19 08:54:51 +08:00
|
|
|
/>
|
|
|
|
{this.state.currentSubmenuOpen == "annotationList" ?
|
|
|
|
this.renderAnnotationList()
|
|
|
|
: null }
|
|
|
|
</div>
|
2017-06-03 07:46:02 +08:00
|
|
|
|
|
|
|
{this.state.annotationSelected.sessionValue == "Text" ?
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Thickness List"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
|
|
|
onClick={this.displaySubMenu.bind(null, "fontSizeList")}
|
|
|
|
onBlur={this.closeSubMenu}
|
|
|
|
className={cx(styles.toolbarButton, this.state.currentSubmenuOpen == "fontSizeList" ? '' : styles.notActive)}
|
|
|
|
customIcon={
|
|
|
|
<p className={styles.textThickness} style={{fontSize: this.state.fontSizeSelected, color: this.state.colorSelected}}>
|
|
|
|
Aa
|
|
|
|
</p>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{this.state.currentSubmenuOpen == "fontSizeList" ?
|
|
|
|
this.renderFontSizeList()
|
|
|
|
: null }
|
|
|
|
</div>
|
|
|
|
:
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Thickness List"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
|
|
|
onClick={this.displaySubMenu.bind(null, "thicknessList")}
|
|
|
|
onBlur={this.closeSubMenu}
|
|
|
|
className={cx(styles.toolbarButton, this.state.currentSubmenuOpen == "thicknessList" ? '' : styles.notActive)}
|
|
|
|
customIcon={
|
|
|
|
<svg className={styles.customSvgIcon} shapeRendering="geometricPrecision">
|
2017-06-03 08:41:39 +08:00
|
|
|
<circle
|
|
|
|
shapeRendering="geometricPrecision"
|
|
|
|
cx="50%"
|
|
|
|
cy="50%"
|
|
|
|
stroke="black"
|
|
|
|
strokeWidth="1"
|
|
|
|
>
|
|
|
|
<animate
|
2017-06-07 07:47:31 +08:00
|
|
|
ref={(ref) => { this.thicknessListIconColor = ref; }}
|
2017-06-03 08:41:39 +08:00
|
|
|
attributeName="fill"
|
|
|
|
attributeType="XML"
|
|
|
|
from={this.state.prevColorSelected}
|
|
|
|
to={this.state.colorSelected}
|
|
|
|
begin={'indefinite'}
|
|
|
|
dur="0.4s"
|
|
|
|
repeatCount="0"
|
|
|
|
fill="freeze"
|
|
|
|
/>
|
|
|
|
<animate
|
2017-06-07 07:47:31 +08:00
|
|
|
ref={(ref) => { this.thicknessListIconRadius = ref; }}
|
2017-06-03 08:41:39 +08:00
|
|
|
attributeName="r"
|
|
|
|
attributeType="XML"
|
|
|
|
from={this.state.prevIconRadius}
|
|
|
|
to={this.state.thicknessSelected.iconRadius}
|
|
|
|
begin={'indefinite'}
|
|
|
|
dur="0.4s"
|
|
|
|
repeatCount="0"
|
|
|
|
fill="freeze"
|
|
|
|
/>
|
|
|
|
</circle>
|
2017-06-03 07:46:02 +08:00
|
|
|
</svg>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{this.state.currentSubmenuOpen == "thicknessList" ?
|
|
|
|
this.renderThicknessList()
|
|
|
|
: null }
|
|
|
|
</div>
|
|
|
|
}
|
2017-04-19 08:54:51 +08:00
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Color List"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
|
|
|
size={'md'}
|
|
|
|
onClick={this.displaySubMenu.bind(null, "colorList")}
|
|
|
|
onBlur={this.closeSubMenu}
|
2017-05-03 08:05:41 +08:00
|
|
|
className={cx(styles.toolbarButton, this.state.currentSubmenuOpen == "colorList" ? '' : styles.notActive)}
|
2017-06-03 07:46:02 +08:00
|
|
|
customIcon={
|
2017-04-19 08:54:51 +08:00
|
|
|
<svg className={styles.customSvgIcon}>
|
2017-06-03 08:41:39 +08:00
|
|
|
<rect x="25%" y="25%" width="50%" height="50%" stroke="black" strokeWidth="1">
|
|
|
|
<animate
|
2017-06-07 07:47:31 +08:00
|
|
|
ref={(ref) => { this.colorListIconColor = ref; }}
|
2017-06-03 08:41:39 +08:00
|
|
|
attributeName="fill"
|
|
|
|
attributeType="XML"
|
|
|
|
from={this.state.prevColorSelected}
|
|
|
|
to={this.state.colorSelected}
|
|
|
|
begin={'indefinite'}
|
|
|
|
dur="0.4s"
|
|
|
|
repeatCount="0"
|
|
|
|
fill="freeze"
|
|
|
|
/>
|
|
|
|
</rect>
|
2017-04-19 08:54:51 +08:00
|
|
|
</svg>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
{this.state.currentSubmenuOpen == "colorList" ?
|
|
|
|
this.renderColorList()
|
|
|
|
: null }
|
|
|
|
</div>
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Undo Annotation"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
|
|
|
icon={'undo'}
|
|
|
|
size={'md'}
|
|
|
|
onClick={this.handleUndo}
|
|
|
|
className={cx(styles.toolbarButton, styles.notActive)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className={styles.buttonWrapper}>
|
|
|
|
<Button
|
|
|
|
label="Clear All Annotations"
|
|
|
|
hideLabel={true}
|
|
|
|
role="button"
|
|
|
|
color={'default'}
|
|
|
|
icon={'circle_close'}
|
|
|
|
size={'md'}
|
2017-04-22 02:01:52 +08:00
|
|
|
onClick={this.handleClearAll}
|
2017-04-19 08:54:51 +08:00
|
|
|
className={cx(styles.toolbarButton, styles.notActive)}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
colors: [
|
|
|
|
'#000000', '#FFFFFF', '#FF0000', '#FF8800', '#CCFF00','#00FF00',
|
|
|
|
'#00FFFF', '#0088FF', '#0000FF', '#8800FF', '#FF00FF', '#C0C0C0'
|
|
|
|
],
|
2017-05-04 22:33:16 +08:00
|
|
|
thicknessRadiuses: [
|
|
|
|
{iconRadius: 14, sessionRadius: 30},
|
|
|
|
{iconRadius: 12, sessionRadius: 22},
|
|
|
|
{iconRadius: 10, sessionRadius: 15},
|
|
|
|
{iconRadius: 8, sessionRadius: 10},
|
|
|
|
{iconRadius: 6, sessionRadius:6},
|
|
|
|
{iconRadius: 4, sessionRadius: 3},
|
|
|
|
{iconRadius: 2, sessionRadius: 1}
|
|
|
|
],
|
2017-05-03 08:05:41 +08:00
|
|
|
annotations: [
|
|
|
|
{icon: 'text_tool', sessionValue: "Text"},
|
|
|
|
{icon: 'linte_tool', sessionValue:"Line"},
|
|
|
|
{icon: 'circle_tool', sessionValue: "Ellipse"},
|
|
|
|
{icon: 'triangle_tool', sessionValue: "Triangle"},
|
|
|
|
{icon: 'rectangle_tool', sessionValue: "Rectangle"},
|
|
|
|
{icon: 'pen_tool', sessionValue: "Pencil"},
|
|
|
|
{icon: 'hand', sessionValue: "Hand"}
|
|
|
|
],
|
2017-06-03 07:46:02 +08:00
|
|
|
fontSizes: [
|
|
|
|
{fontSize: 30},
|
|
|
|
{fontSize: 24},
|
|
|
|
{fontSize: 20},
|
|
|
|
{fontSize: 18},
|
|
|
|
{fontSize: 16},
|
|
|
|
{fontSize: 14},
|
|
|
|
{fontSize: 12},
|
|
|
|
],
|
2017-04-19 08:54:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
WhiteboardToolbar.defaultProps = defaultProps;
|