diff --git a/MyTimeline.py b/MyTimeline.py index ba81b18..9d832b8 100644 --- a/MyTimeline.py +++ b/MyTimeline.py @@ -88,6 +88,24 @@ TOOLTIP_MAX_WIDTH = 500 LABEL_BACKGROUND_PADDING = 8 LABEL_BACKGROUND_RADIUS = 5 +# Visual Effect Constants +MARKER_HOVER_SIZE_MULTIPLIER = 1.3 +MARKER_SELECTED_SIZE_MULTIPLIER = 1.2 +GRADIENT_BRIGHTNESS_OFFSET = 0.2 +GRADIENT_DARKNESS_OFFSET = 0.1 +SHADOW_OFFSET_X = 1 +SHADOW_OFFSET_Y = 1 +SHADOW_OPACITY = 0.3 +BORDER_OPACITY = 0.3 + +# Connection Line Constants +CONNECTION_LINE_COLOR = (0.2, 0.5, 1.0, 0.75) # Brighter, more opaque blue +CONNECTION_LINE_WIDTH = 3.5 +CONNECTION_VERTICAL_LINE_X = 5 # Left of year markers + +# Marker State Colors +SELECTED_MARKER_COLOR = (0.2, 0.4, 0.9) # Blue highlight for selected person's events + # Logger logger = logging.getLogger(__name__) @@ -1371,11 +1389,11 @@ class MyTimelineView(NavigationView): size: Size of the marker. shape: Shape type ('triangle', 'circle', etc.). """ - context.set_source_rgba(0.0, 0.0, 0.0, 0.3) - context.translate(1, 1) + context.set_source_rgba(0.0, 0.0, 0.0, SHADOW_OPACITY) + context.translate(SHADOW_OFFSET_X, SHADOW_OFFSET_Y) self._draw_shape(context, x, y, size, shape) context.fill() - context.translate(-1, -1) + context.translate(-SHADOW_OFFSET_X, -SHADOW_OFFSET_Y) def _draw_marker_gradient(self, context: cairo.Context, x: float, y: float, size: float, color: Tuple[float, float, float], @@ -1393,8 +1411,14 @@ class MyTimelineView(NavigationView): """ pattern = cairo.RadialGradient(x - size/2, y - size/2, 0, x, y, size) r, g, b = color - pattern.add_color_stop_rgb(0, min(1.0, r + 0.2), min(1.0, g + 0.2), min(1.0, b + 0.2)) - pattern.add_color_stop_rgb(1, max(0.0, r - 0.1), max(0.0, g - 0.1), max(0.0, b - 0.1)) + pattern.add_color_stop_rgb(0, + min(1.0, r + GRADIENT_BRIGHTNESS_OFFSET), + min(1.0, g + GRADIENT_BRIGHTNESS_OFFSET), + min(1.0, b + GRADIENT_BRIGHTNESS_OFFSET)) + pattern.add_color_stop_rgb(1, + max(0.0, r - GRADIENT_DARKNESS_OFFSET), + max(0.0, g - GRADIENT_DARKNESS_OFFSET), + max(0.0, b - GRADIENT_DARKNESS_OFFSET)) context.set_source(pattern) self._draw_shape(context, x, y, size, shape) context.fill() @@ -1425,13 +1449,13 @@ class MyTimelineView(NavigationView): # Increase size if hovered or selected if is_hovered: - marker_size *= 1.3 + marker_size *= MARKER_HOVER_SIZE_MULTIPLIER elif is_selected: - marker_size *= 1.2 + marker_size *= MARKER_SELECTED_SIZE_MULTIPLIER # Use highlight color if selected if is_selected: - color = (0.2, 0.4, 0.9) # Blue highlight for selected person's events + color = SELECTED_MARKER_COLOR # Draw shadow self._draw_marker_shadow(context, x, y, marker_size, shape) @@ -1440,7 +1464,7 @@ class MyTimelineView(NavigationView): self._draw_marker_gradient(context, x, y, marker_size, color, shape) # Draw border - context.set_source_rgba(0.0, 0.0, 0.0, 0.3) + context.set_source_rgba(0.0, 0.0, 0.0, BORDER_OPACITY) context.set_line_width(1) self._draw_shape(context, x, y, marker_size, shape) context.stroke() @@ -1686,12 +1710,12 @@ class MyTimelineView(NavigationView): # Position vertical line to the left of year markers # Year labels are positioned at timeline_x - 20 - text_width (around x=90-130) - # Position vertical line at x=5 to be clearly left of all year markers - vertical_line_x = 5 # Left of year markers + # Position vertical line at CONNECTION_VERTICAL_LINE_X to be clearly left of all year markers + vertical_line_x = CONNECTION_VERTICAL_LINE_X # Draw connecting lines - more visible with brighter color and increased opacity - context.set_source_rgba(0.2, 0.5, 1.0, 0.75) # Brighter, more opaque blue - context.set_line_width(3.5) # Increased from 2 + context.set_source_rgba(*CONNECTION_LINE_COLOR) + context.set_line_width(CONNECTION_LINE_WIDTH) context.set_line_cap(cairo.LINE_CAP_ROUND) context.set_line_join(cairo.LINE_JOIN_ROUND) @@ -1703,15 +1727,15 @@ class MyTimelineView(NavigationView): # Draw vertical line connecting all events if max_y - min_y > EVENT_MARKER_SIZE * 2: - context.set_source_rgba(0.2, 0.5, 1.0, 0.75) # Same opacity as horizontal lines - context.set_line_width(3.5) # Same width as horizontal lines + context.set_source_rgba(*CONNECTION_LINE_COLOR) + context.set_line_width(CONNECTION_LINE_WIDTH) context.move_to(vertical_line_x, min_y) context.line_to(vertical_line_x, max_y) context.stroke() # Draw horizontal lines connecting vertical line to each event marker - context.set_source_rgba(0.2, 0.5, 1.0, 0.75) # Brighter, more opaque blue - context.set_line_width(3.5) + context.set_source_rgba(*CONNECTION_LINE_COLOR) + context.set_line_width(CONNECTION_LINE_WIDTH) for event_data in person_events: # Draw horizontal line from vertical line to event marker context.move_to(vertical_line_x, event_data.y_pos)