refactor: get rid of TimelineKind#499
Open
FelipeDefensor wants to merge 5 commits into
Open
Conversation
This was referenced May 3, 2026
b1cf402 to
9af2da3
Compare
FelipeDefensor
commented
May 4, 2026
FelipeDefensor
left a comment
Collaborator
Author
There was a problem hiding this comment.
Review for Claude.
FelipeDefensor
commented
May 4, 2026
FelipeDefensor
commented
May 4, 2026
98f7e90 to
e1f2273
Compare
c6b760a to
8efc99e
Compare
Replace the TimelineKind enum with direct Timeline subclass references. The enum was an extra layer between component classes and the dispatch sites that used them; using classes as first-class citizens removes a parallel taxonomy and lets isinstance / equality checks express intent directly. Also fixes the fallout from this refactor at sites that started comparing backend Timeline classes against UI TimelineUI classes (always False — silently breaking dynamic dispatch): - Beat-timeline creation no longer prompted for a beat pattern, because on_timeline_add's hasattr() check for get_additional_args_for_creation was looking at the backend class (passed via functools.partial), but the hook lives on the UI class. Look the UI class up via get_timeline_ui_class to consult it. - Per-kind submenus under Timelines hid themselves whenever any timeline was created, because update_dynamic_menus compared a UI class against backend classes in instanced_kinds. Bridge through ui_cls.timeline_class so the comparison is backend-vs-backend. - _setup_commands had the same UI-vs-backend bug for SliderTimeline / HarmonyTimeline / PdfTimeline / ScoreTimeline checks (Slider was incorrectly registering an Add command, and Harmony / PDF lost their custom keyboard accelerators).
Filed #507 for moving CSV/MusicXML importers onto the timeline classes so this central dispatch can go away. Reference it from the TODO so the rationale (and the issue) is one click away.
The `&` placement (and the harmony / PDF special cases) is opaque without context. Spell out that they are Qt menu accelerators and why each branch deviates.
SliderTimeline doesn't set COMPONENT_MANAGER_CLASS, so its component_manager is None. Without this guard, len(slider_tl) crashes.
8efc99e to
66544b6
Compare
azfoo
requested changes
Jun 2, 2026
| class ClipboardContents(TypedDict): | ||
| components: dict[str, dict] | ||
| timeline_kind: TimelineKind | None | ||
| timeline_type: Optional[type(Timeline)] |
Collaborator
There was a problem hiding this comment.
I think a previous PR cleaned out all Optionals for | None. Let's keep that consistent here too.
Comment on lines
+233
to
+234
| # TiLiA < 0.7 serialised the kind as e.g. "MARKER_TIMELINE"; | ||
| # strip the suffix so files saved by older versions still load. |
Collaborator
There was a problem hiding this comment.
Considering that we don't technically have a "stable" version yet, this might need to be removed in the future. Maybe have some kind of version converter?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the
TimelineKindenum in favor of direct Timeline subclass references throughout command/menu registries and timeline lookups. This leverages the fact that, in Python, classes are first-class citizens and reduces duplication. It also makes it easier to introduce new timeline types, as less code that is outside the timeline module needs to be touched.This was done in preparation for range timelines, and the range timeline PR (#501) is stacked on top of this one.