mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-24 01:28:39 +02:00
feat(animation): introduce AnimationPrefix enum
This commit is contained in:
@@ -12,6 +12,7 @@ pub mod animation;
|
|||||||
pub use animation::Animation;
|
pub use animation::Animation;
|
||||||
pub mod animation_manager;
|
pub mod animation_manager;
|
||||||
pub mod lerp;
|
pub mod lerp;
|
||||||
|
pub mod prefix;
|
||||||
pub mod style;
|
pub mod style;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
|
|||||||
19
komorebi/src/animation/prefix.rs
Normal file
19
komorebi/src/animation/prefix.rs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
use clap::ValueEnum;
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use serde::Deserialize;
|
||||||
|
use serde::Serialize;
|
||||||
|
use strum::Display;
|
||||||
|
use strum::EnumString;
|
||||||
|
|
||||||
|
#[derive(
|
||||||
|
Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, JsonSchema,
|
||||||
|
)]
|
||||||
|
pub enum AnimationPrefix {
|
||||||
|
WindowMove,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_animation_key(prefix: AnimationPrefix, key: String) -> String {
|
||||||
|
match prefix {
|
||||||
|
AnimationPrefix::WindowMove => format!("window_move:{}", key),
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
use crate::animation::lerp::Lerp;
|
use crate::animation::lerp::Lerp;
|
||||||
|
use crate::animation::prefix::new_animation_key;
|
||||||
|
use crate::animation::prefix::AnimationPrefix;
|
||||||
use crate::animation::ANIMATION_DURATION;
|
use crate::animation::ANIMATION_DURATION;
|
||||||
use crate::animation::ANIMATION_ENABLED;
|
use crate::animation::ANIMATION_ENABLED;
|
||||||
use crate::animation::ANIMATION_MANAGER;
|
use crate::animation::ANIMATION_MANAGER;
|
||||||
@@ -212,7 +214,7 @@ impl Window {
|
|||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
Animation::animate(
|
Animation::animate(
|
||||||
format!("window_move:{}", hwnd).as_str(),
|
new_animation_key(AnimationPrefix::WindowMove, hwnd.to_string()).as_str(),
|
||||||
duration,
|
duration,
|
||||||
|progress: f64| {
|
|progress: f64| {
|
||||||
let new_rect = start_rect.lerp(target_rect, progress, style);
|
let new_rect = start_rect.lerp(target_rect, progress, style);
|
||||||
|
|||||||
Reference in New Issue
Block a user