Output templates tab: Naming pattern on the tab row, no Include all, Reset all or count, Save settings and Export greyed

This commit is contained in:
vangel76 committed 2026-11-23 23:29:50 +01:00
1 parent cfc4b8b3a7
commit e83c3f88c8
3 files changed
+55 -20

No files matched your search

+13 -14
View File
@@ -73,6 +73,8 @@ const CREATE: [(&str, Layout); 5] =
/// The naming patterns the input maps can be shown with (the reference's second one names
/// another vendor's material and is left out)
const NAMING_PATTERNS: [&str; 1] = ["OpenPBR"];
/// Width of the Naming pattern list
const NAMING_PATTERN_WIDTH: f32 = 150.0;
/// The input maps palette: (group, [(label, source)]).
type Palette = [(&'static str, Vec<(&'static str, SourceRef)>); 4];
@@ -244,7 +246,6 @@ pub fn tab(app: &mut TextureCraftApp, ui: &mut Ui, builtins: &[ExportPreset]) {
ui.vertical(|ui| {
ui.set_width(INPUTS_WIDTH);
ui.set_height(height);
naming_pattern(ui);
input_maps(ui);
});
if let Some(a) = list_action {
@@ -262,21 +263,19 @@ pub fn select(app: &mut TextureCraftApp, name: String) {
}
}
/// "Naming pattern" with its info icon
fn naming_pattern(ui: &mut Ui) {
/// "Naming pattern" with its info icon, at the right end of the tab row (laid out right to left)
pub(crate) fn naming_pattern(ui: &mut Ui) {
let tk = Tokens::get(ui.ctx());
ui.horizontal(|ui| {
ui.label(tr("Naming pattern"));
egui::ComboBox::from_id_salt("exp_naming").width(90.0).selected_text(NAMING_PATTERNS[0]).show_ui(ui, |ui| {
for p in NAMING_PATTERNS {
let _ = ui.selectable_label(true, p);
}
});
ui.label(RichText::new(ic::INFO).color(tk.text_dim)).on_hover_ui(|ui| {
ui.label(tr("Select the naming pattern used to display the input maps on this page."));
ui.label(tr("Some input maps (channels) may be named differently depending on the shader used as a Texture Set."));
});
ui.label(RichText::new(ic::INFO).color(tk.text_dim)).on_hover_ui(|ui| {
ui.label(tr("Select the naming pattern used to display the input maps on this page."));
ui.label(tr("Some input maps (channels) may be named differently depending on the shader used as a Texture Set."));
});
egui::ComboBox::from_id_salt("exp_naming").width(NAMING_PATTERN_WIDTH).selected_text(NAMING_PATTERNS[0]).show_ui(ui, |ui| {
for p in NAMING_PATTERNS {
let _ = ui.selectable_label(true, p);
}
});
ui.label(tr("Naming pattern"));
}
/// The Presets list: the templates sorted by name (built-in and user); a right click offers
+12 -6
View File
@@ -1309,6 +1309,8 @@ pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
if ui.button(tr("Open output directory")).clicked() {
open_output_directory(app);
}
} else if app.ui.export.tab == 1 {
crate::export_templates::naming_pattern(ui);
} else if ui.button(tr("Include all")).on_hover_text(tr("Includes all Texture Sets, UV Tiles and output maps.")).clicked() {
app.ui.export.skip.clear();
for o in app.ui.export.sets.values_mut() {
@@ -1362,10 +1364,12 @@ pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
return;
}
let selected = selected_texture_count(app);
// OUTPUT TEMPLATES edits the templates only: no count, nothing to reset, save or export there
let templates_tab = app.ui.export.tab == 1;
let selected = if templates_tab { 0 } else { selected_texture_count(app) };
ui.horizontal(|ui| {
// Not on LIST OF EXPORTS
if app.ui.export.tab != 2
// Only on SETTINGS
if app.ui.export.tab == 0
&& ui.add(footer_button(tr("Reset all"))).on_hover_text(tr("Resets all settings to their default values, including all textures.")).clicked()
{
// Keep ownership so Cancel can restore the opening settings
@@ -1375,19 +1379,21 @@ pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
// Nothing to write without a ticked texture set
let any = !export_selection(app).is_empty();
let any = !export_selection(app).is_empty() && !templates_tab;
if ui.add_enabled(any, footer_button(tr("Export"))).on_hover_text(tr("Exports all selected textures and additional files")).clicked() {
do_export = true;
}
// Saving closes the window without starting an export
if ui.add(footer_button(tr("Save settings"))).on_hover_text(tr("Closes the export window and saves changes")).clicked() {
if ui.add_enabled(!templates_tab, footer_button(tr("Save settings"))).on_hover_text(tr("Closes the export window and saves changes")).clicked() {
app.ui.windows.export = false;
}
if ui.add(footer_button(tr("Cancel"))).on_hover_text(tr("Closes the export window and undoes all recent changes")).clicked() {
canceled = true;
}
ui.label(trf("{n} textures selected for export", &[("n", &selected)]));
if !templates_tab {
ui.label(trf("{n} textures selected for export", &[("n", &selected)]));
}
});
});
});
@@ -30,6 +30,9 @@ fn harness(library: &TemplateLibrary) -> Harness<'static, TextureCraftApp> {
h
}
/// Left edge of the right rail in the 1600 point wide harness
const RAIL_LEFT_EDGE: f32 = 1560.0;
fn click(h: &mut Harness<'_, TextureCraftApp>, label: &str) {
h.get_all_by_label(label).last().unwrap_or_else(|| panic!("no {label}")).click();
h.run_steps(4);
@@ -284,3 +287,30 @@ fn a_retained_draft_keeps_overrides_with_maps_after_an_external_reorder() {
assert_eq!(current, saved, "the corrected draft was saved in its own order");
assert_eq!(harness.state().ui.export.sets[&0].maps, [(1, disabled)].into());
}
#[test]
fn the_tab_row_holds_the_naming_pattern_and_the_bottom_bar_only_cancels() {
let library = TemplateLibrary::new("bottom-bar");
let h = harness(&library);
let naming = h.get_by_label("Naming pattern").rect();
let tabs = h.get_by_label("OUTPUT TEMPLATES").rect();
let presets = h.get_by_label("Presets").rect();
assert!(naming.center().y < presets.top() && (naming.center().y - tabs.center().y).abs() < tabs.height(), "on the tab row: {naming:?}");
assert!(naming.left() > presets.right(), "at the right end");
for absent in ["Include all", "Reset all"] {
assert!(h.query_by_label(absent).is_none(), "{absent}");
}
assert!(h.query_by_label_contains("textures selected for export").is_none());
for greyed in ["Save settings", "Export"] {
// The rail at the right edge has an Export button of its own
let button = h
.get_all_by_role(egui::Role::Button)
.filter(|b| b.rect().max.x < RAIL_LEFT_EDGE && b.accesskit_node().label().as_deref() == Some(greyed))
.last()
.unwrap();
assert!(button.accesskit_node().is_disabled(), "{greyed}");
}
assert!(!h.get_all_by_label("Cancel").last().unwrap().accesskit_node().is_disabled());
}