diff --git a/src/Frontend/src/components/messages2/SequenceDiagram.vue b/src/Frontend/src/components/messages2/SequenceDiagram.vue index 812fa38d7..6aae1e207 100644 --- a/src/Frontend/src/components/messages2/SequenceDiagram.vue +++ b/src/Frontend/src/components/messages2/SequenceDiagram.vue @@ -56,7 +56,7 @@ onMounted(() => store.refreshConversation()); } .outer { max-width: 100%; - max-height: calc(100vh - 27em); + max-height: calc(100vh - 30em); overflow: auto; } diff --git a/src/Frontend/src/components/messages2/SequenceDiagram/EndpointsComponent.vue b/src/Frontend/src/components/messages2/SequenceDiagram/EndpointsComponent.vue index 963047c17..10d328a77 100644 --- a/src/Frontend/src/components/messages2/SequenceDiagram/EndpointsComponent.vue +++ b/src/Frontend/src/components/messages2/SequenceDiagram/EndpointsComponent.vue @@ -7,19 +7,8 @@ import { computed, ref, watch } from "vue"; interface EndpointWithLocation extends Endpoint { width: number; textWidth: number; - x?: number; - surround?: EndpointSurround; -} - -interface EndpointSurround { x: number; - y: number; - width: number; height: number; - fill: string; - rx: string; - strokeWidth: string; - stroke: string; } const Endpoint_Gap = 30; @@ -32,80 +21,77 @@ defineProps<{ const store = useSequenceDiagramStore(); const { startX, endpoints } = storeToRefs(store); -const epTextRefs = ref([]); +const epTextRefs = ref([]); const endpointItems = computed(() => endpoints.value.map((x, index) => { const endpoint = x as EndpointWithLocation; const el = epTextRefs.value[index]; if (el) { - const bounds = el.getBBox(); + const bounds = el.getBoundingClientRect(); const previousEndpoint = index > 0 ? endpointItems.value[index - 1] : undefined; endpoint.width = Math.max(Endpoint_Width, bounds.width); endpoint.textWidth = bounds.width; endpoint.x = (previousEndpoint?.x ?? startX.value) + (previousEndpoint?.width ?? 0) + Endpoint_Gap; - - if (!endpoint.surround && el.isConnected) { - const style = getComputedStyle(el); - const padding_top = parseInt(style.getPropertyValue("padding-top")); - const padding_left = parseInt(style.getPropertyValue("padding-left")); - const padding_right = parseInt(style.getPropertyValue("padding-right")); - const padding_bottom = parseInt(style.getPropertyValue("padding-bottom")); - endpoint.surround = { - x: endpoint.x - endpoint.width / 2 - padding_left, - y: bounds.y - padding_top, - width: endpoint.width + padding_left + padding_right, - height: bounds.height + padding_top + padding_bottom, - fill: style.getPropertyValue("background-color"), - rx: style.getPropertyValue("border-radius"), - strokeWidth: style.getPropertyValue("border-top-width"), - stroke: style.getPropertyValue("border-top-color"), - }; - } + endpoint.height = bounds.height; + endpoint.uiRef = el; } return endpoint; }) ); watch(endpointItems, () => { - store.setEndpointCentrePoints(endpointItems.value.map((endpoint) => ({ name: endpoint.name, centre: endpoint.x, top: (endpoint.surround?.y ?? 0) + (endpoint.surround?.height ?? 0) + 15 }) as EndpointCentrePoint)); + store.setEndpointCentrePoints(endpointItems.value.map((endpoint) => ({ name: endpoint.name, centre: endpoint.x ?? 0, top: (endpoint.height ?? 0) + 15 }) as EndpointCentrePoint)); const lastEndpoint = endpointItems.value[endpointItems.value.length - 1]; store.setMaxWidth((lastEndpoint.x ?? 0) + lastEndpoint.width); }); watch(startX, () => { epTextRefs.value = []; - endpoints.value.forEach((endpoint) => ((endpoint as EndpointWithLocation).surround = undefined)); }); -function setEndpointTextRef(el: SVGTextElement, index: number) { +function setEndpointTextRef(el: Element, index: number) { if (el) epTextRefs.value[index] = el; } diff --git a/src/Frontend/src/components/messages2/SequenceDiagram/HandlersComponent.vue b/src/Frontend/src/components/messages2/SequenceDiagram/HandlersComponent.vue index f5062a401..bad40b0fc 100644 --- a/src/Frontend/src/components/messages2/SequenceDiagram/HandlersComponent.vue +++ b/src/Frontend/src/components/messages2/SequenceDiagram/HandlersComponent.vue @@ -29,7 +29,7 @@ const handlerItems = computed(() => { const messageTypeElement = messageTypeRefs.value[index]; const count = handler.outMessages.length; const height = (count === 0 ? 1 : count) * Height_Per_Out; - if (nextY === 0) nextY += Handler_Gap + (endpoint?.top ?? 0); + if (nextY === 0) nextY += Handler_Gap + (Math.max(...endpointCentrePoints.value.map((cp) => cp.top)) ?? 0); const y = nextY; nextY += height + Handler_Gap; const fill = (() => { diff --git a/src/Frontend/src/resources/SequenceDiagram/Endpoint.ts b/src/Frontend/src/resources/SequenceDiagram/Endpoint.ts index b9bfc6eed..795199191 100644 --- a/src/Frontend/src/resources/SequenceDiagram/Endpoint.ts +++ b/src/Frontend/src/resources/SequenceDiagram/Endpoint.ts @@ -9,7 +9,7 @@ export interface Endpoint { readonly handlers: Handler[]; readonly host: string; readonly version: string; - uiRef?: SVGElement; + uiRef?: Element; addHandler(handler: Handler): void; }