Init of the game resource viewer
This commit is contained in:
		
							
								
								
									
										11
									
								
								resource-viewer/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								resource-viewer/Cargo.toml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
[package]
 | 
			
		||||
name = "resource-viewer"
 | 
			
		||||
version = "0.1.0"
 | 
			
		||||
edition = "2021"
 | 
			
		||||
build = "build.rs"
 | 
			
		||||
 | 
			
		||||
[dependencies]
 | 
			
		||||
slint = "1.0"
 | 
			
		||||
 | 
			
		||||
[build-dependencies]
 | 
			
		||||
slint-build = "1.0"
 | 
			
		||||
							
								
								
									
										3
									
								
								resource-viewer/build.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								resource-viewer/build.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,3 @@
 | 
			
		||||
fn main() {
 | 
			
		||||
    slint_build::compile("ui/appwindow.slint").unwrap();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										13
									
								
								resource-viewer/src/main.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								resource-viewer/src/main.rs
									
									
									
									
									
										Normal file
									
								
							@@ -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()
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										17
									
								
								resource-viewer/ui/appwindow.slint
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								resource-viewer/ui/appwindow.slint
									
									
									
									
									
										Normal file
									
								
							@@ -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();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user