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-26 22:50:56 +00:00
|
|
|
from view.layout_mode import LayoutMode
|
2026-11-19 21:47:35 +00:00
|
|
|
|
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
|
|
|
def __init__(self, parent, assets):
|
2026-11-26 22:50:56 +00:00
|
|
|
super().__init__(parent, bg=BG_COLOR, bd=0, highlightthickness=0)
|
2026-11-19 21:47:35 +00:00
|
|
|
self.assets = assets
|
|
|
|
|
self._bg_photo: ImageTk.PhotoImage | None = None
|
2026-11-26 22:50:56 +00:00
|
|
|
self._last_size: tuple[bool, int, int] = (False, 0, 0)
|
2026-11-19 21:47:35 +00:00
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
try:
|
2026-11-26 22:50:56 +00:00
|
|
|
pw, ph = parent.winfo_width(), parent.winfo_height()
|
2026-11-19 21:47:35 +00:00
|
|
|
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)
|
2026-11-26 22:50:56 +00:00
|
|
|
compact = LayoutMode.is_compact(w, h)
|
|
|
|
|
if w < 100 or h < 100 or (compact, w, h) == self._last_size:
|
2026-11-19 21:47:35 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if self._resize_job is not None:
|
|
|
|
|
try:
|
|
|
|
|
self.after_cancel(self._resize_job)
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
self._resize_job = None
|
|
|
|
|
|
2026-11-26 22:50:56 +00:00
|
|
|
if self._last_size[1] == 0:
|
2026-11-19 21:47:35 +00:00
|
|
|
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-26 22:50:56 +00:00
|
|
|
if not self.winfo_exists():
|
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-26 22:50:56 +00:00
|
|
|
compact = LayoutMode.is_compact(w, h)
|
|
|
|
|
if (compact, w, h) == self._last_size:
|
|
|
|
|
return
|
|
|
|
|
self._last_size = (compact, w, h)
|
2026-11-19 21:47:35 +00:00
|
|
|
|
2026-11-26 22:50:56 +00:00
|
|
|
photo = self.assets.get_bg_patch_photo(w, h, 0, 0, w, h)
|
2026-11-19 21:47:35 +00:00
|
|
|
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):
|
|
|
|
|
self.unbind("<Configure>")
|
|
|
|
|
self.bind("<Configure>", self._on_configure)
|
|
|
|
|
for sub in list(self.winfo_children()):
|
|
|
|
|
try:
|
|
|
|
|
sub.destroy()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
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)
|