Skip to content

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

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

// The theme: the two palettes, and the two properties that choose from them.
//
// Everything the interface is made of — every colour, every radius, every
// metric, every step of the type scale — is read from `Theme`, and nowhere
// else. Nothing outside this directory names a colour. Which colour `Theme`
// hands back depends on `dark`, and for the accent on `accent-choice` as
// well, and that is the whole of the switch.
//
// The split across the files is by what a theme gets to decide:
//
//   - `dark.slint` and `light.slint` are the palettes. Colours only, the same
//     token names in the same order, and each one complete — no palette
//     borrows a value from the other. Their headers say what the values mean
//     and which relationships between them are load-bearing; read the dark
//     one first, it is where those rules are written down. Each lists its
//     accents as a row of `Accent`s (accent.slint), in the order this file
//     names them.
//   - This file holds the switch, and everything a palette does *not* get to
//     decide: the type, the shape, and the content colours. A second theme is
//     a retone, not a redraw — the panels are the same size and the corners
//     are the same radius under both — and the colours a *title* can be belong
//     to the document, which is exported the same way whichever theme the
//     window happened to be wearing.
//
// To add a third theme: write the palette next door, import it here, and give
// `dark` more than two answers to be. To add an accent: a row in each palette
// and a name in `accent-names`, at the same position. To fork the look
// wholesale: change the values in a palette. None of it touches a file
// outside this directory.
//
// Two things are deliberately *not* here:
//
//   - The effect previews in ui/assets, which are photographs of what an
//     effect does rather than anything a theme decides.
//   - Sizes under about 5px — a 2px scrollbar thumb, a 1px splitter pill.
//     Those are shape at a scale nobody themes, and stay where they are drawn.
import { Accent } from "accent.slint";
import { Dark } from "dark.slint";
import { Light } from "light.slint";

