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

202 lines
7.7 KiB
Plaintext
Raw 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 {
visible: root.countdown == 0 && !root.awaiting-release;
x: root.safe-area-insets.left + (root.width - root.safe-area-insets.left - root.safe-area-insets.right - self.width) / 2;
y: privacy-note.y - self.height - 12px * root.ui-scale;
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.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;
}
if root.awaiting-release: Rectangle {
x: (root.width - self.width) / 2;
y: privacy-note.y - self.height - 12px * root.ui-scale;
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;
}
}
privacy-note := Text {
x: panel.x;
y: root.height - self.height - root.inset - root.safe-area-insets.bottom;
width: panel.width;
height: self.preferred-height;
text: "Bilder werden nie gespeichert und ausschließlich zum Drucken eines Fotos verarbeitet.\nImages are never stored and are processed only to print a photo.";
font-size: 12px * root.ui-scale;
color: root.flash-opacity > 0 ? #20302b : #ffffffee;
stroke: root.flash-opacity > 0 ? transparent : #20302bb0;
stroke-width: 0.5px * root.ui-scale;
horizontal-alignment: center;
wrap: word-wrap;
}
}