diff --git a/Items Editing/az_Fade tool (work on context of mouse, razor or time selection).lua b/Items Editing/az_Fade tool (work on context of mouse, razor or time selection).lua index 96c19f05c..5f431addc 100644 --- a/Items Editing/az_Fade tool (work on context of mouse, razor or time selection).lua +++ b/Items Editing/az_Fade tool (work on context of mouse, razor or time selection).lua @@ -1,10 +1,10 @@ -- @description Fade tool (works on context of mouse, razor or time selection) -- @author AZ --- @version 2.2 +-- @version 2.2.1 -- @changelog --- - support adjusting fades/crossfades via mouse for vertical aligned selected items and grouped items --- - new option: ms or frames for batch feature --- - changeable font size for options window +-- - ignore snapping for certain cases +-- - apply font resizing immediately +-- - fixed regression with mouse fade on selected item -- @provides -- az_Fade tool (work on context of mouse, razor or time selection)/az_Options window for az_Fade tool.lua -- [main] az_Fade tool (work on context of mouse, razor or time selection)/az_Open options for az_Fade tool.lua @@ -1007,6 +1007,10 @@ end ----------------------- function MouseOverWhat(razorEdits) + if not reaper.APIExists("JS_Mouse_GetCursor") then + reaper.ShowMessageBox('Missing API!\nInstall js_ReaScriptAPI from ReaPack', 'Fade tool',0) + return + end local currentcur = reaper.JS_Mouse_GetCursor() local fadeid = {105,184, 529} for id=202, 204 do @@ -1873,12 +1877,12 @@ function SortSelItems(Items, ref_item, ref_leftItem, ref_rightItem, reverseFlag) if i_autoFin ~= 0 then leftItem = FindXfadedNeigbourItem(item, i_pos, i_end, -1) - leftIlock = reaper.GetMediaItemInfo_Value( leftItem, "C_LOCK" ) + if leftItem then leftIlock = reaper.GetMediaItemInfo_Value( leftItem, "C_LOCK" ) end end if i_autoFout ~= 0 then rightItem = FindXfadedNeigbourItem(item, i_pos, i_end, 1) - rightIlock = reaper.GetMediaItemInfo_Value( rightItem, "C_LOCK" ) + if rightItem then rightIlock = reaper.GetMediaItemInfo_Value( rightItem, "C_LOCK" ) end end if leftIlock == 1 and Opt.IgnoreLockingMouse == false then leftItem = nil end @@ -2133,8 +2137,10 @@ function FadeToMouse(item, itemHalf) --returns table of fades start position ------------------------ if f_type == 'in' then + if mPosSnapped <= i_pos + 0.0002 then mPosSnapped = mPos end f_size = mPosSnapped - i_pos elseif f_type == 'out' then + if mPosSnapped >= i_end - 0.0002 then mPosSnapped = mPos end f_size = i_end - mPosSnapped end @@ -2465,7 +2471,7 @@ else if UndoString == nil then local item_mouse, itemHalf = GetTopBottomItemHalf() - if item_mouse then --and (Opt.IgnoreLockingMouse == true or fadesLock == 0) then + if item_mouse then reaper.Undo_BeginBlock2( 0 ) reaper.PreventUIRefresh( 1 ) sTime = FadeToMouse(item_mouse, itemHalf) @@ -2502,7 +2508,7 @@ end --------------------------- -----------START----------- -CurVers = 2.2 +CurVers = 2.21 version = tonumber( reaper.GetExtState(ExtStateName, "version") ) if version ~= CurVers then if not version or version < 2.0 then diff --git a/Items Editing/az_Fade tool (work on context of mouse, razor or time selection)/az_Options window for az_Fade tool.lua b/Items Editing/az_Fade tool (work on context of mouse, razor or time selection)/az_Options window for az_Fade tool.lua index 7089b2bf5..0b3e6e89f 100644 --- a/Items Editing/az_Fade tool (work on context of mouse, razor or time selection)/az_Options window for az_Fade tool.lua +++ b/Items Editing/az_Fade tool (work on context of mouse, razor or time selection)/az_Options window for az_Fade tool.lua @@ -81,7 +81,13 @@ function OptionsWindow(OptTable, windowName) Hovered = rgbToHex({35,40,45,80}), Active = rgbToHex({42,42,37,100}), }, - + --[[ + Input = { + Background = rgbToHex({50,50,50,100}), + Hover = rgbToHex({10,10,90,100}), + Text = rgbToHex({90,90,80,100}), + Label = rgbToHex({90,80,90,100}), + },]] Button = { Default = rgbToHex({25,30,30,100}), Hovered = rgbToHex({35,40,45,100}), @@ -95,13 +101,10 @@ function OptionsWindow(OptTable, windowName) if reaper.GetOS():match("^Win") == nil then reaper.ImGui_SetConfigVar(ctx, reaper.ImGui_ConfigVar_ViewportsNoDecoration(), 0) fontName = 'sans-serif' - else fontName = 'Calibri' + else + fontName = 'Calibri' end - font = reaper.ImGui_CreateFont(fontName, fontSize, reaper.ImGui_FontFlags_None()) -- Create the fonts you need - fontSep = reaper.ImGui_CreateFont(fontName, fontSize-2, reaper.ImGui_FontFlags_Italic()) - reaper.ImGui_Attach(ctx, font) - reaper.ImGui_Attach(ctx, fontSep) - + -------------- function frame() reaper.ImGui_PushFont(ctx, font) @@ -222,6 +225,17 @@ function OptionsWindow(OptTable, windowName) -------------- function loop() + if not font or savedFontSize ~= fontSize then + reaper.SetExtState(ExtStateName, 'FontSize', savedFontSize, true) + fontSize = savedFontSize + if font then reaper.ImGui_Detach(ctx, font) end + if fontSep then reaper.ImGui_Detach(ctx, fontSep) end + font = reaper.ImGui_CreateFont(fontName, fontSize, reaper.ImGui_FontFlags_None()) -- Create the fonts you need + fontSep = reaper.ImGui_CreateFont(fontName, fontSize-2, reaper.ImGui_FontFlags_Italic()) + reaper.ImGui_Attach(ctx, font) + reaper.ImGui_Attach(ctx, fontSep) + end + esc = reaper.ImGui_IsKeyPressed(ctx, reaper.ImGui_Key_Escape()) enter = reaper.ImGui_IsKeyPressed(ctx, reaper.ImGui_Key_Enter()) space = reaper.ImGui_IsKeyPressed(ctx, reaper.ImGui_Key_Space()) @@ -254,8 +268,9 @@ function OptionsWindow(OptTable, windowName) reaper.ImGui_PopStyleColor(ctx, 1) if visible then - frame() - if loopcnt == 0 then reaper.ImGui_SetWindowSize(ctx, 0, 0, nil ) end + frame() + reaper.ImGui_SetWindowSize(ctx, 0, 0, nil ) + --if loopcnt == 0 then reaper.ImGui_SetWindowSize(ctx, 0, 0, nil ) end reaper.ImGui_End(ctx) end @@ -269,8 +284,7 @@ function OptionsWindow(OptTable, windowName) space = spaceMouse or reaper.ImGui_IsKeyReleased(ctx, reaper.ImGui_Key_Space()) if space == true then SetExtStates(OptTable) - reaper.SetExtState(ExtStateName, 'TCPaction', tcpActIDstr, true) - reaper.SetExtState(ExtStateName, 'FontSize', savedFontSize, true) + reaper.SetExtState(ExtStateName, 'TCPaction', tcpActIDstr, true) end end @@ -282,8 +296,7 @@ function OptionsWindow(OptTable, windowName) BatchFades() else SetExtStates(OptTable) - reaper.SetExtState(ExtStateName, 'TCPaction', tcpActIDstr, true) - reaper.SetExtState(ExtStateName, 'FontSize', savedFontSize, true) + reaper.SetExtState(ExtStateName, 'TCPaction', tcpActIDstr, true) reaper.ImGui_DestroyContext(ctx) end else