export global Theme {
    /// Which palette every colour below is read from. Settings > Appearance
    /// picks it (main.rs, `on_settings_theme_changed`), and every binding in
    /// the tree is a property read away from it, so the window retones in a
    /// frame without anything being rebuilt.
    in-out property <bool> dark: true;
    /// Which of the palettes' accents the accent tokens are read from: an
    /// index into `accent-names`, and into each palette's `accents`.
    /// Settings > Appearance picks it (lib.rs, `on_settings_accent_changed`)
    /// the way it picks `dark`, and it retones the window the same way.
    /// Remembered by name rather than by number, so a list that grows or
    /// reorders keeps everyone's choice; 0 is Lime, the default. One past
    /// the last name is the custom colour, `accent-custom`.
    in-out property <int> accent-choice: 0;
    /// A colour picked by hand in place of any on the list. Read only while
    /// `accent-choice` points past the list, and one colour under both
    /// palettes: whoever picked it picked what they see, and the three
    /// tokens that go with an accent are derived from it below, each by
    /// the palette's own rule. Grey until picked — the dot that offers it
    /// is grey, and a grey accent is what nobody would choose, so it
    /// cannot be mistaken for a choice that was made.
    in-out property <color> accent-custom: #808080;
    /// The chosen accent is the picked one rather than one of the list.
    out property <bool> accent-is-custom: accent-choice >= accent-names.length;
    /// The accents on offer, in the order both palettes list them. Each
    /// name is the English word Settings shows for it, and the id it is
    /// remembered under in settings.json, lower-cased; the dialog holds the
    /// same list wrapped for translation, in this order.
    out property <[string]> accent-names: ["Lime", "Sky", "Violet", "Rose", "Amber", "Mint"];
    /// The playhead's colour when one was picked by hand in Settings >
    /// Appearance, in place of the palette's own. Read only while
    /// `playhead-is-custom`, and one colour under both palettes, for the
    /// reason the custom accent is: whoever picked it picked what they see.
    /// Grey until picked, so the dot that offers it reads as a blank.
    in-out property <color> playhead-custom: #808080;
    /// The playhead wears `playhead-custom` rather than the palette's own.
    /// Settings > Appearance sets both (lib.rs, `on_settings_playhead_changed`)
    /// and clears this one to put the palette's back.
    in-out property <bool> playhead-is-custom: false;
    /// Which interface scale the window is drawn at: an index into the
    /// scales Settings > Appearance lists, 0 being the display's own. Read
    /// off the Theme global the way the theme and the accent are - it is a
    /// fact about the window, not editor state - though it is not a colour:
    /// the backend takes a multiplier, which Rust gives the open window as a
    /// scale-factor event and puts in `SLINT_SCALE_FACTOR` for the next
    /// launch (lib.rs, `on_settings_scale_changed`).
    /// https://github.com/jub0t/Concat/issues/320
    in-out property <int> ui-scale: 0;

    // ── type ─────────────────────────────────────────────────────────────
    //
    // Two roles, not one, even while one face plays both.
    //
    // `font` carries the interface: every label, title and sentence. `font-
    // technical` is for timecode, the ruler, clip labels, paths, dimensions,
    // counts — anything you read as a *value* rather than as language.
    //
    // Both are Hanken Grotesk, the one face this build bundles (app.slint).
    // The split between the roles stays so that the two can differ again
    // without touching a single element.
    out property <string> font: "Hanken Grotesk";
    out property <string> font-technical: "Hanken Grotesk";
    /// The scale. `fs` is the body size everything inherits; the two either
    /// side of it are the dense readout and the panel title. `xl` is for the
    /// few lines that are content rather than chrome — a project's name in a
    /// list — and `display` is the launch screen's heading and nothing else.
    out property <length> fs-xs: 10px;
    out property <length> fs-sm: 11px;
    out property <length> fs: 12px;
    out property <length> fs-lg: 13px;
    out property <length> fs-xl: 14px;
    out property <length> fs-input: 15px;
    out property <length> fs-display: 34px;

    // The weights the design actually calls for, uncompensated.
    //
    // Skia composites glyph coverage with gamma correction, so text comes out
    // at the weight the tokens name. Do not step these up to make text read
    // heavier on some screen: that is a renderer compensation (FemtoVG, which
    // the app no longer builds with, needed 500/600), and under Skia it reads
    // as too heavy.
    //
    // Weight is the one axis that can absorb a renderer difference without
    // touching a colour token, and every face is bundled, so it costs nothing
    // at runtime. Reach for it rather than nudging a surface to compensate.
    out property <int> weight-body: 400;
    out property <int> weight-title: 500;
    /// The launch screen's heading, and the wordmark in the title bar. The one
    /// weight above `title`, and the only place the type gets to be loud. Bold
    /// is bundled, so this names it exactly.
    out property <int> weight-display: 700;

    // ── shape ────────────────────────────────────────────────────────────
    //
    // radii
    out property <length> r-xs: 3px;
    out property <length> r-sm: 5px;
    out property <length> r: 7px;
    out property <length> r-lg: 12px;
    /// The dialog sheet, and nothing smaller. A modal is the largest rounded
    /// thing in the window and wants a corner to match.
    out property <length> r-xl: 16px;

    // metrics
    out property <length> h: 28px;        // standard control height
    out property <length> gap: 6px;
    out property <length> pad: 14px;      // panel horizontal padding
    out property <length> label-w: 62px;

    // ── surfaces ─────────────────────────────────────────────────────────
    out property <color> panel: dark ? Dark.panel : Light.panel;
    out property <color> raised: dark ? Dark.raised : Light.raised;
    out property <color> well: dark ? Dark.well : Light.well;
    out property <color> field: dark ? Dark.field : Light.field;
    out property <color> field-hover: dark ? Dark.field-hover : Light.field-hover;
    out property <color> field-active: dark ? Dark.field-active : Light.field-active;

    // the launch screen's ladder: the same five steps, cut deeper. Read by
    // start.slint and by the title strip while it is up, and by nothing
    // else — the editor keeps the ladder above.
    out property <color> launch-page: dark ? Dark.launch-page : Light.launch-page;
    out property <color> launch-panel: dark ? Dark.launch-panel : Light.launch-panel;
    out property <color> launch-well: dark ? Dark.launch-well : Light.launch-well;
    out property <color> launch-raised: dark ? Dark.launch-raised : Light.launch-raised;
    out property <color> launch-field: dark ? Dark.launch-field : Light.launch-field;
    out property <color> launch-field-active:
        dark ? Dark.launch-field-active : Light.launch-field-active;

    // hairlines
    out property <color> line: dark ? Dark.line : Light.line;
    out property <color> line-strong: dark ? Dark.line-strong : Light.line-strong;

    // text
    out property <color> fg: dark ? Dark.fg : Light.fg;
    out property <color> fg-muted: dark ? Dark.fg-muted : Light.fg-muted;
    out property <color> fg-dim: dark ? Dark.fg-dim : Light.fg-dim;
    out property <color> fg-hot: dark ? Dark.fg-hot : Light.fg-hot;

    // accents — the chosen row of the palette that is on, spread into the
    // four tokens the tree has always read.
    //
    // A custom colour has no row, so its three companions are made from it
    // the way each palette makes its own: hover is a step towards more
    // contrast, which is brighter on a dark ground and darker on a light
    // one; soft is the colour at the palette's wash alpha; and the ink on
    // it is dark or light by which of the two the colour itself is not.
    // Perceived lightness rather than the mean of the channels, so a pure
    // green gets dark ink and a pure blue gets light, as they should.
    out property <float> custom-light:
        (0.299 * accent-custom.red + 0.587 * accent-custom.green + 0.114 * accent-custom.blue) / 255;
    out property <Accent> custom-tone: {
        accent: accent-custom,
        hover: dark ? accent-custom.brighter(0.15) : accent-custom.darker(0.15),
        soft: accent-custom.with-alpha(dark ? 0.2 : 0.18),
        on: custom-light > 0.55 ? #16161a : #ffffff,
    };
    out property <Accent> tone: accent-is-custom ? custom-tone
        : dark ? Dark.accents[accent-choice] : Light.accents[accent-choice];
    out property <color> accent: tone.accent;
    out property <color> accent-hover: tone.hover;
    out property <color> accent-soft: tone.soft;
    out property <color> on-accent: tone.on;
    out property <color> green: dark ? Dark.green : Light.green;
    out property <color> on-green: dark ? Dark.on-green : Light.on-green;

    /// The `index`th accent under the palette that is on, for the row in
    /// Settings that offers them: each is shown as it would be worn, so the
    /// choice is made in the room it will be seen in.
    public pure function accent-of(index: int) -> color {
        return dark ? Dark.accents[index].accent : Light.accents[index].accent;
    }

    // the Rail's dragger
    out property <color> grip: dark ? Dark.grip : Light.grip;
    out property <color> grip-active: dark ? Dark.grip-active : Light.grip-active;
    out property <color> grip-edge: dark ? Dark.grip-edge : Light.grip-edge;

    // meter ramp
    out property <color> meter-low: dark ? Dark.meter-low : Light.meter-low;
    out property <color> meter-mid: dark ? Dark.meter-mid : Light.meter-mid;
    out property <color> meter-high: dark ? Dark.meter-high : Light.meter-high;

    // media kinds
    out property <color> kind-video: dark ? Dark.kind-video : Light.kind-video;
    out property <color> kind-video-well: dark ? Dark.kind-video-well : Light.kind-video-well;
    out property <color> kind-audio: dark ? Dark.kind-audio : Light.kind-audio;
    out property <color> kind-audio-well: dark ? Dark.kind-audio-well : Light.kind-audio-well;
    out property <color> kind-image: dark ? Dark.kind-image : Light.kind-image;
    out property <color> kind-image-well: dark ? Dark.kind-image-well : Light.kind-image-well;
    out property <color> kind-text: dark ? Dark.kind-text : Light.kind-text;
    out property <color> kind-text-well: dark ? Dark.kind-text-well : Light.kind-text-well;
    out property <color> kind-filter: dark ? Dark.kind-filter : Light.kind-filter;
    out property <color> kind-filter-well: dark ? Dark.kind-filter-well : Light.kind-filter-well;
    out property <color> kind-shape: dark ? Dark.kind-shape : Light.kind-shape;
    out property <color> kind-shape-well: dark ? Dark.kind-shape-well : Light.kind-shape-well;
    out property <color> kind-sound-layer: dark ? Dark.kind-sound-layer : Light.kind-sound-layer;
    out property <color> kind-sound-layer-well: dark ? Dark.kind-sound-layer-well : Light.kind-sound-layer-well;

    // timeline
    out property <color> lane: dark ? Dark.lane : Light.lane;
    out property <color> lane-alt: dark ? Dark.lane-alt : Light.lane-alt;
    out property <color> ruler: dark ? Dark.ruler : Light.ruler;
    out property <color> grid: dark ? Dark.grid : Light.grid;
    /// The palette's own playhead, for the dot in Settings that offers it
    /// back while a picked colour is on.
    out property <color> playhead-default: dark ? Dark.playhead : Light.playhead;
    out property <color> playhead: playhead-is-custom ? playhead-custom : playhead-default;
    out property <color> wave: dark ? Dark.wave : Light.wave;
    out property <color> wave-video: dark ? Dark.wave-video : Light.wave-video;
    out property <color> wave-hot: dark ? Dark.wave-hot : Light.wave-hot;
    /// Where a waveform's bar goes hot: the peak level, as a fraction of
    /// full scale, above which the part of the bar over it is drawn in
    /// `wave-hot`. -6 dBFS: a mix that keeps its peaks under it has
    /// headroom, one that crosses it often is on its way to clipping.
    out property <float> wave-hot-line: 0.5012;

    // clip ink
    out property <color> clip-ink: dark ? Dark.clip-ink : Light.clip-ink;
    out property <color> clip-body: dark ? Dark.clip-body : Light.clip-body;
    out property <color> clip-chip: dark ? Dark.clip-chip : Light.clip-chip;
    out property <color> wave-centre: dark ? Dark.wave-centre : Light.wave-centre;
    out property <color> fade-shade: dark ? Dark.fade-shade : Light.fade-shade;
    out property <color> fade-edge: dark ? Dark.fade-edge : Light.fade-edge;
    out property <color> transition-in: dark ? Dark.transition-in : Light.transition-in;
    out property <color> transition-out: dark ? Dark.transition-out : Light.transition-out;

    // the monitor
    out property <color> stage: dark ? Dark.stage : Light.stage;
    out property <color> sample-ground: dark ? Dark.sample-ground : Light.sample-ground;
    out property <color> on-stage-dim: dark ? Dark.on-stage-dim : Light.on-stage-dim;

    // sheets over things that are not panels
    out property <color> overlay: dark ? Dark.overlay : Light.overlay;
    out property <color> scrim: dark ? Dark.scrim : Light.scrim;
    out property <color> on-scrim: dark ? Dark.on-scrim : Light.on-scrim;

    // destructive
    out property <color> danger: dark ? Dark.danger : Light.danger;
    out property <color> danger-soft: dark ? Dark.danger-soft : Light.danger-soft;
    out property <color> danger-wash: dark ? Dark.danger-wash : Light.danger-wash;
    out property <color> danger-edge: dark ? Dark.danger-edge : Light.danger-edge;

    // the window ground the panes float on
    out property <color> page: dark ? Dark.page : Light.page;
    out property <color> page-fg-muted: dark ? Dark.page-fg-muted : Light.page-fg-muted;

    // ── content ──────────────────────────────────────────────────────────
    //
    // Colours the *edit* can be made of, as opposed to the interface — and the
    // one group here that does not follow the switch. A title's colour is
    // baked into the export; the video does not have a theme, and a shelf that
    // offered different colours depending on which way the toggle was pointing
    // would be offering to change the cut by changing the lighting in the room.
    //
    // They live here rather than beside the control that offers them because
    // there is exactly one shelf and it belongs to the whole application. The
    // list is the neutrals first, then the interface's own status hues, then
    // the clip palette's marks — the chosen accent under both palettes is in
    // it, so the row agrees with the window whichever way it is set. Those
    // two are the one thing in the shelf that follows a setting, and only
    // which colour is *offered* moves: a title already painted keeps its
    // colour, because the colour is in the document and not in the theme.
    // A custom accent has one colour, not two, so it takes the first slot
    // and the lime keeps the second.
    out property <[color]> swatches: [
        #ffffff, #f5f5f7, #a1a1a6, #6e6e73, #15220a, #000000,
        accent-is-custom ? accent-custom : Dark.accents[accent-choice].accent,
        accent-is-custom ? Dark.accents[0].accent : Light.accents[accent-choice].accent,
        #30d158, #ffd60a, #f09e2f, #ff453a,
        #e8355e, #8b5cf6, #4d8df6, #142640,
    ];
    /// What a title's plate is set to when the switch is turned on. A colour
    /// and not a flag: turning it off is clearing it, and this is what "on"
    /// means the first time.
    out property <color> plate-on: #000000cc;
}