This commit is contained in:
2025-07-10 20:21:27 +02:00
parent a5d2ad1f40
commit ab85b948a9
2 changed files with 25 additions and 13 deletions

View File

@@ -14,7 +14,7 @@ use std::fs;
use iced::widget::{TextInput, column, text};
use iced::{
Color, Length, Task, Theme,
Color, Length, Padding, Task, Theme, padding,
widget::{Column, button, canvas, container, pick_list, row, scrollable, slider},
};
use iced::{Element, Font, Subscription};
@@ -70,6 +70,7 @@ struct MyApp {
current_delta: f32,
str_music_length: String,
str_time: String,
can_unpaused: bool,
}
impl MyApp {
@@ -91,6 +92,7 @@ impl MyApp {
current_delta: 0.0,
str_music_length: "01:00:00".to_string(),
str_time: "00:00:00".to_string(),
can_unpaused: true,
},
Task::none(),
)
@@ -200,7 +202,7 @@ impl MyApp {
}
match mut_s.parse::<f32>() {
Ok(val) => {
if val <= 360. {
if val >= 0. && val <= 360. {
self.update(Message::ChangeTeta(i, (val).to_radians()))
}
}
@@ -213,7 +215,7 @@ impl MyApp {
match mut_s.parse::<f32>() {
Ok(val) => {
let val = (val * 10.).floor() / 10.;
if val >= 1. {
if val >= 1. && val < 1000. {
self.music.nb_sec_for_rev = val
}
}
@@ -223,18 +225,21 @@ impl MyApp {
}
Message::CancelColor(i) => {
self.music.set_color_picker(self.current_delta, i, false);
self.paused = false;
self.can_unpaused = true;
}
Message::SubmitColor(i) => {
if !self.paused {
self.update(Message::TogglePaused);
}
self.can_unpaused = false;
self.music.set_color_picker(self.current_delta, i, true);
}
Message::ChooseColor(i, color) => {
self.music.set_color(self.current_delta, i, color);
self.music.set_color_picker(self.current_delta, i, false);
self.can_unpaused = true;
}
Message::None => {}
}
}
@@ -274,14 +279,16 @@ impl MyApp {
new_value
))
.width(Length::FillPortion(1)),
row![
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
.step(2. * PI / 10_000.)
.width(Length::FillPortion(9))
.height(32),
]
.spacing(10),
.padding(Padding::from(16)),
]
.spacing(5),
]
.spacing(10)
.into();
@@ -308,7 +315,7 @@ impl MyApp {
.chain(ngon_options)
.collect();
let polygon_column = scrollable(Column::with_children(polygon_rows).spacing(20));
let polygon_column = scrollable(Column::with_children(polygon_rows).spacing(24));
let mut save_panel: Vec<Element<Message>> = vec![
button("Toggle Save Panel")
.on_press(Message::ToggleSavePanel)
@@ -359,7 +366,11 @@ impl MyApp {
column![
row![
button(text(if self.paused { "󰐊" } else { "󰏤" }).size(28).center())
.on_press(Message::TogglePaused)
.on_press(if self.can_unpaused {
Message::TogglePaused
} else {
Message::None
})
.width(Length::FillPortion(1)),
row![
TextInput::new("MM:SS:CS", &self.str_time)

View File

@@ -2,6 +2,7 @@ use iced::Color;
#[derive(Debug, Clone)]
pub enum Message {
None,
ChangeNbPerSec(String),
Tick,
AddPolygon(String),