object-tree 3.0.0__py3-none-any.whl

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.

Potentially problematic release.


This version of object-tree might be problematic. Click here for more details.

@@ -0,0 +1,42 @@
1
+ Metadata-Version: 2.4
2
+ Name: object-tree
3
+ Version: 3.0.0
4
+ Summary: A zero-dependency, general-purpose nested selection and inspection framework
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/GrayJou/object_tree
7
+ Project-URL: Repository, https://github.com/GrayJou/object_tree
8
+ Keywords: selection,inspection,viewport,editor,framework
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Software Development :: Libraries
17
+ Requires-Python: >=3.10
18
+ Description-Content-Type: text/markdown
19
+ Provides-Extra: demo
20
+ Requires-Dist: dearpygui>=1.10; extra == "demo"
21
+
22
+ # object_tree
23
+
24
+ A zero-dependency, general-purpose nested selection and inspection framework.
25
+
26
+ **Status:** Design phase. The implementation starts from two documents in this repo:
27
+
28
+ - `NestedSelectionIdea.md` — the original concept: object tree, selection state, inspector box stacking, viewport visibility rules, editing groups.
29
+ - `Analysis_NestedSelectionIdea.md` — architecture analysis recommending Phase 1 core types (`InspectableObject`, `SelectionState`, `InspectorSystem`, `ViewportElement`), then adapter layers.
30
+
31
+ Both documents live at the repo root so an agent can read them and implement from the design.
32
+
33
+ ## Goals
34
+
35
+ 1. N-level recursive selection of objects in a tree hierarchy.
36
+ 2. Lightweight, no-dependency core that can be imported by BezierManager, Chromatica2, HLV, or any other consumer.
37
+ 3. Clean separation between the object model, selection state, and viewport/UI logic.
38
+ 4. Adapter pattern for framework-specific rendering (DearPyGui, etc.) without coupling.
39
+
40
+ ---
41
+
42
+ *Created 2026-07-02. See `NestedSelectionIdea.md` and `Analysis_NestedSelectionIdea.md` for the full design.*
@@ -0,0 +1,21 @@
1
+ core/__init__.py,sha256=CrVTEViCCZN4S1aB5oQmkNPNranRJ1uSk0QCzd-V2Xo,1668
2
+ core/adapter.py,sha256=-l026eNc6kf0UuHcj3njnDFOAmpArs11WAjEn-9SUII,2665
3
+ core/hittest.py,sha256=CqH907iQBrp4dsOhq1mDBcR1a_x41lUyPFvBQXpFmrI,1711
4
+ core/inspector.py,sha256=tfCu9loaLujAM5mToeCqu6ouA7DfEMECe0z0ZmogoUU,2209
5
+ core/interaction.py,sha256=p1HWNsUFCbjuR09xTHT51b25b9CU2g2IqL0GnahiuOM,2419
6
+ core/node.py,sha256=uld5feEb-GAvgnKmB9ESeffeIzthcj_upAo7q0VQm5k,4134
7
+ core/selection.py,sha256=Q-SU2ZYs5-oaPiYc2Qm4EDjVPdSCw3H0TAK6Bl66njw,2635
8
+ core/viewport.py,sha256=7tFXKZfsHthsnPUuEje8r5pKntqE6Ulu2xlhsEne7BY,5557
9
+ core/viewport_system.py,sha256=SSGdM_LiONlEDR39fnsFb72On6EwcyocXO9bEW32Ku4,2946
10
+ demo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ demo/app.py,sha256=D0N8vSeD4xYPima0mcXb_rtuJLsBT6LufIsO3t7dbYU,6381
12
+ demo/scene.py,sha256=z_hG_dDIlXQmwVmbf-EVd53X1lDVV2Vkv-vOUKlo18A,7477
13
+ demo/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ demo/tests/test_scene.py,sha256=eMsP0uEvUmFxTCDjB9LPB5pFJEmjNyUAd9JRnwWQBHk,6325
15
+ rules/__init__.py,sha256=Z_ceOtj1fSsgzJ_ABhjVQiayCUqNqvwgwBa93Hlu5DU,653
16
+ rules/boolean_flags.py,sha256=rBVVsUnUpLp6LKLxQk5yDHVxfYB-uQB19ynnFIXGvaY,4146
17
+ rules/function.py,sha256=1Z0IQOfU6dvi2MVvNivysxAmeXZxC0jkepmf6F2PGno,1396
18
+ object_tree-3.0.0.dist-info/METADATA,sha256=rgLLNLieUdgpl2HT7TGfscZHZsRW35e_rQDCRuFivdw,2019
19
+ object_tree-3.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
20
+ object_tree-3.0.0.dist-info/top_level.txt,sha256=-TiiU34SITpxncRSymnUsARh_V5zeNM0V7dbkqmOy2E,16
21
+ object_tree-3.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ core
2
+ demo
3
+ rules
rules/__init__.py ADDED
@@ -0,0 +1,20 @@
1
+ """Convenience helpers for defining visibility and selectability rules.
2
+
3
+ Provides high-level flag classes (:class:`VisibilityFlags`,
4
+ :class:`SelectabilityFlags`) that translate boolean configuration into
5
+ composable :class:`Rule` objects, as well as simple standalone rule
6
+ functions for common cases.
7
+ """
8
+
9
+ from .boolean_flags import VisibilityFlags, SelectabilityFlags
10
+ from .function import CustomRule, always_visible, always_hidden, always_selectable, always_not_selectable
11
+
12
+ __all__ = [
13
+ "VisibilityFlags",
14
+ "SelectabilityFlags",
15
+ "CustomRule",
16
+ "always_visible",
17
+ "always_hidden",
18
+ "always_selectable",
19
+ "always_not_selectable",
20
+ ]
rules/boolean_flags.py ADDED
@@ -0,0 +1,105 @@
1
+ from __future__ import annotations
2
+ from dataclasses import dataclass, field
3
+ from typing import List
4
+
5
+ from core.node import InspectableObject
6
+ from core.selection import SelectionState
7
+ from core.viewport import (
8
+ AncestorSelectedRule,
9
+ AndRule,
10
+ BooleanRule,
11
+ OrRule,
12
+ ParentSelectedRule,
13
+ Rule,
14
+ SameGroupRule,
15
+ SelfOrAncestorSelectedRule,
16
+ SiblingSelectedRule,
17
+ ViewportElement,
18
+ )
19
+
20
+
21
+ @dataclass
22
+ class VisibilityFlags:
23
+ """High-level flag-based visibility configuration for a :class:`ViewportElement`.
24
+
25
+ Translates intuitive boolean flags into a list of :class:`Rule` instances
26
+ via ``to_rules()`` or directly applies them to an element via ``apply()``.
27
+
28
+ Attributes:
29
+ visible_by_default: Always visible when True.
30
+ requires_parent_visible: Reserved for future use.
31
+ reveal_when_parent_selected: Show when the immediate parent is selected.
32
+ reveal_when_ancestor_selected: Show when any ancestor is selected.
33
+ remain_visible_when_self_selected: Stay visible when this object is selected.
34
+ remain_visible_when_sibling_selected: Stay visible when a sibling is selected.
35
+ """
36
+ visible_by_default: bool = False
37
+ requires_parent_visible: bool = True
38
+ reveal_when_parent_selected: bool = False
39
+ reveal_when_ancestor_selected: bool = False
40
+ remain_visible_when_self_selected: bool = True
41
+ remain_visible_when_sibling_selected: bool = False
42
+
43
+ def to_rules(self) -> list[Rule]:
44
+ """Convert flags to a list of Rule objects.
45
+
46
+ If ``visible_by_default`` is True, returns a single ``BooleanRule(True)``.
47
+ Otherwise, combines enabled flags into an ``OrRule`` (any condition
48
+ triggers visibility). Returns ``BooleanRule(False)`` if no flags are set.
49
+ """
50
+ if self.visible_by_default:
51
+ return [BooleanRule(True)]
52
+ conditions: list[Rule] = []
53
+ if self.reveal_when_parent_selected:
54
+ conditions.append(ParentSelectedRule())
55
+ if self.reveal_when_ancestor_selected:
56
+ conditions.append(AncestorSelectedRule())
57
+ if self.remain_visible_when_self_selected:
58
+ conditions.append(SelfOrAncestorSelectedRule())
59
+ if self.remain_visible_when_sibling_selected:
60
+ conditions.append(SiblingSelectedRule())
61
+ if conditions:
62
+ return [OrRule(conditions)]
63
+ return [BooleanRule(False)]
64
+
65
+ def apply(self, element: ViewportElement) -> None:
66
+ """Set ``element.visible_rules`` to the rules generated from these flags."""
67
+ element.visible_rules = self.to_rules()
68
+
69
+
70
+ @dataclass
71
+ class SelectabilityFlags:
72
+ """High-level flag-based selectability configuration for a :class:`ViewportElement`.
73
+
74
+ Attributes:
75
+ selectable_by_default: Always selectable when True.
76
+ selectable_when_parent_selected: Selectable when the immediate parent is selected.
77
+ selectable_when_sibling_selected: Selectable when a sibling is selected.
78
+ selectable_when_inside_same_group: Selectable when sharing the same root tree.
79
+ """
80
+ selectable_by_default: bool = False
81
+ selectable_when_parent_selected: bool = False
82
+ selectable_when_sibling_selected: bool = False
83
+ selectable_when_inside_same_group: bool = False
84
+
85
+ def to_rules(self) -> list[Rule]:
86
+ """Convert flags to a list of Rule objects.
87
+
88
+ Returns ``BooleanRule(False)`` if no flags are set.
89
+ """
90
+ conditions: list[Rule] = []
91
+ if self.selectable_by_default:
92
+ conditions.append(BooleanRule(True))
93
+ if self.selectable_when_parent_selected:
94
+ conditions.append(ParentSelectedRule())
95
+ if self.selectable_when_sibling_selected:
96
+ conditions.append(SiblingSelectedRule())
97
+ if self.selectable_when_inside_same_group:
98
+ conditions.append(SameGroupRule())
99
+ if conditions:
100
+ return [OrRule(conditions)]
101
+ return [BooleanRule(False)]
102
+
103
+ def apply(self, element: ViewportElement) -> None:
104
+ """Set ``element.selectable_rules`` to the rules generated from these flags."""
105
+ element.selectable_rules = self.to_rules()
rules/function.py ADDED
@@ -0,0 +1,42 @@
1
+ from __future__ import annotations
2
+ from dataclasses import dataclass
3
+ from typing import Callable, Optional
4
+
5
+ from core.node import InspectableObject
6
+ from core.selection import SelectionState
7
+ from core.viewport import Rule, ViewportElement
8
+
9
+
10
+ @dataclass
11
+ class CustomRule:
12
+ """A rule backed by an arbitrary callable.
13
+
14
+ Attributes:
15
+ func: Callable that receives the current selection state and the target object.
16
+ description: Optional human-readable explanation (useful for debugging).
17
+ """
18
+ func: Callable[[SelectionState, InspectableObject], bool]
19
+ description: str = ""
20
+
21
+ def __call__(self, selection: SelectionState, obj: InspectableObject) -> bool:
22
+ return self.func(selection, obj)
23
+
24
+
25
+ def always_visible(selection: SelectionState, obj: InspectableObject) -> bool:
26
+ """Rule function that always returns True (always visible)."""
27
+ return True
28
+
29
+
30
+ def always_hidden(selection: SelectionState, obj: InspectableObject) -> bool:
31
+ """Rule function that always returns False (always hidden)."""
32
+ return False
33
+
34
+
35
+ def always_selectable(selection: SelectionState, obj: InspectableObject) -> bool:
36
+ """Rule function that always returns True (always selectable)."""
37
+ return True
38
+
39
+
40
+ def always_not_selectable(selection: SelectionState, obj: InspectableObject) -> bool:
41
+ """Rule function that always returns False (never selectable)."""
42
+ return False