mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Dummy structure for the rust example
This commit is contained in:
parent
f3deea066b
commit
dc33cbbcda
7 changed files with 72 additions and 10 deletions
|
@ -5,6 +5,8 @@ members = [
|
|||
'sixtyfps_compiler',
|
||||
'sixtyfps_compiler/parser_test_macro',
|
||||
'api/sixtyfps-rs',
|
||||
'api/sixtyfps-rs/sixtyfps-rs-macro',
|
||||
'examples/graphicstest',
|
||||
'examples/rusttest',
|
||||
'helper_crates/const-field-offset',
|
||||
]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "sixtyfps-rs"
|
||||
name = "sixtyfps"
|
||||
version = "0.1.0"
|
||||
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||
edition = "2018"
|
||||
|
@ -7,6 +7,5 @@ edition = "2018"
|
|||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
sixtyfps-rs-macro= { path = "sixtyfps-rs-macro" }
|
||||
|
|
|
@ -1,7 +1 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
assert_eq!(2 + 2, 4);
|
||||
}
|
||||
}
|
||||
pub use sixtyfps_rs_macro::sixtyfps;
|
||||
|
|
13
api/sixtyfps-rs/sixtyfps-rs-macro/Cargo.toml
Normal file
13
api/sixtyfps-rs/sixtyfps-rs-macro/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "sixtyfps-rs-macro"
|
||||
version = "0.1.0"
|
||||
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
quote = "1.0"
|
||||
|
18
api/sixtyfps-rs/sixtyfps-rs-macro/lib.rs
Normal file
18
api/sixtyfps-rs/sixtyfps-rs-macro/lib.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
extern crate proc_macro;
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
|
||||
#[proc_macro]
|
||||
pub fn sixtyfps(_item: TokenStream) -> TokenStream {
|
||||
quote!(
|
||||
#[derive(Default)]
|
||||
struct SuperSimple;
|
||||
impl SuperSimple {
|
||||
fn run(&self) {
|
||||
println!("Hello world");
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
.into()
|
||||
}
|
8
examples/rusttest/Cargo.toml
Normal file
8
examples/rusttest/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "rusttest"
|
||||
version = "0.1.0"
|
||||
authors = ["Sixty FPS <info@sixtyfps.io>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
sixtyfps = { path = "../../api/sixtyfps-rs" }
|
28
examples/rusttest/src/main.rs
Normal file
28
examples/rusttest/src/main.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Using a macro for now. But there could be others ways to do that
|
||||
sixtyfps::sixtyfps! {
|
||||
SuperSimple = Rectangle {
|
||||
color: white;
|
||||
|
||||
Rectangle {
|
||||
width: 100;
|
||||
height: 100;
|
||||
color: blue;
|
||||
}
|
||||
Rectangle {
|
||||
x: 100;
|
||||
y: 100;
|
||||
width: (100);
|
||||
height: {100}
|
||||
color: green;
|
||||
}
|
||||
Image {
|
||||
x: 200;
|
||||
y: 200;
|
||||
source: "../graphicstest/logo.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
SuperSimple.run();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue