improve ui

add track properties editor
This commit is contained in:
2023-05-30 23:58:36 +02:00
parent 28613c9214
commit 8d1f949280
33 changed files with 2777 additions and 3751 deletions

View File

@@ -12,6 +12,7 @@ use super::{
pub struct Keyframe {
pub value: f32,
pub offset: f32,
pub id: String,
pub interpolation: Option<InterpolationType>,
}

View File

@@ -25,16 +25,19 @@ fn interpolates_the_input() {
let keyframes1 = Keyframes {
values: vec![
Keyframe {
id: "1".to_string(),
value: 0.0,
offset: 0.0,
interpolation: None,
},
Keyframe {
id: "2".to_string(),
value: 100.0,
offset: 1.0,
interpolation: None,
},
Keyframe {
id: "3".to_string(),
value: 300.0,
offset: 3.0,
interpolation: None,
@@ -45,11 +48,13 @@ fn interpolates_the_input() {
let keyframes2 = Keyframes {
values: vec![
Keyframe {
id: "4".to_string(),
value: -100.0,
offset: 0.0,
interpolation: None,
},
Keyframe {
id: "5".to_string(),
value: 0.0,
offset: 1.0,
interpolation: None,
@@ -145,16 +150,19 @@ fn gets_value_at_frame() {
let keyframes = Keyframes {
values: vec![
Keyframe {
id: "1".to_string(),
value: 0.0,
offset: 0.0,
interpolation: None,
},
Keyframe {
id: "2".to_string(),
value: 100.0,
offset: 1.0,
interpolation: None,
},
Keyframe {
id: "3".to_string(),
value: 300.0,
offset: 3.0,
interpolation: None,

View File

@@ -3,6 +3,7 @@ use super::{
keyframe::{Keyframe, Keyframes},
};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
pub trait AnimatedValue<T> {
fn sort_keyframes(&mut self);
@@ -28,6 +29,7 @@ impl AnimatedFloat {
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: Uuid::new_v4().to_string(),
value: val,
offset: 0.0,
interpolation: None,
@@ -93,7 +95,7 @@ impl AnimatedValue<(f32, f32, f32)> for AnimatedFloatVec3 {
let z = self
.keyframes
.1
.2
.get_value_at_frame(curr_frame, animation_data, fps);
return (x, y, z);

View File

@@ -70,6 +70,7 @@ fn build_bg(offset: f32, paint: Paint, size: (i32, i32)) -> AnimatedRectEntity {
keyframes: Keyframes {
values: vec![
Keyframe {
id: "1".to_string(),
value: (size.0 * -1) as f32,
offset: 0.0,
interpolation: Some(InterpolationType::EasingFunction(
@@ -77,6 +78,7 @@ fn build_bg(offset: f32, paint: Paint, size: (i32, i32)) -> AnimatedRectEntity {
)),
},
Keyframe {
id: "2".to_string(),
value: 0.0,
offset: 5.0,
interpolation: None,
@@ -87,6 +89,7 @@ fn build_bg(offset: f32, paint: Paint, size: (i32, i32)) -> AnimatedRectEntity {
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: "3".to_string(),
value: 0.0,
offset: 0.0,
interpolation: None,
@@ -100,6 +103,7 @@ fn build_bg(offset: f32, paint: Paint, size: (i32, i32)) -> AnimatedRectEntity {
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: "4".to_string(),
interpolation: None,
value: size.0 as f32,
offset: 0.0,
@@ -109,6 +113,7 @@ fn build_bg(offset: f32, paint: Paint, size: (i32, i32)) -> AnimatedRectEntity {
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: "5".to_string(),
value: size.1 as f32,
offset: 0.0,
interpolation: None,
@@ -193,6 +198,7 @@ pub fn test_timeline_entities_at_frame(
keyframes: Keyframes {
values: vec![
Keyframe {
id: "1".to_string(),
value: 0.0,
offset: 0.0,
interpolation: Some(InterpolationType::Spring(
@@ -204,6 +210,7 @@ pub fn test_timeline_entities_at_frame(
)),
},
Keyframe {
id: "2".to_string(),
value: (size.0 / 2) as f32,
offset: 2.0,
interpolation: None,
@@ -214,6 +221,7 @@ pub fn test_timeline_entities_at_frame(
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: "3".to_string(),
value: (size.1 / 2) as f32,
offset: 0.0,
interpolation: None,
@@ -240,6 +248,7 @@ pub fn test_timeline_entities_at_frame(
keyframes: Keyframes {
values: vec![
Keyframe {
id: "5".to_string(),
value: 0.0,
offset: 0.0,
interpolation: Some(InterpolationType::Spring(
@@ -251,6 +260,8 @@ pub fn test_timeline_entities_at_frame(
)),
},
Keyframe {
id: "6".to_string(),
value: (size.0 / 2) as f32,
offset: 2.0,
interpolation: None,
@@ -261,6 +272,7 @@ pub fn test_timeline_entities_at_frame(
AnimatedFloat {
keyframes: Keyframes {
values: vec![Keyframe {
id: "7".to_string(),
value: ((size.1 / 2) as f32) + 80.0,
offset: 0.0,
interpolation: None,

View File

@@ -1,4 +1,5 @@
use font_kit::source::SystemSource;
use rayon::prelude::*;
#[tauri::command]
pub fn get_system_fonts() -> Option<Vec<String>> {
@@ -9,7 +10,7 @@ pub fn get_system_fonts() -> Option<Vec<String>> {
match found_fonts {
Ok(found_fonts) => {
let font_names: Vec<String> = found_fonts
.iter()
.par_iter()
.map(|f| f.load())
.filter(|f| f.is_ok())
.map(|f| f.unwrap())
@@ -24,6 +25,15 @@ pub fn get_system_fonts() -> Option<Vec<String>> {
}
}
#[tauri::command]
pub fn get_system_families() -> Option<Vec<String>> {
let source = SystemSource::new();
let found_families = source.all_families();
found_families.ok()
}
#[tauri::command]
pub fn get_system_font(font_name: String) -> Option<Vec<u8>> {
let source = SystemSource::new();

View File

@@ -3,7 +3,7 @@
use crate::{
animation::timeline::calculate_timeline_entities_at_frame,
fonts::{get_system_font, get_system_fonts},
fonts::{get_system_families, get_system_font, get_system_fonts},
};
pub mod animation;
@@ -14,6 +14,7 @@ fn main() {
.invoke_handler(tauri::generate_handler![
calculate_timeline_entities_at_frame,
get_system_font,
get_system_families,
get_system_fonts
])
.run(tauri::generate_context!())