@yuneta/gobj-ui 7.23.144 → 7.23.145

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.
@@ -60735,6 +60735,23 @@ function auto_layout(gobj) {
60735
60735
  return true;
60736
60736
  }
60737
60737
  /************************************************************
60738
+ * Paint the minimap again from where the nodes are NOW.
60739
+ *
60740
+ * It repaints off the graph's draw events, and a layout emits none:
60741
+ * G6 moves the nodes with a SILENT draw. So after a layout change
60742
+ * the minimap went on showing the arrangement before it.
60743
+ ************************************************************/
60744
+ function repaint_minimap(gobj) {
60745
+ let plugin = graph_get_plugin(gobj, "minimap");
60746
+ if (!plugin || plugin.destroyed) return;
60747
+ try {
60748
+ plugin.renderMinimap();
60749
+ plugin.renderMask();
60750
+ } catch (e) {
60751
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: repaint_minimap failed: ${e}`);
60752
+ }
60753
+ }
60754
+ /************************************************************
60738
60755
  * Show or hide the minimap, deciding by the SIZE of the graph.
60739
60756
  *
60740
60757
  * A minimap of a graph that already fits on screen is decoration; one
@@ -62506,7 +62523,10 @@ async function reconcile_fold_apply(gobj, opts, visible) {
62506
62523
  (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: refresh_minimap failed: ${e}`);
62507
62524
  }
62508
62525
  await graph_draw(gobj);
62509
- if (changed || opts.relayout) await graph_layout(gobj);
62526
+ if (changed || opts.relayout) {
62527
+ await graph_layout(gobj);
62528
+ repaint_minimap(gobj);
62529
+ }
62510
62530
  if (!(opts.restore && await restore_camera(gobj))) {
62511
62531
  if (opts.fit) await graph_fit_readable(gobj);
62512
62532
  else if (opts.keep && opts.keep_vp) await yui_graph_place_at(graph, opts.keep, opts.keep_vp);
@@ -63272,15 +63292,38 @@ function ac_fullscreen(gobj, event, kw, src) {
63272
63292
  }
63273
63293
  /************************************************************
63274
63294
  * Layout change
63295
+ *
63296
+ * A new layout moves EVERY node, so the camera cannot stay on the
63297
+ * coordinates it had: it would look at empty grid where the old
63298
+ * arrangement was. It goes through the reconcile instead, which
63299
+ * holds the node the reader was looking at on the same pixel (the
63300
+ * zoom is kept) and fits only if nothing is left in view.
63275
63301
  ************************************************************/
63276
63302
  function ac_set_layout$1(gobj, event, kw, src) {
63277
- gobj.priv;
63303
+ let priv = gobj.priv;
63304
+ let graph = priv.graph;
63278
63305
  let layout = select_layout(gobj, kw.layout);
63306
+ priv._layout_asked = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "layout");
63279
63307
  apply_layout_direction(gobj);
63280
- graph_set_layout(gobj, layout).then(() => {
63308
+ let done = () => {
63281
63309
  configure_behaviour(gobj);
63282
63310
  update_toolbar(gobj);
63283
- });
63311
+ };
63312
+ if (!priv._fold_model || !graph || !graph.rendered) {
63313
+ graph_set_layout(gobj, layout).then(() => {
63314
+ repaint_minimap(gobj);
63315
+ done();
63316
+ });
63317
+ return 0;
63318
+ }
63319
+ let keep = camera_anchor_node(gobj);
63320
+ let vp = keep ? yui_graph_viewport_of(graph, keep) : null;
63321
+ graph.setLayout(layout);
63322
+ reconcile_fold(gobj, {
63323
+ relayout: true,
63324
+ keep,
63325
+ keep_vp: vp
63326
+ }).then(done);
63284
63327
  return 0;
63285
63328
  }
63286
63329
  /************************************************************
@@ -60730,6 +60730,23 @@ function auto_layout(gobj) {
60730
60730
  return true;
60731
60731
  }
60732
60732
  /************************************************************
60733
+ * Paint the minimap again from where the nodes are NOW.
60734
+ *
60735
+ * It repaints off the graph's draw events, and a layout emits none:
60736
+ * G6 moves the nodes with a SILENT draw. So after a layout change
60737
+ * the minimap went on showing the arrangement before it.
60738
+ ************************************************************/
60739
+ function repaint_minimap(gobj) {
60740
+ let plugin = graph_get_plugin(gobj, "minimap");
60741
+ if (!plugin || plugin.destroyed) return;
60742
+ try {
60743
+ plugin.renderMinimap();
60744
+ plugin.renderMask();
60745
+ } catch (e) {
60746
+ log_error(`${gobj_short_name(gobj)}: repaint_minimap failed: ${e}`);
60747
+ }
60748
+ }
60749
+ /************************************************************
60733
60750
  * Show or hide the minimap, deciding by the SIZE of the graph.
60734
60751
  *
60735
60752
  * A minimap of a graph that already fits on screen is decoration; one
@@ -62501,7 +62518,10 @@ async function reconcile_fold_apply(gobj, opts, visible) {
62501
62518
  log_error(`${gobj_short_name(gobj)}: refresh_minimap failed: ${e}`);
62502
62519
  }
62503
62520
  await graph_draw(gobj);
62504
- if (changed || opts.relayout) await graph_layout(gobj);
62521
+ if (changed || opts.relayout) {
62522
+ await graph_layout(gobj);
62523
+ repaint_minimap(gobj);
62524
+ }
62505
62525
  if (!(opts.restore && await restore_camera(gobj))) {
62506
62526
  if (opts.fit) await graph_fit_readable(gobj);
62507
62527
  else if (opts.keep && opts.keep_vp) await yui_graph_place_at(graph, opts.keep, opts.keep_vp);
@@ -63267,15 +63287,38 @@ function ac_fullscreen(gobj, event, kw, src) {
63267
63287
  }
63268
63288
  /************************************************************
63269
63289
  * Layout change
63290
+ *
63291
+ * A new layout moves EVERY node, so the camera cannot stay on the
63292
+ * coordinates it had: it would look at empty grid where the old
63293
+ * arrangement was. It goes through the reconcile instead, which
63294
+ * holds the node the reader was looking at on the same pixel (the
63295
+ * zoom is kept) and fits only if nothing is left in view.
63270
63296
  ************************************************************/
