Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a trivial widget library #7288

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/bazel_build/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ bazel-bazel_build
bazel-bin
bazel-out
bazel-testlogs
launch.json
10 changes: 9 additions & 1 deletion examples/bazel_build/src/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ cargo_build_script(
srcs = ["build.rs"],
build_script_env = {
"SLINT_INDEX_FILE_PATH": "$(location slint/index.slint)",
"SLINT_WIDGET_LIBRARY_INDEX_PATH": "$(location //widget_library:index.slint)",
"SLINT_EMIT_DEBUG_INFO": "1",
},
crate_root = "build.rs",
data = [
"slint/index.slint",
"//widget_library",
"//widget_library:index.slint",
],
edition = "2021",
deps = [
"//widget_library:widget_library_utils",
"@crates//:slint-build",
],
)
Expand All @@ -26,10 +30,14 @@ rust_binary(
srcs = [
"main.rs",
],
data = ["//widget_library"],
rustc_env = {
"WIDGET_LIBRARY_PACKAGE_PATH": "$${pwd}/widget_library",
},
crate_root = "main.rs",
deps = [
"@crates//:slint",
":ui_builder",
"@crates//:slint",
"@crates//:slint-build",
],
)
4 changes: 4 additions & 0 deletions examples/bazel_build/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
use std::collections::HashMap;
use std::path::PathBuf;

use widget_library_utils::WIDGET_LIBRARY_NAME;

fn main() {
let mut library_paths = HashMap::new();
let ui_lib_path = PathBuf::from(std::env::var_os("SLINT_WIDGET_LIBRARY_INDEX_PATH").unwrap());
library_paths.insert(WIDGET_LIBRARY_NAME.to_string(), ui_lib_path);

slint_build::compile_with_config(
std::env::var_os("SLINT_INDEX_FILE_PATH").unwrap(),
Expand Down
10 changes: 9 additions & 1 deletion examples/bazel_build/src/slint/index.slint
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
// Copyright © 2024 OTIV B.V.
// SPDX-License-Identifier: MIT

import {Icons} from "@initech_widgets";
export component BazelBuildExampleWindow inherits Window {
background: black;

VerticalLayout {
Image {
source: Icons.bazel-logo;
}
Text {
text: "Bazel Build Example";
font_size: 200px;
font_size: 100px;
color: white;
}

}

}
18 changes: 18 additions & 0 deletions examples/bazel_build/widget_library/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright © SixtyFPS GmbH <[email protected]>
# SPDX-License-Identifier: MIT

load("@rules_rust//rust:defs.bzl", "rust_library")

exports_files(["index.slint"] + glob(["assets/**/*"]))

filegroup(
name = "widget_library",
srcs = glob(["assets/**/*"]) + glob(["**/*.slint"]),
visibility = ["//visibility:public"],
)

rust_library(
name = "widget_library_utils",
srcs = ["lib.rs"],
visibility = ["//visibility:public"],
)
11 changes: 11 additions & 0 deletions examples/bazel_build/widget_library/assets/images/Bazel_logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions examples/bazel_build/widget_library/index.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT

export { Icons } from "styling.slint";
4 changes: 4 additions & 0 deletions examples/bazel_build/widget_library/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT

pub const WIDGET_LIBRARY_NAME: &str = "initech_widgets";
6 changes: 6 additions & 0 deletions examples/bazel_build/widget_library/styling.slint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright © SixtyFPS GmbH <[email protected]>
// SPDX-License-Identifier: MIT

export global Icons {
out property <image> bazel-logo: @image-url("assets/images/Bazel_logo.svg"); // From Wikipedia, in public domain
}
Loading