add file dialog for selecting output path

This commit is contained in:
Crispy 2023-07-13 22:15:01 +02:00
parent bbfb3e053c
commit 723d875d95
3 changed files with 135 additions and 13 deletions

133
Cargo.lock generated
View file

@ -167,6 +167,12 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "ascii"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d92bec98840b8f03a5ff5413de5293bfcd8bf96467cf5452609f939ec6f5de16"
[[package]]
name = "async-broadcast"
version = "0.5.1"
@ -621,6 +627,12 @@ dependencies = [
"typenum",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "derivative"
version = "2.2.0"
@ -642,6 +654,27 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"dirs-sys-next",
]
[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d"
dependencies = [
"libc",
"redox_users",
"winapi",
]
[[package]]
name = "dispatch"
version = "0.2.0"
@ -691,7 +724,7 @@ dependencies = [
"log",
"objc",
"percent-encoding",
"raw-window-handle",
"raw-window-handle 0.5.2",
"thiserror",
"wasm-bindgen",
"wasm-bindgen-futures",
@ -724,7 +757,7 @@ dependencies = [
"egui",
"instant",
"log",
"raw-window-handle",
"raw-window-handle 0.5.2",
"smithay-clipboard",
"webbrowser",
"winit",
@ -745,6 +778,12 @@ dependencies = [
"web-sys",
]
[[package]]
name = "either"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "emath"
version = "0.22.0"
@ -1013,7 +1052,7 @@ dependencies = [
"libloading 0.7.4",
"objc2",
"once_cell",
"raw-window-handle",
"raw-window-handle 0.5.2",
"wayland-sys 0.30.1",
"windows-sys 0.45.0",
"x11-dl",
@ -1027,7 +1066,7 @@ checksum = "629a873fc04062830bfe8f97c03773bcd7b371e23bcc465d0a61448cd1588fa4"
dependencies = [
"cfg_aliases",
"glutin",
"raw-window-handle",
"raw-window-handle 0.5.2",
"winit",
]
@ -1190,6 +1229,7 @@ version = "0.1.0"
dependencies = [
"eframe",
"image",
"native-dialog",
]
[[package]]
@ -1322,6 +1362,27 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "native-dialog"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1bbf55edb2747e4e4b3a9cd3989194b88aae32274b4422635dcf98aa6e84197b"
dependencies = [
"ascii",
"block",
"cocoa",
"dirs-next",
"objc",
"objc-foundation",
"objc_id",
"once_cell",
"raw-window-handle 0.4.3",
"thiserror",
"wfd",
"which",
"winapi",
]
[[package]]
name = "ndk"
version = "0.7.0"
@ -1332,7 +1393,7 @@ dependencies = [
"jni-sys",
"ndk-sys",
"num_enum 0.5.11",
"raw-window-handle",
"raw-window-handle 0.5.2",
"thiserror",
]
@ -1544,7 +1605,7 @@ version = "0.3.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "221d488cd70617f1bd599ed8ceb659df2147d9393717954d82a0f5e8032a6ab1"
dependencies = [
"redox_syscall",
"redox_syscall 0.3.5",
]
[[package]]
@ -1590,7 +1651,7 @@ checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"redox_syscall 0.3.5",
"smallvec",
"windows-targets 0.48.1",
]
@ -1718,12 +1779,30 @@ dependencies = [
"getrandom",
]
[[package]]
name = "raw-window-handle"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
[[package]]
name = "raw-window-handle"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
[[package]]
name = "redox_syscall"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a"
dependencies = [
"bitflags",
]
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -1733,6 +1812,17 @@ dependencies = [
"bitflags",
]
[[package]]
name = "redox_users"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
dependencies = [
"getrandom",
"redox_syscall 0.2.16",
"thiserror",
]
[[package]]
name = "regex"
version = "1.9.1"
@ -1989,7 +2079,7 @@ dependencies = [
"autocfg",
"cfg-if",
"fastrand",
"redox_syscall",
"redox_syscall 0.3.5",
"rustix",
"windows-sys 0.48.0",
]
@ -2364,11 +2454,32 @@ dependencies = [
"log",
"ndk-context",
"objc",
"raw-window-handle",
"raw-window-handle 0.5.2",
"url",
"web-sys",
]
[[package]]
name = "wfd"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e713040b67aae5bf1a0ae3e1ebba8cc29ab2b90da9aa1bff6e09031a8a41d7a8"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "which"
version = "4.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2441c784c52b289a054b7201fc93253e288f094e2f4be9058343127c4226a269"
dependencies = [
"either",
"libc",
"once_cell",
]
[[package]]
name = "winapi"
version = "0.3.9"
@ -2595,8 +2706,8 @@ dependencies = [
"once_cell",
"orbclient",
"percent-encoding",
"raw-window-handle",
"redox_syscall",
"raw-window-handle 0.5.2",
"redox_syscall 0.3.5",
"sctk-adwaita",
"smithay-client-toolkit",
"wasm-bindgen",

View file

@ -8,6 +8,7 @@ edition = "2021"
[dependencies]
eframe = "0.22.0"
image = { version = "0.24.6", default_features = false, features = ["png"] }
native-dialog = "0.6.4"
# Enable high optimizations for dependencies
[profile.dev.package."*"]

View file

@ -8,6 +8,7 @@ use eframe::{
};
use generate::{render, FillStyle, RenderOptions};
use image::EncodableLayout;
use native_dialog::FileDialog;
mod generate;
@ -171,8 +172,17 @@ impl eframe::App for JuliaGUI {
self.export_res_multiplier * self.render_options.height
));
let render_button = ui.button(format!("Render to '{}'", &self.export_name));
if render_button.clicked() {
if ui.button("Select file").clicked() {
if let Ok(Some(path)) = FileDialog::new()
.set_filename(&self.export_name)
.add_filter("PNG file", &["png"])
.show_save_single_file()
{
self.export_name = path.to_string_lossy().to_string();
}
}
ui.label(format!("selected path: {}", &self.export_name));
if ui.button("Render").clicked() {
self.export_render();
}
ui.label(format!(