mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-28 17:19:24 +01:00
Export: each greyed bit depth list has its own id
disabled_combo took its id from the label alone, so two Output maps rows with a one-depth file type (BMP, JPEG) clashed and shared one accessibility node (review on #827). It is now salted with the row's own id, as the enabled bit depth list is.
This commit is contained in:
1 parent
254868413e
commit
abe73ab180
3 files changed
+23
-4
No files matched your search
@@ -298,7 +298,7 @@ fn file_type_lists(
|
||||
let options = parsed.map(depth_options).unwrap_or_default();
|
||||
let shown = if parsed.is_some() { depth_label(parsed, *bit_depth, *dithering) } else { String::new() };
|
||||
if options.len() < 2 {
|
||||
drawn::disabled_combo(ui, rects[1], &shown, tr("Bit depth"));
|
||||
drawn::disabled_combo(ui, rects[1], ("bits", id), &shown, tr("Bit depth"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -235,10 +235,10 @@ pub(crate) fn field_button(ui: &mut Ui, rect: Rect, id: Id, text: &str) -> Respo
|
||||
response
|
||||
}
|
||||
|
||||
/// A dropdown that cannot be used: a step lighter than the others, its value and chevron dim
|
||||
pub(crate) fn disabled_combo(ui: &mut Ui, rect: Rect, shown: &str, name: &str) -> Response {
|
||||
/// A dropdown that cannot be used: a step lighter than the others, its value and chevron dim; `id` tells it from the rows' other ones
|
||||
pub(crate) fn disabled_combo(ui: &mut Ui, rect: Rect, id: impl std::hash::Hash + std::fmt::Debug, shown: &str, name: &str) -> Response {
|
||||
let look = ExportLook::get(ui.ctx());
|
||||
let response = ui.interact(rect, ui.scope_id().with(("export_disabled_combo", name)), Sense::hover());
|
||||
let response = ui.interact(rect, ui.scope_id().with(("export_disabled_combo", id)), Sense::hover());
|
||||
response.widget_info(|| {
|
||||
let mut info = WidgetInfo::labeled(Role::ComboBox, false, name);
|
||||
info.current_text_value = Some(shown.to_owned());
|
||||
|
||||
@@ -278,3 +278,22 @@ fn a_map_picks_its_own_size_and_the_export_writes_it_at_that_size() {
|
||||
assert_eq!(image::image_dimensions(&path).unwrap(), (side, side), "{}", path.display());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rows_with_a_one_depth_file_type_each_have_their_own_bit_depth_list() {
|
||||
let mut h = harness();
|
||||
let rows: Vec<usize> = plan(&mut h).iter().take(2).map(|file| file["map"].as_u64().unwrap() as usize).collect();
|
||||
let template = h.state().ui.export.preset.clone();
|
||||
let mut o = SetExport { maps_template: template, ..SetExport::default() };
|
||||
for map in &rows {
|
||||
o.maps.insert(*map, MapExport { enabled: true, file_type: Some(FileType { format: "bmp".into(), bit_depth: 8, dithering: false }), size: None });
|
||||
}
|
||||
h.state_mut().ui.export.sets.insert(0, o);
|
||||
h.run_steps(4);
|
||||
|
||||
let greyed: Vec<_> = h.get_all_by_role_and_label(egui::Role::ComboBox, "Bit depth").map(|node| node.accesskit_node().id()).collect();
|
||||
|
||||
assert_eq!(rows.len(), 2);
|
||||
assert_eq!(greyed.len(), 2, "each row's greyed bit depth list is its own node");
|
||||
assert_ne!(greyed[0], greyed[1]);
|
||||
}
|
||||
Reference in new issue
Block a user