Add animation control buttons to document bar

This commit is contained in:
Keavon Chambers
2025-03-19 02:15:40 -07:00
parent 44694ff8d6
commit 08a4b69948
11 changed files with 91 additions and 17 deletions
@@ -33,6 +33,7 @@ use graphene_core::raster::image::ImageFrameTable;
use graphene_core::vector::style::ViewMode;
use graphene_std::renderer::{ClickTarget, Quad};
use graphene_std::vector::{PointId, path_bool_lib};
use std::time::Duration;
pub struct DocumentMessageData<'a> {
pub document_id: DocumentId,
@@ -1988,7 +1989,7 @@ impl DocumentMessageHandler {
}
}
pub fn update_document_widgets(&self, responses: &mut VecDeque<Message>) {
pub fn update_document_widgets(&self, responses: &mut VecDeque<Message>, animation_is_playing: bool, time: Duration) {
// Document mode (dropdown menu at the left of the bar above the viewport, before the tool options)
let document_mode_layout = WidgetLayout::new(vec![LayoutGroup::Row {
@@ -2026,6 +2027,18 @@ impl DocumentMessageHandler {
let mut snapping_state2 = self.snapping_state.clone();
let mut widgets = vec![
IconButton::new("PlaybackToStart", 24)
.tooltip("Restart Animation")
.tooltip_shortcut(action_keys!(AnimationMessageDiscriminant::RestartAnimation))
.on_update(|_| AnimationMessage::RestartAnimation.into())
.disabled(time == Duration::ZERO)
.widget_holder(),
IconButton::new(if animation_is_playing { "PlaybackPause" } else { "PlaybackPlay" }, 24)
.tooltip(if animation_is_playing { "Pause Animation" } else { "Play Animation" })
.tooltip_shortcut(action_keys!(AnimationMessageDiscriminant::ToggleLivePreview))
.on_update(|_| AnimationMessage::ToggleLivePreview.into())
.widget_holder(),
Separator::new(SeparatorType::Unrelated).widget_holder(),
CheckboxInput::new(self.overlays_visible)
.icon("Overlays")
.tooltip("Overlays")