Skip to content

feat: granular label/action styling, GUI settings persistence, and undo/redo (v0.11.0)#101

Merged
edwardchalstrey1 merged 17 commits into
mainfrom
label-background-fix
Jun 4, 2026
Merged

feat: granular label/action styling, GUI settings persistence, and undo/redo (v0.11.0)#101
edwardchalstrey1 merged 17 commits into
mainfrom
label-background-fix

Conversation

@edwardchalstrey1
Copy link
Copy Markdown
Member

@edwardchalstrey1 edwardchalstrey1 commented Jun 3, 2026

Overview

This PR adds per-player/per-level control over label backgrounds and action label positioning, a new gui_settings.yaml persistence layer that auto-saves and restores per-game settings, a multi-step undo/redo system, a Settings download button, and a suite of GUI improvements including a dynamic colour-scheme palette and a colorblind-accessible default.


API & Core (core.py, cli.py)

Label backgroundslabel_bg now accepts bool | dict[int, bool], enabling selective application per player or per level:

  • label_bg_by="player"|"level" — how to interpret a dict key
  • label_bg_style="player_bg"|"white_bg" — player-colour background with white text, or vice versa
  • CLI: --label-bg=1,2, --label-bg-by=player, --label-bg-style=white_bg
  • New helpers _any_label_bg(), _label_bg_active(player, level) used internally

Action label positioningaction_label_position now accepts float | dict[int, float] for per-player or per-level control:

  • action_label_position_by="player"|"level" — dict key interpretation
  • vary_action_label_positions=True — automatically distributes labels evenly across sibling edges
  • vary_action_label_positions_by, vary_action_label_positions_choices for selective application
  • CLI: --action-label-position=0:0.3,1:0.7, --vary-action-label-positions, etc.

New public functionget_game_levels(game_source, level_scaling, sublevel_scaling) returns the sorted list of actual level values present in the tree (not just the max), with correct scaling for pygambit games. Exported from draw_tree.

All generate_*, draw_tree, and ef_to_tex signatures updated; commandline() return tuple extended accordingly.


GUI (app.py)

Settings download — "Settings" button in the Downloads expander writes the current GUI configuration as a YAML snippet ready to paste into the overrides: section of gui_settings.yaml.

Color scheme palette — Default changed from "custom" to "colorblind". The Palette section now appears for every non-"default" scheme, pre-filled with that scheme's actual colours. Editing any colour auto-switches to "custom"; switching back to a named scheme resets the palette to its defaults.

Per-game settings persistence — A new gui_settings.yaml file (committed, not gitignored) stores defaults and per-game overrides. Settings are auto-saved on every change (only values that differ from draw_tree defaults are stored). When the user switches to a game, its saved settings are automatically restored.

Undo / Redo / Reset — Three sidebar buttons with a bounded 50-step undo stack. ↩ Undo / ↪ Redo do full widget-state snapshot swaps; ↺ Reset removes the current game's overrides from gui_settings.yaml and reloads the effective defaults.

Label styling UI — "Enable Label Background" expands into a scope selector (All / By Player / By Level) with multi-select for selective application, a style toggle (player-colour vs white background), and an opacity slider.

Action label positioning UI — Positioning Mode (Global / By Player / By Level) provides per-player or per-level sliders. "Vary Action Label Positions" checkbox with "Vary by" sub-selector applies automatic even spacing, disabling the manual position controls.

Level-based selection fixesget_game_levels (with correct level_scaling) replaces count_levels for populating level multiselects and sliders, ensuring only levels that actually exist in the tree are shown and that selections take effect correctly.


Tests & Docs

  • TestLabelBackground extended with 9 new cases covering dict label_bg, label_bg_style, and CLI parsing
  • All existing commandline() tuple unpacks updated for the two new return values (label_bg_by, label_bg_style)
  • docs/python_api.md and docs/cli.md updated with all new parameters

Dependencies & version

  • pyyaml added to dependencies
  • Version bumped 0.10.0 → 0.11.0

… configuration overrides for specific models
@edwardchalstrey1 edwardchalstrey1 changed the title Update label backgrounds and action label positioning controls feat: granular label/action styling, GUI settings persistence, and undo/redo (v0.11.0) Jun 3, 2026
…prove session state synchronization when loading game settings
@edwardchalstrey1 edwardchalstrey1 merged commit 1f67f6a into main Jun 4, 2026
4 checks passed
@edwardchalstrey1 edwardchalstrey1 deleted the label-background-fix branch June 4, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant