better view

This commit is contained in:
2025-07-05 20:28:00 +02:00
parent c008eadfe9
commit bc528b63d4
4 changed files with 76 additions and 52 deletions

View File

@@ -1,13 +1,17 @@
mod polygon_draw;
use polygon_draw::{Polygon, PolygonFrame};
mod utils;
use utils::string_to_color;
use std::fs;
use iced::{
Color, Element, Task, Theme,
Color, Element, Length, Task, Theme,
time::{self, Duration},
widget::{Column, button, canvas, column, container, pick_list, row, slider, text},
};
use polygon_draw::{Polygon, PolygonFrame};
use serde::{Deserialize, Serialize};
use std::f32::consts::PI;
@@ -170,14 +174,7 @@ impl MyApp {
self.poly_frame.polygons[i].global_teta = teta;
}
Message::ChangeColor(i, s) => {
let c = match s.as_str() {
"Green" => Color::from_rgb(0.0, 1.0, 0.0),
"Blue" => Color::from_rgb(0.0, 0.0, 1.0),
"Cyan" => Color::from_rgb(0.0, 1.0, 1.0),
"Yellow" => Color::from_rgb(1.0, 1.0, 0.0),
"Pink" => Color::from_rgb(1.0, 0.0, 1.0),
_ => Color::BLACK,
};
let c = string_to_color(&s);
self.poly_frame.polygons[i].color = c;
self.poly_frame.polygons[i].color_name = s;
}
@@ -219,25 +216,28 @@ impl MyApp {
.map(|e| e.path().file_name().unwrap().to_str().unwrap().to_string())
.collect();
entries.sort();
row![
text(&polygon.name),
column![
row![
text(&polygon.name),
button("Remove").on_press(Message::Remove(i)),
pick_list(
["Black", "Blue", "Green", "Pink", "Yellow", "Cyan"]
.map(|s| s.to_string())
.to_vec(),
Some(&polygon.color_name),
move |s| { Message::ChangeColor(current_index, s) }
),
pick_list(entries, Some(&polygon.sound_name), move |s| {
Message::ChangeSound(current_index, s)
}),
]
.spacing(20),
slider(0.0..=2.0 * PI, polygon.global_teta, move |f| {
Message::ChangeTeta(current_index, f)
})
.step(PI / 84f32), // 84 | 4 for do PI / 4
button("Remove").on_press(Message::Remove(i)),
pick_list(
["Black", "Blue", "Green", "Pink", "Yellow", "Cyan"]
.map(|s| s.to_string())
.to_vec(),
Some(&polygon.color_name),
move |s| { Message::ChangeColor(current_index, s) }
),
pick_list(entries, Some(&polygon.sound_name), move |s| {
Message::ChangeSound(current_index, s)
}),
]
.spacing(20)
.into()
})
.collect();
@@ -275,7 +275,11 @@ impl MyApp {
text("Polymusic").size(32.0),
row(save_panel).spacing(20),
row![
container(canvas(&self.poly_frame).height(500).width(500)),
container(
canvas(&self.poly_frame)
.height(Length::FillPortion(2))
.width(Length::FillPortion(1))
),
column![
text(txt_nb_rev),
row![
@@ -286,10 +290,16 @@ impl MyApp {
pick_list(all_options, Some("Choose polygon".to_string()), |s| {
Message::AddPolygon(s)
}),
polygon_column,
],
polygon_column.spacing(10),
]
.spacing(10)
.height(Length::FillPortion(2))
.width(Length::FillPortion(2)),
]
.spacing(20),
row![text("futur time line")]
.height(Length::FillPortion(1))
.width(Length::FillPortion(1)),
]
.spacing(25)
.padding(25)