Skip to content

Move simulation state and controls into SimulationController - #14

Merged
code4teaching merged 25 commits into
editor-storefrom
simulation-controller
Oct 19, 2026
Merged

code4teaching merged 25 commits into
editor-storefrom
simulation-controller

Conversation

@code4teaching

Copy link
Copy Markdown
Owner

Requested by Holger · project thread

Before: ContentView held the simulation engine, the play task, the input text and the simulation mode flag as six @State properties, plus about 100 lines of play/pause/step/input logic.

After: all of that lives in Simulation/SimulationController.swift. The simulation should behave exactly as before.

How: SimulationController is an @Observable class created with the tabs model, like DiagramEditorDocumentServices. It moves the step marker by setting the current tab's selection. The step delay and highlight mode are read from UserDefaults at each step, the same keys the @AppStorage properties used. ContentView keeps isSimulationMode, beginSimulationMode and endSimulationMode as one-line forwards. Step 4 of the plan; stacked on #13.

Check on Mac and iPad: play, pause, single step, stop; an input: statement pauses play and resumes after OK; changing the step delay or the highlight mode in the settings while playing; leaving simulation mode keeps a selection.


Generated by Claude Code

The engine, play/pause task, input text and the simulation mode flag
move from ContentView @State into an @observable SimulationController.
The step delay and highlight mode are read from UserDefaults at each
step, as the @AppStorage values were before.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
@code4teaching code4teaching self-assigned this Oct 18, 2026
- Palette/PaletteActionList.swift: palette rows, drag preview and the
  action buttons below; actions come in as closures.
- Simulation/SimulationDetailView.swift: canvas plus state panel layout
  for simulation mode, driven by SimulationController.
- ContentView keeps the action logic (toggleSimulationMode,
  openCodeGenerator) and the simulation canvas.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
claude and others added 23 commits October 18, 2026 22:25
- VisuStructCore: VisuStructDocumentEditing.multiwayAncestorPath and
  caseIndex(of:inMultiwayAt:), with tests.
- Inspector/InspectorElementHints.swift: line editor placeholder and
  condition hint line per element type.
- Remove the unused statementIOModeIfApplicable().

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
The four export actions in ContentView each rendered the diagram and
mapped errors themselves. Export/DiagramExporter.swift now does that;
ContentView only stores the share payloads it returns.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
- DiagramCanvasView.swift: inputs, state, layout and body, clipboard.
- DiagramCanvasDropZones.swift: drop bands, tap insert targets and
  applying drops.
- DiagramCanvasRenderer.swift: Canvas drawing of cells, lines and text.

The two new files are extensions of DiagramCanvasView, so members they
share lose their `private`. Code is moved unchanged otherwise.

No behavior change intended.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the portrait simulation layout from main into
SimulationDetailView.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
Carries the VoiceOver block labels from main into
DiagramCanvasDropZones.swift.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cp4EQgFQyGbM8MVLiWbJKQ
# Conflicts:
#	VisuStruct-iOS/VisuStructXcodeOpen/VisuStruct/ContentView.swift
Split DiagramCanvasView into view, drop zones and renderer
Bundle PNG, file, PDF and print export in DiagramExporter
Move inspector hints and Fallauswahl path helpers out of ContentView
Extract PaletteActionList and SimulationDetailView from ContentView
@code4teaching
code4teaching merged commit 6c6a3be into editor-store Oct 19, 2026
2 checks passed
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.

2 participants