use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionElementCategory(pub NSInteger);
impl NSCollectionElementCategory {
#[doc(alias = "NSCollectionElementCategoryItem")]
pub const Item: Self = Self(0);
#[doc(alias = "NSCollectionElementCategorySupplementaryView")]
pub const SupplementaryView: Self = Self(1);
#[doc(alias = "NSCollectionElementCategoryDecorationView")]
pub const DecorationView: Self = Self(2);
#[doc(alias = "NSCollectionElementCategoryInterItemGap")]
pub const InterItemGap: Self = Self(3);
}
unsafe impl Encode for NSCollectionElementCategory {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSCollectionElementCategory {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
pub type NSCollectionViewDecorationElementKind = NSString;
extern "C" {
#[cfg(feature = "NSCollectionView")]
pub static NSCollectionElementKindInterItemGapIndicator:
&'static NSCollectionViewSupplementaryElementKind;
}
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSCollectionViewLayoutAttributes;
);
extern_conformance!(
unsafe impl NSCopying for NSCollectionViewLayoutAttributes {}
);
unsafe impl CopyingHelper for NSCollectionViewLayoutAttributes {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for NSCollectionViewLayoutAttributes {}
);
impl NSCollectionViewLayoutAttributes {
extern_methods!(
#[unsafe(method(frame))]
#[unsafe(method_family = none)]
pub fn frame(&self) -> NSRect;
#[unsafe(method(setFrame:))]
#[unsafe(method_family = none)]
pub fn setFrame(&self, frame: NSRect);
#[unsafe(method(size))]
#[unsafe(method_family = none)]
pub fn size(&self) -> NSSize;
#[unsafe(method(setSize:))]
#[unsafe(method_family = none)]
pub fn setSize(&self, size: NSSize);
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(alpha))]
#[unsafe(method_family = none)]
pub fn alpha(&self) -> CGFloat;
#[cfg(feature = "objc2-core-foundation")]
#[unsafe(method(setAlpha:))]
#[unsafe(method_family = none)]
pub fn setAlpha(&self, alpha: CGFloat);
#[unsafe(method(zIndex))]
#[unsafe(method_family = none)]
pub fn zIndex(&self) -> NSInteger;
#[unsafe(method(setZIndex:))]
#[unsafe(method_family = none)]
pub fn setZIndex(&self, z_index: NSInteger);
#[unsafe(method(isHidden))]
#[unsafe(method_family = none)]
pub fn isHidden(&self) -> bool;
#[unsafe(method(setHidden:))]
#[unsafe(method_family = none)]
pub fn setHidden(&self, hidden: bool);
#[unsafe(method(indexPath))]
#[unsafe(method_family = none)]
pub fn indexPath(&self) -> Option<Retained<NSIndexPath>>;
#[unsafe(method(setIndexPath:))]
#[unsafe(method_family = none)]
pub fn setIndexPath(&self, index_path: Option<&NSIndexPath>);
#[unsafe(method(representedElementCategory))]
#[unsafe(method_family = none)]
pub fn representedElementCategory(&self) -> NSCollectionElementCategory;
#[unsafe(method(representedElementKind))]
#[unsafe(method_family = none)]
pub fn representedElementKind(&self) -> Option<Retained<NSString>>;
#[unsafe(method(layoutAttributesForItemWithIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForItemWithIndexPath(
index_path: &NSIndexPath,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[unsafe(method(layoutAttributesForInterItemGapBeforeIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForInterItemGapBeforeIndexPath(
index_path: &NSIndexPath,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(layoutAttributesForSupplementaryViewOfKind:withIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForSupplementaryViewOfKind_withIndexPath(
element_kind: &NSCollectionViewSupplementaryElementKind,
index_path: &NSIndexPath,
mtm: MainThreadMarker,
) -> Retained<Self>;
#[unsafe(method(layoutAttributesForDecorationViewOfKind:withIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForDecorationViewOfKind_withIndexPath(
decoration_view_kind: &NSCollectionViewDecorationElementKind,
index_path: &NSIndexPath,
mtm: MainThreadMarker,
) -> Retained<Self>;
);
}
impl NSCollectionViewLayoutAttributes {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSCollectionUpdateAction(pub NSInteger);
impl NSCollectionUpdateAction {
#[doc(alias = "NSCollectionUpdateActionInsert")]
pub const Insert: Self = Self(0);
#[doc(alias = "NSCollectionUpdateActionDelete")]
pub const Delete: Self = Self(1);
#[doc(alias = "NSCollectionUpdateActionReload")]
pub const Reload: Self = Self(2);
#[doc(alias = "NSCollectionUpdateActionMove")]
pub const Move: Self = Self(3);
#[doc(alias = "NSCollectionUpdateActionNone")]
pub const None: Self = Self(4);
}
unsafe impl Encode for NSCollectionUpdateAction {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSCollectionUpdateAction {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSCollectionViewUpdateItem;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSCollectionViewUpdateItem {}
);
impl NSCollectionViewUpdateItem {
extern_methods!(
#[unsafe(method(indexPathBeforeUpdate))]
#[unsafe(method_family = none)]
pub fn indexPathBeforeUpdate(&self) -> Option<Retained<NSIndexPath>>;
#[unsafe(method(indexPathAfterUpdate))]
#[unsafe(method_family = none)]
pub fn indexPathAfterUpdate(&self) -> Option<Retained<NSIndexPath>>;
#[unsafe(method(updateAction))]
#[unsafe(method_family = none)]
pub fn updateAction(&self) -> NSCollectionUpdateAction;
);
}
impl NSCollectionViewUpdateItem {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSCollectionViewLayoutInvalidationContext;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSCollectionViewLayoutInvalidationContext {}
);
impl NSCollectionViewLayoutInvalidationContext {
extern_methods!(
#[unsafe(method(invalidateEverything))]
#[unsafe(method_family = none)]
pub fn invalidateEverything(&self) -> bool;
#[unsafe(method(invalidateDataSourceCounts))]
#[unsafe(method_family = none)]
pub fn invalidateDataSourceCounts(&self) -> bool;
#[unsafe(method(invalidateItemsAtIndexPaths:))]
#[unsafe(method_family = none)]
pub fn invalidateItemsAtIndexPaths(&self, index_paths: &NSSet<NSIndexPath>);
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(invalidateSupplementaryElementsOfKind:atIndexPaths:))]
#[unsafe(method_family = none)]
pub fn invalidateSupplementaryElementsOfKind_atIndexPaths(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
index_paths: &NSSet<NSIndexPath>,
);
#[unsafe(method(invalidateDecorationElementsOfKind:atIndexPaths:))]
#[unsafe(method_family = none)]
pub fn invalidateDecorationElementsOfKind_atIndexPaths(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
index_paths: &NSSet<NSIndexPath>,
);
#[unsafe(method(invalidatedItemIndexPaths))]
#[unsafe(method_family = none)]
pub fn invalidatedItemIndexPaths(&self) -> Option<Retained<NSSet<NSIndexPath>>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(invalidatedSupplementaryIndexPaths))]
#[unsafe(method_family = none)]
pub fn invalidatedSupplementaryIndexPaths(
&self,
) -> Option<
Retained<NSDictionary<NSCollectionViewSupplementaryElementKind, NSSet<NSIndexPath>>>,
>;
#[unsafe(method(invalidatedDecorationIndexPaths))]
#[unsafe(method_family = none)]
pub fn invalidatedDecorationIndexPaths(
&self,
) -> Option<Retained<NSDictionary<NSCollectionViewDecorationElementKind, NSSet<NSIndexPath>>>>;
#[unsafe(method(contentOffsetAdjustment))]
#[unsafe(method_family = none)]
pub fn contentOffsetAdjustment(&self) -> NSPoint;
#[unsafe(method(setContentOffsetAdjustment:))]
#[unsafe(method_family = none)]
pub fn setContentOffsetAdjustment(&self, content_offset_adjustment: NSPoint);
#[unsafe(method(contentSizeAdjustment))]
#[unsafe(method_family = none)]
pub fn contentSizeAdjustment(&self) -> NSSize;
#[unsafe(method(setContentSizeAdjustment:))]
#[unsafe(method_family = none)]
pub fn setContentSizeAdjustment(&self, content_size_adjustment: NSSize);
);
}
impl NSCollectionViewLayoutInvalidationContext {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSCollectionViewLayout;
);
extern_conformance!(
unsafe impl NSCoding for NSCollectionViewLayout {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSCollectionViewLayout {}
);
impl NSCollectionViewLayout {
extern_methods!(
#[cfg(all(
feature = "NSCollectionView",
feature = "NSResponder",
feature = "NSView"
))]
#[unsafe(method(collectionView))]
#[unsafe(method_family = none)]
pub fn collectionView(&self) -> Option<Retained<NSCollectionView>>;
#[unsafe(method(invalidateLayout))]
#[unsafe(method_family = none)]
pub fn invalidateLayout(&self);
#[unsafe(method(invalidateLayoutWithContext:))]
#[unsafe(method_family = none)]
pub fn invalidateLayoutWithContext(
&self,
context: &NSCollectionViewLayoutInvalidationContext,
);
#[unsafe(method(registerClass:forDecorationViewOfKind:))]
#[unsafe(method_family = none)]
pub unsafe fn registerClass_forDecorationViewOfKind(
&self,
view_class: Option<&AnyClass>,
element_kind: &NSCollectionViewDecorationElementKind,
);
#[cfg(feature = "NSNib")]
#[unsafe(method(registerNib:forDecorationViewOfKind:))]
#[unsafe(method_family = none)]
pub fn registerNib_forDecorationViewOfKind(
&self,
nib: Option<&NSNib>,
element_kind: &NSCollectionViewDecorationElementKind,
);
);
}
impl NSCollectionViewLayout {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}
impl NSCollectionViewLayout {
extern_methods!(
#[unsafe(method(layoutAttributesClass))]
#[unsafe(method_family = none)]
pub fn layoutAttributesClass(mtm: MainThreadMarker) -> &'static AnyClass;
#[unsafe(method(invalidationContextClass))]
#[unsafe(method_family = none)]
pub fn invalidationContextClass(mtm: MainThreadMarker) -> &'static AnyClass;
#[unsafe(method(prepareLayout))]
#[unsafe(method_family = none)]
pub fn prepareLayout(&self);
#[unsafe(method(layoutAttributesForElementsInRect:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForElementsInRect(
&self,
rect: NSRect,
) -> Retained<NSArray<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(layoutAttributesForItemAtIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForItemAtIndexPath(
&self,
index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(layoutAttributesForSupplementaryViewOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForSupplementaryViewOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(layoutAttributesForDecorationViewOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForDecorationViewOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(layoutAttributesForDropTargetAtPoint:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForDropTargetAtPoint(
&self,
point_in_collection_view: NSPoint,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(layoutAttributesForInterItemGapBeforeIndexPath:))]
#[unsafe(method_family = none)]
pub fn layoutAttributesForInterItemGapBeforeIndexPath(
&self,
index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(shouldInvalidateLayoutForBoundsChange:))]
#[unsafe(method_family = none)]
pub fn shouldInvalidateLayoutForBoundsChange(&self, new_bounds: NSRect) -> bool;
#[unsafe(method(invalidationContextForBoundsChange:))]
#[unsafe(method_family = none)]
pub fn invalidationContextForBoundsChange(
&self,
new_bounds: NSRect,
) -> Retained<NSCollectionViewLayoutInvalidationContext>;
#[unsafe(method(shouldInvalidateLayoutForPreferredLayoutAttributes:withOriginalAttributes:))]
#[unsafe(method_family = none)]
pub fn shouldInvalidateLayoutForPreferredLayoutAttributes_withOriginalAttributes(
&self,
preferred_attributes: &NSCollectionViewLayoutAttributes,
original_attributes: &NSCollectionViewLayoutAttributes,
) -> bool;
#[unsafe(method(invalidationContextForPreferredLayoutAttributes:withOriginalAttributes:))]
#[unsafe(method_family = none)]
pub fn invalidationContextForPreferredLayoutAttributes_withOriginalAttributes(
&self,
preferred_attributes: &NSCollectionViewLayoutAttributes,
original_attributes: &NSCollectionViewLayoutAttributes,
) -> Retained<NSCollectionViewLayoutInvalidationContext>;
#[unsafe(method(targetContentOffsetForProposedContentOffset:withScrollingVelocity:))]
#[unsafe(method_family = none)]
pub fn targetContentOffsetForProposedContentOffset_withScrollingVelocity(
&self,
proposed_content_offset: NSPoint,
velocity: NSPoint,
) -> NSPoint;
#[unsafe(method(targetContentOffsetForProposedContentOffset:))]
#[unsafe(method_family = none)]
pub fn targetContentOffsetForProposedContentOffset(
&self,
proposed_content_offset: NSPoint,
) -> NSPoint;
#[unsafe(method(collectionViewContentSize))]
#[unsafe(method_family = none)]
pub fn collectionViewContentSize(&self) -> NSSize;
);
}
impl NSCollectionViewLayout {
extern_methods!(
#[unsafe(method(prepareForCollectionViewUpdates:))]
#[unsafe(method_family = none)]
pub fn prepareForCollectionViewUpdates(
&self,
update_items: &NSArray<NSCollectionViewUpdateItem>,
);
#[unsafe(method(finalizeCollectionViewUpdates))]
#[unsafe(method_family = none)]
pub fn finalizeCollectionViewUpdates(&self);
#[unsafe(method(prepareForAnimatedBoundsChange:))]
#[unsafe(method_family = none)]
pub fn prepareForAnimatedBoundsChange(&self, old_bounds: NSRect);
#[unsafe(method(finalizeAnimatedBoundsChange))]
#[unsafe(method_family = none)]
pub fn finalizeAnimatedBoundsChange(&self);
#[unsafe(method(prepareForTransitionToLayout:))]
#[unsafe(method_family = none)]
pub fn prepareForTransitionToLayout(&self, new_layout: &NSCollectionViewLayout);
#[unsafe(method(prepareForTransitionFromLayout:))]
#[unsafe(method_family = none)]
pub fn prepareForTransitionFromLayout(&self, old_layout: &NSCollectionViewLayout);
#[unsafe(method(finalizeLayoutTransition))]
#[unsafe(method_family = none)]
pub fn finalizeLayoutTransition(&self);
#[unsafe(method(initialLayoutAttributesForAppearingItemAtIndexPath:))]
#[unsafe(method_family = none)]
pub fn initialLayoutAttributesForAppearingItemAtIndexPath(
&self,
item_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(finalLayoutAttributesForDisappearingItemAtIndexPath:))]
#[unsafe(method_family = none)]
pub fn finalLayoutAttributesForDisappearingItemAtIndexPath(
&self,
item_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(initialLayoutAttributesForAppearingSupplementaryElementOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn initialLayoutAttributesForAppearingSupplementaryElementOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
element_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(finalLayoutAttributesForDisappearingSupplementaryElementOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn finalLayoutAttributesForDisappearingSupplementaryElementOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
element_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(initialLayoutAttributesForAppearingDecorationElementOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn initialLayoutAttributesForAppearingDecorationElementOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
decoration_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[unsafe(method(finalLayoutAttributesForDisappearingDecorationElementOfKind:atIndexPath:))]
#[unsafe(method_family = none)]
pub fn finalLayoutAttributesForDisappearingDecorationElementOfKind_atIndexPath(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
decoration_index_path: &NSIndexPath,
) -> Option<Retained<NSCollectionViewLayoutAttributes>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(indexPathsToDeleteForSupplementaryViewOfKind:))]
#[unsafe(method_family = none)]
pub fn indexPathsToDeleteForSupplementaryViewOfKind(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
) -> Retained<NSSet<NSIndexPath>>;
#[unsafe(method(indexPathsToDeleteForDecorationViewOfKind:))]
#[unsafe(method_family = none)]
pub fn indexPathsToDeleteForDecorationViewOfKind(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
) -> Retained<NSSet<NSIndexPath>>;
#[cfg(feature = "NSCollectionView")]
#[unsafe(method(indexPathsToInsertForSupplementaryViewOfKind:))]
#[unsafe(method_family = none)]
pub fn indexPathsToInsertForSupplementaryViewOfKind(
&self,
element_kind: &NSCollectionViewSupplementaryElementKind,
) -> Retained<NSSet<NSIndexPath>>;
#[unsafe(method(indexPathsToInsertForDecorationViewOfKind:))]
#[unsafe(method_family = none)]
pub fn indexPathsToInsertForDecorationViewOfKind(
&self,
element_kind: &NSCollectionViewDecorationElementKind,
) -> Retained<NSSet<NSIndexPath>>;
);
}