Skip to main content

swiftui_native/views/
styles.rs

1//! Style modifiers.
2
3use super::*;
4use crate::resolve;
5use core::ffi::c_void;
6//
7// `.listStyle`, `.pickerStyle`, `.toggleStyle` and their siblings are generic
8// over a protocol, so each takes a *concrete* style type. The enums below name
9// the types conforming to each protocol; every one is a resilient struct with
10// an `init()` and a witness table, which is all `style_modifier` needs.
11//
12// `.containerShape` is missing: it has two overloads differing only by an extra
13// constraint, and picking between them needs more than the name.
14
15/// The concrete types conforming to `SwiftUI.ShapeStyle`.
16#[derive(Clone, Copy, Debug, PartialEq, Eq)]
17pub enum ShapeStyle {
18    BackgroundStyle,
19    ForegroundStyle,
20    LinkShapeStyle,
21    SelectionShapeStyle,
22    SeparatorShapeStyle,
23    TintShapeStyle,
24    WindowBackgroundShapeStyle,
25}
26
27impl ShapeStyle {
28    /// The style's metadata accessor, its witness table, and its `init()`.
29    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
30        match self {
31            Self::BackgroundStyle => (resolve::background_style_ma(), resolve::background_style_wt(), resolve::background_style_init()),
32            Self::ForegroundStyle => (resolve::foreground_style_ma(), resolve::foreground_style_wt(), resolve::foreground_style_init()),
33            Self::LinkShapeStyle => (resolve::link_shape_style_ma(), resolve::link_shape_style_wt(), resolve::link_shape_style_init()),
34            Self::SelectionShapeStyle => (resolve::selection_shape_style_ma(), resolve::selection_shape_style_wt(), resolve::selection_shape_style_init()),
35            Self::SeparatorShapeStyle => (resolve::separator_shape_style_ma(), resolve::separator_shape_style_wt(), resolve::separator_shape_style_init()),
36            Self::TintShapeStyle => (resolve::tint_shape_style_ma(), resolve::tint_shape_style_wt(), resolve::tint_shape_style_init()),
37            Self::WindowBackgroundShapeStyle => (resolve::window_background_shape_style_ma(), resolve::window_background_shape_style_wt(), resolve::window_background_shape_style_init()),
38        }
39    }
40}
41
42
43/// The concrete types conforming to `SwiftUI.ControlGroupStyle`.
44#[derive(Clone, Copy, Debug, PartialEq, Eq)]
45pub enum ControlGroupStyle {
46    AutomaticControlGroupStyle,
47    CompactMenuControlGroupStyle,
48    MenuControlGroupStyle,
49    NavigationControlGroupStyle,
50    PaletteControlGroupStyle,
51}
52
53impl ControlGroupStyle {
54    /// The style's metadata accessor, its witness table, and its `init()`.
55    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
56        match self {
57            Self::AutomaticControlGroupStyle => (resolve::automatic_control_group_style_ma(), resolve::automatic_control_group_style_wt(), resolve::automatic_control_group_style_init()),
58            Self::CompactMenuControlGroupStyle => (resolve::compact_menu_control_group_style_ma(), resolve::compact_menu_control_group_style_wt(), resolve::compact_menu_control_group_style_init()),
59            Self::MenuControlGroupStyle => (resolve::menu_control_group_style_ma(), resolve::menu_control_group_style_wt(), resolve::menu_control_group_style_init()),
60            Self::NavigationControlGroupStyle => (resolve::navigation_control_group_style_ma(), resolve::navigation_control_group_style_wt(), resolve::navigation_control_group_style_init()),
61            Self::PaletteControlGroupStyle => (resolve::palette_control_group_style_ma(), resolve::palette_control_group_style_wt(), resolve::palette_control_group_style_init()),
62        }
63    }
64}
65
66/// The concrete types conforming to `SwiftUI.DatePickerStyle`.
67#[derive(Clone, Copy, Debug, PartialEq, Eq)]
68pub enum DatePickerStyle {
69    CompactDatePickerStyle,
70    DefaultDatePickerStyle,
71    FieldDatePickerStyle,
72    GraphicalDatePickerStyle,
73    StepperFieldDatePickerStyle,
74}
75
76impl DatePickerStyle {
77    /// The style's metadata accessor, its witness table, and its `init()`.
78    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
79        match self {
80            Self::CompactDatePickerStyle => (resolve::compact_date_picker_style_ma(), resolve::compact_date_picker_style_wt(), resolve::compact_date_picker_style_init()),
81            Self::DefaultDatePickerStyle => (resolve::default_date_picker_style_ma(), resolve::default_date_picker_style_wt(), resolve::default_date_picker_style_init()),
82            Self::FieldDatePickerStyle => (resolve::field_date_picker_style_ma(), resolve::field_date_picker_style_wt(), resolve::field_date_picker_style_init()),
83            Self::GraphicalDatePickerStyle => (resolve::graphical_date_picker_style_ma(), resolve::graphical_date_picker_style_wt(), resolve::graphical_date_picker_style_init()),
84            Self::StepperFieldDatePickerStyle => (resolve::stepper_field_date_picker_style_ma(), resolve::stepper_field_date_picker_style_wt(), resolve::stepper_field_date_picker_style_init()),
85        }
86    }
87}
88
89/// The concrete types conforming to `SwiftUI.DisclosureGroupStyle`.
90#[derive(Clone, Copy, Debug, PartialEq, Eq)]
91pub enum DisclosureGroupStyle {
92    AutomaticDisclosureGroupStyle,
93}
94
95impl DisclosureGroupStyle {
96    /// The style's metadata accessor, its witness table, and its `init()`.
97    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
98        match self {
99            Self::AutomaticDisclosureGroupStyle => (resolve::automatic_disclosure_group_style_ma(), resolve::automatic_disclosure_group_style_wt(), resolve::automatic_disclosure_group_style_init()),
100        }
101    }
102}
103
104/// The concrete types conforming to `SwiftUI.FormStyle`.
105#[derive(Clone, Copy, Debug, PartialEq, Eq)]
106pub enum FormStyle {
107    AutomaticFormStyle,
108    ColumnsFormStyle,
109    GroupedFormStyle,
110}
111
112impl FormStyle {
113    /// The style's metadata accessor, its witness table, and its `init()`.
114    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
115        match self {
116            Self::AutomaticFormStyle => (resolve::automatic_form_style_ma(), resolve::automatic_form_style_wt(), resolve::automatic_form_style_init()),
117            Self::ColumnsFormStyle => (resolve::columns_form_style_ma(), resolve::columns_form_style_wt(), resolve::columns_form_style_init()),
118            Self::GroupedFormStyle => (resolve::grouped_form_style_ma(), resolve::grouped_form_style_wt(), resolve::grouped_form_style_init()),
119        }
120    }
121}
122
123/// The concrete types conforming to `SwiftUI.GaugeStyle`.
124#[derive(Clone, Copy, Debug, PartialEq, Eq)]
125pub enum GaugeStyle {
126    AccessoryCircularCapacityGaugeStyle,
127    AccessoryCircularGaugeStyle,
128    AccessoryLinearCapacityGaugeStyle,
129    AccessoryLinearGaugeStyle,
130    DefaultGaugeStyle,
131    LinearCapacityGaugeStyle,
132}
133
134impl GaugeStyle {
135    /// The style's metadata accessor, its witness table, and its `init()`.
136    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
137        match self {
138            Self::AccessoryCircularCapacityGaugeStyle => (resolve::accessory_circular_capacity_gauge_style_ma(), resolve::accessory_circular_capacity_gauge_style_wt(), resolve::accessory_circular_capacity_gauge_style_init()),
139            Self::AccessoryCircularGaugeStyle => (resolve::accessory_circular_gauge_style_ma(), resolve::accessory_circular_gauge_style_wt(), resolve::accessory_circular_gauge_style_init()),
140            Self::AccessoryLinearCapacityGaugeStyle => (resolve::accessory_linear_capacity_gauge_style_ma(), resolve::accessory_linear_capacity_gauge_style_wt(), resolve::accessory_linear_capacity_gauge_style_init()),
141            Self::AccessoryLinearGaugeStyle => (resolve::accessory_linear_gauge_style_ma(), resolve::accessory_linear_gauge_style_wt(), resolve::accessory_linear_gauge_style_init()),
142            Self::DefaultGaugeStyle => (resolve::default_gauge_style_ma(), resolve::default_gauge_style_wt(), resolve::default_gauge_style_init()),
143            Self::LinearCapacityGaugeStyle => (resolve::linear_capacity_gauge_style_ma(), resolve::linear_capacity_gauge_style_wt(), resolve::linear_capacity_gauge_style_init()),
144        }
145    }
146}
147
148/// The concrete types conforming to `SwiftUI.GroupBoxStyle`.
149#[derive(Clone, Copy, Debug, PartialEq, Eq)]
150pub enum GroupBoxStyle {
151    DefaultGroupBoxStyle,
152}
153
154impl GroupBoxStyle {
155    /// The style's metadata accessor, its witness table, and its `init()`.
156    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
157        match self {
158            Self::DefaultGroupBoxStyle => (resolve::default_group_box_style_ma(), resolve::default_group_box_style_wt(), resolve::default_group_box_style_init()),
159        }
160    }
161}
162
163/// The concrete types conforming to `SwiftUI.LabelStyle`.
164#[derive(Clone, Copy, Debug, PartialEq, Eq)]
165pub enum LabelStyle {
166    DefaultLabelStyle,
167    IconOnlyLabelStyle,
168    TitleAndIconLabelStyle,
169    TitleOnlyLabelStyle,
170}
171
172impl LabelStyle {
173    /// The style's metadata accessor, its witness table, and its `init()`.
174    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
175        match self {
176            Self::DefaultLabelStyle => (resolve::default_label_style_ma(), resolve::default_label_style_wt(), resolve::default_label_style_init()),
177            Self::IconOnlyLabelStyle => (resolve::icon_only_label_style_ma(), resolve::icon_only_label_style_wt(), resolve::icon_only_label_style_init()),
178            Self::TitleAndIconLabelStyle => (resolve::title_and_icon_label_style_ma(), resolve::title_and_icon_label_style_wt(), resolve::title_and_icon_label_style_init()),
179            Self::TitleOnlyLabelStyle => (resolve::title_only_label_style_ma(), resolve::title_only_label_style_wt(), resolve::title_only_label_style_init()),
180        }
181    }
182}
183
184/// The concrete types conforming to `SwiftUI.LabeledContentStyle`.
185#[derive(Clone, Copy, Debug, PartialEq, Eq)]
186pub enum LabeledContentStyle {
187    AutomaticLabeledContentStyle,
188}
189
190impl LabeledContentStyle {
191    /// The style's metadata accessor, its witness table, and its `init()`.
192    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
193        match self {
194            Self::AutomaticLabeledContentStyle => (resolve::automatic_labeled_content_style_ma(), resolve::automatic_labeled_content_style_wt(), resolve::automatic_labeled_content_style_init()),
195        }
196    }
197}
198
199/// The concrete types conforming to `SwiftUI.ListStyle`.
200#[derive(Clone, Copy, Debug, PartialEq, Eq)]
201pub enum ListStyle {
202    BorderedListStyle,
203    DefaultListStyle,
204    InsetListStyle,
205    PlainListStyle,
206    SidebarListStyle,
207}
208
209impl ListStyle {
210    /// The style's metadata accessor, its witness table, and its `init()`.
211    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
212        match self {
213            Self::BorderedListStyle => (resolve::bordered_list_style_ma(), resolve::bordered_list_style_wt(), resolve::bordered_list_style_init()),
214            Self::DefaultListStyle => (resolve::default_list_style_ma(), resolve::default_list_style_wt(), resolve::default_list_style_init()),
215            Self::InsetListStyle => (resolve::inset_list_style_ma(), resolve::inset_list_style_wt(), resolve::inset_list_style_init()),
216            Self::PlainListStyle => (resolve::plain_list_style_ma(), resolve::plain_list_style_wt(), resolve::plain_list_style_init()),
217            Self::SidebarListStyle => (resolve::sidebar_list_style_ma(), resolve::sidebar_list_style_wt(), resolve::sidebar_list_style_init()),
218        }
219    }
220}
221
222/// The concrete types conforming to `SwiftUI.MenuButtonStyle`.
223#[derive(Clone, Copy, Debug, PartialEq, Eq)]
224pub enum MenuButtonStyle {
225    BorderlessPullDownMenuButtonStyle,
226    DefaultMenuButtonStyle,
227    PullDownMenuButtonStyle,
228}
229
230impl MenuButtonStyle {
231    /// The style's metadata accessor, its witness table, and its `init()`.
232    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
233        match self {
234            Self::BorderlessPullDownMenuButtonStyle => (resolve::borderless_pull_down_menu_button_style_ma(), resolve::borderless_pull_down_menu_button_style_wt(), resolve::borderless_pull_down_menu_button_style_init()),
235            Self::DefaultMenuButtonStyle => (resolve::default_menu_button_style_ma(), resolve::default_menu_button_style_wt(), resolve::default_menu_button_style_init()),
236            Self::PullDownMenuButtonStyle => (resolve::pull_down_menu_button_style_ma(), resolve::pull_down_menu_button_style_wt(), resolve::pull_down_menu_button_style_init()),
237        }
238    }
239}
240
241/// The concrete types conforming to `SwiftUI.MenuStyle`.
242#[derive(Clone, Copy, Debug, PartialEq, Eq)]
243pub enum MenuStyle {
244    BorderedButtonMenuStyle,
245    BorderlessButtonMenuStyle,
246    ButtonMenuStyle,
247    DefaultMenuStyle,
248}
249
250impl MenuStyle {
251    /// The style's metadata accessor, its witness table, and its `init()`.
252    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
253        match self {
254            Self::BorderedButtonMenuStyle => (resolve::bordered_button_menu_style_ma(), resolve::bordered_button_menu_style_wt(), resolve::bordered_button_menu_style_init()),
255            Self::BorderlessButtonMenuStyle => (resolve::borderless_button_menu_style_ma(), resolve::borderless_button_menu_style_wt(), resolve::borderless_button_menu_style_init()),
256            Self::ButtonMenuStyle => (resolve::button_menu_style_ma(), resolve::button_menu_style_wt(), resolve::button_menu_style_init()),
257            Self::DefaultMenuStyle => (resolve::default_menu_style_ma(), resolve::default_menu_style_wt(), resolve::default_menu_style_init()),
258        }
259    }
260}
261
262/// The concrete types conforming to `SwiftUI.PickerStyle`.
263#[derive(Clone, Copy, Debug, PartialEq, Eq)]
264pub enum PickerStyle {
265    DefaultPickerStyle,
266    InlinePickerStyle,
267    MenuPickerStyle,
268    PalettePickerStyle,
269    PopUpButtonPickerStyle,
270    RadioGroupPickerStyle,
271    SegmentedPickerStyle,
272}
273
274impl PickerStyle {
275    /// The style's metadata accessor, its witness table, and its `init()`.
276    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
277        match self {
278            Self::DefaultPickerStyle => (resolve::default_picker_style_ma(), resolve::default_picker_style_wt(), resolve::default_picker_style_init()),
279            Self::InlinePickerStyle => (resolve::inline_picker_style_ma(), resolve::inline_picker_style_wt(), resolve::inline_picker_style_init()),
280            Self::MenuPickerStyle => (resolve::menu_picker_style_ma(), resolve::menu_picker_style_wt(), resolve::menu_picker_style_init()),
281            Self::PalettePickerStyle => (resolve::palette_picker_style_ma(), resolve::palette_picker_style_wt(), resolve::palette_picker_style_init()),
282            Self::PopUpButtonPickerStyle => (resolve::pop_up_button_picker_style_ma(), resolve::pop_up_button_picker_style_wt(), resolve::pop_up_button_picker_style_init()),
283            Self::RadioGroupPickerStyle => (resolve::radio_group_picker_style_ma(), resolve::radio_group_picker_style_wt(), resolve::radio_group_picker_style_init()),
284            Self::SegmentedPickerStyle => (resolve::segmented_picker_style_ma(), resolve::segmented_picker_style_wt(), resolve::segmented_picker_style_init()),
285        }
286    }
287}
288
289/// The concrete types conforming to `SwiftUI.WindowStyle`.
290#[derive(Clone, Copy, Debug, PartialEq, Eq)]
291pub enum WindowStyle {
292    DefaultWindowStyle,
293    HiddenTitleBarWindowStyle,
294    PlainWindowStyle,
295    TitleBarWindowStyle,
296}
297
298impl WindowStyle {
299    /// The style's metadata accessor, its witness table, and its `init()`.
300    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
301        match self {
302            Self::DefaultWindowStyle => (resolve::default_window_style_ma(), resolve::default_window_style_wt(), resolve::default_window_style_init()),
303            Self::HiddenTitleBarWindowStyle => (resolve::hidden_title_bar_window_style_ma(), resolve::hidden_title_bar_window_style_wt(), resolve::hidden_title_bar_window_style_init()),
304            Self::PlainWindowStyle => (resolve::plain_window_style_ma(), resolve::plain_window_style_wt(), resolve::plain_window_style_init()),
305            Self::TitleBarWindowStyle => (resolve::title_bar_window_style_ma(), resolve::title_bar_window_style_wt(), resolve::title_bar_window_style_init()),
306        }
307    }
308}
309
310/// The concrete types conforming to `SwiftUI.WindowToolbarStyle`.
311#[derive(Clone, Copy, Debug, PartialEq, Eq)]
312pub enum WindowToolbarStyle {
313    DefaultWindowToolbarStyle,
314    ExpandedWindowToolbarStyle,
315    UnifiedCompactWindowToolbarStyle,
316    UnifiedWindowToolbarStyle,
317}
318
319impl WindowToolbarStyle {
320    /// The style's metadata accessor, its witness table, and its `init()`.
321    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
322        match self {
323            Self::DefaultWindowToolbarStyle => (resolve::default_window_toolbar_style_ma(), resolve::default_window_toolbar_style_wt(), resolve::default_window_toolbar_style_init()),
324            Self::ExpandedWindowToolbarStyle => (resolve::expanded_window_toolbar_style_ma(), resolve::expanded_window_toolbar_style_wt(), resolve::expanded_window_toolbar_style_init()),
325            Self::UnifiedCompactWindowToolbarStyle => (resolve::unified_compact_window_toolbar_style_ma(), resolve::unified_compact_window_toolbar_style_wt(), resolve::unified_compact_window_toolbar_style_init()),
326            Self::UnifiedWindowToolbarStyle => (resolve::unified_window_toolbar_style_ma(), resolve::unified_window_toolbar_style_wt(), resolve::unified_window_toolbar_style_init()),
327        }
328    }
329}
330
331/// The concrete types conforming to `SwiftUI.ScrollTargetBehavior`.
332#[derive(Clone, Copy, Debug, PartialEq, Eq)]
333pub enum ScrollTargetBehavior {
334    PagingScrollTargetBehavior,
335}
336
337impl ScrollTargetBehavior {
338    /// The style's metadata accessor, its witness table, and its `init()`.
339    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
340        match self {
341            Self::PagingScrollTargetBehavior => (resolve::paging_scroll_target_behavior_ma(), resolve::paging_scroll_target_behavior_wt(), resolve::paging_scroll_target_behavior_init()),
342        }
343    }
344}
345
346/// The concrete types conforming to `SwiftUI.TableStyle`.
347#[derive(Clone, Copy, Debug, PartialEq, Eq)]
348pub enum TableStyle {
349    AutomaticTableStyle,
350    BorderedTableStyle,
351    InsetTableStyle,
352}
353
354impl TableStyle {
355    /// The style's metadata accessor, its witness table, and its `init()`.
356    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
357        match self {
358            Self::AutomaticTableStyle => (resolve::automatic_table_style_ma(), resolve::automatic_table_style_wt(), resolve::automatic_table_style_init()),
359            Self::BorderedTableStyle => (resolve::bordered_table_style_ma(), resolve::bordered_table_style_wt(), resolve::bordered_table_style_init()),
360            Self::InsetTableStyle => (resolve::inset_table_style_ma(), resolve::inset_table_style_wt(), resolve::inset_table_style_init()),
361        }
362    }
363}
364
365/// The concrete types conforming to `SwiftUI.TextEditorStyle`.
366#[derive(Clone, Copy, Debug, PartialEq, Eq)]
367pub enum TextEditorStyle {
368    AutomaticTextEditorStyle,
369    PlainTextEditorStyle,
370}
371
372impl TextEditorStyle {
373    /// The style's metadata accessor, its witness table, and its `init()`.
374    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
375        match self {
376            Self::AutomaticTextEditorStyle => (resolve::automatic_text_editor_style_ma(), resolve::automatic_text_editor_style_wt(), resolve::automatic_text_editor_style_init()),
377            Self::PlainTextEditorStyle => (resolve::plain_text_editor_style_ma(), resolve::plain_text_editor_style_wt(), resolve::plain_text_editor_style_init()),
378        }
379    }
380}
381
382/// The concrete types conforming to `SwiftUI.TextFieldStyle`.
383#[derive(Clone, Copy, Debug, PartialEq, Eq)]
384pub enum TextFieldStyle {
385    DefaultTextFieldStyle,
386    PlainTextFieldStyle,
387    RoundedBorderTextFieldStyle,
388    SquareBorderTextFieldStyle,
389}
390
391impl TextFieldStyle {
392    /// The style's metadata accessor, its witness table, and its `init()`.
393    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
394        match self {
395            Self::DefaultTextFieldStyle => (resolve::default_text_field_style_ma(), resolve::default_text_field_style_wt(), resolve::default_text_field_style_init()),
396            Self::PlainTextFieldStyle => (resolve::plain_text_field_style_ma(), resolve::plain_text_field_style_wt(), resolve::plain_text_field_style_init()),
397            Self::RoundedBorderTextFieldStyle => (resolve::rounded_border_text_field_style_ma(), resolve::rounded_border_text_field_style_wt(), resolve::rounded_border_text_field_style_init()),
398            Self::SquareBorderTextFieldStyle => (resolve::square_border_text_field_style_ma(), resolve::square_border_text_field_style_wt(), resolve::square_border_text_field_style_init()),
399        }
400    }
401}
402
403/// The concrete types conforming to `SwiftUI.TextSelectability`.
404#[derive(Clone, Copy, Debug, PartialEq, Eq)]
405pub enum TextSelectability {
406    DisabledTextSelectability,
407    EnabledTextSelectability,
408}
409
410impl TextSelectability {
411    /// The style's metadata accessor, its witness table, and its `init()`.
412    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
413        match self {
414            Self::DisabledTextSelectability => (resolve::disabled_text_selectability_ma(), resolve::disabled_text_selectability_wt(), resolve::disabled_text_selectability_init()),
415            Self::EnabledTextSelectability => (resolve::enabled_text_selectability_ma(), resolve::enabled_text_selectability_wt(), resolve::enabled_text_selectability_init()),
416        }
417    }
418}
419
420/// The concrete types conforming to `SwiftUI.ToggleStyle`.
421#[derive(Clone, Copy, Debug, PartialEq, Eq)]
422pub enum ToggleStyle {
423    ButtonToggleStyle,
424    CheckboxToggleStyle,
425    DefaultToggleStyle,
426    SwitchToggleStyle,
427}
428
429impl ToggleStyle {
430    /// The style's metadata accessor, its witness table, and its `init()`.
431    pub(crate) fn parts(self) -> (*const c_void, *const c_void, *const c_void) {
432        match self {
433            Self::ButtonToggleStyle => (resolve::button_toggle_style_ma(), resolve::button_toggle_style_wt(), resolve::button_toggle_style_init()),
434            Self::CheckboxToggleStyle => (resolve::checkbox_toggle_style_ma(), resolve::checkbox_toggle_style_wt(), resolve::checkbox_toggle_style_init()),
435            Self::DefaultToggleStyle => (resolve::default_toggle_style_ma(), resolve::default_toggle_style_wt(), resolve::default_toggle_style_init()),
436            Self::SwitchToggleStyle => (resolve::switch_toggle_style_ma(), resolve::switch_toggle_style_wt(), resolve::switch_toggle_style_init()),
437        }
438    }
439}
440
441/// Apply `.backgroundStyle(_:)`.
442pub fn background_shape_style(view: &ViewHandle, style: ShapeStyle) -> ViewHandle {
443    unsafe {
444        let (meta, wt, init) = style.parts();
445        style_modifier(resolve::background_style_fn(), resolve::background_style_oret(), view, meta, wt, init)
446    }
447}
448
449
450/// Apply `.controlGroupStyle(_:)`.
451pub fn control_group_style(view: &ViewHandle, style: ControlGroupStyle) -> ViewHandle {
452    unsafe {
453        let (meta, wt, init) = style.parts();
454        style_modifier(resolve::control_group_style_fn(), resolve::control_group_style_oret(), view, meta, wt, init)
455    }
456}
457
458/// Apply `.datePickerStyle(_:)`.
459pub fn date_picker_style(view: &ViewHandle, style: DatePickerStyle) -> ViewHandle {
460    unsafe {
461        let (meta, wt, init) = style.parts();
462        style_modifier(resolve::date_picker_style_fn(), resolve::date_picker_style_oret(), view, meta, wt, init)
463    }
464}
465
466/// Apply `.disclosureGroupStyle(_:)`.
467pub fn disclosure_group_style(view: &ViewHandle, style: DisclosureGroupStyle) -> ViewHandle {
468    unsafe {
469        let (meta, wt, init) = style.parts();
470        style_modifier(resolve::disclosure_group_style_fn(), resolve::disclosure_group_style_oret(), view, meta, wt, init)
471    }
472}
473
474/// Apply `.formStyle(_:)`.
475pub fn form_style(view: &ViewHandle, style: FormStyle) -> ViewHandle {
476    unsafe {
477        let (meta, wt, init) = style.parts();
478        style_modifier(resolve::form_style_fn(), resolve::form_style_oret(), view, meta, wt, init)
479    }
480}
481
482/// Apply `.gaugeStyle(_:)`.
483pub fn gauge_style(view: &ViewHandle, style: GaugeStyle) -> ViewHandle {
484    unsafe {
485        let (meta, wt, init) = style.parts();
486        style_modifier(resolve::gauge_style_fn(), resolve::gauge_style_oret(), view, meta, wt, init)
487    }
488}
489
490/// Apply `.groupBoxStyle(_:)`.
491pub fn group_box_style(view: &ViewHandle, style: GroupBoxStyle) -> ViewHandle {
492    unsafe {
493        let (meta, wt, init) = style.parts();
494        style_modifier(resolve::group_box_style_fn(), resolve::group_box_style_oret(), view, meta, wt, init)
495    }
496}
497
498/// Apply `.labelStyle(_:)`.
499pub fn label_style(view: &ViewHandle, style: LabelStyle) -> ViewHandle {
500    unsafe {
501        let (meta, wt, init) = style.parts();
502        style_modifier(resolve::label_style_fn(), resolve::label_style_oret(), view, meta, wt, init)
503    }
504}
505
506/// Apply `.labeledContentStyle(_:)`.
507pub fn labeled_content_style(view: &ViewHandle, style: LabeledContentStyle) -> ViewHandle {
508    unsafe {
509        let (meta, wt, init) = style.parts();
510        style_modifier(resolve::labeled_content_style_fn(), resolve::labeled_content_style_oret(), view, meta, wt, init)
511    }
512}
513
514/// Apply `.listStyle(_:)`.
515pub fn list_style(view: &ViewHandle, style: ListStyle) -> ViewHandle {
516    unsafe {
517        let (meta, wt, init) = style.parts();
518        style_modifier(resolve::list_style_fn(), resolve::list_style_oret(), view, meta, wt, init)
519    }
520}
521
522/// Apply `.menuButtonStyle(_:)`.
523pub fn menu_button_style(view: &ViewHandle, style: MenuButtonStyle) -> ViewHandle {
524    unsafe {
525        let (meta, wt, init) = style.parts();
526        style_modifier(resolve::menu_button_style_fn(), resolve::menu_button_style_oret(), view, meta, wt, init)
527    }
528}
529
530/// Apply `.menuStyle(_:)`.
531pub fn menu_style(view: &ViewHandle, style: MenuStyle) -> ViewHandle {
532    unsafe {
533        let (meta, wt, init) = style.parts();
534        style_modifier(resolve::menu_style_fn(), resolve::menu_style_oret(), view, meta, wt, init)
535    }
536}
537
538/// Apply `.pickerStyle(_:)`.
539pub fn picker_style(view: &ViewHandle, style: PickerStyle) -> ViewHandle {
540    unsafe {
541        let (meta, wt, init) = style.parts();
542        style_modifier(resolve::picker_style_fn(), resolve::picker_style_oret(), view, meta, wt, init)
543    }
544}
545
546/// Apply `.presentedWindowStyle(_:)`.
547pub fn presented_window_style(view: &ViewHandle, style: WindowStyle) -> ViewHandle {
548    unsafe {
549        let (meta, wt, init) = style.parts();
550        style_modifier(resolve::presented_window_style_fn(), resolve::presented_window_style_oret(), view, meta, wt, init)
551    }
552}
553
554/// Apply `.presentedWindowToolbarStyle(_:)`.
555pub fn presented_window_toolbar_style(view: &ViewHandle, style: WindowToolbarStyle) -> ViewHandle {
556    unsafe {
557        let (meta, wt, init) = style.parts();
558        style_modifier(resolve::presented_window_toolbar_style_fn(), resolve::presented_window_toolbar_style_oret(), view, meta, wt, init)
559    }
560}
561
562/// Apply `.scrollTargetBehavior(_:)`.
563pub fn scroll_target_behavior(view: &ViewHandle, style: ScrollTargetBehavior) -> ViewHandle {
564    unsafe {
565        let (meta, wt, init) = style.parts();
566        style_modifier(resolve::scroll_target_behavior_fn(), resolve::scroll_target_behavior_oret(), view, meta, wt, init)
567    }
568}
569
570/// Apply `.tableStyle(_:)`.
571pub fn table_style(view: &ViewHandle, style: TableStyle) -> ViewHandle {
572    unsafe {
573        let (meta, wt, init) = style.parts();
574        style_modifier(resolve::table_style_fn(), resolve::table_style_oret(), view, meta, wt, init)
575    }
576}
577
578/// Apply `.textEditorStyle(_:)`.
579pub fn text_editor_style(view: &ViewHandle, style: TextEditorStyle) -> ViewHandle {
580    unsafe {
581        let (meta, wt, init) = style.parts();
582        style_modifier(resolve::text_editor_style_fn(), resolve::text_editor_style_oret(), view, meta, wt, init)
583    }
584}
585
586/// Apply `.textFieldStyle(_:)`.
587pub fn text_field_style(view: &ViewHandle, style: TextFieldStyle) -> ViewHandle {
588    unsafe {
589        let (meta, wt, init) = style.parts();
590        style_modifier(resolve::text_field_style_fn(), resolve::text_field_style_oret(), view, meta, wt, init)
591    }
592}
593
594/// Apply `.textSelection(_:)`.
595pub fn text_selection(view: &ViewHandle, style: TextSelectability) -> ViewHandle {
596    unsafe {
597        let (meta, wt, init) = style.parts();
598        style_modifier(resolve::text_selection_fn(), resolve::text_selection_oret(), view, meta, wt, init)
599    }
600}
601
602/// Apply `.toggleStyle(_:)`.
603pub fn toggle_style(view: &ViewHandle, style: ToggleStyle) -> ViewHandle {
604    unsafe {
605        let (meta, wt, init) = style.parts();
606        style_modifier(resolve::toggle_style_fn(), resolve::toggle_style_oret(), view, meta, wt, init)
607    }
608}