Skip to content

Commit

Permalink
Added slices unit tests. Other improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
bartoszj committed Jun 27, 2016
1 parent 0a50a2b commit d1f2cfc
Show file tree
Hide file tree
Showing 37 changed files with 349 additions and 57 deletions.
6 changes: 6 additions & 0 deletions Images.xcassets/slices/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,48 @@
"resizing" : {
"mode" : "3-part-horizontal",
"center" : {
"mode" : "stretch",
"width" : 1
"mode" : "tile",
"width" : 4
},
"cap-insets" : {
"right" : 10,
"left" : 10
}
},
"idiom" : "universal",
"filename" : "green.png",
"filename" : "image.png",
"scale" : "1x"
},
{
"resizing" : {
"mode" : "3-part-vertical",
"mode" : "3-part-horizontal",
"center" : {
"mode" : "stretch",
"height" : 1
"width" : 9
},
"cap-insets" : {
"top" : 20,
"bottom" : 20
"right" : 19,
"left" : 20
}
},
"idiom" : "universal",
"filename" : "green@2x.png",
"filename" : "image@2x.png",
"scale" : "2x"
},
{
"resizing" : {
"mode" : "9-part",
"mode" : "3-part-horizontal",
"center" : {
"mode" : "stretch",
"width" : 1,
"height" : 1
"width" : 5
},
"cap-insets" : {
"bottom" : 30,
"top" : 30,
"right" : 29,
"left" : 30
"left" : 29
}
},
"idiom" : "universal",
"filename" : "green@3x.png",
"filename" : "image@3x.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"images" : [
{
"resizing" : {
"mode" : "9-part",
"center" : {
"mode" : "stretch",
"width" : 2,
"height" : 3
},
"cap-insets" : {
"bottom" : 12,
"top" : 10,
"right" : 13,
"left" : 11
}
},
"idiom" : "universal",
"filename" : "cyan.png",
"scale" : "1x"
},
{
"resizing" : {
"mode" : "9-part",
"center" : {
"mode" : "tile",
"width" : 6,
"height" : 2
},
"cap-insets" : {
"bottom" : 20,
"top" : 20,
"right" : 19,
"left" : 20
}
},
"idiom" : "universal",
"filename" : "cyan@2x.png",
"scale" : "2x"
},
{
"resizing" : {
"mode" : "9-part",
"center" : {
"mode" : "tile",
"width" : 8,
"height" : 2
},
"cap-insets" : {
"bottom" : 30,
"top" : 30,
"right" : 29,
"left" : 30
}
},
"idiom" : "universal",
"filename" : "cyan@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,34 +1,16 @@
{
"images" : [
{
"alignment-insets" : {
"top" : 1,
"left" : 2,
"bottom" : 3,
"right" : 4
},
"idiom" : "universal",
"filename" : "green.png",
"scale" : "1x"
},
{
"alignment-insets" : {
"top" : 5,
"left" : 6,
"bottom" : 7,
"right" : 8
},
"idiom" : "universal",
"filename" : "green@2x.png",
"scale" : "2x"
},
{
"alignment-insets" : {
"top" : 9,
"left" : 10,
"bottom" : 11,
"right" : 12
},
"idiom" : "universal",
"filename" : "green@3x.png",
"scale" : "3x"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,50 @@
"images" : [
{
"resizing" : {
"mode" : "3-part-horizontal",
"mode" : "3-part-vertical",
"center" : {
"mode" : "tile",
"width" : 1
"height" : 3
},
"cap-insets" : {
"right" : 10,
"left" : 10
"top" : 10,
"bottom" : 10
}
},
"idiom" : "universal",
"filename" : "green.png",
"filename" : "blue.png",
"scale" : "1x"
},
{
"resizing" : {
"mode" : "3-part-vertical",
"center" : {
"mode" : "tile",
"height" : 1
"mode" : "stretch",
"height" : 7
},
"cap-insets" : {
"top" : 20,
"bottom" : 20
}
},
"idiom" : "universal",
"filename" : "green@2x.png",
"filename" : "blue@2x.png",
"scale" : "2x"
},
{
"resizing" : {
"mode" : "9-part",
"mode" : "3-part-vertical",
"center" : {
"mode" : "tile",
"width" : 1,
"height" : 1
"height" : 11
},
"cap-insets" : {
"bottom" : 30,
"top" : 30,
"right" : 29,
"left" : 30
"top" : 29,
"bottom" : 29
}
},
"idiom" : "universal",
"filename" : "green@3x.png",
"filename" : "blue@3x.png",
"scale" : "3x"
}
],
Expand Down
Binary file added Images.xcassets/slices/s_vertical.imageset/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ or
- [x] Size class
- [x] Rendering
- [x] Alignment
- [ ] Slicing
- [x] Slicing
- [ ] Memory
- [ ] Graphics
- [ ] Data
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed Templates.xcassets/old/i_slice_tiles.imageset/green.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions acextract.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
961DF0011D0DDDFE002AD0CC /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9625C14A1A48C24A00EE5162 /* Images.xcassets */; };
9625C14B1A48C24A00EE5162 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9625C14A1A48C24A00EE5162 /* Images.xcassets */; };
9625C14C1A48C24A00EE5162 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9625C14A1A48C24A00EE5162 /* Images.xcassets */; };
9666CE251D21B363009C9402 /* SlicesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9666CE241D21B363009C9402 /* SlicesTests.swift */; };
9669A6361D20332D0037654D /* TemplateRenderingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9669A6351D20332D0037654D /* TemplateRenderingTests.swift */; };
966A50361A3DEBE0002C814F /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966A50351A3DEBE0002C814F /* main.swift */; };
966A504F1A3DF14C002C814F /* AssetsCatalog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 966A504E1A3DF14C002C814F /* AssetsCatalog.swift */; };
Expand Down Expand Up @@ -141,6 +142,7 @@
961DEFF31D0DDD2F002AD0CC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
961DEFF51D0DDD2F002AD0CC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
9625C14A1A48C24A00EE5162 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
9666CE241D21B363009C9402 /* SlicesTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SlicesTests.swift; sourceTree = "<group>"; };
9669A6351D20332D0037654D /* TemplateRenderingTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TemplateRenderingTests.swift; sourceTree = "<group>"; };
966A50321A3DEBE0002C814F /* acextract */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = acextract; sourceTree = BUILT_PRODUCTS_DIR; };
966A50351A3DEBE0002C814F /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -396,6 +398,7 @@
96D010821D173194000553B1 /* CorrectnessTests.swift */,
96F446651D15DB6F00F30964 /* DeviceTests.swift */,
96F52BFB1D1FFB89006CAD7B /* SizeClassTests.swift */,
9666CE241D21B363009C9402 /* SlicesTests.swift */,
9669A6351D20332D0037654D /* TemplateRenderingTests.swift */,
);
name = Tests;
Expand Down Expand Up @@ -771,6 +774,7 @@
960594241D19D96C00325995 /* PrintInformationOperation.swift in Sources */,
9673B97A1D205CE900F3C684 /* AlignmentTests.swift in Sources */,
96D010831D173194000553B1 /* CorrectnessTests.swift in Sources */,
9666CE251D21B363009C9402 /* SlicesTests.swift in Sources */,
961427121D1F1186005831AA /* Assets.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
57 changes: 51 additions & 6 deletions acextract/CoreUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,49 @@ typedef NS_ENUM(NSInteger, CUIImageType) {
CUIImageTypeHorizontalAndVertical = 3,
};

@class CUIRenditionKey, CUIThemeRendition;
@class CUIRenditionKey, CUIThemeRendition, CUIRenditionSliceInformation;

@interface CUINamedImage : NSObject
@interface CUINamedLookup : NSObject

@property(copy, nonatomic, nonnull) NSString *name;
@property(readonly, nonatomic) BOOL representsOnDemandContent;
- (nonnull CUIRenditionKey *)renditionKey;
- (nonnull NSString *)renditionName;
- (nonnull CUIThemeRendition *)_rendition;

@end

@interface CUINamedImage : CUINamedLookup
// Device idiom:
// - idiom()
// - subtype()
// - scale
//
// Size class:
// - sizeClassVertical()
// - sizeClassHorizontal()
//
// Alignment:
// - hasAlignmentInformation
// - alignmentEdgeInsets
//
// Slices:
// - hasSliceInformation
// - resizingMode
// - imageType
// - _rendition().type()
// - _rendition().sliceInformation()?.renditionType
// - _rendition().sliceInformation()?.edgeInsets
//
// Template:
// - isTemplate
// - templateRenderingMode

@property(readonly, nonatomic) int exifOrientation;
@property(readonly, nonatomic) CUIRenderMode templateRenderingMode;
@property(readonly, nonatomic) BOOL isTemplate;
@property(readonly, nonatomic) BOOL isVectorBased;
@property(readonly, nonatomic) BOOL hasAlignmentInformation;
@property(readonly, nonatomic) BOOL hasSliceInformation;
@property(readonly, nonatomic) CUIResizingMode resizingMode;
@property(readonly, nonatomic) int blendMode;
Expand All @@ -91,8 +125,7 @@ typedef NS_ENUM(NSInteger, CUIImageType) {
- (nonnull CUIRenditionKey *)baseKey;
- (long long)graphicsClass;
- (long long)memoryClass;
- (nonnull CUIThemeRendition *)_rendition;
- (nonnull CUIRenditionKey *)renditionKey;


@end

Expand All @@ -106,18 +139,30 @@ typedef NS_ENUM(NSInteger, CUIImageType) {
@interface CUIThemeRendition : NSObject

- (nonnull NSString *)name;
- (NSInteger)type;
- (CUIImageType)type;
- (unsigned int)subtype;
- (nullable NSString *)utiType;
- (nullable NSData *)data;
- (nullable CGPDFDocumentRef)pdfDocument;
- (nullable CUIRenditionSliceInformation *)sliceInformation;
- (nullable CGImageRef)unslicedImage;

@end

@interface CUIRenditionSliceInformation : NSObject <NSCopying>

@property(readonly, nonatomic) NSEdgeInsets edgeInsets;
@property(readonly, nonatomic) struct CGRect destinationRect;
@property(readonly, nonatomic) CUIImageType renditionType;
- (struct CGSize)_bottomRightCapSize;
- (struct CGSize)_topLeftCapSize;
- (nonnull NSString *)description;

@end

@interface CUICatalog : NSObject

- (nullable instancetype)initWithURL:(nonnull NSURL *)url error:(NSError * _Nullable __autoreleasing *_Nullable)error;
- (nullable instancetype)initWithURL:(nonnull NSURL *)url error:(NSError *_Nullable __autoreleasing *_Nullable)error;
- (nonnull NSArray<NSString *> *)allImageNames;
- (nonnull NSArray<CUINamedImage *> *)imagesWithName:(nonnull NSString *)name;

Expand Down
Loading

0 comments on commit d1f2cfc

Please sign in to comment.