Skip to content

Commit

Permalink
Fix lagging behind draw call
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Jun 5, 2024
1 parent 75eb212 commit d981c3e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 34 deletions.
27 changes: 13 additions & 14 deletions src/renderer/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ export class SDFGRenderer extends EventEmitter {
this.on('selection_changed', () => {
this.on_selection_changed();
});
this.on('graph_edited', () => {
this.draw_async();
});
}

public destroy(): void {
Expand Down Expand Up @@ -1133,9 +1136,8 @@ export class SDFGRenderer extends EventEmitter {
this.add_loading_animation();
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}
}

Expand Down Expand Up @@ -1475,9 +1477,8 @@ export class SDFGRenderer extends EventEmitter {
// to reload the dom with the above loader element.
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}
}

Expand All @@ -1497,9 +1498,8 @@ export class SDFGRenderer extends EventEmitter {
// to reload the dom with the above loader element.
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}

public expandNextLevel(): void {
Expand All @@ -1523,9 +1523,8 @@ export class SDFGRenderer extends EventEmitter {
// to reload the dom with the above loader element.
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}

public expandAll(): void {
Expand All @@ -1544,9 +1543,8 @@ export class SDFGRenderer extends EventEmitter {
// to reload the dom with the above loader element.
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}

public reset_positions(): void {
Expand All @@ -1563,9 +1561,8 @@ export class SDFGRenderer extends EventEmitter {
// to reload the dom with the above loader element.
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

this.draw_async();
}

// Save functions
Expand Down Expand Up @@ -2782,6 +2779,7 @@ export class SDFGRenderer extends EventEmitter {
this.add_loading_animation();
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);

return true;
Expand Down Expand Up @@ -3714,11 +3712,12 @@ export class SDFGRenderer extends EventEmitter {
this.add_loading_animation();
setTimeout(() => {
this.relayout();
this.draw_async();
}, 10);
} else {
this.draw_async();
}

this.draw_async();

if (element_moved)
this.emit('element_position_changed', 'manual_move');
} else if (this.mouse_mode === 'add') {
Expand Down
19 changes: 0 additions & 19 deletions src/renderer/renderer_elements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,25 +685,6 @@ export class State extends BasicBlock {

if (mousepos && this.intersect(mousepos.x, mousepos.y))
renderer.set_tooltip((c) => this.tooltip(c));

// Draw state name in center without contents (does not look good)
/*
let FONTSIZE = Math.min(
renderer.canvas_manager.points_per_pixel() * 16, 100
);
let label = this.label();
let oldfont = ctx.font;
ctx.font = FONTSIZE + "px Arial";
let textmetrics = ctx.measureText(label);
ctx.fillText(
label, this.x - textmetrics.width / 2.0,
this.y - this.height / 6.0 + FONTSIZE / 2.0
);
ctx.font = oldfont;
*/
}

public shade(
Expand Down
3 changes: 2 additions & 1 deletion src/utils/sdfv_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,14 @@ export class SDFVSettings {
this.renderer?.add_loading_animation();
setTimeout(() => {
this.renderer?.relayout();
this.renderer?.draw_async();
}, 10);
}

if (setting.redrawUI)
this.renderer?.initUI();

if (setting.redraw !== false)
if (setting.redraw !== false && !setting.relayout)
this.renderer?.draw_async();

if (this.renderer?.get_in_vscode())
Expand Down

0 comments on commit d981c3e

Please sign in to comment.