Initial commit
This commit is contained in:
commit
8cec608e21
8 changed files with 137 additions and 0 deletions
12
.cargo/config.toml
Normal file
12
.cargo/config.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[target.x86_64-pc-windows-msvc]
|
||||
# Increase default stack size to avoid running out of stack
|
||||
# space in debug builds. The size matches Linux's default.
|
||||
rustflags = [
|
||||
"-C", "link-arg=/STACK:8000000"
|
||||
]
|
||||
[target.aarch64-pc-windows-msvc]
|
||||
# Increase default stack size to avoid running out of stack
|
||||
# space in debug builds. The size matches Linux's default.
|
||||
rustflags = [
|
||||
"-C", "link-arg=/STACK:8000000"
|
||||
]
|
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Alternative VCS systems
|
||||
/.jj/
|
||||
/.hg/
|
||||
/.pijul/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "aliveline"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
slint = "1.12.1"
|
||||
|
||||
[build-dependencies]
|
||||
slint-build = "1.12.1"
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) <year> <copyright holders>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
38
README.md
Normal file
38
README.md
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Slint Rust Template
|
||||
|
||||
A template for a Rust application that's using [Slint](https://slint.rs/) for the user interface.
|
||||
|
||||
## About
|
||||
|
||||
This template helps you get started developing a Rust application with Slint as toolkit
|
||||
for the user interface. It demonstrates the integration between the `.slint` UI markup and
|
||||
Rust code, how to react to callbacks, get and set properties, and use basic widgets.
|
||||
|
||||
## Usage
|
||||
|
||||
1. Install Rust by following its [getting-started guide](https://www.rust-lang.org/learn/get-started).
|
||||
Once this is done, you should have the `rustc` compiler and the `cargo` build system installed in your `PATH`.
|
||||
2. Download and extract the [ZIP archive of this repository](https://github.com/slint-ui/slint-rust-template/archive/refs/heads/main.zip).
|
||||
3. Rename the extracted directory and change into it:
|
||||
```
|
||||
mv slint-rust-template-main my-project
|
||||
cd my-project
|
||||
```
|
||||
4. Build with `cargo`:
|
||||
```
|
||||
cargo build
|
||||
```
|
||||
5. Run the application binary:
|
||||
```
|
||||
cargo run
|
||||
```
|
||||
|
||||
We recommend using an IDE for development, along with our [LSP-based IDE integration for `.slint` files](https://github.com/slint-ui/slint/blob/master/tools/lsp/README.md). You can also load this project directly in [Visual Studio Code](https://code.visualstudio.com) and install our [Slint extension](https://marketplace.visualstudio.com/items?itemName=Slint.slint).
|
||||
|
||||
## Next Steps
|
||||
|
||||
We hope that this template helps you get started, and that you enjoy exploring making user interfaces with Slint. To learn more
|
||||
about the Slint APIs and the `.slint` markup language, check out our [online documentation](https://slint.dev/docs).
|
||||
|
||||
Don't forget to edit this readme to replace it by yours, and edit the `name =` field in `Cargo.toml` to match the name of your
|
||||
project.
|
3
build.rs
Normal file
3
build.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
fn main() {
|
||||
slint_build::compile("ui/app-window.slint").expect("Slint build failed");
|
||||
}
|
22
src/main.rs
Normal file
22
src/main.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Prevent console window in addition to Slint window in Windows release builds when, e.g., starting the app via file manager. Ignored on other platforms.
|
||||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
||||
|
||||
use std::error::Error;
|
||||
|
||||
slint::include_modules!();
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let ui = AppWindow::new()?;
|
||||
|
||||
ui.on_request_increase_value({
|
||||
let ui_handle = ui.as_weak();
|
||||
move || {
|
||||
let ui = ui_handle.unwrap();
|
||||
ui.set_counter(ui.get_counter() + 1);
|
||||
}
|
||||
});
|
||||
|
||||
ui.run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
18
ui/app-window.slint
Normal file
18
ui/app-window.slint
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { Button, VerticalBox } from "std-widgets.slint";
|
||||
|
||||
export component AppWindow inherits Window {
|
||||
in-out property <int> counter: 42;
|
||||
callback request-increase-value();
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: "Counter: \{root.counter}";
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Increase value";
|
||||
clicked => {
|
||||
root.request-increase-value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue