-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathmpl_Render-in-place.lua
1852 lines (1622 loc) · 75.9 KB
/
mpl_Render-in-place.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- @description Render-in-place
-- @version 1.14
-- @author MPL
-- @website http://forum.cockos.com/showthread.php?t=188335
-- @about Based on Cubase "Render Selection" dialog port
-- @changelog
-- # fix sapmming extstate.ini
-- move render sends separately to postprocessing
-- add each new render as new lane / take if in each piece mode
--NOT reaper NOT gfx
local vrs = 1.14
-------------------------------------------------------------------------------- init globals
for key in pairs(reaper) do _G[key]=reaper[key] end
app_vrs = tonumber(GetAppVersion():match('[%d%.]+'))
if app_vrs < 7.18 then return reaper.MB('This script require REAPER 7.18+','',0) end
local ImGui
if not reaper.ImGui_GetBuiltinPath then return reaper.MB('This script require ReaImGui extension','',0) end
package.path = reaper.ImGui_GetBuiltinPath() .. '/?.lua'
ImGui = require 'imgui' '0.9.3.2'
-------------------------------------------------------------------------------- init external defaults
EXT = {
viewport_posX = 0,
viewport_posY = 0,
viewport_posW = 400,
viewport_posH = 640,
preset_base64_user = '',
CONF_name = 'default',
-- src
CONF_source = 1|2|4|8|16,
--[[
-- &1 razor areas
-- &2 items
-- &4 track at selection
-- &8 track if no RA
-- &16 track if no items
]]
CONF_source_itemflags = 1|2, --&1 ignore selected items if they are already catched by RA -- &2 ignore if RA exist
-- preparations
CONF_solomode = 2,
CONF_unmutesends = 0,
CONF_enablemasterfx = 0,
CONF_trackfxenabled = 1|2|4|8|16,--2 instrument -- 4 before instrument -- 8 after instrument -- 16 treat XXi as instrument
CONF_enablechildrens = 1,
-- render props / format
CONF_tail = 0, -- 0 off 1 bars 2 seconds
CONF_tail_len = 0,
CONF_extendtotail = 0,
CONF_bitdepth = 1,
CONF_outputname = 'render',
CONF_outputpath = 'renderinplace',
CONF_source_flags = 0, -- 1 mute items under RA -- 2 mute selected items -- 4 mute tracks
-- dest track
CONF_newtrackname = '#trname_render',
CONF_newtrackname2 = '#trname_sends render',
-- postprocessing
CONF_destination = 1, -- 1 same track 2 new track 3 common track
CONF_destination_sametr = 1, -- 1 as new take to existed item 2 - fixed lane
CONF_destination_sametr_flags = 2, -- &1 new fixedlane gets selected &2 do not set active lave
CONF_destination_trposition = 1, -- 1 below source track 2 above source track 3 start of tracklist 4 end of tracklist
CONF_destination_makeparent = 0,--&1 track above parent to source
CONF_glue = 0,
CONF_mutesrctrack = 0,
CONF_mutedesttrack = 0,
CONF_mutesrcitem = 0,
CONF_disabletrfx = 0,
}
-------------------------------------------------------------------------------- INIT data
DATA = {
ES_key = 'MPL_rendsel',
UI_name = 'Render-in-place',
upd = true,
rend_temp = {
cnt_RA = 0,
cnt_items = 0,
cnt_tracks = 0,
},
rend = {},
preset_name = 'untitled', -- for inputtext
presets_factory = {
--['default'] = "CkNPTkZfZ2x1ZT0wCkNPTkZfbmFtZT1kZWZhdWx0CkNPTkZfc291cmNlPTE="
}
}
-------------------------------------------------------------------------------- INIT UI locals
for key in pairs(reaper) do _G[key]=reaper[key] end
--local ctx
-------------------------------------------------------------------------------- UI init variables
UI = {}
-- font
UI.font='Arial'
UI.font1sz=16
UI.font2sz=14
UI.font3sz=12
-- style
UI.pushcnt = 0
UI.pushcnt2 = 0
-- size / offset
UI.spacingX = 4
UI.spacingX_wind = 10
UI.spacingY = 3
UI.spacingY_wind = 10
-- mouse
UI.hoverdelay = 0.8
UI.hoverdelayshort = 0.8
-- colors
UI.main_col = 0x7F7F7F -- grey
UI.textcol = 0xFFFFFF
UI.but_hovered = 0x878787
UI.windowBg = 0x303030
-- alpha
UI.textcol_a_enabled = 1
UI.textcol_a_disabled = 0.5
-- special
UI.windowBg_plugin = 0x505050
UI.butBg_green = 0x00B300
UI.butBg_red = 0xB31F0F
UI.combo_w = 230
UI.combo_w2 = 180
UI.indent = 20
function msg(s) if not s then return end if type(s) == 'boolean' then if s then s = 'true' else s = 'false' end end ShowConsoleMsg(s..'\n') end
--------------------------------------------------------------------------------
function UI.MAIN_PushStyle(key, value, value2)
local iscol = key:match('Col_')~=nil
local keyid = ImGui[key]
if not iscol then
ImGui.PushStyleVar(ctx, keyid, value, value2)
UI.pushcnt = UI.pushcnt + 1
else
ImGui.PushStyleColor(ctx, keyid, math.floor(value2*255)|(value<<8) )
UI.pushcnt2 = UI.pushcnt2 + 1
end
end
--------------------------------------------------------------------------------
function UI.MAIN_draw(open)
local w_min = 400
local h_min = 640
DATA.display_scrollbarw = 20
-- window_flags
local window_flags = ImGui.WindowFlags_None
--window_flags = window_flags | ImGui.WindowFlags_NoTitleBar
window_flags = window_flags | ImGui.WindowFlags_NoScrollbar
--window_flags = window_flags| ImGui.WindowFlags_AlwaysVerticalScrollbar
--window_flags = window_flags | ImGui.WindowFlags_MenuBar()
--window_flags = window_flags | ImGui.WindowFlags_NoMove()
window_flags = window_flags | ImGui.WindowFlags_NoResize
window_flags = window_flags | ImGui.WindowFlags_NoCollapse
--window_flags = window_flags | ImGui.WindowFlags_NoNav()
--window_flags = window_flags | ImGui.WindowFlags_NoBackground()
window_flags = window_flags | ImGui.WindowFlags_NoDocking
window_flags = window_flags | ImGui.WindowFlags_TopMost
window_flags = window_flags | ImGui.WindowFlags_NoScrollWithMouse
--if UI.disable_save_window_pos == true then window_flags = window_flags | ImGui.WindowFlags_NoSavedSettings() end
--window_flags = window_flags | ImGui.WindowFlags_UnsavedDocument()
--open = false -- disable the close button
-- set style
UI.pushcnt = 0
UI.pushcnt2 = 0
-- rounding
UI.MAIN_PushStyle('StyleVar_FrameRounding',5)
UI.MAIN_PushStyle('StyleVar_GrabRounding',5)
UI.MAIN_PushStyle('StyleVar_WindowRounding',10)
UI.MAIN_PushStyle('StyleVar_ChildRounding',5)
UI.MAIN_PushStyle('StyleVar_PopupRounding',0)
UI.MAIN_PushStyle('StyleVar_ScrollbarRounding',9)
UI.MAIN_PushStyle('StyleVar_TabRounding',4)
-- Borders
UI.MAIN_PushStyle('StyleVar_WindowBorderSize',0)
UI.MAIN_PushStyle('StyleVar_FrameBorderSize',0)
-- spacing
UI.MAIN_PushStyle('StyleVar_WindowPadding',UI.spacingX_wind,UI.spacingY_wind)
UI.MAIN_PushStyle('StyleVar_FramePadding',10,5)
UI.MAIN_PushStyle('StyleVar_CellPadding',UI.spacingX, UI.spacingY)
UI.MAIN_PushStyle('StyleVar_ItemSpacing',UI.spacingX*2, UI.spacingY)
UI.MAIN_PushStyle('StyleVar_ItemInnerSpacing',4,0)
UI.MAIN_PushStyle('StyleVar_IndentSpacing',20)
UI.MAIN_PushStyle('StyleVar_ScrollbarSize',DATA.display_scrollbarw)
-- size
UI.MAIN_PushStyle('StyleVar_GrabMinSize',30)
UI.MAIN_PushStyle('StyleVar_WindowMinSize',w_min,h_min)
-- align
UI.MAIN_PushStyle('StyleVar_WindowTitleAlign',0.5,0.5)
UI.MAIN_PushStyle('StyleVar_ButtonTextAlign',0.5,0.5)
UI.MAIN_PushStyle('StyleVar_SelectableTextAlign',0.01,0.5 )
--UI.MAIN_PushStyle('StyleVar_SeparatorTextAlign,0,0.5 )
--UI.MAIN_PushStyle('StyleVar_SeparatorTextPadding,20,3 )
--UI.MAIN_PushStyle('StyleVar_SeparatorTextBorderSize,3 )
-- alpha
UI.MAIN_PushStyle('StyleVar_Alpha',0.98)
--UI.MAIN_PushStyle('StyleVar_DisabledAlpha,0.6 )
UI.MAIN_PushStyle('Col_Border',UI.main_col, 0.3)
-- colors
--UI.MAIN_PushStyle('Col_BorderShadow(),0xFFFFFF, 1)
UI.MAIN_PushStyle('Col_Button',UI.main_col, 0.3)
UI.MAIN_PushStyle('Col_ButtonActive',UI.main_col, 1)
UI.MAIN_PushStyle('Col_ButtonHovered',UI.but_hovered, 0.8)
--UI.MAIN_PushStyle('Col_CheckMark(),UI.main_col, 0, true)
--UI.MAIN_PushStyle('Col_ChildBg(),UI.main_col, 0, true)
--UI.MAIN_PushStyle('Col_ChildBg(),UI.main_col, 0, true)
--Constant: Col_DockingEmptyBg
--Constant: Col_DockingPreview
--Constant: Col_DragDropTarget
UI.MAIN_PushStyle('Col_DragDropTarget',0xFF1F5F, 0.6)
UI.MAIN_PushStyle('Col_FrameBg',0x1F1F1F, 0.7)
UI.MAIN_PushStyle('Col_FrameBgActive',UI.main_col, .6)
UI.MAIN_PushStyle('Col_FrameBgHovered',UI.main_col, 0.7)
UI.MAIN_PushStyle('Col_Header',UI.main_col, 0.5)
UI.MAIN_PushStyle('Col_HeaderActive',UI.main_col, 1)
UI.MAIN_PushStyle('Col_HeaderHovered',UI.main_col, 0.98)
--Constant: Col_MenuBarBg
--Constant: Col_ModalWindowDimBg
--Constant: Col_NavHighlight
--Constant: Col_NavWindowingDimBg
--Constant: Col_NavWindowingHighlight
--Constant: Col_PlotHistogram
--Constant: Col_PlotHistogramHovered
--Constant: Col_PlotLines
--Constant: Col_PlotLinesHovered
UI.MAIN_PushStyle('Col_PopupBg',0x303030, 0.9)
UI.MAIN_PushStyle('Col_ResizeGrip',UI.main_col, 1)
--Constant: Col_ResizeGripActive
UI.MAIN_PushStyle('Col_ResizeGripHovered',UI.main_col, 1)
--Constant: Col_ScrollbarBg
--Constant: Col_ScrollbarGrab
--Constant: Col_ScrollbarGrabActive
--Constant: Col_ScrollbarGrabHovered
--Constant: Col_Separator
--Constant: Col_SeparatorActive
--Constant: Col_SeparatorHovered
--Constant: Col_SliderGrab
--Constant: Col_SliderGrabActive
UI.MAIN_PushStyle('Col_Tab',UI.main_col, 0.37)
--UI.MAIN_PushStyle('Col_TabActive',UI.main_col, 1)
UI.MAIN_PushStyle('Col_TabHovered',UI.main_col, 0.8)
--Constant: Col_TabUnfocused
--'Col_TabUnfocusedActive
--UI.MAIN_PushStyle('Col_TabUnfocusedActive(),UI.main_col, 0.8, true)
--Constant: Col_TableBorderLight
--Constant: Col_TableBorderStrong
--Constant: Col_TableHeaderBg
--Constant: Col_TableRowBg
--Constant: Col_TableRowBgAlt
UI.MAIN_PushStyle('Col_Text',UI.textcol, UI.textcol_a_enabled)
--Constant: Col_TextDisabled
--Constant: Col_TextSelectedBg
UI.MAIN_PushStyle('Col_TitleBg',UI.main_col, 0.7)
UI.MAIN_PushStyle('Col_TitleBgActive',UI.main_col, 0.95)
--Constant: Col_TitleBgCollapsed
UI.MAIN_PushStyle('Col_WindowBg',UI.windowBg, 1)
-- We specify a default position/size in case there's no data in the .ini file.
local main_viewport = ImGui.GetMainViewport(ctx)
local x, y, w, h =EXT.viewport_posX,EXT.viewport_posY, EXT.viewport_posW,EXT.viewport_posH
ImGui.SetNextWindowPos(ctx, x, y, ImGui.Cond_Appearing )
ImGui.SetNextWindowSize(ctx, w, h, ImGui.Cond_Appearing)
-- init UI
ImGui.PushFont(ctx, DATA.font1)
local rv,open = ImGui.Begin(ctx, DATA.UI_name, open, window_flags)
if rv then
local Viewport = ImGui.GetWindowViewport(ctx)
DATA.display_x, DATA.display_y = ImGui.Viewport_GetPos(Viewport)
DATA.display_w, DATA.display_h = ImGui.Viewport_GetSize(Viewport)
DATA.display_w_region, DATA.display_h_region = ImGui.Viewport_GetWorkSize(Viewport)
--DATA.display_w_child = DATA.display_w - DATA.display_scrollbarw
-- calc stuff for childs
UI.calc_xoffset,UI.calc_yoffset = ImGui.GetStyleVar(ctx, ImGui.StyleVar_WindowPadding)
local framew,frameh = ImGui.GetStyleVar(ctx, ImGui.StyleVar_FramePadding)
local calcitemw, calcitemh = ImGui.CalcTextSize(ctx, 'test')
UI.calc_itemH = calcitemh + frameh * 2
UI.calc_comb_sel_x = DATA.display_w-UI.combo_w-UI.spacingX_wind*2-DATA.display_scrollbarw-UI.spacingX*2
UI.calc_comb_sel_x2 = DATA.display_w-UI.combo_w2-UI.spacingX_wind*2-DATA.display_scrollbarw-UI.spacingX*2
-- draw stuff
UI.draw()
ImGui.Dummy(ctx,0,0)
ImGui.PopStyleVar(ctx, UI.pushcnt)
ImGui.PopStyleColor(ctx, UI.pushcnt2)
ImGui.End(ctx)
else
ImGui.PopStyleVar(ctx, UI.pushcnt)
ImGui.PopStyleColor(ctx, UI.pushcnt2)
end
ImGui.PopFont( ctx )
if ImGui.IsKeyPressed( ctx, ImGui.Key_Escape,false ) then return end
return open
end
--------------------------------------------------------------------------------
function UI.MAIN_PopStyle(ctx, cnt, cnt2)
if cnt then
ImGui.PopStyleVar(ctx,cnt)
UI.pushcnt = UI.pushcnt -cnt
end
if cnt2 then
ImGui.PopStyleColor(ctx,cnt2)
UI.pushcnt2 = UI.pushcnt2 -cnt2
end
end
--------------------------------------------------------------------------------
function UI.MAINloop()
DATA.clock = os.clock()
DATA:handleProjUpdates()
if DATA.upd == true then DATA:CollectData() end
DATA.upd = false
DATA:Render_Queue()
if EXT.CONF_unmutesends&2~=2 then DATA:Render_Glue() end
-- draw UI
UI.open = UI.MAIN_draw(true)
-- handle xy
DATA:handleViewportXYWH()
-- data
if UI.open then defer(UI.MAINloop) end
end
---------------------------------------------------------------------
function VF_GetMediaItemByGUID(optional_proj, itemGUID)
local optional_proj0 = optional_proj or 0
local itemCount = CountMediaItems(optional_proj);
for i = 1, itemCount do
local item = GetMediaItem(0, i-1);
local retval, stringNeedBig = GetSetMediaItemInfo_String(item, "GUID", '', false)
if stringNeedBig == itemGUID then return item end
end
end
--------------------------------------------------------------------------------
function DATA:Render_Glue()
local project = DATA.rend_temp.project
if DATA.rend_temp.schedule_glue ~= true then return end
if not DATA.rend_temp.schedule_glue_state then DATA.rend_temp.schedule_glue_state = 0 end
local destinationtrptr = VF_GetMediaTrackByGUID(project, DATA.rend.pieces[1].dest_trGUID)
-- init state
if DATA.rend_temp.schedule_glue_state == 0 then
DATA.rend_temp.fptoremove = {} for i = 1, #DATA.rend.pieces do DATA.rend_temp.fptoremove[#DATA.rend_temp.fptoremove+1] = DATA.rend.pieces[i].outputfp end
-- DATA:Render_Glue_SelectOutputPieces()
-- Main_OnCommandEx( 40362, 0, project ) -- Item: Glue items, ignoring time selection
-- set dest track solo
SetMediaTrackInfo_Value( destinationtrptr, 'I_SOLO',1)
-- set render params
local outputpath,outputfile,outputfp = DATA:Render_GetFileOutput()
local boundary_st = DATA.rend.boundary_st
local boundary_end = DATA.rend.boundary_end
GetSetProjectInfo( project, 'RENDER_CHANNELS', 2, true ) -- chan cnt
GetSetProjectInfo( project, 'RENDER_STARTPOS', boundary_st, true ) -- bound start
GetSetProjectInfo( project, 'RENDER_ENDPOS', boundary_end, true ) -- bound end
GetSetProjectInfo_String( project, 'RENDER_FILE', outputpath, true )
GetSetProjectInfo_String( project, 'RENDER_PATTERN', outputfile, true )
-- set master fx off
DATA.rend_temp.glue_outputfp = outputfp
local mastertr = reaper.GetMasterTrack(project)
SetMediaTrackInfo_Value( mastertr, 'I_FXEN',0 )
-- render
Main_OnCommandEx( 42230, 0, project ) -- File: Render project, using the most recent render settings, auto-close render dialog
DATA.rend_temp.schedule_glue_state = 1
return
end
-- processing
if DATA.rend_temp.schedule_glue_state == 1 then
local playstate = GetPlayStateEx( project )
if playstate&1==1 then -- is rendering
return
else
-- disable solo for dest track
SetMediaTrackInfo_Value( destinationtrptr, 'I_SOLO',0)
-- restore master fx
if EXT.CONF_enablemasterfx&1==1 then
local mastertr = reaper.GetMasterTrack(project)
SetMediaTrackInfo_Value( mastertr, 'I_FXEN', DATA.rend_temp.masterfxenabled )
end
-- insert glue render
local t = {
outputfp = DATA.rend_temp.glue_outputfp,
boundary_st = DATA.rend.boundary_st,
boundary_end = DATA.rend.boundary_end,
}
DATA:Render_InsertMedia(t)
-- remove temporary items / files
DATA:Render_Glue_RemoveOutputPieces()
if DATA.rend_temp.fptoremove then
for i = 1, #DATA.rend_temp.fptoremove do os.remove(DATA.rend_temp.fptoremove[i]) end
DATA.rend_temp.fptoremove = nil
end
--reset states
DATA.rend_temp.schedule_glue = nil
DATA.rend_temp.schedule_glue_state = nil
DATA:Render_Finish()
end
end
end
--------------------------------------------------------------------------------
function DATA:Render_Glue_RemoveOutputPieces()
local project = DATA.rend_temp.project
--SelectAllMediaItems( project, false )
for i = 1, #DATA.rend.pieces do
local itemGUID = DATA.rend.pieces[i].dest_itemGUID
local item = VF_GetMediaItemByGUID(project, itemGUID)
if item and reaper.ValidatePtr2(project, item, 'MediaItem*') then DeleteTrackMediaItem( reaper.GetMediaItemTrack( item ), item ) end
end
end
--------------------------------------------------------------------------------
function DATA:Render_Finish()
PreventUIRefresh( -1 )
DATA.upd = true -- trigger resfresh
-- restore config / mutesolo states
DATA:Render_CurrentConfig_Restore()
-- mute src item
if EXT.CONF_destination==1 and EXT.CONF_mutesrcitem&1==1 then
for i = 1, #DATA.rend.pieces do
local itemGUID = DATA.rend.pieces[i].srcitemGUID
local item = VF_GetMediaItemByGUID(project, itemGUID)
if item and reaper.ValidatePtr2(project, item, 'MediaItem*') then SetMediaItemInfo_Value( item, 'B_MUTE',1 ) end
end
end
-- disable fx
if EXT.CONF_disabletrfx&1==1 then
local firsttr = VF_GetMediaTrackByGUID(project, DATA.rend.firsttrGUID)
SetMediaTrackInfo_Value( firsttr, 'I_FXEN', 0 )
end
-- refresh arrange
Undo_OnStateChange2( project, 'MPL Render-in-place' )
Main_OnCommandEx( 40047, 0, project ) -- Peaks: Build any missing peaks
TrackList_AdjustWindows( false )
UpdateArrange()
UpdateTimeline()
end
--------------------------------------------------------------------------------
function UI.SameLine(ctx) ImGui.SameLine(ctx) end
--------------------------------------------------------------------------------
function UI.MAIN()
-- imgUI init
ctx = ImGui.CreateContext(DATA.UI_name)
-- fonts
DATA.font1 = ImGui.CreateFont(UI.font, UI.font1sz) ImGui.Attach(ctx, DATA.font1)
DATA.font2 = ImGui.CreateFont(UI.font, UI.font2sz) ImGui.Attach(ctx, DATA.font2)
DATA.font3 = ImGui.CreateFont(UI.font, UI.font3sz) ImGui.Attach(ctx, DATA.font3)
-- config
ImGui.SetConfigVar(ctx, ImGui.ConfigVar_HoverDelayNormal, UI.hoverdelay)
ImGui.SetConfigVar(ctx, ImGui.ConfigVar_HoverDelayShort, UI.hoverdelayshort)
-- run loop
defer(UI.MAINloop)
end
--------------------------------------------------------------------------------
function EXT:save()
if not DATA.ES_key then return end
for key in pairs(EXT) do
if (type(EXT[key]) == 'string' or type(EXT[key]) == 'number') then
SetExtState( DATA.ES_key, key, EXT[key], true )
end
end
EXT:load()
end
--------------------------------------------------------------------------------
function EXT:load()
if not DATA.ES_key then return end
for key in pairs(EXT) do
if (type(EXT[key]) == 'string' or type(EXT[key]) == 'number') then
if HasExtState( DATA.ES_key, key ) then
local val = GetExtState( DATA.ES_key, key )
EXT[key] = tonumber(val) or val
end
end
end
DATA.upd = true
end
--------------------------------------------------------------------------------
function main()
EXT_defaults = VF_CopyTable(EXT)
EXT:load()
DATA.PRESET_GetExtStatePresets()
UI.MAIN()
end
--------------------------------------------------------------------------------
function UI.draw_setbuttoncolor(col)
UI.MAIN_PushStyle('Col_Button',col, 0.5)
UI.MAIN_PushStyle('Col_ButtonActive',col, 1)
UI.MAIN_PushStyle('Col_ButtonHovered',col, 0.8)
end
--------------------------------------------------------------------------------
function UI.draw_setbuttonbackgtransparent()
UI.MAIN_PushStyle('Col_Button',0, 0)
UI.MAIN_PushStyle('Col_ButtonActive',0, 0)
UI.MAIN_PushStyle('Col_ButtonHovered',0, 0)
end
--------------------------------------------------------------------------------
function UI.draw_unsetbuttonstyle()
UI.MAIN_PopStyle(ctx, nil, 3)
end
---------------------------------------------------------------------
function DATA.PRESET_encBase64(data) -- https://stackoverflow.com/questions/34618946/lua-base64-encode
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
---------------------------------------------------------------------
function DATA.PRESET_decBase64(data) -- https://stackoverflow.com/questions/34618946/lua-base64-encode
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' -- You will need this for encoding/decoding
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end
---------------------------------------------------
function spairs(t, order) --http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
local keys = {}
for k in pairs(t) do keys[#keys+1] = k end
if order then table.sort(keys, function(a,b) return order(t, a, b) end) else table.sort(keys) end
local i = 0
return function()
i = i + 1
if keys[i] then return keys[i], t[keys[i]] end
end
end
---------------------------------------------------------------------
function DATA.PRESET_GetCurrentPresetData()
local str = ''
for key in spairs(EXT) do if key:match('CONF_') then str = str..'\n'..key..'='..EXT[key] end end
return DATA.PRESET_encBase64(str)
end
---------------------------------------------------------------------
function DATA.PRESET_GetExtStatePresets()
DATA.presets = {}
DATA.presets.factory = DATA.presets_factory
local preset_base64_user = EXT.preset_base64_user
if preset_base64_user:match('{')== nil and preset_base64_user~= '' then preset_base64_user = DATA.PRESET_decBase64(preset_base64_user) end
DATA.presets.user = table.load(preset_base64_user) or {}
end
---------------------------------------------------------------------
function DATA.PRESET_RestoreDefaults(key, UI)
if not key then
for key in pairs(EXT) do
if key:match('CONF_') or (UI and UI == true and key:match('UI_'))then
local val = EXT_defaults[key]
if val then EXT[key] = val end
end
end
else
local val = EXT_defaults[key]
if val then EXT[key] = val end
end
EXT:save()
end
---------------------------------------------------------------------
function DATA.PRESET_ApplyPreset(base64str)
if not base64str then return end
local preset_t = {}
local str_dec = DATA.PRESET_decBase64(base64str)
if str_dec~= '' then
for line in str_dec:gmatch('[^\r\n]+') do
local key,value = line:gsub('[%{}]',''):match('(.-)=(.*)')
if key and value and key:match('CONF_') then preset_t[key]= tonumber(value) or value end
end
end
for key in pairs(preset_t) do
if key:match('CONF_') then
local presval = preset_t[key]
EXT[key] = tonumber(presval) or presval
end
end
EXT:save()
end
--------------------------------------------------------------------------------
function UI.draw_preset()
-- preset
local select_wsz = 250
local select_hsz = UI.calc_itemH
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Preset') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetCursorPosX( ctx, DATA.display_w-UI.combo_w-UI.spacingX_wind )
ImGui.SetNextItemWidth( ctx, UI.combo_w )
local preview = EXT.CONF_name
if ImGui.BeginCombo(ctx, '##Preset', preview, ImGui.ComboFlags_HeightLargest) then
if ImGui.Button(ctx, 'Restore defaults') then DATA.PRESET_RestoreDefaults() end
local retval, buf = ImGui.InputText( ctx, '##presname', DATA.preset_name )
if retval then DATA.preset_name = buf end
ImGui.SameLine(ctx)
if ImGui.Button(ctx, 'Save current') then
local newID = DATA.preset_name--os.date()
EXT.CONF_name = newID
DATA.presets.user[newID] = DATA.PRESET_GetCurrentPresetData()
EXT.preset_base64_user = DATA.PRESET_encBase64(table.save(DATA.presets.user))
EXT:save()
end
local id = 0
for preset in spairs(DATA.presets.factory) do
id = id + 1
if ImGui.Selectable(ctx, '[F] '..preset..'##factorypresets'..id, nil,nil,select_wsz,select_hsz) then
DATA.PRESET_ApplyPreset(DATA.presets.factory[preset])
EXT:save()
end
end
local id = 0
for preset in spairs(DATA.presets.user) do
id = id + 1
if ImGui.Selectable(ctx, preset..'##userpresets'..id, nil,nil,select_wsz,select_hsz) then
DATA.PRESET_ApplyPreset(DATA.presets.user[preset])
EXT:save()
end
ImGui.SameLine(ctx)
if ImGui.Button(ctx, 'Remove##remove'..id) then
DATA.presets.user[preset] = nil
EXT.preset_base64_user = DATA.PRESET_encBase64(table.save(DATA.presets.user))
EXT:save()
end
end
ImGui.EndCombo(ctx)
end
end
--------------------------------------------------------------------------------
function UI.draw_tab_source()
local trig_action
if ImGui.BeginTabItem(ctx, 'Source') then
local project = DATA.rend_temp.project
if ImGui.BeginChild( ctx, '##settings',nil,nil,ImGui.ChildFlags_Border) then
-- Source
--ImGui.SeparatorText(ctx, 'Source')
if ImGui.Checkbox(ctx, 'Razor areas ('..(DATA.rend_temp.cnt_RA or 0)..')',EXT.CONF_source&1==1) then EXT.CONF_source = EXT.CONF_source~1 EXT:save() end
if ImGui.Checkbox(ctx, 'Selected items ('..(DATA.rend_temp.cnt_items or 0)..')',EXT.CONF_source&2==2) then EXT.CONF_source = EXT.CONF_source~2 EXT:save() end
if EXT.CONF_source&2==2 then
ImGui.Indent(ctx, UI.indent)
if ImGui.Checkbox(ctx, 'If items aren`t catched by razor areas',EXT.CONF_source_itemflags&1==1) then EXT.CONF_source_itemflags = EXT.CONF_source_itemflags~1 EXT:save() end
if ImGui.Checkbox(ctx, 'Ignore if at least one razor area exists',EXT.CONF_source_itemflags&2==2) then EXT.CONF_source_itemflags = EXT.CONF_source_itemflags~2 EXT:save() end
ImGui.Unindent(ctx, UI.indent)
end
if ImGui.Checkbox(ctx, 'Track time selection ('..(DATA.rend_temp.cnt_tracks or 0)..')',EXT.CONF_source&4==4) then EXT.CONF_source = EXT.CONF_source~4 EXT:save() end
if EXT.CONF_source&4==4 then
ImGui.Indent(ctx, UI.indent)
if ImGui.Checkbox(ctx, 'If no razor areas presented',EXT.CONF_source&8==8) then EXT.CONF_source = EXT.CONF_source~8 EXT:save() end
if ImGui.Checkbox(ctx, 'If no selected items presented',EXT.CONF_source&16==16) then EXT.CONF_source = EXT.CONF_source~16 EXT:save() end
ImGui.Unindent(ctx, UI.indent)
end
ImGui.EndChild( ctx )
end
ImGui.EndTabItem(ctx)
end
end
--------------------------------------------------------------------------------
function UI.draw_tab_prepare()
local trig_action
if ImGui.BeginTabItem(ctx, 'Prepare') then
local project = DATA.rend_temp.project
if ImGui.BeginChild( ctx, '##settings',nil,nil,ImGui.ChildFlags_Border) then
-- Preparations
--ImGui.SeparatorText(ctx, 'Preparation')
if ImGui.Checkbox(ctx, 'Enable sends (use solo-in-place)',EXT.CONF_unmutesends&1==1) then EXT.CONF_unmutesends = EXT.CONF_unmutesends~1 EXT:save() end
if EXT.CONF_unmutesends&1==1 then
ImGui.Indent(ctx, UI.indent)
if ImGui.Checkbox(ctx, 'Render sends separately',EXT.CONF_unmutesends&2==2) then EXT.CONF_unmutesends = EXT.CONF_unmutesends~2 EXT:save() end
ImGui.Unindent(ctx, UI.indent)
end
if ImGui.Checkbox(ctx, 'Enable master FX',EXT.CONF_enablemasterfx&1==1) then EXT.CONF_enablemasterfx = EXT.CONF_enablemasterfx~1 EXT:save() end
if ImGui.Checkbox(ctx, 'Enable track FX',EXT.CONF_trackfxenabled&1==1) then EXT.CONF_trackfxenabled = EXT.CONF_trackfxenabled~1 EXT:save() end
if EXT.CONF_trackfxenabled&1==1 then
ImGui.Indent(ctx, UI.indent)
if ImGui.Checkbox(ctx, 'FX before instrument',EXT.CONF_trackfxenabled&4==4) then EXT.CONF_trackfxenabled = EXT.CONF_trackfxenabled~4 EXT:save() end
if ImGui.Checkbox(ctx, 'Instrument FX',EXT.CONF_trackfxenabled&2==2) then EXT.CONF_trackfxenabled = EXT.CONF_trackfxenabled~2 EXT:save() end
if EXT.CONF_trackfxenabled&2==2 then
ImGui.Indent(ctx, UI.indent)
if ImGui.Checkbox(ctx, 'Treat XXi as instrument',EXT.CONF_trackfxenabled&16==16) then EXT.CONF_trackfxenabled = EXT.CONF_trackfxenabled~16 EXT:save() end
ImGui.Unindent(ctx, UI.indent)
end
if ImGui.Checkbox(ctx, 'All FX / FX after instrument',EXT.CONF_trackfxenabled&8==8) then EXT.CONF_trackfxenabled = EXT.CONF_trackfxenabled~8 EXT:save() end
ImGui.Unindent(ctx, UI.indent)
end
--if ImGui.Checkbox(ctx, 'Enable childrens for parent track',EXT.CONF_enablechildrens&1==1) then EXT.CONF_enablechildrens = EXT.CONF_enablechildrens~1 EXT:save() end
ImGui.EndChild( ctx )
end
ImGui.EndTabItem(ctx)
end
end
--------------------------------------------------------------------------------
function UI.draw_tab_properties()
local trig_action
if ImGui.BeginTabItem(ctx, 'Properties') then
-- Properties
ImGui.SeparatorText(ctx, 'Render properties / format')
-- tail
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Tail mode') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w2 )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x2 )
local names = {
'Off',
'Bars.beats',
'Seconds'}
local preview = names[EXT.CONF_tail+1] or '' if ImGui.BeginCombo(ctx, '##tail', preview) then for i = 1, #names do if ImGui.Selectable(ctx, names[i]) then EXT.CONF_tail = i-1 EXT:save() end end ImGui.EndCombo(ctx) end
-- tail length
if EXT.CONF_tail >0 then
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Tail length') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w2 )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x2 )
local ret, buf = ImGui.InputText(ctx,'##taillen',EXT.CONF_tail_len)--, ImGui.InputTextFlags_EnterReturnsTrue)
if ret and tonumber(buf) then
EXT.CONF_tail_len = tonumber(buf)
EXT:save()
end
if ImGui.Checkbox(ctx, 'Extend rendered media for tail',EXT.CONF_extendtotail&1==1) then EXT.CONF_extendtotail = EXT.CONF_extendtotail~1 EXT:save() end
end
-- bitdepth
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Bit depth') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w2 )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x2 )
local names = {
'16bit PCM',
'24bit PCM',
'32bit FP',
'64bit FP',
}
local preview = names[EXT.CONF_bitdepth] or '' if ImGui.BeginCombo(ctx, '##bitdepth', preview) then for i = 1, #names do if ImGui.Selectable(ctx, names[i]) then EXT.CONF_bitdepth = i EXT:save() end end ImGui.EndCombo(ctx) end
-- name
--UI.draw_setbuttonbackgtransparent()
if ImGui.Button(ctx, 'Sub folder') then
local project = DATA.rend_temp.project
local outputpath = GetProjectPathEx( project )..'/'
if EXT.CONF_outputpath ~= '' then outputpath = outputpath..EXT.CONF_outputpath end
outputpath = outputpath:gsub('\\','/')
reaper.RecursiveCreateDirectory(outputpath,0)
os.execute('start "" "'..outputpath..'"')
end
--UI.draw_unsetbuttonstyle()
ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x )
local ret, buf = ImGui.InputText(ctx,'##custpath',EXT.CONF_outputpath)
if ret and buf and buf ~= '' then
EXT.CONF_outputpath = buf:gsub('[%/%\\%:%*%?%<%>%|%"]', '') -- prevent wrong names
EXT:save()
end
-- name
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Filename') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x )
local ret, buf = ImGui.InputText(ctx,'##custname',EXT.CONF_outputname)
if ret and buf and buf ~= '' then
EXT.CONF_outputname = buf:gsub('[%/%\\%:%*%?%<%>%|%"]', '') -- prevent wrong names
EXT:save()
end
ImGui.EndTabItem(ctx)
end
end
--------------------------------------------------------------------------------
function UI.draw_tab_postprocessing()
local trig_action
if ImGui.BeginTabItem(ctx, 'Postprocessing') then
-- dest
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Destination') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x )
local names = {
'Same track',
'New track for each piece',
'New track for all pieces',
}
-- dest options new take
local preview = names[EXT.CONF_destination] or '' if ImGui.BeginCombo(ctx, '##Destination', preview) then for i = 1, #names do if ImGui.Selectable(ctx, names[i]) then EXT.CONF_destination = i EXT:save() end end ImGui.EndCombo(ctx) end
if EXT.CONF_destination==1 then
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, ' ') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x )
local names = {
'New take to item if available',
'New take to fixed lane',
}
local preview = names[EXT.CONF_destination_sametr] or '' if ImGui.BeginCombo(ctx, '##Destinationtr', preview) then for i = 1, #names do if ImGui.Selectable(ctx, names[i]) then EXT.CONF_destination_sametr = i EXT:save() end end ImGui.EndCombo(ctx) end
end
if EXT.CONF_destination == 1 and EXT.CONF_destination_sametr == 2 then
if ImGui.Checkbox(ctx, 'Do not change active lane (otherwise 1st always active)',EXT.CONF_destination_sametr_flags&2==2) then EXT.CONF_destination_sametr_flags = EXT.CONF_destination_sametr_flags~2 EXT:save() end
if EXT.CONF_destination_sametr_flags&2~=2 then
if ImGui.Checkbox(ctx, 'Make new fixed lane selected',EXT.CONF_destination_sametr_flags&1==1) then EXT.CONF_destination_sametr_flags = EXT.CONF_destination_sametr_flags~1 EXT:save() end
end
end
-- tr properties
if EXT.CONF_destination==2 or EXT.CONF_destination == 3 then
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Track position') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x )
local names = {
'Below source track',
'Above source track',
'Start of tracklist',
'End of tracklist'
}
local preview = names[EXT.CONF_destination_trposition] or '' if ImGui.BeginCombo(ctx, '##Destinationtrpos', preview) then for i = 1, #names do if ImGui.Selectable(ctx, names[i]) then EXT.CONF_destination_trposition = i EXT:save() end end ImGui.EndCombo(ctx) end
if EXT.CONF_destination == 2 and EXT.CONF_destination_trposition == 2 and EXT.CONF_unmutesends&2~=2 then
if ImGui.Checkbox(ctx, 'Destination track parent to source',EXT.CONF_destination_makeparent&1==1) then EXT.CONF_destination_makeparent = EXT.CONF_destination_makeparent~1 EXT:save() end
end
-- tr name
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Render track name') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w2 )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x2 )
local ret, buf = ImGui.InputText(ctx,'##trcustname',EXT.CONF_newtrackname)
if ret and buf then
EXT.CONF_newtrackname = buf:gsub('[%/%\\%:%*%?%<%>%|%"]', '')
EXT:save()
end
UI.draw_setbuttonbackgtransparent() ImGui.Button(ctx, 'Send track name') UI.draw_unsetbuttonstyle() ImGui.SameLine(ctx)
ImGui.SetNextItemWidth( ctx, UI.combo_w2 )
ImGui.SetCursorPosX( ctx, UI.calc_comb_sel_x2 )
local ret, buf = ImGui.InputText(ctx,'##trcustname2',EXT.CONF_newtrackname2)
if ret and buf then
EXT.CONF_newtrackname2 = buf:gsub('[%/%\\%:%*%?%<%>%|%"]', '')
EXT:save()
end
if ImGui.Checkbox(ctx, 'Mute source track',EXT.CONF_mutesrctrack&1==1) then EXT.CONF_mutesrctrack = EXT.CONF_mutesrctrack~1 EXT:save() end
if ImGui.Checkbox(ctx, 'Mute destination track',EXT.CONF_mutedesttrack&1==1) then EXT.CONF_mutedesttrack = EXT.CONF_mutedesttrack~1 EXT:save() end
end
-- item properties
if not (EXT.CONF_destination==1 and EXT.CONF_destination_sametr==1) then
if ImGui.Checkbox(ctx, 'Mute source item',EXT.CONF_mutesrcitem&1==1) then EXT.CONF_mutesrcitem = EXT.CONF_mutesrcitem~1 EXT:save() end
end
-- FX
if ImGui.Checkbox(ctx, 'Disable source track FX',EXT.CONF_disabletrfx&1==1) then EXT.CONF_disabletrfx = EXT.CONF_disabletrfx~1 EXT:save() end
-- glue
if EXT.CONF_destination == 3 and EXT.CONF_unmutesends&2~=2 then
if ImGui.Checkbox(ctx, 'Glue resulted pieces',EXT.CONF_glue&1==1) then EXT.CONF_glue = EXT.CONF_glue~1 EXT:save() end ImGui.SetItemTooltip(ctx, 'Glue result + remove temp renders from disk. Not available for "render sends separately".')
end
if ImGui.BeginDisabled(ctx,true) then
if ImGui.Checkbox(ctx, 'Render sends separately',EXT.CONF_unmutesends&2==2) then EXT.CONF_unmutesends = EXT.CONF_unmutesends~2 EXT:save() end ImGui.SetItemTooltip(ctx, 'See "Prepare" tab, this check affects some limitations for glue, make_parent options.')
ImGui.EndDisabled(ctx)
end
ImGui.EndTabItem(ctx)
end
end
--------------------------------------------------------------------------------
function UI.draw()
ImGui.PushStyleVar(ctx,ImGui.StyleVar_WindowPadding,UI.spacingX_wind,UI.spacingY) -- limit Y indent for menus
-- preset
UI.draw_preset()
-- render
--ImGui.SetCursorPosX( ctx, DATA.display_w-UI.combo_w2-UI.spacingX_wind )
if ImGui.Button(ctx, 'Render',DATA.display_w-UI.spacingX_wind*2) then DATA:Render() end--,UI.combo_w2
-- tabs
if ImGui.BeginTabBar(ctx, 'tabs', ImGui.TabBarFlags_None) then
UI.draw_tab_source()
UI.draw_tab_prepare()
UI.draw_tab_properties()
UI.draw_tab_postprocessing()
ImGui.EndTabBar(ctx)
end
-- settings
--UI.draw_settings()
ImGui.PopStyleVar(ctx)
end
----------------------------------------------------------------------------------------- -- http://lua-users.org/wiki/SaveTableToFile
function table.exportstring( s ) return string.format("%q", s) end
--// The Save Function
function table.save( tbl )
local outstr = ''
local charS,charE = " ","\n"
-- initiate variables for save procedure
local tables,lookup = { tbl },{ [tbl] = 1 }
outstr = outstr..'\n'..( "return {"..charE )
for idx,t in ipairs( tables ) do
outstr = outstr..'\n'..( "-- Table: {"..idx.."}"..charE )
outstr = outstr..'\n'..( "{"..charE )
local thandled = {}
for i,v in ipairs( t ) do
thandled[i] = true
local stype = type( v )
-- only handle value
if stype == "table" then
if not lookup[v] then
table.insert( tables, v )
lookup[v] = #tables
end
outstr = outstr..'\n'..( charS.."{"..lookup[v].."},"..charE )
elseif stype == "string" then
outstr = outstr..'\n'..( charS..table.exportstring( v )..","..charE )
elseif stype == "number" then
outstr = outstr..'\n'..( charS..tostring( v )..","..charE )
end
end
for i,v in pairs( t ) do
-- escape handled values
if (not thandled[i]) then
local str = ""
local stype = type( i )
-- handle index
if stype == "table" then
if not lookup[i] then
table.insert( tables,i )
lookup[i] = #tables
end
str = charS.."[{"..lookup[i].."}]="
elseif stype == "string" then
str = charS.."["..table.exportstring( i ).."]="
elseif stype == "number" then
str = charS.."["..tostring( i ).."]="
end
if str ~= "" then
stype = type( v )
-- handle value