Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<script setup lang="ts">
import type { IImage } from '@/app/interfaces/entities';
interface Props {
entityData: IImage;
}
const props = defineProps<Props>();
const emit = defineEmits(['scaleImage', 'editTextPosition']);
const speedDialSize = computed(() => {
let state = [
{
label: 'x0.25',
icon: 'pi pi-arrow-down-left-and-arrow-up-right-to-center',
command: () => emit('scaleImage', '0.25')
},
{
label: 'x0.5',
icon: 'pi pi-arrow-down-left-and-arrow-up-right-to-center',
command: () => emit('scaleImage', '0.5')
},
{
label: 'x0.75',
icon: 'pi pi-arrow-down-left-and-arrow-up-right-to-center',
command: () => emit('scaleImage', '0.75')
},
{
label: 'x1',
icon: 'pi pi-arrow-down-left-and-arrow-up-right-to-center',
command: () => emit('scaleImage', '1')
}
];
const initialImageWidth = Math.ceil(props.entityData.image_width / +props.entityData.image_scale);
const initialImageHeight = Math.ceil(
props.entityData.image_height / +props.entityData.image_scale
);
if (initialImageWidth <= 400 || initialImageHeight <= 400) {
state = state.filter((item) => item.label !== 'x0.25');
if (initialImageWidth <= 200 || initialImageHeight <= 200) {
state = state.filter((item) => item.label !== 'x0.5');
if (initialImageWidth <= 95 || initialImageHeight <= 95) {
state = state.filter((item) => item.label !== 'x0.75');
}
}
}
return state.filter((item) => item.label !== `x${props.entityData.image_scale}`);
});
const speedDialSizeBigger = computed(() => {
let state = [
{
label: 'x1',
icon: 'pi pi-pencil',
command: () => emit('scaleImage', '1')
},
{
label: 'x1.25',
icon: 'pi pi-pencil',
command: () => emit('scaleImage', '1.25')
},
{
label: 'x1.5',
icon: 'pi pi-pencil',
command: () => emit('scaleImage', '1.5')
},
{
label: 'x1.75',
icon: 'pi pi-pencil',
command: () => emit('scaleImage', '1.75')
},
{
label: 'x2',
icon: 'pi pi-pencil',
command: () => emit('scaleImage', '2')
}
];
const initialImageWidth = Math.ceil(props.entityData.image_width / +props.entityData.image_scale);
const initialImageHeight = Math.ceil(
props.entityData.image_height / +props.entityData.image_scale
);
if (initialImageWidth >= 960 || initialImageHeight >= 960) {
state = state.filter((item) => item.label !== 'x1.25');
if (initialImageWidth >= 800 || initialImageHeight >= 800) {
state = state.filter((item) => item.label !== 'x1.5');
if (initialImageWidth >= 685 || initialImageHeight >= 685) {
state = state.filter((item) => item.label !== 'x1.75');
if (initialImageWidth >= 600 || initialImageHeight >= 600) {
state = state.filter((item) => item.label !== 'x2');
}
}
}
}
return state.filter((item) => item.label !== `x${props.entityData.image_scale}`);
});
</script>
<template>
<div
class="flex items-center justify-center relative z-50"
:style="`width: ${props.entityData.image_width}px; height: ${props.entityData.image_height}px`"
>
<SpeedDial
v-if="speedDialSize.length"
:model="speedDialSize"
:radius="70"
type="semi-circle"
direction="left"
:style="{ position: 'absolute', transform: 'translateX(-24px)' }"
showIcon="pi pi-arrow-down-left-and-arrow-up-right-to-center"
:buttonProps="{
rounded: true,
severity: 'info'
}"
>
<template #item="{ item, toggleCallback }">
<div
:class="[
'w-12 text-md font-semibold bg-opacity-70 items-center justify-between -translate-y-2 py-4 border rounded-full border-surface-200 dark:border-surface-700 cursor-pointer',
{
'bg-red-500': item.label.includes('0.25'),
'bg-orange-500': item.label.includes('0.5'),
'bg-yellow-500': item.label.includes('0.75'),
'bg-green-500': item.label.includes('1')
}
]"
@click="toggleCallback"
>
<div class="text-center">
{{ item.label }}
</div>
</div>
</template>
</SpeedDial>
<SpeedDial
v-if="speedDialSizeBigger.length"
:model="speedDialSizeBigger"
:radius="70"
type="semi-circle"
direction="right"
:style="{ position: 'absolute', transform: 'translateX(24px)' }"
showIcon="pi pi-arrow-up-right-and-arrow-down-left-from-center"
:buttonProps="{
rounded: true,
severity: 'info'
}"
>
<template #item="{ item, toggleCallback }">
<div
:class="[
'w-12 text-md font-semibold bg-opacity-70 items-center justify-between -translate-y-2 py-4 border rounded-full border-surface-200 dark:border-surface-700 cursor-pointer',
{
'bg-violet-500': item.label.includes('x2'),
'bg-red-500': item.label.includes('1.75'),
'bg-orange-500': item.label.includes('1.5'),
'bg-yellow-500': item.label.includes('1.25'),
'bg-green-500': item.label.includes('x1')
}
]"
@click="toggleCallback"
>
<div class="text-center">
{{ item.label }}
</div>
</div>
</template>
</SpeedDial>
</div>
</template>
<style scoped></style>