objc2_ui_kit/generated/
UIPageControlProgress.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontrolprogressdelegate?language=objc)
12    pub unsafe trait UIPageControlProgressDelegate: NSObjectProtocol {
13        /// Returns the initial progress (between 0...1) for the specified page. By default, `currentProgress` is set to 0 when the page changes.
14        #[optional]
15        #[unsafe(method(pageControlProgress:initialProgressForPage:))]
16        #[unsafe(method_family = none)]
17        unsafe fn pageControlProgress_initialProgressForPage(
18            &self,
19            progress: &UIPageControlProgress,
20            page: NSInteger,
21        ) -> c_float;
22
23        /// Called when the page control progress visibility has changed, which could occur when the page control is being interacted
24        /// with. The page control progress becomes hidden when the user begins to interact with the page control (when it begins
25        /// continuous interaction), and is visible again when the user stops interacting with the control. Observe the page control progress
26        /// visibility to pause or resume the paging content.
27        ///
28        /// Example:
29        ///
30        /// ```text
31        ///  - (void)pageControlProgressVisibilityDidChange:(UIPageControlProgress *)progress {
32        ///      BOOL isProgressVisible = progress.isProgressVisible;
33        ///      if (isProgressVisible) {
34        ///          [self _resumeContentFromInteractionChanges];
35        ///      } else {
36        ///          [self _pauseContentFromInteractionChanges];
37        ///      }
38        ///  }
39        /// ```
40        #[optional]
41        #[unsafe(method(pageControlProgressVisibilityDidChange:))]
42        #[unsafe(method_family = none)]
43        unsafe fn pageControlProgressVisibilityDidChange(&self, progress: &UIPageControlProgress);
44    }
45);
46
47extern_class!(
48    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontrolprogress?language=objc)
49    #[unsafe(super(NSObject))]
50    #[derive(Debug, PartialEq, Eq, Hash)]
51    pub struct UIPageControlProgress;
52);
53
54unsafe impl NSObjectProtocol for UIPageControlProgress {}
55
56impl UIPageControlProgress {
57    extern_methods!(
58        /// An object that defines the delegate of the page control progress.
59        #[unsafe(method(delegate))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn delegate(
62            &self,
63        ) -> Option<Retained<ProtocolObject<dyn UIPageControlProgressDelegate>>>;
64
65        /// This is a [weak property][objc2::topics::weak_property].
66        /// Setter for [`delegate`][Self::delegate].
67        #[unsafe(method(setDelegate:))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn setDelegate(
70            &self,
71            delegate: Option<&ProtocolObject<dyn UIPageControlProgressDelegate>>,
72        );
73
74        /// The current progress value of the active page control indicator, between 0 and 1.
75        /// Values outside of [0...1] will be clamped.
76        #[unsafe(method(currentProgress))]
77        #[unsafe(method_family = none)]
78        pub unsafe fn currentProgress(&self) -> c_float;
79
80        /// Setter for [`currentProgress`][Self::currentProgress].
81        #[unsafe(method(setCurrentProgress:))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn setCurrentProgress(&self, current_progress: c_float);
84
85        /// Returns `YES` if the progress indicator is visible. The progress indicator is hidden when
86        /// the user is actively interacting with the `UIPageControl`.
87        #[unsafe(method(isProgressVisible))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn isProgressVisible(&self) -> bool;
90    );
91}
92
93/// Methods declared on superclass `NSObject`.
94impl UIPageControlProgress {
95    extern_methods!(
96        #[unsafe(method(init))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
99
100        #[unsafe(method(new))]
101        #[unsafe(method_family = new)]
102        pub unsafe fn new() -> Retained<Self>;
103    );
104}
105
106extern_protocol!(
107    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontroltimerprogressdelegate?language=objc)
108    pub unsafe trait UIPageControlTimerProgressDelegate:
109        UIPageControlProgressDelegate
110    {
111        /// Called when the progress has changed from the time interval progress.
112        #[optional]
113        #[unsafe(method(pageControlTimerProgressDidChange:))]
114        #[unsafe(method_family = none)]
115        unsafe fn pageControlTimerProgressDidChange(&self, progress: &UIPageControlTimerProgress);
116
117        /// Determines if the time interval progress should advance to the next page upon progress completion of
118        /// the current page's duration. Default is YES.
119        #[optional]
120        #[unsafe(method(pageControlTimerProgress:shouldAdvanceToPage:))]
121        #[unsafe(method_family = none)]
122        unsafe fn pageControlTimerProgress_shouldAdvanceToPage(
123            &self,
124            progress: &UIPageControlTimerProgress,
125            page: NSInteger,
126        ) -> bool;
127    }
128);
129
130extern_class!(
131    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontroltimerprogress?language=objc)
132    #[unsafe(super(UIPageControlProgress, NSObject))]
133    #[derive(Debug, PartialEq, Eq, Hash)]
134    pub struct UIPageControlTimerProgress;
135);
136
137unsafe impl NSObjectProtocol for UIPageControlTimerProgress {}
138
139impl UIPageControlTimerProgress {
140    extern_methods!(
141        /// Creates a time interval progress with a specified preferred duration.
142        #[unsafe(method(initWithPreferredDuration:))]
143        #[unsafe(method_family = init)]
144        pub unsafe fn initWithPreferredDuration(
145            this: Allocated<Self>,
146            preferred_duration: NSTimeInterval,
147        ) -> Retained<Self>;
148
149        /// An object that defines the delegate of the page control progress.
150        #[unsafe(method(delegate))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn delegate(
153            &self,
154        ) -> Option<Retained<ProtocolObject<dyn UIPageControlTimerProgressDelegate>>>;
155
156        /// This is a [weak property][objc2::topics::weak_property].
157        /// Setter for [`delegate`][Self::delegate].
158        #[unsafe(method(setDelegate:))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn setDelegate(
161            &self,
162            delegate: Option<&ProtocolObject<dyn UIPageControlTimerProgressDelegate>>,
163        );
164
165        /// Determines if the page control should loop back to page 0 after the last page. Default is NO.
166        #[unsafe(method(resetsToInitialPageAfterEnd))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn resetsToInitialPageAfterEnd(&self) -> bool;
169
170        /// Setter for [`resetsToInitialPageAfterEnd`][Self::resetsToInitialPageAfterEnd].
171        #[unsafe(method(setResetsToInitialPageAfterEnd:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setResetsToInitialPageAfterEnd(&self, resets_to_initial_page_after_end: bool);
174
175        /// Returns YES if the timer is currently active.
176        #[unsafe(method(isRunning))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn isRunning(&self) -> bool;
179
180        /// Resume the timer if it is not currently active.
181        #[unsafe(method(resumeTimer))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn resumeTimer(&self);
184
185        /// Pause the timer if it is active.
186        #[unsafe(method(pauseTimer))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn pauseTimer(&self);
189
190        /// The preferred duration for the time interval progress, used when there is no custom page duration set for the current page.
191        /// The preferred duration must be greater than 0.0
192        #[unsafe(method(preferredDuration))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn preferredDuration(&self) -> NSTimeInterval;
195
196        /// Setter for [`preferredDuration`][Self::preferredDuration].
197        #[unsafe(method(setPreferredDuration:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn setPreferredDuration(&self, preferred_duration: NSTimeInterval);
200
201        /// Sets a custom duration for the specified page. Set 0.0 to remove the custom duration for the specified page.
202        #[unsafe(method(setDuration:forPage:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setDuration_forPage(&self, duration: NSTimeInterval, page: NSInteger);
205
206        /// Returns the duration for the specified page, and `preferredDuration` when there is no custom duration set
207        /// for the specified page.
208        #[unsafe(method(durationForPage:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn durationForPage(&self, page: NSInteger) -> NSTimeInterval;
211
212        #[unsafe(method(init))]
213        #[unsafe(method_family = init)]
214        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
215
216        #[unsafe(method(new))]
217        #[unsafe(method_family = new)]
218        pub unsafe fn new() -> Retained<Self>;
219    );
220}