|
|
@@ -1,17 +1,72 @@
|
|
|
<template>
|
|
|
<div class="shape-style-panel">
|
|
|
<div class="row">
|
|
|
- <div style="flex: 2;">填充颜色:</div>
|
|
|
- <Popover trigger="click">
|
|
|
+ <Select
|
|
|
+ style="flex: 10;"
|
|
|
+ :value="fillType"
|
|
|
+ @change="value => updateFillType(value)"
|
|
|
+ >
|
|
|
+ <SelectOption value="fill">纯色填充</SelectOption>
|
|
|
+ <SelectOption value="gradient">渐变填充</SelectOption>
|
|
|
+ </Select>
|
|
|
+ <div style="flex: 1;"></div>
|
|
|
+ <Popover trigger="click" v-if="fillType === 'fill'">
|
|
|
<template #content>
|
|
|
<ColorPicker
|
|
|
:modelValue="fill"
|
|
|
@update:modelValue="value => updateFill(value)"
|
|
|
/>
|
|
|
</template>
|
|
|
- <ColorButton :color="fill" style="flex: 3;" />
|
|
|
+ <ColorButton :color="fill" style="flex: 10;" />
|
|
|
</Popover>
|
|
|
+ <Select
|
|
|
+ style="flex: 10;"
|
|
|
+ :value="gradient.type"
|
|
|
+ @change="value => updateGradient({ type: value })"
|
|
|
+ v-else
|
|
|
+ >
|
|
|
+ <SelectOption value="line">线性渐变</SelectOption>
|
|
|
+ <SelectOption value="radial">径向渐变</SelectOption>
|
|
|
+ </Select>
|
|
|
</div>
|
|
|
+
|
|
|
+ <template v-if="fillType === 'gradient'">
|
|
|
+ <div class="row">
|
|
|
+ <div style="flex: 2;">起点颜色:</div>
|
|
|
+ <Popover trigger="click">
|
|
|
+ <template #content>
|
|
|
+ <ColorPicker
|
|
|
+ :modelValue="gradient.color[0]"
|
|
|
+ @update:modelValue="value => updateGradient({ color: [value, gradient.color[1]] })"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <ColorButton :color="gradient.color[0]" style="flex: 3;" />
|
|
|
+ </Popover>
|
|
|
+ </div>
|
|
|
+ <div class="row">
|
|
|
+ <div style="flex: 2;">终点颜色:</div>
|
|
|
+ <Popover trigger="click">
|
|
|
+ <template #content>
|
|
|
+ <ColorPicker
|
|
|
+ :modelValue="gradient.color[1]"
|
|
|
+ @update:modelValue="value => updateGradient({ color: [gradient.color[0], value] })"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
+ <ColorButton :color="gradient.color[1]" style="flex: 3;" />
|
|
|
+ </Popover>
|
|
|
+ </div>
|
|
|
+ <div class="row" v-if="gradient.type === 'line'">
|
|
|
+ <div style="flex: 2;">渐变角度:</div>
|
|
|
+ <Slider
|
|
|
+ :min="0"
|
|
|
+ :max="360"
|
|
|
+ :step="15"
|
|
|
+ :value="gradient.rotate"
|
|
|
+ style="flex: 3;"
|
|
|
+ @change="value => updateGradient({ rotate: value })"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
|
|
|
<Divider />
|
|
|
<ElementOutline />
|
|
|
@@ -26,7 +81,7 @@
|
|
|
import { computed, defineComponent, ref, Ref, watch } from 'vue'
|
|
|
import { useStore } from 'vuex'
|
|
|
import { MutationTypes, State } from '@/store'
|
|
|
-import { PPTShapeElement } from '@/types/slides'
|
|
|
+import { PPTShapeElement, ShapeGradient } from '@/types/slides'
|
|
|
import useHistorySnapshot from '@/hooks/useHistorySnapshot'
|
|
|
|
|
|
import ElementOpacity from '../common/ElementOpacity.vue'
|
|
|
@@ -47,14 +102,40 @@ export default defineComponent({
|
|
|
const handleElement: Ref<PPTShapeElement> = computed(() => store.getters.handleElement)
|
|
|
|
|
|
const fill = ref<string>()
|
|
|
+ const gradient = ref<ShapeGradient>()
|
|
|
+ const fillType = ref('fill')
|
|
|
|
|
|
watch(handleElement, () => {
|
|
|
if(!handleElement.value) return
|
|
|
fill.value = handleElement.value.fill || '#000'
|
|
|
+
|
|
|
+ gradient.value = handleElement.value.gradient || { type: 'line', rotate: 0, color: [fill.value, '#fff'] }
|
|
|
+
|
|
|
+ fillType.value = handleElement.value.gradient ? 'gradient' : 'fill'
|
|
|
}, { deep: true, immediate: true })
|
|
|
|
|
|
const { addHistorySnapshot } = useHistorySnapshot()
|
|
|
|
|
|
+ const updateFillType = (type: 'gradient' | 'fill') => {
|
|
|
+ if(type === 'fill') {
|
|
|
+ store.commit(MutationTypes.REMOVE_ELEMENT_PROPS, {
|
|
|
+ id: handleElement.value.id,
|
|
|
+ propName: 'gradient',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ const props = { gradient: gradient.value }
|
|
|
+ store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
|
|
|
+ }
|
|
|
+ addHistorySnapshot()
|
|
|
+ }
|
|
|
+
|
|
|
+ const updateGradient = (gradientProps: Partial<ShapeGradient>) => {
|
|
|
+ const props = { gradient: { ...gradient.value, ...gradientProps } }
|
|
|
+ store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
|
|
|
+ addHistorySnapshot()
|
|
|
+ }
|
|
|
+
|
|
|
const updateFill = (value: string) => {
|
|
|
const props = { fill: value }
|
|
|
store.commit(MutationTypes.UPDATE_ELEMENT, { id: handleElement.value.id, props })
|
|
|
@@ -63,7 +144,11 @@ export default defineComponent({
|
|
|
|
|
|
return {
|
|
|
fill,
|
|
|
+ gradient,
|
|
|
+ fillType,
|
|
|
+ updateFillType,
|
|
|
updateFill,
|
|
|
+ updateGradient,
|
|
|
}
|
|
|
},
|
|
|
})
|