211 lines
7.9 KiB
Plaintext
211 lines
7.9 KiB
Plaintext
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: 18px * 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: 14px * 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;
|
|
// Scale by the shorter screen edge so 1080p and 4K displays remain readable.
|
|
private property <float> ui-scale: clamp(min(root.width / 800px, 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: 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.countdown > 0: Rectangle {
|
|
x: (root.width - self.width) / 2;
|
|
y: (root.height - self.height) / 2;
|
|
width: min(420px * root.ui-scale, root.width - root.inset * 2);
|
|
height: 340px * root.ui-scale;
|
|
border-radius: 32px * root.ui-scale;
|
|
background: #fffffff0;
|
|
VerticalLayout {
|
|
padding: 24px * root.ui-scale;
|
|
spacing: 8px * root.ui-scale;
|
|
Text {
|
|
text: root.countdown;
|
|
color: #20302b;
|
|
font-size: 180px * root.ui-scale;
|
|
font-weight: 700;
|
|
horizontal-alignment: center;
|
|
vertical-alignment: center;
|
|
}
|
|
Text {
|
|
text: "Bitte in die Kamera schauen.";
|
|
color: #20302b;
|
|
font-size: 18px * root.ui-scale;
|
|
font-weight: 600;
|
|
horizontal-alignment: center;
|
|
wrap: word-wrap;
|
|
}
|
|
Text {
|
|
text: "Please look at the camera.";
|
|
color: #52635d;
|
|
font-size: 14px * root.ui-scale;
|
|
horizontal-alignment: center;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
}
|
|
|
|
if root.awaiting-release: Rectangle {
|
|
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: 18px * 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: 14px * root.ui-scale;
|
|
color: #52635d;
|
|
horizontal-alignment: center;
|
|
wrap: word-wrap;
|
|
}
|
|
}
|
|
}
|