Files
winf-photobooth-app/ui/app-window.slint

254 lines
10 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
component Instruction inherits Rectangle {
in property <float> ui-scale: 1;
in property <string> number;
in property <string> german;
in property <string> english;
in property <color> accent;
in property <bool> active;
min-width: 0px;
preferred-width: 0px;
vertical-stretch: 0;
background: active ? root.accent.with-alpha(0.13) : #f5f7f8;
border-radius: 16px * root.ui-scale;
height: max(36px * root.ui-scale, german-text.height + 6px * root.ui-scale + english-text.height) + 36px * root.ui-scale;
Rectangle {
x: 18px * root.ui-scale;
y: 18px * root.ui-scale;
width: 36px * root.ui-scale;
height: 36px * root.ui-scale;
border-radius: 18px * root.ui-scale;
background: root.active ? root.accent : #e6ebed;
Text {
text: root.number;
color: #20302b;
font-size: 17px * root.ui-scale;
font-weight: 700;
horizontal-alignment: center;
vertical-alignment: center;
}
}
german-text := Text {
x: 68px * root.ui-scale;
y: 18px * root.ui-scale;
width: parent.width - 86px * root.ui-scale;
height: self.preferred-height;
text: root.german;
color: #20302b;
font-size: 20px * root.ui-scale;
font-weight: 600;
wrap: word-wrap;
}
english-text := Text {
x: german-text.x;
y: german-text.y + german-text.height + 6px * root.ui-scale;
width: german-text.width;
height: self.preferred-height;
text: root.english;
color: #52635d;
font-size: 15px * root.ui-scale;
wrap: word-wrap;
}
}
export component AppWindow inherits Window {
title: "winf photobooth";
background: #f6f8f5;
default-font-family: "DejaVu Sans";
in property <image> video-frame;
in property <bool> hand-detected: false;
in property <int> countdown: 0;
in property <float> flash-opacity: 0;
in property <bool> awaiting-release: false;
// Use width as well as height: a 1280×1024 (5:4) monitor should not
// enlarge the UI just because it is taller than a widescreen display.
private property <float> ui-scale: clamp(min(root.width / 1280px, root.height / 800px), 0.85, 2.5);
private property <color> primary: #84bf65;
private property <color> secondary: #4caee3;
private property <length> inset: 24px * root.ui-scale;
private property <bool> compact: root.width < 900px * root.ui-scale;
Image {
width: parent.width;
height: parent.height;
source: root.video-frame;
image-fit: cover;
}
Rectangle {
width: parent.width;
height: parent.height;
background: white;
opacity: root.flash-opacity;
}
header := Rectangle {
x: root.inset + root.safe-area-insets.left;
y: root.inset + root.safe-area-insets.top;
width: self.preferred-width;
height: self.preferred-height;
border-radius: 18px * root.ui-scale;
background: #fffffff5;
HorizontalLayout {
padding: 14px * root.ui-scale;
padding-right: 22px * root.ui-scale;
spacing: 12px * root.ui-scale;
Image {
source: @image-url("assets/winf-icon.png");
width: 44px * root.ui-scale;
height: 44px * root.ui-scale;
image-fit: contain;
}
Text {
text: "winf photobooth";
color: #20302b;
font-size: 24px * root.ui-scale;
font-weight: 600;
vertical-alignment: center;
}
}
}
// Wrap the text before sizing the panel, with consistent scaled padding.
panel := Rectangle {
// Keep layout alive while hidden so wrapped text does not reflow on return.
opacity: root.countdown == 0 && !root.awaiting-release ? 1 : 0;
x: root.safe-area-insets.left + (root.width - root.safe-area-insets.left - root.safe-area-insets.right - self.width) / 2;
y: root.height - self.height - root.inset - root.safe-area-insets.bottom;
width: min(1040px * root.ui-scale, root.width - root.inset * 2 - root.safe-area-insets.left - root.safe-area-insets.right);
height: root.compact ? first.height + second.height + 44px * root.ui-scale : max(first.height, second.height) + 32px * root.ui-scale;
border-radius: 22px * root.ui-scale;
background: #fffffff5;
first := Instruction {
ui-scale: root.ui-scale;
x: 16px * root.ui-scale;
y: 16px * root.ui-scale;
width: root.compact ? parent.width - 32px * root.ui-scale : (parent.width - 44px * root.ui-scale) / 2;
number: "1";
german: "Hebe deine offene Hand und zeige die Handfläche zur Kamera.";
english: "Raise your open hand with your palm facing the camera.";
accent: root.primary;
active: !root.hand-detected;
}
second := Instruction {
ui-scale: root.ui-scale;
x: root.compact ? 16px * root.ui-scale : first.x + first.width + 12px * root.ui-scale;
y: root.compact ? first.y + first.height + 12px * root.ui-scale : 16px * root.ui-scale;
width: first.width;
number: "2";
german: "Halte deine Hand ruhig, bis der Kreis vollständig gefüllt ist.";
english: "Keep your hand steady until the circle is completely filled.";
accent: root.secondary;
active: root.hand-detected;
}
}
if root.flash-opacity > 0: Rectangle {
// Keep the portrait below the central countdown and most of the
// monitor white so it continues to provide light for the photo.
width: min(360px * root.ui-scale, root.width * 0.65, root.height * 0.36);
height: self.width * 200 / 360 + 40px * root.ui-scale;
x: (root.width - self.width) / 2;
y: root.height - self.height - root.inset - root.safe-area-insets.bottom;
background: transparent;
pose-label := Text {
x: 0px;
y: 0px;
width: parent.width;
height: 32px * root.ui-scale;
text: "Pose!";
color: #20302b77;
font-size: 26px * root.ui-scale;
font-weight: 600;
horizontal-alignment: center;
vertical-alignment: center;
}
Image {
x: 0px;
y: pose-label.y + pose-label.height + 8px * root.ui-scale;
width: parent.width;
height: parent.height - self.y;
source: @image-url("assets/photo-pose.svg");
image-fit: contain;
}
}
if root.countdown > 0: Text {
width: root.width;
height: root.height;
text: root.countdown;
color: #20302b77;
font-size: min(240px * root.ui-scale, min(root.width * 0.6, root.height * 0.45));
font-weight: 700;
horizontal-alignment: center;
vertical-alignment: center;
}
Rectangle {
// Allocate and measure this prompt once, before the first countdown.
opacity: root.awaiting-release ? 1 : 0;
x: (root.width - self.width) / 2;
y: root.height - self.height - root.inset - root.safe-area-insets.bottom;
width: panel.width;
height: release-german.height + release-english.height + 6px * root.ui-scale + 36px * root.ui-scale;
background: #fffffff5;
border-radius: 22px * root.ui-scale;
release-german := Text {
x: 18px * root.ui-scale;
y: 18px * root.ui-scale;
width: parent.width - 36px * root.ui-scale;
height: self.preferred-height;
text: "Senke deine Hand, um einen neuen Countdown zu starten.";
font-size: 20px * root.ui-scale;
font-weight: 600;
color: #20302b;
horizontal-alignment: center;
wrap: word-wrap;
}
release-english := Text {
x: release-german.x;
y: release-german.y + release-german.height + 6px * root.ui-scale;
width: release-german.width;
height: self.preferred-height;
text: "Lower your hand to start a new countdown.";
font-size: 15px * root.ui-scale;
color: #52635d;
horizontal-alignment: center;
wrap: word-wrap;
}
}
// Sample a small Gaussian kernel behind the glyphs. This softens the
// shadow on Linux KMS's software renderer without a box or hard outline.
for row in [{offset: -2, weight: 0.06}, {offset: -1, weight: 0.24}, {offset: 0, weight: 0.40}, {offset: 1, weight: 0.24}, {offset: 2, weight: 0.06}]: Rectangle {
visible: root.flash-opacity == 0;
x: privacy-note.x;
y: privacy-note.y + (1px + row.offset * 1px) * root.ui-scale;
width: privacy-note.width;
height: privacy-note.height;
background: transparent;
for column in [{offset: -2, weight: 0.06}, {offset: -1, weight: 0.24}, {offset: 0, weight: 0.40}, {offset: 1, weight: 0.24}, {offset: 2, weight: 0.06}]: Text {
x: column.offset * 1px * root.ui-scale;
width: privacy-note.width;
height: privacy-note.height;
text: privacy-note.text;
font-size: privacy-note.font-size;
font-weight: privacy-note.font-weight;
color: black;
opacity: row.weight * column.weight * 0.9;
horizontal-alignment: right;
wrap: privacy-note.wrap;
}
}
privacy-note := Text {
x: root.width - root.inset - root.safe-area-insets.right - self.width;
y: root.compact ? header.y + header.height + 12px * root.ui-scale : header.y + 10px * root.ui-scale;
width: min(740px * root.ui-scale, root.width - root.inset * 2 - root.safe-area-insets.left - root.safe-area-insets.right - (root.compact ? 0px : header.width + 16px * root.ui-scale));
height: self.preferred-height;
text: "Bilder werden nie gespeichert und ausschließlich zum Drucken deines Fotos verarbeitet.\nImages are never stored and are processed only to print your photo.";
font-size: 13px * root.ui-scale;
font-weight: 500;
color: root.flash-opacity > 0 ? #20302b : white;
horizontal-alignment: right;
wrap: word-wrap;
}
}