From 7c7ea91da20a37a036a4d2a49a485bc95847d49c Mon Sep 17 00:00:00 2001 From: Borys <35380525+BlueCookieFrog@users.noreply.github.com> Date: Mon, 11 Nov 2024 14:26:39 +0100 Subject: [PATCH 1/2] Replace radial button selection with comboboxes --- src/gui/mod.rs | 70 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 2ac35e7..c29296f 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -2003,25 +2003,61 @@ impl eframe::App for App { .map(|c| (Some(c.sort_category), c.is_ascending)) .unwrap_or_default(); - let mut clicked = ui.radio_value(&mut sort_category, None, "Manual").clicked(); - for category in SortBy::iter() { - let mut radio_label = category.as_str().to_owned(); - if sort_category == Some(category) { - radio_label.push_str(if is_ascending { " ⏶" } else { " ⏷" }); - } - let resp = ui.radio_value(&mut sort_category, Some(category), radio_label); - if resp.clicked() { - clicked = true; - if resp.changed() { - is_ascending = true; - } else { - is_ascending = !is_ascending; + egui::ComboBox::from_id_salt("sort_cat") + .selected_text( + { + match sort_category { + None => "Manual", + Some(category) => category.as_str(), } + } + .to_string(), + ) + .show_ui(ui, |ui| { + if ui + .selectable_value(&mut sort_category, None, "Manual") + .clicked() + { + self.update_sorting_config(sort_category, is_ascending); }; - } - if clicked { - self.update_sorting_config(sort_category, is_ascending); - } + for category in SortBy::iter() { + let combo_label = category.as_str().to_owned(); + if ui + .selectable_value( + &mut sort_category, + Some(category), + combo_label, + ) + .clicked() + { + self.update_sorting_config(sort_category, is_ascending); + }; + } + }); + + ui.label("Order: "); + + ui.add_enabled_ui(sort_category.is_some(), |ui| { + egui::ComboBox::from_id_salt("order") + .selected_text(match is_ascending { + true => "Ascending", + false => "Descending", + }) + .show_ui(ui, |ui| { + if ui + .selectable_value(&mut is_ascending, true, "Ascending") + .clicked() + { + self.update_sorting_config(sort_category, is_ascending); + } + if ui + .selectable_value(&mut is_ascending, false, "Descending") + .clicked() + { + self.update_sorting_config(sort_category, is_ascending); + } + }); + }); ui.add_space(16.); // TODO: actually implement mod groups. From e1de1d87a2475bdfffb06320da816b502cd63ba5 Mon Sep 17 00:00:00 2001 From: Borys <35380525+BlueCookieFrog@users.noreply.github.com> Date: Mon, 11 Nov 2024 18:36:35 +0100 Subject: [PATCH 2/2] fmt lint --- src/gui/mod.rs | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/src/gui/mod.rs b/src/gui/mod.rs index c29296f..090b30e 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -2004,36 +2004,32 @@ impl eframe::App for App { .unwrap_or_default(); egui::ComboBox::from_id_salt("sort_cat") - .selected_text( - { - match sort_category { - None => "Manual", - Some(category) => category.as_str(), + .selected_text( + { + match sort_category { + None => "Manual", + Some(category) => category.as_str(), + } } - } - .to_string(), - ) - .show_ui(ui, |ui| { - if ui - .selectable_value(&mut sort_category, None, "Manual") - .clicked() - { - self.update_sorting_config(sort_category, is_ascending); - }; - for category in SortBy::iter() { - let combo_label = category.as_str().to_owned(); + .to_string(), + ) + .show_ui(ui, |ui| { if ui - .selectable_value( - &mut sort_category, - Some(category), - combo_label, - ) + .selectable_value(&mut sort_category, None, "Manual") .clicked() { self.update_sorting_config(sort_category, is_ascending); }; - } - }); + for category in SortBy::iter() { + let combo_label = category.as_str().to_owned(); + if ui + .selectable_value(&mut sort_category, Some(category), combo_label) + .clicked() + { + self.update_sorting_config(sort_category, is_ascending); + }; + } + }); ui.label("Order: ");