mirror of
https://github.com/rive-app/rive-ios.git
synced 2026-01-18 17:11:28 +01:00
Drop the ColumnLimit to 80 for clang-format
This gives better support for smaller screens and side-by-side windows. Also standardize the formatting check on GitHub on version 17. Diffs= e52e9fff29 Drop the ColumnLimit to 80 for clang-format (#8320) Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
This commit is contained in:
@@ -1 +1 @@
|
||||
52913023ba59036aa8f96685f1df5d9173551f72
|
||||
e52e9fff2973ce63a689e9d11ea283214109ca18
|
||||
|
||||
@@ -18,16 +18,19 @@
|
||||
andFactory:(RiveFactory*)factory
|
||||
{
|
||||
// TODO: Error handling
|
||||
// TODO: Track tasks, so we can cancel them if we garbage collect the asset loader
|
||||
// TODO: Track tasks, so we can cancel them if we garbage collect the asset
|
||||
// loader
|
||||
|
||||
if ([[asset cdnUuid] length] > 0)
|
||||
{
|
||||
NSURL* URL = [NSURL
|
||||
URLWithString:[NSString
|
||||
stringWithFormat:@"%@/%@", [asset cdnBaseUrl], [asset cdnUuid]]];
|
||||
NSURL* URL =
|
||||
[NSURL URLWithString:[NSString stringWithFormat:@"%@/%@",
|
||||
[asset cdnBaseUrl],
|
||||
[asset cdnUuid]]];
|
||||
NSURLSessionTask* task = [[NSURLSession sharedSession]
|
||||
downloadTaskWithURL:URL
|
||||
completionHandler:^(NSURL* location, NSURLResponse* response, NSError* error) {
|
||||
completionHandler:^(
|
||||
NSURL* location, NSURLResponse* response, NSError* error) {
|
||||
if (!error)
|
||||
{
|
||||
// Load the data into the reader
|
||||
@@ -39,14 +42,15 @@
|
||||
}
|
||||
else if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
[(RiveImageAsset*)asset renderImage:[factory decodeImage:data]];
|
||||
[(RiveImageAsset*)asset
|
||||
renderImage:[factory decodeImage:data]];
|
||||
}
|
||||
}
|
||||
}];
|
||||
|
||||
// Kick off the http download
|
||||
// QUESTION: Do we need to tie this into the RiveFile so we can wait for these loads to be
|
||||
// completed?
|
||||
// QUESTION: Do we need to tie this into the RiveFile so we can wait for
|
||||
// these loads to be completed?
|
||||
[task resume];
|
||||
return true;
|
||||
}
|
||||
@@ -79,7 +83,9 @@
|
||||
{
|
||||
for (RiveFileAssetLoader* loader in loaders)
|
||||
{
|
||||
if ([loader loadContentsWithAsset:asset andData:data andFactory:factory])
|
||||
if ([loader loadContentsWithAsset:asset
|
||||
andData:data
|
||||
andFactory:factory])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -188,10 +188,12 @@ void CoreGraphicsRenderPath::rewind()
|
||||
path = CGPathCreateMutable();
|
||||
}
|
||||
|
||||
void CoreGraphicsRenderPath::addRenderPath(RenderPath* path, const Mat2D& transform)
|
||||
void CoreGraphicsRenderPath::addRenderPath(RenderPath* path,
|
||||
const Mat2D& transform)
|
||||
{
|
||||
// NSLog(@" --- RenderPath::addPath");
|
||||
CGMutablePathRef pathToAdd = reinterpret_cast<CoreGraphicsRenderPath*>(path)->getPath();
|
||||
CGMutablePathRef pathToAdd =
|
||||
reinterpret_cast<CoreGraphicsRenderPath*>(path)->getPath();
|
||||
CGAffineTransform affineTransform = CGAffineTransformMake(transform.xx(),
|
||||
transform.xy(),
|
||||
transform.yx(),
|
||||
@@ -224,10 +226,11 @@ void CoreGraphicsRenderPath::lineTo(float x, float y)
|
||||
CGPathAddLineToPoint(path, NULL, x, y);
|
||||
}
|
||||
|
||||
void CoreGraphicsRenderPath::cubicTo(float ox, float oy, float ix, float iy, float x, float y)
|
||||
void CoreGraphicsRenderPath::cubicTo(
|
||||
float ox, float oy, float ix, float iy, float x, float y)
|
||||
{
|
||||
// NSLog(@" --- call to RenderPath::cubicTo %.1f, %.1f, %.1f, %.1f, %.1f, %.1f, ", ox, oy,
|
||||
// ix, iy, x, y);
|
||||
// NSLog(@" --- call to RenderPath::cubicTo %.1f, %.1f, %.1f, %.1f, %.1f,
|
||||
// %.1f, ", ox, oy, ix, iy, x, y);
|
||||
CGPathAddCurveToPoint(path, NULL, ox, oy, ix, iy, x, y);
|
||||
}
|
||||
|
||||
@@ -254,9 +257,12 @@ void CoreGraphicsRenderer::restore()
|
||||
|
||||
void CoreGraphicsRenderer::drawPath(RenderPath* path, RenderPaint* paint)
|
||||
{
|
||||
// NSLog(@" --- Renderer::drawPath path for type %d", rivePaint->paintStyle);
|
||||
CoreGraphicsRenderPaint* rivePaint = reinterpret_cast<CoreGraphicsRenderPaint*>(paint);
|
||||
CoreGraphicsRenderPath* rivePath = reinterpret_cast<CoreGraphicsRenderPath*>(path);
|
||||
// NSLog(@" --- Renderer::drawPath path for type %d",
|
||||
// rivePaint->paintStyle);
|
||||
CoreGraphicsRenderPaint* rivePaint =
|
||||
reinterpret_cast<CoreGraphicsRenderPaint*>(paint);
|
||||
CoreGraphicsRenderPath* rivePath =
|
||||
reinterpret_cast<CoreGraphicsRenderPath*>(path);
|
||||
|
||||
// Apply the stroke join
|
||||
if (rivePaint->strokeJoin != CoreGraphicsStrokeJoin::None)
|
||||
@@ -381,8 +387,8 @@ void CoreGraphicsRenderer::drawPath(RenderPath* path, RenderPaint* paint)
|
||||
// Draw gradient
|
||||
if (rivePaint->gradientType != CoreGraphicsGradient::None)
|
||||
{
|
||||
// If the path is a stroke, then convert the path to a stroked path to prevent the gradient
|
||||
// from filling the path
|
||||
// If the path is a stroke, then convert the path to a stroked path to
|
||||
// prevent the gradient from filling the path
|
||||
if (rivePaint->paintStyle == CoreGraphicsPaintStyle::Stroke)
|
||||
{
|
||||
CGContextSetLineWidth(ctx, rivePaint->paintThickness);
|
||||
@@ -395,8 +401,11 @@ void CoreGraphicsRenderer::drawPath(RenderPath* path, RenderPaint* paint)
|
||||
|
||||
if (rivePaint->gradientType == CoreGraphicsGradient::Linear)
|
||||
{
|
||||
CGContextDrawLinearGradient(
|
||||
ctx, rivePaint->gradient, rivePaint->gradientStart, rivePaint->gradientEnd, 0x3);
|
||||
CGContextDrawLinearGradient(ctx,
|
||||
rivePaint->gradient,
|
||||
rivePaint->gradientStart,
|
||||
rivePaint->gradientEnd,
|
||||
0x3);
|
||||
}
|
||||
else if (rivePaint->gradientType == CoreGraphicsGradient::Radial)
|
||||
{
|
||||
@@ -429,7 +438,8 @@ void CoreGraphicsRenderer::drawPath(RenderPath* path, RenderPaint* paint)
|
||||
void CoreGraphicsRenderer::clipPath(RenderPath* path)
|
||||
{
|
||||
// NSLog(@" --- Renderer::clipPath %@", clipPath);
|
||||
const CGPath* clipPath = reinterpret_cast<CoreGraphicsRenderPath*>(path)->getPath();
|
||||
const CGPath* clipPath =
|
||||
reinterpret_cast<CoreGraphicsRenderPath*>(path)->getPath();
|
||||
CGContextAddPath(ctx, clipPath);
|
||||
if (!CGContextIsPathEmpty(ctx))
|
||||
CGContextClip(ctx);
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
rive::FileAssetLoaderAdapter::FileAssetLoaderAdapter(RiveFileAssetLoader* myLoader)
|
||||
rive::FileAssetLoaderAdapter::FileAssetLoaderAdapter(
|
||||
RiveFileAssetLoader* myLoader)
|
||||
{
|
||||
loader = myLoader;
|
||||
}
|
||||
@@ -26,21 +27,27 @@ bool rive::FileAssetLoaderAdapter::loadContents(rive::FileAsset& asset,
|
||||
RiveFactory* myFactory = [[RiveFactory alloc] initWithFactory:factory];
|
||||
if (asset.is<rive::FontAsset>())
|
||||
{
|
||||
RiveFontAsset* fontAsset =
|
||||
[[RiveFontAsset alloc] initWithFileAsset:asset.as<rive::FontAsset>()];
|
||||
return [loader loadContentsWithAsset:fontAsset andData:data andFactory:myFactory];
|
||||
RiveFontAsset* fontAsset = [[RiveFontAsset alloc]
|
||||
initWithFileAsset:asset.as<rive::FontAsset>()];
|
||||
return [loader loadContentsWithAsset:fontAsset
|
||||
andData:data
|
||||
andFactory:myFactory];
|
||||
}
|
||||
else if (asset.is<rive::ImageAsset>())
|
||||
{
|
||||
RiveImageAsset* imageAsset =
|
||||
[[RiveImageAsset alloc] initWithFileAsset:asset.as<rive::ImageAsset>()];
|
||||
return [loader loadContentsWithAsset:imageAsset andData:data andFactory:myFactory];
|
||||
RiveImageAsset* imageAsset = [[RiveImageAsset alloc]
|
||||
initWithFileAsset:asset.as<rive::ImageAsset>()];
|
||||
return [loader loadContentsWithAsset:imageAsset
|
||||
andData:data
|
||||
andFactory:myFactory];
|
||||
}
|
||||
else if (asset.is<rive::AudioAsset>())
|
||||
{
|
||||
RiveAudioAsset* audioAsset =
|
||||
[[RiveAudioAsset alloc] initWithFileAsset:asset.as<rive::AudioAsset>()];
|
||||
return [loader loadContentsWithAsset:audioAsset andData:data andFactory:myFactory];
|
||||
RiveAudioAsset* audioAsset = [[RiveAudioAsset alloc]
|
||||
initWithFileAsset:asset.as<rive::AudioAsset>()];
|
||||
return [loader loadContentsWithAsset:audioAsset
|
||||
andData:data
|
||||
andFactory:myFactory];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,8 @@
|
||||
|
||||
if (animation == nil)
|
||||
{
|
||||
return [NSString stringWithCString:"Unknown" encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:"Unknown"
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
return [NSString stringWithCString:animation->name().c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
- (void)endFrame:(MTKView*)view
|
||||
withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
{}
|
||||
|
||||
@end
|
||||
@@ -45,7 +46,8 @@
|
||||
rive::rcp<rive::gpu::RenderTargetMetal> _renderTarget;
|
||||
}
|
||||
|
||||
static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLDevice> gpu)
|
||||
static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(
|
||||
id<MTLDevice> gpu)
|
||||
{
|
||||
return rive::gpu::RenderContextMetalImpl::MakeContext(
|
||||
gpu, rive::gpu::RenderContextMetalImpl::ContextOptions());
|
||||
@@ -53,8 +55,8 @@ static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLD
|
||||
|
||||
- (instancetype)init
|
||||
{
|
||||
// Make a single static RenderContext, since it is also the factory and any objects it
|
||||
// creates may outlive this 'RiveContext' instance.
|
||||
// Make a single static RenderContext, since it is also the factory and any
|
||||
// objects it creates may outlive this 'RiveContext' instance.
|
||||
static id<MTLDevice> s_plsGPU = MTLCreateSystemDefaultDevice();
|
||||
static std::unique_ptr<rive::gpu::RenderContext> s_renderContext =
|
||||
make_pls_context_native(s_plsGPU);
|
||||
@@ -71,8 +73,8 @@ static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLD
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
// Once nobody is referencing a RiveContext anymore, release the global RenderContext's GPU
|
||||
// resource.
|
||||
// Once nobody is referencing a RiveContext anymore, release the global
|
||||
// RenderContext's GPU resource.
|
||||
_renderContext->releaseResources();
|
||||
}
|
||||
|
||||
@@ -100,12 +102,16 @@ static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLD
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (_renderTarget == nullptr || _renderTarget->width() != view.drawableSize.width ||
|
||||
if (_renderTarget == nullptr ||
|
||||
_renderTarget->width() != view.drawableSize.width ||
|
||||
_renderTarget->height() != view.drawableSize.height)
|
||||
{
|
||||
_renderTarget =
|
||||
_renderContext->static_impl_cast<rive::gpu::RenderContextMetalImpl>()->makeRenderTarget(
|
||||
view.colorPixelFormat, view.drawableSize.width, view.drawableSize.height);
|
||||
_renderContext
|
||||
->static_impl_cast<rive::gpu::RenderContextMetalImpl>()
|
||||
->makeRenderTarget(view.colorPixelFormat,
|
||||
view.drawableSize.width,
|
||||
view.drawableSize.height);
|
||||
}
|
||||
_renderTarget->setTargetTexture(surface.texture);
|
||||
|
||||
@@ -118,7 +124,8 @@ static std::unique_ptr<rive::gpu::RenderContext> make_pls_context_native(id<MTLD
|
||||
return _renderer.get();
|
||||
}
|
||||
|
||||
- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
- (void)endFrame:(MTKView*)view
|
||||
withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
{
|
||||
id<MTLCommandBuffer> flushCommandBuffer = [self.metalQueue commandBuffer];
|
||||
_renderContext->flush({
|
||||
@@ -186,10 +193,12 @@ constexpr static int kBufferRingSize = 3;
|
||||
switch (view.colorPixelFormat)
|
||||
{
|
||||
case MTLPixelFormatBGRA8Unorm:
|
||||
cgBitmapInfo = kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst;
|
||||
cgBitmapInfo =
|
||||
kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedFirst;
|
||||
break;
|
||||
case MTLPixelFormatRGBA8Unorm:
|
||||
cgBitmapInfo = kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast;
|
||||
cgBitmapInfo =
|
||||
kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast;
|
||||
break;
|
||||
default:
|
||||
NSLog(@"error: unsupported colorPixelFormat on MTKView");
|
||||
@@ -205,39 +214,46 @@ constexpr static int kBufferRingSize = 3;
|
||||
}
|
||||
|
||||
_currentBufferIdx = (_currentBufferIdx + 1) % kBufferRingSize;
|
||||
size_t bufferSize = _renderTargetTexture.height * _renderTargetTexture.width * 4;
|
||||
size_t bufferSize =
|
||||
_renderTargetTexture.height * _renderTargetTexture.width * 4;
|
||||
if (_buffers[_currentBufferIdx] == nil ||
|
||||
_buffers[_currentBufferIdx].allocatedSize != bufferSize)
|
||||
{
|
||||
_buffers[_currentBufferIdx] =
|
||||
[self.metalDevice newBufferWithLength:bufferSize options:MTLResourceStorageModeShared];
|
||||
[self.metalDevice newBufferWithLength:bufferSize
|
||||
options:MTLResourceStorageModeShared];
|
||||
}
|
||||
AutoCF<CGColorSpaceRef> colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
_cgContext = AutoCF(CGBitmapContextCreate(_buffers[_currentBufferIdx].contents,
|
||||
_renderTargetTexture.width,
|
||||
_renderTargetTexture.height,
|
||||
8,
|
||||
_renderTargetTexture.width * 4,
|
||||
colorSpace,
|
||||
cgBitmapInfo));
|
||||
_cgContext =
|
||||
AutoCF(CGBitmapContextCreate(_buffers[_currentBufferIdx].contents,
|
||||
_renderTargetTexture.width,
|
||||
_renderTargetTexture.height,
|
||||
8,
|
||||
_renderTargetTexture.width * 4,
|
||||
colorSpace,
|
||||
cgBitmapInfo));
|
||||
|
||||
_renderer = std::make_unique<rive::CGRenderer>(
|
||||
_cgContext, _renderTargetTexture.width, _renderTargetTexture.height);
|
||||
return _renderer.get();
|
||||
}
|
||||
|
||||
- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
- (void)endFrame:(MTKView*)view
|
||||
withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
{
|
||||
if (_cgContext != nil)
|
||||
{
|
||||
id<MTLCommandBuffer> commandBuffer = [self.metalQueue commandBuffer];
|
||||
id<MTLBlitCommandEncoder> blitEncoder = [commandBuffer blitCommandEncoder];
|
||||
id<MTLBlitCommandEncoder> blitEncoder =
|
||||
[commandBuffer blitCommandEncoder];
|
||||
[blitEncoder copyFromBuffer:_buffers[_currentBufferIdx]
|
||||
sourceOffset:0
|
||||
sourceBytesPerRow:_renderTargetTexture.width * 4
|
||||
sourceBytesPerImage:_renderTargetTexture.height * _renderTargetTexture.width * 4
|
||||
sourceSize:MTLSizeMake(
|
||||
_renderTargetTexture.width, _renderTargetTexture.height, 1)
|
||||
sourceBytesPerImage:_renderTargetTexture.height *
|
||||
_renderTargetTexture.width * 4
|
||||
sourceSize:MTLSizeMake(_renderTargetTexture.width,
|
||||
_renderTargetTexture.height,
|
||||
1)
|
||||
toTexture:_renderTargetTexture
|
||||
destinationSlice:0
|
||||
destinationLevel:0
|
||||
@@ -295,8 +311,8 @@ constexpr static int kBufferRingSize = 3;
|
||||
|
||||
- (RenderContext*)getRiveRendererContext
|
||||
{
|
||||
// Convert our weak reference to strong before trying to work with it. A weak pointer is liable
|
||||
// to be released out from under us at any moment.
|
||||
// Convert our weak reference to strong before trying to work with it. A
|
||||
// weak pointer is liable to be released out from under us at any moment.
|
||||
// https://stackoverflow.com/questions/15674320/understanding-weak-reference
|
||||
RiveRendererContext* strongPtr = _riveRendererContextWeakPtr;
|
||||
if (strongPtr == nil)
|
||||
@@ -309,8 +325,8 @@ constexpr static int kBufferRingSize = 3;
|
||||
|
||||
- (RenderContext*)getCGRendererContext
|
||||
{
|
||||
// Convert our weak reference to strong before trying to work with it. A weak pointer is liable
|
||||
// to be released out from under us at any moment.
|
||||
// Convert our weak reference to strong before trying to work with it. A
|
||||
// weak pointer is liable to be released out from under us at any moment.
|
||||
// https://stackoverflow.com/questions/15674320/understanding-weak-reference
|
||||
CGRendererContext* strongPtr = _cgContextWeakPtr;
|
||||
if (strongPtr == nil)
|
||||
@@ -323,17 +339,20 @@ constexpr static int kBufferRingSize = 3;
|
||||
|
||||
- (RiveFactory*)getDefaultFactory
|
||||
{
|
||||
return [[RiveFactory alloc] initWithFactory:[[self getDefaultContext] factory]];
|
||||
return [[RiveFactory alloc]
|
||||
initWithFactory:[[self getDefaultContext] factory]];
|
||||
}
|
||||
|
||||
- (RiveFactory*)getRiveRendererFactory
|
||||
{
|
||||
return [[RiveFactory alloc] initWithFactory:[[self getRiveRendererContext] factory]];
|
||||
return [[RiveFactory alloc]
|
||||
initWithFactory:[[self getRiveRendererContext] factory]];
|
||||
}
|
||||
|
||||
- (RiveFactory*)getCGFactory
|
||||
{
|
||||
return [[RiveFactory alloc] initWithFactory:[[self getCGRendererContext] factory]];
|
||||
return [[RiveFactory alloc]
|
||||
initWithFactory:[[self getCGRendererContext] factory]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,7 +33,8 @@ static int artInstanceCount = 0;
|
||||
|
||||
// MARK: LifeCycle
|
||||
|
||||
- (instancetype)initWithArtboard:(std::unique_ptr<rive::ArtboardInstance>)riveArtboard
|
||||
- (instancetype)initWithArtboard:
|
||||
(std::unique_ptr<rive::ArtboardInstance>)riveArtboard
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
@@ -87,7 +88,8 @@ static int artInstanceCount = 0;
|
||||
return _artboardInstance->animationCount();
|
||||
}
|
||||
|
||||
- (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index error:(NSError**)error
|
||||
- (RiveLinearAnimationInstance*)animationFromIndex:(NSInteger)index
|
||||
error:(NSError**)error
|
||||
{
|
||||
if (index < 0 || index >= [self animationCount])
|
||||
{
|
||||
@@ -96,7 +98,8 @@ static int artInstanceCount = 0;
|
||||
code:RiveNoAnimationFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Animation found at index %ld.", (long)index],
|
||||
stringWithFormat:@"No Animation found at index %ld.",
|
||||
(long)index],
|
||||
@"name" : @"NoAnimationFound"
|
||||
}];
|
||||
return nil;
|
||||
@@ -105,7 +108,8 @@ static int artInstanceCount = 0;
|
||||
initWithAnimation:_artboardInstance->animationAt(index)];
|
||||
}
|
||||
|
||||
- (RiveLinearAnimationInstance*)animationFromName:(NSString*)name error:(NSError**)error
|
||||
- (RiveLinearAnimationInstance*)animationFromName:(NSString*)name
|
||||
error:(NSError**)error
|
||||
{
|
||||
std::string stdName = std::string([name UTF8String]);
|
||||
auto animation = _artboardInstance->animationNamed(stdName);
|
||||
@@ -115,13 +119,15 @@ static int artInstanceCount = 0;
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoAnimationFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey :
|
||||
[NSString stringWithFormat:@"No Animation found with name %@.", name],
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Animation found with name %@.",
|
||||
name],
|
||||
@"name" : @"NoAnimationFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
return [[RiveLinearAnimationInstance alloc] initWithAnimation:std::move(animation)];
|
||||
return [[RiveLinearAnimationInstance alloc]
|
||||
initWithAnimation:std::move(animation)];
|
||||
}
|
||||
|
||||
- (NSArray*)animationNames
|
||||
@@ -129,7 +135,8 @@ static int artInstanceCount = 0;
|
||||
NSMutableArray* animationNames = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < [self animationCount]; i++)
|
||||
{
|
||||
RiveLinearAnimationInstance* animation = [self animationFromIndex:i error:nil];
|
||||
RiveLinearAnimationInstance* animation = [self animationFromIndex:i
|
||||
error:nil];
|
||||
if (animation != nil)
|
||||
{
|
||||
[animationNames addObject:[animation name]];
|
||||
@@ -145,18 +152,21 @@ static int artInstanceCount = 0;
|
||||
}
|
||||
|
||||
/// Returns a state machine at the given index, or null if the index is invalid
|
||||
- (RiveStateMachineInstance*)stateMachineFromIndex:(NSInteger)index error:(NSError**)error
|
||||
- (RiveStateMachineInstance*)stateMachineFromIndex:(NSInteger)index
|
||||
error:(NSError**)error
|
||||
{
|
||||
if (index < 0 || index >= [self stateMachineCount])
|
||||
{
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateMachineFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No State Machine found at index %ld.", (long)index],
|
||||
@"name" : @"NoStateMachineFound"
|
||||
}];
|
||||
*error =
|
||||
[NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateMachineFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:
|
||||
@"No State Machine found at index %ld.",
|
||||
(long)index],
|
||||
@"name" : @"NoStateMachineFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
return [[RiveStateMachineInstance alloc]
|
||||
@@ -164,23 +174,26 @@ static int artInstanceCount = 0;
|
||||
}
|
||||
|
||||
/// Returns a state machine with the given name, or null if none exists
|
||||
- (RiveStateMachineInstance*)stateMachineFromName:(NSString*)name error:(NSError**)error
|
||||
- (RiveStateMachineInstance*)stateMachineFromName:(NSString*)name
|
||||
error:(NSError**)error
|
||||
{
|
||||
std::string stdName = std::string([name UTF8String]);
|
||||
auto machine = _artboardInstance->stateMachineNamed(stdName);
|
||||
if (machine == nullptr)
|
||||
{
|
||||
*error =
|
||||
[NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateMachineFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No State Machine found with name %@.", name],
|
||||
@"name" : @"NoStateMachineFound"
|
||||
}];
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateMachineFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:
|
||||
@"No State Machine found with name %@.", name],
|
||||
@"name" : @"NoStateMachineFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
return [[RiveStateMachineInstance alloc] initWithStateMachine:std::move(machine)];
|
||||
return [[RiveStateMachineInstance alloc]
|
||||
initWithStateMachine:std::move(machine)];
|
||||
}
|
||||
|
||||
- (RiveStateMachineInstance*)defaultStateMachine
|
||||
@@ -188,12 +201,15 @@ static int artInstanceCount = 0;
|
||||
auto machine = _artboardInstance->defaultStateMachine();
|
||||
if (machine == nullptr)
|
||||
{
|
||||
// *error = [NSError errorWithDomain:RiveErrorDomain code:RiveNoStateMachineFound
|
||||
// userInfo:@{NSLocalizedDescriptionKey: [NSString stringWithFormat: @"No default
|
||||
// State Machine found."], @"name": @"NoStateMachineFound"}];
|
||||
// *error = [NSError errorWithDomain:RiveErrorDomain
|
||||
// code:RiveNoStateMachineFound
|
||||
// userInfo:@{NSLocalizedDescriptionKey: [NSString
|
||||
// stringWithFormat: @"No default State Machine found."],
|
||||
// @"name": @"NoStateMachineFound"}];
|
||||
return nil;
|
||||
}
|
||||
return [[RiveStateMachineInstance alloc] initWithStateMachine:std::move(machine)];
|
||||
return [[RiveStateMachineInstance alloc]
|
||||
initWithStateMachine:std::move(machine)];
|
||||
}
|
||||
|
||||
- (NSArray*)stateMachineNames
|
||||
@@ -201,7 +217,8 @@ static int artInstanceCount = 0;
|
||||
NSMutableArray* stateMachineNames = [NSMutableArray array];
|
||||
for (NSUInteger i = 0; i < [self stateMachineCount]; i++)
|
||||
{
|
||||
RiveStateMachineInstance* stateMachine = [self stateMachineFromIndex:i error:nil];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[self stateMachineFromIndex:i error:nil];
|
||||
if (stateMachine != nil)
|
||||
{
|
||||
[stateMachineNames addObject:[stateMachine name]];
|
||||
@@ -223,7 +240,8 @@ static int artInstanceCount = 0;
|
||||
- (NSString*)name
|
||||
{
|
||||
std::string str = _artboardInstance->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (CGRect)bounds
|
||||
@@ -238,7 +256,8 @@ static int artInstanceCount = 0;
|
||||
auto riveTextRun = _artboardInstance->find<rive::TextValueRun>(stdName);
|
||||
if (riveTextRun != nullptr)
|
||||
{
|
||||
return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)];
|
||||
return [[RiveTextValueRun alloc]
|
||||
initWithTextValueRun:std::move(riveTextRun)];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -252,11 +271,13 @@ static int artInstanceCount = 0;
|
||||
|
||||
const std::string stdName = std::string([name UTF8String]);
|
||||
const std::string stdPath = std::string([path UTF8String]);
|
||||
// Can we update the cpp library to handle empty paths / default to parent if nullptr?
|
||||
// Can we update the cpp library to handle empty paths / default to parent
|
||||
// if nullptr?
|
||||
auto riveTextRun = _artboardInstance->getTextRun(stdName, stdPath);
|
||||
if (riveTextRun != nullptr)
|
||||
{
|
||||
return [[RiveTextValueRun alloc] initWithTextValueRun:std::move(riveTextRun)];
|
||||
return [[RiveTextValueRun alloc]
|
||||
initWithTextValueRun:std::move(riveTextRun)];
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -265,7 +286,8 @@ static int artInstanceCount = 0;
|
||||
{
|
||||
// Create a unique dictionary name for nested artboards + booleans;
|
||||
// this lets us use one dictionary for the three different types
|
||||
NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_boo"];
|
||||
NSString* dictName =
|
||||
[NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_boo"];
|
||||
// Check if the input is already instanced
|
||||
if ([_inputs objectForKey:dictName] != nil)
|
||||
{
|
||||
@@ -290,7 +312,8 @@ static int artInstanceCount = 0;
|
||||
{
|
||||
// Create a unique dictionary name for nested artboards + triggers;
|
||||
// this lets us use one dictionary for the three different types
|
||||
NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_trg"];
|
||||
NSString* dictName =
|
||||
[NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_trg"];
|
||||
// Check if the input is already instanced
|
||||
if ([_inputs objectForKey:dictName] != nil)
|
||||
{
|
||||
@@ -315,7 +338,8 @@ static int artInstanceCount = 0;
|
||||
{
|
||||
// Create a unique dictionary name for nested artboards + numbers;
|
||||
// this lets us use one dictionary for the three different types
|
||||
NSString* dictName = [NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_num"];
|
||||
NSString* dictName =
|
||||
[NSString stringWithFormat:@"%@%s%@%s", path, "_", name, "_num"];
|
||||
// Check if the input is already instanced
|
||||
if ([_inputs objectForKey:dictName] != nil)
|
||||
{
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
return instance;
|
||||
}
|
||||
|
||||
- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent delay:(float)delay
|
||||
- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent
|
||||
delay:(float)delay
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
@@ -40,7 +41,8 @@
|
||||
- (NSString*)name
|
||||
{
|
||||
std::string str = ((const rive::Event*)instance)->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (NSInteger)type
|
||||
@@ -56,7 +58,8 @@
|
||||
- (NSDictionary<NSString*, id>*)properties
|
||||
{
|
||||
bool hasCustomProperties = false;
|
||||
NSMutableDictionary<NSString*, id>* customProperties = [NSMutableDictionary dictionary];
|
||||
NSMutableDictionary<NSString*, id>* customProperties =
|
||||
[NSMutableDictionary dictionary];
|
||||
for (auto child : ((const rive::Event*)instance)->children())
|
||||
{
|
||||
if (child->is<rive::CustomProperty>())
|
||||
@@ -64,32 +67,36 @@
|
||||
std::string eventName = child->name();
|
||||
if (!eventName.empty())
|
||||
{
|
||||
NSString* convertedName =
|
||||
[NSString stringWithCString:eventName.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
NSString* convertedName = [NSString
|
||||
stringWithCString:eventName.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
switch (child->coreType())
|
||||
{
|
||||
case rive::CustomPropertyBoolean::typeKey:
|
||||
{
|
||||
bool customBoolValue =
|
||||
child->as<rive::CustomPropertyBoolean>()->propertyValue();
|
||||
child->as<rive::CustomPropertyBoolean>()
|
||||
->propertyValue();
|
||||
customProperties[convertedName] = @(customBoolValue);
|
||||
break;
|
||||
}
|
||||
case rive::CustomPropertyString::typeKey:
|
||||
{
|
||||
std::string customStringValue =
|
||||
child->as<rive::CustomPropertyString>()->propertyValue();
|
||||
NSString* convertedStringValue =
|
||||
[NSString stringWithCString:customStringValue.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
child->as<rive::CustomPropertyString>()
|
||||
->propertyValue();
|
||||
NSString* convertedStringValue = [NSString
|
||||
stringWithCString:customStringValue.c_str()
|
||||
encoding:[NSString
|
||||
defaultCStringEncoding]];
|
||||
customProperties[convertedName] = convertedStringValue;
|
||||
break;
|
||||
}
|
||||
case rive::CustomPropertyNumber::typeKey:
|
||||
{
|
||||
float customNumValue =
|
||||
child->as<rive::CustomPropertyNumber>()->propertyValue();
|
||||
child->as<rive::CustomPropertyNumber>()
|
||||
->propertyValue();
|
||||
customProperties[convertedName] = @(customNumValue);
|
||||
break;
|
||||
}
|
||||
@@ -119,12 +126,14 @@
|
||||
- (NSString*)url
|
||||
{
|
||||
std::string str = ((const rive::OpenUrlEvent*)[self getInstance])->url();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (NSString*)target
|
||||
{
|
||||
uint32_t targetValue = ((const rive::OpenUrlEvent*)[self getInstance])->targetValue();
|
||||
uint32_t targetValue =
|
||||
((const rive::OpenUrlEvent*)[self getInstance])->targetValue();
|
||||
std::string targetString;
|
||||
switch (targetValue)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,8 @@ static rive::rcp<rive::Font> riveFontFromNativeFont(id font)
|
||||
return HBFont::FromSystem((void*)ctFont, weight, width);
|
||||
}
|
||||
|
||||
static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> missing)
|
||||
static rive::rcp<rive::Font> findFallbackFont(
|
||||
rive::Span<const rive::Unichar> missing)
|
||||
{
|
||||
// For each descriptor…
|
||||
for (id<RiveFallbackFontProvider> fallback in RiveFont.fallbackFonts)
|
||||
@@ -57,7 +58,8 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
|
||||
@implementation RiveFont
|
||||
{
|
||||
rive::rcp<rive::Font> instance; // note: we do NOT own this, so don't delete it
|
||||
rive::rcp<rive::Font>
|
||||
instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
|
||||
+ (void)load
|
||||
@@ -95,7 +97,8 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
return _fallbackFonts;
|
||||
}
|
||||
|
||||
+ (void)setFallbackFonts:(nonnull NSArray<id<RiveFallbackFontProvider>>*)fallbackFonts
|
||||
+ (void)setFallbackFonts:
|
||||
(nonnull NSArray<id<RiveFallbackFontProvider>>*)fallbackFonts
|
||||
{
|
||||
_fallbackFonts = [fallbackFonts copy];
|
||||
}
|
||||
@@ -104,7 +107,8 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
|
||||
@implementation RiveRenderImage
|
||||
{
|
||||
rive::rcp<rive::RenderImage> instance; // note: we do NOT own this, so don't delete it
|
||||
rive::rcp<rive::RenderImage>
|
||||
instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
- (instancetype)initWithImage:(rive::rcp<rive::RenderImage>)image
|
||||
{
|
||||
@@ -127,7 +131,8 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
|
||||
@implementation RiveAudio
|
||||
{
|
||||
rive::rcp<rive::AudioSource> instance; // note: we do NOT own this, so don't delete it
|
||||
rive::rcp<rive::AudioSource>
|
||||
instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
- (instancetype)initWithAudio:(rive::rcp<rive::AudioSource>)audio
|
||||
{
|
||||
@@ -174,14 +179,16 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
return [[RiveRenderImage alloc]
|
||||
initWithImage:instance->decodeImage(rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
initWithImage:instance->decodeImage(
|
||||
rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
}
|
||||
|
||||
- (RiveFont*)decodeFont:(nonnull NSData*)data
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
return [[RiveFont alloc]
|
||||
initWithFont:instance->decodeFont(rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
initWithFont:instance->decodeFont(
|
||||
rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
}
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
@@ -200,7 +207,8 @@ static rive::rcp<rive::Font> findFallbackFont(rive::Span<const rive::Unichar> mi
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
return [[RiveAudio alloc]
|
||||
initWithAudio:instance->decodeAudio(rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
initWithAudio:instance->decodeAudio(
|
||||
rive::Span<const uint8_t>(bytes, [data length]))];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -33,7 +33,9 @@
|
||||
return UInt8(rive::File::minorVersion);
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithByteArray:(NSArray*)array loadCdn:(bool)cdn error:(NSError**)error
|
||||
- (nullable instancetype)initWithByteArray:(NSArray*)array
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
@@ -42,10 +44,14 @@
|
||||
{
|
||||
bytes = (UInt8*)calloc(array.count, sizeof(UInt64));
|
||||
|
||||
[array enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop) {
|
||||
[array enumerateObjectsUsingBlock:^(
|
||||
NSNumber* number, NSUInteger index, BOOL* stop) {
|
||||
bytes[index] = number.unsignedIntValue;
|
||||
}];
|
||||
BOOL ok = [self import:bytes byteLength:array.count loadCdn:cdn error:error];
|
||||
BOOL ok = [self import:bytes
|
||||
byteLength:array.count
|
||||
loadCdn:cdn
|
||||
error:error];
|
||||
if (!ok)
|
||||
{
|
||||
return nil;
|
||||
@@ -74,7 +80,8 @@
|
||||
{
|
||||
bytes = (UInt8*)calloc(array.count, sizeof(UInt64));
|
||||
|
||||
[array enumerateObjectsUsingBlock:^(NSNumber* number, NSUInteger index, BOOL* stop) {
|
||||
[array enumerateObjectsUsingBlock:^(
|
||||
NSNumber* number, NSUInteger index, BOOL* stop) {
|
||||
bytes[index] = number.unsignedIntValue;
|
||||
}];
|
||||
BOOL ok = [self import:bytes
|
||||
@@ -139,10 +146,15 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithData:(NSData*)data loadCdn:(bool)cdn error:(NSError**)error
|
||||
- (nullable instancetype)initWithData:(NSData*)data
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error
|
||||
{
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
return [self initWithBytes:bytes byteLength:data.length loadCdn:cdn error:error];
|
||||
return [self initWithBytes:bytes
|
||||
byteLength:data.length
|
||||
loadCdn:cdn
|
||||
error:error];
|
||||
}
|
||||
- (nullable instancetype)initWithData:(NSData*)data
|
||||
loadCdn:(bool)cdn
|
||||
@@ -165,10 +177,11 @@
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error
|
||||
{
|
||||
// QUESTION: good ideas on how we can combine a few of these into following the same path
|
||||
// better?
|
||||
// QUESTION: good ideas on how we can combine a few of these into following
|
||||
// the same path better?
|
||||
// there's a lot of copy pasta here.
|
||||
NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName ofType:extension];
|
||||
NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName
|
||||
ofType:extension];
|
||||
NSURL* fileUrl = [NSURL fileURLWithPath:filepath];
|
||||
NSData* fileData = [NSData dataWithContentsOfURL:fileUrl];
|
||||
|
||||
@@ -176,19 +189,24 @@
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a RiveFile from a binary resource, and assumes the resource extension is '.riv'
|
||||
* Creates a RiveFile from a binary resource, and assumes the resource extension
|
||||
* is '.riv'
|
||||
*/
|
||||
- (nullable instancetype)initWithResource:(NSString*)resourceName
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error
|
||||
{
|
||||
return [self initWithResource:resourceName withExtension:@"riv" loadCdn:cdn error:error];
|
||||
return [self initWithResource:resourceName
|
||||
withExtension:@"riv"
|
||||
loadCdn:cdn
|
||||
error:error];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithResource:(nonnull NSString*)resourceName
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(nonnull LoadAsset)customAssetLoader
|
||||
error:(NSError* __autoreleasing _Nullable* _Nullable)error
|
||||
- (nullable instancetype)
|
||||
initWithResource:(nonnull NSString*)resourceName
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(nonnull LoadAsset)customAssetLoader
|
||||
error:(NSError* __autoreleasing _Nullable* _Nullable)error
|
||||
{
|
||||
return [self initWithResource:resourceName
|
||||
withExtension:@"riv"
|
||||
@@ -197,16 +215,21 @@
|
||||
error:error];
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithResource:(nonnull NSString*)resourceName
|
||||
withExtension:(nonnull NSString*)extension
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(nonnull LoadAsset)customAssetLoader
|
||||
error:(NSError* __autoreleasing _Nullable* _Nullable)error
|
||||
- (nullable instancetype)
|
||||
initWithResource:(nonnull NSString*)resourceName
|
||||
withExtension:(nonnull NSString*)extension
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(nonnull LoadAsset)customAssetLoader
|
||||
error:(NSError* __autoreleasing _Nullable* _Nullable)error
|
||||
{
|
||||
NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName ofType:extension];
|
||||
NSString* filepath = [[NSBundle mainBundle] pathForResource:resourceName
|
||||
ofType:extension];
|
||||
NSURL* fileUrl = [NSURL fileURLWithPath:filepath];
|
||||
NSData* fileData = [NSData dataWithContentsOfURL:fileUrl];
|
||||
return [self initWithData:fileData loadCdn:cdn customAssetLoader:customAssetLoader error:error];
|
||||
return [self initWithData:fileData
|
||||
loadCdn:cdn
|
||||
customAssetLoader:customAssetLoader
|
||||
error:error];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -218,7 +241,8 @@
|
||||
{
|
||||
return [self initWithHttpUrl:url
|
||||
loadCdn:loadCdn
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
return false;
|
||||
}
|
||||
withDelegate:delegate];
|
||||
@@ -236,16 +260,19 @@
|
||||
// Set up the http download task
|
||||
NSURL* URL = [NSURL URLWithString:url];
|
||||
|
||||
// TODO: we are still adding 8MB of memory when we load our first http url.
|
||||
// TODO: we are still adding 8MB of memory when we load our first http
|
||||
// url.
|
||||
NSURLSessionTask* task = [[NSURLSession sharedSession]
|
||||
downloadTaskWithURL:URL
|
||||
completionHandler:^(NSURL* location, NSURLResponse* response, NSError* error) {
|
||||
completionHandler:^(
|
||||
NSURL* location, NSURLResponse* response, NSError* error) {
|
||||
if (!error)
|
||||
{
|
||||
// Load the data into the reader
|
||||
NSData* data = [NSData dataWithContentsOfURL:location];
|
||||
UInt8* bytes = (UInt8*)[data bytes];
|
||||
// TODO: Do something with this error the proper way with delegates.
|
||||
// TODO: Do something with this error the proper way with
|
||||
// delegates.
|
||||
NSError* error = nil;
|
||||
[self import:bytes
|
||||
byteLength:[data length]
|
||||
@@ -256,7 +283,8 @@
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if ([[NSThread currentThread] isMainThread])
|
||||
{
|
||||
if ([self.delegate respondsToSelector:@selector(riveFileDidLoad:error:)])
|
||||
if ([self.delegate respondsToSelector:@selector
|
||||
(riveFileDidLoad:error:)])
|
||||
{
|
||||
NSError* error = nil;
|
||||
[self.delegate riveFileDidLoad:self error:&error];
|
||||
@@ -274,12 +302,16 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL)import:(UInt8*)bytes byteLength:(UInt64)length loadCdn:(bool)loadCdn error:(NSError**)error
|
||||
- (BOOL)import:(UInt8*)bytes
|
||||
byteLength:(UInt64)length
|
||||
loadCdn:(bool)loadCdn
|
||||
error:(NSError**)error
|
||||
{
|
||||
return [self import:bytes
|
||||
byteLength:length
|
||||
loadCdn:loadCdn
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
return false;
|
||||
}
|
||||
error:error];
|
||||
@@ -291,11 +323,13 @@
|
||||
error:(NSError**)error
|
||||
{
|
||||
rive::ImportResult result;
|
||||
RenderContext* renderContext = [[RenderContextManager shared] getDefaultContext];
|
||||
RenderContext* renderContext =
|
||||
[[RenderContextManager shared] getDefaultContext];
|
||||
assert(renderContext);
|
||||
rive::Factory* factory = [renderContext factory];
|
||||
|
||||
FallbackFileAssetLoader* fallbackLoader = [[FallbackFileAssetLoader alloc] init];
|
||||
FallbackFileAssetLoader* fallbackLoader =
|
||||
[[FallbackFileAssetLoader alloc] init];
|
||||
|
||||
CustomFileAssetLoader* customAssetLoader =
|
||||
[[CustomFileAssetLoader alloc] initWithLoader:custom];
|
||||
@@ -309,7 +343,8 @@
|
||||
|
||||
fileAssetLoader = new rive::FileAssetLoaderAdapter(fallbackLoader);
|
||||
|
||||
auto file = rive::File::import(rive::Span(bytes, length), factory, &result, fileAssetLoader);
|
||||
auto file = rive::File::import(
|
||||
rive::Span(bytes, length), factory, &result, fileAssetLoader);
|
||||
if (result == rive::ImportResult::success)
|
||||
{
|
||||
riveFile = std::move(file);
|
||||
@@ -319,27 +354,29 @@
|
||||
switch (result)
|
||||
{
|
||||
case rive::ImportResult::unsupportedVersion:
|
||||
*error =
|
||||
[NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveUnsupportedVersion
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"Unsupported Rive File Version",
|
||||
@"name" : @"UnsupportedVersion"
|
||||
}];
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveUnsupportedVersion
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey :
|
||||
@"Unsupported Rive File Version",
|
||||
@"name" : @"UnsupportedVersion"
|
||||
}];
|
||||
break;
|
||||
case rive::ImportResult::malformed:
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveMalformedFile
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"Malformed Rive File.",
|
||||
@"name" : @"Malformed"
|
||||
}];
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveMalformedFile
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"Malformed Rive File.",
|
||||
@"name" : @"Malformed"
|
||||
}];
|
||||
break;
|
||||
default:
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveUnknownError
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"Unknown error loading file.",
|
||||
NSLocalizedDescriptionKey :
|
||||
@"Unknown error loading file.",
|
||||
@"name" : @"Unknown"
|
||||
}];
|
||||
break;
|
||||
@@ -352,12 +389,13 @@
|
||||
auto artboard = riveFile->artboardDefault();
|
||||
if (artboard == nullptr)
|
||||
{
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoArtboardsFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"No Artboards Found.",
|
||||
@"name" : @"NoArtboardsFound"
|
||||
}];
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoArtboardsFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"No Artboards Found.",
|
||||
@"name" : @"NoArtboardsFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
@@ -381,7 +419,8 @@
|
||||
code:RiveNoArtboardFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Artboard Found at index %ld.", (long)index],
|
||||
stringWithFormat:@"No Artboard Found at index %ld.",
|
||||
(long)index],
|
||||
@"name" : @"NoArtboardFound"
|
||||
}];
|
||||
return nil;
|
||||
@@ -395,13 +434,15 @@
|
||||
auto artboard = riveFile->artboardNamed(stdName);
|
||||
if (artboard == nullptr)
|
||||
{
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoArtboardFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Artboard Found with name %@.", name],
|
||||
@"name" : @"NoArtboardFound"
|
||||
}];
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoArtboardFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Artboard Found with name %@.",
|
||||
name],
|
||||
@"name" : @"NoArtboardFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -35,37 +35,43 @@
|
||||
- (nonnull NSString*)cdnBaseUrl
|
||||
{
|
||||
std::string str = instance->cdnBaseUrl();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)cdnUuid
|
||||
{
|
||||
std::string str = instance->cdnUuidStr();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)fileExtension
|
||||
{
|
||||
std::string str = instance->fileExtension();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)name
|
||||
{
|
||||
std::string str = instance->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)uniqueFilename
|
||||
{
|
||||
std::string str = instance->uniqueFilename();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (nonnull NSString*)uniqueName
|
||||
{
|
||||
std::string str = instance->uniqueName();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -22,7 +22,8 @@ static int animInstanceCount = 0;
|
||||
|
||||
// MARK: Lifecycle
|
||||
|
||||
- (instancetype)initWithAnimation:(std::unique_ptr<rive::LinearAnimationInstance>)anim
|
||||
- (instancetype)initWithAnimation:
|
||||
(std::unique_ptr<rive::LinearAnimationInstance>)anim
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
@@ -111,7 +112,8 @@ static int animInstanceCount = 0;
|
||||
- (NSString*)name
|
||||
{
|
||||
std::string str = instance->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (NSInteger)fps
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
*/
|
||||
@implementation RiveSMIInput
|
||||
{
|
||||
const rive::SMIInput* instance; // note: we do NOT own this, so don't delete it
|
||||
const rive::SMIInput*
|
||||
instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
|
||||
- (const rive::SMIInput*)getInstance
|
||||
@@ -54,7 +55,8 @@
|
||||
- (NSString*)name
|
||||
{
|
||||
std::string str = ((const rive::SMIInput*)instance)->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -51,7 +51,8 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
// MARK: Lifecycle
|
||||
|
||||
// Creates a new RiveStateMachineInstance from a cpp StateMachine
|
||||
- (instancetype)initWithStateMachine:(std::unique_ptr<rive::StateMachineInstance>)stateMachine
|
||||
- (instancetype)initWithStateMachine:
|
||||
(std::unique_ptr<rive::StateMachineInstance>)stateMachine
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
@@ -181,7 +182,8 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
- (NSString*)name
|
||||
{
|
||||
std::string str = instance->name();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
- (NSInteger)inputCount
|
||||
@@ -189,7 +191,8 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
return instance->inputCount();
|
||||
}
|
||||
|
||||
- (RiveSMIInput*)_convertInput:(const rive::SMIInput*)input error:(NSError**)error
|
||||
- (RiveSMIInput*)_convertInput:(const rive::SMIInput*)input
|
||||
error:(NSError**)error
|
||||
{
|
||||
if (input->input()->is<rive::StateMachineBool>())
|
||||
{
|
||||
@@ -208,7 +211,8 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
*error = [NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveUnknownStateMachineInput
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : @"Unknown State Machine Input",
|
||||
NSLocalizedDescriptionKey :
|
||||
@"Unknown State Machine Input",
|
||||
@"name" : @"UnknownStateMachineInput"
|
||||
}];
|
||||
return nil;
|
||||
@@ -224,8 +228,9 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateMachineInputFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey :
|
||||
[NSString stringWithFormat:@"No Input found at index %ld.", (long)index],
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No Input found at index %ld.",
|
||||
(long)index],
|
||||
@"name" : @"NoStateMachineInputFound"
|
||||
}];
|
||||
return nil;
|
||||
@@ -256,7 +261,8 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
code:RiveNoStateMachineInputFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No State Machine Input found with name %@.", name],
|
||||
stringWithFormat:
|
||||
@"No State Machine Input found with name %@.", name],
|
||||
@"name" : @"NoStateMachineInputFound"
|
||||
}];
|
||||
return nil;
|
||||
@@ -343,14 +349,16 @@ RiveHitResult RiveHitResultFromRuntime(rive::HitResult result)
|
||||
const rive::LayerState* layerState = instance->stateChangedByIndex(index);
|
||||
if (layerState == nullptr)
|
||||
{
|
||||
*error = [NSError
|
||||
errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateChangeFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:@"No State Changed found at index %ld.", (long)index],
|
||||
@"name" : @"NoStateChangeFound"
|
||||
}];
|
||||
*error =
|
||||
[NSError errorWithDomain:RiveErrorDomain
|
||||
code:RiveNoStateChangeFound
|
||||
userInfo:@{
|
||||
NSLocalizedDescriptionKey : [NSString
|
||||
stringWithFormat:
|
||||
@"No State Changed found at index %ld.",
|
||||
(long)index],
|
||||
@"name" : @"NoStateChangeFound"
|
||||
}];
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
*/
|
||||
@implementation RiveTextValueRun
|
||||
{
|
||||
const rive::TextValueRun* instance; // note: we do NOT own this, so don't delete it
|
||||
const rive::TextValueRun*
|
||||
instance; // note: we do NOT own this, so don't delete it
|
||||
}
|
||||
|
||||
- (const rive::TextValueRun*)getInstance
|
||||
@@ -44,7 +45,8 @@
|
||||
- (NSString*)text
|
||||
{
|
||||
std::string str = ((const rive::TextValueRun*)instance)->text();
|
||||
return [NSString stringWithCString:str.c_str() encoding:[NSString defaultCStringEncoding]];
|
||||
return [NSString stringWithCString:str.c_str()
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
- (void)addLoader:(RiveFileAssetLoader*)loader;
|
||||
@end
|
||||
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory);
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset,
|
||||
NSData* data,
|
||||
RiveFactory* factory);
|
||||
|
||||
@interface CustomFileAssetLoader : RiveFileAssetLoader
|
||||
@property(nonatomic, copy) LoadAsset loadAsset;
|
||||
|
||||
@@ -144,7 +144,8 @@ public:
|
||||
void fillRule(FillRule value) override;
|
||||
void moveTo(float x, float y) override;
|
||||
void lineTo(float x, float y) override;
|
||||
void cubicTo(float ox, float oy, float ix, float iy, float x, float y) override;
|
||||
void cubicTo(float ox, float oy, float ix, float iy, float x, float y)
|
||||
override;
|
||||
void close() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class MTKView;
|
||||
|
||||
/// RenderContext knows how to set up a backend-specific render context (e.g., CG, Rive, ...),
|
||||
/// and provides a rive::Factory and rive::Renderer for it.
|
||||
/// RenderContext knows how to set up a backend-specific render context (e.g.,
|
||||
/// CG, Rive, ...), and provides a rive::Factory and rive::Renderer for it.
|
||||
@interface RenderContext : NSObject
|
||||
@property(strong) id<MTLDevice> metalDevice;
|
||||
@property(strong) id<MTLCommandQueue> metalQueue;
|
||||
@@ -29,7 +29,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@property BOOL framebufferOnly;
|
||||
- (rive::Factory*)factory;
|
||||
- (rive::Renderer*)beginFrame:(MTKView*)view;
|
||||
- (void)endFrame:(MTKView*)view withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
- (void)endFrame:(MTKView*)view
|
||||
withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -14,9 +14,10 @@ typedef NS_ENUM(NSInteger, RendererType) { riveRenderer, cgRenderer };
|
||||
@class RenderContext;
|
||||
@class RiveFactory;
|
||||
|
||||
/// The RenderContextManager is used to allow us to share contexts (e.g., Skia, CG, Rive, ...),
|
||||
/// while there are active view(s). It has weak refs to its render contexts, which means that when
|
||||
/// no more RiveRenderViews require these, they can be freed.
|
||||
/// The RenderContextManager is used to allow us to share contexts (e.g., Skia,
|
||||
/// CG, Rive, ...), while there are active view(s). It has weak refs to its
|
||||
/// render contexts, which means that when no more RiveRenderViews require
|
||||
/// these, they can be freed.
|
||||
@interface RenderContextManager : NSObject
|
||||
@property RendererType defaultRenderer;
|
||||
+ (RenderContextManager*)shared;
|
||||
|
||||
@@ -46,7 +46,15 @@ typedef NS_ENUM(NSInteger, RiveDirection) {
|
||||
/*
|
||||
* Fits
|
||||
*/
|
||||
typedef NS_ENUM(NSInteger, RiveFit) { fill, contain, cover, fitHeight, fitWidth, scaleDown, noFit };
|
||||
typedef NS_ENUM(NSInteger, RiveFit) {
|
||||
fill,
|
||||
contain,
|
||||
cover,
|
||||
fitHeight,
|
||||
fitWidth,
|
||||
scaleDown,
|
||||
noFit
|
||||
};
|
||||
|
||||
/*
|
||||
* Alignments
|
||||
@@ -93,7 +101,9 @@ typedef NS_ENUM(NSInteger, RiveErrorCode) {
|
||||
|
||||
@end
|
||||
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory);
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset,
|
||||
NSData* data,
|
||||
RiveFactory* factory);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
|
||||
@@ -36,13 +36,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (NSArray<NSString*>*)animationNames;
|
||||
- (RiveLinearAnimationInstance* __nullable)animationFromIndex:(NSInteger)index
|
||||
error:(NSError**)error;
|
||||
- (RiveLinearAnimationInstance* __nullable)animationFromName:(NSString*)name error:(NSError**)error;
|
||||
- (RiveLinearAnimationInstance* __nullable)animationFromName:(NSString*)name
|
||||
error:(NSError**)error;
|
||||
|
||||
- (NSInteger)stateMachineCount;
|
||||
- (NSArray<NSString*>*)stateMachineNames;
|
||||
- (RiveStateMachineInstance* __nullable)stateMachineFromIndex:(NSInteger)index
|
||||
error:(NSError**)error;
|
||||
- (RiveStateMachineInstance* __nullable)stateMachineFromName:(NSString*)name error:(NSError**)error;
|
||||
- (RiveStateMachineInstance* __nullable)stateMachineFromName:(NSString*)name
|
||||
error:(NSError**)error;
|
||||
- (RiveStateMachineInstance* __nullable)defaultStateMachine;
|
||||
|
||||
- (RiveTextValueRun* __nullable)textRun:(NSString*)name;
|
||||
|
||||
@@ -25,8 +25,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (NSString*)name;
|
||||
/// Type of the RiveEvent
|
||||
- (NSInteger)type;
|
||||
/// Delay in seconds since the Event was actually fired (applicable in cases of Events fired off
|
||||
/// from timeline animations)
|
||||
/// Delay in seconds since the Event was actually fired (applicable in cases of
|
||||
/// Events fired off from timeline animations)
|
||||
- (float)delay;
|
||||
/// Dictionary of custom properties set on any event
|
||||
- (NSDictionary<NSString*, id>*)properties;
|
||||
|
||||
@@ -22,11 +22,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol RiveFallbackFontProvider;
|
||||
|
||||
@interface RiveFont : NSObject
|
||||
/// An array of font descriptors to attempt to use when text being rendererd by Rive uses a font
|
||||
/// that is missing a glyph. The fonts will be tried in the order in which they are added to the
|
||||
/// array.
|
||||
/// - Note: If unset, the default fallback is a default system font, with regular font weight.
|
||||
@property(class, copy, nonnull) NSArray<id<RiveFallbackFontProvider>>* fallbackFonts;
|
||||
/// An array of font descriptors to attempt to use when text being rendererd by
|
||||
/// Rive uses a font that is missing a glyph. The fonts will be tried in the
|
||||
/// order in which they are added to the array.
|
||||
/// - Note: If unset, the default fallback is a default system font, with
|
||||
/// regular font weight.
|
||||
@property(class, copy, nonnull)
|
||||
NSArray<id<RiveFallbackFontProvider>>* fallbackFonts;
|
||||
@end
|
||||
|
||||
@interface RiveRenderImage : NSObject
|
||||
|
||||
@@ -17,7 +17,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@protocol RiveFileDelegate;
|
||||
@class RiveFileAsset;
|
||||
@class RiveFactory;
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* factory);
|
||||
typedef bool (^LoadAsset)(RiveFileAsset* asset,
|
||||
NSData* data,
|
||||
RiveFactory* factory);
|
||||
|
||||
/*
|
||||
* RiveFile
|
||||
@@ -34,7 +36,9 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto
|
||||
@property(weak) id delegate;
|
||||
|
||||
/// Used to manage url sessions Rive, this is to enable testing.
|
||||
- (nullable instancetype)initWithByteArray:(NSArray*)bytes loadCdn:(bool)cdn error:(NSError**)error;
|
||||
- (nullable instancetype)initWithByteArray:(NSArray*)bytes
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error;
|
||||
- (nullable instancetype)initWithByteArray:(NSArray*)bytes
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(LoadAsset)customAssetLoader
|
||||
@@ -50,7 +54,9 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto
|
||||
customAssetLoader:(LoadAsset)customAssetLoader
|
||||
error:(NSError**)error;
|
||||
|
||||
- (nullable instancetype)initWithData:(NSData*)bytes loadCdn:(bool)cdn error:(NSError**)error;
|
||||
- (nullable instancetype)initWithData:(NSData*)bytes
|
||||
loadCdn:(bool)cdn
|
||||
error:(NSError**)error;
|
||||
- (nullable instancetype)initWithData:(NSData*)bytes
|
||||
loadCdn:(bool)cdn
|
||||
customAssetLoader:(LoadAsset)customAssetLoader
|
||||
@@ -89,10 +95,12 @@ typedef bool (^LoadAsset)(RiveFileAsset* asset, NSData* data, RiveFactory* facto
|
||||
- (NSInteger)artboardCount;
|
||||
|
||||
/// Returns the artboard by its index
|
||||
- (RiveArtboard* __nullable)artboardFromIndex:(NSInteger)index error:(NSError**)error;
|
||||
- (RiveArtboard* __nullable)artboardFromIndex:(NSInteger)index
|
||||
error:(NSError**)error;
|
||||
|
||||
/// Returns the artboard by its name
|
||||
- (RiveArtboard* __nullable)artboardFromName:(NSString*)name error:(NSError**)error;
|
||||
- (RiveArtboard* __nullable)artboardFromName:(NSString*)name
|
||||
error:(NSError**)error;
|
||||
|
||||
/// Returns the names of all artboards in the file.
|
||||
- (NSArray<NSString*>*)artboardNames;
|
||||
|
||||
@@ -49,7 +49,8 @@
|
||||
* RiveStateMachineInstance interface
|
||||
*/
|
||||
@interface RiveStateMachineInstance ()
|
||||
- (instancetype)initWithStateMachine:(std::unique_ptr<rive::StateMachineInstance>)stateMachine;
|
||||
- (instancetype)initWithStateMachine:
|
||||
(std::unique_ptr<rive::StateMachineInstance>)stateMachine;
|
||||
@end
|
||||
|
||||
/*
|
||||
@@ -81,21 +82,24 @@
|
||||
* RiveEvent interface
|
||||
*/
|
||||
@interface RiveEvent ()
|
||||
- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent delay:(float)delay;
|
||||
- (instancetype)initWithRiveEvent:(const rive::Event*)riveEvent
|
||||
delay:(float)delay;
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveTextValueRun interface
|
||||
*/
|
||||
@interface RiveTextValueRun ()
|
||||
- (instancetype)initWithTextValueRun:(const rive::TextValueRun*)riveTextValueRun;
|
||||
- (instancetype)initWithTextValueRun:
|
||||
(const rive::TextValueRun*)riveTextValueRun;
|
||||
@end
|
||||
|
||||
/*
|
||||
* RiveLinearAnimationInstance interface
|
||||
*/
|
||||
@interface RiveLinearAnimationInstance ()
|
||||
- (instancetype)initWithAnimation:(std::unique_ptr<rive::LinearAnimationInstance>)riveAnimation;
|
||||
- (instancetype)initWithAnimation:
|
||||
(std::unique_ptr<rive::LinearAnimationInstance>)riveAnimation;
|
||||
@end
|
||||
|
||||
/*
|
||||
@@ -103,7 +107,8 @@
|
||||
*/
|
||||
@interface RiveArtboard ()
|
||||
- (rive::ArtboardInstance*)artboardInstance;
|
||||
- (instancetype)initWithArtboard:(std::unique_ptr<rive::ArtboardInstance>)riveArtboard;
|
||||
- (instancetype)initWithArtboard:
|
||||
(std::unique_ptr<rive::ArtboardInstance>)riveArtboard;
|
||||
@end
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,10 +36,13 @@ typedef NS_ENUM(NSInteger, RiveHitResult) { none, hit, hitOpaque };
|
||||
- (NSArray<NSString*>*)inputNames;
|
||||
- (NSInteger)inputCount;
|
||||
- (NSInteger)layerCount;
|
||||
- (RiveSMIInput* __nullable)inputFromIndex:(NSInteger)index error:(NSError**)error;
|
||||
- (RiveSMIInput* __nullable)inputFromName:(NSString*)name error:(NSError**)error;
|
||||
- (RiveSMIInput* __nullable)inputFromIndex:(NSInteger)index
|
||||
error:(NSError**)error;
|
||||
- (RiveSMIInput* __nullable)inputFromName:(NSString*)name
|
||||
error:(NSError**)error;
|
||||
- (NSInteger)stateChangedCount;
|
||||
- (RiveLayerState* __nullable)stateChangedFromIndex:(NSInteger)index error:(NSError**)error;
|
||||
- (RiveLayerState* __nullable)stateChangedFromIndex:(NSInteger)index
|
||||
error:(NSError**)error;
|
||||
- (NSArray<NSString*>*)stateChanges;
|
||||
/// Returns number of reported events on the state machine since the last frame
|
||||
- (NSInteger)reportedEventCount;
|
||||
@@ -49,23 +52,28 @@ typedef NS_ENUM(NSInteger, RiveHitResult) { none, hit, hitOpaque };
|
||||
// MARK: Touch
|
||||
|
||||
/// Tells this StateMachineInstance that a user began touching the artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating
|
||||
/// artboard
|
||||
/// @return The RiveHitResult of a touch beginning at the provided location.
|
||||
- (RiveHitResult)touchBeganAtLocation:(CGPoint)touchLocation;
|
||||
|
||||
/// Tells this StateMachineInstance that a touch moved on the artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating
|
||||
/// artboard
|
||||
/// @return The RiveHitResult of a touch moving at the provided location.
|
||||
- (RiveHitResult)touchMovedAtLocation:(CGPoint)touchLocation;
|
||||
|
||||
/// Tells this StateMachineInstance that a user finished touching the artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating
|
||||
/// artboard
|
||||
/// @return The RiveHitResult of a touch ending at the provided location.
|
||||
- (RiveHitResult)touchEndedAtLocation:(CGPoint)touchLocation;
|
||||
|
||||
/// Tells this StateMachineInstance that a user cancelled touching the artboard
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating artboard
|
||||
/// @return The RiveHitResult of a touch being cancelled at the provided location.
|
||||
/// @param touchLocation A CGPoint in the coordinate space of the animating
|
||||
/// artboard
|
||||
/// @return The RiveHitResult of a touch being cancelled at the provided
|
||||
/// location.
|
||||
- (RiveHitResult)touchCancelledAtLocation:(CGPoint)touchLocation;
|
||||
|
||||
// MARK: Debug
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#import "RivePrivateHeaders.h"
|
||||
#import <RenderContext.h>
|
||||
#import <RenderContextManager.h>
|
||||
// We manually need to provide this as our build-time config isn't shared with xcode.
|
||||
// We manually need to provide this as our build-time config isn't shared with
|
||||
// xcode.
|
||||
#define WITH_RIVE_AUDIO
|
||||
#include "rive/audio/audio_engine.hpp"
|
||||
|
||||
@@ -43,23 +44,27 @@
|
||||
- (instancetype)initWithCoder:(NSCoder*)decoder
|
||||
{
|
||||
#if TARGET_OS_IPHONE
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
#else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:NSApplicationDidResignActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:NSApplicationWillBecomeActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:NSApplicationDidResignActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:NSApplicationWillBecomeActiveNotification
|
||||
object:nil];
|
||||
#endif
|
||||
self = [super initWithCoder:decoder];
|
||||
|
||||
@@ -78,28 +83,33 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frameRect
|
||||
{
|
||||
#if TARGET_OS_IPHONE
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:UIApplicationDidEnterBackgroundNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:UIApplicationWillEnterForegroundNotification
|
||||
object:nil];
|
||||
#else
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:NSApplicationDidResignActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:NSApplicationWillBecomeActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterBackground:)
|
||||
name:NSApplicationDidResignActiveNotification
|
||||
object:nil];
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
addObserver:self
|
||||
selector:@selector(didEnterForeground:)
|
||||
name:NSApplicationWillBecomeActiveNotification
|
||||
object:nil];
|
||||
#endif
|
||||
_renderContext = [[RenderContextManager shared] getDefaultContext];
|
||||
assert(_renderContext);
|
||||
|
||||
auto value = [super initWithFrame:frameRect device:_renderContext.metalDevice];
|
||||
auto value = [super initWithFrame:frameRect
|
||||
device:_renderContext.metalDevice];
|
||||
|
||||
[self setDepthStencilPixelFormat:_renderContext.depthStencilPixelFormat];
|
||||
[self setColorPixelFormat:MTLPixelFormatBGRA8Unorm];
|
||||
@@ -141,7 +151,12 @@
|
||||
_renderer->restore();
|
||||
}
|
||||
|
||||
- (void)transform:(float)xx xy:(float)xy yx:(float)yx yy:(float)yy tx:(float)tx ty:(float)ty
|
||||
- (void)transform:(float)xx
|
||||
xy:(float)xy
|
||||
yx:(float)yx
|
||||
yy:(float)yy
|
||||
tx:(float)tx
|
||||
ty:(float)ty
|
||||
{
|
||||
assert(_renderer != nil);
|
||||
_renderer->transform(rive::Mat2D{xx, xy, yx, yy, tx, ty});
|
||||
@@ -163,7 +178,8 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
- (void)drawInRect:(CGRect)rect withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler
|
||||
- (void)drawInRect:(CGRect)rect
|
||||
withCompletion:(_Nullable MTLCommandBufferHandler)completionHandler
|
||||
{
|
||||
if (CGRectGetWidth(rect) == 0 || CGRectGetHeight(rect) == 0)
|
||||
{
|
||||
@@ -285,7 +301,8 @@
|
||||
auto riveFit = [self riveFit:fit];
|
||||
auto riveAlignment = [self riveAlignment:alignment];
|
||||
|
||||
rive::Mat2D forward = rive::computeAlignment(riveFit, riveAlignment, frame, content);
|
||||
rive::Mat2D forward =
|
||||
rive::computeAlignment(riveFit, riveAlignment, frame, content);
|
||||
rive::Mat2D inverse = forward.invertOrIdentity();
|
||||
|
||||
rive::Vec2D frameLocation(touchLocation.x, touchLocation.y);
|
||||
|
||||
@@ -14,8 +14,8 @@ FOUNDATION_EXPORT double RiveRuntimeVersionNumber;
|
||||
//! Project version string for RiveRuntime.
|
||||
FOUNDATION_EXPORT const unsigned char RiveRuntimeVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like
|
||||
// #import <RiveRuntime/PublicHeader.h>
|
||||
// In this header, you should import all the public headers of your framework
|
||||
// using statements like #import <RiveRuntime/PublicHeader.h>
|
||||
#import <RiveRuntime/Rive.h>
|
||||
#import <RiveRuntime/LayerState.h>
|
||||
#import <RiveRuntime/RiveFile.h>
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
image = (RiveImageAsset*)asset;
|
||||
@@ -52,8 +53,10 @@
|
||||
XCTAssertEqualObjects([image uniqueName], @"image-49934");
|
||||
XCTAssertEqualObjects([image uniqueFilename], @"image-49934.png");
|
||||
XCTAssertEqualObjects([image fileExtension], @"png");
|
||||
XCTAssertEqualObjects([image cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([image cdnUuid], @"eadb7ed8-6d71-4b6c-bbc2-f0f5e9c5dd92");
|
||||
XCTAssertEqualObjects([image cdnBaseUrl],
|
||||
@"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([image cdnUuid],
|
||||
@"eadb7ed8-6d71-4b6c-bbc2-f0f5e9c5dd92");
|
||||
|
||||
XCTAssertNotNil(font);
|
||||
XCTAssertEqual(fontData.length, 0);
|
||||
@@ -61,8 +64,10 @@
|
||||
XCTAssertEqualObjects([font uniqueName], @"Inter-45562");
|
||||
XCTAssertEqualObjects([font uniqueFilename], @"Inter-45562.ttf");
|
||||
XCTAssertEqualObjects([font fileExtension], @"ttf");
|
||||
XCTAssertEqualObjects([font cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([font cdnUuid], @"60ad5ede-993c-4e03-9a80-e56888b2cff3");
|
||||
XCTAssertEqualObjects([font cdnBaseUrl],
|
||||
@"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([font cdnUuid],
|
||||
@"60ad5ede-993c-4e03-9a80-e56888b2cff3");
|
||||
}
|
||||
|
||||
- (void)testAudioAssetCallbacks
|
||||
@@ -78,7 +83,8 @@
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveAudioAsset class]])
|
||||
{
|
||||
if (data.length > 0)
|
||||
@@ -104,8 +110,10 @@
|
||||
XCTAssertEqualObjects([hosted uniqueName], @"hosted-55368");
|
||||
XCTAssertEqualObjects([hosted uniqueFilename], @"hosted-55368.wav");
|
||||
XCTAssertEqualObjects([hosted fileExtension], @"wav");
|
||||
XCTAssertEqualObjects([hosted cdnBaseUrl], @"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([hosted cdnUuid], @"79b65f1e-94ea-4191-b5ad-b3d5495b6343");
|
||||
XCTAssertEqualObjects([hosted cdnBaseUrl],
|
||||
@"https://public.uat.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([hosted cdnUuid],
|
||||
@"79b65f1e-94ea-4191-b5ad-b3d5495b6343");
|
||||
|
||||
XCTAssertNotNil(embedded);
|
||||
XCTAssertEqual(embeddedData.length, 26095);
|
||||
@@ -114,7 +122,8 @@
|
||||
XCTAssertEqualObjects([embedded uniqueName], @"embedded-0");
|
||||
XCTAssertEqualObjects([embedded uniqueFilename], @"embedded-0.wav");
|
||||
XCTAssertEqualObjects([embedded fileExtension], @"wav");
|
||||
XCTAssertEqualObjects([embedded cdnBaseUrl], @"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([embedded cdnBaseUrl],
|
||||
@"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([embedded cdnUuid], @"");
|
||||
}
|
||||
|
||||
@@ -130,7 +139,8 @@
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
|
||||
@@ -176,7 +186,8 @@
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
image = (RiveImageAsset*)asset;
|
||||
@@ -200,7 +211,8 @@
|
||||
XCTAssertEqualObjects([image name], @"1x1.png");
|
||||
XCTAssertEqualObjects([image uniqueFilename], @"1x1-49935.png");
|
||||
XCTAssertEqualObjects([image fileExtension], @"png");
|
||||
XCTAssertEqualObjects([image cdnBaseUrl], @"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([image cdnBaseUrl],
|
||||
@"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([image cdnUuid], @"");
|
||||
|
||||
XCTAssertNotNil(font);
|
||||
@@ -209,7 +221,8 @@
|
||||
XCTAssertEqualObjects([font name], @"Inter");
|
||||
XCTAssertEqualObjects([font uniqueFilename], @"Inter-45562.ttf");
|
||||
XCTAssertEqualObjects([font fileExtension], @"ttf");
|
||||
XCTAssertEqualObjects([font cdnBaseUrl], @"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([font cdnBaseUrl],
|
||||
@"https://public.rive.app/cdn/uuid");
|
||||
XCTAssertEqualObjects([font cdnUuid], @"");
|
||||
}
|
||||
|
||||
@@ -222,7 +235,8 @@
|
||||
RiveFile* file = [[RiveFile alloc]
|
||||
initWithData:data
|
||||
loadCdn:false
|
||||
customAssetLoader:^bool(RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
customAssetLoader:^bool(
|
||||
RiveFileAsset* asset, NSData* data, RiveFactory* factory) {
|
||||
if ([asset isKindOfClass:[RiveImageAsset class]])
|
||||
{
|
||||
image = (RiveImageAsset*)asset;
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"loop" error:nil];
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"loop"
|
||||
error:nil];
|
||||
|
||||
XCTAssertEqual([animation loop], RiveLoop::loop);
|
||||
}
|
||||
@@ -37,7 +38,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"pingpong" error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"pingpong" error:nil];
|
||||
|
||||
XCTAssertEqual([animation loop], RiveLoop::pingPong);
|
||||
}
|
||||
@@ -50,7 +52,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"oneshot" error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"oneshot" error:nil];
|
||||
|
||||
XCTAssertEqual([animation loop], RiveLoop::oneShot);
|
||||
}
|
||||
@@ -63,7 +66,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec60fps" error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"1sec60fps" error:nil];
|
||||
|
||||
XCTAssertEqual([animation duration], 60);
|
||||
XCTAssertEqual([animation effectiveDuration], 60);
|
||||
@@ -87,7 +91,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec120fps" error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"1sec120fps" error:nil];
|
||||
|
||||
XCTAssertEqual([animation duration], 120);
|
||||
XCTAssertEqual([animation effectiveDuration], 120);
|
||||
@@ -104,8 +109,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec60fps_f30f50"
|
||||
error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"1sec60fps_f30f50" error:nil];
|
||||
|
||||
XCTAssertEqual([animation duration], 60);
|
||||
XCTAssertEqual([animation effectiveDuration], 20);
|
||||
@@ -118,7 +123,8 @@
|
||||
|
||||
// seconds = duation / fps = 20/60
|
||||
const float secs = 20.0 / 60.0;
|
||||
XCTAssertEqualWithAccuracy([animation effectiveDurationInSeconds], secs, accuracy);
|
||||
XCTAssertEqualWithAccuracy(
|
||||
[animation effectiveDurationInSeconds], secs, accuracy);
|
||||
|
||||
// time = effectiveDuration / fps = 50/60
|
||||
const float time = 50.0 / 60.0;
|
||||
@@ -133,8 +139,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"animationconfigurations" error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"1sec120fps_f50f80"
|
||||
error:nil];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"1sec120fps_f50f80" error:nil];
|
||||
|
||||
XCTAssertEqual([animation duration], 120);
|
||||
XCTAssertEqual([animation effectiveDuration], 30);
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"artboard1" error:&error];
|
||||
|
||||
RiveLinearAnimationInstance* animationByIndex = [artboard animationFromIndex:0 error:&error];
|
||||
RiveLinearAnimationInstance* animationByIndex =
|
||||
[artboard animationFromIndex:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
|
||||
RiveLinearAnimationInstance* animationByName =
|
||||
@@ -47,7 +48,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"artboard2" error:&error];
|
||||
|
||||
RiveLinearAnimationInstance* animationByIndex = [artboard animationFromIndex:0 error:&error];
|
||||
RiveLinearAnimationInstance* animationByIndex =
|
||||
[artboard animationFromIndex:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
RiveLinearAnimationInstance* animationByName =
|
||||
[artboard animationFromName:@"artboard2animation1" error:&error];
|
||||
@@ -55,16 +57,18 @@
|
||||
|
||||
XCTAssertTrue([animationByName.name isEqualToString:animationByIndex.name]);
|
||||
|
||||
RiveLinearAnimationInstance* animation2ByIndex = [artboard animationFromIndex:1 error:&error];
|
||||
RiveLinearAnimationInstance* animation2ByIndex =
|
||||
[artboard animationFromIndex:1 error:&error];
|
||||
XCTAssertNil(error);
|
||||
RiveLinearAnimationInstance* animation2ByName =
|
||||
[artboard animationFromName:@"artboard2animation2" error:&error];
|
||||
XCTAssertNil(error);
|
||||
|
||||
XCTAssertTrue([animation2ByIndex.name isEqualToString:animation2ByName.name]);
|
||||
XCTAssertTrue(
|
||||
[animation2ByIndex.name isEqualToString:animation2ByName.name]);
|
||||
|
||||
NSArray* target =
|
||||
[NSArray arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil];
|
||||
NSArray* target = [NSArray
|
||||
arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil];
|
||||
XCTAssertTrue([[artboard animationNames] isEqualToArray:target]);
|
||||
}
|
||||
|
||||
@@ -90,12 +94,14 @@
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
NSError* error = nil;
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:&error];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromIndex:0 error:&error];
|
||||
XCTAssertNil(animation);
|
||||
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoAnimationFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoAnimationFound");
|
||||
XCTAssertEqual([error code], 201);
|
||||
}
|
||||
|
||||
@@ -108,12 +114,14 @@
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
NSError* error = nil;
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"boo" error:&error];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"boo" error:&error];
|
||||
XCTAssertNil(animation);
|
||||
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoAnimationFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoAnimationFound");
|
||||
XCTAssertEqual([error code], 201);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@
|
||||
XCTAssertEqual([[file artboardFromIndex:0 error:nil] name],
|
||||
[[file artboardFromName:@"artboard2" error:nil] name]);
|
||||
|
||||
NSArray* target = [NSArray arrayWithObjects:@"artboard2", @"artboard1", nil];
|
||||
NSArray* target =
|
||||
[NSArray arrayWithObjects:@"artboard2", @"artboard1", nil];
|
||||
XCTAssertTrue([[file artboardNames] isEqualToArray:target]);
|
||||
}
|
||||
|
||||
@@ -59,7 +60,8 @@
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 100);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardsFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoArtboardsFound");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -76,7 +78,8 @@
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 101);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoArtboardFound");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -93,7 +96,8 @@
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 101);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoArtboardFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoArtboardFound");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -120,7 +124,8 @@
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"testtext" error:nil];
|
||||
NSError* error = nil;
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard"
|
||||
error:&error];
|
||||
RiveTextValueRun* textRun = [artboard textRun:@"MyRun"];
|
||||
|
||||
XCTAssertTrue([[textRun text] isEqualToString:@"Hello there"]);
|
||||
@@ -133,7 +138,8 @@
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"testtext" error:nil];
|
||||
NSError* error = nil;
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard"
|
||||
error:&error];
|
||||
RiveTextValueRun* textRun = [artboard textRun:@"MyRun"];
|
||||
XCTAssertTrue([[textRun text] isEqualToString:@"Hello there"]);
|
||||
[textRun setText:@"Hello text"];
|
||||
@@ -166,7 +172,8 @@
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"testtext" error:nil];
|
||||
NSError* error = nil;
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"New Artboard"
|
||||
error:&error];
|
||||
RiveTextValueRun* textRun = [artboard textRun:@"BADRUN"];
|
||||
XCTAssertNil(textRun);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
XCTAssertNil(file);
|
||||
XCTAssertNotNil(error);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"UnsupportedVersion");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"UnsupportedVersion");
|
||||
XCTAssertEqual([error code], 500);
|
||||
}
|
||||
|
||||
@@ -64,7 +65,8 @@
|
||||
{
|
||||
if ([[RenderContextManager shared] getRiveRendererContext] != nil)
|
||||
{
|
||||
[[RenderContextManager shared] setDefaultRenderer:RendererType::riveRenderer];
|
||||
[[RenderContextManager shared]
|
||||
setDefaultRenderer:RendererType::riveRenderer];
|
||||
}
|
||||
NSError* error = nil;
|
||||
RiveFile* file = [Util loadTestFile:@"flux_capacitor" error:&error];
|
||||
|
||||
@@ -16,91 +16,114 @@
|
||||
|
||||
@implementation RiveRuntimeTests
|
||||
|
||||
UInt8 brokenRiveFileBytes[] = {0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B,
|
||||
0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x00, 0x7A, 0x43, 0x00};
|
||||
UInt8 brokenRiveFileBytes[] = {0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00,
|
||||
0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D,
|
||||
0x61, 0x74, 0x00, 0x7A, 0x43, 0x00};
|
||||
|
||||
UInt8 pingPongRiveFileBytes[] = {
|
||||
0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0x8B, 0x94, 0x02, 0x00, 0x17, 0x00, 0x01, 0x07, 0x00, 0x00,
|
||||
0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x04, 0x0C, 0x4E, 0x65, 0x77, 0x20, 0x41, 0x72, 0x74,
|
||||
0x62, 0x6F, 0x61, 0x72, 0x64, 0x00, 0x03, 0x05, 0x00, 0x0D, 0x00, 0x00, 0x7A, 0x43, 0x0E, 0x00,
|
||||
0x00, 0x7A, 0x43, 0x00, 0x07, 0x05, 0x01, 0x14, 0xEA, 0xA3, 0xC7, 0x42, 0x15, 0xEA, 0xA3, 0xC7,
|
||||
0x42, 0x00, 0x14, 0x05, 0x01, 0x00, 0x12, 0x05, 0x03, 0x00, 0x14, 0x05, 0x00, 0x00, 0x12, 0x05,
|
||||
0x05, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74,
|
||||
0x69, 0x6F, 0x6E, 0x20, 0x31, 0x39, 0x0A, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00,
|
||||
0x1E, 0x44, 0x01, 0x46, 0xE8, 0xA3, 0x47, 0x42, 0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x83,
|
||||
0x0B, 0xE1, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43,
|
||||
0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0x8B, 0x94, 0x02, 0x00, 0x17, 0x00,
|
||||
0x01, 0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x04,
|
||||
0x0C, 0x4E, 0x65, 0x77, 0x20, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72,
|
||||
0x64, 0x00, 0x03, 0x05, 0x00, 0x0D, 0x00, 0x00, 0x7A, 0x43, 0x0E, 0x00,
|
||||
0x00, 0x7A, 0x43, 0x00, 0x07, 0x05, 0x01, 0x14, 0xEA, 0xA3, 0xC7, 0x42,
|
||||
0x15, 0xEA, 0xA3, 0xC7, 0x42, 0x00, 0x14, 0x05, 0x01, 0x00, 0x12, 0x05,
|
||||
0x03, 0x00, 0x14, 0x05, 0x00, 0x00, 0x12, 0x05, 0x05, 0x25, 0x31, 0x31,
|
||||
0x31, 0xFF, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74,
|
||||
0x69, 0x6F, 0x6E, 0x20, 0x31, 0x39, 0x0A, 0x00, 0x19, 0x33, 0x01, 0x00,
|
||||
0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0xE8, 0xA3, 0x47, 0x42,
|
||||
0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x83, 0x0B, 0xE1, 0x43, 0x00,
|
||||
0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43,
|
||||
0x00, 0x1E, 0x43, 0x0A, 0x44, 0x01, 0x46, 0x00, 0x00, 0x7A, 0x43, 0x00};
|
||||
|
||||
UInt8 stateMachineFileBytes[] = {
|
||||
0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0xE1, 0x20, 0x00, 0x17, 0x00, 0x01, 0x04, 0x0A, 0x4D, 0x79,
|
||||
0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, 0x64, 0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00,
|
||||
0xFA, 0x43, 0x09, 0x00, 0x00, 0xBE, 0xC2, 0x0A, 0x00, 0x00, 0xD2, 0xC2, 0x00, 0x03, 0x04, 0x0B,
|
||||
0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x05, 0x00, 0x0D, 0x78, 0x55,
|
||||
0x48, 0x42, 0x0E, 0x78, 0x55, 0x48, 0x42, 0x00, 0x07, 0x04, 0x0F, 0x4D, 0x79, 0x52, 0x65, 0x63,
|
||||
0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x50, 0x61, 0x74, 0x68, 0x05, 0x01, 0x14, 0x7A, 0x55, 0xC8,
|
||||
0x42, 0x15, 0x7A, 0x55, 0xC8, 0x42, 0x00, 0x12, 0x05, 0x05, 0x00, 0x12, 0x05, 0x06, 0x25, 0x31,
|
||||
0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x01, 0x00, 0x14, 0x04, 0x0A, 0x42, 0x61, 0x63, 0x6B, 0x67,
|
||||
0x72, 0x6F, 0x75, 0x6E, 0x64, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x19, 0x57, 0x6F, 0x72, 0x6B, 0x41,
|
||||
0x72, 0x65, 0x61, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61,
|
||||
0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x3C, 0x0F, 0x3D, 0x2E, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01,
|
||||
0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43,
|
||||
0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51,
|
||||
0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A,
|
||||
0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44,
|
||||
0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0,
|
||||
0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18,
|
||||
0x57, 0x6F, 0x72, 0x6B, 0x41, 0x72, 0x65, 0x61, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67, 0x41,
|
||||
0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x3C, 0x0F, 0x3D, 0x2D, 0x3E, 0x01,
|
||||
0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48,
|
||||
0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5,
|
||||
0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00,
|
||||
0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42,
|
||||
0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B, 0x41, 0x72, 0x65, 0x61, 0x4F, 0x6E, 0x65, 0x53,
|
||||
0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3C, 0x0F, 0x3D, 0x2D,
|
||||
0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A,
|
||||
0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E,
|
||||
0x43, 0x28, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46,
|
||||
0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48,
|
||||
0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55,
|
||||
0x48, 0x42, 0x00, 0x1F, 0x37, 0x11, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41, 0x6E,
|
||||
0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35,
|
||||
0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55,
|
||||
0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37,
|
||||
0x10, 0x4F, 0x6E, 0x65, 0x53, 0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x6E, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55,
|
||||
0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35,
|
||||
0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67,
|
||||
0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00,
|
||||
0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01, 0x46,
|
||||
0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x45, 0x04, 0x46, 0x51, 0xF5, 0xE0,
|
||||
0x43, 0x00, 0x35, 0x37, 0x0C, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4D, 0x61, 0x63, 0x68, 0x69, 0x6E,
|
||||
0x65, 0x00, 0x38, 0x8A, 0x01, 0x05, 0x4D, 0x79, 0x4E, 0x75, 0x6D, 0x00, 0x3B, 0x8A, 0x01, 0x06,
|
||||
0x4D, 0x79, 0x42, 0x6F, 0x6F, 0x6C, 0x00, 0x3A, 0x8A, 0x01, 0x06, 0x4D, 0x79, 0x54, 0x72, 0x69,
|
||||
0x67, 0x00, 0x39, 0x8A, 0x01, 0x07, 0x4C, 0x61, 0x79, 0x65, 0x72, 0x20, 0x31, 0x00, 0x3E, 0x00,
|
||||
0x3D, 0x95, 0x01, 0x05, 0x00, 0x41, 0x97, 0x01, 0x04, 0x00, 0x44, 0x9B, 0x01, 0x02, 0x00, 0x40,
|
||||
0x00, 0x3F, 0x00, 0x41, 0x97, 0x01, 0x01, 0x00, 0x3D, 0x95, 0x01, 0x03, 0x00, 0x41, 0x97, 0x01,
|
||||
0x02, 0x00, 0x47, 0x9B, 0x01, 0x01, 0x00, 0x01, 0x04, 0x09, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61,
|
||||
0x72, 0x64, 0x32, 0x07, 0x00, 0x80, 0x8C, 0x43, 0x08, 0x00, 0x80, 0x8C, 0x43, 0x09, 0x00, 0x80,
|
||||
0xE9, 0xC3, 0x0A, 0x00, 0x00, 0x5B, 0x43, 0x00, 0x12, 0x05, 0x02, 0x25, 0x31, 0x31, 0x31, 0xFF,
|
||||
0x00, 0x14, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x52, 0x49, 0x56, 0x45, 0x07, 0x00, 0xE1, 0x20, 0x00, 0x17, 0x00, 0x01,
|
||||
0x04, 0x0A, 0x4D, 0x79, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61, 0x72, 0x64,
|
||||
0x07, 0x00, 0x00, 0xFA, 0x43, 0x08, 0x00, 0x00, 0xFA, 0x43, 0x09, 0x00,
|
||||
0x00, 0xBE, 0xC2, 0x0A, 0x00, 0x00, 0xD2, 0xC2, 0x00, 0x03, 0x04, 0x0B,
|
||||
0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67, 0x6C, 0x65, 0x05,
|
||||
0x00, 0x0D, 0x78, 0x55, 0x48, 0x42, 0x0E, 0x78, 0x55, 0x48, 0x42, 0x00,
|
||||
0x07, 0x04, 0x0F, 0x4D, 0x79, 0x52, 0x65, 0x63, 0x74, 0x61, 0x6E, 0x67,
|
||||
0x6C, 0x65, 0x50, 0x61, 0x74, 0x68, 0x05, 0x01, 0x14, 0x7A, 0x55, 0xC8,
|
||||
0x42, 0x15, 0x7A, 0x55, 0xC8, 0x42, 0x00, 0x12, 0x05, 0x05, 0x00, 0x12,
|
||||
0x05, 0x06, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x01, 0x00,
|
||||
0x14, 0x04, 0x0A, 0x42, 0x61, 0x63, 0x6B, 0x67, 0x72, 0x6F, 0x75, 0x6E,
|
||||
0x64, 0x05, 0x00, 0x00, 0x1F, 0x37, 0x19, 0x57, 0x6F, 0x72, 0x6B, 0x41,
|
||||
0x72, 0x65, 0x61, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F, 0x6E, 0x67, 0x41,
|
||||
0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x02, 0x3C, 0x0F,
|
||||
0x3D, 0x2E, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D,
|
||||
0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43,
|
||||
0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44,
|
||||
0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E,
|
||||
0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44,
|
||||
0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46,
|
||||
0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B,
|
||||
0x41, 0x72, 0x65, 0x61, 0x4C, 0x6F, 0x6F, 0x70, 0x69, 0x6E, 0x67, 0x41,
|
||||
0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B, 0x01, 0x3C, 0x0F,
|
||||
0x3D, 0x2D, 0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D,
|
||||
0x00, 0x1E, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43,
|
||||
0x14, 0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44,
|
||||
0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E,
|
||||
0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44,
|
||||
0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46,
|
||||
0x78, 0x55, 0x48, 0x42, 0x00, 0x1F, 0x37, 0x18, 0x57, 0x6F, 0x72, 0x6B,
|
||||
0x41, 0x72, 0x65, 0x61, 0x4F, 0x6E, 0x65, 0x53, 0x68, 0x6F, 0x74, 0x41,
|
||||
0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3C, 0x0F, 0x3D, 0x2D,
|
||||
0x3E, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E,
|
||||
0x44, 0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44,
|
||||
0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46,
|
||||
0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44, 0x01,
|
||||
0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x14, 0x44, 0x01, 0x46,
|
||||
0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x28, 0x44, 0x01, 0x46, 0x51,
|
||||
0xF5, 0xE0, 0x43, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01, 0x46, 0x78, 0x55,
|
||||
0x48, 0x42, 0x00, 0x1F, 0x37, 0x11, 0x50, 0x69, 0x6E, 0x67, 0x50, 0x6F,
|
||||
0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x3B,
|
||||
0x02, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44,
|
||||
0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44,
|
||||
0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4F, 0x6E, 0x65,
|
||||
0x53, 0x68, 0x6F, 0x74, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x6E, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00, 0x1E, 0x44,
|
||||
0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00, 0x1E, 0x44,
|
||||
0x01, 0x46, 0x7A, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C, 0x44, 0x01,
|
||||
0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1F, 0x37, 0x10, 0x4C, 0x6F, 0x6F,
|
||||
0x70, 0x69, 0x6E, 0x67, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x6E, 0x3B, 0x01, 0x00, 0x19, 0x33, 0x01, 0x00, 0x1A, 0x35, 0x0D, 0x00,
|
||||
0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C,
|
||||
0x44, 0x01, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x1A, 0x35, 0x0E, 0x00,
|
||||
0x1E, 0x44, 0x01, 0x46, 0x78, 0x55, 0x48, 0x42, 0x00, 0x1E, 0x43, 0x3C,
|
||||
0x44, 0x01, 0x45, 0x04, 0x46, 0x51, 0xF5, 0xE0, 0x43, 0x00, 0x35, 0x37,
|
||||
0x0C, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4D, 0x61, 0x63, 0x68, 0x69, 0x6E,
|
||||
0x65, 0x00, 0x38, 0x8A, 0x01, 0x05, 0x4D, 0x79, 0x4E, 0x75, 0x6D, 0x00,
|
||||
0x3B, 0x8A, 0x01, 0x06, 0x4D, 0x79, 0x42, 0x6F, 0x6F, 0x6C, 0x00, 0x3A,
|
||||
0x8A, 0x01, 0x06, 0x4D, 0x79, 0x54, 0x72, 0x69, 0x67, 0x00, 0x39, 0x8A,
|
||||
0x01, 0x07, 0x4C, 0x61, 0x79, 0x65, 0x72, 0x20, 0x31, 0x00, 0x3E, 0x00,
|
||||
0x3D, 0x95, 0x01, 0x05, 0x00, 0x41, 0x97, 0x01, 0x04, 0x00, 0x44, 0x9B,
|
||||
0x01, 0x02, 0x00, 0x40, 0x00, 0x3F, 0x00, 0x41, 0x97, 0x01, 0x01, 0x00,
|
||||
0x3D, 0x95, 0x01, 0x03, 0x00, 0x41, 0x97, 0x01, 0x02, 0x00, 0x47, 0x9B,
|
||||
0x01, 0x01, 0x00, 0x01, 0x04, 0x09, 0x41, 0x72, 0x74, 0x62, 0x6F, 0x61,
|
||||
0x72, 0x64, 0x32, 0x07, 0x00, 0x80, 0x8C, 0x43, 0x08, 0x00, 0x80, 0x8C,
|
||||
0x43, 0x09, 0x00, 0x80, 0xE9, 0xC3, 0x0A, 0x00, 0x00, 0x5B, 0x43, 0x00,
|
||||
0x12, 0x05, 0x02, 0x25, 0x31, 0x31, 0x31, 0xFF, 0x00, 0x14, 0x05, 0x00,
|
||||
0x00, 0x1F, 0x37, 0x0B, 0x41, 0x6E, 0x69, 0x6D, 0x61, 0x74, 0x69, 0x6F,
|
||||
0x6E, 0x20, 0x31, 0x00};
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
// Put setup code here. This method is called before the invocation of each test method in the
|
||||
// class.
|
||||
// Put setup code here. This method is called before the invocation of each
|
||||
// test method in the class.
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the
|
||||
// class.
|
||||
// Put teardown code here. This method is called after the invocation of
|
||||
// each test method in the class.
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -199,7 +222,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssert(artboard != NULL);
|
||||
XCTAssert([artboard animationCount] == 1);
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:nil];
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0
|
||||
error:nil];
|
||||
XCTAssert(animation != NULL);
|
||||
XCTAssert([animation.name isEqual:@"Animation 1"]);
|
||||
}
|
||||
@@ -215,7 +239,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0 error:nil];
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromIndex:0
|
||||
error:nil];
|
||||
XCTAssert(animation != NULL);
|
||||
XCTAssert([[animation name] isEqual:@"Animation 1"]);
|
||||
}
|
||||
@@ -232,8 +257,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
NSError* error = nil;
|
||||
|
||||
RiveLinearAnimationInstance* animation = [artboard animationFromName:@"Animation 1"
|
||||
error:&error];
|
||||
RiveLinearAnimationInstance* animation =
|
||||
[artboard animationFromName:@"Animation 1" error:&error];
|
||||
XCTAssert(animation != NULL);
|
||||
XCTAssert([animation.name isEqual:@"Animation 1"]);
|
||||
}
|
||||
@@ -252,7 +277,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssert(artboard != NULL);
|
||||
XCTAssert([artboard stateMachineCount] == 1);
|
||||
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil];
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0
|
||||
error:nil];
|
||||
XCTAssert(machine != NULL);
|
||||
XCTAssert([machine.name isEqual:@"StateMachine"]);
|
||||
}
|
||||
@@ -271,7 +297,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssert(artboard != NULL);
|
||||
XCTAssert([artboard stateMachineCount] == 1);
|
||||
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil];
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0
|
||||
error:nil];
|
||||
XCTAssert(machine != NULL);
|
||||
XCTAssert([machine.name isEqual:@"StateMachine"]);
|
||||
|
||||
@@ -280,14 +307,16 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssertNil(machine);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 301);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoStateMachineFound");
|
||||
|
||||
error = nil;
|
||||
machine = [artboard stateMachineFromIndex:-1 error:&error];
|
||||
XCTAssertNil(machine);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 301);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoStateMachineFound");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -302,7 +331,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssert(file != NULL);
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
XCTAssert(artboard != NULL);
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromName:@"StateMachine" error:nil];
|
||||
RiveStateMachineInstance* machine =
|
||||
[artboard stateMachineFromName:@"StateMachine" error:nil];
|
||||
XCTAssert(machine != NULL);
|
||||
|
||||
NSError* error = nil;
|
||||
@@ -310,7 +340,8 @@ UInt8 stateMachineFileBytes[] = {
|
||||
XCTAssertNil(machine);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqual([error code], 301);
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoStateMachineFound");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -324,9 +355,11 @@ UInt8 stateMachineFileBytes[] = {
|
||||
error:nil];
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0 error:nil];
|
||||
RiveStateMachineInstance* machine = [artboard stateMachineFromIndex:0
|
||||
error:nil];
|
||||
XCTAssert(machine != NULL);
|
||||
RiveStateMachineInstance* instance = [[RiveStateMachineInstance alloc] init];
|
||||
RiveStateMachineInstance* instance =
|
||||
[[RiveStateMachineInstance alloc] init];
|
||||
XCTAssert(instance != NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
- (void)testNothing
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"nothing"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"nothing" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachine inputCount], 0);
|
||||
XCTAssertEqual([stateMachine layerCount], 0);
|
||||
@@ -35,10 +36,11 @@
|
||||
*/
|
||||
- (void)testOneLayer
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"one_layer"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"one_layer" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachine inputCount], 0);
|
||||
XCTAssertEqual([stateMachine layerCount], 1);
|
||||
@@ -49,10 +51,11 @@
|
||||
*/
|
||||
- (void)testTwoLayers
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"two_layers"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"two_layers" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachine inputCount], 0);
|
||||
XCTAssertEqual([stateMachine layerCount], 2);
|
||||
@@ -63,7 +66,8 @@
|
||||
*/
|
||||
- (void)testNumberInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"number_input" error:nil];
|
||||
@@ -77,8 +81,8 @@
|
||||
XCTAssertEqual([input isTrigger], 0);
|
||||
XCTAssertEqual([input isNumber], 1);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Number 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Number 1"
|
||||
error:nil] name] isEqualToString:@"Number 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Number 1" error:nil] name]
|
||||
isEqualToString:@"Number 1"]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -86,7 +90,8 @@
|
||||
*/
|
||||
- (void)testBooleanInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"boolean_input" error:nil];
|
||||
@@ -100,8 +105,8 @@
|
||||
XCTAssertEqual([input isTrigger], 0);
|
||||
XCTAssertEqual([input isNumber], 0);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Boolean 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Boolean 1"
|
||||
error:nil] name] isEqualToString:@"Boolean 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Boolean 1" error:nil] name]
|
||||
isEqualToString:@"Boolean 1"]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -109,7 +114,8 @@
|
||||
*/
|
||||
- (void)testTriggerInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"trigger_input" error:nil];
|
||||
@@ -123,8 +129,8 @@
|
||||
XCTAssertEqual([input isTrigger], 1);
|
||||
XCTAssertEqual([input isNumber], 0);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Trigger 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Trigger 1"
|
||||
error:nil] name] isEqualToString:@"Trigger 1"]);
|
||||
XCTAssertTrue([[[stateMachine inputFromName:@"Trigger 1" error:nil] name]
|
||||
isEqualToString:@"Trigger 1"]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -132,48 +138,72 @@
|
||||
*/
|
||||
- (void)testMixedInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveStateMachineInstance* stateMachine = [[file artboard:nil] stateMachineFromName:@"mixed"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[[file artboard:nil] stateMachineFromName:@"mixed" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachine inputCount], 6);
|
||||
XCTAssertEqual([stateMachine layerCount], 4);
|
||||
NSArray* target = [NSArray
|
||||
arrayWithObjects:@"zero", @"off", @"trigger", @"two_point_two", @"on", @"three", nil];
|
||||
NSArray* target = [NSArray arrayWithObjects:@"zero",
|
||||
@"off",
|
||||
@"trigger",
|
||||
@"two_point_two",
|
||||
@"on",
|
||||
@"three",
|
||||
nil];
|
||||
|
||||
XCTAssertTrue([[stateMachine inputNames] isEqualToArray:target]);
|
||||
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil] isNumber], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil] isBoolean], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"trigger" error:nil] isTrigger], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"two_point_two" error:nil] isNumber], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isBoolean], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil] isNumber], true);
|
||||
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil] isNumber],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil] isBoolean],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[[stateMachine inputFromName:@"zero" error:nil] isKindOfClass:[RiveSMINumber class]], true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"zero" error:nil] value], 0);
|
||||
[[stateMachine inputFromName:@"trigger" error:nil] isTrigger], true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"two_point_two"
|
||||
error:nil] isKindOfClass:[RiveSMINumber class]],
|
||||
error:nil] isNumber],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"two_point_two" error:nil] value],
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isBoolean],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil] isNumber],
|
||||
true);
|
||||
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"zero" error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"zero"
|
||||
error:nil] value],
|
||||
0);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"two_point_two" error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"two_point_two"
|
||||
error:nil] value],
|
||||
(float)2.2);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"three"
|
||||
error:nil] isKindOfClass:[RiveSMINumber class]],
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"three" error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"three" error:nil] value],
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachine inputFromName:@"three"
|
||||
error:nil] value],
|
||||
(float)3);
|
||||
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil] isKindOfClass:[RiveSMIBool class]],
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"on" error:nil]
|
||||
isKindOfClass:[RiveSMIBool class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"on" error:nil] value], true);
|
||||
XCTAssertEqual(
|
||||
[[stateMachine inputFromName:@"off" error:nil] isKindOfClass:[RiveSMIBool class]], true);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"off" error:nil] value], false);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"on"
|
||||
error:nil] value],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"off" error:nil]
|
||||
isKindOfClass:[RiveSMIBool class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachine inputFromName:@"off"
|
||||
error:nil] value],
|
||||
false);
|
||||
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"trigger"
|
||||
error:nil] isKindOfClass:[RiveSMITrigger class]],
|
||||
XCTAssertEqual([[stateMachine inputFromName:@"trigger" error:nil]
|
||||
isKindOfClass:[RiveSMITrigger class]],
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"artboard1" error:&error];
|
||||
|
||||
RiveStateMachineInstance* animationByIndex = [artboard stateMachineFromIndex:0 error:&error];
|
||||
RiveStateMachineInstance* animationByIndex =
|
||||
[artboard stateMachineFromIndex:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
RiveStateMachineInstance* animationByName =
|
||||
[artboard stateMachineFromName:@"artboard1stateMachine1" error:&error];
|
||||
@@ -46,7 +47,8 @@
|
||||
RiveFile* file = [Util loadTestFile:@"multipleartboards" error:&error];
|
||||
RiveArtboard* artboard = [file artboardFromName:@"artboard2" error:&error];
|
||||
|
||||
RiveStateMachineInstance* animationByIndex = [artboard stateMachineFromIndex:0 error:&error];
|
||||
RiveStateMachineInstance* animationByIndex =
|
||||
[artboard stateMachineFromIndex:0 error:&error];
|
||||
XCTAssertNil(error);
|
||||
RiveStateMachineInstance* animationByName =
|
||||
[artboard stateMachineFromName:@"artboard2stateMachine1" error:&error];
|
||||
@@ -54,16 +56,18 @@
|
||||
|
||||
XCTAssertTrue([animationByName.name isEqualToString:animationByIndex.name]);
|
||||
|
||||
RiveStateMachineInstance* animation2ByIndex = [artboard stateMachineFromIndex:1 error:&error];
|
||||
RiveStateMachineInstance* animation2ByIndex =
|
||||
[artboard stateMachineFromIndex:1 error:&error];
|
||||
XCTAssertNil(error);
|
||||
RiveStateMachineInstance* animation2ByName =
|
||||
[artboard stateMachineFromName:@"artboard2stateMachine2" error:&error];
|
||||
XCTAssertNil(error);
|
||||
|
||||
XCTAssertTrue([animation2ByIndex.name isEqualToString:animation2ByName.name]);
|
||||
XCTAssertTrue(
|
||||
[animation2ByIndex.name isEqualToString:animation2ByName.name]);
|
||||
|
||||
NSArray* target =
|
||||
[NSArray arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil];
|
||||
NSArray* target = [NSArray
|
||||
arrayWithObjects:@"artboard2animation1", @"artboard2animation2", nil];
|
||||
XCTAssertTrue([[artboard animationNames] isEqualToArray:target]);
|
||||
}
|
||||
|
||||
@@ -89,11 +93,13 @@
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
NSError* error = nil;
|
||||
RiveStateMachineInstance* stateMachine = [artboard stateMachineFromIndex:0 error:&error];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[artboard stateMachineFromIndex:0 error:&error];
|
||||
|
||||
XCTAssertNil(stateMachine);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoStateMachineFound");
|
||||
XCTAssertEqual([error code], 301);
|
||||
}
|
||||
|
||||
@@ -106,10 +112,12 @@
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
|
||||
NSError* error = nil;
|
||||
RiveStateMachineInstance* stateMachine = [artboard stateMachineFromName:@"boo" error:&error];
|
||||
RiveStateMachineInstance* stateMachine =
|
||||
[artboard stateMachineFromName:@"boo" error:&error];
|
||||
XCTAssertNil(stateMachine);
|
||||
XCTAssertEqualObjects([error domain], @"rive.app.ios.runtime");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"], @"NoStateMachineFound");
|
||||
XCTAssertEqualObjects([[error userInfo] valueForKey:@"name"],
|
||||
@"NoStateMachineFound");
|
||||
XCTAssertEqual([error code], 301);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,12 @@
|
||||
*/
|
||||
- (void)testNothing
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"nothing"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance =
|
||||
[artboard stateMachineFromName:@"nothing" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachineInstance inputCount], 0);
|
||||
}
|
||||
@@ -35,11 +36,12 @@
|
||||
*/
|
||||
- (void)testNumberInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"number_input"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance =
|
||||
[artboard stateMachineFromName:@"number_input" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachineInstance inputCount], 1);
|
||||
|
||||
@@ -49,8 +51,8 @@
|
||||
XCTAssertEqual([input isTrigger], 0);
|
||||
XCTAssertEqual([input isNumber], 1);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Number 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Number 1"
|
||||
error:nil] name] isEqualToString:@"Number 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Number 1" error:nil]
|
||||
name] isEqualToString:@"Number 1"]);
|
||||
|
||||
[(RiveSMINumber*)input setValue:15];
|
||||
XCTAssertEqual([(RiveSMINumber*)input value], 15);
|
||||
@@ -61,11 +63,12 @@
|
||||
*/
|
||||
- (void)testBooleanInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"boolean_input"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance =
|
||||
[artboard stateMachineFromName:@"boolean_input" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachineInstance inputCount], 1);
|
||||
|
||||
@@ -75,8 +78,8 @@
|
||||
XCTAssertEqual([input isTrigger], 0);
|
||||
XCTAssertEqual([input isNumber], 0);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Boolean 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Boolean 1"
|
||||
error:nil] name] isEqualToString:@"Boolean 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Boolean 1" error:nil]
|
||||
name] isEqualToString:@"Boolean 1"]);
|
||||
|
||||
[(RiveSMIBool*)input setValue:false];
|
||||
XCTAssertEqual([(RiveSMIBool*)input value], false);
|
||||
@@ -90,11 +93,12 @@
|
||||
*/
|
||||
- (void)testTriggerInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"trigger_input"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance =
|
||||
[artboard stateMachineFromName:@"trigger_input" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachineInstance inputCount], 1);
|
||||
|
||||
@@ -104,8 +108,8 @@
|
||||
XCTAssertEqual([input isTrigger], 1);
|
||||
XCTAssertEqual([input isNumber], 0);
|
||||
XCTAssertTrue([[input name] isEqualToString:@"Trigger 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Trigger 1"
|
||||
error:nil] name] isEqualToString:@"Trigger 1"]);
|
||||
XCTAssertTrue([[[stateMachineInstance inputFromName:@"Trigger 1" error:nil]
|
||||
name] isEqualToString:@"Trigger 1"]);
|
||||
|
||||
[(RiveSMITrigger*)input fire];
|
||||
}
|
||||
@@ -115,56 +119,82 @@
|
||||
*/
|
||||
- (void)testMixedInput
|
||||
{
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations" error:nil];
|
||||
RiveFile* file = [Util loadTestFile:@"state_machine_configurations"
|
||||
error:nil];
|
||||
|
||||
RiveArtboard* artboard = [file artboard:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance = [artboard stateMachineFromName:@"mixed"
|
||||
error:nil];
|
||||
RiveStateMachineInstance* stateMachineInstance =
|
||||
[artboard stateMachineFromName:@"mixed" error:nil];
|
||||
|
||||
XCTAssertEqual([stateMachineInstance inputCount], 6);
|
||||
NSArray* target = [NSArray
|
||||
arrayWithObjects:@"zero", @"off", @"trigger", @"two_point_two", @"on", @"three", nil];
|
||||
NSArray* target = [NSArray arrayWithObjects:@"zero",
|
||||
@"off",
|
||||
@"trigger",
|
||||
@"two_point_two",
|
||||
@"on",
|
||||
@"three",
|
||||
nil];
|
||||
|
||||
XCTAssertTrue([[stateMachineInstance inputNames] isEqualToArray:target]);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"zero" error:nil] isNumber], true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"off" error:nil] isBoolean], true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" error:nil] isTrigger], true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two" error:nil] isNumber],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"on" error:nil] isBoolean], true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"three" error:nil] isNumber], true);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"zero"
|
||||
error:nil] isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"zero" error:nil] value],
|
||||
0);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two"
|
||||
error:nil] isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"two_point_two"
|
||||
error:nil] value],
|
||||
(float)2.2);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"three"
|
||||
error:nil] isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMINumber*)[stateMachineInstance inputFromName:@"three" error:nil] value],
|
||||
(float)3);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"on"
|
||||
error:nil] isKindOfClass:[RiveSMIBool class]],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachineInstance inputFromName:@"on" error:nil] value],
|
||||
error:nil] isNumber],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"off"
|
||||
error:nil] isKindOfClass:[RiveSMIBool class]],
|
||||
error:nil] isBoolean],
|
||||
true);
|
||||
XCTAssertEqual([(RiveSMIBool*)[stateMachineInstance inputFromName:@"off" error:nil] value],
|
||||
false);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger"
|
||||
error:nil] isKindOfClass:[RiveSMITrigger class]],
|
||||
error:nil] isTrigger],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two"
|
||||
error:nil] isNumber],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[[stateMachineInstance inputFromName:@"on" error:nil] isBoolean], true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"three"
|
||||
error:nil] isNumber],
|
||||
true);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"zero" error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[(RiveSMINumber*)[stateMachineInstance inputFromName:@"zero"
|
||||
error:nil] value],
|
||||
0);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"two_point_two"
|
||||
error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[(RiveSMINumber*)[stateMachineInstance inputFromName:@"two_point_two"
|
||||
error:nil] value],
|
||||
(float)2.2);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"three" error:nil]
|
||||
isKindOfClass:[RiveSMINumber class]],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[(RiveSMINumber*)[stateMachineInstance inputFromName:@"three"
|
||||
error:nil] value],
|
||||
(float)3);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"on" error:nil]
|
||||
isKindOfClass:[RiveSMIBool class]],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[(RiveSMIBool*)[stateMachineInstance inputFromName:@"on"
|
||||
error:nil] value],
|
||||
true);
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"off" error:nil]
|
||||
isKindOfClass:[RiveSMIBool class]],
|
||||
true);
|
||||
XCTAssertEqual(
|
||||
[(RiveSMIBool*)[stateMachineInstance inputFromName:@"off"
|
||||
error:nil] value],
|
||||
false);
|
||||
|
||||
XCTAssertEqual([[stateMachineInstance inputFromName:@"trigger" error:nil]
|
||||
isKindOfClass:[RiveSMITrigger class]],
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
+ (RiveFile*)loadTestFile:(NSString*)name error:(NSError**)error
|
||||
{
|
||||
NSData* nsData = [self loadTestData:name];
|
||||
RiveFile* file = [[RiveFile alloc] initWithData:nsData loadCdn:false error:error];
|
||||
RiveFile* file = [[RiveFile alloc] initWithData:nsData
|
||||
loadCdn:false
|
||||
error:error];
|
||||
return file;
|
||||
}
|
||||
@end
|
||||
|
||||
typedef void (^CompletionHandler)(NSURL* location, NSURLResponse* response, NSError* error);
|
||||
typedef void (^CompletionHandler)(NSURL* location,
|
||||
NSURLResponse* response,
|
||||
NSError* error);
|
||||
|
||||
@implementation TestSessionDownloadTask
|
||||
{}
|
||||
@@ -52,7 +56,8 @@ typedef void (^CompletionHandler)(NSURL* location, NSURLResponse* response, NSEr
|
||||
}
|
||||
|
||||
- (NSURLSessionDownloadTask*)downloadTaskWithURL:(NSURL*)url
|
||||
completionHandler:(CompletionHandler)completionHandler
|
||||
completionHandler:
|
||||
(CompletionHandler)completionHandler
|
||||
{
|
||||
[urls addObject:url];
|
||||
return [[TestSessionDownloadTask alloc] init];
|
||||
|
||||
Submodule submodules/rive-runtime updated: 71fd5c47b0...163f1beef3
Reference in New Issue
Block a user