refactor: Adjust vertical positioning for forecast icons

This commit is contained in:
ChuckBuilds
2025-04-17 17:47:20 -05:00
parent 11764dd04c
commit c4d976ab0d

View File

@@ -39,9 +39,9 @@ class WeatherManager:
# Layout constants # Layout constants
self.PADDING = 1 self.PADDING = 1
self.ICON_SIZE = { self.ICON_SIZE = {
'large': 24, 'large': 28,
'medium': 18, 'medium': 20,
'small': 12 'small': 14
} }
self.COLORS = { self.COLORS = {
'text': (255, 255, 255), 'text': (255, 255, 255),
@@ -359,9 +359,13 @@ class WeatherManager:
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['extra_dim']) fill=self.COLORS['extra_dim'])
# Draw weather icon in middle # Draw weather icon centered vertically between top/bottom text
icon_size = self.ICON_SIZE['medium'] icon_size = self.ICON_SIZE['medium'] # 20
icon_y = self.display_manager.matrix.height // 3 # Position icon in upper third top_text_height = 8 # Approx height reservation for top text
bottom_text_y = self.display_manager.matrix.height - 8 # Starting Y for bottom text
available_height_for_icon = bottom_text_y - top_text_height
# Ensure calculated y is not negative if space is very tight
icon_y = max(top_text_height, top_text_height + (available_height_for_icon - icon_size) // 2)
icon_x = center_x - icon_size // 2 icon_x = center_x - icon_size // 2
WeatherIcons.draw_weather_icon(image, forecast['condition'], icon_x, icon_y, icon_size) WeatherIcons.draw_weather_icon(image, forecast['condition'], icon_x, icon_y, icon_size)
@@ -424,9 +428,13 @@ class WeatherManager:
font=self.display_manager.small_font, font=self.display_manager.small_font,
fill=self.COLORS['extra_dim']) fill=self.COLORS['extra_dim'])
# Draw weather icon in middle # Draw weather icon centered vertically between top/bottom text
icon_size = self.ICON_SIZE['medium'] icon_size = self.ICON_SIZE['medium'] # 20
icon_y = self.display_manager.matrix.height // 3 # Position icon in upper third top_text_height = 8 # Approx height reservation for top text
bottom_text_y = self.display_manager.matrix.height - 8 # Starting Y for bottom text
available_height_for_icon = bottom_text_y - top_text_height
# Ensure calculated y is not negative if space is very tight
icon_y = max(top_text_height, top_text_height + (available_height_for_icon - icon_size) // 2)
icon_x = center_x - icon_size // 2 icon_x = center_x - icon_size // 2
WeatherIcons.draw_weather_icon(image, forecast['condition'], icon_x, icon_y, icon_size) WeatherIcons.draw_weather_icon(image, forecast['condition'], icon_x, icon_y, icon_size)