deps: Replace cosmic-time with keyframe

This commit is contained in:
Victoria Brekenfeld 2023-07-11 17:12:56 +02:00
parent a683b7cd63
commit 4ee5aaf741
6 changed files with 66 additions and 80 deletions

View file

@ -37,7 +37,7 @@ use crate::{
};
use cosmic_protocols::screencopy::v1::server::zcosmic_screencopy_session_v1::FailureReason;
use cosmic_time::{Cubic, Ease, Tween};
use keyframe::{ease, functions::EaseInOutCubic};
use smithay::{
backend::{
allocator::dmabuf::Dmabuf,
@ -517,7 +517,7 @@ where
let percentage = {
let percentage = Instant::now().duration_since(*start).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32;
Ease::Cubic(Cubic::InOut).tween(percentage)
ease(EaseInOutCubic, 0.0, 1.0, percentage)
};
let offset = Point::<i32, Logical>::from(match (layout, *previous_idx < current.1) {
(WorkspaceLayout::Vertical, true) => {

View file

@ -26,7 +26,10 @@ use cosmic::{
theme,
widget::{icon, Icon},
};
use cosmic_time::{Cubic, Ease, Tween};
use keyframe::{
ease,
functions::{EaseInOutCubic, EaseOutCubic},
};
use std::{
collections::{HashMap, HashSet, VecDeque},
time::{Duration, Instant},
@ -246,13 +249,12 @@ impl State {
pub fn offset(&self, bounds: Rectangle, content_bounds: Size) -> Vector {
if let Some(animation) = self.scroll_animation {
let percentage = {
let percentage = (Instant::now()
let percentage = Instant::now()
.duration_since(animation.start_time)
.as_millis() as f32
/ SCROLL_ANIMATION_DURATION.as_millis() as f32)
.min(1.0);
/ SCROLL_ANIMATION_DURATION.as_millis() as f32;
Ease::Cubic(Cubic::InOut).tween(percentage)
ease(EaseInOutCubic, 0.0, 1.0, percentage)
};
Vector::new(
@ -528,12 +530,11 @@ where
renderer.with_layer(bounds, |renderer| {
renderer.with_translation(Vector::new(-offset.x, -offset.y), |renderer| {
let percentage = if let Some(animation) = state.tab_animations.front() {
let percentage = (Instant::now()
let percentage = Instant::now()
.duration_since(animation.start_time)
.as_millis() as f32
/ TAB_ANIMATION_DURATION.as_millis() as f32)
.min(1.0);
Ease::Cubic(Cubic::Out).tween(percentage)
/ TAB_ANIMATION_DURATION.as_millis() as f32;
ease(EaseOutCubic, 0.0, 1.0, percentage)
} else {
1.0
};

View file

@ -23,8 +23,8 @@ use crate::{
},
};
use cosmic_time::{Cubic, Ease, Tween};
use id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBehavior, Tree};
use keyframe::{ease, functions::EaseInOutCubic};
use smithay::{
backend::renderer::{
element::{
@ -2006,10 +2006,9 @@ impl TilingLayout {
.then(|| &queue.trees.front().unwrap().0);
let percentage = if let Some(animation_start) = queue.animation_start {
let percentage = (Instant::now().duration_since(animation_start).as_millis() as f32
/ duration.as_millis() as f32)
.min(1.0);
Ease::Cubic(Cubic::Out).tween(percentage)
let percentage = Instant::now().duration_since(animation_start).as_millis() as f32
/ duration.as_millis() as f32;
ease(EaseInOutCubic, 0.0, 1.0, percentage)
} else {
1.0
};

View file

@ -10,7 +10,7 @@ use tracing::warn;
use wayland_backend::server::ClientId;
use cosmic_protocols::workspace::v1::server::zcosmic_workspace_handle_v1::State as WState;
use cosmic_time::{Cubic, Ease, Tween};
use keyframe::{ease, functions::EaseInOutCubic};
use smithay::{
desktop::{
layer_map_for_output, space::SpaceElement, LayerSurface, PopupManager, WindowSurfaceType,
@ -81,18 +81,15 @@ impl OverviewMode {
pub fn alpha(&self) -> Option<f32> {
match self {
OverviewMode::Started(_, start) => {
let percentage = (Instant::now().duration_since(*start).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32)
.min(1.0);
Some(Ease::Cubic(Cubic::Out).tween(percentage))
let percentage = Instant::now().duration_since(*start).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32;
Some(ease(EaseInOutCubic, 0.0, 1.0, percentage))
}
OverviewMode::Ended(end) => {
let percentage = (1.0
- Instant::now().duration_since(*end).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32)
.max(0.0);
if percentage > 0.0 {
Some(Ease::Cubic(Cubic::Out).tween(percentage))
let percentage = Instant::now().duration_since(*end).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32;
if percentage < 1.0 {
Some(ease(EaseInOutCubic, 1.0, 0.0, percentage))
} else {
None
}
@ -119,18 +116,15 @@ impl ResizeMode {
pub fn alpha(&self) -> Option<f32> {
match self {
ResizeMode::Started(_, start, _) => {
let percentage = (Instant::now().duration_since(*start).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32)
.min(1.0);
Some(Ease::Cubic(Cubic::Out).tween(percentage))
let percentage = Instant::now().duration_since(*start).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32;
Some(ease(EaseInOutCubic, 0.0, 1.0, percentage))
}
ResizeMode::Ended(end, _) => {
let percentage = (1.0
- Instant::now().duration_since(*end).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32)
.max(0.0);
if percentage > 0.0 {
Some(Ease::Cubic(Cubic::Out).tween(percentage))
let percentage = Instant::now().duration_since(*end).as_millis() as f32
/ ANIMATION_DURATION.as_millis() as f32;
if percentage < 1.0 {
Some(ease(EaseInOutCubic, 1.0, 0.0, percentage))
} else {
None
}