from typing import Callable from rio import Component, Rectangle, Grid, Column, Row, Text, TextStyle, Color from src.ez_lan_manager.components.SeatingPlanPixels import SeatPixel, WallPixel, InvisiblePixel, TextPixel from src.ez_lan_manager.types.Seat import Seat MAX_GRID_WIDTH_PIXELS = 34 MAX_GRID_HEIGHT_PIXELS = 45 class SeatingPlanLegend(Component): def build(self) -> Component: return Column( Text("Legende", style=TextStyle(fill=self.session.theme.neutral_color), justify="center", margin=1), Row( Text("L = Luxus Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)), Text("N = Normaler Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)), ), Row( Rectangle( content=Column( Text(f"Freier Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False), Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False, overflow="wrap") ), min_width=1, min_height=1, fill=self.session.theme.success_color, grow_x=False, grow_y=False, hover_fill=self.session.theme.success_color, transition_time=0.4, ripple=True ), Rectangle( content=Column( Text(f"Belegter Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False), Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False, overflow="wrap") ), min_width=1, min_height=1, fill=self.session.theme.danger_color, grow_x=False, grow_y=False, hover_fill=self.session.theme.danger_color, transition_time=0.4, ripple=True ), Rectangle( content=Column( Text(f"Eigener Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False), Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False, overflow="wrap") ), min_width=1, min_height=1, fill=Color.from_hex("800080"), grow_x=False, grow_y=False, hover_fill=Color.from_hex("800080"), transition_time=0.4, ripple=True ), margin=1, spacing=1 ) ) class SeatingPlan(Component): seat_clicked_cb: Callable seating_info: list[Seat] def get_seat(self, seat_id: str) -> Seat: return next(filter(lambda seat: seat.seat_id == seat_id, self.seating_info)) """ This seating plan is for the community center "Bottenhorn" """ def build(self) -> Component: grid = Grid() # Outlines for column_id in range(0, MAX_GRID_WIDTH_PIXELS): grid.add(InvisiblePixel(), row=0, column=column_id) for y in range(0, 13): grid.add(WallPixel(), row=y, column=0) for y in range(13, 19): grid.add(InvisiblePixel(), row=y, column=0) for y in range(19, MAX_GRID_HEIGHT_PIXELS): grid.add(WallPixel(), row=y, column=0) # Block A block_a_margin_left = 12 block_a_margin_top = 1 (grid .add(SeatPixel("A01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A01")), row=block_a_margin_top, column=block_a_margin_left, width=2, height=3) .add(SeatPixel("A02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A02")), row=block_a_margin_top + 4, column=block_a_margin_left, width=2, height=3) .add(SeatPixel("A03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A03")), row=block_a_margin_top + 8, column=block_a_margin_left, width=2, height=3) .add(SeatPixel("A10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A10")), row=block_a_margin_top, column=block_a_margin_left + 3, width=2, height=3) .add(SeatPixel("A11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A11")), row=block_a_margin_top + 4, column=block_a_margin_left + 3, width=2, height=3) .add(SeatPixel("A12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("A12")), row=block_a_margin_top + 8, column=block_a_margin_left + 3, width=2, height=3) ) # Block B block_b_margin_left = 20 block_b_margin_top = 1 (grid .add(SeatPixel("B01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B01")), row=block_b_margin_top, column=block_b_margin_left, width=2, height=3) .add(SeatPixel("B02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B02")), row=block_b_margin_top + 4, column=block_b_margin_left, width=2, height=3) .add(SeatPixel("B03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B03")), row=block_b_margin_top + 8, column=block_b_margin_left, width=2, height=3) .add(SeatPixel("B10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B10")), row=block_b_margin_top, column=block_b_margin_left + 3, width=2, height=3) .add(SeatPixel("B11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B11")), row=block_b_margin_top + 4, column=block_b_margin_left + 3, width=2, height=3) .add(SeatPixel("B12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("B12")), row=block_b_margin_top + 8, column=block_b_margin_left + 3, width=2, height=3) ) # Block C block_c_margin_left = 28 block_c_margin_top = 1 (grid .add(SeatPixel("C01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C01")), row=block_c_margin_top, column=block_c_margin_left, width=2, height=3) .add(SeatPixel("C02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C02")), row=block_c_margin_top + 4, column=block_c_margin_left, width=2, height=3) .add(SeatPixel("C03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C03")), row=block_c_margin_top + 8, column=block_c_margin_left, width=2, height=3) .add(SeatPixel("C10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C10")), row=block_c_margin_top, column=block_c_margin_left + 3, width=2, height=3) .add(SeatPixel("C11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C11")), row=block_c_margin_top + 4, column=block_c_margin_left + 3, width=2, height=3) .add(SeatPixel("C12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("C12")), row=block_c_margin_top + 8, column=block_c_margin_left + 3, width=2, height=3) ) # Block D block_d_margin_left = 20 block_d_margin_top = 20 (grid .add(SeatPixel("D01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D01")), row=block_d_margin_top, column=block_d_margin_left, width=2, height=3) .add(SeatPixel("D02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D02")), row=block_d_margin_top + 4, column=block_d_margin_left, width=2, height=3) .add(SeatPixel("D03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D03")), row=block_d_margin_top + 8, column=block_d_margin_left, width=2, height=3) .add(SeatPixel("D10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D10")), row=block_d_margin_top, column=block_d_margin_left + 3, width=2, height=3) .add(SeatPixel("D11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D11")), row=block_d_margin_top + 4, column=block_d_margin_left + 3, width=2, height=3) .add(SeatPixel("D12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("D12")), row=block_d_margin_top + 8, column=block_d_margin_left + 3, width=2, height=3) ) # Block E block_e_margin_left = 28 block_e_margin_top = 20 (grid .add(SeatPixel("E01", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E01")), row=block_e_margin_top, column=block_e_margin_left, width=2, height=3) .add(SeatPixel("E02", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E02")), row=block_e_margin_top + 4, column=block_e_margin_left, width=2, height=3) .add(SeatPixel("E03", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E03")), row=block_e_margin_top + 8, column=block_e_margin_left, width=2, height=3) .add(SeatPixel("E10", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E10")), row=block_e_margin_top, column=block_e_margin_left + 3, width=2, height=3) .add(SeatPixel("E11", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E11")), row=block_e_margin_top + 4, column=block_e_margin_left + 3, width=2, height=3) .add(SeatPixel("E12", on_press_cb=self.seat_clicked_cb, seat=self.get_seat("E12")), row=block_e_margin_top + 8, column=block_e_margin_left + 3, width=2, height=3) ) # Middle Wall for y in range(0, 13): grid.add(WallPixel(), row=y, column=10) for y in range(19, MAX_GRID_HEIGHT_PIXELS): grid.add(WallPixel(), row=y, column=10) # Stage for x in range(11, MAX_GRID_WIDTH_PIXELS): grid.add(WallPixel(), row=35, column=x) grid.add(TextPixel(text="Bühne"), row=36, column=11, width=24, height=9) # Drinks grid.add(TextPixel(text="G\ne\nt\nr\nä\nn\nk\ne"), row=21, column=11, width=3, height=11) # Sleeping grid.add(TextPixel(icon_name="material/bed"), row=1, column=1, width=4, height=11) # Toilet grid.add(TextPixel(icon_name="material/floor", no_outline=True), row=1, column=7, width=3, height=2) grid.add(TextPixel(icon_name="material/north", no_outline=True), row=3, column=7, width=3, height=2) grid.add(TextPixel(icon_name="material/wc"), row=5, column=7, width=3, height=2) # Entry/Helpdesk grid.add(TextPixel(text="Einlass\n &Orga"), row=19, column=3, width=7, height=5) # Wall below Entry/Helpdesk for y in range(24, MAX_GRID_HEIGHT_PIXELS): grid.add(WallPixel(), row=y, column=3) # Entry Arrow grid.add(TextPixel(icon_name="material/east", no_outline=True), row=15, column=1, width=2, height=2) return Rectangle( content=grid, grow_x=True, grow_y=True, stroke_color=self.session.theme.neutral_color, stroke_width=0.1, fill=self.session.theme.primary_color, margin=0.5 )