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

View File

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