|
75 | 75 | }) |
76 | 76 | } |
77 | 77 |
|
| 78 | + extern "C" fn cb_has_no_initial_content<T>(ctxt: *mut c_void) -> bool |
| 79 | + where |
| 80 | + T: CustomBinaryViewType, |
| 81 | + { |
| 82 | + ffi_wrap!("BinaryViewTypeBase::has_no_initial_content", unsafe { |
| 83 | + let view_type = &*(ctxt as *mut T); |
| 84 | + view_type.has_no_initial_content() |
| 85 | + }) |
| 86 | + } |
| 87 | + |
78 | 88 | extern "C" fn cb_create<T>(ctxt: *mut c_void, data: *mut BNBinaryView) -> *mut BNBinaryView |
79 | 89 | where |
80 | 90 | T: CustomBinaryViewType, |
@@ -159,6 +169,7 @@ where |
159 | 169 | isDeprecated: Some(cb_deprecated::<T>), |
160 | 170 | isForceLoadable: Some(cb_force_loadable::<T>), |
161 | 171 | getLoadSettingsForData: Some(cb_load_settings::<T>), |
| 172 | + hasNoInitialContent: Some(cb_has_no_initial_content::<T>), |
162 | 173 | }; |
163 | 174 |
|
164 | 175 | unsafe { |
@@ -199,6 +210,17 @@ pub trait BinaryViewTypeBase: AsRef<BinaryViewType> { |
199 | 210 | false |
200 | 211 | } |
201 | 212 |
|
| 213 | + /// Do instances of this [`BinaryViewType`] start with no loaded content? |
| 214 | + /// |
| 215 | + /// When true, the view has no meaningful default state: the user must make a |
| 216 | + /// selection (e.g. load images from a shared cache) before any content exists. |
| 217 | + /// Callers can use this to suppress restoring previously-saved view state for |
| 218 | + /// files not being loaded from a database, since a saved layout would reference |
| 219 | + /// content that isn't available on reopen. |
| 220 | + fn has_no_initial_content(&self) -> bool { |
| 221 | + false |
| 222 | + } |
| 223 | + |
202 | 224 | fn default_load_settings_for_data(&self, data: &BinaryView) -> Option<Ref<Settings>> { |
203 | 225 | let settings_handle = |
204 | 226 | unsafe { BNGetBinaryViewDefaultLoadSettingsForData(self.as_ref().handle, data.handle) }; |
@@ -386,6 +408,10 @@ impl BinaryViewTypeBase for BinaryViewType { |
386 | 408 | unsafe { BNIsBinaryViewTypeForceLoadable(self.handle) } |
387 | 409 | } |
388 | 410 |
|
| 411 | + fn has_no_initial_content(&self) -> bool { |
| 412 | + unsafe { BNBinaryViewTypeHasNoInitialContent(self.handle) } |
| 413 | + } |
| 414 | + |
389 | 415 | fn load_settings_for_data(&self, data: &BinaryView) -> Option<Ref<Settings>> { |
390 | 416 | let settings_handle = |
391 | 417 | unsafe { BNGetBinaryViewLoadSettingsForData(self.handle, data.handle) }; |
|
0 commit comments