Skip to content

Commit 1dfa1fe

Browse files
committed
Improved self message sync/async.
A->A: async A.method { self { B.method self { C.method } } A->A:method B->B:method B.method { B->B:self async C->B:async C->A:async A->C:async1 } } A->A: async A->B: async A->C: async B->B: async B->C: async B->A: async C->C: async C->B: async C->A: async A.method { A->A: async A->B: async A->C: async B->B: async B->C: async B->A: async C->C: async C->B: async C->A: async B.method { A->A: async A->B: async A->C: async B->B: async B->C: async B->A: async C->C: async C->B: async C->A: async } } C.method { A->C: async C->A: async C->B: async B->C: async B.method { A->A: async A->B: async A->C: async B->B: async B->C: async B->A: async C->C: async C->B: async C->A: async } }
1 parent f10589f commit 1dfa1fe

File tree

4 files changed

+22
-28
lines changed

4 files changed

+22
-28
lines changed

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Creation/Creation.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { mapGetters, mapState } from "vuex";
7070
import Comment from "../Comment/Comment.vue";
7171
import Message from "../Message/Message.vue";
7272
import Occurrence from "../Interaction/Occurrence/Occurrence.vue";
73-
import { CodeRange } from "../../../../../../../parser/CodeRange";
73+
import { CodeRange } from "@/parser/CodeRange";
7474
import Participant from "../../../../../../../components/DiagramFrame/SeqDiagram/LifeLineLayer/Participant.vue";
7575
7676
const logger = parentLogger.child({ name: "Creation" });
@@ -79,7 +79,7 @@ export default {
7979
name: "creation",
8080
props: ["context", "comment", "commentObj", "selfCallIndent", "number"],
8181
computed: {
82-
...mapGetters(["cursor", "onElementClick", "distance"]),
82+
...mapGetters(["cursor", "onElementClick", "distance2"]),
8383
...mapState(["numbering"]),
8484
from() {
8585
return this.context.Origin();
@@ -88,12 +88,15 @@ export default {
8888
return this.context.creation();
8989
},
9090
interactionWidth() {
91-
let distance = Math.abs(this.distance(this.to, this.from));
91+
if (this.context && this.isSelf) {
92+
return 0;
93+
}
94+
9295
let safeOffset = this.selfCallIndent || 0;
93-
return distance + (this.rightToLeft ? safeOffset : -safeOffset);
96+
return Math.abs(this.distance2(this.from, this.to) - safeOffset) - 1;
9497
},
9598
rightToLeft() {
96-
return this.distance(this.to, this.from) < 0;
99+
return this.distance2(this.from, this.to) < 0;
97100
},
98101
signature() {
99102
return this.creation.SignatureText();

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Interaction/Interaction.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default {
148148
// increases by 6px (half of the width of an execution bar). However, we set the selfCallIndent back to 0 when
149149
// it enters a non-self sync interaction.
150150
return this.isSelf && !this.isRootBlock
151-
? (this.selfCallIndent || 0) + 6
151+
? (this.selfCallIndent || 0) + 7
152152
: 0;
153153
},
154154
interactionWidth: function () {
@@ -157,7 +157,7 @@ export default {
157157
}
158158
159159
let safeOffset = this.outOfBand ? 0 : this.selfCallIndent || 0;
160-
return Math.abs(this.distance2(this.from, this.to) - safeOffset);
160+
return Math.abs(this.distance2(this.from, this.to) - safeOffset) - 1;
161161
},
162162
to: function () {
163163
return this.context?.message()?.Owner();

src/components/DiagramFrame/SeqDiagram/MessageLayer/Block/Statement/Interaction/Occurrence/Occurrence.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
>
1010
<div
1111
v-if="debug"
12-
class="absolute w-full left-0 bg-amber-700 h-3 -top-2 flex justify-center items-center"
12+
class="absolute w-full left-0 bg-amber-700 h-3 -top-1 flex justify-center items-center"
13+
>
14+
<div class="w-px h-full bg-black"></div>
15+
</div>
16+
<div
17+
v-if="debug"
18+
class="absolute w-full left-0 bg-amber-700 h-3 -bottom-1 flex justify-center items-center"
1319
>
1420
<div class="w-px h-full bg-black"></div>
1521
</div>
@@ -95,8 +101,8 @@ export default {
95101
<style scoped>
96102
.occurrence {
97103
width: 15px;
98-
/* 5 = (OccurrenceWidth(15)-1)/2 - OccurrenceBorderWidth(2)*/
99-
padding: 16px 0 16px 5px;
104+
/* 6 = (OccurrenceWidth(15)+1)/2 - OccurrenceBorderWidth(2)*/
105+
padding: 16px 0 16px 6px;
100106
}
101107
102108
:deep(> .statement-container:last-child > .interaction.return:last-of-type) {

src/components/DiagramFrame/SeqDiagram/MessageLayer/MessageLayer.vue

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,15 @@ const StylePanel = defineAsyncComponent(() => import("./StylePanel.vue"));
1515
1616
const logger = parentLogger.child({ name: "MessageLayer" });
1717
18-
const props = defineProps<{
19-
context: any;
20-
}>();
2118
const store = useStore();
2219
2320
const participants = computed(() => store.getters.participants);
2421
const centerOf = computed(() => store.getters.centerOf);
25-
const isSelfSyncMessage = computed(() => {
26-
const syncMessage = props.context?.stat()[0].message();
27-
if (!syncMessage) {
28-
return false;
29-
}
30-
const to = syncMessage?.Owner();
31-
const providedFrom = syncMessage?.ProvidedFrom();
32-
const origin = props.context?.Origin();
33-
const from = providedFrom || origin;
34-
return !to || to === from;
35-
});
3622
3723
const paddingLeft = computed(() => {
3824
if (participants.value.Array().length >= 1) {
3925
const first = participants.value.Array().slice(0)[0].name;
40-
// push the message layer to the right by 1px only for self message at root level.
41-
return centerOf.value(first) + (isSelfSyncMessage.value ? 1 : 0);
26+
return centerOf.value(first) + 1;
4227
}
4328
return 0;
4429
});
@@ -80,7 +65,7 @@ onUpdated(() => {
8065
8166
.occurrence {
8267
.interaction.sync {
83-
border-left-width: 8px;
68+
border-left-width: 7px;
8469
}
8570
.interaction.sync.right-to-left {
8671
border-right-width: 7px;
@@ -146,7 +131,7 @@ onUpdated(() => {
146131
147132
.interaction.right-to-left > .occurrence {
148133
/* InteractionBorderWidth + (OccurrenceWidth-1)/2 */
149-
left: -14px;
134+
left: -15px;
150135
/* overlay occurrence bar on the existing bar. */
151136
}
152137

0 commit comments

Comments
 (0)