38 lines
678 B
JavaScript
38 lines
678 B
JavaScript
import {
|
|
TOOLBAR_CLASSNAME,
|
|
} from './config.js';
|
|
|
|
export class Toolbar {
|
|
sim = undefined;
|
|
tools = [];
|
|
|
|
constructor(sim) {
|
|
this.sim = sim;
|
|
|
|
// Create ourselves a div, as child of sim's div
|
|
const div = document.createElement('div');
|
|
this.div = div;
|
|
this.sim.div.appendChild(div);
|
|
div.classList.add(TOOLBAR_CLASSNAME);
|
|
}
|
|
|
|
topRight() {
|
|
this.div.style.top = '0px';
|
|
this.div.style.right = '0px';
|
|
return this;
|
|
}
|
|
|
|
// tool: instance of Tool
|
|
addTool(tool) {
|
|
this.div.appendChild(tool.div);
|
|
this.tools.push(tool);
|
|
}
|
|
|
|
frame() {
|
|
for (let tool in this.tools) {
|
|
// TODO: tool.frame()
|
|
tool.frame();
|
|
}
|
|
}
|
|
}
|