mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-29 05:14:48 +00:00
156 lines
4.8 KiB
Text
156 lines
4.8 KiB
Text
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
|
|
|
|
import { DemoPalette, Page } from "common.slint";
|
|
import { HomePage } from "./home_page.slint";
|
|
import { InkLevel, InkPage } from "./ink_page.slint";
|
|
import { SettingsPage } from "./settings_page.slint";
|
|
import { PrinterQueue } from "./printer_queue.slint";
|
|
|
|
// re-export for the native code
|
|
export { PrinterQueue }
|
|
|
|
import "./fonts/NotoSans-Regular.ttf";
|
|
import "./fonts/NotoSans-Bold.ttf";
|
|
|
|
SideBarIcon := Rectangle {
|
|
property <bool> active;
|
|
callback activate;
|
|
TouchArea {
|
|
clicked => { root.activate(); }
|
|
}
|
|
}
|
|
|
|
MainWindow := Window {
|
|
callback quit();
|
|
|
|
width: 320px;
|
|
height: 240px;
|
|
title: "Slint printer demo";
|
|
background: DemoPalette.main-background;
|
|
default-font-family: "Noto Sans";
|
|
default-font-size: DemoPalette.base-font-size;
|
|
|
|
/// Note that this property is overwriten in the .cpp and .rs code.
|
|
/// The data is only in this file so it looks good in the viewer
|
|
property <[InkLevel]> ink-levels: [
|
|
{color: #0ff, level: 60%},
|
|
{color: #ff0, level: 80%},
|
|
{color: #f0f, level: 70%},
|
|
{color: #000, level: 30%},
|
|
];
|
|
|
|
property<int> active-page: 0;
|
|
|
|
main-view := Rectangle {
|
|
property <length> margin: 5px;
|
|
x: sidebar.x + sidebar.width;
|
|
y: margin;
|
|
height: parent.height - margin * 2;
|
|
width: parent.width - x - margin;
|
|
border-radius: 15px;
|
|
background: DemoPalette.page-background-color;
|
|
|
|
Rectangle {
|
|
clip: true;
|
|
x: main-view.border-radius / 2;
|
|
y: main-view.border-radius / 2;
|
|
width: main-view.width - main-view.border-radius;
|
|
height: main-view.height - main-view.border-radius;
|
|
|
|
home-page := HomePage {
|
|
y: active-page == 0 ? 0 : active-page > 0 ? - height - 1px : parent.height + 1px;
|
|
//animate y { duration: 125ms; easing: ease; }
|
|
}
|
|
SettingsPage {
|
|
y: active-page == 1 ? 0 : active-page > 1 ? - height - 1px : parent.height + 1px;
|
|
//animate y { duration: 125ms; easing: ease; }
|
|
}
|
|
InkPage {
|
|
y: active-page == 2 ? 0 : active-page > 2 ? - height - 1px : parent.height + 1px;
|
|
//animate y { duration: 125ms; easing: ease; }
|
|
ink-levels <=> root.ink-levels;
|
|
page-visible: active-page == 2;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
sidebar := Rectangle {
|
|
width: 48px;
|
|
x: 5px;
|
|
|
|
callback icon-y(int) -> length;
|
|
icon-y(index) => {
|
|
return 34px // top padding
|
|
+ index * 50px;
|
|
}
|
|
|
|
Image {
|
|
source: @image-url("images/page_selection.svg");
|
|
y: sidebar.icon-y(root.active-page) - 25px;
|
|
animate y {
|
|
duration: 125ms;
|
|
}
|
|
width: parent.width + 1px;
|
|
height: 1.77 * self.width;
|
|
colorize: DemoPalette.page-background-color;
|
|
}
|
|
|
|
for page-icon[idx] in [
|
|
@image-url("images/home.svg"),
|
|
@image-url("images/settings.svg"),
|
|
@image-url("images/ink.svg"),
|
|
] : SideBarIcon {
|
|
y: sidebar.icon-y(idx);
|
|
x: (parent.width - width) / 2;
|
|
height: 30px;
|
|
width: 30px;
|
|
|
|
icon := Image {
|
|
colorize: (root.active-page == idx) ? DemoPalette.active-page-icon-color : DemoPalette.inactive-page-icon-color;
|
|
animate colorize {
|
|
duration: 125ms;
|
|
}
|
|
source: page-icon;
|
|
image-fit: contain;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
activate => {
|
|
home-page.current-subpage = 0;
|
|
root.active-page = idx;
|
|
}
|
|
}
|
|
|
|
Rectangle {
|
|
y: sidebar.icon-y(3) ;
|
|
x: (parent.width - width) / 2;
|
|
background: #6284FF;
|
|
height: 2px;
|
|
width: 37px;
|
|
}
|
|
|
|
SideBarIcon {
|
|
//y: sidebar.icon-y(3) + 10px;
|
|
y: parent.height - height - main-view.margin * 2;
|
|
x: (parent.width - width) / 2;
|
|
height: 27px;
|
|
width: 27px;
|
|
|
|
Image {
|
|
colorize: DemoPalette.night-mode ? #F1FF98 : DemoPalette.inactive-page-icon-color;
|
|
source: DemoPalette.night-mode ? @image-url("images/moon_full.svg") : @image-url("images/moon.svg");
|
|
image-fit: contain;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
activate => {
|
|
DemoPalette.night-mode = !DemoPalette.night-mode;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|