Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't change ParameterSubGroup Name in parameterChanged #312

Open
latenitefilms opened this issue Dec 29, 2023 · 4 comments
Open

Can't change ParameterSubGroup Name in parameterChanged #312

latenitefilms opened this issue Dec 29, 2023 · 4 comments
Assignees

Comments

@latenitefilms
Copy link
Contributor

latenitefilms commented Dec 29, 2023

Apple Feedback Assistant ID: FB13500374

DESCRIBE THE BUG:
You can't change a ParameterSubGroup Name using dynamicParamAPI?.setParameter(paramID, name: "Test") when triggered from parameterChanged. The code executes without error, but the Sub Group name doesn't actually change in the Final Cut Pro interface.

I've also tried using FxCustomParameterActionAPI_v4 before and after setParameter, but it has no impact.


TO REPRODUCE:
Create a ParameterSubGroup, then try and change the name of the subgroup dynamically via code.


EXPECTED BEHAVIOUR:
You should be able to update the name like you can any other parameter.


SCREENSHOTS:
NA


SPECS:

  • 2021 16-inch MacBook Pro (M1 Max, 64GB RAM, 8TB SSD)
  • macOS Sonoma 14.1.2
  • Final Cut Pro 10.7.1

ADDITIONAL COMMENTS:
None

@latenitefilms
Copy link
Contributor Author

latenitefilms commented Jan 23, 2024

FWIW - I've been able to get this to work in Motion using the FxBrightness sample app from the FxPlug v4.2.9 SDK using this code:

    @objc func pushButton() {
        let dynamicParamAPI = _apiManager!.api(for: FxDynamicParameterAPI_v3.self) as! FxDynamicParameterAPI_v3
        dynamicParamAPI.setParameter(2, name: "BOO")
    }

    func addParameters() throws {
        let paramAPI = _apiManager!.api(for: FxParameterCreationAPI_v5.self) as! FxParameterCreationAPI_v5
        
        paramAPI.addFloatSlider(withName: "Brightness", parameterID: 1, defaultValue: 1.0, parameterMin: 0.0, parameterMax: 100.0, sliderMin: 0.0, sliderMax: 5.0, delta: 0.1, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

        paramAPI.startParameterSubGroup("Test SubGroup", parameterID: 2, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

        paramAPI.addPushButton(withName: "Change Name", parameterID: 3, selector: #selector(pushButton), parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    }

But publishing this as a Title to Final Cut Pro doesn't work. Pressing the button doesn't update the SubGroup name.

I'm guessing this is because there's no official way to publish SubGroup's in Motion - even though lots of Motion Templates do it by modifying the Motion XML.

@latenitefilms
Copy link
Contributor Author

Interestingly, whilst this works in Motion, it doesn't in Final Cut Pro:

@objc func pushButton() {

    let setParamAPI = _apiManager!.api(for: FxParameterSettingAPI_v5.self) as! FxParameterSettingAPI_v5

    let dynamicParamAPI = _apiManager!.api(for: FxDynamicParameterAPI_v3.self) as! FxDynamicParameterAPI_v3

    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_HIDDEN), toParameter: 2)

    dynamicParamAPI.setParameter(2, name: "NEW SUBGROUP NAME")

    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_DEFAULT), toParameter: 2)
    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_COLLAPSED), toParameter: 2)

    dynamicParamAPI.setParameter(1, name: "NEW BRIGHTNESS NAME")
}

func addParameters() throws {
    let paramAPI = _apiManager!.api(for: FxParameterCreationAPI_v5.self) as! FxParameterCreationAPI_v5
    
    paramAPI.addFloatSlider(withName: "Brightness", parameterID: 1, defaultValue: 1.0, parameterMin: 0.0, parameterMax: 100.0, sliderMin: 0.0, sliderMax: 5.0, delta: 0.1, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.startParameterSubGroup("Test SubGroup", parameterID: 2, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.addPushButton(withName: "Change Name", parameterID: 3, selector: #selector(pushButton), parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.endParameterSubGroup()
}

However the group does collapse - it's just none of the names get updated.

@latenitefilms
Copy link
Contributor Author

Note to self, I did also try using FxCustomParameterActionAPI_v4 , but you shouldn't use that in buttons anyway, and it doesn't work due to:

A plugin attempted to call [-FxCustomParameterActionAPI startAction:] at an inappropriate time. Plugins should not call this method when they have been called by the host application.

Here's the code:

@objc func pushButton() {

    let actionAPI = _apiManager!.api(for: FxCustomParameterActionAPI_v4.self) as! FxCustomParameterActionAPI_v4

    actionAPI.startAction(self)

    let setParamAPI = _apiManager!.api(for: FxParameterSettingAPI_v5.self) as! FxParameterSettingAPI_v5

    let dynamicParamAPI = _apiManager!.api(for: FxDynamicParameterAPI_v3.self) as! FxDynamicParameterAPI_v3

    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_HIDDEN), toParameter: 2)

    dynamicParamAPI.setParameter(2, name: "NEW SUBGROUP NAME")

    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_DEFAULT), toParameter: 2)
    setParamAPI.setParameterFlags(FxParameterFlags(kFxParameterFlag_COLLAPSED), toParameter: 2)

    dynamicParamAPI.setParameter(1, name: "NEW BRIGHTNESS NAME")

    actionAPI.endAction(self)
}

func addParameters() throws {
    let paramAPI = _apiManager!.api(for: FxParameterCreationAPI_v5.self) as! FxParameterCreationAPI_v5

    paramAPI.addFloatSlider(withName: "Brightness", parameterID: 1, defaultValue: 1.0, parameterMin: 0.0, parameterMax: 100.0, sliderMin: 0.0, sliderMax: 5.0, delta: 0.1, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.startParameterSubGroup("Test SubGroup", parameterID: 2, parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.addPushButton(withName: "Change Name", parameterID: 3, selector: #selector(pushButton), parameterFlags: FxParameterFlags(kFxParameterFlag_DEFAULT))

    paramAPI.endParameterSubGroup()
}

@latenitefilms
Copy link
Contributor Author

Apple confirms:

The dynamic parameter API doesn’t do what you want in FCP. This is a known limitation. I thought we had documented this somewhere, but I’m not finding it.

Basically, the problem is that using the dynamic parameter API changes the underlying Motion document data. In Motion, the user simply saves the project and it’s fine. But in FCP there’s no way for the user to save the Motion Template, nor would they want to, since it would change all instances of the plug-in in all projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant