Copy link to clipboard
Copied
So I am trying to send some current develop settings to my Stream deck using the SDK and am looking for the right way to obtain the values whenever the Develop Tab is opened, a new photo is selected, or adjustments have been made. From the docs the AdjustmentChangeObserver in the LrDevelopController should provide a lot of that information, but when I set it up like below, I do not see any traces in my log, assuming it's not being called:
myObserver = {}
-- Function to monitor slider changes
local function adjustmentChangeObserverCallback(propertyName, newValue)
logger:trace("Adjustment changed: " .. tostring(propertyName) .. " = " .. tostring(newValue))
-- Callback function is triggered when an adjustment changes
if propertyName and newValue then
-- Log the property name and its new value
logger:trace("Adjustment changed: " .. propertyName .. " = " .. tostring(newValue))
-- Example: Perform some action when exposure changes
if propertyName == "Exposure" then
logger:trace("Exposure changed to: " .. tostring(newValue))
-- Add any additional logic here, e.g., sending data via socket
end
end
end
LrTasks.startAsyncTask (function ()
LrFunctionContext.callWithContext ("adjustmentObserver", function (context)
LrDevelopController.addAdjustmentChangeObserver (context, myObserver, adjustmentChangeObserverCallback)
while _G.running do
LrTasks.sleep (1)
end
end)
end)
Any idea what I am doing wrong here?
I also did not find which values are being passed by the function, the documentation is a bit sparse on this function.
thank you!
Wolfgang
[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]
The following script works with my Debugging Toolkit:
LrFunctionContext.postAsyncTaskWithContext ("", function (context)
LrApplicationView.switchToModule ("develop")
Debug.logn ("Registering observer")
LrDevelopController.addAdjustmentChangeObserver (context, {"Hello"},
function (...) Debug.lognpp ("Change", {...}) end)
Debug.logn ("Registered")
LrTasks.s
...
Copy link to clipboard
Copied
[This post contains formatting and embedded images that don't appear in email. View the post in your Web browser.]
The following script works with my Debugging Toolkit:
LrFunctionContext.postAsyncTaskWithContext ("", function (context)
LrApplicationView.switchToModule ("develop")
Debug.logn ("Registering observer")
LrDevelopController.addAdjustmentChangeObserver (context, {"Hello"},
function (...) Debug.lognpp ("Change", {...}) end)
Debug.logn ("Registered")
LrTasks.sleep (30)
Debug.logn ("Stopping")
end)
Some notes:
1. addAdjustmentChangeObserver() must be called while the Develop module is active -- otherwise it is ignored.
2. If the user switches away from the Develop module and then back, the change observer will still be called.
3. It's easy to miss, but the documentation provides the signature of the observer function:
3. callback
( function( observer ) ) Function that will be called.
The observer function takes one argument, the "observer" object that was passed to addAdjustmentChangeObserver(). The setting being changed and its new value are not passed. My test script above verifies this by logging all the arguments passed to the function.
Copy link to clipboard
Copied
Also, my Any Crop plugin contains this source-code comment from 2016 (LR 6):
"We can't use LrDevelopController observer notifications, because notifications would sometimes cease while the user adjusts a crop."
So instead, Any Crop uses a polling loop to look for changes to the current module and to changes to develop settings. When the user is in the Develop module, it polls every 0.1 seconds; outside of the module, it polls every 0.5 second. Though polling offends an engineer's sensibility, these polling loops are very inexpensive -- you can't notice much change in CPU utilization.
It could conceivably use an observer function to notice changes in module, though in the past years I've sometimes observed that too can be unreliable with my Any Filter plugin -- I have no idea how reliable it might be now.
Copy link to clipboard
Copied
I just observed the observer firing 25 times per second during a crop operation, which in my case isn't even needed to be observed. I guess a cheap polling operation might indeed leave a smaller footprint.
Thank you very much for your help!
Copy link to clipboard
Copied
Thank you John, that's very helpful! Indeed I was not in the develop module when I registered the observer.
A few questions:
you use LrFunctionContext.postAsyncTaskWithContext, is way of starting it required or would the way my example is called work as well?
The example code I was using comes from your reply in this post: https://community.adobe.com/t5/lightroom-classic-discussions/adjustmentchangeobserver-not-triggering...
I guess since the changed values are not provided i'll just go ahead and read them, compare with the stored values and transmit if changed, but that should work just fine.
Thank you!
Copy link to clipboard
Copied
"you use LrFunctionContext.postAsyncTaskWithContext, is way of starting it required or would the way my example is called work as well?"
They're equivalent. LrFunctionContext.postAsyncTaskWithContext (n, f) is equivalent to LrTasks.startAsyncTask (function () LrFunctionContext.callWithContext (n, f) end).