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

69
Cargo.lock generated
View file

@ -482,7 +482,6 @@ dependencies = [
"bytemuck", "bytemuck",
"calloop", "calloop",
"cosmic-protocols", "cosmic-protocols",
"cosmic-time",
"edid-rs", "edid-rs",
"egui", "egui",
"glow 0.11.2", "glow 0.11.2",
@ -491,6 +490,7 @@ dependencies = [
"iced_tiny_skia", "iced_tiny_skia",
"id_tree", "id_tree",
"indexmap 1.9.3", "indexmap 1.9.3",
"keyframe",
"lazy_static", "lazy_static",
"libcosmic", "libcosmic",
"libsystemd", "libsystemd",
@ -524,7 +524,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config" name = "cosmic-config"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -538,7 +538,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config-derive" name = "cosmic-config-derive"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"quote", "quote",
"syn 1.0.109", "syn 1.0.109",
@ -578,7 +578,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-theme" name = "cosmic-theme"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"cosmic-config", "cosmic-config",
@ -590,14 +590,6 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "cosmic-time"
version = "0.2.0"
source = "git+https://github.com/pop-os/cosmic-time?rev=39c96ac#39c96ac8b3c11aeb5a4fe8bc962a89013f3f27b7"
dependencies = [
"libcosmic",
]
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.8" version = "0.2.8"
@ -1761,7 +1753,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"iced_futures", "iced_futures",
@ -1774,7 +1766,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.9.0" version = "0.9.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"instant", "instant",
@ -1787,12 +1779,11 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.6.0" version = "0.6.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
"log", "log",
"tokio",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"wasm-timer", "wasm-timer",
] ]
@ -1800,7 +1791,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -1817,7 +1808,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -1829,7 +1820,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"iced_futures", "iced_futures",
@ -1839,7 +1830,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_style" name = "iced_style"
version = "0.8.0" version = "0.8.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"once_cell", "once_cell",
@ -1849,7 +1840,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -1867,7 +1858,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.10.0" version = "0.10.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"bytemuck", "bytemuck",
@ -1888,7 +1879,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"iced_renderer", "iced_renderer",
"iced_runtime", "iced_runtime",
@ -2097,6 +2088,16 @@ dependencies = [
"mutate_once", "mutate_once",
] ]
[[package]]
name = "keyframe"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "60708bf7981518d09095d6f5673ce5cf6a64f1e0d9708b554f670e6d9d2bd9a9"
dependencies = [
"mint",
"num-traits",
]
[[package]] [[package]]
name = "khronos-egl" name = "khronos-egl"
version = "4.1.0" version = "4.1.0"
@ -2173,7 +2174,7 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic//?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4" source = "git+https://github.com/pop-os/libcosmic/?rev=42d7baf#42d7baf0d5cb14ab476120be9dfcaea9bd1d0be4"
dependencies = [ dependencies = [
"apply", "apply",
"cosmic-config", "cosmic-config",
@ -2192,7 +2193,6 @@ dependencies = [
"lazy_static", "lazy_static",
"palette", "palette",
"slotmap", "slotmap",
"tokio",
"tracing", "tracing",
] ]
@ -2432,6 +2432,12 @@ dependencies = [
"simd-adler32", "simd-adler32",
] ]
[[package]]
name = "mint"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff"
[[package]] [[package]]
name = "mio" name = "mio"
version = "0.8.8" version = "0.8.8"
@ -2684,6 +2690,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [ dependencies = [
"autocfg", "autocfg",
"libm",
] ]
[[package]] [[package]]
@ -4106,18 +4113,6 @@ dependencies = [
"displaydoc", "displaydoc",
] ]
[[package]]
name = "tokio"
version = "1.28.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94d7b1cfd2aa4011f2de74c2c4c63665e27a71006b0a192dcd2710272e73dfa2"
dependencies = [
"autocfg",
"num_cpus",
"pin-project-lite",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "toml" name = "toml"
version = "0.5.11" version = "0.5.11"

View file

@ -31,8 +31,8 @@ libsystemd = { version = "0.5", optional = true }
wayland-backend = "0.1.0" wayland-backend = "0.1.0"
wayland-scanner = "0.30.0" wayland-scanner = "0.30.0"
cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] } cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", branch = "main", default-features = false, features = ["server"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic//", rev = "42d7baf", default-features = false } libcosmic = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf", default-features = false }
iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic//", rev = "42d7baf" } iced_tiny_skia = { git = "https://github.com/pop-os/libcosmic/", rev = "42d7baf" }
tiny-skia = "0.9" tiny-skia = "0.9"
ordered-float = "3.0" ordered-float = "3.0"
glow = "0.11.2" glow = "0.11.2"
@ -41,7 +41,7 @@ tracing-journald = "0.3.0"
tracing = { version = "0.1.37", features = ["max_level_debug", "release_max_level_info"] } tracing = { version = "0.1.37", features = ["max_level_debug", "release_max_level_info"] }
puffin = { version = "0.14.3", optional = true } puffin = { version = "0.14.3", optional = true }
puffin_egui = { version = "0.21.0", optional = true } puffin_egui = { version = "0.21.0", optional = true }
cosmic-time = { git = "https://github.com/pop-os/cosmic-time", rev = "39c96ac", default-features = false, features = ["libcosmic"] } keyframe = "1.1.1"
once_cell = "1.18.0" once_cell = "1.18.0"
i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] } i18n-embed = { version = "0.13", features = ["fluent-system", "desktop-requester"] }
i18n-embed-fl = "0.6" i18n-embed-fl = "0.6"
@ -81,6 +81,3 @@ lto = "fat"
[patch."https://github.com/Smithay/smithay.git"] [patch."https://github.com/Smithay/smithay.git"]
smithay = { git = "https://github.com/smithay//smithay", rev = "8d239c79ae" } smithay = { git = "https://github.com/smithay//smithay", rev = "8d239c79ae" }
[patch."https://github.com/pop-os/libcosmic/"]
libcosmic = { git = "https://github.com/pop-os/libcosmic//", rev = "42d7baf" }

