Gap 21: percentage guides and effect colour labels (#1095)

Guides can store a percent of the comp so they follow comp-size changes
(View > Add Percentage Guide, Convert Guides to Percentage / Pixels); an
effect instance has an optional colour label (effect.setLabel, Effect Controls
header bar and Label menu). Both are serde-defaulted, so old projects load.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-12 21:07:36 +02:00
co-authored by Claude Sonnet 5.5
parent 470ea7a3af
commit f11792827e
20 changed files with 301 additions and 25 deletions
+9 -1
View File
@@ -487,7 +487,15 @@ fn build_group(project: &Project, comp: ItemId, eg: &EssentialGraphics, old: Opt
}
}
}
PropGroup { uid, match_id: GROUP.into(), name: "Essential Properties".into(), kind: GroupKind::Essential { overridden: keep }, enabled: true, children }
PropGroup {
uid,
match_id: GROUP.into(),
name: "Essential Properties".into(),
kind: GroupKind::Essential { overridden: keep },
enabled: true,
label: None,
children,
}
}
fn find_prop<'a>(nodes: &'a [Node], m: &str) -> Option<&'a Property> {
+30
View File
@@ -467,7 +467,37 @@ pub struct Comp {
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub struct Guide {
pub vertical: bool,
/// Comp pixels, or percent of the comp's width (vertical) / height (horizontal) when
/// [`Guide::percent`] is set.
pub position: f64,
/// A percentage guide (After Effects 26.5): `position` is a percent of the comp's size, so the
/// guide keeps its relative place when the comp is resized. Absent in older projects.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub percent: bool,
}
impl Guide {
/// The comp's extent along this guide's axis, never zero.
fn extent(&self, width: u32, height: u32) -> f64 {
f64::from(if self.vertical { width } else { height }).max(1.0)
}
/// The guide's position in comp pixels for a comp of this size.
pub fn px(&self, width: u32, height: u32) -> f64 {
if self.percent { self.position / 100.0 * self.extent(width, height) } else { self.position }
}
/// Place the guide at `px` comp pixels, keeping its unit.
pub fn set_px(&mut self, px: f64, width: u32, height: u32) {
self.position = if self.percent { px / self.extent(width, height) * 100.0 } else { px };
}
/// Switch between pixels and percent without moving the guide on the comp.
pub fn set_percent(&mut self, percent: bool, width: u32, height: u32) {
let px = self.px(width, height);
self.percent = percent;
self.set_px(px, width, height);
}
}
fn yes() -> bool {
+5 -1
View File
@@ -255,6 +255,10 @@ pub struct PropGroup {
/// fx switch for effects, eye for shape groups, etc.
#[serde(default = "yes")]
pub enabled: bool,
/// An effect's colour label (After Effects 26.5), shown in Effect Controls and the Timeline;
/// `None` is unlabelled. Absent in older projects.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub label: Option<effectcraft_color::Label>,
#[serde(default)]
pub children: Vec<Node>,
}
@@ -338,7 +342,7 @@ pub fn parse_path(s: &str) -> Vec<Seg> {
impl PropGroup {
pub fn new(uid: Uid, match_id: &str, name: &str) -> PropGroup {
PropGroup { uid, match_id: match_id.into(), name: name.into(), kind: GroupKind::Plain, enabled: true, children: vec![] }
PropGroup { uid, match_id: match_id.into(), name: name.into(), kind: GroupKind::Plain, enabled: true, label: None, children: vec![] }
}
pub fn with(mut self, n: impl Into<Node>) -> PropGroup {
self.children.push(n.into());