Skip to content

Commit

Permalink
[AppKit/UIKit] Share the implementation of some enums between AppKit …
Browse files Browse the repository at this point in the history
…and UIKit. (#12164)

* [AppKit/UIKit] Merge the definitions of NSDirectionalRectEdge.

* [AppKit/UIKit] Merge the definitions of NSControlCharacterAction.

The enum values weren't the same between AppKit and UIKit, but I picked the
AppKit ones since they looked better, added those to every platform, and
deprecated the other ones where they existed.

Except on Mac Catalyst, where I removed instead of deprecating, since we don't
need to consider backwards compatibility.

* [AppKit/UIKit] Merge the definitions of NSGlyphProperty.

* [AppKit/UIKit] Merge the definitions of NSLayoutAttribute and NSLayoutFormatOptions.

* [AppKit/UIKit] Merge the definitions of NSLayoutRelation.

* [AppKit/UIKit] Merge the definitions of NSLineBreakStrategy.

* [AppKit/UIKit] Merge the definitions of NSRectAlignment.
  • Loading branch information
rolfbjarne authored Jul 22, 2021
1 parent a150c1d commit b4c2185
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 248 deletions.
86 changes: 0 additions & 86 deletions src/AppKit/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,58 +2421,6 @@ public enum NSEventGestureAxis : long {
None, Horizontal, Vertical
}

[Native]
public enum NSLayoutRelation : long {
LessThanOrEqual = -1,
Equal = 0,
GreaterThanOrEqual = 1
}

[Native]
public enum NSLayoutAttribute : long {
NoAttribute = 0,
Left = 1,
Right,
Top,
Bottom,
Leading,
Trailing,
Width,
Height,
CenterX,
CenterY,
Baseline,
[Mac (10,11)] LastBaseline = Baseline,
[Mac (10,11)] FirstBaseline,
}

[Flags]
[Native]
public enum NSLayoutFormatOptions : ulong {
None = 0,

AlignAllLeft = (1 << (int)NSLayoutAttribute.Left),
AlignAllRight = (1 << (int)NSLayoutAttribute.Right),
AlignAllTop = (1 << (int)NSLayoutAttribute.Top),
AlignAllBottom = (1 << (int)NSLayoutAttribute.Bottom),
AlignAllLeading = (1 << (int)NSLayoutAttribute.Leading),
AlignAllTrailing = (1 << (int)NSLayoutAttribute.Trailing),
AlignAllCenterX = (1 << (int)NSLayoutAttribute.CenterX),
AlignAllCenterY = (1 << (int)NSLayoutAttribute.CenterY),
AlignAllBaseline = (1 << (int)NSLayoutAttribute.Baseline),
[Mac (10,11)] AlignAllLastBaseline = (int)AlignAllBaseline,
[Mac (10,11)] AlignAllFirstBaseline = (1 << (int)NSLayoutAttribute.FirstBaseline),
AlignmentMask = 0xFFFF,

/* choose only one of these three
*/
DirectionLeadingToTrailing = 0 << 16, // default
DirectionLeftToRight = 1 << 16,
DirectionRightToLeft = 2 << 16,

DirectionMask = 0x3 << 16,
}

[Native]
public enum NSLayoutConstraintOrientation : long {
Horizontal, Vertical
Expand Down Expand Up @@ -2766,29 +2714,6 @@ public enum NSSpringLoadingOptions : ulong
NoHover = 1 << 3
}

[Mac (10,11)]
[Native]
public enum NSGlyphProperty : long
{
Null = (1 << 0),
ControlCharacter = (1 << 1),
Elastic = (1 << 2),
NonBaseCharacter = (1 << 3)
}

[Flags]
[Mac (10,11)]
[Native]
public enum NSControlCharacterAction : long
{
ZeroAdvancement = (1 << 0),
Whitespace = (1 << 1),
HorizontalTab = (1 << 2),
LineBreak = (1 << 3),
ParagraphBreak = (1 << 4),
ContainerBreak = (1 << 5)
}

[Flags]
[Mac (10,12)]
[Native]
Expand Down Expand Up @@ -3106,15 +3031,4 @@ public enum NSImageSymbolScale : long
Medium = 2,
Large = 3,
}

[Mac (11,0)]
[Flags]
[Native]
public enum NSLineBreakStrategy : ulong
{
None = 0x0,
PushOut = 1uL << 0,
HangulWordPriority = 1uL << 1,
Standard = 0xffff,
}
}
135 changes: 0 additions & 135 deletions src/UIKit/UIEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,84 +1177,6 @@ public enum UITextGranularity : long {
Document
}

// NSInteger -> UITextInput.h
[Native]
[NoWatch]
public enum NSLayoutRelation : long {
LessThanOrEqual = -1,
Equal = 0,
GreaterThanOrEqual = 1
}

// NSInteger -> NSLayoutConstraint.h
[Native]
[NoWatch]
public enum NSLayoutAttribute : long {
NoAttribute = 0,
Left = 1,
Right,
Top,
Bottom,
Leading,
Trailing,
Width,
Height,
CenterX,
CenterY,
Baseline,
LastBaseline = Baseline,
FirstBaseline,

[iOS (8,0)]
LeftMargin,
[iOS (8,0)]
RightMargin,
[iOS (8,0)]
TopMargin,
[iOS (8,0)]
BottomMargin,
[iOS (8,0)]
LeadingMargin,
[iOS (8,0)]
TrailingMargin,
[iOS (8,0)]
CenterXWithinMargins,
[iOS (8,0)]
CenterYWithinMargins,
}

