Development Strip Editor Code Map - ShadobaDev/Platemaker-qt GitHub Wiki

Strip editor β€” code map

Where the code for each part of the screen lives, what each folder may use, and how the parts talk. The why is in the tool framework; the file-by-file recipes for adding a tool, a shape or a kind of object are in Extending the strip editor.

The screen is the folder tree

Every folder under widgets/stripeditor/ is one region of the editor, named as it is on screen.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ TOOL RAIL     β”‚                                  β”‚ OBJECT STATE          β”‚
β”‚ toolrail/     β”‚                                  β”‚ objectstate/          β”‚
β”‚               β”‚          CANVAS                  β”‚                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€          canvas/                 β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ TOOL OPTIONS  β”‚                                  β”‚ OBJECT STACK          β”‚
β”‚ tooloptions/  β”‚   what is drawn on it: objects/  β”‚ objectstack/          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
      editor.* (the root) builds all five and wires them together

Two folders are not regions. objects/ is what sits on the canvas and the controller that owns it. properties/ holds the editors that TOOL OPTIONS and OBJECT STATE both show.

Folders and their files

widgets/stripeditor/
β”œβ”€β”€ editor.{hpp,cpp,ui}        the shell: builds the regions, wires them, zoom, the grade's glue
β”œβ”€β”€ presetstore.*              named looks: built-ins, the user library, packs
β”œβ”€β”€ scrolledpage.hpp           wraps a panel page in a scroll area
β”œβ”€β”€ toolrail/                  LEFT, TOP
β”‚   β”œβ”€β”€ toolregistry.*           the tool table: one row per tool, what it does to the canvas
β”‚   β”œβ”€β”€ toolrail.*               a tile per row, and the colour pair under them
β”‚   β”œβ”€β”€ colourpair.*             primary/secondary colours: furniture, not a tool
β”‚   └── cursors.*                which cursor, from the tool and what is under the pointer
β”œβ”€β”€ tooloptions/               LEFT, BOTTOM: what the next object will be
β”‚   β”œβ”€β”€ tooloptionsstack.*       one page per tool, and the page for tools with none
β”‚   β”œβ”€β”€ bubbletooloptions.*      Speech bubble and Text
β”‚   β”œβ”€β”€ artworktooloptions.*     Artwork: which picture the next placement puts down
β”‚   └── gradetooloptions.*/.ui   Colour correction
β”œβ”€β”€ canvas/                    CENTRE: the strip and what a press on it does
β”‚   β”œβ”€β”€ stripitem.*              draws every page as one seam-free item
β”‚   β”œβ”€β”€ pagesource.*             page memory: proxy, sharp and graded images
β”‚   β”œβ”€β”€ canvasinput.*            the viewport's event filter, routed by the armed tool
β”‚   └── sampling.*               the colour under the eyedropper
β”œβ”€β”€ objects/                   what is placed on the strip
β”‚   β”œβ”€β”€ object.*                 the base every object answers to
β”‚   β”œβ”€β”€ bubbleobject.*           a balloon or lettering Platemaker drew (plain text is a
β”‚   β”‚                            bubble with no balloon)
β”‚   β”œβ”€β”€ artworkobject.*          imported artwork, raster or vector
β”‚   β”œβ”€β”€ objectcontroller.*       the objects, the selection, the drag, and every operation
β”‚   β”œβ”€β”€ placement.*              a Create tool's drag: the rubber band and what it places
β”‚   β”œβ”€β”€ resize.*                 the eight grips' resize maths, a pure function
β”‚   β”œβ”€β”€ selectionchrome.*        the selection's box, grips and tail handles, above every object
β”‚   └── striplayout.*            the strip's pages: where each sits, what an overlay anchors to
β”œβ”€β”€ properties/                SHARED by TOOL OPTIONS and OBJECT STATE: one editor per group
β”‚   β”œβ”€β”€ propertygroup.*          the group list
β”‚   β”œβ”€β”€ propertygroupeditor.*    the base: live `changed`, settled `committed`
β”‚   β”œβ”€β”€ propertygroupset.*       a balloon's four look editors, and the rules for applying them
β”‚   β”œβ”€β”€ shapeeditor.* skineditor.* styleeditor.* texteditor.*
β”‚   β”œβ”€β”€ taileditor.* taillisteditor.* nexttaileditor.*
β”‚   β”œβ”€β”€ blendeditor.*            the one property every kind carries
β”‚   └── colouradjustment.*       one named part of the grade
β”œβ”€β”€ objectstate/               RIGHT, TOP: what the selected thing is
β”‚   β”œβ”€β”€ objectstatestack.*       which panel shows, from what is selected
β”‚   β”œβ”€β”€ objectstate.*            an object, several, or a tail
β”‚   └── stripstate.*             the strip or a page
└── objectstack/               RIGHT, BOTTOM: every object in composite order
    β”œβ”€β”€ objectstack.*            the tree: rows, chips, drag to reorder, mute
    β”œβ”€β”€ objectmenu.*             the right-click menu, on the stack and the canvas alike
    └── rowglyph.*               the object drawn small for its row

