Skip to content

Commit 9a50718

Browse files
committed
fix recipe switching not checking save
1 parent a01593c commit 9a50718

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/smgui.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use winit::raw_window_handle::HasWindowHandle;
1313

1414
struct SmApp {
1515
first_frame: bool,
16+
save_new_recipe: bool,
1617
recipe_change_request: Option<String>,
1718
recipe: Recipe,
1819
metadata: WidgetMetadata,
@@ -98,6 +99,7 @@ pub fn sm_gui<'gui>(
9899
Ok(Box::new(
99100
SmApp {
100101
first_frame: true,
102+
save_new_recipe: false,
101103
recipe_change_request: None,
102104
recipe_saved: format!("{:?}", recipe),
103105
recipe,
@@ -428,7 +430,7 @@ impl eframe::App for SmApp {
428430
ui.label(key.to_owned() + ":");
429431
let response = ui.add(
430432
egui::Slider::new(&mut int, min..=max)
431-
//.text(key)
433+
.clamping(egui::SliderClamping::Never)
432434
.step_by(increment),
433435
);
434436

@@ -482,10 +484,6 @@ impl eframe::App for SmApp {
482484
}
483485
}
484486

485-
// if i.consume_shortcut(&Ctrls){
486-
// println!("you pressed ctrl+s");
487-
// }
488-
489487
if !self.selected_files.is_empty() {
490488
self.start_rendering = true;
491489
}
@@ -496,12 +494,6 @@ impl eframe::App for SmApp {
496494
.collapsible(false)
497495
.resizable(false)
498496
.show(ctx, |ui| {
499-
ui.heading("\nknown bugs");
500-
ui.label(
501-
concat!(
502-
"\n- Starting to render causes the GUI to freeze instead of closing, just minimize it tbh"
503-
),
504-
);
505497
ui.heading("\nwhat is this");
506498
ui.label(
507499
"user interface to edit the recipe.ini text file more conveniently",
@@ -524,7 +516,7 @@ impl eframe::App for SmApp {
524516
"github\n",
525517
"https://github.com/couleur-tweak-tips/smoothie-rs",
526518
)
527-
.on_hover_text_at_pointer("see /smrs-egui/ folder")
519+
.on_hover_text_at_pointer("see /src/smgui.rs folder")
528520
.secondary_clicked()
529521
{
530522
let url = "https://github.com/couleur-tweak-tips/smoothie-rs";
@@ -545,7 +537,10 @@ impl eframe::App for SmApp {
545537
self.show_confirmation_dialog = true;
546538
}
547539
}
548-
540+
if self.save_new_recipe {
541+
self.recipe_saved = format!("{:?}", self.recipe);
542+
self.save_new_recipe = false;
543+
}
549544
if self.recipe_change_request.is_some() {
550545
let old_recipe = self.recipe_change_request.clone().unwrap();
551546
if format!("{:?}", self.recipe) != self.recipe_saved {
@@ -571,8 +566,11 @@ impl eframe::App for SmApp {
571566
self.recipe_change_request = None;
572567
let (recipe, metadata) = crate::recipe::get_recipe(&mut self.args);
573568
self.recipe = recipe.clone();
574-
self.recipe_saved = format!("{:?}", recipe);
575569
self.metadata = metadata;
570+
// the recipe isn't formatted yet, let it go through a frame
571+
// to normalize bools and int slider increments
572+
//self.recipe_saved = format!("{:?}", recipe);
573+
self.save_new_recipe;
576574
}
577575
if ui.button("Don't Save").clicked() {
578576
self.recipe_change_request = None;

0 commit comments

Comments
 (0)