diff --git a/assets/svgs/LF.png b/assets/svgs/LF.png new file mode 100644 index 0000000..88a0415 Binary files /dev/null and b/assets/svgs/LF.png differ diff --git a/assets/svgs/LH.png b/assets/svgs/LH.png new file mode 100644 index 0000000..8f608b3 Binary files /dev/null and b/assets/svgs/LH.png differ diff --git a/assets/svgs/RF.png b/assets/svgs/RF.png new file mode 100644 index 0000000..f0461bd Binary files /dev/null and b/assets/svgs/RF.png differ diff --git a/assets/svgs/RH.png b/assets/svgs/RH.png new file mode 100644 index 0000000..9a0e3b3 Binary files /dev/null and b/assets/svgs/RH.png differ diff --git a/src/AppState.ts b/src/AppState.ts new file mode 100644 index 0000000..43b6831 --- /dev/null +++ b/src/AppState.ts @@ -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(this); + selectedTool: UITool = "track-unit-type"; + activeTrackUnitType: TrackUnitType = "Normal"; + activeStickingType: TrackUnitStickingType = "lh"; + + constructor() {} + + addSubscriber(subscriber: ISubscriber, subscribeTo: Parameters["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"); + } +} diff --git a/src/ui/Root/Toolbox.css b/src/ui/Root/Toolbox.css new file mode 100644 index 0000000..5e88d38 --- /dev/null +++ b/src/ui/Root/Toolbox.css @@ -0,0 +1,46 @@ +.root-toolbox { + position: relative; +} + +.root-toolbox .main-row { + height: 2.5em; + margin: auto; + display: flex; + background-color: var(--color-ui-neutral-dark); + justify-content: center; + width: 100%; +} + +.root-toolbox .details { + position: absolute; + top: 2.5em; + left: 0; + right: 0; + margin: auto; + width: min-content; + border-radius: 0 0 1em 1em; + padding: 0.5em; + background-color: var(--color-ui-neutral-dark-active); + display: flex; + justify-content: center; +} + +.root-toolbox .track-unit { + margin: 0; + padding: 0; +} + +.root-toolbox .toolbox-button { + padding: 0.5em; + cursor: pointer; + color: black; + background-color: var(--color-ui-neutral-dark); +} +.root-toolbox .toolbox-button:hover { + background-color: var(--color-ui-neutral-dark-hover); +} +.root-toolbox .toolbox-button.active { + background-color: var(--color-ui-neutral-dark-active); +} + + diff --git a/src/ui/Root/ToolboxView.tsx b/src/ui/Root/ToolboxView.tsx new file mode 100644 index 0000000..6284d36 --- /dev/null +++ b/src/ui/Root/ToolboxView.tsx @@ -0,0 +1,75 @@ +import AppState, { AppStateEvent } from "@/AppState"; +import { TrackUnitStickingTypeList, TrackUnitTypeList } from "@/TrackUnit"; +import { Capsule, h, frag, Rung, RungOptions, ISubscriber } from "@djledda/ladder"; +import TrackUnitView, { StickingTypeIconMap } from "../TrackUnit/TrackUnitView"; +import IconView from "../Widgets/Icon/IconView"; +import "./Toolbox.css"; + +type ToolboxOptions = RungOptions & { + state: AppState, +}; + +export default class ToolboxView extends Rung implements ISubscriber { + private state: AppState; + + constructor(options: ToolboxOptions) { + super(options); + this.state = options.state; + this.state.addSubscriber(this, 'appstate-tool-select'); + } + + notify(publisher: unknown, event: AppStateEvent): void { + if (event === 'appstate-tool-select') { + this.redraw(); + } + } + + private SubMenuButtons = () => { + switch (this.state.selectedTool) { + case "track-unit-type": + return
{...TrackUnitTypeList.map(type => ( + + ))}
; + case "sticking": + return
{...TrackUnitStickingTypeList.reduce((prev, stickingType) => { + if (stickingType !== "none") { + prev.push( as HTMLButtonElement); + } + return prev; + }, [] as HTMLElement[])}
; + case "eraser": + return <>; + } + } + + protected build() { + return
+
+
this.state.selectTool("track-unit-type")}> + Track Type +
+
this.state.selectTool("sticking")}> + Sticking +
+
this.state.selectTool("eraser")}> + Eraser +
+
+ +
as HTMLDivElement; + } +}