Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/renderer/extensions/minimap/MiniMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
/>

<div
ref="containerRef"
class="litegraph-minimap relative border border-interface-stroke bg-comfy-menu-bg shadow-interface"
:style="containerStyles"
>
Expand Down Expand Up @@ -50,7 +51,12 @@
}"
/>

<canvas :width="width" :height="height" class="minimap-canvas" />
<canvas
ref="canvasRef"
:width="width"
:height="height"
class="minimap-canvas"
/>

<div class="minimap-viewport" :style="viewportStyles" />

Expand All @@ -69,16 +75,17 @@

<script setup lang="ts">
import Button from 'primevue/button'
import { onMounted, onUnmounted, ref } from 'vue'
import { onMounted, onUnmounted, ref, useTemplateRef } from 'vue'

import { useMinimap } from '@/renderer/extensions/minimap/composables/useMinimap'
import { useCommandStore } from '@/stores/commandStore'

import MiniMapPanel from './MiniMapPanel.vue'

const commandStore = useCommandStore()

const minimapRef = ref<HTMLDivElement>()
const containerRef = useTemplateRef<HTMLDivElement>('containerRef')
const canvasRef = useTemplateRef<HTMLCanvasElement>('canvasRef')

const {
initialized,
Expand All @@ -101,7 +108,10 @@ const {
handlePointerCancel,
handleWheel,
setMinimapRef
} = useMinimap()
} = useMinimap({
containerRefMaybe: containerRef,
canvasRefMaybe: canvasRef
})

const showOptionsPanel = ref(false)

Expand Down
17 changes: 11 additions & 6 deletions src/renderer/extensions/minimap/composables/useMinimap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useRafFn } from '@vueuse/core'
import { computed, nextTick, ref, watch } from 'vue'
import { computed, nextTick, ref, shallowRef, watch } from 'vue'
import type { ShallowRef } from 'vue'

import type { LGraph } from '@/lib/litegraph/src/litegraph'
import { useSettingStore } from '@/platform/settings/settingStore'
Expand All @@ -13,14 +14,20 @@ import { useMinimapRenderer } from './useMinimapRenderer'
import { useMinimapSettings } from './useMinimapSettings'
import { useMinimapViewport } from './useMinimapViewport'

export function useMinimap() {
export function useMinimap({
canvasRefMaybe,
containerRefMaybe
}: {
canvasRefMaybe?: Readonly<ShallowRef<HTMLCanvasElement | null>>
containerRefMaybe?: Readonly<ShallowRef<HTMLDivElement | null>>
} = {}) {
const canvasStore = useCanvasStore()
const workflowStore = useWorkflowStore()
const settingStore = useSettingStore()

const containerRef = ref<HTMLDivElement>()
const canvasRef = ref<HTMLCanvasElement>()
const minimapRef = ref<HTMLElement | null>(null)
const canvasRef = canvasRefMaybe ?? shallowRef(null)
const containerRef = containerRefMaybe ?? shallowRef(null)

const visible = ref(true)
const initialized = ref(false)
Expand Down Expand Up @@ -223,8 +230,6 @@ export function useMinimap() {
visible: computed(() => visible.value),
initialized: computed(() => initialized.value),

containerRef,
canvasRef,
containerStyles,
viewportStyles,
panelStyles,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ref } from 'vue'
import type { Ref } from 'vue'
import type { Ref, ShallowRef } from 'vue'

import type { MinimapCanvas } from '../types'

export function useMinimapInteraction(
containerRef: Ref<HTMLDivElement | undefined>,
containerRef: Readonly<ShallowRef<HTMLDivElement | null>>,
bounds: Ref<{ minX: number; minY: number; width: number; height: number }>,
scale: Ref<number>,
width: number,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { ref } from 'vue'
import type { Ref } from 'vue'
import type { Ref, ShallowRef } from 'vue'

import type { LGraph } from '@/lib/litegraph/src/litegraph'

import { renderMinimapToCanvas } from '../minimapCanvasRenderer'
import type { UpdateFlags } from '../types'

export function useMinimapRenderer(
canvasRef: Ref<HTMLCanvasElement | undefined>,
canvasRef: Readonly<ShallowRef<HTMLCanvasElement | null>>,
graph: Ref<LGraph | null>,
bounds: Ref<{ minX: number; minY: number; width: number; height: number }>,
scale: Ref<number>,
Expand Down
Loading