@yuneta/gobj-ui 7.23.144 → 7.23.146

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/README.md CHANGED
@@ -1664,6 +1664,15 @@ forwards them as `EV_SET_HIDDEN_TOPICS`, `EV_SET_MAIN_TOPIC`,
1664
1664
  `main topic`, `highlight topic`, `loose records`, `hidden topics`; `legend`
1665
1665
  is no longer used.
1666
1666
 
1667
+ **The layout select has a stepper beside it** (`7.23.146`): ▲ and ▼ step to
1668
+ the layout before or after the current one, in the order the engine offers
1669
+ them (`layout_names`), without opening the list. Layouts are picked by trying
1670
+ them one after another, and a list closes on every pick. The stepper reads the
1671
+ layout the engine is USING (its `layout` attr, which `auto_layout` can set),
1672
+ not the persisted choice, and disables the button at each end of the list. A
1673
+ press is `EV_STEP_LAYOUT {step}` (internal), which sends `EV_SET_LAYOUT` with
1674
+ the neighbour. Consumer i18n keys: `previous layout`, `next layout`.
1675
+
1667
1676
  **The main topic's chip is not a disabled button** (`7.23.88`): it cannot be
1668
1677
  hidden, so its body is a `div` wearing the `.button` skin — bold, at full
1669
1678
  strength, with a gold star — and not a toggle painted at Bulma's half
