-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 946684a
Showing
8 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
/target/ | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"rust-lang.rust-analyzer", | ||
"vadimcn.vscode-lldb", | ||
"Slint.slint" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "{{project-name}}" | ||
version = "0.1.0" | ||
authors = ["{{authors}}"] | ||
edition = "2021" | ||
build = "build.rs" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
slint = "1.0" | ||
|
||
[build-dependencies] | ||
slint-build = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# 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 trigger react to callbacks, get and set properties and use basic widgets. | ||
|
||
## Usage | ||
|
||
1. Install Rust by following the [Rust 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. Install [`cargo-generate`](https://github.com/cargo-generate/cargo-generate) | ||
``` | ||
cargo install cargo-generate | ||
``` | ||
3. Set up a sample project with this template | ||
``` | ||
cargo generate --git https://github.com/slint-ui/slint-rust-template --name my-project | ||
cd my-project | ||
``` | ||
3. Build with cargo | ||
``` | ||
cargo build | ||
``` | ||
4. 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 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
slint_build::compile("ui/appwindow.slint").unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
slint::include_modules!(); | ||
|
||
fn main() -> Result<(), slint::PlatformError> { | ||
let ui = AppWindow::new()?; | ||
|
||
let ui_handle = ui.as_weak(); | ||
ui.on_request_increase_value(move || { | ||
let ui = ui_handle.unwrap(); | ||
ui.set_counter(ui.get_counter() + 1); | ||
}); | ||
|
||
ui.run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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(); | ||
} | ||
} | ||
} | ||
} |