// NSUInteger -> NSLayoutConstraint.h
[Native]
[Flags]
[NoWatch]
public enum NSLayoutFormatOptions : ulong {
AlignAllLeft = (1 << (int) NSLayoutAttribute.Left),
AlignAllRight = (1 << (int) NSLayoutAttribute.Right),
AlignAllTop = (1 << (int) NSLayoutAttribute.Top),
AlignAllBottom = (1 << (int) NSLayoutAttribute.Bottom),
AlignAllLeading = (1 << (int) NSLayoutAttribute.Leading),
AlignAllTrailing = (1 << (int) NSLayoutAttribute.Trailing),
AlignAllCenterX = (1 << (int) NSLayoutAttribute.CenterX),
AlignAllCenterY = (1 << (int) NSLayoutAttribute.CenterY),
AlignAllBaseline = (1 << (int) NSLayoutAttribute.Baseline),
AlignAllLastBaseline = (1 << (int) NSLayoutAttribute.LastBaseline),
AlignAllFirstBaseline = (1 << (int) NSLayoutAttribute.FirstBaseline),

AlignmentMask = 0xFFFF,

/* choose only one of these three
*/
DirectionLeadingToTrailing = 0 << 16, // default
DirectionLeftToRight = 1 << 16,
DirectionRightToLeft = 2 << 16,

SpacingEdgeToEdge = 0 << 19,
SpacingBaselineToBaseline = 1 << 19,
SpacingMask = 1 << 19,

DirectionMask = 0x3 << 16,
}

// float (and not even a CGFloat) -> NSLayoutConstraint.h
// the API were fixed (a long time ago to use `float`) and the enum
// values can still be used (and useful) since they will be casted
Expand Down Expand Up @@ -1496,28 +1418,6 @@ public enum UIPushBehaviorMode : long {
Instantaneous
}

// NSInteger -> NSLayoutManager.h
[Native]
[NoWatch]
public enum NSGlyphProperty : long {
Null = (1 << 0),
ControlCharacter = (1 << 1),
Elastic = (1 << 2),
NonBaseCharacter = (1 << 3)
}

// NSInteger -> NSLayoutManager.h
[Native]
[NoWatch]
public enum NSControlCharacterAction : long {
ZeroAdvancementAction = (1 << 0),
WhitespaceAction = (1 << 1),
HorizontalTabAction = (1 << 2),
LineBreakAction = (1 << 3),
ParagraphBreakAction = (1 << 4),
ContainerBreakAction = (1 << 5)
}

// NSInteger -> UITabBar.h
[Native]
[NoWatch]
Expand Down Expand Up @@ -2602,31 +2502,6 @@ public enum UICollectionLayoutSectionOrthogonalScrollingBehavior : long {
GroupPagingCentered,
}

[Flags, Watch (6,0), TV (13,0), iOS (13,0)]
[Native]
public enum NSDirectionalRectEdge : ulong {
None = 0x0,
Top = 1uL << 0,
Leading = 1uL << 1,
Bottom = 1uL << 2,
Trailing = 1uL << 3,
All = Top | Leading | Bottom | Trailing,
}

[Watch (6,0), TV (13,0), iOS (13,0)]
[Native]
public enum NSRectAlignment : long {
None = 0,
Top,
TopLeading,
Leading,
BottomLeading,
Bottom,
BottomTrailing,
Trailing,
TopTrailing,
}

[TV (13,0), NoWatch, iOS (13,0)]
[Native]
public enum UIAccessibilityContrast : long {
Expand Down Expand Up @@ -3158,16 +3033,6 @@ public enum UINavigationItemBackButtonDisplayMode : long {
Minimal = 2,
}

[Watch (7,0), TV (14,0), iOS (14,0)]
[Flags]
[Native]
public enum NSLineBreakStrategy : ulong {
None = 0x0,
PushOut = 1uL << 0,
HangulWordPriority = 1uL << 1,
Standard = 0xffff,
}

// NSInteger -> UIGuidedAccessRestrictions.h
[Native]
[NoWatch]
Expand Down
27 changes: 0 additions & 27 deletions src/appkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26341,18 +26341,6 @@ public enum NSCollectionLayoutSectionOrthogonalScrollingBehavior : long
GroupPagingCentered,
}

[Flags, Mac (10,15)]
[Native]
public enum NSDirectionalRectEdge : ulong
{
None = 0x0,
Top = 1uL << 0,
Leading = 1uL << 1,
Bottom = 1uL << 2,
Trailing = 1uL << 3,
All = Top | Leading | Bottom | Trailing,
}

[Mac (10,15)]
[Native]
public enum NSPickerTouchBarItemControlRepresentation : long
Expand All @@ -26371,21 +26359,6 @@ public enum NSPickerTouchBarItemSelectionMode : long
Momentary = 2,
}

[Mac (10,15)]
[Native]
public enum NSRectAlignment : long
{
None = 0,
Top,
TopLeading,
Leading,
BottomLeading,
Bottom,
BottomTrailing,
Trailing,
TopTrailing,
}

[Mac (10,15)]
[Native]
public enum NSTextInputTraitType : long
Expand Down
Loading

1 comment on commit b4c2185

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 Tests failed catastrophically on Build (no summary found). 🔥

Result file $(TEST_SUMMARY_PATH) not found.

Pipeline on Agent XAMBOT-1025.BigSur'
[AppKit/UIKit] Share the implementation of some enums between AppKit and UIKit. (#12164)

Please sign in to comment.