ferroui_dialogs/
managed_file_dialog_options.rs1use ferroui_base::Ref;
2use ferroui_controls::platform::IMountedVolumeInfoProvider;
3use ferroui_controls::ContentControl;
4use std::rc::Rc;
5
6#[derive(Clone, Default)]
11pub struct ManagedFileDialogOptions {
12 allow_directory_selection: bool,
13 custom_volume_info_provider: Option<Rc<dyn IMountedVolumeInfoProvider>>,
14 content_root_factory: Option<Rc<dyn Fn() -> Ref<ContentControl>>>,
15}
16
17impl ManagedFileDialogOptions {
18 pub fn new() -> Self {
19 Self::default()
20 }
21
22 pub fn allow_directory_selection(&self) -> bool {
23 self.allow_directory_selection
24 }
25
26 pub fn set_allow_directory_selection(&mut self, value: bool) {
27 self.allow_directory_selection = value;
28 }
29
30 pub fn custom_volume_info_provider(&self) -> Option<&Rc<dyn IMountedVolumeInfoProvider>> {
32 self.custom_volume_info_provider.as_ref()
33 }
34
35 pub fn set_custom_volume_info_provider(&mut self, value: Option<Rc<dyn IMountedVolumeInfoProvider>>) {
36 self.custom_volume_info_provider = value;
37 }
38
39 pub fn content_root_factory(&self) -> Option<&Rc<dyn Fn() -> Ref<ContentControl>>> {
42 self.content_root_factory.as_ref()
43 }
44
45 pub fn set_content_root_factory(&mut self, value: Option<Rc<dyn Fn() -> Ref<ContentControl>>>) {
46 self.content_root_factory = value;
47 }
48}
49
50impl PartialEq for ManagedFileDialogOptions {
51 fn eq(&self, other: &Self) -> bool {
54 self.allow_directory_selection == other.allow_directory_selection
55 && match (&self.custom_volume_info_provider, &other.custom_volume_info_provider) {
56 (Some(a), Some(b)) => std::ptr::addr_eq(Rc::as_ptr(a), Rc::as_ptr(b)),
57 (None, None) => true,
58 _ => false,
59 }
60 && match (&self.content_root_factory, &other.content_root_factory) {
61 (Some(a), Some(b)) => std::ptr::addr_eq(Rc::as_ptr(a), Rc::as_ptr(b)),
62 (None, None) => true,
63 _ => false,
64 }
65 }
66}