feat: add flash countdown and responsive photobooth overlays
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
component Instruction inherits Rectangle {
|
||||
in property <float> ui-scale: 1;
|
||||
in property <string> number;
|
||||
in property <string> german;
|
||||
in property <string> english;
|
||||
@@ -8,44 +9,44 @@ component Instruction inherits Rectangle {
|
||||
preferred-width: 0px;
|
||||
vertical-stretch: 0;
|
||||
background: active ? root.accent.with-alpha(0.13) : #f5f7f8;
|
||||
border-radius: 16px;
|
||||
border-radius: 16px * root.ui-scale;
|
||||
|
||||
height: max(36px, german-text.height + 6px + english-text.height) + 36px;
|
||||
height: max(36px * root.ui-scale, german-text.height + 6px * root.ui-scale + english-text.height) + 36px * root.ui-scale;
|
||||
Rectangle {
|
||||
x: 18px;
|
||||
y: 18px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 18px;
|
||||
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;
|
||||
font-size: 17px * root.ui-scale;
|
||||
font-weight: 700;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
german-text := Text {
|
||||
x: 68px;
|
||||
y: 18px;
|
||||
width: parent.width - 86px;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
font-size: 14px * root.ui-scale;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
@@ -56,10 +57,15 @@ export component AppWindow inherits Window {
|
||||
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: root.width < 700px ? 20px : 32px;
|
||||
private property <bool> compact: root.width < 800px;
|
||||
private property <length> inset: 24px * root.ui-scale;
|
||||
private property <bool> compact: root.width < 900px * root.ui-scale;
|
||||
|
||||
Image {
|
||||
width: parent.width;
|
||||
@@ -68,45 +74,54 @@ export component AppWindow inherits Window {
|
||||
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;
|
||||
border-radius: 18px * root.ui-scale;
|
||||
background: #fffffff5;
|
||||
HorizontalLayout {
|
||||
padding: 14px;
|
||||
padding-right: 22px;
|
||||
spacing: 12px;
|
||||
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;
|
||||
height: 44px;
|
||||
width: 44px * root.ui-scale;
|
||||
height: 44px * root.ui-scale;
|
||||
image-fit: contain;
|
||||
}
|
||||
Text {
|
||||
text: "winf photobooth";
|
||||
color: #20302b;
|
||||
font-size: root.width < 500px ? 20px : 24px;
|
||||
font-size: 24px * root.ui-scale;
|
||||
font-weight: 600;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap the text before sizing the panel so its bottom inset stays at 16px.
|
||||
// Wrap the text before sizing the panel, with consistent scaled padding.
|
||||
panel := Rectangle {
|
||||
x: root.inset + root.safe-area-insets.left;
|
||||
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: root.width - root.inset * 2 - root.safe-area-insets.left - root.safe-area-insets.right;
|
||||
height: root.compact ? first.height + second.height + 44px : max(first.height, second.height) + 32px;
|
||||
border-radius: 22px;
|
||||
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 {
|
||||
x: 16px;
|
||||
y: 16px;
|
||||
width: root.compact ? parent.width - 32px : (parent.width - 44px) / 2;
|
||||
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.";
|
||||
@@ -114,8 +129,9 @@ export component AppWindow inherits Window {
|
||||
active: !root.hand-detected;
|
||||
}
|
||||
second := Instruction {
|
||||
x: root.compact ? 16px : first.x + first.width + 12px;
|
||||
y: root.compact ? first.y + first.height + 12px : 16px;
|
||||
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.";
|
||||
@@ -124,4 +140,71 @@ export component AppWindow inherits Window {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user