63271
63297
  function ac_set_layout$1(gobj, event, kw, src) {
63272
- gobj.priv;
63298
+ let priv = gobj.priv;
63299
+ let graph = priv.graph;
63273
63300
  let layout = select_layout(gobj, kw.layout);
63301
+ priv._layout_asked = gobj_read_str_attr(gobj, "layout");
63274
63302
  apply_layout_direction(gobj);
63275
- graph_set_layout(gobj, layout).then(() => {
63303
+ let done = () => {
63276
63304
  configure_behaviour(gobj);
63277
63305
  update_toolbar(gobj);
63278
- });
63306
+ };
63307
+ if (!priv._fold_model || !graph || !graph.rendered) {
63308
+ graph_set_layout(gobj, layout).then(() => {
63309
+ repaint_minimap(gobj);
63310
+ done();
63311
+ });
63312
+ return 0;
63313
+ }
63314
+ let keep = camera_anchor_node(gobj);
63315
+ let vp = keep ? yui_graph_viewport_of(graph, keep) : null;
63316
+ graph.setLayout(layout);
63317
+ reconcile_fold(gobj, {
63318
+ relayout: true,
63319
+ keep,
63320
+ keep_vp: vp
63321
+ }).then(done);
63279
63322
  return 0;
63280
63323
  }
63281
63324
  /************************************************************
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.23.144",
3
+ "version": "7.23.145",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -7124,6 +7124,27 @@ function auto_layout(gobj)
7124
7124
  return true;
7125
7125
  }
7126
7126
 
7127
+ /************************************************************
7128
+ * Paint the minimap again from where the nodes are NOW.
7129
+ *
7130
+ * It repaints off the graph's draw events, and a layout emits none:
7131
+ * G6 moves the nodes with a SILENT draw. So after a layout change
7132
+ * the minimap went on showing the arrangement before it.
7133
+ ************************************************************/
7134
+ function repaint_minimap(gobj)
7135
+ {
7136
+ let plugin = graph_get_plugin(gobj, "minimap");
7137
+ if(!plugin || plugin.destroyed) {
7138
+ return;
7139
+ }
7140
+ try {
7141
+ plugin.renderMinimap();
7142
+ plugin.renderMask();
7143
+ } catch(e) {
7144
+ log_error(`${gobj_short_name(gobj)}: repaint_minimap failed: ${e}`);
7145
+ }
7146
+ }
7147
+
7127
7148
  /************************************************************
7128
7149
  * Show or hide the minimap, deciding by the SIZE of the graph.
7129
7150
  *
@@ -9772,6 +9793,7 @@ async function reconcile_fold_apply(gobj, opts, visible)
9772
9793
  await graph_draw(gobj);
9773
9794
  if(changed || opts.relayout) {
9774
9795
  await graph_layout(gobj);
9796
+ repaint_minimap(gobj);
9775
9797
  }
9776
9798
 
9777
9799
  /* THE VIEWPORT, and only here.
@@ -10924,18 +10946,44 @@ function ac_fullscreen(gobj, event, kw, src)
10924
10946
 
10925
10947
  /************************************************************
10926
10948
  * Layout change
10949
+ *
10950
+ * A new layout moves EVERY node, so the camera cannot stay on the
10951
+ * coordinates it had: it would look at empty grid where the old
10952
+ * arrangement was. It goes through the reconcile instead, which
10953
+ * holds the node the reader was looking at on the same pixel (the
10954
+ * zoom is kept) and fits only if nothing is left in view.
10927
10955
  ************************************************************/
10928
10956
  function ac_set_layout(gobj, event, kw, src)
10929
10957
  {
10930
10958
  let priv = gobj.priv;
10959
+ let graph = priv.graph;
10931
10960
  let layout = select_layout(gobj, kw.layout);
10961
+
10962
+ /* The reader chose it: a later load must not auto-lay it back. */
10963
+ priv._layout_asked = gobj_read_str_attr(gobj, "layout");
10964
+
10932
10965
  /* The ports turn with the reading direction, before the lines
10933
10966
  * are laid out from them. */
10934
10967
  apply_layout_direction(gobj);
10935
- graph_set_layout(gobj, layout).then(() => {
10968
+
10969
+ let done = () => {
10936
10970
  configure_behaviour(gobj);
10937
10971
  update_toolbar(gobj);
10938
- });
10972
+ };
10973
+
10974
+ if(!priv._fold_model || !graph || !graph.rendered) {
10975
+ /* No records yet: nothing on screen to hold still. */
10976
+ graph_set_layout(gobj, layout).then(() => {
10977
+ repaint_minimap(gobj);
10978
+ done();
10979
+ });
10980
+ return 0;
10981
+ }
10982
+
10983
+ let keep = camera_anchor_node(gobj);
10984
+ let vp = keep? yui_graph_viewport_of(graph, keep) : null;
10985
+ graph.setLayout(layout);
10986
+ reconcile_fold(gobj, {relayout: true, keep: keep, keep_vp: vp}).then(done);
10939
10987
 
10940
10988
  return 0;
10941
10989
  }