Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

42.1 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-or-later
// SPDX-FileCopyrightText: 2026 Jareer Abdullah and Concat contributors

import { I18n } from "../i18n.slint";
import { Theme, SegmentedControl } from "../primitives/primitives.slint";
import { SectionTabs } from "../primitives/section-tabs.slint";
import { Glyph } from "../icons.slint";
import { Select } from "../primitives/select.slint";
import { Pane, PaneBody, PaneScroll } from "pane.slint";
import { PaneKind, PaneSwitcher } from "pane-switcher.slint";
import { EffectData } from "../demo/effects-panel.slint";
import {
    AdjustPanel, AppliedEntryData, AppliedParamData, AudioPanel, BackgroundRows, ProcessorRows,
    TransitionChoiceData,
    CatalogueEntryData, ColourKnobData, EnhancePanel, FilterPanel, PresetStack, SpeedPanel,
    TransitionPanel, VideoPanel,
} from "../inspector/clip-inspector.slint";
import {
    CurveData, CurveGroupData, WheelData, WheelGroupData,
} from "../inspector/grading.slint";
import { TextPanel } from "../inspector/text-panel.slint";
import {
    ClipField, ClipKind, ClipTextField, SelectedClipData, SelectedTransitionData,
} from "../timeline/model.slint";

// The inspector column, in its two states:
//
// - Nothing selected: the Details panel — the project's facts, read-only,
//   with Modify pinned to the foot.
// - Something selected: the clip inspector — Video, Audio and Effects, or
//   Text alone for a title, or the layer panel for a filter on the lanes.
// - A transition selected on its own: its panel, and nothing of the clips
//   either side of it.

// One fact: muted label left, value right. The value wraps rather than
// elides — a folder path you cannot read is a path you have to go find.
component FactRow inherits HorizontalLayout {
    in property <string> label;
    in property <string> value;

    padding-left: Theme.pad;
    padding-right: Theme.pad;
    spacing: 12px;
    min-height: 21px;

    Text {
        text: root.label;
        color: Theme.fg-muted;
        font-size: Theme.fs;
        vertical-alignment: center;
    }

    // A read-only TextInput and not a Text, so it can be selected and copied.
    // Half of what this panel holds is only useful somewhere else — a folder
    // path pasted into a terminal, an output size quoted to somebody — and a
    // fact you cannot lift off the screen is a fact you have to retype.
    TextInput {
        horizontal-stretch: 1;
        text: root.value;
        color: Theme.fg;
        font-family: Theme.font-technical;
        font-size: Theme.fs;
        horizontal-alignment: right;
        // The label beside this one is centred and the row is taller than a
        // line; without this the value rides at the top of it.
        vertical-alignment: center;
        // Selectable, never editable: this is a readout of the project, and
        // the Modify button is where changing it lives.
        read-only: true;
        single-line: false;
        wrap: word-wrap;
        selection-background-color: Theme.accent;
        selection-foreground-color: Theme.on-accent;
    }
}

// "PROJECT", "CONTENTS" — the muted caps that break the facts into groups.
component FactHeading inherits HorizontalLayout {
    in property <string> title;

    padding-left: Theme.pad;
    padding-right: Theme.pad;
    // The air belongs between the groups, not between the lines inside one.
    padding-top: 12px;
    padding-bottom: 3px;

    Text {
        text: root.title;
        color: Theme.fg-dim;
        font-size: Theme.fs-sm;
        font-weight: Theme.weight-title;
        letter-spacing: 1px;
    }
}

