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        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        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
54extern_conformance!(
55    unsafe impl NSObjectProtocol for UIPageControlProgress {}
56);
57
58impl UIPageControlProgress {
59    extern_methods!(
60        /// An object that defines the delegate of the page control progress.
61        #[unsafe(method(delegate))]
62        #[unsafe(method_family = none)]
63        pub fn delegate(
64            &self,
65        ) -> Option<Retained<ProtocolObject<dyn UIPageControlProgressDelegate>>>;
66
67        /// Setter for [`delegate`][Self::delegate].
68        ///
69        /// This is a [weak property][objc2::topics::weak_property].
70        #[unsafe(method(setDelegate:))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setDelegate(
73            &self,
74            delegate: Option<&ProtocolObject<dyn UIPageControlProgressDelegate>>,
75        );
76
77        /// The current progress value of the active page control indicator, between 0 and 1.
78        /// Values outside of [0...1] will be clamped.
79        #[unsafe(method(currentProgress))]
80        #[unsafe(method_family = none)]
81        pub fn currentProgress(&self) -> c_float;
82
83        /// Setter for [`currentProgress`][Self::currentProgress].
84        #[unsafe(method(setCurrentProgress:))]
85        #[unsafe(method_family = none)]
86        pub fn setCurrentProgress(&self, current_progress: c_float);
87
88        /// Returns `YES` if the progress indicator is visible. The progress indicator is hidden when
89        /// the user is actively interacting with the `UIPageControl`.
90        #[unsafe(method(isProgressVisible))]
91        #[unsafe(method_family = none)]
92        pub fn isProgressVisible(&self) -> bool;
93    );
94}
95
96/// Methods declared on superclass `NSObject`.
97impl UIPageControlProgress {
98    extern_methods!(
99        #[unsafe(method(init))]
100        #[unsafe(method_family = init)]
101        pub fn init(this: Allocated<Self>) -> Retained<Self>;
102
103        #[unsafe(method(new))]
104        #[unsafe(method_family = new)]
105        pub fn new() -> Retained<Self>;
106    );
107}
108
109impl DefaultRetained for UIPageControlProgress {
110    #[inline]
111    fn default_retained() -> Retained<Self> {
112        Self::new()
113    }
114}
115
116extern_protocol!(
117    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontroltimerprogressdelegate?language=objc)
118    pub unsafe trait UIPageControlTimerProgressDelegate:
119        UIPageControlProgressDelegate
120    {
121        /// Called when the progress has changed from the time interval progress.
122        #[optional]
123        #[unsafe(method(pageControlTimerProgressDidChange:))]
124        #[unsafe(method_family = none)]
125        fn pageControlTimerProgressDidChange(&self, progress: &UIPageControlTimerProgress);
126
127        /// Determines if the time interval progress should advance to the next page upon progress completion of
128        /// the current page's duration. Default is YES.
129        #[optional]
130        #[unsafe(method(pageControlTimerProgress:shouldAdvanceToPage:))]
131        #[unsafe(method_family = none)]
132        fn pageControlTimerProgress_shouldAdvanceToPage(
133            &self,
134            progress: &UIPageControlTimerProgress,
135            page: NSInteger,
136        ) -> bool;
137    }
138);
139
140extern_class!(
141    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uipagecontroltimerprogress?language=objc)
142    #[unsafe(super(UIPageControlProgress, NSObject))]
143    #[derive(Debug, PartialEq, Eq, Hash)]
144    pub struct UIPageControlTimerProgress;
145);
146
147extern_conformance!(
148    unsafe impl NSObjectProtocol for UIPageControlTimerProgress {}
149);
150
151impl UIPageControlTimerProgress {
152    extern_methods!(
153        /// Creates a time interval progress with a specified preferred duration.
154        #[unsafe(method(initWithPreferredDuration:))]
155        #[unsafe(method_family = init)]
156        pub fn initWithPreferredDuration(
157            this: Allocated<Self>,
158            preferred_duration: NSTimeInterval,
159        ) -> Retained<Self>;
160
161        /// An object that defines the delegate of the page control progress.
162        #[unsafe(method(delegate))]
163        #[unsafe(method_family = none)]
164        pub fn delegate(
165            &self,
166        ) -> Option<Retained<ProtocolObject<dyn UIPageControlTimerProgressDelegate>>>;
167
168        /// Setter for [`delegate`][Self::delegate].
169        ///
170        /// This is a [weak property][objc2::topics::weak_property].
171        #[unsafe(method(setDelegate:))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn setDelegate(
174            &self,
175            delegate: Option<&ProtocolObject<dyn UIPageControlTimerProgressDelegate>>,
176        );
177
178        /// Determines if the page control should loop back to page 0 after the last page. Default is NO.
179        #[unsafe(method(resetsToInitialPageAfterEnd))]
180        #[unsafe(method_family = none)]
181        pub fn resetsToInitialPageAfterEnd(&self) -> bool;
182
183        /// Setter for [`resetsToInitialPageAfterEnd`][Self::resetsToInitialPageAfterEnd].
184        #[unsafe(method(setResetsToInitialPageAfterEnd:))]
185        #[unsafe(method_family = none)]
186        pub fn setResetsToInitialPageAfterEnd(&self, resets_to_initial_page_after_end: bool);
187
188        /// Returns YES if the timer is currently active.
189        #[unsafe(method(isRunning))]
190        #[unsafe(method_family = none)]
191        pub fn isRunning(&self) -> bool;
192
193        /// Resume the timer if it is not currently active.
194        #[unsafe(method(resumeTimer))]
195        #[unsafe(method_family = none)]
196        pub fn resumeTimer(&self);
197
198        /// Pause the timer if it is active.
199        #[unsafe(method(pauseTimer))]
200        #[unsafe(method_family = none)]
201        pub fn pauseTimer(&self);
202
203        /// The preferred duration for the time interval progress, used when there is no custom page duration set for the current page.
204        /// The preferred duration must be greater than 0.0
205        #[unsafe(method(preferredDuration))]
206        #[unsafe(method_family = none)]
207        pub fn preferredDuration(&self) -> NSTimeInterval;
208
209        /// Setter for [`preferredDuration`][Self::preferredDuration].
210        #[unsafe(method(setPreferredDuration:))]
211        #[unsafe(method_family = none)]
212        pub fn setPreferredDuration(&self, preferred_duration: NSTimeInterval);
213
214        /// Sets a custom duration for the specified page. Set 0.0 to remove the custom duration for the specified page.
215        #[unsafe(method(setDuration:forPage:))]
216        #[unsafe(method_family = none)]
217        pub fn setDuration_forPage(&self, duration: NSTimeInterval, page: NSInteger);
218
219        /// Returns the duration for the specified page, and `preferredDuration` when there is no custom duration set
220        /// for the specified page.
221        #[unsafe(method(durationForPage:))]
222        #[unsafe(method_family = none)]
223        pub fn durationForPage(&self, page: NSInteger) -> NSTimeInterval;
224
225        #[unsafe(method(init))]
226        #[unsafe(method_family = init)]
227        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
228
229        #[unsafe(method(new))]
230        #[unsafe(method_family = new)]
231        pub unsafe fn new() -> Retained<Self>;
232    );
233}