From 80fa033a88d7fcee669355fa24b118cf092e80aa Mon Sep 17 00:00:00 2001 From: Daniel Ledda Date: Sat, 1 Jun 2024 18:52:46 +0200 Subject: [PATCH] update --- src/AppState.ts | 7 +-- src/Track.ts | 6 +- src/assets/svgs/delete.svg | 1 + src/ui/Root/Toolbox.vue | 49 +++++++++------- src/ui/Track/Track.vue | 9 ++- src/ui/TrackUnit/TrackUnit.vue | 78 +++---------------------- src/ui/TrackUnitBox/TrackUnitBox.vue | 87 ++++++++++++++++++++++++++++ src/ui/Widgets/Icon/icons.ts | 2 + 8 files changed, 135 insertions(+), 104 deletions(-) create mode 100644 src/assets/svgs/delete.svg create mode 100644 src/ui/TrackUnitBox/TrackUnitBox.vue diff --git a/src/AppState.ts b/src/AppState.ts index d183591..bca7adc 100644 --- a/src/AppState.ts +++ b/src/AppState.ts @@ -3,13 +3,12 @@ import { Bound } from "./utils"; export type UITool = | "track-unit-type" - | "eraser" | "sticking"; -export class AppStateStore extends Bound { +class AppStateStore extends Bound { selectedTool = ref("track-unit-type"); - activeTrackUnitType = ref(0); - activeStickingType = ref(1); + activeTrackUnitType = ref(0); + activeStickingType = ref(1); unitMouseStart = ref(null); selectingUnits = ref(false); deselectingUnits = ref(false); diff --git a/src/Track.ts b/src/Track.ts index 1a5d00b..03f1b16 100644 --- a/src/Track.ts +++ b/src/Track.ts @@ -23,7 +23,7 @@ const TrackSerialSchema = z.object({ units: z.object({ isOn: z.array(z.boolean()), type: z.array(z.number()), - stickingType: z.array(z.number()), + stickingType: z.array(z.number().nullable()), }), barCount: z.number(), loopLength: z.number(), @@ -72,7 +72,7 @@ export function deserialise(serial: unknown, manager: BeatManager) { export type TrackUnit = { on: boolean, type: number, - stickingType: number, + stickingType: number | null, }; export class Track extends EffectScoped { @@ -191,7 +191,7 @@ export class Track extends EffectScoped { }; } - setStickingType(index: number, stickingType: number): void { + setStickingType(index: number, stickingType: number | null): void { const unit = this.getUnitByIndex(index); if (!unit) { return; diff --git a/src/assets/svgs/delete.svg b/src/assets/svgs/delete.svg new file mode 100644 index 0000000..8c6074b --- /dev/null +++ b/src/assets/svgs/delete.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/ui/Root/Toolbox.vue b/src/ui/Root/Toolbox.vue index 8b21958..f427eb4 100644 --- a/src/ui/Root/Toolbox.vue +++ b/src/ui/Root/Toolbox.vue @@ -5,18 +5,21 @@
-
+ :sticking-type="null" :on="true" :type="activeTrackUnitType" /> +
@@ -24,7 +27,7 @@ - - -
@@ -56,7 +58,7 @@ import { StickingTypeIconMap } from "@/ui/TrackUnit/trackUnit"; import Icon from "@/ui/Widgets/Icon/Icon.vue"; import Dropdown from '@/ui/Widgets/Dropdown/Dropdown.vue'; - import { getClasses } from "@/ui/TrackUnit/trackUnit"; + import TrackUnitBox from "@/ui/TrackUnitBox/TrackUnitBox.vue"; const { selectedTool, @@ -86,12 +88,19 @@ padding: 0; } + .track-unit-type { + margin: 5em; + } + .toolbox-button { cursor: pointer; color: black; + &.eraser { + background-color: black; + } + &.paint-button-cont { - padding: 0.25em; background-color: var(--color-ui-bg-dark); &:hover { @@ -111,10 +120,6 @@ } .paint-button { - height: 1.5em; - width: 1.5em; - background-color: black; - &.active { background-color: var(--color-ui-neutral-dark); } diff --git a/src/ui/Track/Track.vue b/src/ui/Track/Track.vue index f605c70..ff1eb13 100644 --- a/src/ui/Track/Track.vue +++ b/src/ui/Track/Track.vue @@ -54,7 +54,9 @@ function toggle(index: number) { if (!track.value) return; - track.value.toggleUnit(index); + if (selectedTool.value === 'track-unit-type') { + track.value.toggleUnit(index); + } if (track.value.getUnitByIndex(index)?.on) { applyCurrentToolToTrackUnit(index); } @@ -75,10 +77,7 @@ track.value?.setStickingType(index, activeStickingType.value); break; case "track-unit-type": - track.value?.updateUnit(index, { on: true, type: activeTrackUnitType.value }); - break; - case "eraser": - track.value?.setUnitOn(index, false); + track.value?.updateUnit(index, { on: activeTrackUnitType.value === null ? false : true, type: activeTrackUnitType.value === null ? undefined : activeTrackUnitType.value }); break; } } diff --git a/src/ui/TrackUnit/TrackUnit.vue b/src/ui/TrackUnit/TrackUnit.vue index b5e878a..ac853f0 100644 --- a/src/ui/TrackUnit/TrackUnit.vue +++ b/src/ui/TrackUnit/TrackUnit.vue @@ -1,5 +1,9 @@ diff --git a/src/ui/TrackUnitBox/TrackUnitBox.vue b/src/ui/TrackUnitBox/TrackUnitBox.vue new file mode 100644 index 0000000..8ab30f2 --- /dev/null +++ b/src/ui/TrackUnitBox/TrackUnitBox.vue @@ -0,0 +1,87 @@ + + + + + diff --git a/src/ui/Widgets/Icon/icons.ts b/src/ui/Widgets/Icon/icons.ts index e041fed..a2650dc 100644 --- a/src/ui/Widgets/Icon/icons.ts +++ b/src/ui/Widgets/Icon/icons.ts @@ -10,6 +10,7 @@ import RightFoot from "@/assets/svgs/RF.png"; import Eraser from "@/assets/svgs/eraser-fill.svg"; import Upload from "@/assets/svgs/upload.svg"; import Floppy from "@/assets/svgs/floppy2-fill.svg"; +import Delete from "@/assets/svgs/delete.svg"; export const IconUrlMap = { arrowClockwise: ArrowClockwise, @@ -24,6 +25,7 @@ export const IconUrlMap = { eraser: Eraser, upload: Upload, save: Floppy, + delete: Delete, } as const; export type IconName = keyof typeof IconUrlMap;