Skip to content
Snippets Groups Projects
Commit 63589575 authored by Maximilian Giller's avatar Maximilian Giller
Browse files

Intial changes for menu implementation

parent 0d3e0883
No related branches found
No related tags found
No related merge requests found
......@@ -13,3 +13,7 @@ div#ks-editor section > * {
div#ks-editor *.selected {
background-color: lightblue;
}
div#ks-editor *.hidden {
display: none;
}
......@@ -2,6 +2,7 @@
<h1>Interface</h1>
<div id="2d-graph"></div>
<section id="toolbar"></section>
<section id="tool-menu" class="hidden"></section>
<section>
<h3 id="selected-item">Nothing selected</h3>
<ul id="selected-params"></ul>
......
......@@ -49,7 +49,7 @@ export class State extends Tool {
}
if (this.tool !== undefined) {
this.tool.onToolDeactivate(tool);
this.tool.deactivateTool(tool);
}
this.previousTool = this.tool;
......@@ -57,7 +57,7 @@ export class State extends Tool {
this.display.setSelectedTool(tool);
if (this.tool !== undefined) {
this.tool.onToolActivate();
this.tool.activateTool();
}
}
......
import jQuery from "jquery";
export default class ToolMenu {
constructor(tool) {
this.tool = tool;
this.menuId = this.tool.getKey() + "-menu";
}
show() {
jQuery("#" + this.menuId).removeClass("hidden");
}
hide() {
jQuery("#" + this.menuId).addClass("hidden");
}
}
......@@ -4,6 +4,7 @@ export default class Tool {
this.icon = icon;
this.key = key;
this.warnings = false;
this.menu = undefined;
}
getName() {
......@@ -18,18 +19,28 @@ export default class Tool {
return this.icon;
}
onToolActivate() {
if (this.warnings) {
console.warn('Method "onToolActivate" not implemented.');
activateTool() {
if (this.menu !== undefined) {
this.menu.show();
}
this.onToolActivate();
}
onToolDeactivate(nextTool) {
if (this.warnings) {
console.warn('Method "onToolDeactivate" not implemented.');
deactivateTool(nextTool) {
this.onToolDeactivate(nextTool);
if (this.menu !== undefined) {
this.menu.hide();
}
}
onToolActivate() {
}
onToolDeactivate(nextTool) {
}
onNodeClick(node) {
if (this.warnings) {
console.warn('Method "onNodeClick" not implemented.');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment