From 120e75b420a4c756c71ce42bd0eea2565cde06ce Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 20 Feb 2017 03:58:52 +0100 Subject: [PATCH] And some more action-script icons --- scripts/addscopes.lua | 17 ++++++++++++++ scripts/create_drum_tracks.lua | 39 +++++++++++++++++++++++++++++++- scripts/remove_unknown_procs.lua | 23 ++++++++++++++++++- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/scripts/addscopes.lua b/scripts/addscopes.lua index deb3a5c814..5ff40a7da8 100644 --- a/scripts/addscopes.lua +++ b/scripts/addscopes.lua @@ -55,3 +55,20 @@ function factory (params) end end end + + +function icon (params) return function (ctx, width, height) + local wh = math.min (width, height) * .5 + local x0 = math.ceil (wh * .4) + local x1 = math.floor (wh * 1.6) + ctx:rectangle (wh * .4, wh * .4, wh * 1.2, wh * 1.2) + ctx:set_source_rgba (.7, .7, .7, 1) + ctx:fill () + ctx:set_line_width (1) + ctx:set_source_rgba (.0, .0, .0, 1) + ctx:move_to (x0, wh) + for x = x0, x1 do + ctx:line_to (x, wh - math.sin (2 * math.pi * (x-x0) / (x1-x0)) * wh * .5) + end + ctx:stroke () +end end diff --git a/scripts/create_drum_tracks.lua b/scripts/create_drum_tracks.lua index 57c484a61e..0f16f87a70 100644 --- a/scripts/create_drum_tracks.lua +++ b/scripts/create_drum_tracks.lua @@ -6,7 +6,6 @@ ardour { } function factory () return function () - local names = { "Kick", "Snare", @@ -34,3 +33,41 @@ function factory () return function () end --foreach track end end -- function factory + + +function icon (params) return function (ctx, width, height) + local x = width * .5 + local y = height * .5 + local r = math.min (x, y) * .7 + ctx:save () + ctx:translate (x, y) + ctx:scale (1, .5) + ctx:translate (-x, -y) + ctx:arc (x, y, r, 0, 2 * math.pi) + ctx:set_source_rgba (.9, .9, 1, 1) + ctx:fill () + ctx:arc (x, y, r, 0, math.pi) + ctx:arc_negative (x, y * 1.6, r, math.pi, 0) + ctx:set_source_rgba (.7, .7, .7, 1) + ctx:fill () + ctx:restore () + + ctx:set_source_rgba (.6, .4, .2, 1) + ctx:translate (x, y) + ctx:scale (.7, 1) + ctx:translate (-x, -y) + ctx:set_line_cap (Cairo.LineCap.Round) + + function drumstick (xp, lr) + ctx:set_line_width (r * .3) + ctx:move_to (x * xp, y) + ctx:close_path () + ctx:stroke () + ctx:set_line_width (r * .2) + ctx:move_to (x * xp, y) + ctx:rel_line_to (lr * x, y) + ctx:stroke () + end + drumstick (1.2, 1.2) + drumstick (0.7, -.5) +end end diff --git a/scripts/remove_unknown_procs.lua b/scripts/remove_unknown_procs.lua index 0461e88567..044e85b3b8 100644 --- a/scripts/remove_unknown_procs.lua +++ b/scripts/remove_unknown_procs.lua @@ -5,10 +5,11 @@ ardour { ["type"] = "EditorAction", name = "Remove Unknown Plugins", } function factory (params) return function () - -- iterate over all tracks and busses + -- iterate over all tracks and busses (aka routes) for route in Session:get_routes ():iter () do -- route is-a http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Route local i = 0; + -- we need to iterate one-by one, removing a processor invalidates the list repeat proc = route:nth_processor (i) -- proc is a http://manual.ardour.org/lua-scripting/class_reference/#ARDOUR:Processor @@ -21,3 +22,23 @@ function factory (params) return function () until proc:isnil () end end end + + +function icon (params) return function (ctx, width, height, fg) + local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil (math.min (width, height) * .5) .. "px") + txt:set_text ("Fx") + local tw, th = txt:get_pixel_size () + ctx:move_to (.5 * (width - tw), .5 * (height - th)) + txt:layout_cairo_path (ctx) + + ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) + ctx:set_line_width (3) + ctx:stroke_preserve () + + ctx:set_source_rgba (.8, .2, .2, 1) + ctx:set_line_width (2) + ctx:stroke_preserve () + + ctx:set_source_rgba (0, 0, 0, 1) + ctx:fill () +end end