Skip to content

Commit

Permalink
Fix libjpg on Mac Sonoma
Browse files Browse the repository at this point in the history
Diffs=
dde676085 Fix libjpg on Mac Sonoma (#7329)
e0a786c90 Runtime API for Nested Inputs (#7316)

Co-authored-by: Gordon Hayes <pggordonhayes@gmail.com>
Co-authored-by: Philip Chung <philterdesign@gmail.com>
  • Loading branch information
3 people committed May 31, 2024
1 parent 1ee0c5f commit 296c14d
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .rive_head
Original file line number Diff line number Diff line change
@@ -1 +1 @@
01d20e02661309cd2f8a0702f9de102107c1a0f1
dde676085908d492af545660cbbb19ee0d10d91d
2 changes: 1 addition & 1 deletion .rive_renderer
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13410e662550cd7ffd9c568d3880c3325f953314
f1ec43c82b136c33edfd71ec9759249d9fb5b182
Binary file added Example-iOS/Assets/runtime_nested_inputs.riv
Binary file not shown.
12 changes: 12 additions & 0 deletions Example-iOS/RiveExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@
04E51C702A151C230075E473 /* blendmodes.riv in Resources */ = {isa = PBXBuildFile; fileRef = 046AFA6E2673AF04004ED497 /* blendmodes.riv */; };
04F1C80B26A8442300CEE6BE /* two_bone_ik.riv in Resources */ = {isa = PBXBuildFile; fileRef = 04F1C80826A8442300CEE6BE /* two_bone_ik.riv */; };
27108F2F282C96E700A99D81 /* light_switch.riv in Resources */ = {isa = PBXBuildFile; fileRef = 27108F2C282C96E700A99D81 /* light_switch.riv */; };
2E83910A2C050B0F003BCF2A /* SwiftNestedInputs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */; };
2E83910B2C050B0F003BCF2A /* SwiftNestedInputs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */; };
2E83910D2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = 2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */; };
2E83910E2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */ = {isa = PBXBuildFile; fileRef = 2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */; };
83C89ACB29886ECB00044C17 /* StressTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83C89ACA29886ECB00044C17 /* StressTest.swift */; };
83C89ACF2988709400044C17 /* marty.riv in Resources */ = {isa = PBXBuildFile; fileRef = 83C89ACE2988709400044C17 /* marty.riv */; };
83C89AD1298870A700044C17 /* paper.riv in Resources */ = {isa = PBXBuildFile; fileRef = 83C89AD0298870A700044C17 /* paper.riv */; };
Expand Down Expand Up @@ -420,6 +424,8 @@
04E51C3E2A151A1F0075E473 /* Example__macOS_.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Example__macOS_.entitlements; sourceTree = "<group>"; };
04F1C80826A8442300CEE6BE /* two_bone_ik.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = two_bone_ik.riv; sourceTree = "<group>"; };
27108F2C282C96E700A99D81 /* light_switch.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = light_switch.riv; sourceTree = "<group>"; };
2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftNestedInputs.swift; sourceTree = "<group>"; };
2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = runtime_nested_inputs.riv; sourceTree = "<group>"; };
83C89ACA29886ECB00044C17 /* StressTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StressTest.swift; sourceTree = "<group>"; };
83C89ACE2988709400044C17 /* marty.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = marty.riv; sourceTree = "<group>"; };
83C89AD0298870A700044C17 /* paper.riv */ = {isa = PBXFileReference; lastKnownFileType = file; path = paper.riv; sourceTree = "<group>"; };
Expand Down Expand Up @@ -583,6 +589,7 @@
C9696B0E24FC6FD10041502A /* Assets */ = {
isa = PBXGroup;
children = (
2E83910C2C050BC4003BCF2A /* runtime_nested_inputs.riv */,
0490915C2BC832D100F2C12B /* lip-sync_test.riv */,
049091522BC832AF00F2C12B /* ping_pong_audio_demo.riv */,
049091502BC832AE00F2C12B /* racket1-59343.wav */,
Expand Down Expand Up @@ -648,6 +655,7 @@
C9A84F342644931E0014D8E0 /* SwiftUI */ = {
isa = PBXGroup;
children = (
2E8391072C050B0F003BCF2A /* SwiftNestedInputs.swift */,
E5E87A002AE5A83700E7295F /* SwiftVariableFPS.swift */,
04026DC327CE3ED6002B3DBF /* SwiftSimpleAnimation.swift */,
C9CB2F12264C92D200E7FF0D /* SwiftWidgets.swift */,
Expand Down Expand Up @@ -945,6 +953,7 @@
040553FC2B7A2858008F076A /* play_button_event_example.riv in Resources */,
040553FD2B7A2858008F076A /* neostream.riv in Resources */,
040553FE2B7A2858008F076A /* loopy.riv in Resources */,
2E83910D2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */,
040553FF2B7A2858008F076A /* progress.riv in Resources */,
040554002B7A2858008F076A /* magic_8-ball_v2.riv in Resources */,
040554012B7A2858008F076A /* nothing.riv in Resources */,
Expand Down Expand Up @@ -1074,6 +1083,7 @@
C3ECAC2B281837B300A81123 /* play_button_event_example.riv in Resources */,
042C88E42644447500E7DBB2 /* neostream.riv in Resources */,
042C88E82644447500E7DBB2 /* loopy.riv in Resources */,
2E83910E2C050BC4003BCF2A /* runtime_nested_inputs.riv in Resources */,
042C88E02644447500E7DBB2 /* progress.riv in Resources */,
C3ECAC252817BE1100A81123 /* magic_8-ball_v2.riv in Resources */,
04D5B06C266A460C004ACA5B /* nothing.riv in Resources */,
Expand Down Expand Up @@ -1175,6 +1185,7 @@
040553EF2B7A2858008F076A /* SwiftTestText.swift in Sources */,
040553F02B7A2858008F076A /* SwiftStateMachine.swift in Sources */,
040553F12B7A2858008F076A /* DismissableView.swift in Sources */,
2E83910A2C050B0F003BCF2A /* SwiftNestedInputs.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1226,6 +1237,7 @@
E57798A92A730A9B00FF25C3 /* SwiftTestText.swift in Sources */,
04026DCE27CE3F0F002B3DBF /* SwiftStateMachine.swift in Sources */,
F8DA7B452AF523A800FF3CBF /* DismissableView.swift in Sources */,
2E83910B2C050B0F003BCF2A /* SwiftNestedInputs.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
44 changes: 44 additions & 0 deletions Example-iOS/Source/Examples/SwiftUI/SwiftNestedInputs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// SwiftNestedInputs.swift
// RiveExample
//
// Created by Philip Chung on 05/27/2022.
// Copyright © 2024 Rive. All rights reserved.
//

import SwiftUI
import RiveRuntime

struct SwiftNestedInputs: DismissableView {
var dismiss: () -> Void = {}

// MARK: RiveViewModel
// This view model specifies the exact StateMachine that it wants from the file
@StateObject private var stateChanger = RiveViewModel(fileName: "runtime_nested_inputs", stateMachineName: "MainStateMachine")

var body: some View {
ScrollView{
VStack {
stateChanger.view()
.frame(height:200)

VStack{
Button("Outer Circle on") {
stateChanger.setInput("CircleOuterState", value: true, path: "CircleOuter")
}
Button("Outer Circle off") {
stateChanger.setInput("CircleOuterState", value: false, path: "CircleOuter")
}
Button("Inner Circle on") {
stateChanger.setInput("CircleInnerState", value: true, path: "CircleOuter/CircleInner")
}
Button("Inner Circle off") {
stateChanger.setInput("CircleInnerState", value: false, path: "CircleOuter/CircleInner")
}
}

}
}
}
}

1 change: 1 addition & 0 deletions Example-iOS/Source/ExamplesMaster.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ExamplesMasterTableViewController: UITableViewController {
("MultipleAnimations", typeErased(dismissableView: SwiftMultipleAnimations())),
("Cannon Game", typeErased(dismissableView: SwiftCannonGame())),
("State Machine", typeErased(dismissableView: SwiftStateMachine())),
("Nested Inputs", typeErased(dismissableView: SwiftNestedInputs())),
("Mesh Animation", typeErased(dismissableView: SwiftMeshAnimation())),
("Playing with Text", typeErased(dismissableView: TextInputView())),
("Rive Events", typeErased(dismissableView: SwiftEvents())),
Expand Down
83 changes: 83 additions & 0 deletions Source/Renderer/RiveArtboard.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
static int artInstanceCount = 0;

// MARK: - RiveArtboard
@interface RiveArtboard ()

/// Holds references to SMIInputs
@property NSMutableDictionary* inputs;

@end

@implementation RiveArtboard
{
Expand All @@ -36,6 +42,7 @@ - (instancetype)initWithArtboard:(std::unique_ptr<rive::ArtboardInstance>)riveAr
[RiveArtboard raiseInstanceCount];
#endif // RIVE_ENABLE_REFERENCE_COUNTING

_inputs = [[NSMutableDictionary alloc] init];
_artboardInstance = std::move(riveArtboard);
return self;
}
Expand Down Expand Up @@ -228,4 +235,80 @@ - (RiveTextValueRun*)textRun:(NSString*)name
return nullptr;
}

- (RiveSMIBool*)getBool:(NSString*)name path:(NSString*)path
{
// Create a unique dictionary name for numbers;
// this lets us use one dictionary for the three different types
NSString* dictName = [NSString stringWithFormat:@"%@%s", name, "_boo"];
// Check if the input is already instanced
if ([_inputs objectForKey:dictName] != nil)
{
return _inputs[dictName];
}
// Otherwise, try to retrieve from runtime
std::string stdName = std::string([name UTF8String]);
std::string stdPath = std::string([path UTF8String]);
rive::SMIBool* smi = _artboardInstance->getBool(stdName, stdPath);
if (smi == nullptr)
{
return NULL;
}
else
{
_inputs[dictName] = [[RiveSMIBool alloc] initWithSMIInput:smi];
return _inputs[dictName];
}
}

- (RiveSMITrigger*)getTrigger:(NSString*)name path:(NSString*)path
{
// Create a unique dictionary name for numbers;
// this lets us use one dictionary for the three different types
NSString* dictName = [NSString stringWithFormat:@"%@%s", name, "_trg"];
// Check if the input is already instanced
if ([_inputs objectForKey:dictName] != nil)
{
return _inputs[dictName];
}
// Otherwise, try to retrieve from runtime
std::string stdName = std::string([name UTF8String]);
std::string stdPath = std::string([path UTF8String]);
rive::SMITrigger* smi = _artboardInstance->getTrigger(stdName, stdPath);
if (smi == nullptr)
{
return NULL;
}
else
{
_inputs[dictName] = [[RiveSMITrigger alloc] initWithSMIInput:smi];
return _inputs[dictName];
}
}

- (RiveSMINumber*)getNumber:(NSString*)name path:(NSString*)path
{
// Create a unique dictionary name for numbers;
// this lets us use one dictionary for the three different types
NSString* dictName = [NSString stringWithFormat:@"%@%s", name, "_num"];
// Check if the input is already instanced
if ([_inputs objectForKey:dictName] != nil)
{
return _inputs[dictName];
}
// Otherwise, try to retrieve from runtime
std::string stdName = std::string([name UTF8String]);
std::string stdPath = std::string([path UTF8String]);
rive::SMINumber* smi = _artboardInstance->getNumber(stdName, stdPath);
if (smi == nullptr)
{
return NULL;
}
else
{
_inputs[dictName] = [[RiveSMINumber alloc] initWithSMIInput:smi];
;
return _inputs[dictName];
}
}

@end
7 changes: 7 additions & 0 deletions Source/Renderer/include/RiveArtboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
NS_ASSUME_NONNULL_BEGIN

@class RiveLinearAnimationInstance;
@class RiveSMIBool;
@class RiveSMITrigger;
@class RiveSMINumber;
@class RiveStateMachineInstance;
@class RiveRenderer;
@class RiveTextValueRun;
Expand All @@ -23,6 +26,10 @@ NS_ASSUME_NONNULL_BEGIN
- (NSString*)name;
- (CGRect)bounds;

- (const RiveSMIBool*)getBool:(NSString*)name path:(NSString*)path;
- (const RiveSMITrigger*)getTrigger:(NSString*)name path:(NSString*)path;
- (const RiveSMINumber*)getNumber:(NSString*)name path:(NSString*)path;

- (NSInteger)animationCount;
- (NSArray<NSString*>*)animationNames;
- (RiveLinearAnimationInstance* __nullable)animationFromIndex:(NSInteger)index
Expand Down
38 changes: 38 additions & 0 deletions Source/RiveViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,44 @@ open class RiveViewModel: NSObject, ObservableObject, RiveFileDelegate, RiveStat
setInput(inputName, value: Float(value))
}

/// Provide the specified nested Artboard with a `Trigger` input
/// - Parameters:
/// - inputName: The name of a `Trigger` input on the active StateMachine
/// - path: A String representing the path to the nested artboard delimited by "/" (ie. "Nested" or "Level1/Level2/Level3")
open func triggerInput(_ inputName: String, path: String) {
riveModel?.artboard?.getTrigger(inputName, path: path).fire()
play()
}

/// Provide the specified nested Artboard with a `Boolean` input
/// - Parameters:
/// - inputName: The name of a `Boolean` input on the active StateMachine
/// - value: A Bool value for the input
/// - path: A String representing the path to the nested artboard delimited by "/" (ie. "Nested" or "Level1/Level2/Level3")
open func setInput(_ inputName: String, value: Bool, path: String) {
riveModel?.artboard?.getBool(inputName, path: path).setValue(value)
play()
}

/// Provide the specified nested Artboard with a `Number` input
/// - Parameters:
/// - inputName: The name of a `Number` input on the active StateMachine
/// - value: A Float value for the input
/// - path: A String representing the path to the nested artboard delimited by "/" (ie. "Nested" or "Level1/Level2/Level3")
open func setInput(_ inputName: String, value: Float, path: String) {
riveModel?.artboard?.getNumber(inputName, path: path).setValue(value);
play()
}

/// Provide the specified nested Artboard with a `Number` input
/// - Parameters:
/// - inputName: The name of a `Number` input on the active StateMachine
/// - value: A Double value for the input
/// - path: A String representing the path to the nested artboard delimited by "/" (ie. "Nested" or "Level1/Level2/Level3")
open func setInput(_ inputName: String, value: Double, path: String) {
setInput(inputName, value: Float(value), path: path)
}

/// Get a text value from a specified text run
/// - Parameters:
/// - textRunName: The name of a `Text Run` on the active Artboard
Expand Down
2 changes: 1 addition & 1 deletion submodules/rive-cpp

0 comments on commit 296c14d

Please sign in to comment.