-
Notifications
You must be signed in to change notification settings - Fork 543
/
home_page.60
119 lines (102 loc) · 3.98 KB
/
home_page.60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* LICENSE BEGIN
This file is part of the SixtyFPS Project -- https://sixtyfps.io
Copyright (c) 2021 Olivier Goffart <olivier.goffart@sixtyfps.io>
Copyright (c) 2021 Simon Hausmann <simon.hausmann@sixtyfps.io>
SPDX-License-Identifier: GPL-3.0-only
This file is also available under commercial licensing terms.
Please contact info@sixtyfps.io for more information.
LICENSE END */
import { DemoPalette, Page, PrinterQueueItem, PushButton } from "./common.60";
import { CopyPage } from "./copy_page.60";
import { ScanPage } from "./scan_page.60";
import { PrintPage } from "./print_page.60";
import { PrinterQueue } from "./printer_queue.60";
import { UsbPage } from "./usb_page.60";
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 {
callback start_job(string);
callback cancel_job(int);
callback pause_job(int);
property <length> header_row_height: 40px;
property <[PrinterQueueItem]> printer_queue;
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 := PrinterQueue {
x: parent.width - width;
width: 313px;
printer_queue: root.printer_queue;
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 }
printer_queue: root.printer_queue;
cancel_job(id) => { root.cancel_job(id); }
pause_job(id) => { root.pause_job(id); }
}
ScanPage {
x: current_subpage == 2 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current_subpage = 0 }
start_job(title) => { root.start_job(title); }
}
CopyPage {
x: current_subpage == 3 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current_subpage = 0 }
start_job(title) => { root.start_job(title); }
}
UsbPage {
x: current_subpage == 4 ? 0 : parent.width + parent.x + 2px;
animate x { duration: 125ms; easing: ease; }
back => { current_subpage = 0 }
start_job(title) => { root.start_job(title); }
}
}