Open a file dialog when the user clicks on the open file
This commit is contained in:
parent
6afbafcb43
commit
92421943fc
|
@ -163,6 +163,7 @@ dependencies = [
|
|||
"euclid 0.19.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"jemallocator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"pathfinder_geometry 0.3.0",
|
||||
"pathfinder_gl 0.1.0",
|
||||
"pathfinder_renderer 0.1.0",
|
||||
|
@ -229,6 +230,11 @@ name = "fuchsia-zircon-sys"
|
|||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "gcc"
|
||||
version = "0.3.55"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "generate-gamma-lut"
|
||||
version = "0.1.0"
|
||||
|
@ -433,6 +439,14 @@ name = "memoffset"
|
|||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "nfd"
|
||||
version = "0.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nodrop"
|
||||
version = "0.1.13"
|
||||
|
@ -1154,6 +1168,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum fs_extra 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674"
|
||||
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
|
||||
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
|
||||
"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2"
|
||||
"checksum gif 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4bca55ac1f213920ce3527ccd62386f1f15fa3f1714aeee1cf93f2c416903f"
|
||||
"checksum gl 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1c73b90c285f02059b34a6c66bc645ba5faa18c0e3ab332e0725654fc71db441"
|
||||
"checksum gl_generator 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "75d69f914b49d9ff32fdf394cbd798f8c716d74fd19f9cc29da3e99797b2a78d"
|
||||
|
@ -1177,6 +1192,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
"checksum lzw 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d947cbb889ed21c2a84be6ffbaebf5b4e0f4340638cba0444907e38b56be084"
|
||||
"checksum memchr 2.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db4c41318937f6e76648f42826b1d9ade5c09cafb5aef7e351240a70f39206e9"
|
||||
"checksum memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0f9dc261e2b62d7a622bf416ea3c5245cdd5d9a7fcc428c0d06804dfce1775b3"
|
||||
"checksum nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e752e3c216bc8a491c5b59fa46da10f1379ae450b19ac688e07f4bb55042e98"
|
||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
||||
"checksum num 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "4703ad64153382334aa8db57c637364c322d3372e097840c72000dabdcf6156e"
|
||||
"checksum num-derive 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8af1847c907c2f04d7bfd572fb25bbb4385c637fe5be163cf2f8c5d778fe1e7d"
|
||||
|
|
|
@ -9,6 +9,7 @@ clap = "2.32"
|
|||
euclid = "0.19"
|
||||
gl = "0.6"
|
||||
jemallocator = "0.1"
|
||||
nfd = "0.0.4"
|
||||
rayon = "1.0"
|
||||
sdl2 = "0.32"
|
||||
usvg = "0.4"
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
// except according to those terms.
|
||||
|
||||
use crate::Options;
|
||||
use nfd::Response;
|
||||
use pathfinder_geometry::basic::point::Point2DI32;
|
||||
use pathfinder_geometry::basic::rect::RectI32;
|
||||
use pathfinder_gl::debug::{BUTTON_HEIGHT, BUTTON_TEXT_OFFSET, BUTTON_WIDTH, DebugUI, PADDING};
|
||||
use pathfinder_gl::debug::{TEXT_COLOR, WINDOW_COLOR};
|
||||
use pathfinder_gl::device::Texture;
|
||||
use std::path::PathBuf;
|
||||
|
||||
const SWITCH_SIZE: i32 = SWITCH_HALF_SIZE * 2 + 1;
|
||||
const SWITCH_HALF_SIZE: i32 = 96;
|
||||
|
@ -33,6 +35,7 @@ pub struct DemoUI {
|
|||
pub gamma_correction_effect_enabled: bool,
|
||||
pub stem_darkening_effect_enabled: bool,
|
||||
pub subpixel_aa_effect_enabled: bool,
|
||||
pub file_to_open: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl DemoUI {
|
||||
|
@ -48,6 +51,7 @@ impl DemoUI {
|
|||
gamma_correction_effect_enabled: false,
|
||||
stem_darkening_effect_enabled: false,
|
||||
subpixel_aa_effect_enabled: false,
|
||||
file_to_open: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +68,11 @@ impl DemoUI {
|
|||
let open_button_x = PADDING + BUTTON_WIDTH + PADDING;
|
||||
let open_button_y = bottom - BUTTON_HEIGHT;
|
||||
let open_button_position = Point2DI32::new(open_button_x, open_button_y);
|
||||
self.draw_button(debug_ui, event, open_button_position, &self.open_texture);
|
||||
if self.draw_button(debug_ui, event, open_button_position, &self.open_texture) {
|
||||
if let Ok(Response::Okay(file)) = nfd::open_file_dialog(Some("svg"), None) {
|
||||
self.file_to_open = Some(PathBuf::from(file));
|
||||
}
|
||||
}
|
||||
|
||||
// Draw 3D switch.
|
||||
let threed_switch_x = PADDING + (BUTTON_WIDTH + PADDING) * 2;
|
||||
|
|
Loading…
Reference in New Issue