Reworked UI for easier workflow.
This commit is contained in:
74
ptlinux/ui/components/header.py
Normal file
74
ptlinux/ui/components/header.py
Normal file
@@ -0,0 +1,74 @@
|
||||
"""Dashboard header construction."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from ..viewmodels.dashboard import preloader_logo_subsample_factor
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class DashboardHeader:
|
||||
frame: Any
|
||||
version: Any
|
||||
logo: Any
|
||||
|
||||
|
||||
def build_dashboard_header(
|
||||
parent: Any,
|
||||
*,
|
||||
widgets: Any,
|
||||
tk_module: Any,
|
||||
launcher_version: str,
|
||||
window_icon: Any | None,
|
||||
) -> DashboardHeader:
|
||||
"""Build the shared content frame and branded dashboard heading."""
|
||||
|
||||
frame = widgets.Frame(parent, style="Root.TFrame", padding=12)
|
||||
frame.pack(fill="both", expand=True)
|
||||
header = widgets.Frame(frame, style="Root.TFrame")
|
||||
header.pack(fill="x", pady=(0, 8))
|
||||
logo = tk_module.Canvas(
|
||||
header,
|
||||
width=42,
|
||||
height=42,
|
||||
background="#0c0908",
|
||||
highlightthickness=0,
|
||||
borderwidth=0,
|
||||
)
|
||||
dashboard_header_icon = None
|
||||
icon: Any = window_icon
|
||||
if icon is not None:
|
||||
try:
|
||||
header_icon_factor = preloader_logo_subsample_factor(
|
||||
icon.width(),
|
||||
icon.height(),
|
||||
max_dimension=40,
|
||||
)
|
||||
dashboard_header_icon = icon.subsample(
|
||||
header_icon_factor,
|
||||
header_icon_factor,
|
||||
)
|
||||
except tk_module.TclError:
|
||||
dashboard_header_icon = None
|
||||
if dashboard_header_icon is not None:
|
||||
logo.create_image(21, 21, image=dashboard_header_icon)
|
||||
logo.image = dashboard_header_icon
|
||||
logo.pack(side="left", padx=(0, 9))
|
||||
brand = widgets.Frame(header, style="Root.TFrame")
|
||||
brand.pack(side="left", fill="x", expand=True)
|
||||
widgets.Label(brand, text="PRISTONTALE EU", style="Brand.TLabel").pack(anchor="w")
|
||||
widgets.Label(
|
||||
brand,
|
||||
text="PRISTONTALE EU · NATIVE LINUX LAUNCHER",
|
||||
style="Tagline.TLabel",
|
||||
).pack(anchor="w", pady=(1, 0))
|
||||
version = tk_module.StringVar(
|
||||
value=f"Launcher {launcher_version} · checking official game build…"
|
||||
)
|
||||
widgets.Label(header, textvariable=version, style="Tagline.TLabel").pack(
|
||||
side="right",
|
||||
anchor="e",
|
||||
)
|
||||
return DashboardHeader(frame=frame, version=version, logo=logo)
|
||||
Reference in New Issue
Block a user