The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.
Rust ffmpegfree-video-editormodel-context-protocolnon-linear-editoroffline-firstopen-source-video-editorself-hostedvideo-editingvideo-editing-automationvideo-editing-softwarevideo-editing-toolsvideo-editorvoice-cloningyoutube-automationyoutube-shorts
// SPDX-License-Identifier: AGPL-3.0-or-later
// SPDX-FileCopyrightText: 2026 Jareer Abdullah and Concat contributors
import { I18n } from "i18n.slint";
import { Theme } from "theme/theme.slint";
import { CopyChip, Modal } from "primitives/modal.slint";
import { FocusRing } from "primitives/focus-ring.slint";
import { Glyph, Icon } from "icons.slint";
import { ThinScrollbar } from "primitives/scrollbar.slint";
import { Tip } from "primitives/tooltip.slint";
import { Focus } from "util.slint";
import { NumberField } from "primitives/number-field.slint";
import { Select } from "primitives/select.slint";
import { CanvasPicker } from "dialogs/canvas-picker.slint";
import { SegmentedControl } from "primitives/segmented-control.slint";
// The launch screen: the app's home, and the window's own ground under all
// of it — no card around the whole thing, no shadow. A setup screen is not
// a dialog floating over something; it *is* the window.
//
// Three things, in the order a person wants them, the way CapCut's home
// and every modern editor's start page have them:
//
// - create: New project, filled with the accent, the one verb on the page
// that starts something; Open project beside it; and where the system
// can drag a file in, a tile saying the window takes a drop - a project
// folder opens, media starts a new project with it;
// - the projects: every one this machine has opened, as a grid of posters
// with their running time, edit time and frame, hover actions to show
// one in its folder or forget it, a missing folder shown as missing, and
// a search and a sort once there are more than a page of them;
// - learn and community: the guides, the first edit, the shortcuts, the
// repository, the Discord and how to report a problem, as cards that
// open in the browser, and the version with its release notes.
//
// The settings are behind the title strip's gear, as they are in the
// editor.
//
// The new project's form is a sheet over the window — `NewProjectDialog`,
// held at the window root like every other sheet, since Slint has no
// portal — rather than a page of its own. An editor should not drop you
// straight into an untitled timeline: the frame rate, the frame shape and
// where the folder goes are decisions the whole edit depends on, and
// choosing them after material is cut is how you end up conforming
// footage. But five rows of settings are a question to answer, not a place
// to be, and a question is a sheet.
//
// Two shapes by the width the window is given, since a Slint layout has no
// wrap:
//
// - wide, a desk's window from 680px up: one centred column, the create
// row across it, the projects as a grid, and the learn cards as a panel
// beside the projects once the column is 1100px wide, under them before;
// - narrow, a phone held upright: stacked the way a phone's own apps are -
// New project across the width, the projects as a list of rows with the
// forget cross on every one, since there is no hover to reveal it with,
// and the learn cards as one grouped list at the foot. The sheet's labels
// sit over their values there, with its chip rows across the width.
//
// The look is the website's, which is the same product wearing the same
// clothes: near-black steps for the surfaces, a hairline of light on the
// top edge of anything raised, one accent used on almost nothing, and a
// filled button whose fill is the ink rather than the accent. The accent
// here is New project's fill and the one link in the sheet.
//
// There is no template store in this tree, which is also why the library's
// "save as template" is an unwired seam, and why the create row has no
// fourth verb.
/// One option on one of the form's three ladders.
///
/// The word the chip carries, and — on the shape ladder — the proportions
/// of the little box drawn beside it. A zero ratio is a chip with no box,
/// which is every size and every rate.
export struct ChipOption {
label: string,
/// Width over height: 1.78 for 16:9, 0.5625 upright, 0 for no box.
ratio: float,
}
/// One card in the projects grid.
///
/// The two lines under the name arrive formatted. A decimal frame rate to
/// two places and a coarse "4 days ago" are both easier to produce where
/// the numbers are than in an expression language with no printf and no
/// clock.
export struct RecentProjectData {
/// The folder, and the card's identity — what reopening and forgetting
/// name.
path: string,
name: string,
/// "1080 × 1920 · 30 fps"
detail: string,
/// When it was last worked on: "2 hours ago", "yesterday".
when: string,
/// How long its timeline runs, "1:05"; empty until it has been read,
/// or when there is nothing on it.
length: string,
/// The frame's width over its height.
ratio: float,
/// Its folder is not there: a drive unplugged, the folder moved.
missing: bool,
/// A frame from the earliest clip on its timeline, once something has
/// produced one. Empty falls back to a quiet film mark rather than an
/// error: the launch screen is not the place to complain about footage.
poster: image,
}
/// The form, as one struct — the same shape the other sheets use, and for
/// the same reason: it is one sheet's worth of state and a partial update
/// is how a panel ends up showing half of two things.
export struct StartData {
/// The sheet is up. Rust takes it down when the project it describes
/// opens, so a create that fails leaves the form and its notice where
/// they were.
composing: bool,
name: string,
location: string,
/// Index into `aspects`; the ratio behind it is Rust's.
aspect: int,
/// Index into `sizes`.
size: int,
/// Index into `rates`.
rate: int,
/// The rates as the dropdown lists them, "24 fps" and the rest, then
/// Custom: published with the rest of the sheet, so the words follow a
/// change of language.
rate-options: [string],
/// "1920 x 1080"
size-readout: string,
/// The frame and rate as numbers, for the custom fields: the typed
/// ones when Custom is picked, the preset's otherwise, so picking
/// Custom starts the fields from the frame that was showing.
custom-width: float,
custom-height: float,
custom-fps: float,
/// The chosen frame's width over its height, for the swatch beside the
/// readout that shows its shape: 1.78 for landscape HD, 0.56 upright.
frame-aspect: float,
/// "30/1 fps" — the exact fraction, because 29.97 is 30000/1001 and
/// never anything else.
rate-readout: string,
/// What shows where no picture covers the frame (#456).
canvas: color,
/// Creating. The button says so and everything is refused meanwhile.
busy: bool,
/// Non-empty puts up the notice above the button.
error: string,
/// Files dropped on the launch screen to start this project, which go
/// into it once it is made.
dropped: int,
/// The launch screen's project search, and its order: 0 the most
/// recent first, 1 by name.
query: string,
sort: int,
}
// ── the small parts ──────────────────────────────────────────────────────
// The shape of a frame: a box of the frame's own proportions inside a
// square of room, so 9:16 reads as upright at a glance and 4:3 as nearly
// square, without anyone reading the digits. At 15px it rides inside a
// chip; at 40px it stands beside the size readout.
component FrameShape inherits Rectangle {
in property <float> ratio: 16 / 9;
in property <length> room: 40px;
in property <brush> tint: Theme.line-strong;
in property <brush> fill: Theme.launch-well;
property <float> shape: Math.max(0.2, Math.min(5.0, root.ratio));
width: root.room;
height: root.room;
Rectangle {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
width: root.shape >= 1 ? root.room : root.room * root.shape;
height: root.shape >= 1 ? root.room / root.shape : root.room;
border-radius: Theme.r-xs;
background: root.fill;
border-width: 1px;
border-color: root.tint;
animate width, height { duration: 160ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
}
}
// A field's editable line: no box, no ground, just the text on the row it
// is in. The rules between the rows are already saying where one value ends
// and the next begins, so a border round each one is the same fact twice.
component PlainInput inherits Rectangle {
in property <string> text;
in property <string> placeholder;
in property <length> size: Theme.fs-input;
in property <string> face: Theme.font;
in property <bool> enabled: true;
callback edited(text: string);
callback accepted();
/// Takes the caret, and selects what is there — so the default name
/// can be replaced by typing rather than by clearing it first. Called
/// by the sheet each time it opens: a field built once and shown many
/// times cannot do this from `init`.
public function take-focus() {
input.focus();
input.select-all();
}
height: Math.max(22px, root.size + 8px);
// The text being edited, held apart from `text`.
//
// A TextInput writes to whatever it is bound to, and an assignment in
// Slint replaces the binding — so binding straight to the published
// value works for one keystroke and then goes deaf. Seeded instead, and
// never while the field has focus, so a republish mid-word cannot yank
// the caret. Same as `Field` in primitives/modal.slint, same reason.
property <string> draft;
function seed() { root.draft = root.text; }
init => { root.seed(); }
changed text => {
if (!input.has-focus) {
root.seed();
}
}
touch := TouchArea {
mouse-cursor: MouseCursor.text;
clicked => { input.focus(); }
}
input := TextInput {
x: 0;
y: (parent.height - self.height) / 2;
width: parent.width;
// A TextInput fills its Rectangle parent by default, so without
// this the centring above subtracts the parent's own height from
// itself and resolves to zero, leaving the text against the top
// edge. Same fix, and the same reason, as Field in modal.slint.
height: self.preferred-height;
text <=> root.draft;
color: Theme.fg;
font-family: root.face;
font-size: root.size;
single-line: true;
read-only: !root.enabled;
selection-background-color: Theme.accent;
selection-foreground-color: Theme.on-accent;
edited => { root.edited(self.text); }
accepted => { root.accepted(); }
}
if root.draft == "": Text {
x: 0;
y: (parent.height - self.height) / 2;
width: parent.width;
text: root.placeholder;
color: Theme.fg-dim;
font-family: root.face;
font-size: root.size;
overflow: elide;
}
}
// The one accent-coloured word in the sheet. A link and not a button: it
// opens a picker for the field beside it rather than doing anything to the
// project, and a filled button here would out-shout Create.
component LinkButton inherits Rectangle {
in property <string> label;
in property <bool> enabled: true;
callback clicked();
width: text.preferred-width;
height: 20px;
opacity: root.enabled ? (touch.has-hover ? 0.7 : 1.0) : 0.4;
animate opacity { duration: 100ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
text := Text {
x: 0;
y: (parent.height - self.height) / 2;
text: root.label;
color: Theme.accent;
font-size: Theme.fs-lg;
font-weight: Theme.weight-title;
}
touch := TouchArea {
enabled: root.enabled;
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
}
// One chip on a ladder: a pill that is either the answer or one of the
// others. Selected is a lit surface and a brighter edge, never a fill of
// the accent — the accent on this screen belongs to the new-project card
// and the link, and four lime pills in a row would leave nothing for the
// button to say.
component Chip inherits Rectangle {
in property <string> label;
/// Non-zero draws the shape of that ratio before the word.
in property <float> ratio;
in property <bool> selected;
in property <bool> enabled: true;
/// Fill the width the row gives it, rather than its own.
in property <bool> block;
/// The keyboard is on this row and this is the chip it is on.
in property <bool> ring;
callback clicked();
property <bool> lit: touch.has-hover && root.enabled;
property <length> box: root.ratio > 0 ? 15px : 0px;
property <length> gap: root.ratio > 0 ? 7px : 0px;
height: 32px;
horizontal-stretch: root.block ? 1 : 0;
// From the label's *preferred* width, never its actual one: the layout
// below sizes the label from this chip's width, so reading back the
// result is a loop. Same as Button in primitives/modal.slint.
min-width: caption.preferred-width + root.box + root.gap + 26px;
border-radius: self.height / 2;
background: root.selected ? Theme.launch-field
: root.lit ? Theme.launch-raised
: Colors.transparent;
border-width: 1px;
border-color: root.selected || root.lit ? Theme.line-strong : Theme.line;
opacity: root.enabled ? 1.0 : 0.45;
animate background, border-color { duration: 140ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
HorizontalLayout {
alignment: center;
spacing: root.gap;
if root.ratio > 0: VerticalLayout {
alignment: center;
FrameShape {
room: root.box;
ratio: root.ratio;
fill: Colors.transparent;
tint: root.selected ? Theme.fg-muted : Theme.fg-dim;
}
}
// The weight does not move with the selection: it is this chip's
// own preferred width, and a row whose chips resize as you step
// along it is a row that shudders.
caption := Text {
text: root.label;
color: root.selected || root.lit ? Theme.fg : Theme.fg-muted;
font-size: Theme.fs-lg;
font-weight: Theme.weight-title;
vertical-alignment: center;
animate color { duration: 140ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
}
}
touch := TouchArea {
enabled: root.enabled;
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
FocusRing {
active: root.ring;
radius: root.height / 2;
}
}
// A ladder of chips, and the arrow keys that walk it.
//
// The focus ring goes round the current chip rather than round the row: a
// stadium two hundred pixels wide says the row has the keyboard but not
// which answer it is on.
component ChipRow inherits Rectangle {
in property <[ChipOption]> options;
/// A last chip after the options, at index `options.length`: Custom,
/// on the rows that can be typed. Named here rather than carried in
/// `options` so its word is translated where it is drawn.
in property <string> extra;
in property <int> current;
in property <bool> enabled: true;
/// The chips share the width rather than take their own: the phone
/// shape, where a ladder has to fit across a thumb's screen.
in property <bool> block;
/// Chips a row, for a ladder too long for one - the rates, twelve
/// with Custom. Zero is one row of chips at their own widths; a count
/// lays them in rows of equal cells, so the ladder reads as a keypad
/// rather than as a line that runs off the sheet.
in property <int> per-row: 0;
callback changed(index: int);
property <bool> ring;
property <int> count: root.options.length + (root.extra != "" ? 1 : 0);
property <length> gap: 8px;
property <length> chip-h: 32px;
property <int> rows: root.per-row > 0 ? Math.ceil(root.count / root.per-row) : 1;
property <length> cell-w: root.per-row > 0
? (root.width - (root.per-row - 1) * root.gap) / root.per-row
: 0px;
height: root.rows * root.chip-h + (root.rows - 1) * root.gap;
function select(index: int) {
if (index >= 0 && index < root.count) {
root.changed(index);
}
}
fs := FocusScope {
enabled: root.enabled;
// :focus-visible — keyboard focus only, as in SegmentedControl.
focus-gained(reason) => {
root.ring = reason == FocusReason.tab-navigation;
}
focus-lost(reason) => {
root.ring = false;
}
key-pressed(event) => {
if (event.text == Key.RightArrow || event.text == Key.DownArrow) {
root.select(Math.mod(root.current + 1, root.count));
return EventResult.accept;
}
if (event.text == Key.LeftArrow || event.text == Key.UpArrow) {
root.select(Math.mod(root.current - 1 + root.count, root.count));
return EventResult.accept;
}
return EventResult.reject;
}
}
if root.per-row == 0: HorizontalLayout {
alignment: root.block ? LayoutAlignment.stretch : LayoutAlignment.start;
spacing: root.gap;
for option[index] in root.options: Chip {
label: option.label;
ratio: option.ratio;
selected: index == root.current;
enabled: root.enabled;
block: root.block;
ring: root.ring && index == root.current;
clicked => {
fs.focus();
root.select(index);
}
}
if root.extra != "": Chip {
label: root.extra;
selected: root.current == root.options.length;
enabled: root.enabled;
block: root.block;
ring: root.ring && root.current == root.options.length;
clicked => {
fs.focus();
root.select(root.options.length);
}
}
}
// The rows: placed by arithmetic, the way the grids are, since a Slint
// layout has no wrap. Every cell the same width, the last row shorter.
if root.per-row > 0: Rectangle {
for option[index] in root.options: Chip {
x: Math.mod(index, root.per-row) * (root.cell-w + root.gap);
y: Math.floor(index / root.per-row) * (root.chip-h + root.gap);
width: root.cell-w;
label: option.label;
ratio: option.ratio;
selected: index == root.current;
enabled: root.enabled;
ring: root.ring && index == root.current;
clicked => {
fs.focus();
root.select(index);
}
}
if root.extra != "": Chip {
x: Math.mod(root.options.length, root.per-row) * (root.cell-w + root.gap);
y: Math.floor(root.options.length / root.per-row) * (root.chip-h + root.gap);
width: root.cell-w;
label: root.extra;
selected: root.current == root.options.length;
enabled: root.enabled;
ring: root.ring && root.current == root.options.length;
clicked => {
fs.focus();
root.select(root.options.length);
}
}
}
}
// A labelled row of the form, with a hairline under it. Beside the value
// where there is room, above it where there is not.
//
// The label is the website's eyebrow: small, letter-spaced, quiet. It is
// handed here already in capitals, because the casing is Rust's — see
// `I18n.upper`.
component FormRow inherits Rectangle {
in property <string> label;
/// The last row carries no rule: there is nothing under it to divide
/// from.
in property <bool> last;
/// The label over the value rather than beside it: the narrow shape.
in property <bool> stacked;
/// The label column. Wide enough for the longest of them at 10px with
/// its tracking, which is what keeps every value on one x.
property <length> label-w: 84px;
property <length> body-x: root.stacked ? 0px : root.label-w + 20px;
property <length> body-y: root.stacked ? 30px : 18px;
height: root.body-y + body.preferred-height + 18px;
Text {
x: 0;
// Against the first line of the body rather than the top of the
// row: a ten-pixel label hung from the same y as a thirty-pixel
// chip reads as a footnote to the row above it.
y: root.stacked ? 14px : root.body-y + 9px;
width: root.stacked ? root.width : root.label-w;
text: root.label;
color: Theme.fg-dim;
font-family: Theme.font-technical;
font-size: Theme.fs-xs;
letter-spacing: 0.9px;
}
body := VerticalLayout {
x: root.body-x;
y: root.body-y;
width: root.width - root.body-x;
height: self.preferred-height;
spacing: 10px;
@children
}
if !root.last: Rectangle {
x: 0;
y: parent.height - 1px;
width: parent.width;
height: 1px;
background: Theme.line;
}
}
// The pill the sheet is built around, and its quieter sibling.
//
// Primary is the ink itself — near-white on the dark palette, near-black on
// the light one — and not the accent. It is the site's rule: one accent,
// spent on a mark and a word, never on a fill this size. Hover goes one
// step further from the ground rather than towards it, which is what
// `fg-hot` is for.
component PillButton inherits Rectangle {
in property <string> label;
in property <Glyph> glyph;
in property <bool> primary;
in property <bool> enabled: true;
in property <bool> block;
callback clicked();
property <bool> lit: touch.has-hover && root.enabled;
property <length> mark: root.glyph == Glyph.none ? 0px : 15px;
property <length> gap: root.glyph == Glyph.none ? 0px : 8px;
property <brush> ink: root.primary ? Theme.launch-page
: root.lit ? Theme.fg
: Theme.fg-muted;
height: 40px;
horizontal-stretch: root.block ? 1 : 0;
min-width: root.block ? 0px
: caption.preferred-width + root.mark + root.gap + 44px;
border-radius: self.height / 2;
background: root.primary ? (root.lit ? Theme.fg-hot : Theme.fg)
: root.lit ? Theme.launch-field
: Theme.launch-raised;
border-width: root.primary ? 0px : 1px;
border-color: root.lit ? Theme.line-strong : Theme.line;
opacity: root.enabled ? 1.0 : 0.4;
animate background, border-color { duration: 140ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
HorizontalLayout {
alignment: center;
spacing: root.gap;
if root.glyph != Glyph.none: VerticalLayout {
alignment: center;
Icon {
glyph: root.glyph;
size: 15px;
tint: root.ink;
}
}
caption := Text {
text: root.label;
color: root.ink;
font-size: Theme.fs-xl;
font-weight: Theme.weight-title;
vertical-alignment: center;
}
}
touch := TouchArea {
enabled: root.enabled;
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
}
// A round icon button: Open and Settings on the heading's row, for the
// narrow page that has no create row wide enough to put Open in.
component BarAction inherits Rectangle {
in property <Glyph> glyph;
in property <string> label;
in property <bool> enabled: true;
callback clicked();
property <bool> lit: touch.has-hover && root.enabled;
width: 36px;
height: 36px;
border-radius: self.width / 2;
background: root.lit ? Theme.launch-field : Theme.launch-raised;
border-width: 1px;
border-color: root.lit ? Theme.line-strong : Theme.line;
opacity: root.enabled ? 1.0 : 0.4;
accessible-role: button;
accessible-label: root.label;
accessible-action-default => { root.clicked(); }
animate background, border-color { duration: 140ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: root.glyph;
size: 16px;
tint: root.lit ? Theme.fg : Theme.fg-muted;
}
touch := TouchArea {
enabled: root.enabled;
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
Tip {
text: root.label;
active: touch.has-hover;
}
}
// ── the home page ────────────────────────────────────────────────────────
// Anything on the page that does something when pressed: a pointer's
// hover and press, Enter or Space once Tab has put the ring on it, and the
// ring. The look is the caller's, read from `lit`, `down` and `ring`; the
// content is its children, drawn over the touch area, so a button inside
// one - a card's Remove - still takes its own press.
component Pressable inherits Rectangle {
in property <bool> enabled: true;
in property <length> radius: Theme.r-lg;
/// What a screen reader calls it.
in property <string> label;
out property <bool> lit: touch.has-hover && root.enabled;
out property <bool> down: touch.pressed && root.enabled;
/// The keyboard is on it: Tab brought it here, not a click.
out property <bool> ring;
callback clicked();
/// Delete or Backspace with the ring on it.
callback deleted();
border-radius: root.radius;
accessible-role: button;
accessible-label: root.label;
accessible-action-default => { root.clicked(); }
// Under the touch area, so a press lands on the touch area and the
// keys on this; a click does not take the focus, so no ring follows
// the mouse about.
FocusScope {
enabled: root.enabled;
focus-gained(reason) => {
root.ring = reason == FocusReason.tab-navigation;
}
focus-lost(reason) => {
root.ring = false;
}
key-pressed(event) => {
if (event.text == Key.Return || event.text == "\n" || event.text == " ") {
root.clicked();
return accept;
}
if (event.text == Key.Delete || event.text == Key.Backspace) {
root.deleted();
return accept;
}
return reject;
}
}
touch := TouchArea {
enabled: root.enabled;
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
@children
FocusRing {
active: root.ring;
radius: root.radius;
}
}
// One of the create row's verbs: a mark in a round well, a title and the
// line under it. The primary one is filled with the accent - the one verb
// on the page that starts something wears the colour the person chose -
// and the other sits on the page's own card surface.
component CreateTile inherits Pressable {
in property <Glyph> glyph;
in property <string> title;
in property <string> note;
in property <bool> primary;
property <color> ink: root.primary ? Theme.on-accent : Theme.fg;
label: root.title;
background: root.primary
? (root.lit && !root.down ? Theme.accent-hover : Theme.accent)
: (root.lit ? Theme.launch-raised : Theme.launch-panel);
border-width: root.primary ? 0px : 1px;
border-color: root.lit ? Theme.line-strong : Theme.line;
opacity: root.enabled ? 1.0 : 0.45;
animate background, border-color { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
HorizontalLayout {
padding-left: 20px;
padding-right: 18px;
spacing: 14px;
VerticalLayout {
alignment: center;
Rectangle {
width: 42px;
height: 42px;
border-radius: self.width / 2;
background: root.primary ? root.ink.with-alpha(0.14) : Theme.launch-field;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: root.glyph;
size: 19px;
weight: root.primary ? 2.3 : 1.9;
tint: root.ink;
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 3px;
Text {
text: root.title;
color: root.ink;
font-size: 16px;
font-weight: Theme.weight-title;
overflow: elide;
}
Text {
text: root.note;
color: root.primary ? root.ink.with-alpha(0.72) : Theme.fg-dim;
font-size: Theme.fs;
overflow: elide;
}
}
}
}
// Where a drag from the file manager can land, said where the verbs are.
// It takes no press: the whole window takes the drop, and this only says
// so - so it is drawn as a hole in the page, a ring with nothing on it,
// rather than as one more card to click.
component DropTile inherits Rectangle {
border-radius: Theme.r-lg;
border-width: 1px;
border-color: Theme.line-strong;
HorizontalLayout {
padding-left: 20px;
padding-right: 18px;
spacing: 14px;
VerticalLayout {
alignment: center;
Icon {
glyph: Glyph.import;
size: 19px;
tint: Theme.fg-dim;
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 3px;
Text {
text: I18n.t("start.dropToStart");
color: Theme.fg-muted;
font-size: 16px;
font-weight: Theme.weight-title;
overflow: elide;
}
Text {
text: I18n.t("start.dropToStartNote");
color: Theme.fg-dim;
font-size: Theme.fs;
wrap: word-wrap;
max-height: 2 * Theme.fs * 1.4;
overflow: elide;
}
}
}
}
// A small round button over a poster: Show in folder, Remove from list.
// Dark glass under a white mark whatever the theme, because what is under
// it is a picture, not the page.
component PosterAction inherits Rectangle {
in property <Glyph> glyph;
in property <string> label;
callback clicked();
width: 28px;
height: 28px;
border-radius: self.width / 2;
background: touch.has-hover ? Theme.on-scrim.with-alpha(0.24) : Theme.scrim;
accessible-role: button;
accessible-label: root.label;
accessible-action-default => { root.clicked(); }
animate background { duration: 100ms; }
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: root.glyph;
size: 13px;
weight: 2.2;
tint: Theme.on-scrim;
}
touch := TouchArea {
mouse-cursor: pointer;
clicked => { root.clicked(); }
}
Tip {
text: root.label;
active: touch.has-hover;
}
}
// One project: its poster, inset in the card like a print on a mount, its
// running time over the poster's corner, and its name and what it is
// under it. Show in folder and Remove come up over the poster on hover - or
// stay there, where there is no hover. A project whose folder has gone
// keeps its card, greyed, saying so, with Remove always up.
component PosterCard inherits Pressable {
in property <RecentProjectData> project;
/// No pointer to hover with, so the actions stay out.
in property <bool> touchy;
/// Show in folder: a desk's, which has a file manager to show it in.
in property <bool> can-reveal;
callback opened();
callback forgotten();
callback revealed();
property <length> inset: 6px;
property <bool> actions: root.touchy || root.lit || root.ring || root.project.missing;
label: root.project.name;
clicked => { root.opened(); }
deleted => { root.forgotten(); }
background: root.lit ? Theme.launch-raised : Theme.launch-panel;
border-width: 1px;
border-color: root.lit ? Theme.line-strong : Theme.line;
animate background, border-color { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
poster := Rectangle {
x: root.inset;
y: root.inset;
width: root.width - 2 * root.inset;
// The frame is always this shape, poster or not, so a poster that
// arrives late moves nothing on the page.
height: self.width * 9 / 16;
border-radius: Theme.r;
background: Theme.launch-well;
clip: true;
if root.project.poster.width > 0 && !root.project.missing: Image {
width: parent.width;
height: parent.height;
source: root.project.poster;
image-fit: cover;
}
if root.project.poster.width == 0 && !root.project.missing: Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.film;
size: 20px;
weight: 1.5;
tint: Theme.fg-dim;
}
if root.project.missing: VerticalLayout {
alignment: center;
spacing: 8px;
HorizontalLayout {
alignment: center;
Icon {
glyph: Glyph.folder;
size: 20px;
weight: 1.5;
tint: Theme.fg-dim;
}
}
Text {
text: I18n.t("start.folderNotFound");
color: Theme.fg-muted;
font-size: Theme.fs;
horizontal-alignment: center;
}
}
// The running time, where every video site puts it.
if root.project.length != "": Rectangle {
x: parent.width - self.width - 8px;
y: parent.height - self.height - 8px;
width: length-text.preferred-width + 12px;
height: 20px;
border-radius: Theme.r-sm;
background: Theme.scrim;
length-text := Text {
text: root.project.length;
color: Theme.on-scrim;
font-family: Theme.font-technical;
font-size: Theme.fs-sm;
font-weight: Theme.weight-title;
vertical-alignment: center;
horizontal-alignment: center;
}
}
if root.actions: HorizontalLayout {
x: parent.width - self.preferred-width - 8px;
y: 8px;
height: 28px;
width: self.preferred-width;
spacing: 6px;
if root.can-reveal && !root.project.missing: PosterAction {
glyph: Glyph.folder;
label: I18n.t("start.showInFolder");
clicked => { root.revealed(); }
}
PosterAction {
glyph: Glyph.close;
label: I18n.t("start.removeFromList");
clicked => { root.forgotten(); }
}
}
}
VerticalLayout {
x: root.inset + 6px;
y: poster.y + poster.height + 10px;
width: root.width - 2 * root.inset - 12px;
height: self.preferred-height;
spacing: 3px;
Text {
text: root.project.name;
color: root.project.missing ? Theme.fg-muted : Theme.fg;
font-size: Theme.fs-xl;
font-weight: Theme.weight-title;
overflow: elide;
}
// Where it was, for one that has gone: the one thing worth
// knowing about a folder that is not there.
Text {
text: root.project.missing ? root.project.path
: root.project.when + " · " + root.project.detail;
color: Theme.fg-dim;
font-size: Theme.fs-sm;
overflow: elide;
}
}
}
// The projects as a grid of posters.
//
// `grid-cols-[repeat(auto-fill,minmax(220px,1fr))]`, arithmetic instead of
// a layout: Slint has no auto-fill grid, and a GridLayout wants its cells
// named at compile time, which a model cannot do. Same as the bin's grid in
// workspace/media-pane.slint.
component ProjectsGrid inherits Rectangle {
in property <[RecentProjectData]> recents;
in property <bool> enabled: true;
in property <bool> touchy;
in property <bool> can-reveal;
callback opened(path: string);
callback forgotten(path: string);
callback revealed(path: string);
property <length> gap: 16px;
property <length> min-card: 220px;
property <int> cols: Math.max(1,
Math.floor((root.width + root.gap) / (root.min-card + root.gap)));
property <length> card-w: (root.width - (root.cols - 1) * root.gap) / root.cols;
/// The inset poster, and the name and the line under it.
property <length> card-h: (root.card-w - 12px) * 9 / 16 + 70px;
property <int> rows: Math.ceil(root.recents.length / root.cols);
height: Math.max(0px, root.rows * (root.card-h + root.gap) - root.gap);
for project[index] in root.recents: PosterCard {
x: Math.mod(index, root.cols) * (root.card-w + root.gap);
y: Math.floor(index / root.cols) * (root.card-h + root.gap);
width: root.card-w;
height: root.card-h;
project: project;
enabled: root.enabled;
touchy: root.touchy;
can-reveal: root.can-reveal;
opened => { root.opened(project.path); }
forgotten => { root.forgotten(project.path); }
revealed => { root.revealed(project.path); }
}
}
// One project as a row of a list: the narrow page's shape, where a grid of
// posters a thumb wide is a column of stamps. The poster small at the
// start, the name and what it is beside it, Remove at the end.
component ProjectRow inherits Pressable {
in property <RecentProjectData> project;
callback opened();
callback forgotten();
label: root.project.name;
radius: Theme.r;
clicked => { root.opened(); }
deleted => { root.forgotten(); }
height: 68px;
background: root.lit || root.down ? Theme.launch-raised : Colors.transparent;
HorizontalLayout {
padding-left: 8px;
padding-right: 2px;
padding-top: 8px;
padding-bottom: 8px;
spacing: 12px;
Rectangle {
width: 92px;
border-radius: Theme.r-sm;
background: Theme.launch-well;
clip: true;
if root.project.poster.width > 0 && !root.project.missing: Image {
width: parent.width;
height: parent.height;
source: root.project.poster;
image-fit: cover;
}
if root.project.poster.width == 0 || root.project.missing: Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: root.project.missing ? Glyph.folder : Glyph.film;
size: 16px;
weight: 1.5;
tint: Theme.fg-dim;
}
if root.project.length != "" && !root.project.missing: Rectangle {
x: parent.width - self.width - 4px;
y: parent.height - self.height - 4px;
width: row-length.preferred-width + 8px;
height: 16px;
border-radius: Theme.r-xs;
background: Theme.scrim;
row-length := Text {
text: root.project.length;
color: Theme.on-scrim;
font-family: Theme.font-technical;
font-size: Theme.fs-xs;
vertical-alignment: center;
horizontal-alignment: center;
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 3px;
Text {
text: root.project.name;
color: root.project.missing ? Theme.fg-muted : Theme.fg;
font-size: Theme.fs-xl;
font-weight: Theme.weight-title;
overflow: elide;
}
Text {
text: root.project.missing ? I18n.t("start.folderNotFound")
: root.project.when + " · " + root.project.detail;
color: Theme.fg-dim;
font-size: Theme.fs-sm;
overflow: elide;
}
}
// A thumb's target, though the cross is small: the whole square
// at the row's end takes the press.
Rectangle {
width: 44px;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.close;
size: 14px;
tint: forget.pressed || forget.has-hover ? Theme.fg : Theme.fg-dim;
}
forget := TouchArea {
mouse-cursor: pointer;
clicked => { root.forgotten(); }
}
}
}
}
// The search over the projects: a pill with the glass at its start and a
// cross at its end once there is something to clear.
component SearchField inherits Rectangle {
in property <string> text;
in property <string> placeholder;
callback edited(text: string);
// Seeded, never bound: see PlainInput, same reason.
property <string> draft;
function seed() { root.draft = root.text; }
init => { root.seed(); }
changed text => {
if (!input.has-focus) {
root.seed();
}
}
height: 34px;
border-radius: self.height / 2;
background: Theme.launch-panel;
border-width: 1px;
border-color: input.has-focus ? Theme.accent
: touch.has-hover ? Theme.line-strong : Theme.line;
animate border-color { duration: 120ms; }
touch := TouchArea {
mouse-cursor: MouseCursor.text;
clicked => { input.focus(); }
}
Icon {
x: 12px;
y: (parent.height - self.height) / 2;
glyph: Glyph.search;
size: 14px;
tint: Theme.fg-dim;
}
input := TextInput {
x: 34px;
y: (parent.height - self.height) / 2;
width: parent.width - 34px - 32px;
height: self.preferred-height;
text <=> root.draft;
color: Theme.fg;
font-size: Theme.fs-lg;
single-line: true;
selection-background-color: Theme.accent;
selection-foreground-color: Theme.on-accent;
accessible-label: root.placeholder;
edited => { root.edited(self.text); }
}
if root.draft == "": Text {
x: 34px;
y: (parent.height - self.height) / 2;
width: parent.width - 34px - 12px;
text: root.placeholder;
color: Theme.fg-dim;
font-size: Theme.fs-lg;
overflow: elide;
}
if root.draft != "": Rectangle {
x: parent.width - self.width - 6px;
y: (parent.height - self.height) / 2;
width: 24px;
height: 24px;
border-radius: self.width / 2;
background: clear.has-hover ? Theme.launch-field : Colors.transparent;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.close;
size: 12px;
tint: Theme.fg-muted;
}
clear := TouchArea {
mouse-cursor: pointer;
clicked => {
root.draft = "";
root.edited("");
}
}
}
}
/// One card of the learn-and-community section: where it goes by name -
/// see `start::link` in Rust, and "shortcuts", which opens Settings - and
/// what it says.
struct LearnItem {
name: string,
glyph: Glyph,
title: string,
note: string,
/// Leaves the app for a web page: the arrow says so.
external: bool,
}
// One learn-and-community card: a mark in a square well, a title and the
// line under it, and an arrow out when it opens a web page. `flat` is the
// row of a grouped list, with the list's surface rather than its own.
component LearnCard inherits Pressable {
in property <LearnItem> item;
in property <bool> flat;
label: root.item.title;
radius: root.flat ? Theme.r : Theme.r-lg;
background: root.lit || root.down ? Theme.launch-raised
: root.flat ? Colors.transparent : Theme.launch-panel;
border-width: root.flat ? 0px : 1px;
border-color: root.lit ? Theme.line-strong : Theme.line;
animate background, border-color { duration: 120ms; easing: cubic-bezier(0.4, 0, 0.2, 1); }
HorizontalLayout {
padding-left: root.flat ? 10px : 14px;
padding-right: 14px;
spacing: 12px;
VerticalLayout {
alignment: center;
Rectangle {
width: 34px;
height: 34px;
border-radius: Theme.r;
background: root.lit ? Theme.launch-field-active : Theme.launch-field;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: root.item.glyph;
size: 17px;
tint: Theme.fg;
}
}
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: 2px;
Text {
text: root.item.title;
color: Theme.fg;
font-size: Theme.fs-lg;
font-weight: Theme.weight-title;
overflow: elide;
}
Text {
text: root.item.note;
color: Theme.fg-dim;
font-size: Theme.fs-sm;
overflow: elide;
}
}
VerticalLayout {
alignment: center;
Icon {
glyph: root.item.external ? Glyph.arrow-up-right : Glyph.chevron-right;
size: 14px;
tint: root.lit ? Theme.fg : Theme.fg-dim;
}
}
}
}
// A word that goes somewhere: the version line's release notes.
component TextLink inherits Pressable {
in property <string> text;
label: root.text;
radius: Theme.r-xs;
width: link-text.preferred-width + 14px;
height: 22px;
HorizontalLayout {
alignment: start;
spacing: 3px;
link-text := Text {
text: root.text;
color: root.lit ? Theme.fg : Theme.fg-muted;
font-size: Theme.fs-sm;
vertical-alignment: center;
}
VerticalLayout {
alignment: center;
Icon {
glyph: Glyph.arrow-up-right;
size: 11px;
tint: root.lit ? Theme.fg : Theme.fg-dim;
}
}
}
}
// The section headings: a title, and room at the end of its row for what
// works on the section - the search and the sort.
component SectionHead inherits HorizontalLayout {
in property <string> text;
/// A count beside the title, when there is one to give.
in property <string> count;
spacing: 10px;
VerticalLayout {
alignment: center;
Text {
text: root.text;
color: Theme.fg;
font-size: 17px;
font-weight: Theme.weight-title;
}
}
if root.count != "": VerticalLayout {
alignment: center;
Rectangle {
width: count-text.preferred-width + 14px;
height: 20px;
border-radius: self.height / 2;
background: Theme.launch-field;
count-text := Text {
text: root.count;
color: Theme.fg-muted;
font-family: Theme.font-technical;
font-size: Theme.fs-sm;
vertical-alignment: center;
horizontal-alignment: center;
}
}
}
Rectangle { horizontal-stretch: 1; }
@children
}
// What the projects section says when there are none: an invitation, not
// a blank. The way in for someone who has never cut a video is the guide
// that walks through the first one.
component EmptyProjects inherits Rectangle {
callback first-edit();
border-radius: Theme.r-lg;
border-width: 1px;
border-color: Theme.line;
background: Theme.launch-panel;
height: body.preferred-height;
body := VerticalLayout {
padding: 36px;
spacing: 12px;
alignment: center;
HorizontalLayout {
alignment: center;
Rectangle {
width: 52px;
height: 52px;
border-radius: self.width / 2;
background: Theme.launch-field;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.film;
size: 22px;
weight: 1.6;
tint: Theme.fg-muted;
}
}
}
Text {
text: I18n.t("start.noProjectsYet");
color: Theme.fg;
font-size: 16px;
font-weight: Theme.weight-title;
horizontal-alignment: center;
}
HorizontalLayout {
alignment: center;
Text {
max-width: 460px;
text: I18n.t("start.noProjectsNote");
color: Theme.fg-muted;
font-size: Theme.fs-lg;
horizontal-alignment: center;
wrap: word-wrap;
}
}
Rectangle { height: 4px; }
HorizontalLayout {
alignment: center;
PillButton {
label: I18n.t("start.firstEdit");
glyph: Glyph.circle-play;
clicked => { root.first-edit(); }
}
}
}
}
// The line at the foot of the page: which Concat this is, and what changed
// in it.
component VersionLine inherits HorizontalLayout {
in property <string> version;
callback notes();
spacing: 10px;
VerticalLayout {
alignment: center;
Text {
text: "Concat " + root.version;
color: Theme.fg-dim;
font-family: Theme.font-technical;
font-size: Theme.fs-sm;
}
}
VerticalLayout {
alignment: center;
Rectangle {
width: 3px;
height: 3px;
border-radius: 1.5px;
background: Theme.fg-dim;
}
}
TextLink {
text: I18n.t1("start.whatsNew", root.version);
clicked => { root.notes(); }
}
Rectangle { horizontal-stretch: 1; }
}
// The cards, and the words on them, in one place: the wide page lays them
// as a column beside the projects or a grid under them, the narrow one as
// a list. The phone has no Shortcuts page in its Settings, so it has no
// card for one.
global Learn {
out property <LearnItem> docs: {
name: "guides", glyph: Glyph.book, external: true,
title: I18n.t("start.documentation"), note: I18n.t("start.documentationNote"),
};
out property <LearnItem> guide: {
name: "first-edit", glyph: Glyph.circle-play, external: true,
title: I18n.t("start.firstEdit"), note: I18n.t("start.firstEditNote"),
};
out property <LearnItem> keys: {
name: "shortcuts", glyph: Glyph.keyboard, external: false,
title: I18n.t("start.keyboardShortcuts"), note: I18n.t("start.keyboardShortcutsNote"),
};
out property <LearnItem> code: {
name: "github", glyph: Glyph.github, external: true,
title: "GitHub", note: I18n.t("start.githubNote"),
};
out property <LearnItem> chat: {
name: "discord", glyph: Glyph.discord, external: true,
title: "Discord", note: I18n.t("start.discordNote"),
};
out property <LearnItem> report: {
name: "report", glyph: Glyph.bug, external: true,
title: I18n.t("start.reportProblem"), note: I18n.t("start.reportProblemNote"),
};
out property <[LearnItem]> desk: [docs, guide, keys, code, chat, report];
out property <[LearnItem]> phone: [docs, guide, code, chat, report];
}
// The learn cards as a grid of rows, for the wide page under the projects
// when there is no room for a column beside them.
component LearnGrid inherits Rectangle {
in property <[LearnItem]> items;
callback link(name: string);
property <length> gap: 12px;
property <int> cols: root.width >= 860px ? 3 : 2;
property <length> card-w: (root.width - (root.cols - 1) * root.gap) / root.cols;
property <length> card-h: 64px;
property <int> rows: Math.ceil(root.items.length / root.cols);
height: Math.max(0px, root.rows * (root.card-h + root.gap) - root.gap);
for item[index] in root.items: LearnCard {
x: Math.mod(index, root.cols) * (root.card-w + root.gap);
y: Math.floor(index / root.cols) * (root.card-h + root.gap);
width: root.card-w;
height: root.card-h;
item: item;
clicked => { root.link(item.name); }
}
}
// ── the screen ───────────────────────────────────────────────────────────
// The wide page: a desk's window, from 680px across to a 4K screen.
//
// One column, centred, no wider than reads well: a greeting, the create
// row, the projects, and - once the column is wide enough to spare it - a
// learn-and-community panel beside the projects rather than under them,
// so it is in view without a scroll and the projects keep the width.
component WideHome inherits Rectangle {
in property <[RecentProjectData]> recents;
in property <int> recents-total;
in property <string> query;
in property <int> sort;
in property <bool> busy;
in property <string> version;
in property <bool> can-drop;
callback compose();
callback open();
callback open-recent(path: string);
callback forget-recent(path: string);
callback reveal-recent(path: string);
callback search-edited(query: string);
callback sort-changed(sort: int);
callback link(name: string);
/// The margin the page keeps from the window's edges.
property <length> pad: Math.max(24px, Math.min(64px, root.width / 18));
property <length> pad-top: Math.max(28px, Math.min(72px, root.height / 12));
property <length> content-w: Math.min(root.width - 2 * root.pad, 1360px);
/// Room for the learn panel beside the projects.
property <bool> aside: root.content-w >= 1100px;
property <length> aside-w: root.content-w >= 1280px ? 360px : 330px;
property <length> aside-gap: 40px;
property <length> main-w: root.aside ? root.content-w - root.aside-w - root.aside-gap
: root.content-w;
/// The drop tile, beside New and Open, where they still have room.
property <bool> drop-tile: root.can-drop && root.main-w >= 940px;
/// The create row shares its width by weight - New a third again as
/// wide as the others - and not by what its words would like, so a
/// longer line on one tile does not shoulder the others aside.
property <length> tile-unit: (root.main-w - (root.drop-tile ? 2 : 1) * 14px)
/ (root.drop-tile ? 3.3 : 2.3);
property <bool> searchable: root.recents-total > 8;
flick := Flickable {
content-width: self.width;
content-height: Math.max(self.height, page.height + root.pad-top + root.pad);
interactive: page.height + root.pad-top + root.pad > self.height;
page := Rectangle {
x: (flick.width - self.width) / 2;
y: root.pad-top;
width: root.content-w;
height: Math.max(main.preferred-height,
root.aside ? side.y + side-body.preferred-height : 0px);
main := VerticalLayout {
x: 0;
y: 0;
width: root.main-w;
height: self.preferred-height;
alignment: start;
// ── the greeting ─────────────────────────────────────
Text {
text: root.recents-total == 0
? I18n.t("start.welcome")
: I18n.t("start.welcomeBack");
color: Theme.fg;
// The one display-sized line in the app. The tree
// bundles no display face, so the interface face
// carries it at its heaviest weight and tight tracking.
font-size: Theme.fs-display;
font-weight: Theme.weight-display;
letter-spacing: -1px;
wrap: word-wrap;
}
Rectangle { height: 8px; }
Text {
text: root.recents-total == 0
? I18n.t("start.welcomeNote")
: I18n.t("start.welcomeBackNote");
color: Theme.fg-muted;
font-size: Theme.fs-xl;
wrap: word-wrap;
}
Rectangle { height: 28px; }
// ── create ───────────────────────────────────────────
create-row := HorizontalLayout {
height: 92px;
spacing: 14px;
CreateTile {
width: root.tile-unit * 1.3;
primary: true;
glyph: Glyph.plus;
title: I18n.t("start.newProject");
note: I18n.t("start.newProjectNote");
enabled: !root.busy;
clicked => { root.compose(); }
}
CreateTile {
width: root.tile-unit;
glyph: Glyph.folder;
title: I18n.t("start.openProject");
note: I18n.t("start.openProjectNote");
enabled: !root.busy;
clicked => { root.open(); }
}
if root.drop-tile: DropTile {
width: root.tile-unit;
}
}
// Where the tile does not fit, a line says what it would.
if root.can-drop && !root.drop-tile: VerticalLayout {
padding-top: 12px;
Text {
text: I18n.t("start.dropHint");
color: Theme.fg-dim;
font-size: Theme.fs;
wrap: word-wrap;
}
}
Rectangle { height: 44px; }
// ── the projects ─────────────────────────────────────
SectionHead {
height: 34px;
text: I18n.t("start.recentProjects");
count: root.recents-total > 0 ? "\{root.recents-total}" : "";
// Past a page of them: by the time there are more
// than a screen holds, the eye is not a search.
if root.searchable: SearchField {
width: Math.min(260px, root.main-w * 0.32);
text: root.query;
placeholder: I18n.t("start.searchProjects");
edited(text) => { root.search-edited(text); }
}
if root.searchable: VerticalLayout {
alignment: center;
SegmentedControl {
width: 156px;
options: [I18n.t("start.sortRecent"), I18n.t("start.sortName")];
current: root.sort;
changed(index) => { root.sort-changed(index); }
}
}
}
Rectangle { height: 16px; }
if root.recents-total == 0: EmptyProjects {
first-edit => { root.link("first-edit"); }
}
if root.recents-total > 0 && root.recents.length == 0: Text {
text: I18n.t1("start.noMatches", root.query);
color: Theme.fg-muted;
font-size: Theme.fs-lg;
wrap: word-wrap;
}
ProjectsGrid {
recents: root.recents;
enabled: !root.busy;
can-reveal: true;
opened(path) => { root.open-recent(path); }
forgotten(path) => { root.forget-recent(path); }
revealed(path) => { root.reveal-recent(path); }
}
// ── learn, under the projects ────────────────────────
if !root.aside: VerticalLayout {
padding-top: 48px;
spacing: 16px;
SectionHead {
height: 34px;
text: I18n.t("start.learnAndCommunity");
}
LearnGrid {
items: Learn.desk;
link(name) => { root.link(name); }
}
VersionLine {
padding-top: 8px;
version: root.version;
notes => { root.link("release-notes"); }
}
}
}
// ── learn, beside the projects ───────────────────────────
// From the create row down, so its top lines up with the
// first thing that can be pressed.
side := Rectangle {
x: root.main-w + root.aside-gap;
y: create-row.y;
width: root.aside-w;
height: side-body.preferred-height;
visible: root.aside;
border-radius: Theme.r-lg;
background: Theme.launch-panel;
border-width: 1px;
border-color: Theme.line;
side-body := VerticalLayout {
padding: 8px;
padding-top: 16px;
spacing: 2px;
HorizontalLayout {
padding-left: 10px;
Text {
text: I18n.t("start.learnAndCommunity");
color: Theme.fg;
font-size: Theme.fs-xl;
font-weight: Theme.weight-title;
}
}
Rectangle { height: 8px; }
for item in Learn.desk: LearnCard {
height: 58px;
flat: true;
item: item;
enabled: root.aside;
clicked => { root.link(item.name); }
}
Rectangle {
height: 1px;
background: Theme.line;
}
VersionLine {
padding-left: 10px;
padding-top: 8px;
padding-bottom: 4px;
version: root.version;
notes => { root.link("release-notes"); }
}
}
}
}
}
if flick.interactive: ThinScrollbar {
x: parent.width - self.width - 2px;
y: 0;
height: parent.height;
viewport: parent.height;
content: flick.content-height;
offset: -flick.content-y;
scrolled(to) => { flick.content-y = -to; }
}
}
// The narrow page: a phone held upright, or a desk's window squeezed that
// far. Stacked the way a phone's own apps are - the greeting with Settings
// beside it, New project across the width under the thumb, the projects as
// a list, and the learn cards as one grouped list at the foot.
component NarrowHome inherits Rectangle {
in property <[RecentProjectData]> recents;
in property <int> recents-total;
in property <string> query;
in property <bool> busy;
in property <string> version;
/// A phone: no folder picker, so no Open; projects live in the app's
/// own folder, which the page already lists. See platform::pick_folder.
/// https://github.com/jub0t/Concat/issues/222
in property <bool> phone;
callback compose();
callback open();
callback open-settings();
callback open-recent(path: string);
callback forget-recent(path: string);
callback search-edited(query: string);
callback link(name: string);
property <length> pad: 16px;
property <bool> searchable: root.recents-total > 8;
flick := Flickable {
content-width: self.width;
content-height: Math.max(self.height, stack.preferred-height);
interactive: stack.preferred-height > self.height;
stack := VerticalLayout {
x: 0;
y: 0;
width: flick.width;
height: self.preferred-height;
padding-left: root.pad;
padding-right: root.pad;
padding-top: 24px;
padding-bottom: 28px;
alignment: start;
HorizontalLayout {
spacing: 8px;
Text {
horizontal-stretch: 1;
text: root.recents-total == 0
? I18n.t("start.welcome")
: I18n.t("start.welcomeBack");
color: Theme.fg;
font-size: 26px;
font-weight: Theme.weight-display;
letter-spacing: -0.6px;
vertical-alignment: center;
wrap: word-wrap;
}
if !root.phone: VerticalLayout {
alignment: center;
BarAction {
glyph: Glyph.folder;
label: I18n.t("start.openProject");
enabled: !root.busy;
clicked => { root.open(); }
}
}
VerticalLayout {
alignment: center;
BarAction {
glyph: Glyph.settings;
label: I18n.t("common.settings");
enabled: !root.busy;
clicked => { root.open-settings(); }
}
}
}
Rectangle { height: 6px; }
Text {
text: root.recents-total == 0
? I18n.t("start.welcomeNote")
: I18n.t("start.welcomeBackNote");
color: Theme.fg-muted;
font-size: Theme.fs-lg;
wrap: word-wrap;
}
Rectangle { height: 20px; }
// New project across the width: the one thing on the screen
// that starts something, where a thumb reaches.
CreateTile {
height: 72px;
primary: true;
glyph: Glyph.plus;
title: I18n.t("start.newProject");
note: I18n.t("start.newProjectNote");
enabled: !root.busy;
clicked => { root.compose(); }
}
Rectangle { height: 32px; }
SectionHead {
height: 28px;
text: I18n.t("start.recentProjects");
count: root.recents-total > 0 ? "\{root.recents-total}" : "";
}
if root.searchable: VerticalLayout {
padding-top: 12px;
SearchField {
text: root.query;
placeholder: I18n.t("start.searchProjects");
edited(text) => { root.search-edited(text); }
}
}
Rectangle { height: 10px; }
if root.recents-total == 0: EmptyProjects {
first-edit => { root.link("first-edit"); }
}
if root.recents-total > 0 && root.recents.length == 0: Text {
text: I18n.t1("start.noMatches", root.query);
color: Theme.fg-muted;
font-size: Theme.fs-lg;
wrap: word-wrap;
}
for project in root.recents: ProjectRow {
project: project;
enabled: !root.busy;
opened => { root.open-recent(project.path); }
forgotten => { root.forget-recent(project.path); }
}
Rectangle { height: 32px; }
SectionHead {
height: 28px;
text: I18n.t("start.learnAndCommunity");
}
Rectangle { height: 10px; }
// One grouped list, as a phone's settings are: one surface,
// rows on it, hairlines between.
Rectangle {
border-radius: Theme.r-lg;
background: Theme.launch-panel;
border-width: 1px;
border-color: Theme.line;
height: list.preferred-height;
list := VerticalLayout {
padding: 6px;
for item[index] in (root.phone ? Learn.phone : Learn.desk): VerticalLayout {
if index > 0: Rectangle {
height: 1px;
background: Theme.line;
}
LearnCard {
height: 56px;
flat: true;
item: item;
clicked => { root.link(item.name); }
}
}
}
}
Rectangle { height: 16px; }
VersionLine {
version: root.version;
notes => { root.link("release-notes"); }
}
}
}
}
// The launch screen: the window's own ground under all of it - no card
// round the whole thing, no shadow. A setup screen is not a dialog floating
// over something; it *is* the window. Two shapes by the width it is given,
// since a Slint layout has no wrap; see WideHome and NarrowHome.
export component StartScreen inherits Rectangle {
/// The projects the grid shows: the search applied and the sort.
in property <[RecentProjectData]> recents;
/// How many there are before the search.
in property <int> recents-total;
in property <string> query;
in property <int> sort;
/// A project is being made: every verb on the page waits for it.
in property <bool> busy;
/// "0.2.7"
in property <string> version;
/// A file can be dragged in from the system here.
in property <bool> can-drop;
in property <bool> phone;
/// Put up the sheet a new project is described on.
callback compose();
/// Open a project that already exists, picked from disk.
callback open();
callback open-recent(path: string);
callback forget-recent(path: string);
callback reveal-recent(path: string);
callback open-settings();
callback search-edited(query: string);
callback sort-changed(sort: int);
/// One of the page's links, by name; see `start::link` in Rust.
callback link(name: string);
property <bool> narrow: root.phone || root.width < 680px;
background: Theme.launch-page;
clip: true;
if !root.narrow: WideHome {
width: root.width;
height: root.height;
recents: root.recents;
recents-total: root.recents-total;
query: root.query;
sort: root.sort;
busy: root.busy;
version: root.version;
can-drop: root.can-drop;
compose => { root.compose(); }
open => { root.open(); }
open-recent(path) => { root.open-recent(path); }
forget-recent(path) => { root.forget-recent(path); }
reveal-recent(path) => { root.reveal-recent(path); }
search-edited(query) => { root.search-edited(query); }
sort-changed(sort) => { root.sort-changed(sort); }
link(name) => { root.link(name); }
}
if root.narrow: NarrowHome {
width: root.width;
height: root.height;
recents: root.recents;
recents-total: root.recents-total;
query: root.query;
busy: root.busy;
version: root.version;
phone: root.phone;
compose => { root.compose(); }
open => { root.open(); }
open-settings => { root.open-settings(); }
open-recent(path) => { root.open-recent(path); }
forget-recent(path) => { root.forget-recent(path); }
search-edited(query) => { root.search-edited(query); }
link(name) => { root.link(name); }
}
}
// ── the sheet ────────────────────────────────────────────────────────────
// The new project's form, over the window: what the card at the head of
// the grid and the rail's first verb both open.
//
// Its parts are the launch screen's own — the plain field, the chip
// ladders, the ink-filled pill — rather than the other sheets' fields and
// buttons, because it is the launch screen's form and wears the launch
// screen's clothes; it is held here with them for that reason. The window
// root places it with the other sheets, since a sheet has to be declared
// where it is drawn, and it is drawn over everything.
export component NewProjectDialog inherits Modal {
in property <StartData> data;
/// The three ladders. The numbers behind each index are Rust's, so
/// there is one place that knows what 4K is in pixels and that 29.97 is
/// 30000 over 1001 — see `ASPECTS`, `SIZES` and `RATES` in the
/// window.
in property <[ChipOption]> aspects;
in property <[ChipOption]> sizes;
in property <[ChipOption]> rates;
callback name-edited(name: string);
callback location-edited(path: string);
callback browse();
callback aspect-changed(index: int);
callback size-changed(index: int);
callback rate-changed(index: int);
callback custom-width-edited(width: float);
callback custom-height-edited(height: float);
callback custom-fps-edited(fps: float);
callback canvas-changed(value: color);
callback create();
callback dismiss-error();
/// A phone held upright: every label over its value, every chip row
/// across the width, the button across the width with its line under
/// it.
/// A phone: no folder picker, so no Open and no Choose - projects live
/// in the app's own folder, which the page already lists, and the
/// location is shown rather than typed. See platform::pick_folder.
/// https://github.com/jub0t/Concat/issues/222
in property <bool> phone;
property <bool> narrow: root.width < 680px;
/// A project needs somewhere to go. Everything else has a default.
property <bool> can-create: !root.data.busy && root.data.location != "";
open: root.data.composing;
title: I18n.t("start.newProject");
glyph: Glyph.plus;
// Not while creating: the sheet is what the notice lands on, and a
// sheet dismissed out from under a create is a create nobody hears
// about.
dismissable: !root.data.busy;
// Wide enough for six rates a row, with their readout beside an 84px
// label, and no wider than the window less a margin, on a phone.
surface-width: Math.min(640px, root.width - 32px);
// The caret goes to the name each time the sheet comes up, with the
// name selected, so the default is replaced by typing over it. From
// here rather than the field's own `init`: the sheet is built once,
// hidden, when the window is, and shown many times after.
changed open => {
if (root.open) {
name-field.take-focus();
}
}
VerticalLayout {
padding-left: root.narrow ? 18px : 26px;
padding-right: root.narrow ? 18px : 26px;
padding-top: 16px;
padding-bottom: 22px;
// What the form is for, before the form: the one line a person
// should read before choosing.
Text {
text: I18n.t("start.settingsApplyWholeEdit");
color: Theme.fg-muted;
font-size: Theme.fs;
wrap: word-wrap;
}
// Files dropped on the launch screen: the sheet is up because of
// them, and says where they are going.
if root.data.dropped > 0: HorizontalLayout {
padding-top: 10px;
spacing: 8px;
VerticalLayout {
alignment: start;
padding-top: 1px;
Icon {
glyph: Glyph.import;
size: 13px;
tint: Theme.accent;
}
}
Text {
horizontal-stretch: 1;
text: root.data.dropped == 1
? I18n.t("start.droppedOneFile")
: I18n.t1("start.droppedFiles", "\{root.data.dropped}");
color: Theme.fg;
font-size: Theme.fs;
wrap: word-wrap;
}
}
FormRow {
label: I18n.upper("common.name");
stacked: root.narrow;
name-field := PlainInput {
text: root.data.name;
placeholder: I18n.t("common.untitledProject");
enabled: !root.data.busy;
edited(text) => { root.name-edited(text); }
accepted => { root.create(); }
}
}
// A desk's question. A phone keeps its projects in the app's own
// folder, as every phone editor does, and a path there is nothing
// anybody can browse to, so the row is not shown.
if !root.phone: FormRow {
label: I18n.upper("start.location");
stacked: root.narrow;
HorizontalLayout {
spacing: 12px;
PlainInput {
horizontal-stretch: 1;
text: root.data.location;
placeholder: I18n.t("start.chooseAFolder");
size: Theme.fs;
face: Theme.font-technical;
enabled: !root.data.busy;
edited(text) => { root.location-edited(text); }
accepted => { root.create(); }
}
VerticalLayout {
alignment: center;
horizontal-stretch: 0;
LinkButton {
label: I18n.t("start.choose");
enabled: !root.data.busy;
// The field beside this ignores a new value while it
// holds the caret (see PlainInput), so a folder picked
// with the caret still in it never showed. Let go of
// it first; the window's press-away blur only covers
// a mouse, not a touch, a pen or the keyboard.
clicked => {
Focus.release();
root.browse();
}
}
}
}
}
FormRow {
label: I18n.upper("start.shape");
stacked: root.narrow;
HorizontalLayout {
spacing: 16px;
ChipRow {
horizontal-stretch: 1;
options: root.aspects;
current: root.data.aspect;
// A typed frame is its own shape.
enabled: !root.data.busy && root.data.size < root.sizes.length;
block: root.narrow;
// Seven shapes are past a phone's width; four to a
// row there, as the sizes wrap three.
per-row: root.narrow ? 4 : 0;
changed(index) => { root.aspect-changed(index); }
}
// The chosen frame at the row's end, drawn rather than
// described: the one thing on this sheet that shows what
// the numbers mean.
if !root.narrow: VerticalLayout {
alignment: center;
horizontal-stretch: 0;
FrameShape {
room: 32px;
ratio: root.data.frame-aspect;
}
}
}
}
FormRow {
label: I18n.upper("common.size");
stacked: root.narrow;
VerticalLayout {
spacing: 10px;
HorizontalLayout {
spacing: 16px;
ChipRow {
horizontal-stretch: 1;
options: root.sizes;
extra: I18n.t("common.custom");
current: root.data.size;
enabled: !root.data.busy;
block: root.narrow;
// Five chips and the readout do not fit one line of
// a phone held upright: 4K and Custom ran off the
// edge out of reach (#356). Three to a row there,
// as the frame rates wrap four.
per-row: root.narrow ? 3 : 0;
changed(index) => { root.size-changed(index); }
}
VerticalLayout {
alignment: center;
horizontal-stretch: 0;
Text {
text: root.data.size-readout;
color: Theme.fg-dim;
font-family: Theme.font-technical;
font-size: Theme.fs-sm;
}
}
}
// The typed frame: width by height, each side even and
// within 16 to 8192, which Rust rounds a typed number to.
if root.data.size == root.sizes.length: HorizontalLayout {
spacing: 8px;
alignment: start;
NumberField {
width: 96px;
value: root.data.custom-width;
minimum: 16;
maximum: 8192;
step: 2;
unit: "W";
enabled: !root.data.busy;
changed(value) => { root.custom-width-edited(value); }
}
Text {
text: "×";
color: Theme.fg-dim;
vertical-alignment: center;
}
NumberField {
width: 96px;
value: root.data.custom-height;
minimum: 16;
maximum: 8192;
step: 2;
unit: "H";
enabled: !root.data.busy;
changed(value) => { root.custom-height-edited(value); }
}
}
}
}
FormRow {
label: I18n.upper("common.frameRate");
stacked: root.narrow;
VerticalLayout {
spacing: 10px;
HorizontalLayout {
spacing: 16px;
// Eleven rates and Custom in a list, not a wall of
// twelve buttons: most edits want one of three, and
// the rest are there when the list is opened.
Select {
width: 168px;
options: root.data.rate-options;
current: root.data.rate;
enabled: !root.data.busy;
changed(index) => { root.rate-changed(index); }
}
Rectangle { horizontal-stretch: 1; }
VerticalLayout {
alignment: center;
horizontal-stretch: 0;
Text {
text: root.data.rate-readout;
color: Theme.fg-dim;
font-family: Theme.font-technical;
font-size: Theme.fs-sm;
}
}
}
// The typed rate, from 1 to 240. The readout above says the
// fraction it is kept as: 23.976 is 24000/1001.
if root.data.rate == root.rates.length: HorizontalLayout {
alignment: start;
NumberField {
width: 112px;
value: root.data.custom-fps;
minimum: 1;
maximum: 240;
step: 1;
precision: 3;
unit: "fps";
enabled: !root.data.busy;
changed(value) => { root.custom-fps-edited(value); }
}
}
}
}
// What shows where no picture covers the frame; see CanvasPicker.
FormRow {
label: I18n.upper("start.background");
last: true;
stacked: root.narrow;
CanvasPicker {
value: root.data.canvas;
enabled: !root.data.busy;
changed(value) => { root.canvas-changed(value); }
}
}
// The notice, above the button, wrapping to as many lines as the
// error takes: an elided error is half an error, and on a phone
// that is most of it.
if root.data.error != "": Rectangle {
height: notice.preferred-height + 4px;
notice := Rectangle {
x: 0;
y: 4px;
width: parent.width;
height: self.preferred-height;
border-radius: Theme.r;
background: Theme.danger-soft;
HorizontalLayout {
padding-left: 10px;
padding-right: 6px;
padding-top: 8px;
padding-bottom: 8px;
spacing: 8px;
VerticalLayout {
alignment: start;
padding-top: 2px;
Icon {
glyph: Glyph.info;
size: 13px;
tint: Theme.danger;
}
}
Text {
horizontal-stretch: 1;
text: root.data.error;
color: Theme.danger;
font-size: Theme.fs;
wrap: word-wrap;
}
VerticalLayout {
alignment: start;
CopyChip {
text: root.data.error;
}
}
VerticalLayout {
alignment: start;
Rectangle {
width: 22px;
height: 22px;
border-radius: Theme.r-xs;
Icon {
x: (parent.width - self.width) / 2;
y: (parent.height - self.height) / 2;
glyph: Glyph.close;
size: 11px;
tint: Theme.danger;
}
TouchArea {
mouse-cursor: pointer;
clicked => { root.dismiss-error(); }
}
}
}
}
}
}
Rectangle { height: 22px; }
// The button and the line about what pressing it does to the disk:
// side by side where there is room, the button across the width
// and the line under it on a phone, where a pill a thumb can miss
// is a pill that will be missed.
if !root.narrow: HorizontalLayout {
spacing: 18px;
PillButton {
primary: true;
label: root.data.busy
? I18n.t("start.creating")
: I18n.t("start.create");
enabled: root.can-create;
clicked => { root.create(); }
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: I18n.t("start.projectFolderCreatedNow");
color: Theme.fg-dim;
font-size: Theme.fs-sm;
wrap: word-wrap;
}
}
}
if root.narrow: VerticalLayout {
spacing: 12px;
PillButton {
primary: true;
block: true;
label: root.data.busy
? I18n.t("start.creating")
: I18n.t("start.create");
enabled: root.can-create;
clicked => { root.create(); }
}
Text {
text: I18n.t("start.projectFolderCreatedNow");
color: Theme.fg-dim;
font-size: Theme.fs-sm;
horizontal-alignment: center;
wrap: word-wrap;
}
}
}
}