@elicdavis/node-flow 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +10 -4
- package/dist/index.mjs.map +1 -1
- package/index.html +7 -2
- package/package.json +1 -1
- package/src/node.ts +11 -4
package/index.html
CHANGED
|
@@ -298,11 +298,16 @@ node.addOutput({ name: "sum", type: "float32" })
|
|
|
298
298
|
],
|
|
299
299
|
messages: [
|
|
300
300
|
{
|
|
301
|
-
message: "I am a message attatched to the node"
|
|
301
|
+
message: "I am a message attatched to the node",
|
|
302
|
+
alwaysShow: true,
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
message: "I am a message that only shows when you're hovering over the node!",
|
|
302
306
|
},
|
|
303
307
|
{
|
|
304
308
|
message: "I am another message attatched to the node with type \"error\"",
|
|
305
|
-
type: "error"
|
|
309
|
+
type: "error",
|
|
310
|
+
alwaysShow: true,
|
|
306
311
|
}
|
|
307
312
|
],
|
|
308
313
|
});
|
package/package.json
CHANGED
package/src/node.ts
CHANGED
|
@@ -35,7 +35,6 @@ type TitleChangeCallback = (node: FlowNode, oldTitle: string, newTitle: string)
|
|
|
35
35
|
type InfoChangeCallback = (node: FlowNode, oldInfo: string, newInfo: string) => void
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
|
|
39
38
|
export interface WidgetConfig {
|
|
40
39
|
type?: string,
|
|
41
40
|
config?: any
|
|
@@ -81,6 +80,8 @@ function MessageTypeColor(messageType: MessageType): string {
|
|
|
81
80
|
export interface NodeMessageConfig {
|
|
82
81
|
message: string;
|
|
83
82
|
type?: MessageType;
|
|
83
|
+
alwaysShow?: boolean;
|
|
84
|
+
color?: string;
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
export interface FlowNodeConfig {
|
|
@@ -143,10 +144,13 @@ class MessageRenderer {
|
|
|
143
144
|
|
|
144
145
|
#text: Text;
|
|
145
146
|
|
|
147
|
+
#alwaysShow: boolean;
|
|
148
|
+
|
|
146
149
|
constructor(config: NodeMessageConfig) {
|
|
150
|
+
this.#alwaysShow = config.alwaysShow ? config.alwaysShow : false;
|
|
147
151
|
this.#text = new Text(config.message,
|
|
148
152
|
{
|
|
149
|
-
color: MessageTypeColor(config.type ? config.type : MessageType.Info),
|
|
153
|
+
color: config.color ? config.color : MessageTypeColor(config.type ? config.type : MessageType.Info),
|
|
150
154
|
},
|
|
151
155
|
{
|
|
152
156
|
LineSpacing: 2.5,
|
|
@@ -155,7 +159,10 @@ class MessageRenderer {
|
|
|
155
159
|
);
|
|
156
160
|
}
|
|
157
161
|
|
|
158
|
-
render(ctx: CanvasRenderingContext2D, scale: number, position: Vector2): number {
|
|
162
|
+
render(ctx: CanvasRenderingContext2D, scale: number, position: Vector2, hovering: boolean): number {
|
|
163
|
+
if (!this.#alwaysShow && !hovering) {
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
159
166
|
ctx.textAlign = TextAlign.Center;
|
|
160
167
|
this.#text.render(ctx, scale, position);
|
|
161
168
|
return this.#text.height(ctx) * scale;
|
|
@@ -1201,7 +1208,7 @@ export class FlowNode {
|
|
|
1201
1208
|
messageStart.y = nodeBounds.Position.y + nodeBounds.Size.y + (15 * camera.zoom);
|
|
1202
1209
|
for (let i = 0; i < this.#messages.length; i++) {
|
|
1203
1210
|
const message = this.#messages[i];
|
|
1204
|
-
messageStart.y += message.render(ctx, camera.zoom, messageStart) + (10 * camera.zoom);
|
|
1211
|
+
messageStart.y += message.render(ctx, camera.zoom, messageStart, !(state === NodeState.Idle)) + (10 * camera.zoom);
|
|
1205
1212
|
}
|
|
1206
1213
|
})
|
|
1207
1214
|
}
|