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 51209b1f6d
commit 4c448d3331
3 changed files with 24 additions and 12 deletions

View File

@@ -3,16 +3,16 @@ use crate::polygon_draw::*;
use crate::utils::string_to_polygon;
use serde::{Deserialize, Serialize};
use kira::{AudioManager, sound::static_sound::StaticSoundData};
use kira::{sound::static_sound::StaticSoundData, AudioManager};
use iced::event::Status;
use iced::mouse::Cursor;
use iced::widget::canvas::{Event, Geometry};
use iced::{keyboard, Vector};
use iced::{
Size,
mouse::{self, ScrollDelta},
Size,
};
use iced::{Vector, keyboard};
use iced::widget::canvas;
use iced::widget::canvas::Stroke;
@@ -174,17 +174,23 @@ impl Music {
pub fn add_polygon(&mut self, delta: f32, polygon_name: String) {
let current_frame = self.find_poly_frame(delta);
let poly = string_to_polygon(polygon_name);
let mut poly = string_to_polygon(polygon_name);
poly.update();
current_frame.polygons.push(poly);
}
pub fn remove_polygon(&mut self, delta: f32, i: usize) -> String {
pub fn add_polygon_from(&mut self, delta: f32, polygon: Polygon) {
let current_frame = self.find_poly_frame(delta);
current_frame.polygons.push(polygon);
}
pub fn remove_polygon(&mut self, delta: f32, i: usize) -> Polygon {
let pf = self.find_poly_frame(delta);
let mut i = i;
if i == usize::MAX {
i = pf.polygons.len() - 1
}
let out = pf.polygons[i].name.clone();
let out = pf.polygons[i].clone();
pf.polygons.remove(i);
out
}