Shapes: edit gradient color and opacity stops (#612)

The Timeline's "Edit Gradient…" on a gradient property (Gradient Fill /
Gradient Stroke ▸ Colors, Gradient Overlay) only painted its label. It now
opens a Gradient Editor (prop.editGradient): opacity stops above a preview
bar and colour stops below. Click to add a stop (it takes that track's
own value there), drag or type a Location to move it, set its opacity or
colour (egui's colour picker), Delete removes it (never the last of a
track, never while typing). The tracks stay in order while editing and the
selection follows its stop.

The editor works on a draft. OK sets the property once with prop.set at
the composition time it opened, snapped to the frame, with
timeBase: "comp" (offset and stretched layers get the key where it was
opened): one undo step, and nothing at all when the draft is unchanged, so
OK adds no keyframe. Cancel and Escape change nothing; Escape with the
picker open closes only the picker. On an animated gradient only the
keyframe at that time changes; when its stop counts no longer match a
neighbouring keyframe's (gradients only blend with equal counts) the
editor says so. The draft is saved in the typed form, so one colour stop
and each stop's RGBA survive.

prop.editGradient checks its target is a gradient property before the UI
opens anything, so agents get an error for a wrong one. New Gradient
color_at / opacity_at sample one track each (sample() multiplies opacity
in, which would apply it twice to a new stop).

Tests: ui_gradient_value (fails on main: the value had no automation id),
ui_gradient_editor (11), gradient_editor and keyframe unit tests.
This commit is contained in:
tylerjenningsw
2026-10-10 22:22:13 -04:00
parent 9a7d3e7699
commit ec1bc8cc99
13 changed files with 1133 additions and 3 deletions
+26
View File
@@ -145,6 +145,10 @@ const JAPANESE: &[(&str, &str)] = &[
("Clear", "消去"),
("Clear list", "リストを消去"),
("Click a key to see its commands.", "キーをクリックすると、割り当てられたコマンドが表示されます。"),
(
"Click above the bar to add an opacity stop, below it to add a color stop.",
"バーの上をクリックすると不透明度の分岐点、下をクリックするとカラーの分岐点を追加します。",
),
("Click adds a point (½ height = no change)", "クリックでポイントを追加(高さの½=変化なし)"),
("Click adds a point; drag one off to remove", "クリックでポイントを追加、外へドラッグで削除"),
("Click to make this viewer active", "クリックしてこのビューアーをアクティブ化"),
@@ -238,6 +242,7 @@ const JAPANESE: &[(&str, &str)] = &[
("Frame Render Time {}ms", "フレームのレンダリング時間 {}ms"),
("Frame Target:", "フレームターゲット:"),
("Grab bag", "いろいろ"),
("Gradient Editor", "グラデーションエディター"),
("Grid", "グリッド"),
("Guide Layers: {}", "ガイドレイヤー:{}"),
("Guides", "ガイド"),
@@ -274,6 +279,7 @@ const JAPANESE: &[(&str, &str)] = &[
("Light Type", "ライトの種類"),
("Lighter", "明るく"),
("Link Selected Property", "選択したプロパティをリンク"),
("Location:", "位置:"),
("Lock Aspect Ratio to {}", "アスペクト比を{}に固定"),
("Lock to Zoom", "ズームにロック"),
("Locked: {} — {}", "ロック済み:{} — {}"),
@@ -461,6 +467,7 @@ const JAPANESE: &[(&str, &str)] = &[
("The Media Browser is not available here (use File ▸ Import)", "ここではメディアブラウザーを使用できません(「ファイル ▸ 読み込み」を使ってください)"),
("The OpenEXR layer shown in red, green, blue and alpha", "赤・緑・青・アルファとして表示するOpenEXRレイヤー"),
("The render queue is empty.", "レンダーキューは空です。"),
("These adjacent keyframes cannot interpolate because their stop counts differ.", "これらの隣接するキーフレームは分岐点の数が異なるため、補間できません。"),
("This ScriptUI panel has closed", "このScriptUIパネルは閉じられました"),
("This change will create a new solid for this layer.", "この変更により、このレイヤー用に新しい平面が作成されます。"),
("Time", "時間"),
@@ -577,6 +584,7 @@ const SIMPLIFIED_CHINESE: &[(&str, &str)] = &[
("Clear", "清除"),
("Clear list", "清空列表"),
("Click a key to see its commands.", "单击某个按键以查看其命令。"),
("Click above the bar to add an opacity stop, below it to add a color stop.", "点击渐变条上方添加不透明度色标,点击下方添加颜色色标。"),
("Click adds a point (½ height = no change)", "单击可添加点(上下滑动高度的一半 = 无变化)"),
("Click adds a point; drag one off to remove", "单击可添加点;拖出一个即可删除"),
("Click to make this viewer active", "单击可激活此视图"),
@@ -673,6 +681,7 @@ const SIMPLIFIED_CHINESE: &[(&str, &str)] = &[
("Frame Target:", "帧目标:"),
("Freeze", "冻结"),
("Grab bag", "列表"),
("Gradient Editor", "渐变编辑器"),
("Grid", "网格"),
("Guide Layers: {}", "参考图层:{}"),
("Guides", "参考线"),
@@ -711,6 +720,7 @@ const SIMPLIFIED_CHINESE: &[(&str, &str)] = &[
("Light Type", "灯光类型"),
("Lighter", "更浅"),
("Link Selected Property", "链接所选属性"),
("Location:", "位置:"),
("Lock Aspect Ratio to {}", "锁定长宽比为 {}"),
("Lock to Zoom", "锁定缩放"),
("Locked: {} — {}", "已锁定:{} — {}"),
@@ -899,6 +909,7 @@ const SIMPLIFIED_CHINESE: &[(&str, &str)] = &[
("The Media Browser is not available here (use File ▸ Import)", "此处不支持媒体浏览器(请使用 文件 ▸ 导入)"),
("The OpenEXR layer shown in red, green, blue and alpha", "以红、绿、蓝和 Alpha 显示的 OpenEXR 图层"),
("The render queue is empty.", "渲染队列为空。"),
("These adjacent keyframes cannot interpolate because their stop counts differ.", "这些相邻关键帧的色标数量不同,无法插值。"),
("This ScriptUI panel has closed", "此 ScriptUI 面板已关闭"),
("This change will create a new solid for this layer.", "此更改将为该图层创建新的纯色。"),
("Time", "时间"),
@@ -1102,6 +1113,7 @@ const TRADITIONAL_CHINESE: &[(&str, &str)] = &[
("Clear", "清除"),
("Clear list", "清空清單"),
("Click a key to see its commands.", "按一下某個按鍵以查看其命令。"),
("Click above the bar to add an opacity stop, below it to add a color stop.", "按一下漸變條上方以新增不透明度色標,按一下下方以新增顏色色標。"),
("Click adds a point (½ height = no change)", "按一下可添加點(上下滑動高度的一半 = 無變化)"),
("Click adds a point; drag one off to remove", "按一下可添加點;拖出一個即可刪除"),
("Click to make this viewer active", "按一下可激活此檢視"),
@@ -1198,6 +1210,7 @@ const TRADITIONAL_CHINESE: &[(&str, &str)] = &[
("Frame Target:", "幀目標:"),
("Freeze", "凍結"),
("Grab bag", "清單"),
("Gradient Editor", "漸變編輯器"),
("Grid", "格點"),
("Guide Layers: {}", "參考圖層:{}"),
("Guides", "參考線"),
@@ -1236,6 +1249,7 @@ const TRADITIONAL_CHINESE: &[(&str, &str)] = &[
("Light Type", "燈光類型"),
("Lighter", "更淺"),
("Link Selected Property", "鏈接所選屬性"),
("Location:", "位置:"),
("Lock Aspect Ratio to {}", "鎖定長寬比例為 {}"),
("Lock to Zoom", "鎖定縮放"),
("Locked: {} — {}", "已鎖定:{} — {}"),
@@ -1424,6 +1438,7 @@ const TRADITIONAL_CHINESE: &[(&str, &str)] = &[
("The Media Browser is not available here (use File ▸ Import)", "此處不支援媒體瀏覽器(請使用 文件 ▸ 匯入)"),
("The OpenEXR layer shown in red, green, blue and alpha", "以紅、綠、藍和 Alpha 顯示的 OpenEXR 圖層"),
("The render queue is empty.", "算圖佇列為空。"),
("These adjacent keyframes cannot interpolate because their stop counts differ.", "這些相鄰關鍵影格的色標數量不同,無法內插。"),
("This ScriptUI panel has closed", "此 ScriptUI 面板已關閉"),
("This change will create a new solid for this layer.", "此更改將為該圖層創建新的純色。"),
("Time", "時間"),
@@ -1622,6 +1637,10 @@ const UKRAINIAN: &[(&str, &str)] = &[
("Clear", "Очистити"),
("Clear list", "Очистити список"),
("Click a key to see its commands.", "Клацніть клавішу, щоб переглянути її команди."),
(
"Click above the bar to add an opacity stop, below it to add a color stop.",
"Клацніть над смугою, щоб додати точку непрозорості, під нею — щоб додати точку кольору.",
),
("Click adds a point (½ height = no change)", "Клацніть, щоб додати точку (½ висоти = без змін)"),
("Click adds a point; drag one off to remove", "Клацніть, щоб додати точку; перетягніть її за межі, щоб вилучити"),
("Click to make this viewer active", "Клацніть, щоб зробити цю область перегляду активною"),
@@ -1715,6 +1734,7 @@ const UKRAINIAN: &[(&str, &str)] = &[
("Frame Render Time {}ms", "Час рендерингу кадру {} мс"),
("Frame Target:", "Цільовий фрейм:"),
("Grab bag", "Список"),
("Gradient Editor", "Редактор градієнта"),
("Grid", "Сітка"),
("Guide Layers: {}", "Допоміжні шари: {}"),
("Guides", "Напрямні"),
@@ -1751,6 +1771,7 @@ const UKRAINIAN: &[(&str, &str)] = &[
("Light Type", "Тип світла"),
("Lighter", "Світліше"),
("Link Selected Property", "Зв’язати виділену властивість"),
("Location:", "Розташування:"),
("Lock Aspect Ratio to {}", "Зафіксувати співвідношення сторін на {}"),
("Lock to Zoom", "Прив’язати до масштабу"),
("Locked: {} — {}", "Заблоковано: {} — {}"),
@@ -1941,6 +1962,10 @@ const UKRAINIAN: &[(&str, &str)] = &[
("The Media Browser is not available here (use File ▸ Import)", "Браузер матеріалів тут недоступний (скористайтеся меню «Файл ▸ Імпорт»)"),
("The OpenEXR layer shown in red, green, blue and alpha", "Шар OpenEXR, показаний у червоному, зеленому, синьому та альфа-каналі"),
("The render queue is empty.", "Черга рендерингу порожня."),
(
"These adjacent keyframes cannot interpolate because their stop counts differ.",
"Ці сусідні ключові кадри не можуть інтерполюватися, бо кількість точок у них різна.",
),
("This ScriptUI panel has closed", "Цю панель ScriptUI закрито"),
("This change will create a new solid for this layer.", "Ця зміна створить новий матеріал суцільного кольору для цього шару."),
("Time", "Час"),
@@ -2007,6 +2032,7 @@ mod tests {
("panels/comp_settings.rs", include_str!("../panels/comp_settings.rs")),
("panels/content_fill_panel.rs", include_str!("../panels/content_fill_panel.rs")),
("panels/delete_items.rs", include_str!("../panels/delete_items.rs")),
("panels/gradient_editor.rs", include_str!("../panels/gradient_editor.rs")),
("panels/dialogs.rs", include_str!("../panels/dialogs.rs")),
("panels/dialogs_3d.rs", include_str!("../panels/dialogs_3d.rs")),
("panels/effect_controls.rs", include_str!("../panels/effect_controls.rs")),