From 1ab3d33df7b86cab5e168ae0a22f7c0de117141e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 18 Feb 2017 16:12:59 +0100 Subject: Some more EditorAction icons & color API update --- scripts/delete_xrun_markers.lua | 31 +++++++++++++++++++++++++++++++ scripts/preare_record_example.lua | 2 +- scripts/split_all_markers.lua | 8 ++++++-- scripts/tomsloop.lua | 39 +++++++++++++++++++++++++++++++++++++++ scripts/vamp_audio_to_midi.lua | 9 +++++++++ 5 files changed, 86 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/delete_xrun_markers.lua b/scripts/delete_xrun_markers.lua index 2530ec2a8e..5512e653b6 100644 --- a/scripts/delete_xrun_markers.lua +++ b/scripts/delete_xrun_markers.lua @@ -7,3 +7,34 @@ function factory () return function () end end end end + +function icon (params) return function (ctx, width, height, fg) + local mh = height - 3.5; + local m3 = width / 3; + local m6 = width / 6; + + ctx:set_line_width (.5) + + ctx:set_source_rgba (.8, .2, .2, 1.0) + ctx:move_to (width / 2 - m6, 2) + ctx:rel_line_to (m3, 0) + ctx:rel_line_to (0, mh * 0.4) + ctx:rel_line_to (-m6, mh * 0.6) + ctx:rel_line_to (-m6, -mh * 0.6) + ctx:close_path () + ctx:fill_preserve () + ctx:set_source_rgba (.0, .0, .0, 1.0) + ctx:stroke () + + ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) + ctx:set_line_width (1) + + ctx:move_to (width * .2, height * .2) + ctx:line_to (width * .8, height * .8) + ctx:stroke () + + ctx:move_to (width * .8, height * .2) + ctx:line_to (width * .2, height * .8) + ctx:stroke () + +end end diff --git a/scripts/preare_record_example.lua b/scripts/preare_record_example.lua index 92ee8847f3..48e063d326 100644 --- a/scripts/preare_record_example.lua +++ b/scripts/preare_record_example.lua @@ -67,7 +67,7 @@ function icon (params) return function (ctx, width, height) local r = math.min (x, y) * .55 ctx:arc (x, y, r, 0, 2 * math.pi) - ctx:set_source_rgba (9, .3, .3, 1.) + ctx:set_source_rgba (.9, .3, .3, 1.) ctx:fill_preserve () ctx:set_source_rgba (0, 0, 0, .8) ctx:set_line_width (1) diff --git a/scripts/split_all_markers.lua b/scripts/split_all_markers.lua index 64aeea7f5a..967743e56a 100644 --- a/scripts/split_all_markers.lua +++ b/scripts/split_all_markers.lua @@ -82,6 +82,8 @@ function icon (params) return function (ctx, width, height, fg) local m3 = width / 3; local m6 = width / 6; + ctx:set_line_width (.5) + -- compare to gtk2_ardour/marker.cc "Marker" ctx:set_source_rgba (.8, .8, .2, 1.0) ctx:move_to (width / 2 - m6, 2) @@ -90,10 +92,12 @@ function icon (params) return function (ctx, width, height, fg) ctx:rel_line_to (-m6, mh * 0.6) ctx:rel_line_to (-m6, -mh * 0.6) ctx:close_path () - ctx:fill () + ctx:fill_preserve () + ctx:set_source_rgba (.0, .0, .0, 1.0) + ctx:stroke () -- draw an arrow <--|--> on top, using the foreground color - ctx:set_source_rgba (LuaCairo.color_to_rgba (fg)) + ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) ctx:set_line_width (1) ctx:move_to (width * .5, height * .4) diff --git a/scripts/tomsloop.lua b/scripts/tomsloop.lua index 56fec4262f..6b643506d4 100644 --- a/scripts/tomsloop.lua +++ b/scripts/tomsloop.lua @@ -278,3 +278,42 @@ function factory (params) return function () ::errorout:: end -- end of anonymous action script function end -- end of script factory + + +function icon (params) return function (ctx, width, height) + local x = width * .5 + local y = height * .5 + local r = math.min (x, y) + + ctx:set_line_width (1) + + function stroke_outline () + ctx:set_source_rgba (0, 0, 0, 1) + ctx:stroke_preserve () + ctx:set_source_rgba (1, 1, 1, 1) + ctx:fill () + end + + ctx:rectangle (x - r * .6, y - r * .05, r * .6, r * .3) + stroke_outline () + + ctx:arc (x, y, r * .61, math.pi, 0.2 * math.pi) + ctx:arc_negative (x, y, r * .35, 0.2 * math.pi, math.pi); + stroke_outline () + + function arc_arrow (rad, ang) + return x - rad * math.sin (ang * 2.0 * math.pi), y - rad * math.cos (ang * 2.0 * math.pi) + end + + ctx:move_to (arc_arrow (r * .36, .72)) + ctx:line_to (arc_arrow (r * .17, .72)) + ctx:line_to (arc_arrow (r * .56, .60)) + ctx:line_to (arc_arrow (r * .75, .72)) + ctx:line_to (arc_arrow (r * .62, .72)) + + ctx:set_source_rgba (0, 0, 0, 1) + ctx:stroke_preserve () + ctx:close_path () + ctx:set_source_rgba (1, 1, 1, 1) + ctx:fill () +end end diff --git a/scripts/vamp_audio_to_midi.lua b/scripts/vamp_audio_to_midi.lua index 79fc32ac83..5792e8f115 100644 --- a/scripts/vamp_audio_to_midi.lua +++ b/scripts/vamp_audio_to_midi.lua @@ -68,3 +68,12 @@ function factory () return function () end end end end + +function icon (params) return function (ctx, width, height, fg) + local txt = Cairo.PangoLayout (ctx, "ArdourMono ".. math.ceil(width * .7) .. "px") + txt:set_text ("\u{2669}") -- quarter note symbol UTF8 + local tw, th = txt:get_pixel_size () + ctx:set_source_rgba (ARDOUR.LuaAPI.color_to_rgba (fg)) + ctx:move_to (.5 * (width - tw), .5 * (height - th)) + txt:show_in_cairo_context (ctx) +end end -- cgit v1.2.3