slint/examples/printerdemo/ui/home_page.slint
Tobias Hunger 4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +01:00

101 lines
3.2 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
import { DemoPalette, Page, PushButton } from "./common.slint";
import { CopyPage } from "./copy_page.slint";
import { ScanPage } from "./scan_page.slint";
import { PrintPage } from "./print_page.slint";
import { PrinterQueueView } from "./printer_queue.slint";
import { UsbPage } from "./usb_page.slint";
ActionButton := Rectangle {
property <image> icon <=> img.source;
property <string> text <=> label.text;
callback clicked;
VerticalLayout {
spacing: 4px;
Rectangle {
border-radius: 25px;
border-width: 5px;
border-color: DemoPalette.control-outline-color;
background: DemoPalette.printer-action-background-color;
img := Image {
x: (parent.width / 2) - (self.width / 2);
y: (parent.height / 2) - (self.height / 2);
colorize: DemoPalette.text-foreground-color;
}
}
label := Text {
font-size: DemoPalette.base-font-size * 1.375;
font-weight: 800;
horizontal-alignment: center;
color: DemoPalette.text-foreground-color;
}
}
TouchArea { clicked => { root.clicked() } }
}
export HomePage := Page {
property <length> header-row-height: 40px;
property <length> button-spacing: 35px;
property <length> button-width: 127px;
property <length> button-height: button-width + 37px;
header: "Xerol 1347 hdp";
property <int> current-subpage: 0;
for action[idx] in [
{ name: "Print", icon: @image-url("images/print.svg") },
{ name: "Scan", icon: @image-url("images/scan.svg") },
{ name: "Copy", icon: @image-url("images/copy.svg") },
{ name: "USB", icon: @image-url("images/usb.svg") },
]: ActionButton {
x: mod(idx, 2) * (button-width + button-spacing);
y: floor(idx / 2) * (button-height + button-spacing)
+ /* header row height */ 46px
+ /* top-padding of printer queue */ 27px; // align with the first item of the printer queue
width: button-width;
height: button-height;
icon: action.icon;
text: action.name;
clicked => { current-subpage = idx + 1; }
}
queue-view := PrinterQueueView {
x: parent.width - width;
width: 313px;
show-job-details(idx) => {
current-subpage = 1; // Not nice to hard-code the index here...
}
}
PrintPage {
x: current-subpage == 1 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current-subpage = 0 }
}
ScanPage {
x: current-subpage == 2 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current-subpage = 0 }
}
CopyPage {
x: current-subpage == 3 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current-subpage = 0 }
}
UsbPage {
x: current-subpage == 4 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current-subpage = 0 }
}
}