Skip to content

Commit acd592a

Browse files
committed
drawAnnotationConversation
1 parent d8eff20 commit acd592a

File tree

4 files changed

+61
-44
lines changed

4 files changed

+61
-44
lines changed

services/static-webserver/client/source/class/osparc/workbench/Annotation.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,8 @@ qx.Class.define("osparc.workbench.Annotation", {
124124
break;
125125
case this.self().TYPES.CONVERSATION: {
126126
const text = `${attrs.x}, ${attrs.y}`;
127-
const conversationData = {
128-
conversationId: attrs.conversationId,
129-
title: attrs.text || text,
130-
}
131-
representation = new osparc.workbench.ConversationUI(conversationData);
132-
// OM: Add it to the svgLayer or something
133-
representation.moveTo(attrs.x, attrs.y);
134-
representation.isSVG = false;
127+
representation = this.__svgLayer.drawAnnotationConversation(attrs.width, attrs.height, attrs.x, attrs.y, this.getColor());
128+
representation.isSVG = true;
135129
break;
136130
}
137131
}

services/static-webserver/client/source/class/osparc/workbench/ConversationUI.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

services/static-webserver/client/source/class/osparc/workbench/SvgWidget.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ qx.Class.define("osparc.workbench.SvgWidget", {
105105
return osparc.wrapper.Svg.drawAnnotationRect(this.__canvas, width, height, x, y, color);
106106
},
107107

108+
drawAnnotationConversation: function(x, y, color) {
109+
return osparc.wrapper.Svg.drawAnnotationConversation(this.__canvas, x, y, color);
110+
},
111+
108112
drawDashedRect: function(width, height, x = 0, y = 0) {
109113
return osparc.wrapper.Svg.drawDashedRect(this.__canvas, width, height, x, y);
110114
},

services/static-webserver/client/source/class/osparc/wrapper/Svg.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,61 @@ qx.Class.define("osparc.wrapper.Svg", {
274274
return rect;
275275
},
276276

277+
drawAnnotationConversation: function(draw, x, y, color) {
278+
// Group to keep all elements together
279+
const bubble = draw.group();
280+
281+
// Rounded rectangle as the base
282+
const rect = draw.rect(280, 60)
283+
.radius(15)
284+
.fill("none")
285+
.stroke({
286+
width: 2,
287+
color,
288+
});
289+
bubble.add(rect);
290+
291+
// Icon (simple speech bubble using path or text)
292+
const icon = draw.text('💬')
293+
.font({ size: 24 })
294+
.move(10, 18);
295+
bubble.add(icon);
296+
297+
// Title text
298+
const title = draw.text('Hello')
299+
.font({
300+
size: 16,
301+
anchor: 'start'
302+
})
303+
.move(50, 22);
304+
bubble.add(title);
305+
306+
// Button (small circle with i or icon)
307+
const button = draw.circle(24)
308+
.fill('#ccc')
309+
.move(250, 18);
310+
const btnText = draw.text('➤')
311+
.font({
312+
size: 14,
313+
anchor: 'middle',
314+
leading: '1'
315+
})
316+
.move(250 + 12 - 7, 18 + 12 - 10); // center text in circle
317+
318+
bubble.add(button);
319+
bubble.add(btnText);
320+
321+
// Add a click event to the button
322+
button.click(function () {
323+
alert('Popup or conversation panel here!');
324+
});
325+
btnText.click(function () {
326+
alert('Popup or conversation panel here!');
327+
});
328+
329+
return bubble;
330+
},
331+
277332
updateText: function(representation, label) {
278333
if (representation.type === "text") {
279334
representation.text(label);

0 commit comments

Comments
 (0)