BigUI WIP: Panel standardization

This commit is contained in:
firestarsdog
2026-06-15 21:15:52 -04:00
parent 2dc441d621
commit 57d7796edb
5 changed files with 43 additions and 67 deletions
@@ -558,6 +558,24 @@ class PanelManagerView(AetherInteractiveMixin, Widget):
return 0.0
return sum(sections) + self.METRICS.section_gap * (len(sections) - 1)
def _compute_two_column_height(self, left_height: float) -> float:
return max(self._scroll_rect.height if self._scroll_rect else 0.0, left_height)
def _draw_two_column_tile_grid(self, grid: TileGrid, x: float, y: float, column_width: float, matching_height: float, title: str | None = None, style: PanelStyle | None = None):
if style is None:
style = self.PANEL_STYLE
grid._columns = 2
if title:
draw_section_header(rl.Rectangle(x, y, column_width, self.METRICS.section_header_height), title, style=style)
draw_y = y + self.METRICS.section_header_height + self.METRICS.section_header_gap
draw_h = max(0.0, matching_height - (self.METRICS.section_header_height + self.METRICS.section_header_gap))
else:
draw_y = y
draw_h = max(0.0, matching_height)
draw_list_group_shell(rl.Rectangle(x, draw_y, column_width, draw_h), style=style)
self._render_page_grid(grid, rl.Rectangle(x + 12, draw_y + 12, column_width - 24, max(0.0, draw_h - 24)))
# ── convenience builders ──────────────────────────────────
def _make_toggle_tile(self, d: dict) -> ToggleTile:
@@ -249,20 +249,13 @@ class SteeringManagerView(PanelManagerView):
tiles_height = 0.0
if self._toggle_grid.tiles:
if self._uses_two_columns(width):
self._toggle_grid._columns = 2
column_w = self._column_width(width)
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
tiles_height = self._section_block_height(grid_h + 24)
else:
if not self._uses_two_columns(width):
self._toggle_grid._columns = 3
tiles_content_h = self._toggle_grid.measure_height(width - 24)
tiles_height = SECTION_GAP + self._section_block_height(tiles_content_h + 24)
if self._uses_two_columns(width):
vh = self._scroll_rect.height if self._scroll_rect and self._scroll_rect.height > 0 else tiles_height
return max(left_h, vh)
return self._compute_two_column_height(left_h)
return left_h + tiles_height
def _draw_scroll_content(self, rect: rl.Rectangle, width: float):
@@ -298,17 +291,8 @@ class SteeringManagerView(PanelManagerView):
if self._toggle_grid.tiles:
rx = x + column_w + self.COLUMN_GAP
draw_section_header(rl.Rectangle(rx, y, column_w, SECTION_HEADER_HEIGHT),
tr("Toggles"), style=PANEL_STYLE)
right_container_y = y + SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
self._toggle_grid._columns = 2
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
container_h = grid_h + 24
draw_list_group_shell(rl.Rectangle(rx, right_container_y, column_w, container_h), style=PANEL_STYLE)
self._render_page_grid(self._toggle_grid, rl.Rectangle(rx + 12, right_container_y + 12, column_w - 24, grid_h))
left_h = curr_y - y
self._draw_two_column_tile_grid(self._toggle_grid, rx, y, column_w, left_h, title=tr("Toggles"), style=PANEL_STYLE)
else:
curr_y = y
for section in sections:
@@ -246,17 +246,11 @@ class SoundsManagerView(PanelManagerView):
cd_h = self._adjustor_rows[self._controller.COOLDOWN_KEY].measure_height(col_width)
tiles_content_h = self._toggle_grid.measure_height(col_width - 24)
# col_w is the width of each tile in the 2-column grid
col_w = (col_width - 24 - 12) / 2
# Standardize right-side grid height: 2x3 rectangular layout (same container as before)
self._tile_grid_h = 2 * col_w + 12
right_column_total_h = cd_h + SECTION_GAP + (GROUP_HEADER_HEIGHT + GROUP_HEADER_GAP) + (self._tile_grid_h + 24.0)
tiles_container_h = left_column_total_h - cd_h - SECTION_GAP
self._tiles_container_h = max(130.0, tiles_container_h)
section_overhead = SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
min_h = self._scroll_rect.height if self._scroll_rect else 0.0
return max(min_h, section_overhead + max(left_column_total_h, right_column_total_h))
return self._compute_two_column_height(section_overhead + max(left_column_total_h, cd_h + SECTION_GAP + self._tiles_container_h))
def _draw_header(self, rect: rl.Rectangle):
draw_settings_panel_header(rect, tr("Sounds & Alerts"), tr("Manage system volumes and custom alert toggles."), subtitle_size=24)
@@ -344,9 +338,8 @@ class SoundsManagerView(PanelManagerView):
current_y = self._draw_group_header(x + 24, current_y, width - 48, tr("CUSTOM ALERTS"))
draw_list_group_shell(rl.Rectangle(x, current_y, width, self._tile_grid_h + 24), style=PANEL_STYLE)
self._render_page_grid(self._toggle_grid, rl.Rectangle(x + 12, current_y + 12, width - 24, self._tile_grid_h))
grid_container_h = self._tiles_container_h - (GROUP_HEADER_HEIGHT + GROUP_HEADER_GAP)
self._draw_two_column_tile_grid(self._toggle_grid, x, current_y, width, grid_container_h, title=None, style=PANEL_STYLE)
class StarPilotSoundsLayout(_SettingsPage):
@@ -311,7 +311,7 @@ class SystemSettingsManagerView(PanelManagerView):
self._connectivity_tile_grid.set_touch_valid_callback(lambda: self._scroll_panel.is_touch_valid())
self._child(self._connectivity_tile_grid)
self._page_grid = self._connectivity_tile_grid
self._set_toggle_pages([self._toggle_defs[i:i+6] for i in range(0, len(self._toggle_defs), 6)])
self._set_toggle_pages([self._toggle_defs[i:i+4] for i in range(0, len(self._toggle_defs), 4)])
self._drive_mode_control = self._child(
AetherSegmentedControl(
@@ -479,13 +479,14 @@ class SystemSettingsManagerView(PanelManagerView):
if self._uses_two_columns(width):
column_w = self._column_width(width)
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
container_h = grid_h + 24
right_h = self._section_block_height(container_h)
left_h = display_h + SECTION_GAP + power_h
min_h = self._scroll_rect.height if self._scroll_rect else 0.0
return max(min_h, left_h, right_h)
display_container_h = self._slider_section_height(self._display_slider_keys, column_w)
power_container_h = self._slider_section_height(self._power_slider_keys, column_w)
header_overhead = (SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP) * 2
viewport_h = self._scroll_rect.height if self._scroll_rect else 0.0
needed_gap = viewport_h - (display_container_h + power_container_h + header_overhead)
section_gap = max(AETHER_LIST_METRICS.section_gap, needed_gap)
left_h = display_container_h + power_container_h + header_overhead + section_gap
return self._compute_two_column_height(left_h)
else:
tiles_content_h = self._connectivity_tile_grid.measure_height(width - 24)
return self._stacked_section_height([display_h, power_h, tiles_content_h + 24])
@@ -517,10 +518,9 @@ class SystemSettingsManagerView(PanelManagerView):
self._draw_slider_section(power_y, x, column_w, tr("Power"), self._power_slider_keys)
container_top = y + SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
container_height = grid_h + 24
self._draw_connectivity_tiles_column(container_top, x + column_w + self.COLUMN_GAP, column_w, container_height)
left_h = display_container_h + power_container_h + header_overhead + section_gap
container_height = left_h - (SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP)
self._draw_two_column_tile_grid(self._connectivity_tile_grid, x + column_w + self.COLUMN_GAP, container_top, column_w, container_height)
return
y = self._draw_slider_section(y, x, width, tr("Display"), self._display_slider_keys)
y += SECTION_GAP
@@ -528,10 +528,6 @@ class SystemSettingsManagerView(PanelManagerView):
y += SECTION_GAP
self._draw_connectivity_tiles_section(y, x, width)
def _draw_connectivity_tiles_column(self, y: float, x: float, width: float, height: float):
draw_list_group_shell(rl.Rectangle(x, y, width, height), style=PANEL_STYLE)
self._render_page_grid(self._connectivity_tile_grid, rl.Rectangle(x + 12, y + 12, width - 24, height - 24))
def _draw_connectivity_tiles_section(self, y: float, x: float, width: float):
tiles_content_h = self._connectivity_tile_grid.measure_height(width - 24)
@@ -327,21 +327,14 @@ class VehicleSettingsManagerView(PanelManagerView):
# Right Column/Features height
tiles_height = 0.0
if self._toggle_grid.tiles:
if self._uses_two_columns(width):
self._toggle_grid._columns = 2
column_w = self._column_width(width)
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
tiles_height = self._section_block_height(grid_h + 24)
else:
if not self._uses_two_columns(width):
self._toggle_grid._columns = 3
avail_w = width - 24
tiles_content_h = self._toggle_grid.measure_height(avail_w)
tiles_height = SECTION_GAP + self._section_block_height(tiles_content_h + 24)
if self._uses_two_columns(width):
vh = self._scroll_rect.height if self._scroll_rect and self._scroll_rect.height > 0 else tiles_height
return max(left_h, vh)
return self._compute_two_column_height(left_h)
return left_h + tiles_height
def _draw_scroll_content(self, rect: rl.Rectangle, width: float):
@@ -399,16 +392,8 @@ class VehicleSettingsManagerView(PanelManagerView):
# Right Column: Features
if self._toggle_grid.tiles:
rx = x + column_w + self.COLUMN_GAP
draw_section_header(rl.Rectangle(rx, y, column_w, SECTION_HEADER_HEIGHT), tr("Features"), style=PANEL_STYLE)
right_container_y = y + SECTION_HEADER_HEIGHT + SECTION_HEADER_GAP
self._toggle_grid._columns = 2
col_w = (column_w - 24 - 12) / 2
grid_h = 2 * col_w + 12
container_h = grid_h + 24
draw_list_group_shell(rl.Rectangle(rx, right_container_y, column_w, container_h), style=PANEL_STYLE)
self._render_page_grid(self._toggle_grid, rl.Rectangle(rx + 12, right_container_y + 12, column_w - 24, grid_h))
left_h = curr_y - y
self._draw_two_column_tile_grid(self._toggle_grid, rx, y, column_w, left_h, title=tr("Features"), style=PANEL_STYLE)
else:
# Single Column Stacked Layout
draw_section_header(rl.Rectangle(x, y, width, SECTION_HEADER_HEIGHT), tr("Vehicle Identity"), style=PANEL_STYLE)