export component ConfigPane inherits Rectangle {
    // ── the demo-era seams, kept so main.rs keeps compiling ──────────────
    // The meter/mute machinery has nothing to drive since the demo effects
    // panel left the pane; the properties stay declared because app.slint
    // and main.rs read them for the life of the process. Strip the whole
    // group when the Rust side sheds its demo plumbing.
    in property <[EffectData]> video-effects;
    in property <[EffectData]> audio-effects;
    in property <float> level;
    in property <float> peak;
    out property <bool> muted;
    out property <bool> meter-hovered;
    callback add-effect(audio: bool);
    callback remove-effect(id: int);

    // ── details ──────────────────────────────────────────────────────────
    /// The selected clip, or `present: false` for the project details.
    in property <SelectedClipData> selected;
    /// The selected clip's media's audio tracks; see Editor.audio-tracks.
    in property <[string]> audio-tracks;
    property <bool> has-selection: root.selected.present;
    /// The transition selected on its own on the lanes, when no clip is.
    in property <SelectedTransitionData> transition;
    in property <[AppliedParamData]> transition-knobs;
    in property <[TransitionChoiceData]> transition-choices;
    property <bool> on-transition: root.transition.present && !root.has-selection;
    in property <string> project-name: I18n.t("common.untitledProject");
    in property <string> project-folder: "—";
    /// The active timeline, whose frame, rate and duration the rows below
    /// report. Named in the panel so a project with three cuts at three
    /// frames never leaves anyone wondering which one "1080 × 1920" is.
    in property <string> timeline-name: I18n.t("configPane.timelineOne");
    in property <string> project-output: "1080 x 1920";
    in property <string> project-rate: "30.00 fps";
    in property <string> project-duration: "00:00:00:00";
    in property <int> count-media;
    in property <int> count-tracks;
    in property <int> count-clips;

    callback modify-project();

    /// The corner button: show something else in this pane's seat.
    callback pane-picked(kind: PaneKind);
    /// Which seat this pane is in. It travels no further than the corner
    /// button, whose drag payload has to say where it is being taken from.
    in property <int> pane-seat;
    /// False when this is the last panel on screen. Travels the same way, and
    /// only greys the one row that would close it.
    in property <bool> pane-removable: true;
    /// That row was used.
    callback pane-removed();

    // ── the clip inspector's chains, owned by Rust ───────────────────────
    //
    // The library shelves come from the effect catalogue, the applied lists
    // from the selected clip. Two chains: the picture's, which Effects
    // edits, and the sound's, which Audio edits. A `audio` flag on every
    // callback says which. A filter is neither: it is a layer on the lanes,
    // with a panel of its own.
    in property <[CatalogueEntryData]> catalogue-effects;
    in property <[CatalogueEntryData]> catalogue-audio;
    in property <[string]> effect-groups;
    in property <[string]> audio-groups;
    in property <[AppliedEntryData]> applied-visual;
    in property <[AppliedEntryData]> applied-audio;
    in property <[AppliedParamData]> visual-params;
    in property <[AppliedParamData]> audio-params;
    /// The colour panel's knobs: the adjust package's parameters, at the
    /// selected clip's values or the defaults.
    in property <[AppliedParamData]> adjust-params;
    callback adjust-set(key: string, value: float);
    /// The colour panel's wheels and curves, and the picture chain's by link.
    in property <[WheelData]> adjust-wheels;
    in property <[CurveData]> adjust-curves;
    in property <[WheelGroupData]> visual-wheels;
    in property <[CurveGroupData]> visual-curves;
    /// The picture chain's colour knobs, and one of them picked.
    in property <[ColourKnobData]> visual-colours;
    callback chain-set-colour(index: int, key: string, value: color);
    /// A curve's point moved, or put down when `point` is -1, or taken off:
    /// `entry` -1 is the colour panel's, else a link of the picture's chain.
    callback curve-point(entry: int, key: string, point: int, x: float, y: float);
    callback curve-remove(entry: int, key: string, point: int);

    /// See Editor.inspector-jump-token: the library applied something and
    /// this pane should show it.
    in property <int> jump-token;
    in property <string> jump-tab;
    in property <string> jump-section;

    callback chain-add(audio: bool, id: string);
    callback chain-toggle(audio: bool, index: int);
    callback chain-move-by(audio: bool, index: int, delta: int);
    callback chain-remove(audio: bool, index: int);
    callback chain-set-param(audio: bool, index: int, key: string, value: float);

    callback clip-set(field: ClipField, value: float);
    callback clip-set-text(field: ClipTextField, value: string);
    callback clip-set-words(text: string, caret: int);
    callback clip-select-words(anchor: int, cursor: int);
    callback clip-reset-words();
    callback clip-set-colour(field: ClipTextField, value: color);
    callback clip-commit();
    /// The Text tab's font picker and its import button; see Editor.
    in property <[string]> font-families;
    callback import-font();
    callback text-style-default();

    /// The cutout's brush and controls; see Editor.
    in property <int> brush-tool;
    in property <float> brush-size;
    in property <bool> painting;
    callback cutout-mode(mode: int);
    callback cutout-tool(index: int);
    callback cutout-size(size: float);
    callback cutout-painting(on: bool);
    callback cutout-subject(index: int);
    callback cutout-clear();
    /// The Enhance switch: start it, or show the copy or the original.
    callback clip-enhance-set(on: bool);
    callback clip-enhance-size(index: int);
    callback clip-enhance-strength(strength: float);
    callback clip-enhance-preview();
    callback clip-enhance-run();
    callback transition-remove();
    callback transition-duration-set(seconds: float);
    callback transition-param-set(key: string, value: float);


    // The tab strip follows the selection, and stays short: three tabs at
    // most, each with a dropdown of its sections, because seven tabs on a
    // strip this narrow cannot be read. Video holds what happens to the
    // picture - its placement, its speed, its colour; Audio
    // the level, the fades and the voice and room chain; Effects the two
    // shelves and the picture's chain. A still loses Audio, a sound clip
    // keeps Audio alone, and a title gets Text and Effects: its look is its
    // typography, stroke and box, all on the Text tab, and Video or Audio
    // on a title would be panels that can only say "nothing here". Its
    // picture chain is real, though - a title draws its effects like any
    // clip - so the chain has its tab, or one dropped on it could be
    // neither seen nor taken off (#484).
    property <bool> is-text: root.selected.kind == ClipKind.text;
    property <bool> is-image: root.selected.kind == ClipKind.image;
    /// A shape gets one tab, Vector Image, with the placement panel
    /// alone: it has no sound, no rate, no colour to adjust and no chain
    /// of effects - a figure is its fill and its outline, nothing more.
    property <bool> is-shape: root.selected.kind == ClipKind.shape;
    property <bool> is-audio: root.selected.kind == ClipKind.audio;
    /// A filter layer gets its own lone tab for the same reason a title does:
    /// it has no transform, no gain and no rate, and every other tab could
    /// only say "nothing here". What it does have - its strength, the colour
    /// panel it grades everything beneath it with, and its chain - are the
    /// tab's sections, so an adjustment layer is graded the way a clip is.
    property <bool> is-layer: root.selected.kind == ClipKind.filter;
    /// A sound layer gets one tab, Audio, for the filter layer's reason:
    /// its strength and ramps, then its chain and the sound library -
    /// the Audio effects page a sound clip has, over everything heard.
    property <bool> is-sound-layer: root.selected.kind == ClipKind.sound-layer;
    /// Effects are laid on the timeline as layers now, so a clip's own
    /// chain is not something to go looking for: its tab shows only on a
    /// clip that already carries one - from an older project, a template,
    /// the API - so that chain can still be seen, tuned and taken off.
    /// The colour panel's own package and the chroma key have homes of
    /// their own (Adjust, the cutout), so they do not count as a chain: a
    /// clip only graded or keyed has no Effects tab to go looking in.
    pure function own-link(id: string) -> bool {
        return id == "concat.adjust" || id == "concat.chroma-key";
    }
    property <bool> has-chain: root.applied-visual.length > 2
        || (root.applied-visual.length > 0 && !root.own-link(root.applied-visual[0].id))
        || (root.applied-visual.length > 1 && !root.own-link(root.applied-visual[1].id));
    property <[string]> tabs: root.selected.batch-volume ? ["Audio"]
        : root.is-text ? (root.has-chain ? ["Text", "Effects"] : ["Text"])
        : root.is-layer ? ["Filter"]
        : root.is-sound-layer ? ["Audio"]
        : root.is-shape ? ["Video"]
        : root.is-image ? (root.has-chain ? ["Video", "Effects"] : ["Video"])
        : root.is-audio ? ["Audio"]
        : root.has-chain ? ["Video", "Audio", "Effects"] : ["Video", "Audio"];
    /// The same tabs in the interface's language. `tabs` stays English,
    /// because the panels are picked by comparing against it.
    ///
    /// Held, not bound (#549): bound, it was worked out again whenever
    /// anything in `selected` changed - every frame of playback on a keyed
    /// clip - and each time the strip's repeater got a new model, so its
    /// segments were torn down and rebuilt sixty times a second, their
    /// colour fade replaying (the blink) and a click landing on a segment
    /// already gone. Now it is set again only when `strip-key` - which
    /// tabs, in which language - says the strip is a different one.
    property <[string]> tabs-shown;
    pure function strip-labels() -> [string] {
        return root.selected.batch-volume ? [I18n.t("common.audio")]
        : root.is-text ? (root.has-chain ? [I18n.t("common.text"), I18n.t("common.effects")]
            : [I18n.t("common.text")])
        : root.is-layer ? [I18n.t("configPane.filter")]
        : root.is-sound-layer ? [I18n.t("common.audio")]
        : root.is-shape ? [I18n.t("configPane.vectorImage")]
        : root.is-image ? (root.has-chain ? [I18n.t("common.video"), I18n.t("common.effects")]
            : [I18n.t("common.video")])
        : root.is-audio ? [I18n.t("common.audio")]
        : root.has-chain ? [I18n.t("common.video"), I18n.t("common.audio"), I18n.t("common.effects")]
            : [I18n.t("common.video"), I18n.t("common.audio")];
    }
    property <string> strip-key: root.tabs.length + ":" + root.tabs[0] + ":"
        + (root.tabs.length > 1 ? root.tabs[1] : "") + ":"
        + (root.tabs.length > 2 ? root.tabs[2] : "") + ":"
        + (root.is-shape ? "shape" : "") + ":" + I18n.t("common.video");
    changed strip-key => { root.tabs-shown = root.strip-labels(); }
    /// A one-segment segmented control is a label wearing a costume, so a lone
    /// tab renders as the panel's plain heading instead.
    property <bool> single: root.tabs.length < 2;

    // The segmented control owns this: it writes to `current`, which would
    // drop any binding declared here, so it is assigned and never bound.
    property <int> tab;
    /// The kind the strip was last built for. A selection change can leave the
    /// strip pointing past the end of a shorter list — Audio on a still,
    /// a video's third tab on a title — so the index is pulled back in when the
    /// shape of the strip changes, and left alone when it has not.
    property <ClipKind> strip-kind;
    // Taking a clip's last effect off takes its tab away under you.
    changed has-chain => { root.tab = Math.min(root.tab, root.tabs.length - 1); }
    changed selected => {
        if (root.selected.kind != root.strip-kind) {
            root.strip-kind = root.selected.kind;
            // Clamped rather than reset: going from a video to a still should
            // stay on Effects, which both offer, instead of jumping back.
            root.tab = Math.min(root.tab, root.tabs.length - 1);
        }
    }

    /// Which tab the index names.
    property <string> heading: root.tabs[Math.max(0,
        Math.min(root.tab, root.tabs.length - 1))];

    /// The sections of the current tab, as the dropdown lists them.
    property <[string]> sections: root.heading == "Video"
            ? (root.is-shape ? ["Basic"] : ["Basic", "Enhance", "Adjust"])
        // Audio's chain library is a page of its own, beside the level,
        // fades and treatments rather than under them, the way Video's
        // Adjust sits beside its Basic. Named apart from Video's "Basic"
        // and the Effects tab's "Effects", since `showing` picks the panel
        // by this name alone.
        : root.heading == "Audio"
            ? (root.selected.batch-volume ? ["Sound"]
                : root.is-sound-layer ? ["Layer", "AudioEffects"]
                : ["Sound", "AudioEffects"])
        : root.heading == "Effects" ? ["Effects"]
        : root.heading == "Text" ? ["Text"]
        : ["Layer", "Adjust", "Effects"];
    /// A mark for each section, in the same order: where the clip sits,
    /// what makes it better, its colour's knobs; its level and its sound's
    /// chain; a layer's own strength, then its colour and its chain.
    property <[Glyph]> section-icons: root.heading == "Video"
            ? (root.is-shape ? [Glyph.move] : [Glyph.move, Glyph.wand, Glyph.sliders])
        : root.heading == "Audio"
            ? (root.selected.batch-volume ? [Glyph.volume]
                : root.is-sound-layer ? [Glyph.filter, Glyph.waveform]
                : [Glyph.volume, Glyph.waveform])
        : root.heading == "Effects" ? [Glyph.sparkle]
        : root.heading == "Text" ? [Glyph.text-mark]
        : [Glyph.filter, Glyph.sliders, Glyph.sparkle];
    /// The sections as the dropdown shows them; see `tabs-shown`.
    property <[string]> sections-shown: root.heading == "Video"
            ? (root.is-shape ? [I18n.t("configPane.basic")]
                : [I18n.t("configPane.basic"), I18n.t("common.enhance"), I18n.t("common.adjust")])
        : root.heading == "Audio"
            ? (root.selected.batch-volume ? [I18n.t("configPane.basic")]
                : root.is-sound-layer ? [I18n.t("common.layer"), I18n.t("configPane.audioEffects")]
                : [I18n.t("configPane.basic"), I18n.t("configPane.audioEffects")])
        : root.heading == "Effects" ? [I18n.t("common.effects")]
        : root.heading == "Text" ? [I18n.t("common.text")]
        : [I18n.t("common.layer"), I18n.t("common.adjust"), I18n.t("common.effects")];

    // Each tab remembers its own section, so flipping to Audio and back
    // lands on the colour panel you were adjusting. Assigned, never bound,
    // for the same reason `tab` is.
    property <int> section-video;
    property <int> section-audio;
    property <int> section-effects;
    property <int> section-text;
    property <int> section-layer;
    property <int> section: root.heading == "Video" ? root.section-video
        : root.heading == "Audio" ? root.section-audio
        : root.heading == "Effects" ? root.section-effects
        : root.heading == "Text" ? root.section-text
        : root.heading == "Filter" ? root.section-layer
        : 0;
    function pick-section(index: int) {
        if (root.heading == "Video") { root.section-video = index; }
        else if (root.heading == "Audio") { root.section-audio = index; }
        else if (root.heading == "Effects") { root.section-effects = index; }
        else if (root.heading == "Text") { root.section-text = index; }
        else if (root.heading == "Filter") { root.section-layer = index; }
    }

    /// Which panel is up, resolved once rather than at each `if`: the same
    /// number means different things depending on what is selected.
    property <string> showing: root.sections[Math.max(0,
        Math.min(root.section, root.sections.length - 1))];

    // Go where the library just put something. On a fresh token, and once
    // on opening, so an inspector that was not on screen when the effect
    // was applied still opens on it.
    function jump() {
        if (root.jump-token == 0) { return; }
        // A layer has the one tab: the library names the section - Adjust
        // for a fresh adjustment layer, Effects for a look put on its chain.
        if (root.is-layer) {
            root.tab = 0;
            root.section-layer = root.jump-section == "Adjust" ? 1
                : root.jump-section == "Effects" ? 2 : 0;
            return;
        }
        if (root.jump-tab == "Video") { root.tab = 0; }
        else if (root.jump-tab == "Audio") { root.tab = root.is-audio || root.is-sound-layer ? 0 : 1; }
        else if (root.jump-tab == "Effects") { root.tab = root.tabs.length - 1; }
        // Enhance sits second in the Video tab for a video and a still
        // alike, and Audio effects second in the Audio tab.
        root.pick-section(root.jump-section == "Enhance" || root.jump-section == "AudioEffects"
            ? 1 : 0);
    }
    changed jump-token => { root.jump(); }
    init => {
        root.tabs-shown = root.strip-labels();
        root.jump();
    }

    Pane {
        // ── details ──────────────────────────────────────────────────────
        if !root.has-selection && !root.on-transition: Rectangle {
            // The same 52px as the panes either side of it; see PaneHeader.
            height: 52px;

            Rectangle {
                x: 0;
                y: parent.height - 1px;
                width: parent.width;
                height: 1px;
                background: Theme.line;
            }

            HorizontalLayout {
                padding-left: Theme.pad;
                padding-right: 8px;
                spacing: 8px;

                Text {
                    text: I18n.t("configPane.details");
                    color: Theme.fg-muted;
                    // The small size, not the body one. Caps at 12px with a
                    // point and a half of tracking is nearly as wide as the
                    // Preview pane's 13px title and reads heavier than it —
                    // which puts the loudest thing in the column on the one
                    // panel that has nothing to say. It is a section label,
                    // so it takes the same size and tracking as the FactHeadings
                    // under it.
                    font-size: Theme.fs-sm;
                    font-weight: Theme.weight-title;
                    letter-spacing: 1px;
                    vertical-alignment: center;
                }

                Rectangle { horizontal-stretch: 1; }

                VerticalLayout {
                    alignment: center;
                    PaneSwitcher {
                        kind: PaneKind.inspector;
                        seat: root.pane-seat;
                        removable: root.pane-removable;
                        picked(kind) => { root.pane-picked(kind); }
                        removed => { root.pane-removed(); }
                    }
                }
            }
        }

        if !root.has-selection && !root.on-transition: PaneBody {
            padding: 0px;
            spacing: 0px;

            PaneScroll {
                VerticalLayout {
                    padding-top: 4px;
                    // No gap: the rows carry their own height and a spacing on
                    // top of it opens the table back up.
                    spacing: 0px;

                    FactHeading { title: I18n.t("configPane.project"); }
                    FactRow { label: I18n.t("common.name"); value: root.project-name; }
                    FactRow { label: I18n.t("configPane.folder"); value: root.project-folder; }

                    // The frame is a timeline's, not the project's: two cuts
                    // of one edit can be two shapes, and these rows say which
                    // one they are describing.
                    FactHeading { title: I18n.t("configPane.timeline"); }
                    FactRow { label: I18n.t("common.name"); value: root.timeline-name; }
                    FactRow { label: I18n.t("common.frame"); value: root.project-output; }
                    FactRow { label: I18n.t("common.rate"); value: root.project-rate; }
                    FactRow { label: I18n.t("common.duration"); value: root.project-duration; }

                    FactHeading { title: I18n.t("configPane.contents"); }
                    FactRow { label: I18n.t("common.media"); value: "\{root.count-media}"; }
                    FactRow { label: I18n.t("configPane.tracks"); value: "\{root.count-tracks}"; }
                    FactRow { label: I18n.t("configPane.clips"); value: "\{root.count-clips}"; }
                }
            }
        }

        if !root.has-selection && !root.on-transition: Rectangle {
            height: 49px;

            Rectangle {
                x: 0;
                y: 0;
                width: parent.width;
                height: 1px;
                background: Theme.line;
            }

            modify := Rectangle {
                x: parent.width - self.width - 10px;
                y: (parent.height - self.height) / 2;
                width: modify-label.width + 30px;
                height: 30px;
                // The control radius, not the pane's. It was the roundest of
                // the named radii on the theory that the one button in the
                // panel should stand apart from the fields; at 30px tall that
                // is most of the way to a pill, and it stood apart from every
                // other button in the window instead.
                border-radius: Theme.r;
                background: modify-touch.has-hover ? Theme.field-hover : Theme.field;

                animate background { duration: 100ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }

                modify-label := Text {
                    x: (parent.width - self.width) / 2;
                    y: (parent.height - self.height) / 2;
                    text: I18n.t("configPane.modify");
                    color: Theme.fg;
                    font-size: Theme.fs;
                    font-weight: Theme.weight-title;
                }

                modify-touch := TouchArea {
                    mouse-cursor: pointer;
                    clicked => { root.modify-project(); }
                }
            }
        }

        // ── a transition ─────────────────────────────────────────────────
        if root.on-transition: Rectangle {
            height: 52px;

            Rectangle {
                x: 0;
                y: parent.height - 1px;
                width: parent.width;
                height: 1px;
                background: Theme.line;
            }

            HorizontalLayout {
                padding-left: Theme.pad;
                padding-right: 8px;
                spacing: 8px;

                Text {
                    text: I18n.t("clipInspector.transition");
                    color: Theme.fg-muted;
                    font-size: Theme.fs-sm;
                    font-weight: Theme.weight-title;
                    letter-spacing: 1px;
                    vertical-alignment: center;
                }

                Rectangle { horizontal-stretch: 1; }

                VerticalLayout {
                    alignment: center;
                    PaneSwitcher {
                        kind: PaneKind.inspector;
                        seat: root.pane-seat;
                        removable: root.pane-removable;
                        picked(kind) => { root.pane-picked(kind); }
                        removed => { root.pane-removed(); }
                    }
                }
            }
        }

        if root.on-transition: PaneBody {
            padding: 0px;
            spacing: 0px;

            PaneScroll {
                TransitionPanel {
                    transition: root.transition;
                    knobs: root.transition-knobs;
                    choices: root.transition-choices;
                    param-set(key, value) => { root.transition-param-set(key, value); }
                    remove => { root.transition-remove(); }
                    duration-set(seconds) => { root.transition-duration-set(seconds); }
                }
            }
        }

        // ── the clip inspector ───────────────────────────────────────────
        if root.has-selection: Rectangle {
            // Matched to the Details bar above, or the top of the column
            // would jump by four pixels every time a clip was selected.
            height: 52px;

            Rectangle {
                x: 0;
                y: parent.height - 1px;
                width: parent.width;
                height: 1px;
                background: Theme.line;
            }

            HorizontalLayout {
                padding-left: root.single ? Theme.pad : 8px;
                padding-right: 8px;
                spacing: 8px;

                if root.single: Text {
                    text: root.tabs-shown[0];
                    color: Theme.fg-muted;
                    font-size: Theme.fs-sm;
                    font-weight: Theme.weight-title;
                    letter-spacing: 1px;
                    vertical-alignment: center;
                }

                if root.single: Rectangle { horizontal-stretch: 1; }

                // The clip's own name on the trailing edge, so a panel of
                // numbers says which clip it is describing. The strip below
                // has no room for it, which is why it only appears here.
                if root.single: Text {
                    text: root.selected.name;
                    color: Theme.fg-dim;
                    font-size: Theme.fs-sm;
                    vertical-alignment: center;
                    overflow: elide;
                }

                if !root.single: VerticalLayout {
                    alignment: center;
                    SegmentedControl {
                        options: root.tabs-shown;
                        current <=> root.tab;
                    }
                }

                VerticalLayout {
                    alignment: center;
                    PaneSwitcher {
                        kind: PaneKind.inspector;
                        seat: root.pane-seat;
                        removable: root.pane-removable;
                        picked(kind) => { root.pane-picked(kind); }
                        removed => { root.pane-removed(); }
                    }
                }
            }
        }

        // The tab's sections, as a strip of marks and words under the
        // tabs: on the panel itself, so it reads as a place inside the tab
        // and not a second row of tabs. One section needs no strip: the tab
        // already says where you are.
        if root.has-selection && root.sections.length > 1: Rectangle {
            height: 40px;
            background: Theme.panel;

            Rectangle {
                x: 0;
                y: parent.height - 1px;
                width: parent.width;
                height: 1px;
                background: Theme.line;
            }

            HorizontalLayout {
                padding-left: 4px;
                padding-right: 4px;
                VerticalLayout {
                    SectionTabs {
                        options: root.sections-shown;
                        icons: root.section-icons;
                        // A press on a segment assigns `current` inside the
                        // control, which ends a plain binding here: the
                        // highlight then stayed where it was pressed while
                        // the tab, the selection or a jump moved the section
                        // under it. So it is set again whenever the section
                        // shown changes. https://github.com/jub0t/Concat/issues/250
                        property <int> shown: Math.max(0, Math.min(root.section, root.sections.length - 1));
                        current: self.shown;
                        changed shown => { self.current = self.shown; }
                        changed(index) => { root.pick-section(index); }
                    }
                }
            }
        }

        if root.has-selection: PaneBody {
            // No padding: the inspector rows carry their own 14px inset, and
            // sections run edge to edge so their hairlines reach both sides.
            padding: 0px;

            PaneScroll {
                // Basic, with the clip's speed under it: one knob is not a
                // page of its own.
                if root.showing == "Basic": VerticalLayout {
                    VideoPanel {
                        selected: root.selected;
                        applied: root.applied-visual;
                        params: root.visual-params;
                        colours: root.visual-colours;
                        brush-tool: root.brush-tool;
                        brush-size: root.brush-size;
                        painting: root.painting;
                        set(field, value) => { root.clip-set(field, value); }
                        commit => { root.clip-commit(); }
                        chain-add(id) => { root.chain-add(false, id); }
                        chain-remove(index) => { root.chain-remove(false, index); }
                        chain-set-param(index, key, value) => {
                            root.chain-set-param(false, index, key, value);
                        }
                        chain-set-colour(index, key, value) => {
                            root.chain-set-colour(index, key, value);
                        }
                        cutout-mode(mode) => { root.cutout-mode(mode); }
                        cutout-tool(index) => { root.cutout-tool(index); }
                        cutout-size(size) => { root.cutout-size(size); }
                        cutout-painting(on) => { root.cutout-painting(on); }
                        cutout-subject(index) => { root.cutout-subject(index); }
                        cutout-clear => { root.cutout-clear(); }
                    }

                    if !root.is-image && !root.is-shape: SpeedPanel {
                        first: false;
                        selected: root.selected;
                        set(field, value) => { root.clip-set(field, value); }
                        commit => { root.clip-commit(); }
                    }
                }

                if root.showing == "Enhance": EnhancePanel {
                    selected: root.selected;
                    enhance-set(on) => { root.clip-enhance-set(on); }
                    enhance-size(index) => { root.clip-enhance-size(index); }
                    enhance-strength(strength) => { root.clip-enhance-strength(strength); }
                    enhance-preview => { root.clip-enhance-preview(); }
                    enhance-run => { root.clip-enhance-run(); }
                }

                if root.showing == "Adjust": AdjustPanel {
                    params: root.adjust-params;
                    wheels: root.adjust-wheels;
                    curves: root.adjust-curves;
                    set(key, value) => { root.adjust-set(key, value); }
                    curve-point(key, point, x, y) => { root.curve-point(-1, key, point, x, y); }
                    curve-remove(key, point) => { root.curve-remove(-1, key, point); }
                    commit => { root.clip-commit(); }
                }

                if root.showing == "Layer": FilterPanel {
                    selected: root.selected;
                    help: root.is-sound-layer ? I18n.t("clipInspector.soundLayerTreatsTheMix")
                        : I18n.t("clipInspector.layerTreatsEverythingUnder");
                    set(field, value) => { root.clip-set(field, value); }
                    commit => { root.clip-commit(); }
                }

                if root.showing == "Text": TextPanel {
                    selected: root.selected;
                    families: root.font-families;
                    set(field, value) => { root.clip-set(field, value); }
                    set-text(field, value) => { root.clip-set-text(field, value); }
                    set-words(text, caret) => { root.clip-set-words(text, caret); }
                    select-words(anchor, cursor) => { root.clip-select-words(anchor, cursor); }
                    reset-words => { root.clip-reset-words(); }
                    set-colour(field, value) => { root.clip-set-colour(field, value); }
                    commit => { root.clip-commit(); }
                    import-font => { root.import-font(); }
                    set-default => { root.text-style-default(); }
                }

                // Audio: the level and fades, then the voice and room chain
                // under them, the way an audio tab is usually laid out.
                if root.showing == "Sound": VerticalLayout {
                    AudioPanel {
                        selected: root.selected;
                        audio-tracks: root.audio-tracks;
                        set(field, value) => { root.clip-set(field, value); }
                        commit => { root.clip-commit(); }
                    }
                    // A sound clip's speed, under its level and fades: one
                    // knob is not a page of its own. A picture's sound
                    // rides the picture's, set under Video › Basic.
                    if root.is-audio && !root.selected.batch-volume: SpeedPanel {
                        first: false;
                        selected: root.selected;
                        set(field, value) => { root.clip-set(field, value); }
                        commit => { root.clip-commit(); }
                    }
                    // The three treatments, between the mix and the library:
                    // they are chain links like any other, but they are the
                    // ones a sound clip usually needs, so they get a switch
                    // rather than a search.
                    if !root.selected.batch-volume: ProcessorRows {
                        applied: root.applied-audio;
                        params: root.audio-params;
                        add(id) => { root.chain-add(true, id); }
                        remove(index) => { root.chain-remove(true, index); }
                        set-param(index, key, value) => {
                            root.chain-set-param(true, index, key, value);
                        }
                        commit => { root.clip-commit(); }
                    }
                }

                // The sound's chain and its library, on their own page
                // rather than under everything Basic holds, where a long
                // chain pushed the library off the bottom of the pane.
                if root.showing == "AudioEffects": VerticalLayout {
                    if !root.selected.batch-volume: PresetStack {
                        noun: I18n.t("common.audioEffect");
                        library-title: I18n.t("configPane.audioEffects");
                        shelf: 2;
                        // A sound layer has no Sound page with their switches,
                        // so its treatments are cards like any other link.
                        hidden: root.selected.kind == ClipKind.sound-layer ? []
                            : ["concat.loudness", "concat.denoise", "concat.enhance-voice"];
                        group-labels: root.audio-groups;
                        catalogue: root.catalogue-audio;
                        applied: root.applied-audio;
                        params: root.audio-params;

                        add(id) => { root.chain-add(true, id); }
                        toggle(index) => { root.chain-toggle(true, index); }
                        move-by(index, delta) => { root.chain-move-by(true, index, delta); }
                        remove(index) => { root.chain-remove(true, index); }
                        set-param(index, key, value) => {
                            root.chain-set-param(true, index, key, value);
                        }
                        commit => { root.clip-commit(); }
                    }
                }

                // The picture's chain. Filters are not in it: a filter is a
                // layer on the lanes, edited in its own panel.
                if root.showing == "Effects": PresetStack {
                    noun: I18n.t("common.effect");
                    library-title: I18n.t("common.effects");
                    library: false;
                    empty-note: I18n.t("configPane.noEffectClipYet");
                    shelf: 1;
                    group-labels: root.effect-groups;
                    catalogue: root.catalogue-effects;
                    applied: root.applied-visual;
                    params: root.visual-params;
                    wheel-groups: root.visual-wheels;
                    curve-groups: root.visual-curves;
                    colours: root.visual-colours;

                    add(id) => { root.chain-add(false, id); }
                    toggle(index) => { root.chain-toggle(false, index); }
                    move-by(index, delta) => { root.chain-move-by(false, index, delta); }
                    remove(index) => { root.chain-remove(false, index); }
                    set-param(index, key, value) => {
                        root.chain-set-param(false, index, key, value);
                    }
                    set-colour(index, key, value) => {
                        root.chain-set-colour(index, key, value);
                    }
                    curve-point(index, key, point, x, y) => {
                        root.curve-point(index, key, point, x, y);
                    }
                    curve-remove(index, key, point) => {
                        root.curve-remove(index, key, point);
                    }
                    commit => { root.clip-commit(); }
                }
            }
        }
    }
}