py2max 0.5.0__tar.gz → 0.6.0__tar.gz
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.
- {py2max-0.5.0 → py2max-0.6.0}/CHANGELOG.md +71 -0
- {py2max-0.5.0 → py2max-0.6.0}/PKG-INFO +1 -1
- {py2max-0.5.0 → py2max-0.6.0}/py2max/__init__.py +1 -1
- {py2max-0.5.0 → py2max-0.6.0}/py2max/cli.py +3 -2
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/abstract.py +5 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/factory.py +15 -3
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/patcher.py +58 -13
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/serialization.py +1 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/__init__.py +8 -1
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/base.py +83 -1
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/grid.py +9 -6
- {py2max-0.5.0 → py2max-0.6.0}/pyproject.toml +2 -2
- {py2max-0.5.0 → py2max-0.6.0}/pyproject.toml.orig +2 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/conftest.py +0 -102
- py2max-0.6.0/tests/examples/advanced/connection_patterns.py +165 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/advanced/custom_extensions.py +63 -31
- py2max-0.6.0/tests/examples/advanced/data_containers.py +178 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/advanced/performance_optimization.py +12 -9
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/advanced/subpatchers.py +25 -23
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/api/box_api_examples.py +3 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/api/patcher_api_examples.py +8 -8
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/auto_layout_demo.py +2 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/layout/columnar_layout_examples.py +3 -1
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/layout/flow_layout_examples.py +46 -29
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/layout/grid_layout_examples.py +14 -10
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/layout/matrix_layout_examples.py +12 -6
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/complex_synth.maxpat +53 -58
- py2max-0.6.0/tests/examples/preview/complex_synth.svg +82 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/svg_preview_demo.py +3 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/quickstart/layout_examples.py +2 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/tutorial/generative_music.py +16 -14
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/tutorial/interactive_controller.py +2 -1
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/tutorial/signal_processing_chain.py +29 -18
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_attrui.py +1 -1
- py2max-0.6.0/tests/test_auto_layout.py +127 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_cli.py +8 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_core_coverage.py +11 -7
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_encapsulate.py +14 -14
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_examples.py +40 -2
- py2max-0.6.0/tests/test_layout_align_ports.py +135 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_graph_manager.py +11 -4
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_matrix.py +2 -2
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_subset.py +7 -4
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_loaded_rects.py +29 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_patcher.py +1 -1
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_svg.py +8 -8
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_validate_attrs.py +21 -0
- py2max-0.5.0/tests/examples/advanced/connection_patterns.py +0 -128
- py2max-0.5.0/tests/examples/advanced/data_containers.py +0 -141
- py2max-0.5.0/tests/examples/preview/complex_synth.svg +0 -71
- {py2max-0.5.0 → py2max-0.6.0}/LICENSE +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/README.md +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/__main__.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/__init__.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/box.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/colors.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/common.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/patchline.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/core/props.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/data/js2max/js2max.js +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/data/js2max/js2max.v8.js +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/exceptions.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/export/__init__.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/export/converters.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/export/svg.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/js2max_runtime.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/external.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/flow.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/graph.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/layout/matrix.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/lint.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/log.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/m4l.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/__init__.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/aliases.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/category.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/data/bundle.json.gz +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/db.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/legacy.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/parser.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/maxref/porttypes.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/py.typed +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/transformers.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/py2max/utils.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/__init__.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/complex.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/desc.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/empty.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/mydevice.amxd +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/mydevice2.amxd +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/nested.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/simple.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/tabular.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/data/umenu.maxref.xml +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/README.md +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/advanced/error_handling.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/db/category_db_demo.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/db/maxref_db_demo.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/basic_synth.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/basic_synth.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/flow_layout.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/flow_layout.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/grid_layout.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/grid_layout.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/horizontal_layout.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/horizontal_layout.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/styled_no_ports.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/styled_no_title.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/styled_patch.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/styled_with_ports.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/vertical_layout.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/vertical_layout.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/workflow_demo.maxpat +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/preview/workflow_demo.svg +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/quickstart/basic_patch.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/examples/tutorial/simple_synthesis.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/graphs/random/v30e33.tglf +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_abstract_coverage.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_abstraction.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_add.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_amxd.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_basic.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_beap.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_box_props.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_bpatcher.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_coll.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_colors.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_colors_theme.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_comment.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_connection_validation.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_converters.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_db.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_db_schema.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_defaults.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_dict.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_edit_operations.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_error_handling.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_ezdac.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_gen.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_group.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_itable.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_js.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_js2max_runtime.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_kwds_filter.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_box_dims.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_builtins.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_coverage.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_flow.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_flow_crossings.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_graph.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_graph_layout.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_grid_order.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_overlaps.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_layout_vertical.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_linking.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_lint.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_logging.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_m4l.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_maxref.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_maxref_bundle.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_maxref_lazy.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_maxref_parser.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_maxref_refpages.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_mc_cycle.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_mc_poly.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_message.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_mypatch.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_nested.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_nested_patchers.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_number_tilde.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_numbers.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_on_invalid.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_param.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_param_placement.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_pitched_osc.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_porttypes.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_presets.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_pydantic.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_rnbo.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_rnbo_subpatcher.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_scripting_name.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_search.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_semantic_ids.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_serialization.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_single_file.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_subpatch.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_svg_fidelity.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_table.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_textbox_ports.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_transformers.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_transformers_e4.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_tree.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_tree_builder.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_tutorial_simple_synthesis.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_two_sines.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_umenu.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_utils.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_validation.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_varname.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_wheel_bundle.py +0 -0
- {py2max-0.5.0 → py2max-0.6.0}/tests/test_zl_group.py +0 -0
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0]
|
|
4
|
+
|
|
5
|
+
The default layout is now `"topdown"`: a vertical grid whose `optimize_layout()` sorts boxes into signal order and aligns ports.
|
|
6
|
+
|
|
7
|
+
Upgrading from 0.5.x:
|
|
8
|
+
|
|
9
|
+
- A patch that names no layout is placed top to bottom instead of left to right. `Patcher(layout="horizontal")` restores the 0.5 placement. Named layouts are unchanged. `py2max new --layout` defaults to `topdown` too, and `new --template stereo` now lays out its patch.
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `optimize_layout(align_ports=True)` shifts boxes sideways so each cord from a box above drops straight; y is kept. It works with every layout manager and is off by default. Boxes with an explicit rect never move, and a shift that would put the box or its cord on another box is skipped. A window-anchored `ezdac~` shifts too, which is the common case: it no longer sits offset below a vertical chain.
|
|
14
|
+
|
|
15
|
+
- `layout="topdown"`: the `"vertical"` grid with `align_ports` on by default, so `optimize_layout()` aligns without the flag. `optimize_layout(align_ports=False)` still turns it off. Also a `py2max new --layout` choice.
|
|
16
|
+
|
|
17
|
+
- `Patcher(auto_layout=True)`: `save()`/`save_as()` runs `optimize_layout()` first, but only if boxes or cords changed since the last layout. A blanket re-run would discard an explicit `optimize_layout(...)` call's options, and flow recomputes every position. Moves made by hand after a layout are kept. Off by default, so `save()` never moves boxes unless asked. Subpatchers inherit the setting; patches loaded from a file have it off; `to_dict()`/`to_json()` never lay out.
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
p = Patcher("patch.maxpat", layout="topdown", auto_layout=True)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Every `add_*` method raises `TypeError` when `patching_rect` is not 4 numbers. A misplaced positional argument used to be saved as the box's rect: `add_message("start", "stop")` stored the string `"stop"`, and `add_comment("note", box)` stored the box.
|
|
26
|
+
|
|
27
|
+
- `add_table(data=[...])` saved an empty table. The values go in `array=`, and `data` was on the attribute whitelist for every object, so the stray key passed without a warning. `add_table` now raises `TypeError` for `data=`. `data` is now a known attribute only for `dict`, so `add_coll(data=...)` (it takes `dictionary=`) warns as an unknown attribute. The examples and docs used both forms, so their tables and colls were empty.
|
|
28
|
+
|
|
29
|
+
- `optimize_layout()` raised `AttributeError: 'list' object has no attribute 'y'` on a patch of two or more boxes when one was added with `patching_rect=[x, y, w, h]`. The list was stored as given, and the overlap pass reads `rect.y`. Loaded patches were already converted; `add_box` now converts too.
|
|
30
|
+
|
|
31
|
+
### Examples and docs
|
|
32
|
+
|
|
33
|
+
- The examples (`tests/examples/`) and the user guide used objects that do not exist in Max: `crossfade~`, `freeverb~`, `reverb~`, `chorus~`, `compressor~`, `eq~`, `inlet~`, `outlet~`. These are now real objects (`svf~`, `lores~`, `comb~`, `omx.comp~`, `selector~`, `tapin~`/`tapout~`, `inlet`/`outlet`).
|
|
34
|
+
- `biquad~` was given a frequency, Q or filter type, though it takes 5 coefficients.
|
|
35
|
+
- `delay~` was given a time in ms, though its arguments are in samples.
|
|
36
|
+
- Delay feedback now goes through `tapin~`/`tapout~`, since MSP rejects a signal loop through `delay~`.
|
|
37
|
+
|
|
38
|
+
- Several example patches could not make sound:
|
|
39
|
+
- The custom and modular synths never triggered their `adsr~`. `CustomPatcher.add_gate` now adds a `[1(` (note-on) and a `[0(` (note-off) to each one.
|
|
40
|
+
- The generative tutorial sent `start` to `metro`, which has no such message. Its stop message was never created: `add_message("start", "stop")` passed `"stop"` as the rect. Both are now `[1(` and `[0(`.
|
|
41
|
+
- The custom synth wired the wrong boxes into its oscillator mixer. It also sent the envelope into a filter inlet that does not exist; the envelope now scales a `*~`.
|
|
42
|
+
- The wavetable example read `wave~` from `table` objects. `wave~` reads a `buffer~`, so the example now writes WAV files that `buffer~` loads.
|
|
43
|
+
- The sequencer's `coll`s were empty, and its `select` was never connected.
|
|
44
|
+
|
|
45
|
+
- Subpatcher examples now wire the `add_subpatcher` box itself, with the `p` prefix Max needs. Before, they wired a second, empty `p` box.
|
|
46
|
+
|
|
47
|
+
- The matrix mixer is now an abstraction, `matrix-mixer.maxpat`: 4 signal inlets, a 5th inlet for `src dst gain` messages, and 4 outlets. A host patch uses it by file name.
|
|
48
|
+
|
|
49
|
+
- `svg_preview_demo.py` imported `export_svg` from `py2max`; it now imports from `py2max.export`.
|
|
50
|
+
|
|
51
|
+
### Tests
|
|
52
|
+
|
|
53
|
+
- Test patches are built with `validate_connections=True` and use only cords Max accepts. Tests about invalid input are the exception.
|
|
54
|
+
- `metro` no longer feeds `cycle~` or `scope~`, nothing is wired out of `scope~`, and `gain~` no longer feeds `+`.
|
|
55
|
+
- The random-graph layout tests sample cords until the requested number are valid.
|
|
56
|
+
- The Pure Data `osc~` is now `cycle~`.
|
|
57
|
+
|
|
58
|
+
### Removed
|
|
59
|
+
|
|
60
|
+
- The `signal_order` A/B test fixture. Layout tests run once again, and `build/test-output/signal_order_ab.md` is no longer written. It saved every patcher under `test_layout*` twice, which produced too many files to inspect.
|
|
61
|
+
|
|
62
|
+
## [0.5.1]
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- `js2max/max/serialize-demo.maxpat` is regenerated. 0.5.0 corrected port inference for `+ 48` and `*~ 0.15` (2 inlets; `*~` has a signal outlet), but the committed demo kept the 0.4 counts, so `make js2max-check` failed in CI.
|
|
67
|
+
|
|
68
|
+
### Build
|
|
69
|
+
|
|
70
|
+
- The `uv_build` requirement is relaxed to `>=0.11,<0.13`.
|
|
71
|
+
|
|
72
|
+
- `make test` also runs `gen_v8_harness.py --check`, so a stale demo patch fails locally. It needs no bun, unlike `make js2max-check`.
|
|
73
|
+
|
|
3
74
|
## [0.5.0]
|
|
4
75
|
|
|
5
76
|
More validation on by default: (a) connection validation (inlet index and message type) should prevent the wrong connects and (b) attribute validation stop usage of properties unknown to the object's Max class. Layouts also changed: code boxes are sized to their content, auto-placed boxes no longer overlap, and grid `optimize_layout()` follows signal order.
|
|
@@ -24,7 +24,7 @@ from .export.converters import maxpat_to_python, maxref_to_sqlite
|
|
|
24
24
|
from .maxref import MaxRefCache, MaxRefDB
|
|
25
25
|
from .transformers import available_transformers, create_transformer, run_pipeline
|
|
26
26
|
|
|
27
|
-
LAYOUT_CHOICES = ["horizontal", "vertical", "grid", "flow", "matrix"]
|
|
27
|
+
LAYOUT_CHOICES = ["horizontal", "vertical", "topdown", "grid", "flow", "matrix"]
|
|
28
28
|
FLOW_CHOICES = ["horizontal", "vertical", "column"]
|
|
29
29
|
|
|
30
30
|
|
|
@@ -169,6 +169,7 @@ def cmd_new(args: argparse.Namespace) -> int:
|
|
|
169
169
|
patcher.link(osc, gain)
|
|
170
170
|
patcher.link(gain, dac)
|
|
171
171
|
patcher.link(gain, dac, inlet=1)
|
|
172
|
+
patcher.optimize_layout()
|
|
172
173
|
elif args.template == "blank":
|
|
173
174
|
pass
|
|
174
175
|
else:
|
|
@@ -764,7 +765,7 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
764
765
|
new_parser = subparsers.add_parser("new", help="Create a new patcher file")
|
|
765
766
|
new_parser.add_argument("path", help="Destination .maxpat path")
|
|
766
767
|
new_parser.add_argument("--title", help="Optional patcher title")
|
|
767
|
-
new_parser.add_argument("--layout", choices=LAYOUT_CHOICES, default="
|
|
768
|
+
new_parser.add_argument("--layout", choices=LAYOUT_CHOICES, default="topdown")
|
|
768
769
|
new_parser.add_argument(
|
|
769
770
|
"--flow-direction", choices=FLOW_CHOICES, default="horizontal"
|
|
770
771
|
)
|
|
@@ -144,6 +144,7 @@ class AbstractPatcher(ABC):
|
|
|
144
144
|
_signal_order: bool
|
|
145
145
|
_layout_mgr: AbstractLayoutManager
|
|
146
146
|
_auto_hints: bool
|
|
147
|
+
_auto_layout: bool
|
|
147
148
|
_validate_connections: bool
|
|
148
149
|
_on_invalid: str
|
|
149
150
|
_validate_attrs: bool
|
|
@@ -175,6 +176,10 @@ class AbstractPatcher(ABC):
|
|
|
175
176
|
"""Render boxes/lines to dicts (implemented by Patcher)."""
|
|
176
177
|
raise NotImplementedError
|
|
177
178
|
|
|
179
|
+
def _auto_arrange(self) -> None:
|
|
180
|
+
"""Lay out before saving if ``auto_layout`` is on (implemented by Patcher)."""
|
|
181
|
+
raise NotImplementedError
|
|
182
|
+
|
|
178
183
|
def _process_pending_comments(self) -> None:
|
|
179
184
|
"""Position deferred associated comments (implemented by Patcher)."""
|
|
180
185
|
raise NotImplementedError
|
|
@@ -13,6 +13,7 @@ core class.
|
|
|
13
13
|
from __future__ import annotations
|
|
14
14
|
|
|
15
15
|
import inspect
|
|
16
|
+
import numbers
|
|
16
17
|
import re
|
|
17
18
|
import warnings
|
|
18
19
|
from typing import (
|
|
@@ -37,7 +38,7 @@ from ..log import get_logger
|
|
|
37
38
|
from ..utils import kwds_filter, parse_attr_args
|
|
38
39
|
from .abstract import AbstractBox, AbstractPatcher, AbstractPatchline
|
|
39
40
|
from .box import Box
|
|
40
|
-
from .common import Rect, box_width_for
|
|
41
|
+
from .common import Rect, as_rect, box_width_for
|
|
41
42
|
from .patchline import Patchline
|
|
42
43
|
from .props import TextboxProps
|
|
43
44
|
|
|
@@ -120,7 +121,6 @@ UNIVERSAL_BOX_ATTRS = frozenset(
|
|
|
120
121
|
"presentation_rect",
|
|
121
122
|
"presentation",
|
|
122
123
|
"code",
|
|
123
|
-
"data",
|
|
124
124
|
"table_data",
|
|
125
125
|
"editor_rect",
|
|
126
126
|
"embed",
|
|
@@ -181,8 +181,9 @@ SAVED_BOX_ATTRS: Dict[str, FrozenSet[str]] = {
|
|
|
181
181
|
"pattr": frozenset({"restore"}),
|
|
182
182
|
"table~": frozenset({"showeditor"}),
|
|
183
183
|
"table": frozenset({"showeditor"}),
|
|
184
|
-
# written by add_coll / add_bpatcher / add_beap
|
|
184
|
+
# written by add_coll / add_dict / add_bpatcher / add_beap
|
|
185
185
|
"coll": frozenset({"coll_data"}),
|
|
186
|
+
"dict": frozenset({"data"}),
|
|
186
187
|
"bpatcher": frozenset({"viewvisibility", "extract"}),
|
|
187
188
|
}
|
|
188
189
|
|
|
@@ -250,6 +251,15 @@ class BoxFactoryMixin(AbstractPatcher):
|
|
|
250
251
|
assert box.id, f"object {box} must have an id"
|
|
251
252
|
if self._validate_attrs:
|
|
252
253
|
self._validate_box_attrs(box)
|
|
254
|
+
# a list (patching_rect=[...]) breaks layouts, which read rect.x
|
|
255
|
+
box.patching_rect = as_rect(box.patching_rect)
|
|
256
|
+
if not isinstance(box.patching_rect, Rect) or not all(
|
|
257
|
+
isinstance(v, numbers.Real) for v in box.patching_rect
|
|
258
|
+
):
|
|
259
|
+
# e.g. add_message("start", "stop"): "stop" lands in patching_rect
|
|
260
|
+
raise TypeError(
|
|
261
|
+
f"patching_rect must be a Rect or 4 numbers, got {box.patching_rect!r}"
|
|
262
|
+
)
|
|
253
263
|
auto_xy, self._auto_xy = getattr(self, "_auto_xy", None), None
|
|
254
264
|
rect = box.patching_rect
|
|
255
265
|
if auto_xy and rect is not None and tuple(rect[:2]) == auto_xy:
|
|
@@ -1790,6 +1800,8 @@ class BoxFactoryMixin(AbstractPatcher):
|
|
|
1790
1800
|
**kwds: Any,
|
|
1791
1801
|
) -> "Box":
|
|
1792
1802
|
"""Add a table object with option to pre-populate from a py list."""
|
|
1803
|
+
if "data" in kwds: # would be saved as an ignored key, leaving it empty
|
|
1804
|
+
raise TypeError("add_table() takes its values as array=, not data=")
|
|
1793
1805
|
|
|
1794
1806
|
extra = {
|
|
1795
1807
|
"embed": embed,
|
|
@@ -130,8 +130,13 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
130
130
|
parent: Parent patcher for hierarchical organization.
|
|
131
131
|
classnamespace: Namespace for object classes (e.g., 'rnbo').
|
|
132
132
|
reset_on_render: Whether to reset layout on render.
|
|
133
|
-
layout: Layout manager type ('
|
|
133
|
+
layout: Layout manager type ('topdown' (default), 'horizontal', 'vertical',
|
|
134
|
+
'grid', 'flow', 'matrix', 'columnar'). 'topdown' is 'vertical' that
|
|
135
|
+
also aligns ports on ``optimize_layout()``.
|
|
134
136
|
auto_hints: Whether to automatically generate object hints.
|
|
137
|
+
auto_layout: Whether ``save()``/``save_as()`` runs ``optimize_layout()``
|
|
138
|
+
first, when boxes or cords changed since the last layout. Defaults
|
|
139
|
+
to the parent patcher's setting, else off.
|
|
135
140
|
openinpresentation: Presentation mode setting.
|
|
136
141
|
validate_connections: Shorthand for ``on_invalid``: ``True`` means
|
|
137
142
|
``"raise"``, ``False`` means ``"ignore"``.
|
|
@@ -173,8 +178,9 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
173
178
|
parent: Optional["AbstractPatcher"] = None,
|
|
174
179
|
classnamespace: Optional[str] = None,
|
|
175
180
|
reset_on_render: bool = True,
|
|
176
|
-
layout: str = "
|
|
181
|
+
layout: str = "topdown",
|
|
177
182
|
auto_hints: bool = False,
|
|
183
|
+
auto_layout: Optional[bool] = None,
|
|
178
184
|
openinpresentation: int = 0,
|
|
179
185
|
validate_connections: Optional[bool] = None,
|
|
180
186
|
on_invalid: Optional[str] = None,
|
|
@@ -223,6 +229,11 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
223
229
|
self._dimension_spacing = dimension_spacing
|
|
224
230
|
self._layout_mgr: AbstractLayoutManager = self.set_layout_mgr(layout)
|
|
225
231
|
self._auto_hints = auto_hints
|
|
232
|
+
if auto_layout is None:
|
|
233
|
+
auto_layout = getattr(parent, "_auto_layout", False)
|
|
234
|
+
self._auto_layout = auto_layout
|
|
235
|
+
# boxes and cords at the last optimize_layout(); None: never laid out
|
|
236
|
+
self._laid_out: Optional[tuple[Any, ...]] = None
|
|
226
237
|
self._on_invalid = _resolve_on_invalid(validate_connections, on_invalid, parent)
|
|
227
238
|
self._validate_connections = self._on_invalid != "ignore"
|
|
228
239
|
if validate_attrs is None:
|
|
@@ -424,10 +435,11 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
424
435
|
) -> "Patcher":
|
|
425
436
|
"""create a patcher instance from a dict"""
|
|
426
437
|
|
|
438
|
+
# a hand-placed patch must not be rearranged on save
|
|
427
439
|
if save_to:
|
|
428
|
-
patcher = cls(save_to)
|
|
440
|
+
patcher = cls(save_to, auto_layout=False)
|
|
429
441
|
else:
|
|
430
|
-
patcher = cls()
|
|
442
|
+
patcher = cls(auto_layout=False)
|
|
431
443
|
# __init__ seeds every Max patcher attribute with a default (bglocked,
|
|
432
444
|
# gridsize, autosave, dependency_cache, ...). Real Max subpatchers omit
|
|
433
445
|
# a few of these -- notably ``autosave`` and ``dependency_cache``, which
|
|
@@ -707,6 +719,10 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
707
719
|
return layout_module.VerticalLayoutManager(
|
|
708
720
|
self, signal_order=self._signal_order
|
|
709
721
|
)
|
|
722
|
+
elif name == "topdown":
|
|
723
|
+
return layout_module.TopDownLayoutManager(
|
|
724
|
+
self, signal_order=self._signal_order
|
|
725
|
+
)
|
|
710
726
|
elif name == "flow":
|
|
711
727
|
return layout_module.FlowLayoutManager(
|
|
712
728
|
self, flow_direction=self._flow_direction
|
|
@@ -751,7 +767,7 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
751
767
|
self._auto_xy = (rect.x, rect.y)
|
|
752
768
|
return rect
|
|
753
769
|
|
|
754
|
-
def optimize_layout(self) -> None:
|
|
770
|
+
def optimize_layout(self, *, align_ports: Optional[bool] = None) -> None:
|
|
755
771
|
"""Arrange the whole patch based on the active layout manager.
|
|
756
772
|
|
|
757
773
|
Calls the layout manager to lay out every object, then repositions any
|
|
@@ -766,33 +782,62 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
766
782
|
all objects and connections have been added. Interactive, per-edit
|
|
767
783
|
relayout is out of scope for py2max (see ``docs/auto-layout.md`` in
|
|
768
784
|
py2max-server).
|
|
785
|
+
|
|
786
|
+
Args:
|
|
787
|
+
align_ports: Shift layout-placed boxes sideways so each cord from a
|
|
788
|
+
box above drops straight. Works with every layout manager.
|
|
789
|
+
``None`` uses the manager's default (on for ``"topdown"``).
|
|
769
790
|
"""
|
|
770
|
-
self._arrange()
|
|
791
|
+
self._arrange(align_ports)
|
|
771
792
|
|
|
772
793
|
# Process pending comments after layout optimization
|
|
773
794
|
self._process_pending_comments()
|
|
795
|
+
self._laid_out = self._layout_key()
|
|
796
|
+
|
|
797
|
+
def _layout_key(self) -> tuple[Any, ...]:
|
|
798
|
+
"""The boxes and cords a layout depends on."""
|
|
799
|
+
lines = cast(List[Any], self._lines)
|
|
800
|
+
return (
|
|
801
|
+
tuple(b.id for b in self._boxes),
|
|
802
|
+
tuple((tuple(ln.source), tuple(ln.destination)) for ln in lines),
|
|
803
|
+
)
|
|
774
804
|
|
|
775
|
-
def
|
|
805
|
+
def _auto_arrange(self) -> None:
|
|
806
|
+
"""Lay out this patcher and its subpatchers that have ``auto_layout``
|
|
807
|
+
on and changed since their last layout."""
|
|
808
|
+
for box in self._boxes:
|
|
809
|
+
sub = getattr(box, "_patcher", None)
|
|
810
|
+
if sub is not None:
|
|
811
|
+
sub._auto_arrange()
|
|
812
|
+
if self._auto_layout and self._laid_out != self._layout_key():
|
|
813
|
+
self.optimize_layout()
|
|
814
|
+
|
|
815
|
+
def optimize_layout_subset(
|
|
816
|
+
self, boxes: Iterable["AbstractBox"], *, align_ports: Optional[bool] = None
|
|
817
|
+
) -> None:
|
|
776
818
|
"""Lay out only ``boxes`` and the cords between them.
|
|
777
819
|
|
|
778
820
|
Every other box stays put, so logic can be arranged around fixed UI (a
|
|
779
821
|
``bpatcher`` view, a presentation area). The group keeps its top-left
|
|
780
822
|
corner, and moves down as a whole if it then overlaps a fixed box.
|
|
781
|
-
Like ``optimize_layout``, this is a batch operation
|
|
823
|
+
Like ``optimize_layout``, this is a batch operation; ``align_ports``
|
|
824
|
+
is as there.
|
|
782
825
|
"""
|
|
783
|
-
self._arrange_subset(list(boxes))
|
|
826
|
+
self._arrange_subset(list(boxes), align_ports)
|
|
784
827
|
self._process_pending_comments()
|
|
785
828
|
|
|
786
|
-
def _arrange(self) -> None:
|
|
829
|
+
def _arrange(self, align_ports: Optional[bool] = None) -> None:
|
|
787
830
|
"""Run the layout manager, then dock params if enabled."""
|
|
788
831
|
if hasattr(self._layout_mgr, "optimize_layout"):
|
|
789
|
-
self._layout_mgr.optimize_layout()
|
|
832
|
+
self._layout_mgr.optimize_layout(align_ports=align_ports)
|
|
790
833
|
|
|
791
834
|
# Dock value/UI params next to the object they drive (opt-in).
|
|
792
835
|
if self._param_placement and hasattr(self._layout_mgr, "place_params"):
|
|
793
836
|
self._layout_mgr.place_params()
|
|
794
837
|
|
|
795
|
-
def _arrange_subset(
|
|
838
|
+
def _arrange_subset(
|
|
839
|
+
self, subset: List["AbstractBox"], align_ports: Optional[bool] = None
|
|
840
|
+
) -> None:
|
|
796
841
|
"""Lay out ``subset`` alone, then put it back clear of the other boxes."""
|
|
797
842
|
ids = {b.id for b in subset}
|
|
798
843
|
if not ids:
|
|
@@ -804,7 +849,7 @@ class Patcher(BoxFactoryMixin, SerializationMixin, AbstractPatcher):
|
|
|
804
849
|
self._objects = {k: v for k, v in self._objects.items() if k in ids}
|
|
805
850
|
self._lines = [ln for ln in self._lines if ln.src in ids and ln.dst in ids]
|
|
806
851
|
try:
|
|
807
|
-
self._arrange()
|
|
852
|
+
self._arrange(align_ports)
|
|
808
853
|
finally:
|
|
809
854
|
self._boxes, self._objects, self._lines = saved
|
|
810
855
|
|
|
@@ -87,6 +87,7 @@ class SerializationMixin(AbstractPatcher):
|
|
|
87
87
|
resolved_path.parent.mkdir(parents=True, exist_ok=True)
|
|
88
88
|
logger.debug(f"Created parent directories: {resolved_path.parent}")
|
|
89
89
|
|
|
90
|
+
self._auto_arrange()
|
|
90
91
|
with log_operation(
|
|
91
92
|
logger, "render patcher", boxes=len(self._boxes), lines=len(self._lines)
|
|
92
93
|
):
|
|
@@ -9,11 +9,17 @@ Max objects in patches:
|
|
|
9
9
|
- MatrixLayoutManager: Matrix/columnar layout for signal chains
|
|
10
10
|
- HorizontalLayoutManager: Legacy alias for GridLayoutManager (horizontal)
|
|
11
11
|
- VerticalLayoutManager: Legacy alias for GridLayoutManager (vertical)
|
|
12
|
+
- TopDownLayoutManager: VerticalLayoutManager that aligns ports
|
|
12
13
|
"""
|
|
13
14
|
|
|
14
15
|
from .base import LayoutManager
|
|
15
16
|
from .flow import FlowLayoutManager
|
|
16
|
-
from .grid import
|
|
17
|
+
from .grid import (
|
|
18
|
+
GridLayoutManager,
|
|
19
|
+
HorizontalLayoutManager,
|
|
20
|
+
TopDownLayoutManager,
|
|
21
|
+
VerticalLayoutManager,
|
|
22
|
+
)
|
|
17
23
|
from .matrix import ColumnarLayoutManager, MatrixLayoutManager
|
|
18
24
|
from .external import GraphLayoutManager
|
|
19
25
|
|
|
@@ -22,6 +28,7 @@ __all__ = [
|
|
|
22
28
|
"GridLayoutManager",
|
|
23
29
|
"HorizontalLayoutManager",
|
|
24
30
|
"VerticalLayoutManager",
|
|
31
|
+
"TopDownLayoutManager",
|
|
25
32
|
"FlowLayoutManager",
|
|
26
33
|
"MatrixLayoutManager",
|
|
27
34
|
"ColumnarLayoutManager",
|
|
@@ -10,6 +10,8 @@ from py2max.core.common import Rect
|
|
|
10
10
|
from py2max.maxref import MAXCLASS_DEFAULTS
|
|
11
11
|
from py2max.utils import object_name
|
|
12
12
|
|
|
13
|
+
from .graph import PatchGraph
|
|
14
|
+
|
|
13
15
|
# Value/UI "param" objects: their role is to set a value on one object's inlet,
|
|
14
16
|
# so they read better docked next to that object than spread through the graph.
|
|
15
17
|
PARAM_MAXCLASSES = frozenset(
|
|
@@ -17,6 +19,26 @@ PARAM_MAXCLASSES = frozenset(
|
|
|
17
19
|
)
|
|
18
20
|
|
|
19
21
|
|
|
22
|
+
# approximate width of a Max inlet/outlet; ports spread edge to edge
|
|
23
|
+
_PORT_W = 7.0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _port_x(rect: Rect, n_ports: int, port: int) -> float:
|
|
27
|
+
"""Offset of ``port`` from the box's left edge (a lone port sits left)."""
|
|
28
|
+
if n_ports <= 1:
|
|
29
|
+
return 0.0
|
|
30
|
+
return (rect.w - _PORT_W) * min(port, n_ports - 1) / (n_ports - 1)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _overlaps(a: Rect, b: Rect, gap: float) -> bool:
|
|
34
|
+
return (
|
|
35
|
+
a.x < b.x + b.w + gap
|
|
36
|
+
and b.x < a.x + a.w + gap
|
|
37
|
+
and a.y < b.y + b.h + gap
|
|
38
|
+
and b.y < a.y + a.h + gap
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
|
|
20
42
|
def _is_param(box: object) -> bool:
|
|
21
43
|
"""True for a value/UI control that parameterizes another object."""
|
|
22
44
|
mc = getattr(box, "maxclass", "") or ""
|
|
@@ -48,6 +70,9 @@ class LayoutManager(AbstractLayoutManager):
|
|
|
48
70
|
DEFAULT_BOX_HEIGHT = 22.0
|
|
49
71
|
DEFAULT_COMMENT_PAD = 2
|
|
50
72
|
|
|
73
|
+
# optimize_layout()'s align_ports when the call leaves it unset
|
|
74
|
+
align_ports = False
|
|
75
|
+
|
|
51
76
|
def __init__(
|
|
52
77
|
self,
|
|
53
78
|
parent: AbstractPatcher,
|
|
@@ -389,7 +414,7 @@ class LayoutManager(AbstractLayoutManager):
|
|
|
389
414
|
return tx + tw / 2
|
|
390
415
|
return tx + tw * min(inlet, n_inlets - 1) / (n_inlets - 1)
|
|
391
416
|
|
|
392
|
-
def optimize_layout(self) -> None:
|
|
417
|
+
def optimize_layout(self, *, align_ports: Optional[bool] = None) -> None:
|
|
393
418
|
"""Arrange every object in the patch (batch, whole-patch layout).
|
|
394
419
|
|
|
395
420
|
This is py2max's batch layout entry point: it always performs a full
|
|
@@ -399,14 +424,71 @@ class LayoutManager(AbstractLayoutManager):
|
|
|
399
424
|
Interactive, per-edit ("incremental") relayout is intentionally out of
|
|
400
425
|
scope for py2max; it belongs to the editor/server that owns the live
|
|
401
426
|
editing session. See ``docs/auto-layout.md`` in py2max-server.
|
|
427
|
+
|
|
428
|
+
Args:
|
|
429
|
+
align_ports: Shift boxes sideways so each cord from a box above
|
|
430
|
+
drops straight (see ``_align_ports``). ``None`` uses the
|
|
431
|
+
manager's ``align_ports``.
|
|
402
432
|
"""
|
|
403
433
|
self._port_order_before = before = self._port_order()
|
|
404
434
|
self._full_layout()
|
|
435
|
+
if self.align_ports if align_ports is None else align_ports:
|
|
436
|
+
self._align_ports()
|
|
405
437
|
self._restore_port_order(before)
|
|
406
438
|
# layouts and the overlap pass can run past the window; grow it so the
|
|
407
439
|
# whole patch is visible when opened
|
|
408
440
|
self._fit_window(list(self.parent._boxes))
|
|
409
441
|
|
|
442
|
+
def _signal_rank(self) -> Dict[str, int]:
|
|
443
|
+
"""Each box id's position in signal order (ties by creation order)."""
|
|
444
|
+
ids = [b.id for b in self.parent._boxes if b.id]
|
|
445
|
+
order = PatchGraph(self.parent._lines, nodes=ids).signal_order()
|
|
446
|
+
return {box_id: i for i, box_id in enumerate(order)}
|
|
447
|
+
|
|
448
|
+
def _align_ports(self, gap: float = 10.0) -> None:
|
|
449
|
+
"""Shift layout-placed boxes sideways so their input cord drops straight.
|
|
450
|
+
|
|
451
|
+
Each box takes the x that puts its lowest connected inlet under the
|
|
452
|
+
outlet feeding it; only cords from a box above qualify, in any layout.
|
|
453
|
+
Window-anchored boxes (``ezdac~``) move too, keeping their y. Boxes with
|
|
454
|
+
an explicit rect never move. A move is skipped if the box or the cord
|
|
455
|
+
would hit another box.
|
|
456
|
+
"""
|
|
457
|
+
parent = self.parent
|
|
458
|
+
slots: Dict[str, Any] = getattr(parent, "_auto_slots", {})
|
|
459
|
+
feeds: Dict[str, Any] = {}
|
|
460
|
+
for line in cast(List[Any], parent._lines):
|
|
461
|
+
if len(line.source) < 2 or len(line.destination) < 2:
|
|
462
|
+
continue
|
|
463
|
+
cur = feeds.get(line.dst)
|
|
464
|
+
if cur is None or int(line.destination[1]) < int(cur.destination[1]):
|
|
465
|
+
feeds[line.dst] = line
|
|
466
|
+
rank = self._signal_rank()
|
|
467
|
+
boxes = sorted(
|
|
468
|
+
(b for b in parent._boxes if b.id in slots and b.id in feeds),
|
|
469
|
+
key=lambda b: rank[cast(str, b.id)],
|
|
470
|
+
)
|
|
471
|
+
for box in boxes:
|
|
472
|
+
line = feeds[cast(str, box.id)]
|
|
473
|
+
src = parent._objects.get(line.src)
|
|
474
|
+
if src is None or src is box:
|
|
475
|
+
continue
|
|
476
|
+
s, r = Rect(*src.patching_rect[:4]), Rect(*box.patching_rect[:4])
|
|
477
|
+
if s.y + s.h > r.y: # source not above: no straight drop
|
|
478
|
+
continue
|
|
479
|
+
cx = s.x + _port_x(s, src.numoutlets, int(line.source[1]))
|
|
480
|
+
x = cx - _port_x(r, box.numinlets, int(line.destination[1]))
|
|
481
|
+
if x < 0 or x == r.x:
|
|
482
|
+
continue
|
|
483
|
+
moved = Rect(x, r.y, r.w, r.h)
|
|
484
|
+
cord = Rect(cx, s.y + s.h, _PORT_W, r.y - s.y - s.h)
|
|
485
|
+
others = [
|
|
486
|
+
o.patching_rect for o in parent._boxes if o is not box and o is not src
|
|
487
|
+
]
|
|
488
|
+
if any(_overlaps(moved, o, gap) or _overlaps(cord, o, 0.0) for o in others):
|
|
489
|
+
continue
|
|
490
|
+
box.patching_rect = moved
|
|
491
|
+
|
|
410
492
|
def _fit_window(self, boxes: List[Any]) -> None:
|
|
411
493
|
"""Grow the patcher window so every laid-out box is fully visible."""
|
|
412
494
|
if not boxes:
|
|
@@ -106,12 +106,6 @@ class GridLayoutManager(LayoutManager):
|
|
|
106
106
|
# Prevent any remaining overlaps after clustering
|
|
107
107
|
self.prevent_overlaps()
|
|
108
108
|
|
|
109
|
-
def _signal_rank(self) -> Dict[str, int]:
|
|
110
|
-
"""Each box id's position in signal order (ties by creation order)."""
|
|
111
|
-
ids = [b.id for b in self.parent._boxes if b.id]
|
|
112
|
-
order = PatchGraph(self.parent._lines, nodes=ids).signal_order()
|
|
113
|
-
return {box_id: i for i, box_id in enumerate(order)}
|
|
114
|
-
|
|
115
109
|
def _reorder_by_signal(self) -> None:
|
|
116
110
|
"""Give the grid slots, in creation order, to boxes in signal order.
|
|
117
111
|
|
|
@@ -383,3 +377,12 @@ class VerticalLayoutManager(GridLayoutManager):
|
|
|
383
377
|
flow_direction="vertical",
|
|
384
378
|
signal_order=signal_order,
|
|
385
379
|
)
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
class TopDownLayoutManager(VerticalLayoutManager):
|
|
383
|
+
"""Vertical grid that also aligns ports on ``optimize_layout()``.
|
|
384
|
+
|
|
385
|
+
The default layout; also ``Patcher(..., layout="topdown")``.
|
|
386
|
+
"""
|
|
387
|
+
|
|
388
|
+
align_ports = True
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "py2max"
|
|
3
3
|
description = "A library for offline generation of Max/MSP patcher (.maxpat) files."
|
|
4
|
-
version = "0.
|
|
4
|
+
version = "0.6.0"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.9"
|
|
7
7
|
keywords = [
|
|
@@ -69,7 +69,7 @@ docs = [
|
|
|
69
69
|
]
|
|
70
70
|
|
|
71
71
|
[build-system]
|
|
72
|
-
requires = ["uv_build>=0.11,<0.
|
|
72
|
+
requires = ["uv_build>=0.11,<0.14"]
|
|
73
73
|
build-backend = "uv_build"
|
|
74
74
|
|
|
75
75
|
[tool.uv.build-backend]
|
|
@@ -7,7 +7,7 @@ authors = [
|
|
|
7
7
|
maintainers = [
|
|
8
8
|
{ name = "Shakeeb Alireza", email = "shakfu@users.noreply.github.com" }
|
|
9
9
|
]
|
|
10
|
-
version = "0.
|
|
10
|
+
version = "0.6.0"
|
|
11
11
|
readme = "README.md"
|
|
12
12
|
requires-python = ">=3.9"
|
|
13
13
|
keywords = ["Max", "maxpat", "offline"]
|
|
@@ -75,7 +75,7 @@ py2max = "py2max.__main__:main"
|
|
|
75
75
|
# python-preference = "only-system" # comment this out to use managed python
|
|
76
76
|
|
|
77
77
|
[build-system]
|
|
78
|
-
requires = ["uv_build>=0.11,<0.
|
|
78
|
+
requires = ["uv_build>=0.11,<0.14"]
|
|
79
79
|
build-backend = "uv_build"
|
|
80
80
|
|
|
81
81
|
[tool.uv.build-backend]
|