remove comment in french and usless things, add remove buttons

This commit is contained in:
2025-06-03 15:26:06 +02:00
parent b732708ce3
commit 4d4347a0d0
2 changed files with 18 additions and 17 deletions

View File

@@ -29,6 +29,7 @@ enum Message {
Tick,
AddPolygon(String),
ChangeTeta(usize, f32),
Remove(usize),
}
struct MyApp {
@@ -106,6 +107,9 @@ impl MyApp {
}
self.time_last_frame = Instant::now();
}
Message::Remove(i) => {
self.poly_frame.polygons.remove(i - 1);
}
Message::ChangeTeta(i, teta) => self.poly_frame.polygons[i].global_teta = teta,
}
}
@@ -119,7 +123,7 @@ impl MyApp {
.iter()
.map(|polygon| {
let current_index = i;
i += 1; // Incrémenter l'index pour le prochain polygone
i += 1;
row![
text(&polygon.name),
@@ -128,13 +132,13 @@ impl MyApp {
polygon.global_teta,
move |f| { Message::ChangeTeta(current_index, f) }
)
.step(2.0 * PI / 42f32)
.step(2.0 * PI / 42f32),
button("Remove").on_press(Message::Remove(i))
]
.into()
})
.collect();
// Utiliser Column::with_children pour ajouter dynamiquement les boutons
let polygon_column = Column::with_children(polygon_rows);
column![
text("Polymusic").size(32.0),
@@ -164,12 +168,3 @@ impl MyApp {
time::every(Duration::from_millis(16)).map(|_| Message::Tick)
}
}
/*
fn do_sound(file_name: &str) {
let (_stream, handle) = rodio::OutputStream::try_default().unwrap();
let sink = rodio::Sink::try_new(&handle).unwrap();
let file = std::fs::File::open(file_name).unwrap();
sink.append(rodio::Decoder::new(BufReader::new(file)).unwrap());
sink.sleep_until_end();
}*/

View File

@@ -34,10 +34,6 @@ impl PolygonFrame {
let mut all_sound: Vec<&StaticSoundData> = vec![];
for poly in &self.polygons {
all_sound.extend(poly.sound_to_play_btw(before, after));
/*
if poly.have_points_btw(before, after) {
return true;
}*/
}
all_sound
}
@@ -74,7 +70,7 @@ impl<Message> canvas::Program<Message> for PolygonFrame {
&line,
Stroke {
width: 4.0,
style: Style::Solid(Color::BLACK),
style: Style::Solid(poly.color.clone()),
..Stroke::default()
},
);
@@ -116,6 +112,7 @@ pub struct Polygon {
pub points_teta: Vec<f32>,
pub sound: StaticSoundData,
pub name: String,
pub color: Color,
}
#[warn(dead_code)]
impl Polygon {
@@ -146,6 +143,7 @@ impl Polygon {
points_teta: v,
sound: sound,
name: "".to_string(),
color: Color::BLACK,
}
}
pub fn segment(teta: f32, sound: StaticSoundData) -> Self {
@@ -164,6 +162,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
2.0 * 5.0 * PI / 30.0,
@@ -179,6 +178,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
0.0,
@@ -195,6 +195,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
2.0 * PI / 30.0,
@@ -212,6 +213,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
0.0,
@@ -230,6 +232,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
2.0 * 3.0 * PI / 42.0,
@@ -247,6 +250,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
0.0,
@@ -265,6 +269,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
2.0 * 6.0 * PI / 42.0,
@@ -284,6 +289,7 @@ impl Polygon {
Polygon {
sound: sound,
name: "".to_string(),
color: Color::BLACK,
global_teta: teta,
points_teta: vec![
0.0,