-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made it possible to click through node operations
Done by making a new OperationButtonPanel component. Can now also change node and edge color. Issue: #78
- Loading branch information
1 parent
4ad71fa
commit c335901
Showing
4 changed files
with
107 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import Core from "../../Core"; | ||
import Button from "../Button"; | ||
import { GuiComponent } from "../interfaces"; | ||
|
||
class OperationButtonPanel implements GuiComponent { | ||
htmlElement: HTMLElement; | ||
counter: number; | ||
operationList: (() => void)[]; | ||
reverseOperationList: (() => void)[]; | ||
backButton: Button; | ||
fourthButton: Button; | ||
|
||
constructor(operationList: (() => void)[], reverseOperationList: (() => void)[]) { | ||
const panelWrapper = document.createElement("div"); | ||
panelWrapper.className = "panel-wrapper"; | ||
this.htmlElement = panelWrapper; | ||
|
||
this.counter = 0; | ||
this.operationList = operationList; | ||
this.reverseOperationList = reverseOperationList; | ||
this.backButton = new Button({label: "<"}); | ||
this.backButton.addObserver(() => this.executePreviousOperation()); | ||
this.backButton.htmlElement | ||
this.fourthButton = new Button({label: ">"}); | ||
this.fourthButton.addObserver(() => this.executeNextOperation()); | ||
|
||
this.htmlElement.appendChild(this.backButton.htmlElement ); | ||
this.htmlElement.appendChild(this.fourthButton.htmlElement); | ||
|
||
/* core.addGui(this.backButton); | ||
core.addGui(this.fourthButton); */ | ||
} | ||
|
||
executeNextOperation(): void { | ||
if (this.counter < this.operationList.length) { | ||
const nextOperation = this.operationList[this.counter]; | ||
nextOperation(); | ||
this.counter++; | ||
} else { | ||
console.log("No more operations to perform"); | ||
} | ||
} | ||
|
||
executePreviousOperation(): void { | ||
if (this.counter > 0) { | ||
this.counter--; | ||
const prevOperation = this.reverseOperationList[this.counter]; | ||
prevOperation(); | ||
} else { | ||
console.log("No earlier operations to perform"); | ||
} | ||
} | ||
} | ||
|
||
export default OperationButtonPanel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters