add automation flatten function

Implements #4756.
This commit is contained in:
Alexandros Theodotou 2023-12-15 18:34:58 +09:00
parent 85c14719d2
commit 9d84dba007
No known key found for this signature in database
GPG Key ID: 022EAE42313D70F3
7 changed files with 108 additions and 8 deletions

View File

@ -209,6 +209,14 @@ Comment:
The files have been slightly modified.
From https://github.com/microsoft/fluentui-system-icons.
Files:
resources/icons/iconpark/*.svg
Copyright: IconPark contributors <https://github.com/bytedance/IconPark>
License: Apache-2.0
Comment:
The files have been slightly modified.
From https://iconpark.oceanengine.com/official.
Files: resources/icons/font-awesome/*.svg
Copyright: Font Awesome project
License: CC-BY-4.0

View File

@ -28,17 +28,19 @@ typedef enum AutomationFunctionType
{
AUTOMATION_FUNCTION_FLIP_HORIZONTAL,
AUTOMATION_FUNCTION_FLIP_VERTICAL,
AUTOMATION_FUNCTION_FLATTEN,
} AutomationFunctionType;
static const cyaml_strval_t automation_function_type_strings[] = {
{N_ ("Flip H"), AUTOMATION_FUNCTION_FLIP_HORIZONTAL},
{ N_ ("Flip V"), AUTOMATION_FUNCTION_FLIP_VERTICAL },
static const char * automation_function_type_strings[] = {
N_ ("Flip H"),
N_ ("Flip V"),
N_ ("Flatten"),
};
static inline const char *
automation_function_type_to_string (AutomationFunctionType type)
{
return automation_function_type_strings[type].str;
return automation_function_type_strings[type];
}
/**

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
width="24"
height="24"
viewBox="0 0 48 48"
fill="none"
version="1.1"
id="svg4"
sodipodi:docname="figma-flatten-selection.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25, custom)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs4" />
<sodipodi:namedview
id="namedview4"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="33.666667"
inkscape:cx="11.985149"
inkscape:cy="12"
inkscape:window-width="2560"
inkscape:window-height="1023"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg4" />
<path
d="M32 18L24 26L16 18"
stroke="#333"
stroke-width="4"
stroke-linecap="round"
stroke-linejoin="round"
id="path1"
style="stroke:#f2f2f2" />
<path
d="M36 42H12"
stroke="#333"
stroke-width="4"
stroke-linecap="round"
stroke-linejoin="round"
id="path2"
style="stroke:#f2f2f2" />
<path
d="M42 34H6"
stroke="#333"
stroke-width="4"
stroke-linecap="round"
stroke-linejoin="round"
id="path3"
style="stroke:#f2f2f2" />
<path
d="M24 6V26"
stroke="#333"
stroke-width="4"
stroke-linecap="round"
stroke-linejoin="round"
id="path4"
style="stroke:#f2f2f2" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -205,6 +205,12 @@
</menu>
<menu id="automation_functions_menu">
<section>
<item>
<attribute name="label" translatable="yes">Flatten</attribute>
<attribute name="action">editor-toolbar.editor-function</attribute>
<attribute name="target">flatten</attribute>
<attribute name="icon">iconpark-figma-flatten-selection</attribute>
</item>
<submenu>
<attribute name="label" translatable="yes">Flip</attribute>
<item>

View File

@ -120,7 +120,7 @@ Args:
(string-suffix? ".png" f))))))
'("arena" "gnome-builder" "gnome-icon-library" "ext"
"fork-awesome" "font-awesome"
"fluentui" "jam-icons" "box-icons"))
"fluentui" "jam-icons" "box-icons" "iconpark"))
;; insert standard gtk menus
;; (see GtkApplication docs)

View File

@ -2531,6 +2531,10 @@ DEFINE_SIMPLE (activate_editor_function)
{
do_automation_func (AUTOMATION_FUNCTION_FLIP_VERTICAL);
}
else if (string_is_equal (str, "flatten"))
{
do_automation_func (AUTOMATION_FUNCTION_FLATTEN);
}
else
{
g_return_if_reached ();

View File

@ -1,7 +1,5 @@
// SPDX-FileCopyrightText: © 2020 Alexandros Theodotou <alex@zrythm.org>
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
/*
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org>
*/
#include "dsp/automation_function.h"
#include "dsp/engine.h"
@ -33,6 +31,18 @@ flip (AutomationSelections * sel, bool vertical)
}
}
static void
flatten (AutomationSelections * sel)
{
for (int i = 0; i < sel->num_automation_points; i++)
{
AutomationPoint * ap = sel->automation_points[i];
ap->curve_opts.curviness = 1.0;
ap->curve_opts.algo = CURVE_ALGORITHM_PULSE;
}
}
/**
* Applies the given action to the given selections.
*
@ -55,6 +65,9 @@ automation_function_apply (
case AUTOMATION_FUNCTION_FLIP_VERTICAL:
flip ((AutomationSelections *) sel, true);
break;
case AUTOMATION_FUNCTION_FLATTEN:
flatten ((AutomationSelections *) sel);
break;
}
/* set last action */