fix ctrl z for remove polygon, now polygon return with there color, sound and teta

This commit is contained in:
2025-07-25 18:35:02 +02:00
parent 29d257eef0
commit 6c360c4222
3 changed files with 24 additions and 12 deletions

View File

@@ -22,15 +22,15 @@ use gui::{load_file_view, music_view};
use iced::Font;
use iced::Theme;
use iced::{
Color, Event, Task,
event::{self, Status},
keyboard::{Key, key::Named},
keyboard::{key::Named, Key},
Color, Event, Task,
};
use std::time::Instant;
use kira::{
AudioManager, AudioManagerSettings, DefaultBackend, sound::static_sound::StaticSoundData,
sound::static_sound::StaticSoundData, AudioManager, AudioManagerSettings, DefaultBackend,
};
const FONT_BYTES: &[u8] = include_bytes!("../fonts/EnvyCodeRNerdFontMono-Regular.ttf");
const FONT: Font = Font::with_name("EnvyCodeR Nerd Font Mono");
@@ -87,7 +87,6 @@ impl Polymusic {
fn new() -> (Self, Task<Message>) {
let manager = AudioManager::<DefaultBackend>::new(AudioManagerSettings::default())
.expect("Error to load AudioManager");
(
Self {
time_last_frame: Instant::now(),
@@ -120,6 +119,9 @@ impl Polymusic {
self.current_delta,
);
}
Message::ReAddPolygon(poly) => {
self.music.add_polygon_from(self.current_delta, poly);
}
Message::Tick => {
if self.current_delta >= self.music.length {
self.paused = true
@@ -135,10 +137,10 @@ impl Polymusic {
}
}
Message::Remove(i) => {
let name = self.music.remove_polygon(self.current_delta, i);
let poly = self.music.remove_polygon(self.current_delta, i);
self.already_save = false;
self.historic.add(
Message::AddPolygon(name),
Message::ReAddPolygon(poly),
Message::Remove(i),
self.current_delta,
);
@@ -443,6 +445,7 @@ impl Polymusic {
self.update(Message::TogglePaused);
self.update(Message::Tick);
self.update(Message::TogglePaused);
self.update(Message::None);
}
}
}