fix: added untracked files:

This commit is contained in:
Daniel Ledda
2023-01-04 12:56:05 +01:00
parent 3908fbe6d1
commit f5a6ad745e
7 changed files with 158 additions and 0 deletions

37
src/AppState.ts Normal file
View File

@@ -0,0 +1,37 @@
import { ISubscriber, Publisher } from "@djledda/ladder";
import { TrackUnitStickingType, TrackUnitType } from "./TrackUnit";
export type UITool =
| "track-unit-type"
| "eraser"
| "sticking";
export type AppStateEvent = "appstate-tool-select";
export default class AppState {
private publisher = new Publisher<AppStateEvent, AppState>(this);
selectedTool: UITool = "track-unit-type";
activeTrackUnitType: TrackUnitType = "Normal";
activeStickingType: TrackUnitStickingType = "lh";
constructor() {}
addSubscriber(subscriber: ISubscriber<AppStateEvent>, subscribeTo: Parameters<Publisher<AppStateEvent, AppState>["addSubscriber"]>[1]) {
this.publisher.addSubscriber(subscriber, subscribeTo);
}
selectStickingTypePaint(stickingType: TrackUnitStickingType) {
this.activeStickingType = stickingType;
this.publisher.notifySubs("appstate-tool-select");
}
selectTrackUnitTypePaint(trackUnitType: TrackUnitType) {
this.activeTrackUnitType = trackUnitType;
this.publisher.notifySubs("appstate-tool-select");
}
selectTool(tool: UITool) {
this.selectedTool = tool;
this.publisher.notifySubs("appstate-tool-select");
}
}