From 5a8d9b643f5f1e2c5a1b76d572cd7f40db33b859 Mon Sep 17 00:00:00 2001 From: Hanxing Yang Date: Mon, 1 Jul 2024 14:50:29 +0800 Subject: [PATCH] component `AnimationSettings` (#621) * component AnimationSettings * use UIIcon instead of inline svg * fix svg icon --- spx-gui/src/components/asset/index.ts | 8 +- .../editor/panels/sound/SoundSummaryItem.vue | 8 +- .../sprite/animation/AnimationSettings.vue | 148 ++++++++++++++++++ .../sprite/animation/DurationEditor.vue | 34 ++++ .../sprite/animation/sound/SoundEditor.vue | 124 +++++++++++++++ .../sprite/animation/sound/SoundItem.vue | 45 ++++++ .../animation/state/BoundStateEditor.vue | 106 +++++++++++++ .../editor/sprite/animation/state/default.svg | 3 + .../editor/sprite/animation/state/die.svg | 3 + .../editor/sprite/animation/state/step.svg | 3 + spx-gui/src/components/ui/UIBlockItem.vue | 43 +++++ .../src/components/ui/UIConfigProvider.vue | 7 + spx-gui/src/components/ui/UIDropdown.vue | 10 ++ spx-gui/src/components/ui/icons/UIIcon.vue | 8 +- spx-gui/src/components/ui/icons/sound.svg | 3 + spx-gui/src/components/ui/icons/status.svg | 3 + spx-gui/src/components/ui/icons/timer.svg | 3 + spx-gui/src/components/ui/index.ts | 4 +- .../components/ui/modal/UIDropdownModal.vue | 75 +++++++++ spx-gui/src/components/ui/modal/index.ts | 1 + spx-gui/src/components/ui/utils/index.ts | 10 ++ spx-gui/src/models/animation.ts | 7 +- spx-gui/src/models/common/asset-name.test.ts | 7 +- spx-gui/src/utils/audio.ts | 7 +- 24 files changed, 649 insertions(+), 21 deletions(-) create mode 100644 spx-gui/src/components/editor/sprite/animation/AnimationSettings.vue create mode 100644 spx-gui/src/components/editor/sprite/animation/DurationEditor.vue create mode 100644 spx-gui/src/components/editor/sprite/animation/sound/SoundEditor.vue create mode 100644 spx-gui/src/components/editor/sprite/animation/sound/SoundItem.vue create mode 100644 spx-gui/src/components/editor/sprite/animation/state/BoundStateEditor.vue create mode 100644 spx-gui/src/components/editor/sprite/animation/state/default.svg create mode 100644 spx-gui/src/components/editor/sprite/animation/state/die.svg create mode 100644 spx-gui/src/components/editor/sprite/animation/state/step.svg create mode 100644 spx-gui/src/components/ui/UIBlockItem.vue create mode 100644 spx-gui/src/components/ui/icons/sound.svg create mode 100644 spx-gui/src/components/ui/icons/status.svg create mode 100644 spx-gui/src/components/ui/icons/timer.svg create mode 100644 spx-gui/src/components/ui/modal/UIDropdownModal.vue diff --git a/spx-gui/src/components/asset/index.ts b/spx-gui/src/components/asset/index.ts index 5e14f87f6..fe30f383c 100644 --- a/spx-gui/src/components/asset/index.ts +++ b/spx-gui/src/components/asset/index.ts @@ -24,11 +24,11 @@ function selectAsset(project: Project, asset: AssetModel | undefined) { } } -export function useAddAssetFromLibrary() { +export function useAddAssetFromLibrary(autoSelect = true) { const invokeAssetLibraryModal = useModal(AssetLibraryModal) return async function addAssetFromLibrary(project: Project, type: T) { const added = (await invokeAssetLibraryModal({ project, type })) as Array> - selectAsset(project, added[0]) + if (autoSelect) selectAsset(project, added[0]) return added } } @@ -110,13 +110,13 @@ export function useAddCostumeFromLocalFile() { } } -export function useAddSoundFromLocalFile() { +export function useAddSoundFromLocalFile(autoSelect = true) { return async function addSoundFromLocalFile(project: Project) { const audio = await selectAudio() const sound = await Sound.create(stripExt(audio.name), fromNativeFile(audio)) const action = { name: { en: 'Add sound', zh: '添加声音' } } await project.history.doAction(action, () => project.addSound(sound)) - selectAsset(project, sound) + if (autoSelect) selectAsset(project, sound) return sound } } diff --git a/spx-gui/src/components/editor/panels/sound/SoundSummaryItem.vue b/spx-gui/src/components/editor/panels/sound/SoundSummaryItem.vue index 261a5dff5..96707e460 100644 --- a/spx-gui/src/components/editor/panels/sound/SoundSummaryItem.vue +++ b/spx-gui/src/components/editor/panels/sound/SoundSummaryItem.vue @@ -1,16 +1,12 @@ + + diff --git a/spx-gui/src/components/editor/sprite/animation/DurationEditor.vue b/spx-gui/src/components/editor/sprite/animation/DurationEditor.vue new file mode 100644 index 000000000..a67abf7d1 --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/DurationEditor.vue @@ -0,0 +1,34 @@ + + + diff --git a/spx-gui/src/components/editor/sprite/animation/sound/SoundEditor.vue b/spx-gui/src/components/editor/sprite/animation/sound/SoundEditor.vue new file mode 100644 index 000000000..b5348fe54 --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/sound/SoundEditor.vue @@ -0,0 +1,124 @@ + + + + + diff --git a/spx-gui/src/components/editor/sprite/animation/sound/SoundItem.vue b/spx-gui/src/components/editor/sprite/animation/sound/SoundItem.vue new file mode 100644 index 000000000..756f75f1a --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/sound/SoundItem.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/spx-gui/src/components/editor/sprite/animation/state/BoundStateEditor.vue b/spx-gui/src/components/editor/sprite/animation/state/BoundStateEditor.vue new file mode 100644 index 000000000..c743ce3b4 --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/state/BoundStateEditor.vue @@ -0,0 +1,106 @@ + + + + + + + diff --git a/spx-gui/src/components/editor/sprite/animation/state/default.svg b/spx-gui/src/components/editor/sprite/animation/state/default.svg new file mode 100644 index 000000000..8bd52b83e --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/state/default.svg @@ -0,0 +1,3 @@ + + + diff --git a/spx-gui/src/components/editor/sprite/animation/state/die.svg b/spx-gui/src/components/editor/sprite/animation/state/die.svg new file mode 100644 index 000000000..fc34ebd6a --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/state/die.svg @@ -0,0 +1,3 @@ + + + diff --git a/spx-gui/src/components/editor/sprite/animation/state/step.svg b/spx-gui/src/components/editor/sprite/animation/state/step.svg new file mode 100644 index 000000000..505b76d51 --- /dev/null +++ b/spx-gui/src/components/editor/sprite/animation/state/step.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/spx-gui/src/components/ui/UIBlockItem.vue b/spx-gui/src/components/ui/UIBlockItem.vue new file mode 100644 index 000000000..e892b271b --- /dev/null +++ b/spx-gui/src/components/ui/UIBlockItem.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/spx-gui/src/components/ui/UIConfigProvider.vue b/spx-gui/src/components/ui/UIConfigProvider.vue index 3db000dc7..ff583331a 100644 --- a/spx-gui/src/components/ui/UIConfigProvider.vue +++ b/spx-gui/src/components/ui/UIConfigProvider.vue @@ -181,4 +181,11 @@ h6 { button:focus { outline: 2px solid var(--ui-color-primary-700); } + +// vueuc (dep of naive-ui) uses `pointer-events: all` on children of `v-binder-follower-content`, which wraps `Popover` content in naive-ui. +// It causes pointer behavior issues in popup content. For example, a svg in a `visibility: hidden` element will still be clickable. +// So we override it here to fix the issue. See details in https://github.com/07akioni/vueuc/issues/314 +.v-binder-follower-content > * { + pointer-events: initial; +} diff --git a/spx-gui/src/components/ui/UIDropdown.vue b/spx-gui/src/components/ui/UIDropdown.vue index 31cb668c5..e563c5dde 100644 --- a/spx-gui/src/components/ui/UIDropdown.vue +++ b/spx-gui/src/components/ui/UIDropdown.vue @@ -12,6 +12,7 @@ :style="{ marginTop: offset.y + 'px', marginLeft: offset.x + 'px' }" raw @update:show="(v) => emit('update:visible', v)" + @clickoutside="handleClickOutside" >