fix: added untracked files:
This commit is contained in:
37
src/AppState.ts
Normal file
37
src/AppState.ts
Normal 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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user