Line data Source code
1 16 : <template>
2 34 : <div class="flex h-full flex-col justify-between bg-background">
3 : <div class="flex flex-col">
4 170 : <div
5 : v-for="tool in allTools"
6 : :key="tool"
7 : data-testid="tool-button"
8 : :data-tool="tool"
9 : :class="
10 : cn(
11 : 'maskEditor_toolPanelContainer hover:bg-accent',
12 : currentTool === tool && 'maskEditor_toolPanelContainerSelected'
13 : )
14 : "
15 : @click="onToolSelect(tool)"
16 : >
17 : <div class="flex items-center justify-center">
18 : <MaskEditorToolIcon :tool="tool" />
19 : </div>
20 : <div class="maskEditor_toolPanelIndicator"></div>
21 : </div>
22 : </div>
23 :
24 : <div
25 : class="mb-2 flex cursor-pointer flex-col items-center rounded-md text-muted-foreground transition-colors duration-200 hover:bg-accent"
26 : :title="t('maskEditor.clickToResetZoom')"
27 : @click="onResetZoom"
28 : >
29 : <span data-testid="zoom-percentage" class="text-sm">{{ zoomText }}</span>
30 : <span data-testid="zoom-dimensions" class="text-xs">{{
31 : dimensionsText
32 : }}</span>
33 : </div>
34 : </div>
35 : </template>
36 :
37 : <script setup lang="ts">
38 : import { computed } from 'vue'
39 : import { useI18n } from 'vue-i18n'
40 :
41 : import { cn } from '@comfyorg/tailwind-utils'
42 :
43 : import MaskEditorToolIcon from './MaskEditorToolIcon.vue'
44 : import type { useToolManager } from '#/useToolManager'
45 : import type { Tools } from '#/types'
46 : import { allTools } from '#/types'
47 : import { useMaskEditorStore } from '#/maskEditorStore'
48 :
49 : const { toolManager } = defineProps<{
50 : toolManager: ReturnType<typeof useToolManager>
51 : }>()
52 :
53 29 : const { t } = useI18n()
54 29 : const store = useMaskEditorStore()
55 :
56 29 : const onToolSelect = (tool: Tools) => {
57 5 : toolManager.switchTool(tool)
58 : }
59 :
60 29 : const currentTool = computed(() => store.currentTool)
61 :
62 29 : const zoomText = computed(() => `${Math.round(store.displayZoomRatio * 100)}%`)
63 29 : const dimensionsText = computed(() => {
64 29 : const img = store.image
65 29 : return img ? `${img.width}x${img.height}` : ' '
66 : })
67 :
68 29 : const onResetZoom = () => {
69 0 : store.resetZoom()
70 : }
71 : </script>
|