Loading files
9d2aa90beThis file is pinned to the selected release. Download the original to open it in your design tool.
import "../../../../share/librepcb/fonts/NotoSans-Regular.ttf";
import "../../../../share/librepcb/fonts/NotoSansMono-Regular.ttf";
import { MainMenuBar } from "mainmenubar.slint";
import { SideBar } from "sidebar.slint";
import { HomePanel } from "homepanel.slint";
import { DocumentsPanel } from "documentspanel.slint";
import { GraphicsLayersPanel } from "graphicslayerspanel.slint";
import { PlaceDevicesPanel } from "project/placedevicespanel.slint";
import { RuleCheckPanel } from "rulecheckpanel.slint";
import { OrderPanel } from "project/orderpanel.slint";
import { LibrariesPanel } from "library/librariespanel.slint";
import { AboutPanel } from "aboutpanel.slint";
import { WindowSection } from "windowsection.slint";
import { StatusBar } from "statusbar.slint";
import {
Backend,
Data,
EditorCommandSet as Cmd,
FeatureState,
PanelPage,
Shortcuts,
} from "api.slint";
export { Backend, Data, Cmd as EditorCommandSet }
export component AppWindow inherits Window {
property <float> panel-width-factor: (Data.sections.length > 1) ? 0.25 : 0.3;
property <length> panel-width: min(self.width * panel-width-factor, 350px);
property <length> actual-panel-width: (Data.panel-page != PanelPage.none) ? panel-width : 0;
title: Data.window-title;
background: #2a2a2a;
icon: @image-url("../../../../img/app/librepcb.svg");
default-font-family: "Noto Sans";
preferred-width: 1024px;
preferred-height: 768px;
forward-focus: fs;
fs := FocusScope {
// This is an ugly hack to not make any undesired element having the
// focus after application startup. The preview-mode is true at the
// beginning, so this focus scope will be focused initially. But the
// property changes to false during application startup which seems
// to keep the focus here.
enabled: Data.preview-mode;
focus-on-tab-navigation: false;
key-pressed(event) => {
if Shortcuts.process(event) {
return accept;
} else if Shortcuts.is-shortcut(event, Cmd.find) && (Data.current-tab.features.find == FeatureState.enabled) {
menubar.focus-search();
return accept;
} else if Shortcuts.is-shortcut(event, Cmd.grid-properties) && (Data.current-tab.features.grid == FeatureState.enabled) {
statusbar.focus-grid-interval();
return accept;
}
reject
}
menubar := MainMenuBar {
x: 0;
y: 0;
z: 100; // For the tooltips.
width: 100%;
height: 26px;
sections-start-x: sidebar.width + actual-panel-width;
focus-root => {
fs.focus();
}
focus-grid-interval => {
statusbar.focus-grid-interval();
}
}
sidebar := SideBar {
x: 0px;
y: menubar.height;
z: 90; // For the tooltips.
width: ((root.width <= 1200px) || (root.height <= 600px)) ? 35px : 45px;
height: parent.height - self.y - statusbar.height - 1px;
}
if Data.panel-page == PanelPage.home: home-panel := HomePanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.documents: documents-panel := DocumentsPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.layers: GraphicsLayersPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.place-devices: PlaceDevicesPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.rule-check: RuleCheckPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.order: OrderPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.libraries: LibrariesPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
if Data.panel-page == PanelPage.about: AboutPanel {
x: sidebar.width;
y: sidebar.y;
z: 80; // For the tooltips.
width: panel-width;
height: sidebar.height;
}
HorizontalLayout {
x: sidebar.width + actual-panel-width;
y: sidebar.y + 1px;
width: parent.width - self.x;
height: sidebar.height - 1px;
if actual-panel-width > 0: Rectangle {
background: #555555;
width: 1px;
}
for section[i] in Data.sections: HorizontalLayout {
window-section := WindowSection {
section-index: i;
section: section;
}
if i < (Data.sections.length - 1): Rectangle {
width: 1px;
horizontal-stretch: 0;
background: #555555;
}
}
}
statusbar := StatusBar {
x: 0;
y: parent.height - self.height;
width: parent.width;
focus-root => {
fs.focus();
}
}
}
}