fix ctrl z for remove polygon, now polygon return with there color, sound and teta
This commit is contained in:
18
src/music.rs
18
src/music.rs
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user