slint/examples/servo/ui/app.slint

77 lines
1.8 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint.dev>
// SPDX-License-Identifier: MIT
import {
VerticalBox,
HorizontalBox,
Button,
LineEdit,
} from "std-widgets.slint";
import { Webview } from "../src/webview/webview.slint";
export { WebviewLogic } from "../src/webview/webview.slint";
export { Palette } from "std-widgets.slint";
export component MyApp inherits Window {
preferred-width: 1224px;
preferred-height: 768px;
VerticalBox {
padding-left: root.safe-area-inset-left;
padding-top: root.safe-area-inset-top;
padding-right: root.safe-area-inset-right;
padding-bottom: root.safe-area-inset-bottom;
HorizontalBox {
height: 50px;
padding: 8px;
spacing: 8px;
Button {
text: "Back";
clicked => {
webview.back();
}
}
Button {
text: "Forward";
clicked => {
webview.forward();
}
}
Button {
text: "Reload";
clicked => {
webview.reload();
}
}
lineEdit := LineEdit {
text: webview.current_url;
horizontal-stretch: 1;
accepted(url) => {
webview.loadUrl(lineEdit.text);
}
}
Button {
text: "Go";
clicked => {
webview.loadUrl(lineEdit.text);
}
}
}
Rectangle {
webview := Webview {
width: 100%;
height: 100%;
changed current_url => {
lineEdit.text = self.current_url;
}
}
}
}
}