Date: 2026-11-19
Branch: windows-engine
Status: design (awaiting approval before build)
Make the MAD Designer workspace a working report-layout studio in the WPF shell,
mirroring the Mac’s three-pane design, by closing the one real gap: the mad serve
protocol cannot read or mutate the report-layout model (RptqDocumentSection /
RptqDocumentElement) that the Mac edits in-process. This doc records how — the
protocol shape, the WPF architecture, and the delivery split. The what (palette,
minimap, canvas, inspector, undo) is already fixed by PHASE6C_DESIGNER.md and
WINDOWS_POC_PLAN.md §4 Phase 6.
mad serve gains a report-layout read method plus granular mutations that expose the
existing engine model — no report-model reimplementation in C#.MADMacSmokeTest step 5): three resizable panes
(220pt / canvas / 260pt) that stay put on resize; a minimap wired to the canvas; three
distinct non-overlapping elements from label + data field + aggregate; X/Y edits persist
and undo/redo restores geometry; cross-band moves undo/redo; zoom/grid/snap/rulers/guides;
delete/duplicate; no crashes or UI stalls.MADBarcodes. The palette shows Barcode
disabled. No zint.[Image]); the engine’s image payload is an NSImage/UIImage that
does not exist off-Apple.foregroundColor/backgroundColor are AppKit/UIKit colours in
the engine model and have no portable representation on Windows; the inspector omits the
colour wells (deferred).EngineService/MVVM and the 6b query-model work.-s to windows-engine, keep DCO and Linux verification green, leave PR #32 a draft.Chosen — granular mutations (mirrors Phase 6b). A layout-model read returns the full
snapshot; ~10 small mutation methods keyed by store identifier each mutate the Rptq*
objects and answer the same snapshot. The client holds the snapshot for display and records
inverse calls for undo. This is the proven 6b pattern and honours “expose the existing model”.
Rejected — coarse get/apply spec. A single apply-layout replacing the whole model
would make the C# client reconstruct the model (closer to reimplementing it) and force the
engine to reconcile object identities on apply. Bigger, riskier, and against the constraint.
mad serve, §6f)Every mutation returns the full layout-model object, so the client swaps its snapshot
atomically — exactly as the query-model methods do.
| method | params | result |
|---|---|---|
layout-model |
handle |
paperSize, sections[], elements[], fields[] |
handle and answer the full layout-model)| method | extra params | effect |
|---|---|---|
add-element |
kind (label|data-field|aggregate|image|line), section, x, y |
create element (default size/content), place at origin |
remove-elements |
elements: [id…] |
remove elements from their rows |
duplicate-elements |
elements: [id…] |
clone each (same kind/content/style/size), offset +16/+12 |
move-elements |
elements: [id…], section |
transfer to target section, keep relative origin |
set-element-geometry |
elements: [{id,x,y,w,h}…] |
set origin + size |
set-element-content |
element, content{…} |
type-specific content (label text / data-field binding / aggregate function+scope+field) |
set-element-typography |
elements: [id…], style{fontname,fontsize,bold,italic,underline,strikethrough,hAlign,vAlign} |
bulk typography |
set-element-box-model |
elements: [id…], box{borderTop,borderBottom,borderLeft,borderRight,padding,margin} |
bulk box model |
set-section |
section, {height,visible,pageBreak} |
band height/visibility/page-break |
set-paper-size |
paperSize |
MTPaperType int16 (Letter 2 / Legal 7 / A4 19) |
paperSize: MTPaperType int16.sections[]: { id, type (MADDocumentSectionType int16), title, height (interface height),
visible, pageBreak, groupField } — in the engine’s canonical order (Report Header, Page
Header, Group Headers, Detail, Group Footers, Page Footer, Report Footer), the same order
MADMacDocument -orderedSections yields.elements[]: { id, type (MADPrintPageElementType int16), section, x, y, w, h, text, field,
table, column, aggregateFunction, aggregateScope, aggregateGroup, fontname, fontsize, bold,
italic, underline, strikethrough, hAlign, vAlign, borderTop, borderBottom, borderLeft,
borderRight, padding, margin }.fields[]: { id, name, table, display } — the query fields (from the main query), so the
sidebar browser and the binding popup have store identifiers to bind to.Engine-side, each method calls the same factories/helpers the Mac controller uses
(newDocumentSectionOfType:, addDocumentObject:withDropPoint:managedObjectContext:,
setOriginPoint:, setSizeWidth:height:, moveElement semantics via row membership,
setInterfaceHeight:, setProducesFormFeed:), reading the live document through
[RptqDocument newDocumentReadFromManagedObjectContext: document.storeContext] so every
mutation is visible to the next read. add-element takes an explicit origin; the
non-overlapping placement heuristic (the Mac’s nextAvailableOriginInSection:) is
computed client-side, keeping the engine free of visual layout policy.
Models/LayoutModel.cs — records + Parse for the snapshot (mirrors QueryModel).EngineService — LayoutModelAsync, AddElementAsync, RemoveElementsAsync,
DuplicateElementsAsync, MoveElementsAsync, SetElementGeometryAsync,
SetElementContentAsync, SetElementTypographyAsync, SetElementBoxModelAsync,
SetSectionAsync, SetPaperSizeAsync.ViewModels/DesignerViewModel.cs — owns the LayoutModel snapshot, selection
(section + element set), zoom/grid/snap/ruler state, the non-overlap placement helper, and
the undo/redo stack (a bounded list of inverse-call closures, the WPF counterpart of the
Mac’s NSUndoManager). Every mutation goes through the stack and re-applies the snapshot.Views/DesignerCanvas.cs — a WPF Canvas drawing the bands and elements (the template
is QueryCanvas.cs), with drag-move, cross-section drag, 8-handle resize, marquee,
alignment guides, grid/snap, rulers, and inline label editing. Reports geometry commits back
to the view model.Views/DesignerMinimap.cs — miniature bands/elements + viewport box, wired to the canvas.Views/DesignerView.xaml — replaces the placeholder: top palette bar, GridSplitter
three-pane layout (220pt / canvas / 260pt), left sidebar (minimap + sections outline +
query-fields browser), right inspector (document/section card + element cards).DocumentViewModel — gains a Designer child (DesignerViewModel), loaded on open and
re-read on apply-connection, the same way Query is.LayoutModel parser, EngineService additions, DesignerViewModel (snapshot + selection +
placement), DesignerCanvas bands/elements rendering, and the three-pane shell. Headless
tests: a fresh-document protocol round-trip (add three distinct non-overlapping elements →
edit geometry → move → read back), plus an STA canvas render test (bands/elements draw and
geometry round-trips) in the existing Mad.Designer.Windows.Tests pattern.Each increment lands as its own DCO-signed commit on windows-engine, pushed to origin,
with Linux verification and DCO green. Docs (docs/project/MAD_WINDOWS.md §6f,
Windows/README.md) are updated in 6c-i.
MADHorizontalAlignment/MADVerticalAlignment int values (confirm from the headers
during implementation; the JSON carries the raw int16).duplicate-elements clones image/barcode placeholders or only the three core kinds
(label/data-field/aggregate/line — barcode is disabled, image is a placeholder).