View file

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

View file

@ -26,7 +26,10 @@ use cosmic::{
theme, theme,
widget::{icon, Icon}, widget::{icon, Icon},
}; };
use cosmic_time::{Cubic, Ease, Tween}; use keyframe::{
ease,
functions::{EaseInOutCubic, EaseOutCubic},
};
use std::{ use std::{
collections::{HashMap, HashSet, VecDeque}, collections::{HashMap, HashSet, VecDeque},
time::{Duration, Instant}, time::{Duration, Instant},
@ -246,13 +249,12 @@ impl State {
pub fn offset(&self, bounds: Rectangle, content_bounds: Size) -> Vector { pub fn offset(&self, bounds: Rectangle, content_bounds: Size) -> Vector {
if let Some(animation) = self.scroll_animation { if let Some(animation) = self.scroll_animation {
let percentage = { let percentage = {
let percentage = (Instant::now() let percentage = Instant::now()
.duration_since(animation.start_time) .duration_since(animation.start_time)
.as_millis() as f32 .as_millis() as f32
/ SCROLL_ANIMATION_DURATION.as_millis() as f32) / SCROLL_ANIMATION_DURATION.as_millis() as f32;
.min(1.0);
Ease::Cubic(Cubic::InOut).tween(percentage) ease(EaseInOutCubic, 0.0, 1.0, percentage)
}; };
Vector::new( Vector::new(
@ -528,12 +530,11 @@ where
renderer.with_layer(bounds, |renderer| { renderer.with_layer(bounds, |renderer| {
renderer.with_translation(Vector::new(-offset.x, -offset.y), |renderer| { renderer.with_translation(Vector::new(-offset.x, -offset.y), |renderer| {
let percentage = if let Some(animation) = state.tab_animations.front() { let percentage = if let Some(animation) = state.tab_animations.front() {
let percentage = (Instant::now() let percentage = Instant::now()
.duration_since(animation.start_time) .duration_since(animation.start_time)
.as_millis() as f32 .as_millis() as f32
/ TAB_ANIMATION_DURATION.as_millis() as f32) / TAB_ANIMATION_DURATION.as_millis() as f32;
.min(1.0); ease(EaseOutCubic, 0.0, 1.0, percentage)
Ease::Cubic(Cubic::Out).tween(percentage)
} else { } else {
1.0 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 id_tree::{InsertBehavior, MoveBehavior, Node, NodeId, NodeIdError, RemoveBehavior, Tree};
use keyframe::{ease, functions::EaseInOutCubic};
use smithay::{ use smithay::{
backend::renderer::{ backend::renderer::{
element::{ element::{
@ -2006,10 +2006,9 @@ impl TilingLayout {
.then(|| &queue.trees.front().unwrap().0); .then(|| &queue.trees.front().unwrap().0);
let percentage = if let Some(animation_start) = queue.animation_start { let percentage = if let Some(animation_start) = queue.animation_start {
let percentage = (Instant::now().duration_since(animation_start).as_millis() as f32 let percentage = Instant::now().duration_since(animation_start).as_millis() as f32
/ duration.as_millis() as f32) / duration.as_millis() as f32;
.min(1.0); ease(EaseInOutCubic, 0.0, 1.0, percentage)
Ease::Cubic(Cubic::Out).tween(percentage)
} else { } else {
1.0 1.0
}; };

View file

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