Skip to content

Commit

Permalink
Review pt 1
Browse files Browse the repository at this point in the history
  • Loading branch information
kazcw committed Mar 15, 2024
1 parent 905e91f commit 60b2e9b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
15 changes: 15 additions & 0 deletions app/gui2/src/components/GraphEditor/widgets/WidgetSelection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
type ArgumentWidgetConfiguration,
} from '@/providers/widgetRegistry/configuration'
import { WidgetEditHandler } from '@/providers/widgetRegistry/editHandler'
import { injectWidgetTree } from '@/providers/widgetTree.ts'
import { useGraphStore } from '@/stores/graph'
import { requiredImports, type RequiredImport } from '@/stores/graph/imports.ts'
import { useSuggestionDbStore } from '@/stores/suggestionDatabase'
Expand All @@ -27,6 +28,9 @@ import { computed, ref, watch, type ComponentInstance } from 'vue'
const props = defineProps(widgetProps(widgetDefinition))
const suggestions = useSuggestionDbStore()
const graph = useGraphStore()
const tree = injectWidgetTree()
const widgetRoot = ref<HTMLElement>()
const dropdownElement = ref<ComponentInstance<typeof DropdownWidget>>()
Expand Down Expand Up @@ -252,6 +256,17 @@ watch(selectedIndex, (_index) => {
}
props.onUpdate({ edit, portUpdate: { value, origin: props.input.portId } })
})
let endClippingInhibition: (() => void) | undefined
watch(dropdownVisible, (visible) => {
if (visible) {
const { unregister } = tree.inhibitClipping()
endClippingInhibition = unregister
} else {
endClippingInhibition?.()
endClippingInhibition = undefined
}
})
</script>

<script lang="ts">
Expand Down
11 changes: 1 addition & 10 deletions app/gui2/src/components/widgets/DropdownWidget.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<script setup lang="ts">
import SvgIcon from '@/components/SvgIcon.vue'
import { injectWidgetTree } from '@/providers/widgetTree'
import type { Icon } from '@/util/iconName'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { computed, ref } from 'vue'
enum SortDirection {
none = 'none',
Expand All @@ -13,14 +12,6 @@ enum SortDirection {
const props = defineProps<{ color: string; selectedValue: string | undefined; values: string[] }>()
const emit = defineEmits<{ click: [index: number, keepOpen: boolean] }>()
const tree = injectWidgetTree()
let endClippingInhibition: (() => void) | undefined
onMounted(() => {
endClippingInhibition = tree.inhibitClipping()
})
onUnmounted(() => endClippingInhibition?.())
const sortDirection = ref<SortDirection>(SortDirection.none)
const sortedValuesAndIndices = computed(() => {
Expand Down
22 changes: 13 additions & 9 deletions app/gui2/src/providers/widgetTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import { computed, proxyRefs, type Ref } from 'vue'
function makeExistenceRegistry(onChange: (anyExist: boolean) => void) {
const registered = new Set<number>()
let nextId = 0
return () => {
const id = nextId++
if (registered.size === 0) onChange(true)
registered.add(id)
return () => {
registered.delete(id)
if (registered.size === 0) onChange(false)
}
return {
register: () => {
const id = nextId++
if (registered.size === 0) onChange(true)
registered.add(id)
return {
unregister: () => {
registered.delete(id)
if (registered.size === 0) onChange(false)
},
}
},
}
}

Expand All @@ -35,7 +39,7 @@ const { provideFn, injectFn } = createContextStore(
) => {
const graph = useGraphStore()
const nodeSpanStart = computed(() => graph.moduleSource.getSpan(astRoot.value.id)![0])
const inhibitClipping = makeExistenceRegistry(clippingInhibitorsChanged)
const { register: inhibitClipping } = makeExistenceRegistry(clippingInhibitorsChanged)
return proxyRefs({
astRoot,
nodeId,
Expand Down

0 comments on commit 60b2e9b

Please sign in to comment.