@@ -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
  /************************************************************
@@ -64442,6 +64485,40 @@ function refresh_fold_level(gobj) {
64442
64485
  if ($collapse) $collapse.disabled = !(levels && level > 1);
64443
64486
  if ($expand) $expand.disabled = !(levels && level < levels);
64444
64487
  }
64488
+ function layout_step_button(gobj, cls, icon, key, step) {
64489
+ return [
64490
+ "button",
64491
+ {
64492
+ class: `${cls} button`,
64493
+ type: "button",
64494
+ style: {
64495
+ height: (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "wide"),
64496
+ width: "2.5em"
64497
+ },
64498
+ disabled: true,
64499
+ title: (0, i18next.t)(key),
64500
+ "data-i18n-title": key,
64501
+ "aria-label": (0, i18next.t)(key),
64502
+ "data-i18n-aria-label": key
64503
+ },
64504
+ yui_toolbar_icon(icon),
64505
+ { click: (evt) => {
64506
+ evt.stopPropagation();
64507
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_STEP_LAYOUT", { step }, gobj);
64508
+ } }
64509
+ ];
64510
+ }
64511
+ function refresh_layout_stepper(gobj) {
64512
+ let priv = gobj.priv;
64513
+ let $container = priv.$container;
64514
+ if (!$container || !priv.gobj_nodes_tree) return;
64515
+ let names = (0, _yuneta_gobj_js.gobj_read_attr)(priv.gobj_nodes_tree, "layout_names") || [];
64516
+ let index = names.indexOf((0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout"));
64517
+ let $prev = $container.querySelector(".GRAPH_LAYOUT_PREV");
64518
+ let $next = $container.querySelector(".GRAPH_LAYOUT_NEXT");
64519
+ if ($prev) $prev.disabled = !(index > 0);
64520
+ if ($next) $next.disabled = !(index >= 0 && index < names.length - 1);
64521
+ }
64445
64522
  function make_toolbar(gobj) {
64446
64523
  let priv = gobj.priv;
64447
64524
  let modes = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "operation_modes");
@@ -64479,6 +64556,14 @@ function make_toolbar(gobj) {
64479
64556
  (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_LAYOUT", { layout: evt.target.value }, gobj);
64480
64557
  } }
64481
64558
  ],
64559
+ [
64560
+ "div",
64561
+ {
64562
+ class: "GRAPH_LAYOUT_STEPPER buttons has-addons",
64563
+ style: "margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
64564
+ },
64565
+ [layout_step_button(gobj, "GRAPH_LAYOUT_PREV", "yi-chevron-up", "previous layout", -1), layout_step_button(gobj, "GRAPH_LAYOUT_NEXT", "yi-chevron-down", "next layout", 1)]
64566
+ ],
64482
64567
  [
64483
64568
  "span",
64484
64569
  {
@@ -64825,6 +64910,7 @@ function populate_nodes_tree_options(gobj) {
64825
64910
  }
64826
64911
  let current_layout = (0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout");
64827
64912
  if (current_layout) $layout_select.value = current_layout;
64913
+ refresh_layout_stepper(gobj);
64828
64914
  }
64829
64915
  let $operation_mode_select = $container.querySelector(".GRAPH_MODE_SELECT");
64830
64916
  $operation_mode_select.value = priv.operation_mode;
@@ -65517,6 +65603,25 @@ function ac_set_layout(gobj, event, kw, src) {
65517
65603
  let $layout_select = priv.$container.querySelector(".GRAPH_LAYOUT_SELECT");
65518
65604
  $layout_select.value = priv.layout;
65519
65605
  (0, _yuneta_gobj_js.gobj_send_event)(priv.gobj_nodes_tree, "EV_SET_LAYOUT", { layout }, gobj);
65606
+ refresh_layout_stepper(gobj);
65607
+ return 0;
65608
+ }
65609
+ /************************************************************
65610
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
65611
+ * layout before or after the one the engine is using, in the order
65612
+ * it offers them. The buttons are disabled at the ends, so a step
65613
+ * out of the list is a sender that did not read them.
65614
+ ************************************************************/
65615
+ function ac_step_layout(gobj, event, kw, src) {
65616
+ let priv = gobj.priv;
65617
+ let step = kw && kw.step || 0;
65618
+ let names = (0, _yuneta_gobj_js.gobj_read_attr)(priv.gobj_nodes_tree, "layout_names") || [];
65619
+ let index = names.indexOf((0, _yuneta_gobj_js.gobj_read_str_attr)(priv.gobj_nodes_tree, "layout")) + step;
65620
+ if (step === 0 || index < 0 || index >= names.length) {
65621
+ (0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: layout step ${step} is out of the list`);
65622
+ return -1;
65623
+ }
65624
+ (0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_SET_LAYOUT", { layout: names[index] }, gobj);
65520
65625
  return 0;
65521
65626
  }
65522
65627
  /************************************************************
@@ -65849,6 +65954,7 @@ function ac_layout_autoset(gobj, event, kw, src) {
65849
65954
  let layout = kw && kw.layout || "";
65850
65955
  if (!$select || !layout) return 0;
65851
65956
  $select.value = layout;
65957
+ refresh_layout_stepper(gobj);
65852
65958
  return 0;
65853
65959
  }
65854
65960
  /************************************************************
@@ -66125,6 +66231,11 @@ function create_gclass$3(gclass_name) {
66125
66231
  ac_set_layout,
66126
66232
  null
66127
66233
  ],
66234
+ [
66235
+ "EV_STEP_LAYOUT",
66236
+ ac_step_layout,
66237
+ null
66238
+ ],
66128
66239
  [
66129
66240
  "EV_SET_OPERATION_MODE",
66130
66241
  ac_set_operation_mode,
@@ -66229,6 +66340,7 @@ function create_gclass$3(gclass_name) {
66229
66340
  ["EV_RUN_NODE", 0],
66230
66341
  ["EV_CLOSE_WINDOW", 0],
66231
66342
  ["EV_SET_LAYOUT", 0],
66343
+ ["EV_STEP_LAYOUT", 0],
66232
66344
  ["EV_SET_OPERATION_MODE", 0],
66233
66345
  ["EV_SET_FOCUS_TOPIC", 0],
66234
66346
  ["EV_FIND_NODES", 0],
@@ -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
  /************************************************************
@@ -64437,6 +64480,40 @@ function refresh_fold_level(gobj) {
64437
64480
  if ($collapse) $collapse.disabled = !(levels && level > 1);
64438
64481
  if ($expand) $expand.disabled = !(levels && level < levels);
64439
64482
  }
64483
+ function layout_step_button(gobj, cls, icon, key, step) {
64484
+ return [
64485
+ "button",
64486
+ {
64487
+ class: `${cls} button`,
64488
+ type: "button",
64489
+ style: {
64490
+ height: gobj_read_str_attr(gobj, "wide"),
64491
+ width: "2.5em"
64492
+ },
64493
+ disabled: true,
64494
+ title: t(key),
64495
+ "data-i18n-title": key,
64496
+ "aria-label": t(key),
64497
+ "data-i18n-aria-label": key
64498
+ },
64499
+ yui_toolbar_icon(icon),
64500
+ { click: (evt) => {
64501
+ evt.stopPropagation();
64502
+ gobj_send_event(gobj, "EV_STEP_LAYOUT", { step }, gobj);
64503
+ } }
64504
+ ];
64505
+ }
64506
+ function refresh_layout_stepper(gobj) {
64507
+ let priv = gobj.priv;
64508
+ let $container = priv.$container;
64509
+ if (!$container || !priv.gobj_nodes_tree) return;
64510
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
64511
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout"));
64512
+ let $prev = $container.querySelector(".GRAPH_LAYOUT_PREV");
64513
+ let $next = $container.querySelector(".GRAPH_LAYOUT_NEXT");
64514
+ if ($prev) $prev.disabled = !(index > 0);
64515
+ if ($next) $next.disabled = !(index >= 0 && index < names.length - 1);
64516
+ }
64440
64517
  function make_toolbar(gobj) {
64441
64518
  let priv = gobj.priv;
64442
64519
  let modes = gobj_read_attr(gobj, "operation_modes");
@@ -64474,6 +64551,14 @@ function make_toolbar(gobj) {
64474
64551
  gobj_send_event(gobj, "EV_SET_LAYOUT", { layout: evt.target.value }, gobj);
64475
64552
  } }
64476
64553
  ],
64554
+ [
64555
+ "div",
64556
+ {
64557
+ class: "GRAPH_LAYOUT_STEPPER buttons has-addons",
64558
+ style: "margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;"
64559
+ },
64560
+ [layout_step_button(gobj, "GRAPH_LAYOUT_PREV", "yi-chevron-up", "previous layout", -1), layout_step_button(gobj, "GRAPH_LAYOUT_NEXT", "yi-chevron-down", "next layout", 1)]
64561
+ ],
64477
64562
  [
64478
64563
  "span",
64479
64564
  {
@@ -64820,6 +64905,7 @@ function populate_nodes_tree_options(gobj) {
64820
64905
  }
64821
64906
  let current_layout = gobj_read_str_attr(priv.gobj_nodes_tree, "layout");
64822
64907
  if (current_layout) $layout_select.value = current_layout;
64908
+ refresh_layout_stepper(gobj);
64823
64909
  }
64824
64910
  let $operation_mode_select = $container.querySelector(".GRAPH_MODE_SELECT");
64825
64911
  $operation_mode_select.value = priv.operation_mode;
@@ -65512,6 +65598,25 @@ function ac_set_layout(gobj, event, kw, src) {
65512
65598
  let $layout_select = priv.$container.querySelector(".GRAPH_LAYOUT_SELECT");
65513
65599
  $layout_select.value = priv.layout;
65514
65600
  gobj_send_event(priv.gobj_nodes_tree, "EV_SET_LAYOUT", { layout }, gobj);
65601
+ refresh_layout_stepper(gobj);
65602
+ return 0;
65603
+ }
65604
+ /************************************************************
65605
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
65606
+ * layout before or after the one the engine is using, in the order
65607
+ * it offers them. The buttons are disabled at the ends, so a step
65608
+ * out of the list is a sender that did not read them.
65609
+ ************************************************************/
65610
+ function ac_step_layout(gobj, event, kw, src) {
65611
+ let priv = gobj.priv;
65612
+ let step = kw && kw.step || 0;
65613
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
65614
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout")) + step;
65615
+ if (step === 0 || index < 0 || index >= names.length) {
65616
+ log_error(`${gobj_short_name(gobj)}: layout step ${step} is out of the list`);
65617
+ return -1;
65618
+ }
65619
+ gobj_send_event(gobj, "EV_SET_LAYOUT", { layout: names[index] }, gobj);
65515
65620
  return 0;
65516
65621
  }
65517
65622
  /************************************************************
@@ -65844,6 +65949,7 @@ function ac_layout_autoset(gobj, event, kw, src) {
65844
65949
  let layout = kw && kw.layout || "";
65845
65950
  if (!$select || !layout) return 0;
65846
65951
  $select.value = layout;
65952
+ refresh_layout_stepper(gobj);
65847
65953
  return 0;
65848
65954
  }
65849
65955
  /************************************************************
@@ -66120,6 +66226,11 @@ function create_gclass$3(gclass_name) {
66120
66226
  ac_set_layout,
66121
66227
  null
66122
66228
  ],
66229
+ [
66230
+ "EV_STEP_LAYOUT",
66231
+ ac_step_layout,
66232
+ null
66233
+ ],
66123
66234
  [
66124
66235
  "EV_SET_OPERATION_MODE",
66125
66236
  ac_set_operation_mode,
@@ -66224,6 +66335,7 @@ function create_gclass$3(gclass_name) {
66224
66335
  ["EV_RUN_NODE", 0],
66225
66336
  ["EV_CLOSE_WINDOW", 0],
66226
66337
  ["EV_SET_LAYOUT", 0],
66338
+ ["EV_STEP_LAYOUT", 0],
66227
66339
  ["EV_SET_OPERATION_MODE", 0],
66228
66340
  ["EV_SET_FOCUS_TOPIC", 0],
66229
66341
  ["EV_FIND_NODES", 0],
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.146",
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
  }
@@ -783,6 +783,48 @@ function refresh_fold_level(gobj)
783
783
  }
784
784
  }
785
785
 
786
+ /* A button of the layout stepper: the layout before (`step` -1) or
787
+ * after (+1) the current one, in the order the engine offers them. */
788
+ function layout_step_button(gobj, cls, icon, key, step)
789
+ {
790
+ return ['button', {class: `${cls} button`, type: 'button',
791
+ style: {height: gobj_read_str_attr(gobj, "wide"), width: '2.5em'},
792
+ disabled: true,
793
+ title: t(key), 'data-i18n-title': key,
794
+ 'aria-label': t(key), 'data-i18n-aria-label': key},
795
+ yui_toolbar_icon(icon),
796
+ {
797
+ click: (evt) => {
798
+ evt.stopPropagation();
799
+ gobj_send_event(gobj, "EV_STEP_LAYOUT", {step: step}, gobj);
800
+ }
801
+ }
802
+ ];
803
+ }
804
+
805
+ /* Paint the layout stepper from the layout the engine is USING: it can
806
+ * differ from the persisted choice (auto_layout picks one for a treedb
807
+ * nobody arranged). The ends of the list disable their button. */
808
+ function refresh_layout_stepper(gobj)
809
+ {
810
+ let priv = gobj.priv;
811
+ let $container = priv.$container;
812
+ if(!$container || !priv.gobj_nodes_tree) {
813
+ return;
814
+ }
815
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
816
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout"));
817
+
818
+ let $prev = $container.querySelector('.GRAPH_LAYOUT_PREV');
819
+ let $next = $container.querySelector('.GRAPH_LAYOUT_NEXT');
820
+ if($prev) {
821
+ $prev.disabled = !(index > 0);
822
+ }
823
+ if($next) {
824
+ $next.disabled = !(index >= 0 && index < names.length - 1);
825
+ }
826
+ }
827
+
786
828
  function make_toolbar(gobj)
787
829
  {
788
830
  let priv = gobj.priv;
@@ -833,6 +875,15 @@ function make_toolbar(gobj)
833
875
  gobj_send_event(gobj, "EV_SET_LAYOUT", {layout: evt.target.value}, gobj);
834
876
  }
835
877
  }],
878
+ /* One step up or down the list without opening it: layouts are
879
+ * picked by trying them one after another, and a list closes on
880
+ * every pick. Born disabled, like the fold stepper: the options
881
+ * arrive with the child (populate_nodes_tree_options). */
882
+ ['div', {class: 'GRAPH_LAYOUT_STEPPER buttons has-addons',
883
+ style: 'margin:0 0 0 .25rem; flex:0 0 auto; flex-wrap:nowrap; align-items:stretch;'}, [
884
+ layout_step_button(gobj, 'GRAPH_LAYOUT_PREV', 'yi-chevron-up', 'previous layout', -1),
885
+ layout_step_button(gobj, 'GRAPH_LAYOUT_NEXT', 'yi-chevron-down', 'next layout', 1),
886
+ ]],
836
887
 
837
888
  ['span', {class: 'GRAPH_MODE_LABEL is-hidden-mobile', style: 'padding-left:10px; padding-right:5px;', i18n: 'operation mode'}, 'operation mode'],
838
889
  ['div', {class: 'select'}, [
@@ -1264,6 +1315,7 @@ function populate_nodes_tree_options(gobj)
1264
1315
  if(current_layout) {
1265
1316
  $layout_select.value = current_layout;
1266
1317
  }
1318
+ refresh_layout_stepper(gobj);
1267
1319
  }
1268
1320
 
1269
1321
  // Restore persisted operation_mode selection
@@ -2558,7 +2610,30 @@ function ac_set_layout(gobj, event, kw, src)
2558
2610
  },
2559
2611
  gobj
2560
2612
  );
2613
+ refresh_layout_stepper(gobj);
2614
+
2615
+ return 0;
2616
+ }
2617
+
2618
+ /************************************************************
2619
+ * One press of the layout stepper (EV_STEP_LAYOUT {step}): the
2620
+ * layout before or after the one the engine is using, in the order
2621
+ * it offers them. The buttons are disabled at the ends, so a step
2622
+ * out of the list is a sender that did not read them.
2623
+ ************************************************************/
2624
+ function ac_step_layout(gobj, event, kw, src)
2625
+ {
2626
+ let priv = gobj.priv;
2627
+
2628
+ let step = (kw && kw.step) || 0;
2629
+ let names = gobj_read_attr(priv.gobj_nodes_tree, "layout_names") || [];
2630
+ let index = names.indexOf(gobj_read_str_attr(priv.gobj_nodes_tree, "layout")) + step;
2631
+ if(step === 0 || index < 0 || index >= names.length) {
2632
+ log_error(`${gobj_short_name(gobj)}: layout step ${step} is out of the list`);
2633
+ return -1;
2634
+ }
2561
2635
 
2636
+ gobj_send_event(gobj, "EV_SET_LAYOUT", {layout: names[index]}, gobj);
2562
2637
  return 0;
2563
2638
  }
2564
2639
 
@@ -3037,6 +3112,7 @@ function ac_layout_autoset(gobj, event, kw, src)
3037
3112
  return 0;
3038
3113
  }
3039
3114
  $select.value = layout;
3115
+ refresh_layout_stepper(gobj);
3040
3116
  return 0;
3041
3117
  }
3042
3118
 
@@ -3308,6 +3384,7 @@ function create_gclass(gclass_name)
3308
3384
  ["EV_RUN_NODE", ac_run_node, null],
3309
3385
  ["EV_CLOSE_WINDOW", ac_close_window, null],
3310
3386
  ["EV_SET_LAYOUT", ac_set_layout, null],
3387
+ ["EV_STEP_LAYOUT", ac_step_layout, null],
3311
3388
  ["EV_SET_OPERATION_MODE", ac_set_operation_mode, null],
3312
3389
  ["EV_SET_FOCUS_TOPIC", ac_set_focus_topic, null],
3313
3390
  ["EV_FIND_NODES", ac_find_nodes, null],
@@ -3353,6 +3430,7 @@ function create_gclass(gclass_name)
3353
3430
  ["EV_RUN_NODE", 0],
3354
3431
  ["EV_CLOSE_WINDOW", 0],
3355
3432
  ["EV_SET_LAYOUT", 0],
3433
+ ["EV_STEP_LAYOUT", 0],
3356
3434
  ["EV_SET_OPERATION_MODE", 0],
3357
3435
  ["EV_SET_FOCUS_TOPIC", 0],
3358
3436
  ["EV_FIND_NODES", 0],