2026-11-14 04:25:51 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
# view/widgets/resizing_bg.py
|
2026-11-19 21:47:35 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
import tkinter as tk
|
|
|
|
|
from PIL import Image, ImageTk
|
|
|
|
|
|
2026-11-19 21:47:35 +00:00
|
|
|
from resources.code_res.game_constants import BG_COLOR
|
|
|
|
|
|
2026-11-14 04:25:51 +00:00
|
|
|
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
class ResizingBG(tk.Canvas):
|
|
|
|
|
"""
|
2026-11-19 21:47:35 +00:00
|
|
|
Persistentes Vollbild-Hintergrund-Canvas für das Hauptfenster:
|
|
|
|
|
- Bleibt über alle View-Wechsel hinweg bestehen (verhindert Schwarz-Flackern unter X11/Crostini & Windows).
|
|
|
|
|
- Nutzt den zentralen get_bg_patch_photo()-Cache aus AssetManager (kein doppeltes Vollbild-Skalieren).
|
|
|
|
|
- Zeichnet sofort im Konstruktor vor, falls das Elternfenster bereits eine Größe hat (0 Frames Leerlauf).
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
"""
|
|
|
|
|
|
2026-11-19 21:47:35 +00:00
|
|
|
def __init__(self, parent, assets):
|
|
|
|
|
super().__init__(
|
|
|
|
|
parent,
|
|
|
|
|
bg=BG_COLOR,
|
|
|
|
|
bd=0,
|
|
|
|
|
highlightthickness=0,
|
|
|
|
|
)
|
|
|
|
|
self.assets = assets
|
|
|
|
|
self._bg_photo: ImageTk.PhotoImage | None = None
|
|
|
|
|
self._last_size: tuple[int, int] = (0, 0)
|
|
|
|
|
self._resize_job: str | None = None
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-19 21:47:35 +00:00
|
|
|
self.bind("<Configure>", self._on_configure)
|
|
|
|
|
self.bind("<Destroy>", self._on_destroy)
|
|
|
|
|
|
|
|
|
|
# Sofortiges Vorzeichnen mit bekannter Elternfenster-Größe (vermeidet schwarzen Erst-Frame)
|
|
|
|
|
try:
|
|
|
|
|
pw = parent.winfo_width()
|
|
|
|
|
ph = parent.winfo_height()
|
|
|
|
|
if pw >= 200 and ph >= 200:
|
|
|
|
|
self._apply_bg(pw, ph)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _on_destroy(self, event=None):
|
|
|
|
|
if event is not None and event.widget is not self:
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
return
|
2026-11-19 21:47:35 +00:00
|
|
|
if self._resize_job is not None:
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
try:
|
|
|
|
|
self.after_cancel(self._resize_job)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
2026-11-19 21:47:35 +00:00
|
|
|
self._resize_job = None
|
2026-11-14 04:25:51 +00:00
|
|
|
|
2026-11-19 21:47:35 +00:00
|
|
|
def _on_configure(self, event):
|
|
|
|
|
if event.widget is not self:
|
|
|
|
|
return
|
|
|
|
|
w, h = max(1, event.width), max(1, event.height)
|
|
|
|
|
if w < 100 or h < 100 or (w, h) == self._last_size:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self._resize_job is not None:
|
|
|
|
|
try:
|
|
|
|
|
self.after_cancel(self._resize_job)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
self._resize_job = None
|
|
|
|
|
|
|
|
|
|
# Beim allerersten echten Layout sofort zeichnen, beim Ziehen am Fensterrand sanft entprellen (35 ms)
|
|
|
|
|
if self._last_size == (0, 0):
|
|
|
|
|
self._apply_bg(w, h)
|
|
|
|
|
else:
|
|
|
|
|
self._resize_job = self.after(35, self._apply_bg, w, h)
|
|
|
|
|
|
|
|
|
|
def _apply_bg(self, w: int, h: int):
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
self._resize_job = None
|
2026-11-19 21:47:35 +00:00
|
|
|
if not self.winfo_exists() or (w, h) == self._last_size:
|
feat(ui): overhaul menus, stats & dialogs to custom canvas-based Gothic UI
- Add ui_typography.py and update game_constants.py for Old London typography and new image assets
- Upgrade AssetManager with downscaled 9-slice box rendering and PIL Old London text engine
- Convert ResizingBG to full-window Canvas with automatic horizontal/vertical background switching
- Add GothEntry and two-part GothDropdown with proportional arrow cap, mousewheel scrolling, and scroll indicators
- Update ImageButton with 3-slice side caps, frame-aware auto-width, and automatic icon stripping
- Refactor GothTopbar, LoginView, MainMenuView (hover zoom), StatisticsView, StatsBoardWidget, BotSetupWidget, and AudioSettingsDialog
- Migrate Blackjack, Poker, FreeCell, Klondike, and Spider menu/stats views plus BlackjackResultDialog to frameless canvas layouts
- Fix Crostini shelf icon matching via exact X11 WM_CLASS and absolute pixmap path
2026-11-17 21:31:02 +00:00
|
|
|
return
|
|
|
|
|
self._last_size = (w, h)
|
2026-11-19 21:47:35 +00:00
|
|
|
|
|
|
|
|
photo: ImageTk.PhotoImage | None = None
|
|
|
|
|
if hasattr(self.assets, "get_bg_patch_photo"):
|
|
|
|
|
photo = self.assets.get_bg_patch_photo(w, h, 0, 0, w, h)
|
|
|
|
|
else:
|
|
|
|
|
src = (
|
|
|
|
|
self.assets.raw_bg_vertical
|
|
|
|
|
if (h > w and getattr(self.assets, "raw_bg_vertical", None) is not None)
|
|
|
|
|
else (getattr(self.assets, "raw_bg_horizontal", None) or getattr(self.assets, "raw_bg", None))
|
|
|
|
|
)
|
|
|
|
|
if src is not None:
|
|
|
|
|
rgb_src = src.convert("RGB") if src.mode != "RGB" else src
|
|
|
|
|
photo = ImageTk.PhotoImage(rgb_src.resize((w, h), Image.Resampling.BILINEAR))
|
|
|
|
|
|
|
|
|
|
if photo is None:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
self._bg_photo = photo
|
|
|
|
|
existing = self.find_withtag("root_bg_img")
|
|
|
|
|
if existing:
|
|
|
|
|
self.itemconfigure(existing[0], image=self._bg_photo)
|
|
|
|
|
else:
|
|
|
|
|
self.create_image(0, 0, image=self._bg_photo, anchor="nw", tags=("root_bg_img",))
|
|
|
|
|
self.tag_lower("root_bg_img")
|
|
|
|
|
|
|
|
|
|
def clear_foreground(self):
|
|
|
|
|
"""
|
|
|
|
|
Räumt alle Vordergrund-Elemente UND fremde Event-Bindings (z. B. aus LoginView / MainMenuView)
|
|
|
|
|
restlos ab, lässt aber das gerenderte Hintergrundbild ('root_bg_img') stehen.
|
|
|
|
|
"""
|
|
|
|
|
# 1. Alte <Configure>-Handler vorheriger Views entfernen und nur eigenen BG-Handler wiederherstellen
|
|
|
|
|
self.unbind("<Configure>")
|
|
|
|
|
self.bind("<Configure>", self._on_configure)
|
|
|
|
|
|
|
|
|
|
# 2. Aufgesetzte Sub-Widgets (Buttons, Dropdowns, Entries) zerstören
|
|
|
|
|
for sub in list(self.winfo_children()):
|
|
|
|
|
try:
|
|
|
|
|
sub.destroy()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# 3. Alle gezeichneten Canvas-Items löschen AUSSER dem Hintergrundbild 'root_bg_img'
|
|
|
|
|
keep_ids = set(self.find_withtag("root_bg_img"))
|
|
|
|
|
for item_id in self.find_all():
|
|
|
|
|
if item_id not in keep_ids:
|
|
|
|
|
self.delete(item_id)
|