Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More keyboard shortcuts in animation bar #187

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/app/animation_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,29 @@ pub fn display_animation_bar(
);
if response.hovered() {
ui.ctx().input_mut(|i| {
if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowRight) {
animation_state.current_frame += 1.0;
if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowLeft) { //Go back one frame
animation_state.current_frame = (animation_state.current_frame - 1.0).ceil();
animation_state.should_update_animations = true;
} else if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowLeft) {
animation_state.current_frame -= 1.0;
} else if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowRight) { //Go forward one frame
animation_state.current_frame = (animation_state.current_frame + 1.0).floor();
animation_state.should_update_animations = true;
}
} else if i.consume_key(egui::Modifiers::COMMAND, egui::Key::ArrowLeft) { //Go back to first frame
animation_state.current_frame = 0.0;
animation_state.should_update_animations = true;
} else if i.consume_key(egui::Modifiers::COMMAND, egui::Key::ArrowRight) { //Go forward to last frame
animation_state.current_frame = final_frame_index;
animation_state.should_update_animations = true;
} else if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowUp) { //Speed up by 0.01
animation_state.playback_speed += 0.01;
} else if i.consume_key(egui::Modifiers::default(), egui::Key::ArrowDown) { //Slow down by 0.01
animation_state.playback_speed -= 0.01;
} else if i.consume_key(egui::Modifiers::COMMAND, egui::Key::ArrowUp) { //Speed up to multiple of 0.25
animation_state.playback_speed = (animation_state.playback_speed * 4.0 + 1.0).floor() / 4.0;
} else if i.consume_key(egui::Modifiers::COMMAND, egui::Key::ArrowDown) { //Slow down to multiple of 0.25
animation_state.playback_speed = (animation_state.playback_speed * 4.0 - 1.0).ceil() / 4.0;
} else if i.consume_key(egui::Modifiers::default(), egui::Key::Space) { //Play or Pause
animation_state.is_playing = !animation_state.is_playing;
}
})
};

Expand Down
Loading