mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 06:11:16 +00:00
88 lines
2.7 KiB
Text
88 lines
2.7 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 { PrinterQueueView } from "./printer_queue.slint";
|
|
|
|
ActionButton := Rectangle {
|
|
|
|
property <image> icon <=> img.source;
|
|
property <string> text <=> label.text;
|
|
callback clicked;
|
|
|
|
VerticalLayout {
|
|
spacing: 4px;
|
|
|
|
Rectangle {
|
|
border-radius: 12px;
|
|
border-width: 3px;
|
|
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);
|
|
width: self.source.width * 1px / 2;
|
|
height: self.source.height * 1px / 2;
|
|
colorize: DemoPalette.text-foreground-color;
|
|
}
|
|
}
|
|
|
|
label := Text {
|
|
font-size: DemoPalette.base-font-size * 1.2;
|
|
font-weight: 800;
|
|
horizontal-alignment: center;
|
|
color: DemoPalette.text-foreground-color;
|
|
}
|
|
}
|
|
|
|
TouchArea { clicked => { root.clicked() } }
|
|
}
|
|
|
|
export HomePage := Page {
|
|
property <length> header-row-height: 40px / 2;
|
|
|
|
property <length> button-spacing: 8px;
|
|
property <length> button-width: 127px / 2;
|
|
property <length> button-height: button-width + 20px;
|
|
|
|
header: "Printer";
|
|
|
|
property <int> current-subpage: 0;
|
|
|
|
|
|
for action[idx] in [
|
|
{ name: "Copy", icon: @image-url("images/copy.svg") },
|
|
{ name: "Scan", icon: @image-url("images/scan.svg") },
|
|
|
|
]: ActionButton {
|
|
x: mod(idx, 1) * (button-width + button-spacing) + button-spacing;
|
|
y: floor(idx / 1) * (button-height + button-spacing)
|
|
+ header-row-height
|
|
+ /* top-padding of printer queue */ 18px; // 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: button-width + button-spacing * 2;
|
|
width: parent.width - x;
|
|
}
|
|
|
|
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 == 1 ? 0 : parent.width + parent.x + 2px;
|
|
animate x { duration: 125ms; easing: ease; }
|
|
back => { current-subpage = 0 }
|
|
}
|
|
}
|