Fix connection line z-order and add portrait gap

- Move connection lines to draw before events so they appear below event icons
- Add PORTRAIT_GAP constant (12px) for spacing between event marker and portrait
- Update portrait and label positioning to account for the gap
This commit is contained in:
Daniel Viegas 2025-11-30 11:52:58 +01:00
parent fd6c002bec
commit cb572c4dc5

View File

@ -135,6 +135,7 @@ TOOLTIP_BORDER_WIDTH = 8 # Border width for tooltip window
PORTRAIT_SIZE_TIMELINE = 24 # Size of timeline portraits
PORTRAIT_SIZE_TOOLTIP = 120 # Size of tooltip portraits
PORTRAIT_MARGIN = 5 # Margin around portraits
PORTRAIT_GAP = 12 # Gap in pixels between event marker edge and portrait edge
# Font Constants
FONT_FAMILY = "Sans"
@ -3119,7 +3120,8 @@ class MyTimelineView(NavigationView):
# Draw portrait if person has one (between timeline and label)
if event_data.person:
portrait_x = timeline_x + PORTRAIT_MARGIN + PORTRAIT_SIZE_TIMELINE / 2
# Position portrait with gap after event marker edge
portrait_x = timeline_x + EVENT_MARKER_SIZE / 2 + PORTRAIT_GAP + PORTRAIT_SIZE_TIMELINE / 2
self.draw_portrait(context, portrait_x, event_data.y_pos,
event_data.person, PORTRAIT_SIZE_TIMELINE)
@ -3127,7 +3129,7 @@ class MyTimelineView(NavigationView):
label_x = timeline_x + LABEL_X_OFFSET
# Adjust label position if portrait is present
if event_data.person:
label_x = timeline_x + PORTRAIT_SIZE_TIMELINE + PORTRAIT_MARGIN * 2 + LABEL_X_OFFSET
label_x = timeline_x + EVENT_MARKER_SIZE / 2 + PORTRAIT_GAP + PORTRAIT_SIZE_TIMELINE + PORTRAIT_MARGIN + LABEL_X_OFFSET
self.draw_event_label(
context, label_x, event_data.y_pos, event_data.date_obj,
event_data.event, event_data.person, event_data.event_type, is_hovered
@ -3174,14 +3176,15 @@ class MyTimelineView(NavigationView):
# Get adjusted events with collision detection (uses cache)
events_with_y_pos = self._get_adjusted_events(context, timeline_y_start, timeline_y_end)
# Draw events
self._draw_events(context, events_with_y_pos, timeline_x)
# Draw visual connections for selected person (from selected event)
# Draw before events so lines appear below event markers
if self.selected_person_handles:
self.draw_person_connections(context, events_with_y_pos, timeline_x,
timeline_y_start, timeline_y_end)
# Draw events
self._draw_events(context, events_with_y_pos, timeline_x)
# Draw year markers on the left
self.draw_year_markers(context, timeline_x, timeline_y_start, timeline_y_end,
min_date, max_date)