Angles: the revolutions ("0x") scrub and take typing (#93)
An angle's revolutions were painted text: only the degrees could be dragged or typed, so full turns needed the dial or typing past 360. fx_widgets::angle_field draws `0x+45.0°` as two hot numbers: the revolutions (widgets::hot_int_at, ten pixels a turn, fractions adding up between frames so slow drags still step; a typed value is truncated) and the degrees, each keeping the other. Effect Controls, the Timeline and the Properties panel use it, so they read and edit angles alike (the Timeline showed `-1x-40.0°` and Properties had its own split). Automation ids: timeline.prop.<uid>.revolutions, effectControls.prop.<uid>.revolutions, properties.prop.<uid>.revolutions. Regression test: angle_revolutions_scrub_and_take_typing drags and types the revolutions in all three panels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
1a9288f83c
commit
27b0eec216
@@ -2,7 +2,7 @@
|
||||
//! like After Effects' Properties panel. Sections appear by layer type:
|
||||
//!
|
||||
//! - **Layer Transform** (all layers but cameras/lights): keyframe navigator (◀ ◆ ▶) or
|
||||
//! stopwatch, scrubbable values, linked Scale, `Nx+N°` Rotation, Reset.
|
||||
//! stopwatch, scrubbable values, linked Scale, `Nx+N°` Rotation (revolutions and degrees scrub on their own), Reset.
|
||||
//! - **Text** (text layers): font family/style, size, leading, tracking, stroke width, fill and
|
||||
//! stroke with enable checkboxes; "More" opens the Character panel.
|
||||
//! - **Paragraph** (text layers): the seven alignment buttons; "More" opens the Paragraph panel.
|
||||
@@ -50,12 +50,6 @@ fn decimals(v: f64) -> usize {
|
||||
if (v - v.round()).abs() < 1e-6 { 0 } else { 1 }
|
||||
}
|
||||
|
||||
/// Rotation as AE shows it: revolutions and remaining degrees (`1x+30°`, `-0x-45°`).
|
||||
pub fn split_rotation(deg: f64) -> (i64, f64) {
|
||||
let rev = (deg / 360.0).trunc();
|
||||
(rev as i64, deg - rev * 360.0)
|
||||
}
|
||||
|
||||
pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
|
||||
let t = app.tokens;
|
||||
let p = ui.painter().with_clip_rect(rect);
|
||||
@@ -259,15 +253,12 @@ fn transform_row(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter,
|
||||
let suffix = if pct { "%" } else { "" };
|
||||
match &value {
|
||||
Value::Scalar(v) if pr.name == "Rotation" || pr.name.ends_with(" Rotation") => {
|
||||
let (rev, deg) = split_rotation(*v);
|
||||
let g = p.layout_no_wrap(format!("{rev}x{}", if deg < 0.0 { "" } else { "+" }), Tokens::ui(12.0), t.hot_text);
|
||||
let gw = g.size().x;
|
||||
p.galley(pos2(vx + 2.0, cy - g.size().y / 2.0), g, t.hot_text);
|
||||
let (vr, nv, _) =
|
||||
widgets::hot_number_at(ui, pos2(vx + gw, cy - 9.0), egui::Id::new(("props-v", uid)), deg, 0.5, (-1e9, 1e9), decimals(deg), "°", &t);
|
||||
app.auto.add(&format!("{base}.value"), vr, &pr.name);
|
||||
let (_, deg) = super::fx_widgets::split_angle(*v);
|
||||
let (rr, dr, nv) = super::fx_widgets::angle_field(ui, pos2(vx, cy - 9.0), egui::Id::new(("props-v", uid)), *v, decimals(deg), &t);
|
||||
app.auto.add(&format!("{base}.value"), dr, &pr.name);
|
||||
app.auto.add(&format!("{base}.revolutions"), rr, &pr.name);
|
||||
if let Some(nv) = nv {
|
||||
set(actions, json!(rev as f64 * 360.0 + nv));
|
||||
set(actions, json!(nv));
|
||||
}
|
||||
}
|
||||
Value::Scalar(v) => {
|
||||
@@ -515,14 +506,6 @@ fn more_button(app: &mut EffectcraftApp, ui: &mut egui::Ui, p: &egui::Painter, x
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rotation_splits_like_ae() {
|
||||
assert_eq!(split_rotation(0.0), (0, 0.0));
|
||||
assert_eq!(split_rotation(390.0), (1, 30.0));
|
||||
assert_eq!(split_rotation(-45.0), (0, -45.0));
|
||||
assert_eq!(split_rotation(-725.0), (-2, -5.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn decimals_hide_whole_numbers() {
|
||||
assert_eq!(decimals(960.0), 0);
|
||||
|
||||
Reference in New Issue
Block a user