From c817c4b1bcd32a5535a28fe1fd539149b01e74fb Mon Sep 17 00:00:00 2001 From: beckett Date: Wed, 19 Aug 2026 13:09:04 -0500 Subject: [PATCH] Render the word tier above the phone tier in TextGrid timelines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flips _TIER_ORDER so "words" sorts before "phones" wherever a TextGrid timeline is drawn — the Viewer, Compare Alignments, and Correct Alignments all share this widget. Words-over-phones reads top-down from coarse to fine, which is the order these tiers are conventionally shown in and the order reviewers expect when scanning an alignment. The Viewer's inline active-segment label was building its parts straight from _loaded_tiers in raw file order, so it could disagree with the timeline right above it. It now sorts through the same _TIER_ORDER. --- src/voxkit/gui/pages/pipeline/viewer_stacker.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/voxkit/gui/pages/pipeline/viewer_stacker.py b/src/voxkit/gui/pages/pipeline/viewer_stacker.py index dbff89a..9edf9e3 100644 --- a/src/voxkit/gui/pages/pipeline/viewer_stacker.py +++ b/src/voxkit/gui/pages/pipeline/viewer_stacker.py @@ -410,7 +410,7 @@ def __init__(self, parent: QWidget | None = None) -> None: self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Fixed) self.setFixedHeight(self.RULER_HEIGHT) - _TIER_ORDER = {"phones": 0, "words": 1} + _TIER_ORDER = {"words": 0, "phones": 1} def set_data(self, tiers: list[dict], duration: float) -> None: self._tiers = sorted( @@ -1839,7 +1839,11 @@ def _on_position_changed(self, position_ms: int): def _update_active_segment_label(self, secs: float) -> None: if self._active_label and self._active_label.isVisible() and self._loaded_tiers: parts = [] - for tier in self._loaded_tiers: + ordered_tiers = sorted( + self._loaded_tiers, + key=lambda t: TextGridTimeline._TIER_ORDER.get(t["name"].lower(), 2), + ) + for tier in ordered_tiers: if tier["class"] == "IntervalTier": for iv in tier["intervals"]: if iv["start"] <= secs < iv["end"] and iv["label"] not in _SILENCE_LABELS: