@@ -88,6 +88,79 @@ local loopPattern = reaper.GetExtState("BruteSeq", "LoopPattern") == "1"
8888local loopSong = reaper .GetExtState (" BruteSeq" , " LoopSong" ) == " 1"
8989local ripple = reaper .GetExtState (" BruteSeq" , " Ripple" ) == " 1"
9090
91+ local function processPattern (currentPattern )
92+ -- Navigation Step Bar
93+ local currentStepTotal = getCurrentStep (currentPattern .item )
94+ local currentStep = currentStepTotal and (currentStepTotal % currentPattern .steps ) + 1 or - 1
95+ local currentTime = currentStepTotal and (currentStepTotal // currentPattern .steps ) + 1 or - 1
96+
97+ reaper .ImGui_PushStyleVar (ctx , reaper .ImGui_StyleVar_ItemSpacing (), 2 , 2 ) -- (x,y)
98+
99+ drawTrackLabel (ctx , images .Channel_button_on , " Sequencer" )
100+ for s = 1 , currentPattern .steps do
101+ reaper .ImGui_SameLine (ctx )
102+ local isCurrent = currentStep and s == currentStep
103+ drawStepCursor (isCurrent )
104+
105+ if reaper .ImGui_IsItemClicked (ctx ) then
106+ jumpToStep (currentPattern .item , s - 1 )
107+ end
108+ end
109+
110+ if currentPattern .times > 1 then
111+ drawTimesSeparator ()
112+ for s = 1 , currentPattern .times do
113+ reaper .ImGui_SameLine (ctx )
114+ local isCurrent = currentTime and s == currentTime
115+ drawStepCursor (isCurrent )
116+
117+ if reaper .ImGui_IsItemClicked (ctx ) then
118+ jumpToStep (currentPattern .item , (s - 1 ) * currentPattern .steps )
119+ end
120+ end
121+ end
122+
123+ -- Step Grid
124+
125+ for ti ,trk in ipairs (tracks ) do
126+ local id = ' ##ch' .. ti
127+ local selected = false
128+ local sprite = selected and images .Channel_button_on
129+ or images .Channel_button_off
130+
131+ drawTrackLabel (ctx , sprite , trk .name )
132+ reaper .ImGui_SameLine (ctx )
133+
134+ for s = 1 , currentPattern .steps do
135+ local stepVelocity = getStepVelocity (currentPattern .item , s , trk .note )
136+ local active = stepVelocity ~= nil
137+ local odd = ((s - 1 )// 4 )% 2 == 0
138+ local accent = active and (stepVelocity > accentThreshold )
139+
140+ drawStepButton (active , odd , accent )
141+
142+ if s < currentPattern .steps then reaper .ImGui_SameLine (ctx ) end
143+
144+ local clicked = reaper .ImGui_IsItemClicked (ctx )
145+ if clicked then
146+ local shift = reaper .ImGui_IsKeyDown (ctx , reaper .ImGui_Key_LeftShift ())
147+
148+ local shouldDelete = active
149+ local shouldCreate = not active or (shift ~= accent )
150+
151+ if shouldDelete then
152+ deleteMidiNote (currentPattern .item , s , trk .note )
153+ end
154+ if shouldCreate then
155+ local newVelocity = shift and accentVelocity or normalVelocity
156+ addMidiNote (currentPattern .item , s , trk .note , newVelocity )
157+ end
158+ end
159+ end
160+ end
161+ reaper .ImGui_PopStyleVar (ctx )
162+ end
163+
91164local function loop ()
92165 passThroughShortcuts (ctx )
93166 reaper .ImGui_SetNextWindowSize (ctx ,900 ,420 ,reaper .ImGui_Cond_FirstUseEver ())
@@ -204,76 +277,12 @@ local function loop()
204277
205278 reaper .ImGui_Separator (ctx )
206279
207- -- Navigation Step Bar
208- local currentStepTotal = getCurrentStep (currentPattern .item )
209- local currentStep = currentStepTotal and (currentStepTotal % currentPattern .steps ) + 1 or - 1
210- local currentTime = currentStepTotal and (currentStepTotal // currentPattern .steps ) + 1 or - 1
211-
212- reaper .ImGui_PushStyleVar (ctx , reaper .ImGui_StyleVar_ItemSpacing (), 2 , 2 ) -- (x,y)
213-
214- drawTrackLabel (ctx , images .Channel_button_on , " Sequencer" )
215- for s = 1 , currentPattern .steps do
216- reaper .ImGui_SameLine (ctx )
217- local isCurrent = currentStep and s == currentStep
218- drawStepCursor (isCurrent )
219-
220- if reaper .ImGui_IsItemClicked (ctx ) then
221- jumpToStep (currentPattern .item , s - 1 )
222- end
223- end
224-
225- if currentPattern .times > 1 then
226- drawTimesSeparator ()
227- for s = 1 , currentPattern .times do
228- reaper .ImGui_SameLine (ctx )
229- local isCurrent = currentTime and s == currentTime
230- drawStepCursor (isCurrent )
231-
232- if reaper .ImGui_IsItemClicked (ctx ) then
233- jumpToStep (currentPattern .item , (s - 1 ) * currentPattern .steps )
234- end
235- end
280+ if isMidi (currentPattern .item ) then
281+ processPattern (currentPattern )
282+ else
283+ reaper .ImGui_AlignTextToFramePadding (ctx )
284+ reaper .ImGui_Text (ctx , " Non MIDI items are not supported in the sequencer track" )
236285 end
237-
238- -- Step Grid
239-
240- for ti ,trk in ipairs (tracks ) do
241- local id = ' ##ch' .. ti
242- local selected = false
243- local sprite = selected and images .Channel_button_on
244- or images .Channel_button_off
245-
246- drawTrackLabel (ctx , sprite , trk .name )
247- reaper .ImGui_SameLine (ctx )
248-
249- for s = 1 , currentPattern .steps do
250- local stepVelocity = getStepVelocity (currentPattern .item , s , trk .note )
251- local active = stepVelocity ~= nil
252- local odd = ((s - 1 )// 4 )% 2 == 0
253- local accent = active and (stepVelocity > accentThreshold )
254-
255- drawStepButton (active , odd , accent )
256-
257- if s < currentPattern .steps then reaper .ImGui_SameLine (ctx ) end
258-
259- local clicked = reaper .ImGui_IsItemClicked (ctx )
260- if clicked then
261- local shift = reaper .ImGui_IsKeyDown (ctx , reaper .ImGui_Key_LeftShift ())
262-
263- local shouldDelete = active
264- local shouldCreate = not active or (shift ~= accent )
265-
266- if shouldDelete then
267- deleteMidiNote (currentPattern .item , s , trk .note )
268- end
269- if shouldCreate then
270- local newVelocity = shift and accentVelocity or normalVelocity
271- addMidiNote (currentPattern .item , s , trk .note , newVelocity )
272- end
273- end
274- end
275- end
276- reaper .ImGui_PopStyleVar (ctx )
277286 else
278287 reaper .ImGui_SameLine (ctx )
279288 reaper .ImGui_AlignTextToFramePadding (ctx )
0 commit comments