widgets/objectrecord/          outside the editor: the project and the main window use it too
β”œβ”€β”€ objectrecord.hpp           what a bubble is: the record an overlay is rendered from
β”œβ”€β”€ propertygroups.hpp         the groups a record is made of: Shape, Skin, Style, Text, Tails
β”œβ”€β”€ recordpainter.*            draws a record (namespace Painter)
β”œβ”€β”€ recordsvg.*                a record as SVG and back (namespace Svg)
└── recordstore.*              every open project's records, by project uid

What may include what

toolrail ─────┐
tooloptions ──┼──► properties ──► widgets/objectrecord
objectstate β”€β”€β”˜         β–²
objectstack ──► objects β”˜
canvas ───────► objects
editor (root) ──► everything β€” the only place the regions meet
  • A region never includes another region. TOOL OPTIONS and OBJECT STATE meet through properties/ (the same editor classes) and through Editor (the wiring).
  • Nothing includes editor.hpp. The root's other files (presetstore, scrolledpage) are shared.
  • Includes name their folder: #include "objects/object.hpp". widgets/stripeditor is the only include root, so an include line is the dependency, and an unqualified one does not compile.

It is checked on every build. cmake/check_layers.cmake runs before Platemaker compiles, and as the strip_editor_layers test. A violation stops the build with file:line: error: tooloptions/ may not include objectstate/.

A few headers are allowed across a region line. The script lists each one with its reason, and warns when one is no longer used. Today they are:

  • the tool table and the cursor rule (toolrail/toolregistry, toolrail/cursors), for the canvas, TOOL OPTIONS and the objects;
  • the strip's layout, for OBJECT STATE;
  • loadArtwork(), for the Artwork tool's preview;
  • the colour pair, for the object menu.

How the parts talk

                 MainWindow / Project  (persistence, one undo history per project)
                   β–² recordCreated, overlaysCommitted,            β”‚ setOverlaySource,
                   β”‚ artworkImportRequested,                      β”‚ setColourCorrection,
                   β”‚ colourCorrectionCommitted                    β–Ό setPreviewSource
               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ Editor ─────────────────────────────┐
               β”‚                                                                  β”‚
 TOOL RAIL ── toolPicked ──► Editor::setTool ──► TOOL OPTIONS page, CanvasInput   β”‚
                                                                                  β”‚
 CanvasInput ── a Create drag ─────────► Placement ──► ObjectController           β”‚
             ── sampleRequested ───────► Editor ──► sampleCanvas ──► ColourPair   β”‚
             ── colourApplyRequested ──► Editor ──► ObjectController              β”‚
             ── artworkDropped, zoomStepRequested ──► Editor                      β”‚
                                                                                  β”‚
 OBJECT STATE ── changed / committed ──────────────────► ObjectController         β”‚
              ◄─ boundToRecord, boundToTail, boundToRecords… β”€β”˜   (via Editor)    β”‚
                                                                                  β”‚
 OBJECT STACK, object menu ── read the controller's getters, call its methods     β”‚
                           ◄─ stackChanged, selectionChanged, subjectRowChanged   β”‚
               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • ObjectController is the model and the selection. It holds no widget of any region. The stack and the menu are views of it, the way a list view is a view of a model. OBJECT STATE may not include it, so the controller tells it what to show by signal, and the Editor connects the two.
  • No edit is final in the editor. Every change leaves as a signal, MainWindow pushes it onto the project's undo history, and the result comes back through setOverlaySource(). See History and undo.
  • Live and settled have one spelling. …changed is live (preview, no history step); …committed is settled (one undo step). Every editor and panel uses the pair.

I want to… β†’ look in

I want to… Look in
add a kind of object objects/ (a subclass of Object); its record in widgets/objectrecord/
add or change a property the struct in widgets/objectrecord/propertygroups.hpp, its editor in properties/, the group in properties/propertygroup.hpp
add a tool a row in toolrail/toolregistry.cpp; its page in tooloptions/, registered by the Editor (the stack asserts every tool has one)
link a tool's options to an object's properties properties/propertygroupset.* and the page's prototype()
use the colour pair toolrail/colourpair.*; it is read by the bucket (canvas/canvasinput β†’ ObjectController::applyColourAt), written by the eyedropper (canvas/sampling), and read by the menu's Fill and Outline
change what the strip or a page shows objects/striplayout.* (geometry), canvas/stripitem.* (drawing), objectstate/stripstate.* (its panel)
add a filter like the grade toolrail/ (row) + tooloptions/gradetooloptions.*; the glue is in editor.cpp
make a filter reach the render the library: a model field, its codec, the strip builder. No GUI folder makes that cheap
change what a right-click offers objectstack/objectmenu.* for the entries; the operation itself in objects/objectcontroller.*
change a cursor toolrail/cursors.*

See also: Tool framework Β· Object state and tool options Β· Architecture