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