Skip to content

Commit 925d928

Browse files
committed
Move refresh to limits module
ditto
1 parent 8bf372d commit 925d928

File tree

4 files changed

+78
-86
lines changed

4 files changed

+78
-86
lines changed

src/plugin/Client.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ LrTasks.startAsyncTask(
180180
Filter_7 = CU.fApplyFilter(7),
181181
Filter_8 = CU.fApplyFilter(8),
182182
Filter_9 = CU.fApplyFilter(9),
183-
FullRefresh = CU.FullRefresh,
183+
FullRefresh = Limits.RefreshMidiController,
184184
GetPluginInfo = DebugInfo.sendLog, -- not in db: internal use only
185185
GridViewStyle = LrApplicationView.gridViewStyle,
186186
HoldAltOpt = CU.HoldAltOptToggle,
@@ -845,7 +845,7 @@ LrTasks.startAsyncTask(
845845
CU.showBezel(param,value,actualvalue)
846846
end
847847
if lastfullrefresh + 1 < os.clock() then --try refreshing controller once a second
848-
CU.FullRefresh()
848+
Limits.RefreshMidiController()
849849
lastfullrefresh = os.clock()
850850
end
851851
end -- end of if pickup/elseif bezel group

src/plugin/ClientUtilities.lua

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,6 @@ local function LRValueToMIDIValue(param)
501501
return retval
502502
end
503503

504-
local function FullRefresh()
505-
return function()
506-
Profiles.refreshMidiController()
507-
end
508-
end
509-
510504
local function fSimulateKeys(keys, developonly, tool)
511505
return function()
512506
if developonly then
@@ -634,13 +628,13 @@ local function cg_hsl_paste()
634628
LrDevelopController.setValue(cg_hsl_parms.shadow[1],cg_hsl[1])
635629
LrDevelopController.setValue(cg_hsl_parms.shadow[2],cg_hsl[2])
636630
LrDevelopController.setValue(cg_hsl_parms.shadow[3],cg_hsl[3])
637-
FullRefresh()
631+
Limits.RefreshMidiController()
638632
return
639633
end
640634
LrDevelopController.setValue(cg_hsl_parms[currentView][1],cg_hsl[1])
641635
LrDevelopController.setValue(cg_hsl_parms[currentView][2],cg_hsl[2])
642636
LrDevelopController.setValue(cg_hsl_parms[currentView][3],cg_hsl[3])
643-
FullRefresh()
637+
Limits.RefreshMidiController()
644638
end
645639

646640
local function cg_reset_3way()
@@ -653,7 +647,7 @@ local function cg_reset_3way()
653647
LrDevelopController.resetToDefault('SplitToningShadowHue')
654648
LrDevelopController.resetToDefault('SplitToningShadowSaturation')
655649
LrDevelopController.resetToDefault('ColorGradeShadowLum')
656-
FullRefresh()
650+
Limits.RefreshMidiController()
657651
end
658652

659653
local function cg_reset_all()
@@ -673,28 +667,28 @@ local function cg_reset_current()
673667
LrDevelopController.resetToDefault('ColorGradeGlobalHue')
674668
LrDevelopController.resetToDefault('ColorGradeGlobalSat')
675669
LrDevelopController.resetToDefault('ColorGradeGlobalLum')
676-
FullRefresh()
670+
Limits.RefreshMidiController()
677671
return
678672
end
679673
if currentView == 'highlight' then
680674
LrDevelopController.resetToDefault('SplitToningHighlightHue')
681675
LrDevelopController.resetToDefault('SplitToningHighlightSaturation')
682676
LrDevelopController.resetToDefault('ColorGradeHighlightLum')
683-
FullRefresh()
677+
Limits.RefreshMidiController()
684678
return
685679
end
686680
if currentView == 'midtone' then
687681
LrDevelopController.resetToDefault('ColorGradeMidtoneHue')
688682
LrDevelopController.resetToDefault('ColorGradeMidtoneSat')
689683
LrDevelopController.resetToDefault('ColorGradeMidtoneLum')
690-
FullRefresh()
684+
Limits.RefreshMidiController()
691685
return
692686
end
693687
if currentView == 'shadow' then
694688
LrDevelopController.resetToDefault('SplitToningShadowHue')
695689
LrDevelopController.resetToDefault('SplitToningShadowSaturation')
696690
LrDevelopController.resetToDefault('ColorGradeShadowLum')
697-
FullRefresh()
691+
Limits.RefreshMidiController()
698692
return
699693
end
700694
end
@@ -923,7 +917,6 @@ local function quickDevAdjustWB(par,val,cmd) --note lightroom applies this to al
923917
end
924918
return {
925919
ApplySettings = ApplySettings,
926-
FullRefresh = FullRefresh,
927920
HoldAltOptToggle = HoldAltOptToggle,
928921
LRValueToMIDIValue = LRValueToMIDIValue,
929922
MIDIValueToLRValue = MIDIValueToLRValue,

src/plugin/Limits.lua

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ MIDI2LR. If not, see <http://www.gnu.org/licenses/>.
1616
local LrApplication = import 'LrApplication'
1717
local LrApplicationView = import 'LrApplicationView'
1818
local LrDevelopController = import 'LrDevelopController'
19+
local LrTasks = import 'LrTasks'
1920
local LrView = import 'LrView'
2021
local Database = require 'Database'
2122

@@ -109,6 +110,72 @@ local function ClampValue(param)
109110
return nil
110111
end
111112

113+
local function RefreshMidiController()
114+
if (LrApplication.activeCatalog():getTargetPhoto() == nil) or (LrApplicationView.getCurrentModuleName() ~= 'develop') then
115+
return
116+
end
117+
LrTasks.startAsyncTask (function ()
118+
--[[-----------debug section, enable by adding - to beginning this line
119+
LrMobdebug.on()
120+
--]]-----------end debug section
121+
local photoval = LrApplication.activeCatalog():getTargetPhoto():getDevelopSettings()
122+
-- refresh crop values
123+
local val_bottom = photoval.CropBottom
124+
MIDI2LR.SERVER:send(string.format('CropBottomRight %g\n', val_bottom))
125+
MIDI2LR.SERVER:send(string.format('CropBottomLeft %g\n', val_bottom))
126+
MIDI2LR.SERVER:send(string.format('CropAll %g\n', val_bottom))
127+
MIDI2LR.SERVER:send(string.format('CropBottom %g\n', val_bottom))
128+
local val_top = photoval.CropTop
129+
MIDI2LR.SERVER:send(string.format('CropTopRight %g\n', val_top))
130+
MIDI2LR.SERVER:send(string.format('CropTopLeft %g\n', val_top))
131+
MIDI2LR.SERVER:send(string.format('CropTop %g\n', val_top))
132+
local val_left = photoval.CropLeft
133+
local val_right = photoval.CropRight
134+
MIDI2LR.SERVER:send(string.format('CropLeft %g\n', val_left))
135+
MIDI2LR.SERVER:send(string.format('CropRight %g\n', val_right))
136+
local range_v = (1 - (val_bottom - val_top))
137+
if range_v == 0.0 then
138+
MIDI2LR.SERVER:send('CropMoveVertical 0\n')
139+
else
140+
MIDI2LR.SERVER:send(string.format('CropMoveVertical %g\n', val_top / range_v))
141+
end
142+
local range_h = (1 - (val_right - val_left))
143+
if range_h == 0.0 then
144+
MIDI2LR.SERVER:send('CropMoveHorizontal 0\n')
145+
else
146+
MIDI2LR.SERVER:send(string.format('CropMoveHorizontal %g\n', val_left / range_h))
147+
end
148+
local sel_mask = LrDevelopController.getSelectedMask()
149+
for param,altparam in pairs(Database.Parameters) do
150+
LrTasks.yield()
151+
local min,max = GetMinMax(param)
152+
local lrvalue
153+
if altparam == 'Direct' then
154+
if (param:sub(1,6) ~= 'local_') or sel_mask then lrvalue = LrDevelopController.getValue(param) end
155+
else
156+
if photoval[altparam] ~= nil then
157+
lrvalue = photoval[altparam]
158+
elseif photoval[param] ~= nil then
159+
lrvalue = photoval[param]
160+
else
161+
lrvalue = 0
162+
end
163+
end
164+
if type(min) == 'number' and type(max) == 'number' and type(lrvalue) == 'number' then
165+
local midivalue = (lrvalue-min)/(max-min)
166+
if midivalue >= 1.0 then
167+
MIDI2LR.SERVER:send(string.format('%s 1.0\n', param))
168+
elseif midivalue <= 0.0 then -- = catches -0.0 and sends it as 0.0
169+
MIDI2LR.SERVER:send(string.format('%s 0.0\n', param))
170+
else
171+
MIDI2LR.SERVER:send(string.format('%s %g\n', param, midivalue))
172+
end
173+
end
174+
end
175+
end
176+
)
177+
end
178+
112179
--------------------------------------------------------------------------------
113180
-- Provide rows of controls for dialog boxes.
114181
-- For the current photo type (HDR, raw, jpg, etc) will produce
@@ -203,5 +270,6 @@ return {
203270
GetMinMax = GetMinMax,
204271
LimitsCanBeSet = LimitsCanBeSet,
205272
Parameters = LimitParameters,
273+
RefreshMidiController = RefreshMidiController,
206274
StartDialog = StartDialog,
207275
}

src/plugin/Profiles.lua

Lines changed: 1 addition & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,14 @@ You should have received a copy of the GNU General Public License along with
1818
MIDI2LR. If not, see <http://www.gnu.org/licenses/>.
1919
------------------------------------------------------------------------------]]
2020

21-
local Database = require 'Database'
2221
local Init = require 'Init'
2322
local Limits = require 'Limits'
2423
local ProfileTypes = require 'ProfileTypes'
25-
local LrApplication = import 'LrApplication'
2624
local LrApplicationView = import 'LrApplicationView'
2725
local LrDevelopController = import 'LrDevelopController'
2826
local LrDialogs = import 'LrDialogs'
2927
local LrFileUtils = import 'LrFileUtils'
3028
local LrStringUtils = import 'LrStringUtils'
31-
local LrTasks = import 'LrTasks'
3229
local LrView = import 'LrView'
3330
--[[-----------debug section, enable by adding - to beginning this line
3431
local LrMobdebug = import 'LrMobdebug'
@@ -38,80 +35,14 @@ local currentTMP = {Tool = '', Module = '', Panel = '', Profile = ''}
3835
local loadedprofile = ''-- according to application and us
3936
local profilepath = '' --according to application
4037

41-
local function refreshMidiController()
42-
if (LrApplication.activeCatalog():getTargetPhoto() == nil) or (LrApplicationView.getCurrentModuleName() ~= 'develop') then
43-
return
44-
end
45-
LrTasks.startAsyncTask (function ()
46-
--[[-----------debug section, enable by adding - to beginning this line
47-
LrMobdebug.on()
48-
--]]-----------end debug section
49-
local photoval = LrApplication.activeCatalog():getTargetPhoto():getDevelopSettings()
50-
-- refresh crop values
51-
local val_bottom = photoval.CropBottom
52-
MIDI2LR.SERVER:send(string.format('CropBottomRight %g\n', val_bottom))
53-
MIDI2LR.SERVER:send(string.format('CropBottomLeft %g\n', val_bottom))
54-
MIDI2LR.SERVER:send(string.format('CropAll %g\n', val_bottom))
55-
MIDI2LR.SERVER:send(string.format('CropBottom %g\n', val_bottom))
56-
local val_top = photoval.CropTop
57-
MIDI2LR.SERVER:send(string.format('CropTopRight %g\n', val_top))
58-
MIDI2LR.SERVER:send(string.format('CropTopLeft %g\n', val_top))
59-
MIDI2LR.SERVER:send(string.format('CropTop %g\n', val_top))
60-
local val_left = photoval.CropLeft
61-
local val_right = photoval.CropRight
62-
MIDI2LR.SERVER:send(string.format('CropLeft %g\n', val_left))
63-
MIDI2LR.SERVER:send(string.format('CropRight %g\n', val_right))
64-
local range_v = (1 - (val_bottom - val_top))
65-
if range_v == 0.0 then
66-
MIDI2LR.SERVER:send('CropMoveVertical 0\n')
67-
else
68-
MIDI2LR.SERVER:send(string.format('CropMoveVertical %g\n', val_top / range_v))
69-
end
70-
local range_h = (1 - (val_right - val_left))
71-
if range_h == 0.0 then
72-
MIDI2LR.SERVER:send('CropMoveHorizontal 0\n')
73-
else
74-
MIDI2LR.SERVER:send(string.format('CropMoveHorizontal %g\n', val_left / range_h))
75-
end
76-
local sel_mask = LrDevelopController.getSelectedMask()
77-
for param,altparam in pairs(Database.Parameters) do
78-
LrTasks.yield()
79-
local min,max = Limits.GetMinMax(param)
80-
local lrvalue
81-
if altparam == 'Direct' then
82-
if (param:sub(1,6) ~= 'local_') or sel_mask then lrvalue = LrDevelopController.getValue(param) end
83-
else
84-
if photoval[altparam] ~= nil then
85-
lrvalue = photoval[altparam]
86-
elseif photoval[param] ~= nil then
87-
lrvalue = photoval[param]
88-
else
89-
lrvalue = 0
90-
end
91-
end
92-
if type(min) == 'number' and type(max) == 'number' and type(lrvalue) == 'number' then
93-
local midivalue = (lrvalue-min)/(max-min)
94-
if midivalue >= 1.0 then
95-
MIDI2LR.SERVER:send(string.format('%s 1.0\n', param))
96-
elseif midivalue <= 0.0 then -- = catches -0.0 and sends it as 0.0
97-
MIDI2LR.SERVER:send(string.format('%s 0.0\n', param))
98-
else
99-
MIDI2LR.SERVER:send(string.format('%s %g\n', param, midivalue))
100-
end
101-
end
102-
end
103-
end
104-
)
105-
end
106-
10738
local function doprofilechange(newprofile)
10839
if ProgramPreferences.ProfilesShowBezelOnChange then
10940
local filename = newprofile:match(".-([^\\^/]-([^%.]+))$")
11041
filename = filename:sub(0, -5)
11142
LrDialogs.showBezel(filename)
11243
end
11344
loadedprofile = newprofile
114-
refreshMidiController()
45+
Limits.RefreshMidiController()
11546
end
11647

11748
local function setDirectory(value)

0 commit comments

Comments
 (0)