This commit is contained in:
tengge1 2019-06-04 21:20:13 +08:00
parent 5d86d38f52
commit d7dc100dee
2 changed files with 72 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import Toolbar from '../toolbar/Toolbar.jsx';
import Button from '../form/Button.jsx';
import Icon from '../form/IconButton.jsx';
import ToolbarSeparator from '../toolbar/ToolbarSeparator.jsx';
import Timeline from '../timeline/Timeline.jsx';
/**
* 工作区
@ -77,7 +78,9 @@ class EWorkspace extends React.Component {
<Button color={'danger'}>Button 5</Button>
</Toolbar>
</Panel>
<Panel title={'South'} region={'south'} split={true} style={{ height: '120px', border: 'none' }}></Panel>
<Panel title={'South'} region={'south'} split={true} style={{ height: '120px', border: 'none' }}>
<Timeline></Timeline>
</Panel>
<Panel title={'West'} region={'west'} split={true} style={{ width: '200px', border: 'none' }}>
<Toolbar direction={'vertical'}>
<Icon icon={'select'}></Icon>

View File

@ -7,10 +7,77 @@ import PropTypes from 'prop-types';
* @author tengge / https://github.com/tengge1
*/
class Timeline extends React.Component {
constructor(props) {
super(props);
}
render() {
const { className, style } = this.props;
return <div className={classNames('Timeline', className)} style={style}></div>;
return <div className={classNames('Timeline', className)} style={style}>
<canvas></canvas>
</div>;
}
componentDidMount() {
return;
var duration = this.duration; //
var scale = this.scale; // 1
var width = duration * scale; //
var scale5 = scale / 5; // 0.2
var margin = 0; //
this.dom.style.width = (width + margin * 2) + 'px';
this.dom.width = this.dom.clientWidth;
var context = this.dom.getContext('2d');
//
context.fillStyle = '#eee';
context.fillRect(0, 0, this.dom.width, this.dom.height);
//
context.strokeStyle = '#555';
context.beginPath();
for (var i = margin; i <= width + margin; i += scale) { //
for (var j = 0; j < 5; j++) { //
if (j === 0) { //
context.moveTo(i + scale5 * j, 22);
context.lineTo(i + scale5 * j, 30);
} else { //
context.moveTo(i + scale5 * j, 26);
context.lineTo(i + scale5 * j, 30);
}
}
}
context.stroke();
//
context.font = '12px Arial';
context.fillStyle = '#888'
for (var i = 0; i <= duration; i += 2) { //
var minute = Math.floor(i / 60);
var second = Math.floor(i % 60);
var text = (minute > 0 ? minute + ':' : '') + ('0' + second).slice(-2);
if (i === 0) {
context.textAlign = 'left';
} else if (i === duration) {
context.textAlign = 'right';
} else {
context.textAlign = 'center';
}
context.fillText(text, margin + i * scale, 16);
}
}
componentWillUnmount() {
}
}