enso/app/gui2/stories/SelectionBrushWrapper.vue
Kaz Wesley 277dfb1991
Ast edits (#8576)
- The module is edited by changing the AST, not the text representation.
- `IdMap`s no longer need to be maintained in parallel with the module content; they are snapshots produced as needed from the ASTs.
- Simplistic synchronization is in place until #8237: Edits are never merged; if two edits are started from the same state, one will be overwritten.
2023-12-19 17:58:11 +00:00

40 lines
1.1 KiB
Vue

<script setup lang="ts">
import { computed, ref, shallowRef } from 'vue'
import type { Vec2 } from '@/util/data/vec2'
import { usePointer } from '@/util/events'
import { useNavigator } from '@/util/navigator'
const viewportNode = ref<HTMLElement>()
const navigator = useNavigator(viewportNode)
const selectionAnchor = shallowRef<Vec2>()
const selection = usePointer((_, __, eventType) => {
if (selection.dragging && selectionAnchor.value == null) {
selectionAnchor.value = navigator.sceneMousePos?.copy()
} else if (eventType === 'stop') {
selectionAnchor.value = undefined
}
})
const scaledMousePos = computed(() => navigator.sceneMousePos?.scale(navigator.scale))
const scaledSelectionAnchor = computed(() => selectionAnchor.value?.scale(navigator.scale))
</script>
<template>
<div
ref="viewportNode"
style="cursor: none; height: 100%"
v-on.="navigator.events"
v-on..="selection.events"
>
<slot
:scaledMousePos="scaledMousePos"
:scaledSelectionAnchor="scaledSelectionAnchor"
:navigator="navigator"
></slot>
</div>
</template>