Skip to content

Commit

Permalink
Replace radial button selection with comboboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueCookieFrog committed Nov 11, 2024
1 parent 8f39d26 commit 7c7ea91
Showing 1 changed file with 53 additions and 17 deletions.
70 changes: 53 additions & 17 deletions src/gui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7c7ea91

Please sign in to comment.