-
Notifications
You must be signed in to change notification settings - Fork 631
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
material: base setup components import #6497
base: feature/material
Are you sure you want to change the base?
Changes from 1 commit
aa00ea8
dbe1194
d01aa45
c653ba8
51350e1
64f7e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright © SixtyFPS GmbH <[email protected]> | ||
# SPDX-License-Identifier: MIT | ||
|
||
[package] | ||
name = "material-gallery" | ||
version = "1.9.0" | ||
authors = ["Slint Developers <[email protected]>"] | ||
edition = "2021" | ||
build = "build.rs" | ||
license = "MIT" | ||
publish = false | ||
description = "Slint Widgets Gallery Example" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe "Slint Material Widgets Gallery Example"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sure |
||
|
||
[[bin]] | ||
path = "src/main.rs" | ||
name = "material-gallery" | ||
|
||
[dependencies] | ||
slint = { path = "../../api/rs/slint" } | ||
|
||
# Disable gettext on macOS due to https://github.com/Koka/gettext-rs/issues/114 | ||
[target.'cfg(not(target_os = "macos"))'.dependencies] | ||
slint = { path = "../../api/rs/slint", features=["gettext"] } | ||
|
||
[build-dependencies] | ||
slint-build = { path = "../../api/rs/build" } | ||
|
||
# Remove the `#wasm#` to uncomment the wasm build. | ||
# This is commented out by default because we don't want to build it as a library by default | ||
# The CI has a script that does sed "s/#wasm# //" to generate the wasm build. | ||
|
||
#wasm# [lib] | ||
#wasm# crate-type = ["cdylib"] | ||
#wasm# path = "main.rs" | ||
#wasm# | ||
#wasm# [target.'cfg(target_arch = "wasm32")'.dependencies] | ||
#wasm# wasm-bindgen = { version = "0.2" } | ||
#wasm# web-sys = { version = "0.3", features=["console"] } | ||
#wasm# console_error_panic_hook = "0.1.5" | ||
|
||
[package.metadata.bundle] | ||
identifier = "com.slint.examples.material-gallery" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
fn main() { | ||
slint_build::compile("ui/index.slint").unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK I will change it. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#[cfg(target_arch = "wasm32")] | ||
use wasm_bindgen::prelude::*; | ||
|
||
slint::include_modules!(); | ||
|
||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen(start))] | ||
pub fn main() { | ||
// This provides better error messages in debug mode. | ||
// It's disabled in release mode so it doesn't bloat up the file size. | ||
#[cfg(all(debug_assertions, target_arch = "wasm32"))] | ||
console_error_panic_hook::set_once(); | ||
|
||
MaterialGallery::new().unwrap().run().unwrap(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: MIT | ||
|
||
import { FilledButton } from "@slint/material.slint"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can bike shed about this later, but I think we should offer a library as full encapsulated (so I'd go with something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought of |
||
|
||
export component MaterialGallery inherits Window { | ||
preferred-width: 600px; | ||
preferred-height: 400px; | ||
|
||
FilledButton { } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,11 @@ fn widget_library() -> &'static [(&'static str, &'static BuiltinDirectory<'stati | |
|
||
println!("cargo:rustc-env=SLINT_WIDGETS_LIBRARY={}", output_file_path.display()); | ||
|
||
let mut slint_dir = PathBuf::from(std::env::var_os("CARGO_MANIFEST_DIR").unwrap()); | ||
slint_dir.push("components"); | ||
Comment on lines
+45
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's an issue with this, which is that it doesn't work when the slint-compiler is used from Node.js, C++, or WASM, or the LSP. In those cases the directory doesn't exist like that anymore. That's why the compiler ships the widgets built-in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes true. OK then I need to handle this like the std-widgets |
||
|
||
println!("cargo:rustc-env=SLINT_COMPONENTS_LIBRARY={}", slint_dir.display()); | ||
|
||
Ok(()) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
export { ButtonBase } from "headless/button-base.slint"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
export component ButtonBase { | ||
callback clicked <=> touch-area.clicked; | ||
|
||
touch-area := TouchArea {} | ||
|
||
@children | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
export { FilledButton } from "material/filled-button.slint"; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Copyright © SixtyFPS GmbH <[email protected]> | ||
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 | ||
|
||
import { ButtonBase } from "@slint/headless.slint"; | ||
|
||
export component FilledButton inherits ButtonBase { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to change the default really? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ups, thanks