@yuneta/gobj-ui 7.4.5 → 7.5.1
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/gobj-ui.cjs.js +79 -1
- package/dist/gobj-ui.es.js +79 -1
- package/package.json +1 -1
- package/src/c_g6_nodes_tree.js +93 -0
- package/src/c_yui_treedb_graph.js +23 -0
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -19971,6 +19971,21 @@ function ac_legend_topic(gobj, event, kw, src) {
|
|
|
19971
19971
|
return 0;
|
|
19972
19972
|
}
|
|
19973
19973
|
/************************************************************
|
|
19974
|
+
* The child chose a layout for a treedb nobody has arranged yet.
|
|
19975
|
+
* Only the SELECT is moved: the pick is a default, not the user's
|
|
19976
|
+
* choice, so it is not persisted — the day somebody drags a node the
|
|
19977
|
+
* saved geometry exists and `manual` is right again.
|
|
19978
|
+
************************************************************/
|
|
19979
|
+
function ac_layout_autoset(gobj, event, kw, src) {
|
|
19980
|
+
let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
|
|
19981
|
+
if (!$container) return 0;
|
|
19982
|
+
let $select = $container.querySelector(".GRAPH_LAYOUT_SELECT");
|
|
19983
|
+
let layout = kw && kw.layout || "";
|
|
19984
|
+
if (!$select || !layout) return 0;
|
|
19985
|
+
$select.value = layout;
|
|
19986
|
+
return 0;
|
|
19987
|
+
}
|
|
19988
|
+
/************************************************************
|
|
19974
19989
|
* Forward the find down to the graph child.
|
|
19975
19990
|
************************************************************/
|
|
19976
19991
|
function ac_find_nodes$1(gobj, event, kw, src) {
|
|
@@ -20171,6 +20186,11 @@ function create_gclass$4(gclass_name) {
|
|
|
20171
20186
|
ac_find_nodes$1,
|
|
20172
20187
|
null
|
|
20173
20188
|
],
|
|
20189
|
+
[
|
|
20190
|
+
"EV_LAYOUT_AUTOSET",
|
|
20191
|
+
ac_layout_autoset,
|
|
20192
|
+
null
|
|
20193
|
+
],
|
|
20174
20194
|
[
|
|
20175
20195
|
"EV_TOGGLE_LEGEND",
|
|
20176
20196
|
ac_toggle_legend,
|
|
@@ -20229,6 +20249,7 @@ function create_gclass$4(gclass_name) {
|
|
|
20229
20249
|
["EV_SET_FOCUS_TOPIC", 0],
|
|
20230
20250
|
["EV_FIND_NODES", 0],
|
|
20231
20251
|
["EV_FIND_RESULT", 0],
|
|
20252
|
+
["EV_LAYOUT_AUTOSET", 0],
|
|
20232
20253
|
["EV_TOGGLE_LEGEND", 0],
|
|
20233
20254
|
["EV_LEGEND_TOPIC", 0],
|
|
20234
20255
|
["EV_TOPIC_SELECTED", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT | _yuneta_gobj_js.event_flag_t.EVF_NO_WARN_SUBS],
|
|
@@ -52901,7 +52922,8 @@ var PRIVATE_DATA$1 = {
|
|
|
52901
52922
|
_focus_topic: null,
|
|
52902
52923
|
_focus_ids: [],
|
|
52903
52924
|
_pending_focus_topic: null,
|
|
52904
|
-
_pending_find: null
|
|
52925
|
+
_pending_find: null,
|
|
52926
|
+
_layout_asked: ""
|
|
52905
52927
|
};
|
|
52906
52928
|
var __gclass__$1 = null;
|
|
52907
52929
|
/******************************
|
|
@@ -52912,6 +52934,7 @@ var __gclass__$1 = null;
|
|
|
52912
52934
|
***************************************************************/
|
|
52913
52935
|
function mt_create$1(gobj) {
|
|
52914
52936
|
let priv = gobj.priv;
|
|
52937
|
+
priv._layout_asked = (0, _yuneta_gobj_js.gobj_read_str_attr)(gobj, "layout") || "";
|
|
52915
52938
|
let subscriber = (0, _yuneta_gobj_js.gobj_read_pointer_attr)(gobj, "subscriber");
|
|
52916
52939
|
if (!subscriber) subscriber = (0, _yuneta_gobj_js.gobj_parent)(gobj);
|
|
52917
52940
|
(0, _yuneta_gobj_js.gobj_subscribe_event)(gobj, null, {}, subscriber);
|
|
@@ -55678,6 +55701,55 @@ function show_node_detail_popover(gobj, node_id) {
|
|
|
55678
55701
|
* junction diamonds get their neutral fill/stroke re-themed.
|
|
55679
55702
|
************************************************************/
|
|
55680
55703
|
/************************************************************
|
|
55704
|
+
* Has anybody ever PLACED a node of this treedb?
|
|
55705
|
+
*
|
|
55706
|
+
* Saved positions live in `__graphs__` (per topic, per node) and, on
|
|
55707
|
+
* older data, in a `_geometry` on the record itself. Both are read.
|
|
55708
|
+
************************************************************/
|
|
55709
|
+
function has_saved_geometry(gobj) {
|
|
55710
|
+
let priv = gobj.priv;
|
|
55711
|
+
for (let topic of Object.keys(priv._graph_properties || {})) {
|
|
55712
|
+
let props = priv._graph_properties[topic];
|
|
55713
|
+
if (props && (0, _yuneta_gobj_js.is_object)(props.nodes) && Object.keys(props.nodes).length > 0) return true;
|
|
55714
|
+
}
|
|
55715
|
+
for (let topic of Object.keys(priv.records || {})) {
|
|
55716
|
+
let records = priv.records[topic];
|
|
55717
|
+
if (!(0, _yuneta_gobj_js.is_array)(records)) continue;
|
|
55718
|
+
for (let record of records) if (record && (0, _yuneta_gobj_js.is_object)(record._geometry)) return true;
|
|
55719
|
+
}
|
|
55720
|
+
return false;
|
|
55721
|
+
}
|
|
55722
|
+
/************************************************************
|
|
55723
|
+
* Choose a layout for a treedb nobody has arranged yet.
|
|
55724
|
+
*
|
|
55725
|
+
* `manual` means "leave every node where it was put", and where none
|
|
55726
|
+
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
55727
|
+
* together, so a treedb opened for the first time was a diagonal pile
|
|
55728
|
+
* of cards — 126 of them on a real one — and the only way out was to
|
|
55729
|
+
* know to pick a layout by hand. It is the right default only once
|
|
55730
|
+
* there ARE saved positions to leave alone.
|
|
55731
|
+
*
|
|
55732
|
+
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
|
55733
|
+
* is deliberately NOT persisted — it is a default, not a choice, and
|
|
55734
|
+
* the moment the user drags one node the geometry exists and `manual`
|
|
55735
|
+
* becomes right again by itself.
|
|
55736
|
+
************************************************************/
|
|
55737
|
+
function auto_layout(gobj) {
|
|
55738
|
+
let priv = gobj.priv;
|
|
55739
|
+
if (priv._layout_asked) return;
|
|
55740
|
+
if (has_saved_geometry(gobj)) return;
|
|
55741
|
+
if (!priv.graph) return;
|
|
55742
|
+
let name = "dagre";
|
|
55743
|
+
(0, _yuneta_gobj_js.gobj_write_attr)(gobj, "layout", name);
|
|
55744
|
+
try {
|
|
55745
|
+
priv.graph.setLayout(_layouts[name]);
|
|
55746
|
+
} catch (e) {
|
|
55747
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: cannot set the '${name}' layout: ${e}`);
|
|
55748
|
+
return;
|
|
55749
|
+
}
|
|
55750
|
+
(0, _yuneta_gobj_js.gobj_publish_event)(gobj, "EV_LAYOUT_AUTOSET", { layout: name });
|
|
55751
|
+
}
|
|
55752
|
+
/************************************************************
|
|
55681
55753
|
* Show or hide the minimap, deciding by the SIZE of the graph.
|
|
55682
55754
|
*
|
|
55683
55755
|
* A minimap of a graph that already fits on screen is decoration; one
|
|
@@ -56532,6 +56604,11 @@ function ac_load_data(gobj, event, kw, src) {
|
|
|
56532
56604
|
graph_draw(gobj).then(() => {
|
|
56533
56605
|
create_links(gobj);
|
|
56534
56606
|
graph_draw(gobj).then(() => {
|
|
56607
|
+
try {
|
|
56608
|
+
auto_layout(gobj);
|
|
56609
|
+
} catch (e) {
|
|
56610
|
+
(0, _yuneta_gobj_js.log_error)(`${(0, _yuneta_gobj_js.gobj_short_name)(gobj)}: auto_layout failed: ${e}`);
|
|
56611
|
+
}
|
|
56535
56612
|
graph_layout(gobj).then(() => {
|
|
56536
56613
|
if (priv.edit_mode) graph_add_plugin(gobj, "history");
|
|
56537
56614
|
else graph_remove_plugin(gobj, "history");
|
|
@@ -57172,6 +57249,7 @@ function create_gclass$1(gclass_name) {
|
|
|
57172
57249
|
["EV_FOCUS_TOPIC", 0],
|
|
57173
57250
|
["EV_FIND_NODES", 0],
|
|
57174
57251
|
["EV_FIND_RESULT", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT],
|
|
57252
|
+
["EV_LAYOUT_AUTOSET", _yuneta_gobj_js.event_flag_t.EVF_OUTPUT_EVENT],
|
|
57175
57253
|
["EV_CENTER", 0],
|
|
57176
57254
|
["EV_FULLSCREEN", 0],
|
|
57177
57255
|
["EV_SET_LAYOUT", 0],
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -19958,6 +19958,21 @@ function ac_legend_topic(gobj, event, kw, src) {
|
|
|
19958
19958
|
return 0;
|
|
19959
19959
|
}
|
|
19960
19960
|
/************************************************************
|
|
19961
|
+
* The child chose a layout for a treedb nobody has arranged yet.
|
|
19962
|
+
* Only the SELECT is moved: the pick is a default, not the user's
|
|
19963
|
+
* choice, so it is not persisted — the day somebody drags a node the
|
|
19964
|
+
* saved geometry exists and `manual` is right again.
|
|
19965
|
+
************************************************************/
|
|
19966
|
+
function ac_layout_autoset(gobj, event, kw, src) {
|
|
19967
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
19968
|
+
if (!$container) return 0;
|
|
19969
|
+
let $select = $container.querySelector(".GRAPH_LAYOUT_SELECT");
|
|
19970
|
+
let layout = kw && kw.layout || "";
|
|
19971
|
+
if (!$select || !layout) return 0;
|
|
19972
|
+
$select.value = layout;
|
|
19973
|
+
return 0;
|
|
19974
|
+
}
|
|
19975
|
+
/************************************************************
|
|
19961
19976
|
* Forward the find down to the graph child.
|
|
19962
19977
|
************************************************************/
|
|
19963
19978
|
function ac_find_nodes$1(gobj, event, kw, src) {
|
|
@@ -20158,6 +20173,11 @@ function create_gclass$4(gclass_name) {
|
|
|
20158
20173
|
ac_find_nodes$1,
|
|
20159
20174
|
null
|
|
20160
20175
|
],
|
|
20176
|
+
[
|
|
20177
|
+
"EV_LAYOUT_AUTOSET",
|
|
20178
|
+
ac_layout_autoset,
|
|
20179
|
+
null
|
|
20180
|
+
],
|
|
20161
20181
|
[
|
|
20162
20182
|
"EV_TOGGLE_LEGEND",
|
|
20163
20183
|
ac_toggle_legend,
|
|
@@ -20216,6 +20236,7 @@ function create_gclass$4(gclass_name) {
|
|
|
20216
20236
|
["EV_SET_FOCUS_TOPIC", 0],
|
|
20217
20237
|
["EV_FIND_NODES", 0],
|
|
20218
20238
|
["EV_FIND_RESULT", 0],
|
|
20239
|
+
["EV_LAYOUT_AUTOSET", 0],
|
|
20219
20240
|
["EV_TOGGLE_LEGEND", 0],
|
|
20220
20241
|
["EV_LEGEND_TOPIC", 0],
|
|
20221
20242
|
["EV_TOPIC_SELECTED", event_flag_t.EVF_OUTPUT_EVENT | event_flag_t.EVF_NO_WARN_SUBS],
|
|
@@ -52888,7 +52909,8 @@ var PRIVATE_DATA$1 = {
|
|
|
52888
52909
|
_focus_topic: null,
|
|
52889
52910
|
_focus_ids: [],
|
|
52890
52911
|
_pending_focus_topic: null,
|
|
52891
|
-
_pending_find: null
|
|
52912
|
+
_pending_find: null,
|
|
52913
|
+
_layout_asked: ""
|
|
52892
52914
|
};
|
|
52893
52915
|
var __gclass__$1 = null;
|
|
52894
52916
|
/******************************
|
|
@@ -52899,6 +52921,7 @@ var __gclass__$1 = null;
|
|
|
52899
52921
|
***************************************************************/
|
|
52900
52922
|
function mt_create$1(gobj) {
|
|
52901
52923
|
let priv = gobj.priv;
|
|
52924
|
+
priv._layout_asked = gobj_read_str_attr(gobj, "layout") || "";
|
|
52902
52925
|
let subscriber = gobj_read_pointer_attr(gobj, "subscriber");
|
|
52903
52926
|
if (!subscriber) subscriber = gobj_parent(gobj);
|
|
52904
52927
|
gobj_subscribe_event(gobj, null, {}, subscriber);
|
|
@@ -55665,6 +55688,55 @@ function show_node_detail_popover(gobj, node_id) {
|
|
|
55665
55688
|
* junction diamonds get their neutral fill/stroke re-themed.
|
|
55666
55689
|
************************************************************/
|
|
55667
55690
|
/************************************************************
|
|
55691
|
+
* Has anybody ever PLACED a node of this treedb?
|
|
55692
|
+
*
|
|
55693
|
+
* Saved positions live in `__graphs__` (per topic, per node) and, on
|
|
55694
|
+
* older data, in a `_geometry` on the record itself. Both are read.
|
|
55695
|
+
************************************************************/
|
|
55696
|
+
function has_saved_geometry(gobj) {
|
|
55697
|
+
let priv = gobj.priv;
|
|
55698
|
+
for (let topic of Object.keys(priv._graph_properties || {})) {
|
|
55699
|
+
let props = priv._graph_properties[topic];
|
|
55700
|
+
if (props && is_object(props.nodes) && Object.keys(props.nodes).length > 0) return true;
|
|
55701
|
+
}
|
|
55702
|
+
for (let topic of Object.keys(priv.records || {})) {
|
|
55703
|
+
let records = priv.records[topic];
|
|
55704
|
+
if (!is_array(records)) continue;
|
|
55705
|
+
for (let record of records) if (record && is_object(record._geometry)) return true;
|
|
55706
|
+
}
|
|
55707
|
+
return false;
|
|
55708
|
+
}
|
|
55709
|
+
/************************************************************
|
|
55710
|
+
* Choose a layout for a treedb nobody has arranged yet.
|
|
55711
|
+
*
|
|
55712
|
+
* `manual` means "leave every node where it was put", and where none
|
|
55713
|
+
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
55714
|
+
* together, so a treedb opened for the first time was a diagonal pile
|
|
55715
|
+
* of cards — 126 of them on a real one — and the only way out was to
|
|
55716
|
+
* know to pick a layout by hand. It is the right default only once
|
|
55717
|
+
* there ARE saved positions to leave alone.
|
|
55718
|
+
*
|
|
55719
|
+
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
|
55720
|
+
* is deliberately NOT persisted — it is a default, not a choice, and
|
|
55721
|
+
* the moment the user drags one node the geometry exists and `manual`
|
|
55722
|
+
* becomes right again by itself.
|
|
55723
|
+
************************************************************/
|
|
55724
|
+
function auto_layout(gobj) {
|
|
55725
|
+
let priv = gobj.priv;
|
|
55726
|
+
if (priv._layout_asked) return;
|
|
55727
|
+
if (has_saved_geometry(gobj)) return;
|
|
55728
|
+
if (!priv.graph) return;
|
|
55729
|
+
let name = "dagre";
|
|
55730
|
+
gobj_write_attr(gobj, "layout", name);
|
|
55731
|
+
try {
|
|
55732
|
+
priv.graph.setLayout(_layouts[name]);
|
|
55733
|
+
} catch (e) {
|
|
55734
|
+
log_error(`${gobj_short_name(gobj)}: cannot set the '${name}' layout: ${e}`);
|
|
55735
|
+
return;
|
|
55736
|
+
}
|
|
55737
|
+
gobj_publish_event(gobj, "EV_LAYOUT_AUTOSET", { layout: name });
|
|
55738
|
+
}
|
|
55739
|
+
/************************************************************
|
|
55668
55740
|
* Show or hide the minimap, deciding by the SIZE of the graph.
|
|
55669
55741
|
*
|
|
55670
55742
|
* A minimap of a graph that already fits on screen is decoration; one
|
|
@@ -56519,6 +56591,11 @@ function ac_load_data(gobj, event, kw, src) {
|
|
|
56519
56591
|
graph_draw(gobj).then(() => {
|
|
56520
56592
|
create_links(gobj);
|
|
56521
56593
|
graph_draw(gobj).then(() => {
|
|
56594
|
+
try {
|
|
56595
|
+
auto_layout(gobj);
|
|
56596
|
+
} catch (e) {
|
|
56597
|
+
log_error(`${gobj_short_name(gobj)}: auto_layout failed: ${e}`);
|
|
56598
|
+
}
|
|
56522
56599
|
graph_layout(gobj).then(() => {
|
|
56523
56600
|
if (priv.edit_mode) graph_add_plugin(gobj, "history");
|
|
56524
56601
|
else graph_remove_plugin(gobj, "history");
|
|
@@ -57159,6 +57236,7 @@ function create_gclass$1(gclass_name) {
|
|
|
57159
57236
|
["EV_FOCUS_TOPIC", 0],
|
|
57160
57237
|
["EV_FIND_NODES", 0],
|
|
57161
57238
|
["EV_FIND_RESULT", event_flag_t.EVF_OUTPUT_EVENT],
|
|
57239
|
+
["EV_LAYOUT_AUTOSET", event_flag_t.EVF_OUTPUT_EVENT],
|
|
57162
57240
|
["EV_CENTER", 0],
|
|
57163
57241
|
["EV_FULLSCREEN", 0],
|
|
57164
57242
|
["EV_SET_LAYOUT", 0],
|
package/package.json
CHANGED
package/src/c_g6_nodes_tree.js
CHANGED
|
@@ -291,6 +291,7 @@ let PRIVATE_DATA = {
|
|
|
291
291
|
_focus_ids: [], // node ids carrying the focus 'active' state
|
|
292
292
|
_pending_focus_topic: null, // focus requested before data was loaded
|
|
293
293
|
_pending_find: null, // find requested before data was loaded
|
|
294
|
+
_layout_asked: "", // layout the host asked for at create (see mt_create)
|
|
294
295
|
};
|
|
295
296
|
|
|
296
297
|
let __gclass__ = null;
|
|
@@ -312,6 +313,15 @@ function mt_create(gobj)
|
|
|
312
313
|
{
|
|
313
314
|
let priv = gobj.priv;
|
|
314
315
|
|
|
316
|
+
/* What the HOST asked for, captured before anything overwrites it.
|
|
317
|
+
*
|
|
318
|
+
* `gobj_write_attr()` also writes the private field of the same name,
|
|
319
|
+
* so the moment select_layout() resolves the empty preference to
|
|
320
|
+
* `manual` and stores it, `priv.layout` reads "manual" and no longer
|
|
321
|
+
* says whether anybody ever chose it. auto_layout() needs exactly that
|
|
322
|
+
* distinction. */
|
|
323
|
+
priv._layout_asked = gobj_read_str_attr(gobj, "layout") || "";
|
|
324
|
+
|
|
315
325
|
/*
|
|
316
326
|
* CHILD subscription model
|
|
317
327
|
*/
|
|
@@ -4483,6 +4493,80 @@ function show_node_detail_popover(gobj, node_id)
|
|
|
4483
4493
|
* not re-themed by setTheme()) are regenerated; structural
|
|
4484
4494
|
* junction diamonds get their neutral fill/stroke re-themed.
|
|
4485
4495
|
************************************************************/
|
|
4496
|
+
/************************************************************
|
|
4497
|
+
* Has anybody ever PLACED a node of this treedb?
|
|
4498
|
+
*
|
|
4499
|
+
* Saved positions live in `__graphs__` (per topic, per node) and, on
|
|
4500
|
+
* older data, in a `_geometry` on the record itself. Both are read.
|
|
4501
|
+
************************************************************/
|
|
4502
|
+
function has_saved_geometry(gobj)
|
|
4503
|
+
{
|
|
4504
|
+
let priv = gobj.priv;
|
|
4505
|
+
|
|
4506
|
+
for(let topic of Object.keys(priv._graph_properties || {})) {
|
|
4507
|
+
let props = priv._graph_properties[topic];
|
|
4508
|
+
if(props && is_object(props.nodes) && Object.keys(props.nodes).length > 0) {
|
|
4509
|
+
return true;
|
|
4510
|
+
}
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
for(let topic of Object.keys(priv.records || {})) {
|
|
4514
|
+
let records = priv.records[topic];
|
|
4515
|
+
if(!is_array(records)) {
|
|
4516
|
+
continue;
|
|
4517
|
+
}
|
|
4518
|
+
for(let record of records) {
|
|
4519
|
+
if(record && is_object(record._geometry)) {
|
|
4520
|
+
return true;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4524
|
+
|
|
4525
|
+
return false;
|
|
4526
|
+
}
|
|
4527
|
+
|
|
4528
|
+
/************************************************************
|
|
4529
|
+
* Choose a layout for a treedb nobody has arranged yet.
|
|
4530
|
+
*
|
|
4531
|
+
* `manual` means "leave every node where it was put", and where none
|
|
4532
|
+
* was put it means a cascade: get_default_ne_xy() walks x and y
|
|
4533
|
+
* together, so a treedb opened for the first time was a diagonal pile
|
|
4534
|
+
* of cards — 126 of them on a real one — and the only way out was to
|
|
4535
|
+
* know to pick a layout by hand. It is the right default only once
|
|
4536
|
+
* there ARE saved positions to leave alone.
|
|
4537
|
+
*
|
|
4538
|
+
* So: nothing saved and no preference of the user's ⇒ dagre. The pick
|
|
4539
|
+
* is deliberately NOT persisted — it is a default, not a choice, and
|
|
4540
|
+
* the moment the user drags one node the geometry exists and `manual`
|
|
4541
|
+
* becomes right again by itself.
|
|
4542
|
+
************************************************************/
|
|
4543
|
+
function auto_layout(gobj)
|
|
4544
|
+
{
|
|
4545
|
+
let priv = gobj.priv;
|
|
4546
|
+
|
|
4547
|
+
if(priv._layout_asked) {
|
|
4548
|
+
return; /* the user picked one for this treedb */
|
|
4549
|
+
}
|
|
4550
|
+
if(has_saved_geometry(gobj)) {
|
|
4551
|
+
return; /* somebody arranged it: leave it alone */
|
|
4552
|
+
}
|
|
4553
|
+
if(!priv.graph) {
|
|
4554
|
+
return;
|
|
4555
|
+
}
|
|
4556
|
+
|
|
4557
|
+
let name = "dagre";
|
|
4558
|
+
gobj_write_attr(gobj, "layout", name);
|
|
4559
|
+
try {
|
|
4560
|
+
priv.graph.setLayout(_layouts[name]);
|
|
4561
|
+
} catch(e) {
|
|
4562
|
+
log_error(`${gobj_short_name(gobj)}: cannot set the '${name}' layout: ${e}`);
|
|
4563
|
+
return;
|
|
4564
|
+
}
|
|
4565
|
+
/* The toolbar's select was filled before the data arrived, so it is
|
|
4566
|
+
* still showing `manual`: tell it what the graph is actually doing. */
|
|
4567
|
+
gobj_publish_event(gobj, "EV_LAYOUT_AUTOSET", {layout: name});
|
|
4568
|
+
}
|
|
4569
|
+
|
|
4486
4570
|
/************************************************************
|
|
4487
4571
|
* Show or hide the minimap, deciding by the SIZE of the graph.
|
|
4488
4572
|
*
|
|
@@ -5770,6 +5854,14 @@ function ac_load_data(gobj, event, kw, src)
|
|
|
5770
5854
|
graph_draw(gobj).then(() => { // draw nodes, else the link fails
|
|
5771
5855
|
create_links(gobj);
|
|
5772
5856
|
graph_draw(gobj).then(() => {
|
|
5857
|
+
/* Before the layout runs, and only now: whether anybody has
|
|
5858
|
+
* ever placed a node of this treedb is not known until its
|
|
5859
|
+
* records and __graphs__ are in. */
|
|
5860
|
+
try {
|
|
5861
|
+
auto_layout(gobj);
|
|
5862
|
+
} catch(e) {
|
|
5863
|
+
log_error(`${gobj_short_name(gobj)}: auto_layout failed: ${e}`);
|
|
5864
|
+
}
|
|
5773
5865
|
graph_layout(gobj).then(() => {
|
|
5774
5866
|
if(priv.edit_mode) {
|
|
5775
5867
|
graph_add_plugin(gobj, "history");
|
|
@@ -6563,6 +6655,7 @@ function create_gclass(gclass_name)
|
|
|
6563
6655
|
["EV_FOCUS_TOPIC", 0],
|
|
6564
6656
|
["EV_FIND_NODES", 0],
|
|
6565
6657
|
["EV_FIND_RESULT", event_flag_t.EVF_OUTPUT_EVENT],
|
|
6658
|
+
["EV_LAYOUT_AUTOSET", event_flag_t.EVF_OUTPUT_EVENT],
|
|
6566
6659
|
["EV_CENTER", 0],
|
|
6567
6660
|
["EV_FULLSCREEN", 0],
|
|
6568
6661
|
["EV_SET_LAYOUT", 0],
|
|
@@ -2337,6 +2337,27 @@ function ac_legend_topic(gobj, event, kw, src)
|
|
|
2337
2337
|
return 0;
|
|
2338
2338
|
}
|
|
2339
2339
|
|
|
2340
|
+
/************************************************************
|
|
2341
|
+
* The child chose a layout for a treedb nobody has arranged yet.
|
|
2342
|
+
* Only the SELECT is moved: the pick is a default, not the user's
|
|
2343
|
+
* choice, so it is not persisted — the day somebody drags a node the
|
|
2344
|
+
* saved geometry exists and `manual` is right again.
|
|
2345
|
+
************************************************************/
|
|
2346
|
+
function ac_layout_autoset(gobj, event, kw, src)
|
|
2347
|
+
{
|
|
2348
|
+
let $container = gobj_read_attr(gobj, "$container");
|
|
2349
|
+
if(!$container) {
|
|
2350
|
+
return 0;
|
|
2351
|
+
}
|
|
2352
|
+
let $select = $container.querySelector(".GRAPH_LAYOUT_SELECT");
|
|
2353
|
+
let layout = (kw && kw.layout) || "";
|
|
2354
|
+
if(!$select || !layout) {
|
|
2355
|
+
return 0;
|
|
2356
|
+
}
|
|
2357
|
+
$select.value = layout;
|
|
2358
|
+
return 0;
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2340
2361
|
/************************************************************
|
|
2341
2362
|
* Forward the find down to the graph child.
|
|
2342
2363
|
************************************************************/
|
|
@@ -2490,6 +2511,7 @@ function create_gclass(gclass_name)
|
|
|
2490
2511
|
["EV_SET_OPERATION_MODE", ac_set_operation_mode, null],
|
|
2491
2512
|
["EV_SET_FOCUS_TOPIC", ac_set_focus_topic, null],
|
|
2492
2513
|
["EV_FIND_NODES", ac_find_nodes, null],
|
|
2514
|
+
["EV_LAYOUT_AUTOSET", ac_layout_autoset, null],
|
|
2493
2515
|
["EV_TOGGLE_LEGEND", ac_toggle_legend, null],
|
|
2494
2516
|
["EV_LEGEND_TOPIC", ac_legend_topic, null],
|
|
2495
2517
|
["EV_FIND_RESULT", ac_find_result, null],
|
|
@@ -2529,6 +2551,7 @@ function create_gclass(gclass_name)
|
|
|
2529
2551
|
["EV_SET_FOCUS_TOPIC", 0],
|
|
2530
2552
|
["EV_FIND_NODES", 0],
|
|
2531
2553
|
["EV_FIND_RESULT", 0],
|
|
2554
|
+
["EV_LAYOUT_AUTOSET", 0],
|
|
2532
2555
|
["EV_TOGGLE_LEGEND", 0],
|
|
2533
2556
|
["EV_LEGEND_TOPIC", 0],
|
|
2534
2557
|
["EV_TOPIC_SELECTED",
|