|
| 1 | +use iced_native::time::Duration; |
1 | 2 | use iced_native::{widget, Element, Length, Padding}; |
2 | 3 |
|
3 | | -use std::time::{Duration, Instant}; |
4 | | - |
5 | | -use crate::keyframes::{get_length, Repeat}; |
| 4 | +use crate::keyframes::{as_f32, get_length, Repeat}; |
6 | 5 | use crate::timeline::DurFrame; |
7 | 6 | use crate::{Ease, Linear}; |
8 | 7 |
|
@@ -105,16 +104,15 @@ impl Button { |
105 | 104 | Renderer::Theme: widget::button::StyleSheet, |
106 | 105 | { |
107 | 106 | let id: widget::Id = id.into(); |
108 | | - let now = Instant::now(); |
109 | 107 |
|
110 | 108 | widget::Button::new(content) |
111 | | - .width(get_length(&id, timeline, &now, 0, Length::Shrink)) |
112 | | - .height(get_length(&id, timeline, &now, 1, Length::Shrink)) |
| 109 | + .width(get_length(&id, timeline, 0, Length::Shrink)) |
| 110 | + .height(get_length(&id, timeline, 1, Length::Shrink)) |
113 | 111 | .padding([ |
114 | | - timeline.get(&id, &now, 2).map(|m| m.value).unwrap_or(5.0), |
115 | | - timeline.get(&id, &now, 3).map(|m| m.value).unwrap_or(5.0), |
116 | | - timeline.get(&id, &now, 4).map(|m| m.value).unwrap_or(5.0), |
117 | | - timeline.get(&id, &now, 5).map(|m| m.value).unwrap_or(5.0), |
| 112 | + timeline.get(&id, 2).map(|m| m.value).unwrap_or(5.0), |
| 113 | + timeline.get(&id, 3).map(|m| m.value).unwrap_or(5.0), |
| 114 | + timeline.get(&id, 4).map(|m| m.value).unwrap_or(5.0), |
| 115 | + timeline.get(&id, 5).map(|m| m.value).unwrap_or(5.0), |
118 | 116 | ]) |
119 | 117 | } |
120 | 118 |
|
@@ -179,10 +177,3 @@ impl ExactSizeIterator for Button { |
179 | 177 | 6 - self.index |
180 | 178 | } |
181 | 179 | } |
182 | | - |
183 | | -fn as_f32(length: Option<Length>) -> Option<f32> { |
184 | | - match length { |
185 | | - Some(Length::Fixed(i)) => Some(i), |
186 | | - _ => None, |
187 | | - } |
188 | | -} |
0 commit comments