1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[cfg(all(
11 feature = "NSControl",
12 feature = "NSResponder",
13 feature = "NSTableColumn",
14 feature = "NSTableView",
15 feature = "NSView",
16 feature = "block2"
17))]
18pub type NSTableViewDiffableDataSourceCellProvider = *mut block2::DynBlock<
19 dyn Fn(
20 NonNull<NSTableView>,
21 NonNull<NSTableColumn>,
22 NSInteger,
23 NonNull<AnyObject>,
24 ) -> NonNull<NSView>,
25>;
26
27#[cfg(all(
29 feature = "NSControl",
30 feature = "NSResponder",
31 feature = "NSTableRowView",
32 feature = "NSTableView",
33 feature = "NSView",
34 feature = "block2"
35))]
36pub type NSTableViewDiffableDataSourceRowProvider = *mut block2::DynBlock<
37 dyn Fn(NonNull<NSTableView>, NSInteger, NonNull<AnyObject>) -> NonNull<NSTableRowView>,
38>;
39
40#[cfg(all(
42 feature = "NSControl",
43 feature = "NSResponder",
44 feature = "NSTableView",
45 feature = "NSView",
46 feature = "block2"
47))]
48pub type NSTableViewDiffableDataSourceSectionHeaderViewProvider = *mut block2::DynBlock<
49 dyn Fn(NonNull<NSTableView>, NSInteger, NonNull<AnyObject>) -> NonNull<NSView>,
50>;
51
52extern_class!(
53 #[unsafe(super(NSObject))]
55 #[derive(Debug, PartialEq, Eq, Hash)]
56 pub struct NSTableViewDiffableDataSource<
57 SectionIdentifierType: ?Sized = AnyObject,
58 ItemIdentifierType: ?Sized = AnyObject,
59 >;
60);
61
62extern_conformance!(
63 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSObjectProtocol
64 for NSTableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
65 {
66 }
67);
68
69#[cfg(feature = "NSTableView")]
70extern_conformance!(
71 unsafe impl<SectionIdentifierType: ?Sized, ItemIdentifierType: ?Sized> NSTableViewDataSource
72 for NSTableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
73 {
74 }
75);
76
77impl<SectionIdentifierType: Message, ItemIdentifierType: Message>
78 NSTableViewDiffableDataSource<SectionIdentifierType, ItemIdentifierType>
79{
80 extern_methods!(
81 #[cfg(all(
82 feature = "NSControl",
83 feature = "NSResponder",
84 feature = "NSTableColumn",
85 feature = "NSTableView",
86 feature = "NSView",
87 feature = "block2"
88 ))]
89 #[unsafe(method(initWithTableView:cellProvider:))]
90 #[unsafe(method_family = init)]
91 pub unsafe fn initWithTableView_cellProvider(
92 this: Allocated<Self>,
93 table_view: &NSTableView,
94 cell_provider: NSTableViewDiffableDataSourceCellProvider,
95 ) -> Retained<Self>;
96
97 #[unsafe(method(init))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
100
101 #[unsafe(method(new))]
102 #[unsafe(method_family = new)]
103 pub unsafe fn new() -> Retained<Self>;
104
105 #[cfg(feature = "NSDiffableDataSource")]
106 #[unsafe(method(snapshot))]
107 #[unsafe(method_family = none)]
108 pub unsafe fn snapshot(
109 &self,
110 ) -> Retained<NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>>;
111
112 #[cfg(feature = "NSDiffableDataSource")]
113 #[unsafe(method(applySnapshot:animatingDifferences:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn applySnapshot_animatingDifferences(
116 &self,
117 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
118 animating_differences: bool,
119 );
120
121 #[cfg(all(feature = "NSDiffableDataSource", feature = "block2"))]
122 #[unsafe(method(applySnapshot:animatingDifferences:completion:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn applySnapshot_animatingDifferences_completion(
125 &self,
126 snapshot: &NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
127 animating_differences: bool,
128 completion: Option<&block2::DynBlock<dyn Fn()>>,
129 );
130
131 #[unsafe(method(itemIdentifierForRow:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn itemIdentifierForRow(
134 &self,
135 row: NSInteger,
136 ) -> Option<Retained<ItemIdentifierType>>;
137
138 #[unsafe(method(rowForItemIdentifier:))]
139 #[unsafe(method_family = none)]
140 pub unsafe fn rowForItemIdentifier(&self, identifier: &ItemIdentifierType) -> NSInteger;
141
142 #[unsafe(method(sectionIdentifierForRow:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn sectionIdentifierForRow(
145 &self,
146 row: NSInteger,
147 ) -> Option<Retained<SectionIdentifierType>>;
148
149 #[unsafe(method(rowForSectionIdentifier:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn rowForSectionIdentifier(
152 &self,
153 identifier: &SectionIdentifierType,
154 ) -> NSInteger;
155
156 #[cfg(all(
157 feature = "NSControl",
158 feature = "NSResponder",
159 feature = "NSTableRowView",
160 feature = "NSTableView",
161 feature = "NSView",
162 feature = "block2"
163 ))]
164 #[unsafe(method(rowViewProvider))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn rowViewProvider(
167 &self,
168 mtm: MainThreadMarker,
169 ) -> NSTableViewDiffableDataSourceRowProvider;
170
171 #[cfg(all(
172 feature = "NSControl",
173 feature = "NSResponder",
174 feature = "NSTableRowView",
175 feature = "NSTableView",
176 feature = "NSView",
177 feature = "block2"
178 ))]
179 #[unsafe(method(setRowViewProvider:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn setRowViewProvider(
183 &self,
184 row_view_provider: NSTableViewDiffableDataSourceRowProvider,
185 );
186
187 #[cfg(all(
188 feature = "NSControl",
189 feature = "NSResponder",
190 feature = "NSTableView",
191 feature = "NSView",
192 feature = "block2"
193 ))]
194 #[unsafe(method(sectionHeaderViewProvider))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn sectionHeaderViewProvider(
197 &self,
198 mtm: MainThreadMarker,
199 ) -> NSTableViewDiffableDataSourceSectionHeaderViewProvider;
200
201 #[cfg(all(
202 feature = "NSControl",
203 feature = "NSResponder",
204 feature = "NSTableView",
205 feature = "NSView",
206 feature = "block2"
207 ))]
208 #[unsafe(method(setSectionHeaderViewProvider:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setSectionHeaderViewProvider(
212 &self,
213 section_header_view_provider: NSTableViewDiffableDataSourceSectionHeaderViewProvider,
214 );
215
216 #[cfg(feature = "NSTableView")]
217 #[unsafe(method(defaultRowAnimation))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn defaultRowAnimation(&self) -> NSTableViewAnimationOptions;
220
221 #[cfg(feature = "NSTableView")]
222 #[unsafe(method(setDefaultRowAnimation:))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn setDefaultRowAnimation(
226 &self,
227 default_row_animation: NSTableViewAnimationOptions,
228 );
229 );
230}