mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-25 00:40:47 +01:00
Align menus and default UI with the context-menu plan
Match menu labels, defaults, checkmarks, toolbar visibility and Help links. Add recent-project limits, per-mode layouts and session log actions. Make dialogs movable and resizable with consistent titles and scrollbar clearance. Validation: release app build succeeded and preview opened. Full tests and screenshots were not rerun at the user's request.
This commit is contained in:
1 parent
fde68a0fc6
commit
255977e304
44 files changed
+1346
-752
No files matched your search
@@ -46,3 +46,13 @@ Built-in environments (`crates/render/src/ibl.rs`), smart materials and procedur
|
||||
(`crates/paint/src/brush.rs`), meshes (`crates/geom/src/primitives.rs`) and shelf thumbnails
|
||||
(`crates/ui-egui/src/thumbs.rs`) are generated in code by TextureCraft contributors (MIT OR
|
||||
Apache-2.0). None of them is derived from another product's presets, shaders, materials or images.
|
||||
|
||||
## Default-browser integration dependencies
|
||||
|
||||
The desktop app enables eframe's `links` feature. These unmodified Rust dependencies open links in the system browser and parse their URLs; their upstream MIT and Apache-2.0 licence files remain in the published crates.
|
||||
|
||||
| Dependency | Source | License |
|
||||
|---|---|---|
|
||||
| `webbrowser` 1.2.7 | https://github.com/amodm/webbrowser-rs | MIT OR Apache-2.0 |
|
||||
| `url` 2.5.8, `idna` 1.1.0, `form_urlencoded` 1.2.2 | https://github.com/servo/rust-url | MIT OR Apache-2.0 |
|
||||
| `idna_adapter` 1.2.2 | https://github.com/hsivonen/idna_adapter | Apache-2.0 OR MIT |
|
||||
Generated
+59
@@ -1423,6 +1423,7 @@ dependencies = [
|
||||
"raw-window-handle",
|
||||
"serde",
|
||||
"web-time",
|
||||
"webbrowser",
|
||||
"windows-sys 0.61.2",
|
||||
"winit",
|
||||
]
|
||||
@@ -1744,6 +1745,15 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
|
||||
|
||||
[[package]]
|
||||
name = "form_urlencoded"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"
|
||||
dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fs-set-times"
|
||||
version = "0.20.3"
|
||||
@@ -2400,6 +2410,27 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
|
||||
|
||||
[[package]]
|
||||
name = "idna"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"
|
||||
dependencies = [
|
||||
"idna_adapter",
|
||||
"smallvec",
|
||||
"utf8_iter",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "idna_adapter"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"
|
||||
dependencies = [
|
||||
"icu_normalizer",
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.10"
|
||||
@@ -5184,6 +5215,18 @@ dependencies = [
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"idna",
|
||||
"percent-encoding",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "urlencoding"
|
||||
version = "2.1.3"
|
||||
@@ -5485,6 +5528,22 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webbrowser"
|
||||
version = "1.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73e91ccd4698f2647d6137e8eb17a3f1dcfd63810be9029fb2398f507279b95b"
|
||||
dependencies = [
|
||||
"jni",
|
||||
"log",
|
||||
"ndk-context",
|
||||
"objc2 0.6.5",
|
||||
"objc2-app-kit 0.3.2",
|
||||
"objc2-foundation 0.3.2",
|
||||
"url",
|
||||
"web-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-root-certs"
|
||||
version = "1.0.11"
|
||||
|
||||
@@ -25,3 +25,10 @@ in https://github.com/storytold/craft-fonts/blob/main/ATTRIBUTION.md (Inter
|
||||
and BIZ UDPGothic on desktop and web, Noto Sans CJK SC on desktop), under the SIL Open Font License
|
||||
1.1. Their licence texts ship
|
||||
with the package as OFL-<family>.txt.
|
||||
|
||||
Default-browser integration (eframe's links feature):
|
||||
webbrowser 1.2.7 — MIT OR Apache-2.0, https://github.com/amodm/webbrowser-rs.
|
||||
url 2.5.8, idna 1.1.0 and form_urlencoded 1.2.2 — MIT OR Apache-2.0,
|
||||
https://github.com/servo/rust-url.
|
||||
idna_adapter 1.2.2 — Apache-2.0 OR MIT, https://github.com/hsivonen/idna_adapter.
|
||||
These dependencies are used unmodified; their published crates retain the upstream licence files.
|
||||
@@ -15,7 +15,7 @@ texturecraft-engine = { workspace = true }
|
||||
texturecraft-ui-egui = { workspace = true }
|
||||
# The control channel's token, framing and connection limits (shared with `texturecraft-cli serve`).
|
||||
texturecraft-automation = { workspace = true }
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "wayland", "x11", "persistence"] }
|
||||
eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit", "wayland", "x11", "persistence", "links"] }
|
||||
egui = { workspace = true }
|
||||
image = { workspace = true }
|
||||
craft-image-codecs = { workspace = true }
|
||||
|
||||
@@ -32,7 +32,7 @@ pub fn color_selection_properties(app: &mut TextureCraftApp, ui: &mut Ui, effect
|
||||
let set_index = app.session.doc.project.locate(effect_owner(app, effect)).map_or(app.session.ts(), |(set_index, _, _)| set_index);
|
||||
let has_id_map = app.session.baked(set_index).is_some_and(|baked| baked.maps.contains_key(&BakedMap::Id));
|
||||
if !has_id_map {
|
||||
ui.label(RichText::new(format!("{} {}", ic::WARNING, tr("Bake an ID map (Ctrl+Shift+B) to pick colors from the mesh."))).color(tokens.warning));
|
||||
ui.label(RichText::new(format!("{} {}", ic::WARNING, tr("Bake an ID map (F8) to pick colors from the mesh."))).color(tokens.warning));
|
||||
}
|
||||
|
||||
let picking = app.picking_id_color.filter(|pick| pick.effect == effect);
|
||||
|
||||
@@ -92,6 +92,7 @@ fn refresh_draft_preferences(draft: &mut Prefs, previous: &Prefs, current: &Pref
|
||||
refresh_fields!(
|
||||
ui_scale,
|
||||
autosave_minutes,
|
||||
recent_projects_limit,
|
||||
language,
|
||||
viewport_texture,
|
||||
brightness,
|
||||
@@ -227,6 +228,7 @@ pub fn handle(app: &mut TextureCraftApp, ctx: &egui::Context, method: &str, para
|
||||
.map(|item| json!({
|
||||
"menu": item.menu, "submenu": item.sub, "label": item.label, "id": item.id, "shortcut": crate::keymap::shortcut_of(&app.ui.keymap, item.id),
|
||||
"implemented": crate::menus::implemented(item.id), "enabled": crate::menus::enabled(app, item.id),
|
||||
"checked": crate::menus::checked(app, item.id),
|
||||
}))
|
||||
.collect::<Vec<_>>()
|
||||
)),
|
||||
@@ -283,6 +285,7 @@ pub fn handle(app: &mut TextureCraftApp, ctx: &egui::Context, method: &str, para
|
||||
refresh_draft_preferences(&mut draft.prefs, &app.ui.prefs, &ui.prefs);
|
||||
}
|
||||
|
||||
ui.trim_recent();
|
||||
app.ui = ui;
|
||||
app.reschedule_autosave_if_changed(previous_autosave_minutes);
|
||||
app.ui.prefs.apply_resource_limits();
|
||||
|
||||
@@ -38,14 +38,16 @@ pub enum Panel {
|
||||
Shader,
|
||||
History,
|
||||
Log,
|
||||
BakingLog,
|
||||
Export,
|
||||
/// The path tracer's settings (Window ▸ Views ▸ Renderer Settings, Rendering mode only)
|
||||
Renderer,
|
||||
}
|
||||
|
||||
/// Window ▸ Views items and the panels they show or hide.
|
||||
pub const VIEWS: [(&str, Panel); 14] = [
|
||||
pub const VIEWS: [(&str, Panel); 15] = [
|
||||
("ui.view.assets", Panel::Assets),
|
||||
("ui.view.bakingLog", Panel::BakingLog),
|
||||
("ui.view.bakeMaps", Panel::MeshMapSettings),
|
||||
("ui.view.bakeSettings", Panel::CommonSettings),
|
||||
("ui.view.display", Panel::Display),
|
||||
@@ -74,7 +76,7 @@ impl Panel {
|
||||
pub(crate) fn available_in(self, mode: crate::state::Mode) -> bool {
|
||||
use crate::state::Mode;
|
||||
match self {
|
||||
Self::MeshMapSettings | Self::CommonSettings | Self::MeshMapBakers => mode == Mode::Baking,
|
||||
Self::MeshMapSettings | Self::CommonSettings | Self::MeshMapBakers | Self::BakingLog => mode == Mode::Baking,
|
||||
Self::Assets | Self::Layers | Self::Properties | Self::TextureSetSettings | Self::Export => mode == Mode::Painting,
|
||||
Self::History => mode != Mode::Rendering,
|
||||
Self::Shader => mode != Mode::Baking,
|
||||
@@ -83,7 +85,7 @@ impl Panel {
|
||||
}
|
||||
}
|
||||
|
||||
pub const ALL: [Panel; 15] = [
|
||||
pub const ALL: [Panel; 16] = [
|
||||
Panel::Viewport,
|
||||
Panel::Assets,
|
||||
Panel::MeshMapSettings,
|
||||
@@ -97,6 +99,7 @@ impl Panel {
|
||||
Panel::Shader,
|
||||
Panel::History,
|
||||
Panel::Log,
|
||||
Panel::BakingLog,
|
||||
Panel::Export,
|
||||
Panel::Renderer,
|
||||
];
|
||||
@@ -116,6 +119,7 @@ impl Panel {
|
||||
Panel::Shader => "Shader Settings",
|
||||
Panel::History => "History",
|
||||
Panel::Log => "Log",
|
||||
Panel::BakingLog => "Baking Log",
|
||||
Panel::Export => "Export",
|
||||
Panel::Renderer => "Renderer Settings",
|
||||
}
|
||||
@@ -130,6 +134,7 @@ impl Panel {
|
||||
Panel::Log => 3.0,
|
||||
Panel::Export => 4.0,
|
||||
Panel::Renderer => 5.0,
|
||||
Panel::BakingLog => 6.0,
|
||||
_ => return None,
|
||||
};
|
||||
Some([960.0, 90.0 + 50.0 * slot, 300.0, 380.0])
|
||||
@@ -524,6 +529,13 @@ pub(crate) fn panel_body(app: &mut TextureCraftApp, ui: &mut Ui, panel: Panel) {
|
||||
Panel::Shader => crate::shader_settings::body(app, ui),
|
||||
Panel::History => crate::windows::history(app, ui),
|
||||
Panel::Log => crate::log_panel::body(app, ui),
|
||||
Panel::BakingLog => {
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
for entry in app.session.log.entries().iter().filter(|entry| entry.source == "Baker") {
|
||||
ui.label(entry.line());
|
||||
}
|
||||
});
|
||||
}
|
||||
Panel::Export => crate::export_panel::body(app, ui),
|
||||
Panel::Renderer => crate::render_mode::settings_body(app, ui),
|
||||
Panel::Viewport => {}
|
||||
|
||||
@@ -423,13 +423,13 @@ pub(crate) fn ask(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let mut yes = false;
|
||||
let (title, text, yes_label, no_label) = match &question {
|
||||
Ask::Delete(name) => (
|
||||
tr("Delete template"),
|
||||
tr("Delete Template"),
|
||||
trf("Delete the template \"{name}\"? Its file is removed and this cannot be undone.", &[("name", name)]),
|
||||
tr("Delete"),
|
||||
tr("Cancel"),
|
||||
),
|
||||
Ask::Leave(_) => (
|
||||
tr("Unfinished template edit"),
|
||||
tr("Unfinished Template Edit"),
|
||||
trf(
|
||||
"The last edit of the template \"{name}\" is not saved: {error}. Switching away drops it.",
|
||||
&[("name", &app.ui.export.preset), ("error", &unfinished(app).unwrap_or_default())],
|
||||
@@ -438,27 +438,22 @@ pub(crate) fn ask(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
tr("Keep editing"),
|
||||
),
|
||||
};
|
||||
egui::Window::new(title)
|
||||
.id(egui::Id::unique("export_template_ask"))
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.anchor(egui::Align2::CENTER_CENTER, vec2(0.0, 0.0))
|
||||
.show(ctx, |ui| {
|
||||
ui.set_max_width(360.0);
|
||||
ui.label(text);
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
yes = ui.button(yes_label).clicked();
|
||||
cancel |= ui.button(no_label).clicked();
|
||||
});
|
||||
let mut open = true;
|
||||
crate::windows::dialog(ctx, "export_template_ask", title, &mut open).default_width(360.0).show(ctx, |ui| {
|
||||
ui.label(text);
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
yes = ui.button(yes_label).clicked();
|
||||
cancel |= ui.button(no_label).clicked();
|
||||
});
|
||||
});
|
||||
if yes {
|
||||
app.ui.export.ask = None;
|
||||
match question {
|
||||
Ask::Delete(name) => remove(app, name),
|
||||
Ask::Leave(act) => perform(app, ctx, act),
|
||||
}
|
||||
} else if cancel {
|
||||
} else if cancel || !open {
|
||||
app.ui.export.ask = None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,7 +717,7 @@ fn set_list(app: &mut TextureCraftApp, ui: &mut Ui) {
|
||||
}
|
||||
|
||||
// Many texture sets scroll inside the list; the footer stays in view
|
||||
let list_height = BODY_HEIGHT - header.rect.height() - ui.spacing().item_spacing.y;
|
||||
let list_height = ui.available_height();
|
||||
egui::ScrollArea::vertical().id_salt("export_texture_sets").max_height(list_height.max(0.0)).show(ui, |ui| set_rows(app, ui));
|
||||
}
|
||||
|
||||
@@ -1204,107 +1204,121 @@ pub fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let mut do_export = false;
|
||||
let mut canceled = false;
|
||||
let presets = texturecraft_engine::formats::builtin_presets();
|
||||
crate::windows::dialog("export_textures", tr("Export textures"), &mut open).fixed_size(vec2(900.0, 520.0)).show(ctx, |ui| {
|
||||
crate::windows::dialog(ctx, "export_textures", tr("Export Textures"), &mut open).default_size(vec2(900.0, BODY_HEIGHT + 80.0)).show(ctx, |ui| {
|
||||
// Nothing to export without a project
|
||||
if !app.session.project_open {
|
||||
ui.label(tr("No project is open"));
|
||||
return;
|
||||
}
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
for (i, t) in [tr("Settings"), tr("Output templates"), tr("List of exports")].iter().enumerate() {
|
||||
if ui.selectable_label(app.ui.export.tab == i as u8, caption(&t.to_uppercase())).clicked() {
|
||||
app.ui.export.tab = i as u8;
|
||||
}
|
||||
}
|
||||
|
||||
// The file list opens the destination folder
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if app.ui.export.tab == 2 {
|
||||
// The browser downloads the files instead
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
crate::unavailable::greyed(ui, |ui| ui.button(tr("Open output directory")));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if ui.button(tr("Open output directory")).clicked() {
|
||||
open_output_directory(app);
|
||||
}
|
||||
} else if ui.button(tr("Include all")).on_hover_text(tr("Select every texture set, UV tile and output map")).clicked() {
|
||||
app.ui.export.skip.clear();
|
||||
for o in app.ui.export.sets.values_mut() {
|
||||
o.maps.values_mut().for_each(|m| m.enabled = true);
|
||||
}
|
||||
app.ui.export.sets.retain(|_, o| !o.is_default());
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.allocate_ui_with_layout(vec2(ui.available_width(), BODY_HEIGHT), egui::Layout::left_to_right(egui::Align::Min), |ui| {
|
||||
ui.set_height(BODY_HEIGHT);
|
||||
match app.ui.export.tab {
|
||||
1 => {
|
||||
crate::export_templates::tab(app, ui, &presets);
|
||||
return;
|
||||
}
|
||||
2 => {
|
||||
list_tab(app, ui);
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(LIST_WIDTH);
|
||||
set_list(app, ui);
|
||||
});
|
||||
ui.separator();
|
||||
ui.vertical(|ui| match app.ui.export.page {
|
||||
Some(ts) if ts < app.session.set_count() => set_page(app, ui, ts, &presets),
|
||||
_ => global_page(app, ui, &presets),
|
||||
});
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.separator();
|
||||
|
||||
// While exporting: the progress and Cancel Export
|
||||
if let Some(job) = &app.ui.export.job {
|
||||
let done = job.total - job.pending.len();
|
||||
let progress = if job.total == 0 { 1.0 } else { done as f32 / job.total as f32 };
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if ui.button(tr("Cancel Export")).clicked() {
|
||||
app.ui.export.job = None;
|
||||
}
|
||||
let percent = format!("{:.0}%", progress * 100.0);
|
||||
ui.add(egui::ProgressBar::new(progress).text(percent));
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
|
||||
// While exporting: the progress and Cancel Export
|
||||
if let Some(job) = &app.ui.export.job {
|
||||
let done = job.total - job.pending.len();
|
||||
let progress = if job.total == 0 { 1.0 } else { done as f32 / job.total as f32 };
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if ui.button(tr("Cancel Export")).clicked() {
|
||||
app.ui.export.job = None;
|
||||
}
|
||||
let percent = format!("{:.0}%", progress * 100.0);
|
||||
ui.add(egui::ProgressBar::new(progress).text(percent));
|
||||
});
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
let selected = selected_texture_count(app);
|
||||
ui.horizontal(|ui| {
|
||||
// Not on LIST OF EXPORTS
|
||||
if app.ui.export.tab != 2 && ui.button(tr("Reset all")).on_hover_text(tr("Restore the export defaults and select every texture")).clicked()
|
||||
{
|
||||
// Keep ownership so Cancel can restore the opening settings
|
||||
let e = &mut app.ui.export;
|
||||
let (opened_with, owner, owner_id) = (e.opened_with.take(), std::mem::take(&mut e.owner), e.owner_id);
|
||||
app.ui.export = ExportUi { opened_with, owner, owner_id, ..ExportUi::default() };
|
||||
}
|
||||
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();
|
||||
if ui
|
||||
.add_enabled(any, primary_button(ui, tr("Export")))
|
||||
.on_hover_text(tr("Write the selected textures using the settings above"))
|
||||
.clicked()
|
||||
{
|
||||
do_export = true;
|
||||
}
|
||||
|
||||
let selected = selected_texture_count(app);
|
||||
ui.horizontal(|ui| {
|
||||
// Not on LIST OF EXPORTS
|
||||
if app.ui.export.tab != 2 && ui.button(tr("Reset all")).on_hover_text(tr("Restore the export defaults and select every texture")).clicked() {
|
||||
// Keep ownership so Cancel can restore the opening settings
|
||||
let e = &mut app.ui.export;
|
||||
let (opened_with, owner, owner_id) = (e.opened_with.take(), std::mem::take(&mut e.owner), e.owner_id);
|
||||
app.ui.export = ExportUi { opened_with, owner, owner_id, ..ExportUi::default() };
|
||||
// Saving closes the window without starting an export
|
||||
if ui.button(tr("Save settings")).on_hover_text(tr("Keep these settings for the next export")).clicked() {
|
||||
app.ui.windows.export = false;
|
||||
}
|
||||
if ui.button(tr("Cancel")).on_hover_text(tr("Restore the settings from when you opened this window")).clicked() {
|
||||
canceled = true;
|
||||
}
|
||||
ui.label(trf("{n} textures selected for export", &[("n", &selected)]));
|
||||
});
|
||||
});
|
||||
}
|
||||
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();
|
||||
if ui.add_enabled(any, primary_button(ui, tr("Export"))).on_hover_text(tr("Write the selected textures using the settings above")).clicked() {
|
||||
do_export = true;
|
||||
}
|
||||
ui.separator();
|
||||
ui.add_space(8.0);
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
for (i, t) in [tr("Settings"), tr("Output templates"), tr("List of exports")].iter().enumerate() {
|
||||
if ui.selectable_label(app.ui.export.tab == i as u8, caption(&t.to_uppercase())).clicked() {
|
||||
app.ui.export.tab = i as u8;
|
||||
}
|
||||
}
|
||||
|
||||
// Saving closes the window without starting an export
|
||||
if ui.button(tr("Save settings")).on_hover_text(tr("Keep these settings for the next export")).clicked() {
|
||||
app.ui.windows.export = false;
|
||||
}
|
||||
if ui.button(tr("Cancel")).on_hover_text(tr("Restore the settings from when you opened this window")).clicked() {
|
||||
canceled = true;
|
||||
}
|
||||
ui.label(trf("{n} textures selected for export", &[("n", &selected)]));
|
||||
// The file list opens the destination folder
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
if app.ui.export.tab == 2 {
|
||||
// The browser downloads the files instead
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
crate::unavailable::greyed(ui, |ui| ui.button(tr("Open output directory")));
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if ui.button(tr("Open output directory")).clicked() {
|
||||
open_output_directory(app);
|
||||
}
|
||||
} else if ui.button(tr("Include all")).on_hover_text(tr("Select every texture set, UV tile and output map")).clicked() {
|
||||
app.ui.export.skip.clear();
|
||||
for o in app.ui.export.sets.values_mut() {
|
||||
o.maps.values_mut().for_each(|m| m.enabled = true);
|
||||
}
|
||||
app.ui.export.sets.retain(|_, o| !o.is_default());
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
let body_height = ui.available_height().max(0.0);
|
||||
ui.allocate_ui_with_layout(vec2(ui.available_width(), body_height), egui::Layout::left_to_right(egui::Align::Min), |ui| {
|
||||
ui.set_height(body_height);
|
||||
match app.ui.export.tab {
|
||||
1 => {
|
||||
crate::export_templates::tab(app, ui, &presets);
|
||||
return;
|
||||
}
|
||||
2 => {
|
||||
list_tab(app, ui);
|
||||
return;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(LIST_WIDTH);
|
||||
set_list(app, ui);
|
||||
});
|
||||
ui.separator();
|
||||
ui.vertical(|ui| {
|
||||
egui::ScrollArea::both().id_salt("export_settings_page").auto_shrink([false, false]).min_scrolled_height(0.0).show(ui, |ui| match app
|
||||
.ui
|
||||
.export
|
||||
.page
|
||||
{
|
||||
Some(ts) if ts < app.session.set_count() => set_page(app, ui, ts, &presets),
|
||||
_ => global_page(app, ui, &presets),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -59,8 +59,7 @@ pub(crate) fn generator_properties(app: &mut TextureCraftApp, ui: &mut Ui, layer
|
||||
}
|
||||
if !app.session.doc.baked.contains_key(&app.session.ts()) {
|
||||
ui.label(
|
||||
RichText::new(format!("{} {}", ic::WARNING, tr("Bake mesh maps (Ctrl+Shift+B) for curvature, AO and thickness based generators.")))
|
||||
.color(tokens.warning),
|
||||
RichText::new(format!("{} {}", ic::WARNING, tr("Bake mesh maps (F8) for curvature, AO and thickness based generators."))).color(tokens.warning),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,113 +114,132 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let (mut import, mut cancel, mut add) = (std::mem::take(&mut window.confirm), false, false);
|
||||
let mut remove = false;
|
||||
|
||||
crate::windows::dialog("import_resources", tr("Import resources"), &mut open).default_width(WINDOW_WIDTH_POINTS).show(ctx, |ui| {
|
||||
ui.set_min_width(WINDOW_WIDTH_POINTS);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(tr("Choose files and assign their roles"));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.add_enabled_ui(!window.selected.is_empty(), |ui| {
|
||||
remove = ui.button(tr("Remove selected resources")).clicked();
|
||||
});
|
||||
add = ui.button(tr("Add resources")).clicked();
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
|
||||
let all_label = trf("All files ({count})", &[("count", &window.rows.len())]);
|
||||
let filter_text = match window.filter {
|
||||
None => all_label.clone(),
|
||||
Some(usage) => trf("{usage} ({count})", &[("usage", &usage.name()), ("count", &window.rows.iter().filter(|row| row.usage == usage).count())]),
|
||||
};
|
||||
egui::ComboBox::from_id_salt("import_filter").width(ui.available_width()).selected_text(filter_text).show_ui(ui, |ui| {
|
||||
if ui.selectable_label(window.filter.is_none(), &all_label).clicked() {
|
||||
window.filter = None;
|
||||
}
|
||||
|
||||
// Only usages some row has, so the list is never empty by filter
|
||||
for usage in ResourceUsage::ALL {
|
||||
let count = window.rows.iter().filter(|row| row.usage == usage).count();
|
||||
if count > 0 && ui.selectable_label(window.filter == Some(usage), format!("{} ({count})", usage.name())).clicked() {
|
||||
window.filter = Some(usage);
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
|
||||
let filter = window.filter;
|
||||
let visible = |row: &ImportRow| filter.is_none_or(|usage| row.usage == usage);
|
||||
let modifiers = ui.input(|i| i.modifiers);
|
||||
let mut clicked = None;
|
||||
|
||||
egui::ScrollArea::vertical().min_scrolled_height(LIST_HEIGHT_POINTS).max_height(LIST_HEIGHT_POINTS).auto_shrink([false, false]).show(ui, |ui| {
|
||||
for row in window.rows.iter_mut().filter(|row| visible(row)) {
|
||||
let material = is_material(row);
|
||||
let selected = window.selected.contains(&row.id);
|
||||
crate::windows::dialog(ctx, "import_resources", tr("Import Resources"), &mut open)
|
||||
.default_size(egui::vec2(WINDOW_WIDTH_POINTS, LIST_HEIGHT_POINTS + 200.0))
|
||||
.show(ctx, |ui| {
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
let name_width =
|
||||
(ui.available_width() - PREFIX_WIDTH_POINTS - USAGE_WIDTH_POINTS - 2.0 * ui.spacing().item_spacing.x).max(MIN_NAME_WIDTH_POINTS);
|
||||
let name = ui.add_sized([name_width, ui.spacing().interact_size.y], egui::Button::selectable(selected, file_name(row)).truncate());
|
||||
if name.on_hover_text(row.path.display().to_string()).clicked() {
|
||||
clicked = Some(row.id);
|
||||
}
|
||||
|
||||
let prefix = ui.add_enabled(
|
||||
!material,
|
||||
egui::TextEdit::singleline(&mut row.prefix).hint_text(tr("Optional prefix/path...")).desired_width(PREFIX_WIDTH_POINTS),
|
||||
);
|
||||
if material {
|
||||
prefix.on_disabled_hover_text(tr("Materials keep their own name"));
|
||||
} else {
|
||||
prefix.on_hover_text(tr("Put in front of the resource's name. Characters other than letters, digits and _ . - become _"));
|
||||
}
|
||||
|
||||
ui.add_enabled_ui(!material, |ui| {
|
||||
egui::ComboBox::from_id_salt(("import_usage", row.id)).width(USAGE_WIDTH_POINTS).selected_text(row.usage.name()).show_ui(ui, |ui| {
|
||||
for usage in ResourceUsage::ALL {
|
||||
let item = ui.add_enabled(usage.available(), egui::Button::selectable(row.usage == usage, usage.name()));
|
||||
if usage.available() {
|
||||
if item.clicked() {
|
||||
row.usage = usage;
|
||||
ui.close();
|
||||
}
|
||||
} else {
|
||||
item.on_disabled_hover_text(tr("Not available yet"));
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
cancel = ui.button(tr("Cancel")).clicked();
|
||||
import |= ui.add_enabled(app.session.project_open && !window.rows.is_empty(), primary_button(ui, tr("Import"))).clicked();
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
if !app.session.project_open {
|
||||
ui.label(tr("Open a project to import resources. Importing into the asset library is not available yet."));
|
||||
}
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
egui::ComboBox::from_id_salt("import_target").width(TARGET_WIDTH_POINTS).selected_text(tr("Open project")).show_ui(ui, |ui| {
|
||||
if ui.selectable_label(true, tr("Open project")).clicked() {
|
||||
ui.close();
|
||||
}
|
||||
|
||||
ui.add_enabled(false, egui::Button::selectable(false, tr("Asset library"))).on_disabled_hover_text(tr("Not available yet"));
|
||||
});
|
||||
})
|
||||
.response
|
||||
.on_disabled_hover_text(tr("Materials need no usage"));
|
||||
ui.label(tr("Destination"));
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(tr("Choose files and assign their roles"));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ui.add_enabled_ui(!window.selected.is_empty(), |ui| {
|
||||
remove = ui.button(tr("Remove selected resources")).clicked();
|
||||
});
|
||||
add = ui.button(tr("Add resources")).clicked();
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
|
||||
if let Some(id) = clicked {
|
||||
let visible: Vec<u64> = if modifiers.shift { window.rows.iter().filter(|row| visible(row)).map(|row| row.id).collect() } else { Vec::new() };
|
||||
click_row(&mut window, &visible, id, modifiers);
|
||||
}
|
||||
let all_label = trf("All files ({count})", &[("count", &window.rows.len())]);
|
||||
let filter_text = match window.filter {
|
||||
None => all_label.clone(),
|
||||
Some(usage) => {
|
||||
trf("{usage} ({count})", &[("usage", &usage.name()), ("count", &window.rows.iter().filter(|row| row.usage == usage).count())])
|
||||
}
|
||||
};
|
||||
egui::ComboBox::from_id_salt("import_filter").width(ui.available_width()).selected_text(filter_text).show_ui(ui, |ui| {
|
||||
if ui.selectable_label(window.filter.is_none(), &all_label).clicked() {
|
||||
window.filter = None;
|
||||
}
|
||||
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
egui::ComboBox::from_id_salt("import_target").width(TARGET_WIDTH_POINTS).selected_text(tr("Open project")).show_ui(ui, |ui| {
|
||||
if ui.selectable_label(true, tr("Open project")).clicked() {
|
||||
ui.close();
|
||||
// Only usages some row has, so the list is never empty by filter
|
||||
for usage in ResourceUsage::ALL {
|
||||
let count = window.rows.iter().filter(|row| row.usage == usage).count();
|
||||
if count > 0 && ui.selectable_label(window.filter == Some(usage), format!("{} ({count})", usage.name())).clicked() {
|
||||
window.filter = Some(usage);
|
||||
}
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
|
||||
let filter = window.filter;
|
||||
let visible = |row: &ImportRow| filter.is_none_or(|usage| row.usage == usage);
|
||||
let modifiers = ui.input(|i| i.modifiers);
|
||||
let mut clicked = None;
|
||||
|
||||
let list_height = ui.available_height().max(0.0);
|
||||
egui::ScrollArea::both().min_scrolled_width(0.0).min_scrolled_height(0.0).max_height(list_height).auto_shrink([false, false]).show(
|
||||
ui,
|
||||
|ui| {
|
||||
for row in window.rows.iter_mut().filter(|row| visible(row)) {
|
||||
let material = is_material(row);
|
||||
let selected = window.selected.contains(&row.id);
|
||||
ui.horizontal(|ui| {
|
||||
let name_width = (ui.available_width() - PREFIX_WIDTH_POINTS - USAGE_WIDTH_POINTS - 2.0 * ui.spacing().item_spacing.x)
|
||||
.max(MIN_NAME_WIDTH_POINTS);
|
||||
let name =
|
||||
ui.add_sized([name_width, ui.spacing().interact_size.y], egui::Button::selectable(selected, file_name(row)).truncate());
|
||||
if name.on_hover_text(row.path.display().to_string()).clicked() {
|
||||
clicked = Some(row.id);
|
||||
}
|
||||
|
||||
let prefix = ui.add_enabled(
|
||||
!material,
|
||||
egui::TextEdit::singleline(&mut row.prefix).hint_text(tr("Optional prefix/path...")).desired_width(PREFIX_WIDTH_POINTS),
|
||||
);
|
||||
if material {
|
||||
prefix.on_disabled_hover_text(tr("Materials keep their own name"));
|
||||
} else {
|
||||
prefix
|
||||
.on_hover_text(tr("Put in front of the resource's name. Characters other than letters, digits and _ . - become _"));
|
||||
}
|
||||
|
||||
ui.add_enabled_ui(!material, |ui| {
|
||||
egui::ComboBox::from_id_salt(("import_usage", row.id))
|
||||
.width(USAGE_WIDTH_POINTS)
|
||||
.selected_text(row.usage.name())
|
||||
.show_ui(ui, |ui| {
|
||||
for usage in ResourceUsage::ALL {
|
||||
let item = ui.add_enabled(usage.available(), egui::Button::selectable(row.usage == usage, usage.name()));
|
||||
if usage.available() {
|
||||
if item.clicked() {
|
||||
row.usage = usage;
|
||||
ui.close();
|
||||
}
|
||||
} else {
|
||||
item.on_disabled_hover_text(tr("Not available yet"));
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.response
|
||||
.on_disabled_hover_text(tr("Materials need no usage"));
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
if let Some(id) = clicked {
|
||||
let visible: Vec<u64> =
|
||||
if modifiers.shift { window.rows.iter().filter(|row| visible(row)).map(|row| row.id).collect() } else { Vec::new() };
|
||||
click_row(&mut window, &visible, id, modifiers);
|
||||
}
|
||||
|
||||
ui.add_enabled(false, egui::Button::selectable(false, tr("Asset library"))).on_disabled_hover_text(tr("Not available yet"));
|
||||
});
|
||||
ui.label(tr("Destination"));
|
||||
});
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
cancel = ui.button(tr("Cancel")).clicked();
|
||||
import |= ui.add_enabled(!window.rows.is_empty(), primary_button(ui, tr("Import"))).clicked();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if cancel || !open {
|
||||
return;
|
||||
@@ -250,7 +269,7 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
});
|
||||
}
|
||||
|
||||
if import && !window.rows.is_empty() {
|
||||
if import && app.session.project_open && !window.rows.is_empty() {
|
||||
window.rows.retain(|row| !import_row(app, row));
|
||||
if window.rows.is_empty() {
|
||||
app.ui.dock.focus(crate::docking::Panel::Assets);
|
||||
|
||||
@@ -55,7 +55,7 @@ const LISTED_SHORTCUTS: &[ShortcutListEntry] = &[
|
||||
ShortcutListEntry::new("ui.quit", "Quit application", Some("Ctrl+Q")),
|
||||
ShortcutListEntry::new("ui.export", "Export Textures...", Some("Ctrl+Shift+E")),
|
||||
ShortcutListEntry::new("file.reimportMesh", "Reimport mesh", Some("Ctrl+Shift+R")),
|
||||
ShortcutListEntry::new("ui.mode.bake", "Switch to baking mode", Some("Ctrl+Shift+B")),
|
||||
ShortcutListEntry::new("ui.mode.bake", "Switch to baking mode", Some("F8")),
|
||||
ShortcutListEntry::new("ui.mode.paint", "Switch to edition mode", Some("F9")),
|
||||
ShortcutListEntry::new("ui.mode.render", "Switch to rendering mode (path traced)", Some("F10")),
|
||||
ShortcutListEntry::new("ui.wireframe", "Show mesh wireframe", None),
|
||||
@@ -76,6 +76,11 @@ const LISTED_SHORTCUTS: &[ShortcutListEntry] = &[
|
||||
ShortcutListEntry::new("ui.layout.3d", "Viewers layout: 3D only", Some("F2")),
|
||||
ShortcutListEntry::new("ui.layout.2d", "Viewers layout: 2D only", Some("F3")),
|
||||
ShortcutListEntry::new("ui.layout.swap", "Viewers layout: Swap 3D/2D", Some("F4")),
|
||||
ShortcutListEntry::new("ui.layout.saveAs", "Save current layout as...", None),
|
||||
ShortcutListEntry::new("ui.layout.manage", "Manage layouts...", None),
|
||||
ShortcutListEntry::new("ui.resetPanelLayout", "Reset panel layout", None),
|
||||
ShortcutListEntry::new("ui.navButtons", "Navigation buttons", None),
|
||||
ShortcutListEntry::new("ui.uvChecker", "UV checker", None),
|
||||
];
|
||||
|
||||
/// The menu a command without a menu entry is listed under, from its id.
|
||||
@@ -515,7 +520,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
app.bindings.sync(&app.ui.keymap, craft_keymap::egui::platform(ctx));
|
||||
let mut filter: String = ctx.data(|d| d.get_temp(filter_id)).unwrap_or_default();
|
||||
let mut open = true;
|
||||
crate::windows::window("keyboard_shortcuts", tr("Keyboard shortcuts"), &mut open).default_width(480.0).show(ctx, |ui| {
|
||||
crate::windows::window("keyboard_shortcuts", tr("Keyboard Shortcuts"), &mut open).default_width(480.0).show(ctx, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(RichText::new(ic::MAGNIFYING_GLASS).color(tk.text_dim));
|
||||
ui.add(egui::TextEdit::singleline(&mut filter).hint_text(tr("Search commands or keys")).desired_width(300.0));
|
||||
|
||||
@@ -54,6 +54,8 @@ mod mask_preview_image;
|
||||
mod material_preview_image;
|
||||
pub mod menus;
|
||||
mod mesh_export_options;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod mode_layout;
|
||||
mod name_error;
|
||||
mod named_layout;
|
||||
pub mod named_layouts;
|
||||
@@ -90,6 +92,8 @@ mod running_bake;
|
||||
pub mod saved_search;
|
||||
mod screen_color_pick;
|
||||
mod section_page;
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
mod session_log_file;
|
||||
pub mod settings_window;
|
||||
pub mod shader_settings;
|
||||
pub mod shelf;
|
||||
@@ -191,6 +195,8 @@ pub struct Toast {
|
||||
|
||||
pub struct TextureCraftApp {
|
||||
pub session: Session,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub(crate) session_log_file: Option<session_log_file::SessionLogFile>,
|
||||
/// A smooth move to a saved camera in progress.
|
||||
camera_glide: Option<CameraGlide>,
|
||||
/// Yaw and pitch an Alt+Shift drag has reached before snapping to 90° steps (see `viewport`).
|
||||
@@ -304,6 +310,7 @@ impl TextureCraftApp {
|
||||
// The first run speaks the OS (or browser) language
|
||||
let mut ui_store = ui_state_store::UiStateStore::new(ui_state_store::FILE.get().cloned());
|
||||
let mut ui = start_ui(ui_store.load(cc.storage), &mut session);
|
||||
ui.trim_recent();
|
||||
|
||||
// No window opens by itself with no project (a saved layout may have left Export open)
|
||||
if !session.project_open {
|
||||
@@ -319,6 +326,8 @@ impl TextureCraftApp {
|
||||
uv_rotation_snap: None,
|
||||
uv_view_reset: false,
|
||||
session,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
session_log_file: None,
|
||||
ui,
|
||||
ui_store,
|
||||
gpu,
|
||||
@@ -371,6 +380,17 @@ impl TextureCraftApp {
|
||||
if cc.winit_window().is_none() {
|
||||
app.file_dialogs.without_window();
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if cc.winit_window().is_some() {
|
||||
let path = crate::data_dir()
|
||||
.join("logs")
|
||||
.join(format!("session-{}-{}", chrono::Utc::now().format("%Y%m%dT%H%M%S%.6fZ"), std::process::id()))
|
||||
.join("log.txt");
|
||||
match session_log_file::SessionLogFile::new(path) {
|
||||
Ok(file) => app.session_log_file = Some(file),
|
||||
Err(error) => app.toast(format!("{}: {error}", i18n::tr("Could not create the session log")), true),
|
||||
}
|
||||
}
|
||||
app.ui.rename = None;
|
||||
app.ui.windows.new_project = false;
|
||||
i18n::set_language(&app.ui.prefs.language);
|
||||
@@ -1037,6 +1057,13 @@ impl eframe::App for TextureCraftApp {
|
||||
}
|
||||
profile::drive(self, ctx);
|
||||
self.toasts.retain(|t| t.until > now);
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if let Some(file) = &mut self.session_log_file
|
||||
&& let Err(error) = file.sync(self.session.log_id, self.session.log.entries())
|
||||
{
|
||||
self.session_log_file = None;
|
||||
self.toast(format!("{}: {error}", i18n::tr("Could not update the session log")), true);
|
||||
}
|
||||
self.profiler.logic_ms = (now_ms() - t0) as f32;
|
||||
|
||||
// Last, so it sees every close request this frame's work made
|
||||
@@ -1057,9 +1084,7 @@ impl eframe::App for TextureCraftApp {
|
||||
titlebar::show(self, ui);
|
||||
banner(self, ui);
|
||||
toolbar::status_bar(self, ui);
|
||||
if self.ui.toolbar_tools {
|
||||
toolbar::tool_shelf(self, ui);
|
||||
}
|
||||
toolbar::tool_shelf(self, ui);
|
||||
self.ui.sync_mode_dock();
|
||||
if self.ui.mode != state::Mode::Baking && self.ui.toolbar_docks {
|
||||
toolbar::rail(self, ui);
|
||||
|
||||
+99
-101
@@ -2,7 +2,7 @@
|
||||
//! texture-painting workflow, with stable ids; an item is live when the engine (or the shell, for `ui.*` ids) implements
|
||||
//! its id. The same catalog drives `docs/parity.md`.
|
||||
|
||||
use egui::{Key, Modifiers};
|
||||
use egui::{Key, Modifiers, class::HasClasses as _};
|
||||
use serde_json::{Value, json};
|
||||
use texturecraft_engine::Tool;
|
||||
|
||||
@@ -36,38 +36,36 @@ pub const TOP: [&str; 6] = ["File", "Edit", "Mode", "Window", "Viewport", "Help"
|
||||
|
||||
/// The menu catalog (the target menu tree with our ids).
|
||||
pub const CATALOG: &[Item] = &[
|
||||
it("File", "New project...", "ui.newProject", Some("Ctrl+N")),
|
||||
it("File", "Open...", "file.open", Some("Ctrl+O")),
|
||||
it("File", "New Project", "ui.newProject", Some("Ctrl+N")),
|
||||
it("File", "Open", "file.open", Some("Ctrl+O")),
|
||||
sub("File", "Recent Projects", "Clear", "ui.recent.clear", None),
|
||||
sep("File"),
|
||||
it("File", "Open sample project...", "project.sample", None),
|
||||
it("File", "Open Sample Project", "project.sample", None),
|
||||
sep("File"),
|
||||
it("File", "Close", "file.close", Some("Ctrl+F4")),
|
||||
sep("File"),
|
||||
it("File", "Save", "file.save", Some("Ctrl+S")),
|
||||
it("File", "Save as...", "file.saveAs", Some("Ctrl+Shift+S")),
|
||||
sub("File", "More save options", "Save as template...", "ui.saveAsTemplate", None),
|
||||
sub("File", "More save options", "Save and reduce file size", "ui.saveReduced", None),
|
||||
sub("File", "More save options", "Save as copy...", "file.saveCopy", None),
|
||||
it("File", "Remove unused resources...", "file.removeUnused", None),
|
||||
it("File", "Save As", "file.saveAs", Some("Ctrl+Shift+S")),
|
||||
sub("File", "More Save Options", "Save As Template", "ui.saveAsTemplate", None),
|
||||
sub("File", "More Save Options", "Save and Reduce File Size", "ui.saveReduced", None),
|
||||
sub("File", "More Save Options", "Save As Copy", "file.saveCopy", None),
|
||||
it("File", "Remove Unused Resources", "file.removeUnused", None),
|
||||
sep("File"),
|
||||
it("File", "Import resources...", "resource.import", None),
|
||||
it("File", "Import MaterialX material...", "file.importMaterialX", None),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
it("File", "Import PBR texture folder...", "file.importPbrFolder", None),
|
||||
it("File", "Import material...", "material.load", None),
|
||||
it("File", "Export Textures...", "ui.export", Some("Ctrl+Shift+E")),
|
||||
it("File", "Export Mesh...", "file.exportMesh", None),
|
||||
it("File", "Import Resources", "resource.import", None),
|
||||
it("File", "Export Textures", "ui.export", Some("Ctrl+Shift+E")),
|
||||
it("File", "Export Mesh", "file.exportMesh", None),
|
||||
sep("File"),
|
||||
it("File", "Quit", "ui.quit", Some("Ctrl+Q")),
|
||||
it("Edit", "Undo", "edit.undo", Some("Ctrl+Z")),
|
||||
it("Edit", "Redo", "edit.redo", Some("Ctrl+Y")),
|
||||
it("Edit", "Project Configuration...", "ui.projectConfig", None),
|
||||
it("Edit", "Reimport mesh", "file.reimportMesh", Some("Ctrl+Shift+R")),
|
||||
it("Edit", "Settings...", "ui.settings", None),
|
||||
it("Mode", "Bake Mesh Maps", "ui.mode.bake", Some("Ctrl+Shift+B")),
|
||||
it("Edit", "Project Configuration", "ui.projectConfig", None),
|
||||
it("Edit", "Reimport Mesh", "file.reimportMesh", Some("Ctrl+Shift+R")),
|
||||
it("Edit", "Settings", "ui.settings", None),
|
||||
it("Mode", "Bake Mesh Maps", "ui.mode.bake", Some("F8")),
|
||||
it("Mode", "Painting", "ui.mode.paint", Some("F9")),
|
||||
it("Mode", "Rendering (path traced)", "ui.mode.render", Some("F10")),
|
||||
it("Mode", "Rendering", "ui.mode.render", Some("F10")),
|
||||
sub("Window", "Views", "Assets", "ui.view.assets", None),
|
||||
sub("Window", "Views", "Baking Log", "ui.view.bakingLog", None),
|
||||
sub("Window", "Views", "Common Settings", "ui.view.bakeSettings", None),
|
||||
sub("Window", "Views", "Display Settings", "ui.view.display", None),
|
||||
sub("Window", "Views", "Export", "ui.view.export", None),
|
||||
@@ -77,68 +75,43 @@ pub const CATALOG: &[Item] = &[
|
||||
sub("Window", "Views", "Mesh Map Bakers", "ui.view.meshMapBakers", None),
|
||||
sub("Window", "Views", "Mesh Map Settings", "ui.view.bakeMaps", None),
|
||||
sub("Window", "Views", "Properties", "ui.view.properties", None),
|
||||
sub("Window", "Views", "Python Console", "ui.view.pythonConsole", None),
|
||||
sub("Window", "Views", "Renderer Settings", "ui.view.renderer", None),
|
||||
sub("Window", "Views", "Shader Settings", "ui.view.shader", None),
|
||||
sub("Window", "Views", "Online assets", "ui.view.onlineAssets", None),
|
||||
sub("Window", "Views", "Texture Sets", "ui.view.textureSetList", None),
|
||||
sub("Window", "Views", "Texture Set List", "ui.view.textureSetList", None),
|
||||
sub("Window", "Views", "Texture Set Settings", "ui.view.textureSetSettings", None),
|
||||
sub("Window", "Toolbars", "Docks", "ui.toolbar.docks", None),
|
||||
sub("Window", "Toolbars", "Plugins", "ui.toolbar.plugins", None),
|
||||
sub("Window", "Toolbars", "Tools", "ui.toolbar.tools", None),
|
||||
sep("Window"),
|
||||
sub("Window", "Save UI Layout", "Painting mode", "ui.layout.save.painting", None),
|
||||
sub("Window", "Save UI Layout", "Rendering mode", "ui.layout.save.rendering", None),
|
||||
sub("Window", "Save UI Layout", "Baking mode", "ui.layout.save.baking", None),
|
||||
sub("Window", "Save UI Layout", "Painting Mode", "ui.layout.save.painting", None),
|
||||
sub("Window", "Save UI Layout", "Rendering Mode", "ui.layout.save.rendering", None),
|
||||
sub("Window", "Save UI Layout", "Baking Mode", "ui.layout.save.baking", None),
|
||||
it("Window", "Load UI Layout", "ui.layout.load", None),
|
||||
sub("Window", "Layouts", "Save current layout as...", "ui.layout.saveAs", None),
|
||||
sub("Window", "Layouts", "Manage layouts...", "ui.layout.manage", None),
|
||||
sep("Window"),
|
||||
it("Window", "Hide UI", "ui.hideUi", Some("Tab")),
|
||||
it("Window", "Reset panel layout", "ui.resetPanelLayout", None),
|
||||
it("Window", "Reset UI", "ui.resetUi", None),
|
||||
it("Viewport", "Display material", "viewport.displayMaterial", Some("M")),
|
||||
it("Viewport", "Display next channel", "viewport.nextChannel", Some("C")),
|
||||
it("Viewport", "Display previous channel", "viewport.previousChannel", Some("Shift+C")),
|
||||
it("Viewport", "Display next mesh map", "viewport.nextMeshMap", Some("B")),
|
||||
it("Viewport", "Display previous mesh map", "viewport.previousMeshMap", Some("Shift+B")),
|
||||
it("Viewport", "UV checker", "ui.uvChecker", None),
|
||||
it("Viewport", "Display Material", "viewport.displayMaterial", Some("M")),
|
||||
it("Viewport", "Display Next Channel", "viewport.nextChannel", Some("C")),
|
||||
it("Viewport", "Display Previous Channel", "viewport.previousChannel", Some("Shift+C")),
|
||||
it("Viewport", "Display Next Mesh Map", "viewport.nextMeshMap", Some("B")),
|
||||
it("Viewport", "Display Previous Mesh Map", "viewport.previousMeshMap", Some("Shift+B")),
|
||||
sep("Viewport"),
|
||||
it("Viewport", "Frame texture set", "viewport.frameSelection", Some("Shift+F")),
|
||||
it("Viewport", "Show entire mesh", "viewport.frame", Some("F")),
|
||||
it("Viewport", "Front view", "camera.view.front", None),
|
||||
it("Viewport", "Back view", "camera.view.back", None),
|
||||
it("Viewport", "Left view", "camera.view.left", None),
|
||||
it("Viewport", "Right view", "camera.view.right", None),
|
||||
it("Viewport", "Top view", "camera.view.top", None),
|
||||
it("Viewport", "Bottom view", "camera.view.bottom", None),
|
||||
it("Viewport", "Show Entire Mesh/Path", "viewport.frame", Some("F")),
|
||||
sep("Viewport"),
|
||||
it("Viewport", "Perspective", "camera.perspective", Some("F5")),
|
||||
it("Viewport", "Orthographic", "camera.orthographic", Some("F6")),
|
||||
sep("Viewport"),
|
||||
it("Viewport", "3D/2D views", "ui.layout.split", Some("F1")),
|
||||
it("Viewport", "3D view only", "ui.layout.3d", Some("F2")),
|
||||
it("Viewport", "2D view only", "ui.layout.2d", Some("F3")),
|
||||
it("Viewport", "Swap 3D/2D", "ui.layout.swap", Some("F4")),
|
||||
sep("Viewport"),
|
||||
it("Viewport", "Navigation buttons", "ui.navButtons", None),
|
||||
sep("Viewport"),
|
||||
it("Viewport", "Enable quick mask", "viewport.quickMask", Some("Y")),
|
||||
it("Viewport", "Edit quick mask", "viewport.quickMask.edit", Some("U")),
|
||||
it("Viewport", "Invert quick mask", "viewport.quickMask.invert", Some("Ctrl+Shift+I")),
|
||||
it("Help", "Release notes...", "ui.help.releaseNotes", None),
|
||||
it("Help", "Documentation...", "ui.help.docs", None),
|
||||
it("Help", "Shortcuts list...", "ui.help.shortcuts", None),
|
||||
it("Viewport", "Enable Quick Mask", "viewport.quickMask", Some("Y")),
|
||||
it("Viewport", "Edit Quick Mask", "viewport.quickMask.edit", Some("U")),
|
||||
it("Viewport", "Invert Quick Mask", "viewport.quickMask.invert", Some("Ctrl+Shift+I")),
|
||||
it("Help", "Release Notes", "ui.help.releaseNotes", None),
|
||||
it("Help", "Documentation", "ui.help.docs", None),
|
||||
it("Help", "Shortcuts List", "ui.help.shortcuts", None),
|
||||
sep("Help"),
|
||||
it("Help", "Join the community (Discord)...", "ui.help.discord", None),
|
||||
it("Help", "ArtCraft website...", "ui.help.website", None),
|
||||
it("Help", "Report a bug...", "ui.help.bug", None),
|
||||
it("Help", "Show log...", "ui.view.log", None),
|
||||
it("Help", "Export log...", "ui.help.exportLog", None),
|
||||
it("Help", "Discord", "ui.help.discord", None),
|
||||
it("Help", "Report a Bug", "ui.help.bug", None),
|
||||
it("Help", "Show Log", "ui.help.showLog", None),
|
||||
it("Help", "Export Log", "ui.help.exportLog", None),
|
||||
sep("Help"),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
it("Help", "Check for Updates...", "ui.help.checkForUpdates", None),
|
||||
it("Help", "About TextureCraft...", "ui.about", None),
|
||||
it("Help", "Check for Updates", "ui.help.checkForUpdates", None),
|
||||
it("Help", "About TextureCraft", "ui.about", None),
|
||||
];
|
||||
|
||||
/// Ids the shell handles itself.
|
||||
@@ -179,8 +152,17 @@ pub fn enabled(app: &TextureCraftApp, id: &str) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
if id == "ui.recent.clear" {
|
||||
return !app.ui.recent.is_empty();
|
||||
}
|
||||
// Opening the import dialog is independent of importing into a project.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if id == "resource.import" {
|
||||
return true;
|
||||
}
|
||||
if let Some(panel) = crate::docking::view_panel(id) {
|
||||
return panel.available_in(app.ui.mode);
|
||||
let mode = if app.session.project_open { app.ui.mode } else { Mode::Painting };
|
||||
return panel.available_in(mode);
|
||||
}
|
||||
|
||||
if app.ui.mode != Mode::Painting && (id.starts_with("tool.") || id.starts_with("viewport.quickMask")) {
|
||||
@@ -233,6 +215,7 @@ pub fn invoke(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) {
|
||||
}
|
||||
|
||||
match id {
|
||||
"ui.recent.clear" => app.ui.recent.clear(),
|
||||
"ui.newProject" => crate::new_project_advanced::open(app),
|
||||
"ui.export" => app.ui.windows.export = true,
|
||||
|
||||
@@ -274,7 +257,14 @@ pub fn invoke(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) {
|
||||
"ui.layout.3d" => app.ui.layout = ViewLayout::Only3D,
|
||||
"ui.layout.2d" => app.ui.layout = ViewLayout::Only2D,
|
||||
"ui.layout.swap" => app.ui.swap_views = !app.ui.swap_views,
|
||||
"ui.help.shortcuts" => app.ui.windows.shortcuts = true,
|
||||
"ui.help.shortcuts" => {
|
||||
app.ui.windows.shortcuts = false;
|
||||
app.ui.windows.settings = true;
|
||||
app.ui.windows.settings_page = crate::settings_window::SettingsPage::Shortcuts;
|
||||
if let Some(draft) = &mut app.ui.windows.settings_draft {
|
||||
draft.page = crate::settings_window::SettingsPage::Shortcuts;
|
||||
}
|
||||
}
|
||||
"ui.about" => app.ui.windows.about = true,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
"ui.help.checkForUpdates" => crate::updates_ui::request_check(app, ctx),
|
||||
@@ -282,6 +272,7 @@ pub fn invoke(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) {
|
||||
"ui.help.website" => ctx.open_url(egui::OpenUrl::new_tab("https://getartcraft.com/apps/texturecraft")),
|
||||
"ui.help.docs" => ctx.open_url(egui::OpenUrl::new_tab("https://github.com/storytold/texturecraft#readme")),
|
||||
"ui.help.releaseNotes" => ctx.open_url(egui::OpenUrl::new_tab("https://github.com/storytold/texturecraft/releases")),
|
||||
"ui.help.showLog" => crate::windows::show_log(app, ctx),
|
||||
"ui.help.exportLog" => crate::windows::export_log(app),
|
||||
"ui.help.bug" => ctx.open_url(egui::OpenUrl::new_tab("https://github.com/storytold/texturecraft/issues")),
|
||||
_ => {
|
||||
@@ -311,13 +302,23 @@ pub fn menu_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
|
||||
}
|
||||
|
||||
current_sub = Some(s);
|
||||
ui.menu_button(tr(s), |ui| {
|
||||
for x in items.iter().filter(|x| x.sub == Some(s)) {
|
||||
menu_item(app, &ctx, ui, x);
|
||||
}
|
||||
if s == "Layouts" {
|
||||
crate::named_layouts::entries(app, ui);
|
||||
}
|
||||
let submenu_enabled = s != "More Save Options" || app.session.project_open;
|
||||
ui.add_enabled_ui(submenu_enabled, |ui| {
|
||||
ui.menu_button((menu_mark(ui, None), tr(s)), |ui| {
|
||||
if s == "Recent Projects" {
|
||||
for path in app.ui.recent.clone() {
|
||||
if ui.button((menu_mark(ui, None), path.as_str())).clicked() {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
crate::windows::open_path(app, &path);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
for x in items.iter().filter(|x| x.sub == Some(s)) {
|
||||
menu_item(app, &ctx, ui, x);
|
||||
}
|
||||
})
|
||||
});
|
||||
continue;
|
||||
}
|
||||
@@ -342,12 +343,10 @@ pub fn menu_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
}
|
||||
|
||||
/// The check mark an item shows: the mode and view items, the toolbars and Hide UI (None: not checkable)
|
||||
/// The check mark an item shows: view items, toolbars and Hide UI (None: not checkable)
|
||||
pub fn checked(app: &TextureCraftApp, id: &str) -> Option<bool> {
|
||||
match id {
|
||||
"ui.mode.paint" => Some(app.ui.mode == Mode::Painting),
|
||||
"ui.mode.bake" => Some(app.ui.mode == Mode::Baking),
|
||||
"ui.mode.render" => Some(app.ui.mode == Mode::Rendering),
|
||||
"viewport.quickMask" => Some(!app.session.project_open || app.session.quick_mask.enabled),
|
||||
"ui.navButtons" => Some(app.ui.nav_buttons),
|
||||
"ui.hideUi" => Some(app.ui.hide_ui),
|
||||
"ui.toolbar.docks" => Some(app.ui.toolbar_docks),
|
||||
@@ -358,15 +357,32 @@ pub fn checked(app: &TextureCraftApp, id: &str) -> Option<bool> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Reserve the same checkmark column for actions, submenu headings and recent paths.
|
||||
fn menu_mark(ui: &egui::Ui, checked: Option<bool>) -> egui::Atom<'static> {
|
||||
egui::Atom::paint(egui::Vec2::splat(ui.spacing().icon_width), move |ui, args| {
|
||||
if checked == Some(true) {
|
||||
ui.painter().text(
|
||||
args.rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
egui_phosphor::regular::CHECK,
|
||||
egui::TextStyle::Button.resolve(ui.style()),
|
||||
args.fallback_text_color,
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn menu_item(app: &mut TextureCraftApp, ctx: &egui::Context, ui: &mut egui::Ui, item: &Item) {
|
||||
let on = enabled(app, item.id);
|
||||
let mut b = egui::Button::new(item_label(app, item));
|
||||
let checked = checked(app, item.id);
|
||||
let mut b = egui::Button::new((menu_mark(ui, checked), item_label(app, item)));
|
||||
if let Some(sc) = crate::keymap::shortcut_of(&app.ui.keymap, item.id) {
|
||||
b = b.shortcut_text(sc);
|
||||
}
|
||||
let checked = checked(app, item.id);
|
||||
if let Some(c) = checked {
|
||||
// Keep the accessible checked state; the checkmark supplies the visual state.
|
||||
b = b.selected(c);
|
||||
b.set_class(egui::Button::CLASS_SELECTED, false);
|
||||
}
|
||||
let mut response = ui.add_enabled(on, b);
|
||||
if let Some(tip) = tooltip_of(item.id) {
|
||||
@@ -379,24 +395,6 @@ fn menu_item(app: &mut TextureCraftApp, ctx: &egui::Context, ui: &mut egui::Ui,
|
||||
invoke(app, ctx, item.id);
|
||||
ui.close();
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if item.id == "file.open" {
|
||||
ui.add_enabled_ui(!app.ui.recent.is_empty(), |ui| {
|
||||
ui.menu_button(tr("Recent projects"), |ui| {
|
||||
for path in app.ui.recent.clone() {
|
||||
if ui.button(&path).clicked() {
|
||||
crate::windows::open_path(app, &path);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
if ui.button(tr("Clear recent projects")).clicked() {
|
||||
app.ui.recent.clear();
|
||||
ui.close();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// Global shortcuts: the catalog's and every engine command's (defaults or the user's keymap),
|
||||
|
||||
@@ -22,7 +22,7 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
|
||||
let mut open = true;
|
||||
let (mut export, mut cancel) = (false, false);
|
||||
crate::windows::dialog("mesh_export_options", tr("Mesh Export Options"), &mut open).show(ctx, |ui| {
|
||||
crate::windows::dialog(ctx, "mesh_export_options", tr("Mesh Export Options"), &mut open).show(ctx, |ui| {
|
||||
// TextureCraft exports the mesh as it is: triangulated, without displacement
|
||||
ui.add(egui::RadioButton::new(true, tr("Without displacement/tessellation")));
|
||||
option(ui, true, tr("Apply triangulation"));
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//! A layout file contains one mode's panels and view arrangement, never preferences or recent files.
|
||||
use crate::{
|
||||
docking::Dock,
|
||||
state::{Mode, UiState, ViewLayout},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub(crate) struct ModeLayout {
|
||||
pub mode: Mode,
|
||||
dock: Dock,
|
||||
layout: ViewLayout,
|
||||
swap_views: bool,
|
||||
split_ratio: f32,
|
||||
toolbar_docks: bool,
|
||||
toolbar_tools: bool,
|
||||
}
|
||||
|
||||
impl ModeLayout {
|
||||
pub fn of(ui: &UiState, mode: Mode) -> Self {
|
||||
let mut state = ui.clone();
|
||||
state.mode = mode;
|
||||
state.sync_mode_dock();
|
||||
Self {
|
||||
mode,
|
||||
dock: state.dock,
|
||||
layout: state.layout,
|
||||
swap_views: state.swap_views,
|
||||
split_ratio: state.split_ratio,
|
||||
toolbar_docks: state.toolbar_docks,
|
||||
toolbar_tools: state.toolbar_tools,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn apply(self, ui: &mut UiState) {
|
||||
ui.mode = self.mode;
|
||||
ui.sync_mode_dock();
|
||||
ui.dock = self.dock;
|
||||
ui.layout = self.layout;
|
||||
ui.swap_views = self.swap_views;
|
||||
ui.split_ratio = self.split_ratio;
|
||||
ui.toolbar_docks = self.toolbar_docks;
|
||||
ui.toolbar_tools = self.toolbar_tools;
|
||||
ui.rail_panel = None;
|
||||
}
|
||||
|
||||
pub fn read(bytes: &[u8]) -> Result<Self, String> {
|
||||
let value: serde_json::Value = serde_json::from_slice(bytes).map_err(|e| e.to_string())?;
|
||||
if value.get("windows").is_some() {
|
||||
let state: UiState = serde_json::from_value(value).map_err(|e| e.to_string())?;
|
||||
return Ok(Self::of(&state, state.mode));
|
||||
}
|
||||
let layout: Self = serde_json::from_value(value).map_err(|e| e.to_string())?;
|
||||
if !layout.split_ratio.is_finite() || !(0.0..=1.0).contains(&layout.split_ratio) || layout.dock.replaced_unreadable() {
|
||||
return Err("Invalid UI layout".into());
|
||||
}
|
||||
Ok(layout)
|
||||
}
|
||||
}
|
||||
@@ -30,7 +30,13 @@ impl UiState {
|
||||
return false;
|
||||
}
|
||||
|
||||
let (painting, baking) = if self.dock_is_baking { (&self.inactive_mode_dock, &self.dock) } else { (&self.dock, &self.inactive_mode_dock) };
|
||||
let (painting, baking) = if self.dock_is_baking {
|
||||
(&self.inactive_mode_dock, &self.dock)
|
||||
} else if self.dock_is_rendering {
|
||||
(self.inactive_render_dock.as_ref().unwrap_or(&self.dock), &self.inactive_mode_dock)
|
||||
} else {
|
||||
(&self.dock, &self.inactive_mode_dock)
|
||||
};
|
||||
let layout = NamedLayout { name: name.to_string(), painting: painting.clone(), baking: baking.clone() };
|
||||
match self.named_layout_index(name) {
|
||||
Some(index) => self.named_layouts[index] = layout,
|
||||
@@ -74,21 +80,6 @@ impl UiState {
|
||||
}
|
||||
}
|
||||
|
||||
/// One entry per saved layout, under the catalog's items of the Layouts submenu
|
||||
pub(crate) fn entries(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
|
||||
if app.ui.named_layouts.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
for name in app.ui.named_layouts.iter().map(|layout| layout.name.clone()).collect::<Vec<_>>() {
|
||||
if ui.button(&name).clicked() {
|
||||
app.ui.apply_named_layout(&name);
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The save, overwrite and manage dialogs
|
||||
pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
forget_finished_focus(app, ctx);
|
||||
@@ -136,7 +127,7 @@ fn focus_once(ui: &egui::Ui, edit: &egui::Response, key: &'static str, what: Str
|
||||
|
||||
fn save_dialog(app: &mut TextureCraftApp, ctx: &egui::Context, open: &mut bool, mut name: String) -> Option<LayoutDialog> {
|
||||
let mut done = None;
|
||||
dialog("save_layout", tr("Save layout"), open).show(ctx, |ui| {
|
||||
dialog(ctx, "save_layout", tr("Save Layout"), open).show(ctx, |ui| {
|
||||
ui.label(tr("Name of the layout"));
|
||||
let edit = ui.add(egui::TextEdit::singleline(&mut name).desired_width(240.0));
|
||||
focus_once(ui, &edit, SAVE_FOCUS, String::new());
|
||||
@@ -167,7 +158,7 @@ fn save_dialog(app: &mut TextureCraftApp, ctx: &egui::Context, open: &mut bool,
|
||||
|
||||
fn overwrite_dialog(app: &mut TextureCraftApp, ctx: &egui::Context, open: &mut bool, name: String) -> Option<LayoutDialog> {
|
||||
let mut answer = None;
|
||||
dialog("overwrite_layout", tr("Replace layout"), open).show(ctx, |ui| {
|
||||
dialog(ctx, "overwrite_layout", tr("Replace Layout"), open).show(ctx, |ui| {
|
||||
ui.label(trf("A layout named {name} already exists. Replace it?", &[("name", &name)]));
|
||||
ui.add_space(8.0);
|
||||
ui.horizontal(|ui| {
|
||||
@@ -199,7 +190,7 @@ fn manage_dialog(
|
||||
mut deleting: Option<String>,
|
||||
) -> Option<LayoutDialog> {
|
||||
let mut finished = false;
|
||||
dialog("manage_layouts", tr("Manage layouts"), open).show(ctx, |ui| {
|
||||
dialog(ctx, "manage_layouts", tr("Manage Layouts"), open).show(ctx, |ui| {
|
||||
ui.set_min_width(320.0);
|
||||
if let Some(name) = deleting.clone() {
|
||||
ui.label(trf("Delete the layout {name}?", &[("name", &name)]));
|
||||
|
||||
@@ -80,28 +80,43 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let mut open = true;
|
||||
let (mut create, mut cancel) = (false, false);
|
||||
|
||||
// A fixed height keeps the centered window still while its sections lay out
|
||||
// Start with a form that fits the viewport; subsequent sizes follow the user's resize.
|
||||
let form_height = (ctx.content_rect().height() - DIALOG_VIEWPORT_MARGIN_POINTS - DIALOG_CHROME_HEIGHT_POINTS)
|
||||
.clamp(crate::project_form::MIN_FORM_HEIGHT_POINTS, crate::project_form::FORM_HEIGHT_POINTS);
|
||||
dialog("new_project", tr("New project"), &mut open).default_width(DIALOG_WIDTH_POINTS).show(ctx, |ui| {
|
||||
ui.set_width(DIALOG_WIDTH_POINTS);
|
||||
egui::ScrollArea::vertical().id_salt("np_form").min_scrolled_height(form_height).max_height(form_height).auto_shrink([false, true]).show(ui, |ui| {
|
||||
basic_settings(app, ui);
|
||||
ui.add_space(8.0);
|
||||
advanced_settings(app, ui);
|
||||
});
|
||||
ui.separator();
|
||||
let can_create = app.ui.new_project.file.is_some();
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
create = ui
|
||||
.add_enabled(can_create, primary_button(ui, tr("Create")).min_size(vec2(BUTTON_WIDTH_POINTS, 0.0)))
|
||||
.on_disabled_hover_text(tr("Select a 3D mesh first"))
|
||||
.clicked();
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
dialog(ctx, "new_project", tr("New Project"), &mut open).default_size(vec2(DIALOG_WIDTH_POINTS, form_height + DIALOG_CHROME_HEIGHT_POINTS)).show(
|
||||
ctx,
|
||||
|ui| {
|
||||
// Lay out the actual footer first so it cannot make the window grow each frame.
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
|
||||
let can_create = app.ui.new_project.file.is_some();
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
create = ui
|
||||
.add_enabled(can_create, primary_button(ui, tr("Create")).min_size(vec2(BUTTON_WIDTH_POINTS, 0.0)))
|
||||
.on_disabled_hover_text(tr("Select a 3D mesh first"))
|
||||
.clicked();
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
let form_height = ui.available_height().max(0.0);
|
||||
egui::ScrollArea::both()
|
||||
.id_salt("np_form")
|
||||
.content_margin(crate::windows::dialog_scroll_margin(ui))
|
||||
.min_scrolled_width(0.0)
|
||||
.min_scrolled_height(0.0)
|
||||
.max_height(form_height)
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
basic_settings(app, ui);
|
||||
ui.add_space(8.0);
|
||||
advanced_settings(app, ui);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
if cancel || !open {
|
||||
app.ui.new_project.baked_maps = Vec::new();
|
||||
|
||||
@@ -100,7 +100,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
|
||||
let mut open = true;
|
||||
let (mut import_clicked, mut cancel_clicked) = (false, false);
|
||||
crate::windows::dialog("pbrImport", tr("Import PBR textures"), &mut open).show(ctx, |ui| {
|
||||
crate::windows::dialog(ctx, "pbrImport", tr("Import PBR Textures"), &mut open).show(ctx, |ui| {
|
||||
ui.set_min_width(380.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(tr("Layer name"));
|
||||
|
||||
@@ -137,142 +137,154 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let mut open = true;
|
||||
let (mut ok, mut cancel, mut select) = (std::mem::take(&mut config.confirm), false, false);
|
||||
|
||||
// A fixed height keeps the centered window still while its sections lay out
|
||||
// Start with a form that fits the viewport; subsequent sizes follow the user's resize.
|
||||
let form_height = (ctx.content_rect().height() - DIALOG_VIEWPORT_MARGIN_POINTS - DIALOG_CHROME_HEIGHT_POINTS)
|
||||
.clamp(crate::project_form::MIN_FORM_HEIGHT_POINTS, crate::project_form::FORM_HEIGHT_POINTS);
|
||||
let dialog = crate::windows::dialog("project_config", tr("Project configuration"), &mut open).default_width(DEFAULT_DIALOG_WIDTH_POINTS);
|
||||
let dialog = crate::windows::dialog(ctx, "project_config", tr("Project Configuration"), &mut open)
|
||||
.default_size(egui::vec2(DEFAULT_DIALOG_WIDTH_POINTS, form_height + DIALOG_CHROME_HEIGHT_POINTS));
|
||||
|
||||
dialog.show(ctx, |ui| {
|
||||
ui.set_width(DEFAULT_DIALOG_WIDTH_POINTS);
|
||||
egui::ScrollArea::vertical().id_salt("project_config_form").min_scrolled_height(form_height).max_height(form_height).auto_shrink([false, true]).show(ui, |ui| {
|
||||
// Keep the project sections in the order users expect
|
||||
ui.label(caption(tr("3D MESH")));
|
||||
ui.add_space(4.0);
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(ROW_INDENT_POINTS);
|
||||
ui.label(tr("3D mesh"));
|
||||
|
||||
let display_path = chosen_mesh.unwrap_or(mesh_label);
|
||||
let font = egui::TextStyle::Body.resolve(ui.style());
|
||||
let path_width_points = (ui.available_width() - SELECT_BUTTON_WIDTH_POINTS).max(MIN_FIELD_WIDTH_POINTS);
|
||||
let painter = ui.painter().clone();
|
||||
let measure = |text: &str| painter.layout_no_wrap(text.to_string(), font.clone(), egui::Color32::WHITE).rect.width() <= path_width_points;
|
||||
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
info_icon(ui, tr("The mesh file the project is built on. Select... chooses another one, read when you press OK."));
|
||||
select = ui.button(tr("Select...")).clicked();
|
||||
if display_path.is_empty() {
|
||||
ui.weak(tr("Built-in mesh"));
|
||||
} else {
|
||||
ui.label(elide_start(display_path, measure)).on_hover_text(display_path);
|
||||
}
|
||||
ok |= ui.add(primary_button(ui, tr("OK")).min_size(egui::vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(egui::vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
});
|
||||
});
|
||||
if chosen_mesh.is_none() && !current_mesh_path.is_empty() && !source_file_available {
|
||||
ui.colored_label(ui.visuals().error_fg_color, tr("File not found"));
|
||||
}
|
||||
|
||||
// A selected replacement always reads the mesh again
|
||||
// A missing source file cannot be reimported
|
||||
let mut reimport = config.reimport || chosen_mesh.is_some();
|
||||
let can_reimport_source = chosen_mesh.is_none() && source_file_available;
|
||||
let reimport_checkbox = check_row(
|
||||
ui,
|
||||
Some(tr("Read the mesh file again, keeping the layers and painted strokes")),
|
||||
|ui| ui.add_enabled(can_reimport_source, egui::Checkbox::new(&mut reimport, tr("Reimport mesh"))),
|
||||
|_| {},
|
||||
);
|
||||
|
||||
if can_reimport_source {
|
||||
config.reimport = reimport;
|
||||
} else if chosen_mesh.is_none() {
|
||||
reimport_checkbox.on_disabled_hover_text(tr("There is no mesh file to read again. Select one."));
|
||||
}
|
||||
|
||||
ui.add_space(12.0);
|
||||
ui.label(caption(tr("PROJECT SETTINGS")));
|
||||
ui.add_space(4.0);
|
||||
let shown_format = config.normal_format.unwrap_or(current_normal_format);
|
||||
row(
|
||||
ui,
|
||||
tr("Normal map format"),
|
||||
Some(tr("Green channel convention of normal maps: OpenGL (Y+) or DirectX (Y-). Imported and exported normal maps follow it.")),
|
||||
|ui| {
|
||||
egui::ComboBox::from_id_salt(tr("Normal map format"))
|
||||
.width(FIELD_WIDTH_POINTS)
|
||||
.wrap_mode(egui::TextWrapMode::Truncate)
|
||||
.selected_text(format_name(shown_format))
|
||||
.show_ui(ui, |ui| {
|
||||
for format in [NormalFormat::OpenGl, NormalFormat::DirectX] {
|
||||
if ui.selectable_label(format == shown_format, format_name(format)).clicked() {
|
||||
config.normal_format = (format != current_normal_format).then_some(format);
|
||||
ui.label(egui::RichText::new(tr("Changing the mesh or normal format can recalculate texture channels.")).color(Tokens::get(ui.ctx()).warning));
|
||||
ui.add_space(8.0);
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
let form_height = ui.available_height().max(0.0);
|
||||
let scroll = egui::ScrollArea::both()
|
||||
.id_salt("project_config_form")
|
||||
.content_margin(crate::windows::dialog_scroll_margin(ui))
|
||||
.min_scrolled_width(0.0)
|
||||
.min_scrolled_height(0.0)
|
||||
.max_height(form_height)
|
||||
.auto_shrink([false, false]);
|
||||
scroll.show(ui, |ui| {
|
||||
// Keep the project sections in the order users expect
|
||||
ui.label(caption(tr("3D MESH")));
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(ROW_INDENT_POINTS);
|
||||
ui.label(tr("3D mesh"));
|
||||
|
||||
let display_path = chosen_mesh.unwrap_or(mesh_label);
|
||||
let font = egui::TextStyle::Body.resolve(ui.style());
|
||||
let path_width_points = (ui.available_width() - SELECT_BUTTON_WIDTH_POINTS).max(MIN_FIELD_WIDTH_POINTS);
|
||||
let painter = ui.painter().clone();
|
||||
let measure = |text: &str| painter.layout_no_wrap(text.to_string(), font.clone(), egui::Color32::WHITE).rect.width() <= path_width_points;
|
||||
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
info_icon(ui, tr("The mesh file the project is built on. Select... chooses another one, read when you press OK."));
|
||||
select = ui.button(tr("Select...")).clicked();
|
||||
if display_path.is_empty() {
|
||||
ui.weak(tr("Built-in mesh"));
|
||||
} else {
|
||||
ui.label(elide_start(display_path, measure)).on_hover_text(display_path);
|
||||
}
|
||||
});
|
||||
});
|
||||
if chosen_mesh.is_none() && !current_mesh_path.is_empty() && !source_file_available {
|
||||
ui.colored_label(ui.visuals().error_fg_color, tr("File not found"));
|
||||
}
|
||||
|
||||
// A selected replacement always reads the mesh again
|
||||
// A missing source file cannot be reimported
|
||||
let mut reimport = config.reimport || chosen_mesh.is_some();
|
||||
let can_reimport_source = chosen_mesh.is_none() && source_file_available;
|
||||
let reimport_checkbox = check_row(
|
||||
ui,
|
||||
Some(tr("Read the mesh file again, keeping the layers and painted strokes")),
|
||||
|ui| ui.add_enabled(can_reimport_source, egui::Checkbox::new(&mut reimport, tr("Reimport mesh"))),
|
||||
|_| {},
|
||||
);
|
||||
|
||||
if can_reimport_source {
|
||||
config.reimport = reimport;
|
||||
} else if chosen_mesh.is_none() {
|
||||
reimport_checkbox.on_disabled_hover_text(tr("There is no mesh file to read again. Select one."));
|
||||
}
|
||||
|
||||
ui.add_space(12.0);
|
||||
ui.label(caption(tr("PROJECT SETTINGS")));
|
||||
ui.add_space(4.0);
|
||||
let shown_format = config.normal_format.unwrap_or(current_normal_format);
|
||||
row(
|
||||
ui,
|
||||
tr("Normal map format"),
|
||||
Some(tr("Green channel convention of normal maps: OpenGL (Y+) or DirectX (Y-). Imported and exported normal maps follow it.")),
|
||||
|ui| {
|
||||
egui::ComboBox::from_id_salt(tr("Normal map format"))
|
||||
.width(FIELD_WIDTH_POINTS)
|
||||
.wrap_mode(egui::TextWrapMode::Truncate)
|
||||
.selected_text(format_name(shown_format))
|
||||
.show_ui(ui, |ui| {
|
||||
for format in [NormalFormat::OpenGl, NormalFormat::DirectX] {
|
||||
if ui.selectable_label(format == shown_format, format_name(format)).clicked() {
|
||||
config.normal_format = (format != current_normal_format).then_some(format);
|
||||
}
|
||||
}
|
||||
})
|
||||
.response
|
||||
.on_hover_text(tr(
|
||||
"For the whole project: how normal map images set as mesh maps are read (set them again after a change), and the default for export",
|
||||
));
|
||||
},
|
||||
);
|
||||
tangent_space_row(ui);
|
||||
|
||||
// Texture Set Settings owns UV tile changes
|
||||
ui.add_space(4.0);
|
||||
sub_title(ui, tr("UV Tile settings (UDIMs)"), Some(tr("View the UV tiles assigned to each texture set")));
|
||||
let tiles_hint = tr("Change the UV tiles of a texture set in Texture Set Settings");
|
||||
note(ui, tiles_hint);
|
||||
let mut has_tiles = project.texture_sets.iter().any(|set| !set.uv_tiles.is_empty());
|
||||
|
||||
check_row(ui, None, |ui| ui.add_enabled(false, egui::Checkbox::new(&mut has_tiles, tr("Use UV Tile workflow"))), |_| {})
|
||||
.on_disabled_hover_ui(|ui| {
|
||||
ui.set_max_width(ui.spacing().tooltip_width);
|
||||
if !has_tiles {
|
||||
ui.label(tr("No UV tiles"));
|
||||
}
|
||||
|
||||
for set in project.texture_sets.iter().filter(|set| !set.uv_tiles.is_empty()) {
|
||||
let tiles = set.uv_tiles.iter().map(u32::to_string).collect::<Vec<_>>().join(", ");
|
||||
if project.texture_sets.len() > 1 {
|
||||
ui.label(trf("{set}: {tiles}", &[("set", &set.name), ("tiles", &tiles)]));
|
||||
} else {
|
||||
ui.label(tiles);
|
||||
}
|
||||
}
|
||||
})
|
||||
.response
|
||||
.on_hover_text(tr(
|
||||
"For the whole project: how normal map images set as mesh maps are read (set them again after a change), and the default for export",
|
||||
));
|
||||
},
|
||||
);
|
||||
tangent_space_row(ui);
|
||||
});
|
||||
uv_tile_radios(ui, false, tiles_hint);
|
||||
|
||||
// Texture Set Settings owns UV tile changes
|
||||
ui.add_space(4.0);
|
||||
sub_title(ui, tr("UV Tile settings (UDIMs)"), Some(tr("View the UV tiles assigned to each texture set")));
|
||||
let tiles_hint = tr("Change the UV tiles of a texture set in Texture Set Settings");
|
||||
note(ui, tiles_hint);
|
||||
let mut has_tiles = project.texture_sets.iter().any(|set| !set.uv_tiles.is_empty());
|
||||
ui.add_space(4.0);
|
||||
sub_title(ui, tr("Import settings"), None);
|
||||
check_row(
|
||||
ui,
|
||||
Some(tr("Keep the cameras stored in the mesh file")),
|
||||
|ui| unavailable(ui.add_enabled(false, egui::Checkbox::new(&mut false, tr("Import cameras")))),
|
||||
|_| {},
|
||||
);
|
||||
|
||||
check_row(ui, None, |ui| ui.add_enabled(false, egui::Checkbox::new(&mut has_tiles, tr("Use UV Tile workflow"))), |_| {})
|
||||
.on_disabled_hover_ui(|ui| {
|
||||
ui.set_max_width(ui.spacing().tooltip_width);
|
||||
if !has_tiles {
|
||||
ui.label(tr("No UV tiles"));
|
||||
}
|
||||
// Import settings matter only when a mesh will be read
|
||||
let importing = chosen_mesh.is_some() || (config.reimport && source_file_available);
|
||||
check_row(
|
||||
ui,
|
||||
Some(tr("Painted strokes follow the surface when the new mesh's UVs differ")),
|
||||
|ui| ui.add_enabled(importing, egui::Checkbox::new(&mut config.preserve, tr("Preserve stroke positions on mesh"))),
|
||||
|_| {},
|
||||
);
|
||||
auto_unwrap_row(ui);
|
||||
|
||||
for set in project.texture_sets.iter().filter(|set| !set.uv_tiles.is_empty()) {
|
||||
let tiles = set.uv_tiles.iter().map(u32::to_string).collect::<Vec<_>>().join(", ");
|
||||
if project.texture_sets.len() > 1 {
|
||||
ui.label(trf("{set}: {tiles}", &[("set", &set.name), ("tiles", &tiles)]));
|
||||
} else {
|
||||
ui.label(tiles);
|
||||
}
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
physical_size(ui, "project_config_physical_size", false);
|
||||
color_management(ui, "project_config_color_management", &mut config.color_management);
|
||||
});
|
||||
uv_tile_radios(ui, false, tiles_hint);
|
||||
|
||||
ui.add_space(4.0);
|
||||
sub_title(ui, tr("Import settings"), None);
|
||||
check_row(
|
||||
ui,
|
||||
Some(tr("Keep the cameras stored in the mesh file")),
|
||||
|ui| unavailable(ui.add_enabled(false, egui::Checkbox::new(&mut false, tr("Import cameras")))),
|
||||
|_| {},
|
||||
);
|
||||
|
||||
// Import settings matter only when a mesh will be read
|
||||
let importing = chosen_mesh.is_some() || (config.reimport && source_file_available);
|
||||
check_row(
|
||||
ui,
|
||||
Some(tr("Painted strokes follow the surface when the new mesh's UVs differ")),
|
||||
|ui| ui.add_enabled(importing, egui::Checkbox::new(&mut config.preserve, tr("Preserve stroke positions on mesh"))),
|
||||
|_| {},
|
||||
);
|
||||
auto_unwrap_row(ui);
|
||||
|
||||
ui.add_space(4.0);
|
||||
physical_size(ui, "project_config_physical_size", false);
|
||||
color_management(ui, "project_config_color_management", &mut config.color_management);
|
||||
});
|
||||
|
||||
ui.add_space(8.0);
|
||||
ui.label(egui::RichText::new(tr("Changing the mesh or normal format can recalculate texture channels.")).color(Tokens::get(ui.ctx()).warning));
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
ok |= ui.add(primary_button(ui, tr("OK")).min_size(egui::vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(egui::vec2(BUTTON_WIDTH_POINTS, 0.0))).clicked();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//! The current desktop run's rolling log, separate from the clearable Log panel.
|
||||
use std::{
|
||||
fs::{File, OpenOptions},
|
||||
io::{self, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
use texturecraft_engine::LogEntry;
|
||||
|
||||
pub(crate) struct SessionLogFile {
|
||||
pub path: PathBuf,
|
||||
file: File,
|
||||
bytes: u64,
|
||||
log_id: u64,
|
||||
cursor: usize,
|
||||
last: Option<LogEntry>,
|
||||
}
|
||||
|
||||
impl SessionLogFile {
|
||||
pub fn new(path: PathBuf) -> io::Result<Self> {
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent)?;
|
||||
}
|
||||
let file = OpenOptions::new().create_new(true).append(true).open(&path)?;
|
||||
Ok(Self { path, file, bytes: 0, log_id: 0, cursor: 0, last: None })
|
||||
}
|
||||
|
||||
pub fn text(&mut self) -> io::Result<String> {
|
||||
self.file.flush()?;
|
||||
let previous = self.path.with_file_name("log.previous.txt");
|
||||
let mut text = match std::fs::read_to_string(previous) {
|
||||
Ok(text) => text,
|
||||
Err(error) if error.kind() == io::ErrorKind::NotFound => String::new(),
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
text.push_str(&std::fs::read_to_string(&self.path)?);
|
||||
Ok(text)
|
||||
}
|
||||
|
||||
pub fn sync(&mut self, log_id: u64, entries: &[LogEntry]) -> io::Result<()> {
|
||||
let same_tail = self.log_id == log_id && self.cursor.checked_sub(1).and_then(|i| entries.get(i)) == self.last.as_ref();
|
||||
if same_tail && self.cursor == entries.len() {
|
||||
return Ok(());
|
||||
}
|
||||
let start = if same_tail { self.cursor } else { 0 };
|
||||
for entry in entries.get(start..).unwrap_or_default() {
|
||||
// Clearing lines in the panel must not append the remaining old lines twice.
|
||||
if self.log_id == log_id && self.last.as_ref().is_some_and(|last| entry.time <= last.time) {
|
||||
continue;
|
||||
}
|
||||
let text = crate::windows::log_text(std::slice::from_ref(entry));
|
||||
let line = text.split_once('\n').map(|(_, line)| line).unwrap_or_default();
|
||||
// Bound each run's disk use. Keep one previous segment when the active log rolls.
|
||||
if self.bytes.saturating_add(line.len() as u64) > 8 * 1024 * 1024 {
|
||||
self.file.flush()?;
|
||||
std::fs::copy(&self.path, self.path.with_file_name("log.previous.txt"))?;
|
||||
self.file.set_len(0)?;
|
||||
self.bytes = 0;
|
||||
}
|
||||
self.file.write_all(line.as_bytes())?;
|
||||
self.bytes = self.bytes.saturating_add(line.len() as u64);
|
||||
}
|
||||
self.file.flush()?;
|
||||
self.log_id = log_id;
|
||||
self.cursor = entries.len();
|
||||
if let Some(last) = entries.last() {
|
||||
self.last = Some(last.clone());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use texturecraft_engine::{LogLevel, SessionLog};
|
||||
|
||||
#[test]
|
||||
fn log_file_keeps_messages_after_panel_clear_and_across_projects() {
|
||||
let dir = std::env::temp_dir().join(format!("texturecraft-session-log-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let path = dir.join(format!("{}.txt", chrono::Utc::now().timestamp_nanos_opt().unwrap()));
|
||||
let mut file = SessionLogFile::new(path.clone()).unwrap();
|
||||
let mut log = SessionLog::new();
|
||||
log.push("first".into());
|
||||
file.sync(1, log.entries()).unwrap();
|
||||
file.sync(1, log.entries()).unwrap();
|
||||
log.clear();
|
||||
file.sync(1, log.entries()).unwrap();
|
||||
log.error("UI", "second");
|
||||
file.sync(1, log.entries()).unwrap();
|
||||
file.sync(2, &[LogEntry::new(LogLevel::Info, "UI", "new project")]).unwrap();
|
||||
let text = std::fs::read_to_string(&path).unwrap();
|
||||
assert_eq!(text.matches("first").count(), 1);
|
||||
assert!(text.contains("second") && text.contains("new project"));
|
||||
drop(file);
|
||||
std::fs::remove_file(path).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -75,77 +75,84 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
crate::keymap::follow(&mut app.settings_bindings, &draft.keymap, ctx);
|
||||
let shortcut_conflict = crate::keymap::has_conflict(&app.settings_bindings);
|
||||
|
||||
crate::windows::window("settings", tr("Settings"), &mut open).resizable(false).show(ctx, |ui| {
|
||||
// Keep the footer inside the viewport when the fixed-width controls need to scroll
|
||||
ui.set_max_width(content_width);
|
||||
ui.horizontal_top(|ui| {
|
||||
egui::ScrollArea::vertical().id_salt("settings_navigation").min_scrolled_height(0.0).max_height(page_height).show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(PAGE_BUTTON.x);
|
||||
for page in SettingsPage::ALL {
|
||||
let warn = page == SettingsPage::Shortcuts && shortcut_conflict;
|
||||
if page_button(ui, page, draft.page == page, warn).clicked() {
|
||||
draft.page = page;
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
crate::windows::window("settings", tr("Settings"), &mut open)
|
||||
.default_size(vec2(content_width + frame_width, page_height + WINDOW_CHROME_HEIGHT_POINTS))
|
||||
.show(ctx, |ui| {
|
||||
// Measure the footer through layout, then let the pages use only what remains.
|
||||
ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| {
|
||||
// Recheck after drawing the page as well, before accepting any edits.
|
||||
let conflict = crate::keymap::has_conflict(&app.settings_bindings);
|
||||
ui.horizontal(|ui| {
|
||||
if conflict {
|
||||
let danger = Tokens::get(ui.ctx()).danger;
|
||||
ui.label(RichText::new(format!("{} {}", ic::WARNING, tr(SHORTCUT_ERRORS))).color(danger));
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(vec2(100.0, 0.0))).clicked();
|
||||
ok = ui.add_enabled(!conflict, egui::Button::new(tr("OK")).min_size(vec2(100.0, 0.0))).clicked();
|
||||
});
|
||||
});
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
egui::ScrollArea::both()
|
||||
.id_salt(("settings_page", draft.page as u8))
|
||||
.auto_shrink([false, false])
|
||||
.min_scrolled_width(0.0)
|
||||
.min_scrolled_height(page_height)
|
||||
.max_height(page_height)
|
||||
.show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(PAGE_WIDTH);
|
||||
match draft.page {
|
||||
SettingsPage::General => {
|
||||
general(
|
||||
ui,
|
||||
&mut draft.prefs,
|
||||
&drawable,
|
||||
gpu.as_deref(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
resources,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
&mut pick,
|
||||
);
|
||||
}
|
||||
SettingsPage::Shortcuts => {
|
||||
crate::keymap::actions_page(ui, &mut draft.keymap, &app.bindings, &mut app.settings_bindings);
|
||||
}
|
||||
SettingsPage::Libraries => {
|
||||
libraries(
|
||||
ui,
|
||||
&mut draft,
|
||||
project_open,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
&mut pick,
|
||||
);
|
||||
}
|
||||
}
|
||||
ui.separator();
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Min), |ui| {
|
||||
let page_height = ui.available_height().max(0.0);
|
||||
ui.horizontal_top(|ui| {
|
||||
egui::ScrollArea::vertical().id_salt("settings_navigation").min_scrolled_height(0.0).max_height(page_height).show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(PAGE_BUTTON.x);
|
||||
for page in SettingsPage::ALL {
|
||||
let warn = page == SettingsPage::Shortcuts && shortcut_conflict;
|
||||
if page_button(ui, page, draft.page == page, warn).clicked() {
|
||||
draft.page = page;
|
||||
}
|
||||
ui.add_space(6.0);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
egui::ScrollArea::both()
|
||||
.id_salt(("settings_page", draft.page as u8))
|
||||
.content_margin(crate::windows::dialog_scroll_margin(ui))
|
||||
.auto_shrink([false, false])
|
||||
.min_scrolled_width(0.0)
|
||||
.min_scrolled_height(0.0)
|
||||
.max_height(page_height)
|
||||
.show(ui, |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_min_width(PAGE_WIDTH);
|
||||
match draft.page {
|
||||
SettingsPage::General => {
|
||||
general(
|
||||
ui,
|
||||
&mut draft.prefs,
|
||||
&drawable,
|
||||
gpu.as_deref(),
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
resources,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
&mut pick,
|
||||
);
|
||||
}
|
||||
SettingsPage::Shortcuts => {
|
||||
crate::keymap::actions_page(ui, &mut draft.keymap, &app.bindings, &mut app.settings_bindings);
|
||||
}
|
||||
SettingsPage::Libraries => {
|
||||
libraries(
|
||||
ui,
|
||||
&mut draft,
|
||||
project_open,
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
&mut pick,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
ui.separator();
|
||||
|
||||
// The page has brought the checker up to date, so OK follows this frame's edits
|
||||
let conflict = crate::keymap::has_conflict(&app.settings_bindings);
|
||||
ui.horizontal(|ui| {
|
||||
if conflict {
|
||||
let danger = Tokens::get(ui.ctx()).danger;
|
||||
ui.label(RichText::new(format!("{} {}", ic::WARNING, tr(SHORTCUT_ERRORS))).color(danger));
|
||||
}
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(vec2(100.0, 0.0))).clicked();
|
||||
ok = ui.add_enabled(!conflict, egui::Button::new(tr("OK")).min_size(vec2(100.0, 0.0))).clicked();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
ok &= !crate::keymap::has_conflict(&app.settings_bindings);
|
||||
app.ui.windows.settings_page = draft.page;
|
||||
if draft.page != SettingsPage::Shortcuts || ok || cancel || !open {
|
||||
crate::keymap::stop_settings_capture(ctx);
|
||||
@@ -169,6 +176,7 @@ fn apply(app: &mut TextureCraftApp, draft: SettingsDraft) {
|
||||
let previous_autosave_minutes = app.ui.prefs.autosave_minutes;
|
||||
|
||||
app.ui.prefs = draft.prefs;
|
||||
app.ui.trim_recent();
|
||||
app.reschedule_autosave_if_changed(previous_autosave_minutes);
|
||||
|
||||
let ids: std::collections::BTreeSet<&String> = draft.keymap.keys().chain(draft.keymap_at_open.keys()).collect();
|
||||
@@ -354,6 +362,12 @@ fn general(
|
||||
});
|
||||
});
|
||||
|
||||
row(ui, tr("Recent projects limit"), |ui, label| {
|
||||
ui.add(egui::DragValue::new(&mut p.recent_projects_limit).range(0..=100))
|
||||
.labelled_by(label)
|
||||
.on_hover_text(tr("Number of recent projects to remember. 0 disables recent-project history."));
|
||||
});
|
||||
|
||||
section(ui, n_("LAYER STACK OPTIONS"));
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(12.0);
|
||||
|
||||
@@ -146,6 +146,8 @@ pub struct Prefs {
|
||||
pub ui_scale: f32,
|
||||
/// Minutes between autosaves of a modified project (0: off; desktop).
|
||||
pub autosave_minutes: u32,
|
||||
/// Maximum recent projects retained (0 disables the history, capped at 100).
|
||||
pub recent_projects_limit: u16,
|
||||
/// UI language code (`i18n::LANGUAGES`), or `i18n::SYSTEM_LANGUAGE` to follow the system.
|
||||
pub language: String,
|
||||
/// Viewport texture resolution: 0 full, 1 half, 2 quarter of each texture set's size (lighter
|
||||
@@ -197,6 +199,7 @@ impl Default for Prefs {
|
||||
Prefs {
|
||||
ui_scale: 1.0,
|
||||
autosave_minutes: 10,
|
||||
recent_projects_limit: 10,
|
||||
language: "en".into(),
|
||||
viewport_texture: 0,
|
||||
brightness: crate::theme::Brightness::default(),
|
||||
@@ -502,6 +505,11 @@ pub struct UiState {
|
||||
pub(crate) inactive_mode_dock: Dock,
|
||||
#[serde(default)]
|
||||
pub(crate) dock_is_baking: bool,
|
||||
/// Rendering's saved dock, or Painting's while Rendering is active. Older states start from Painting.
|
||||
#[serde(default)]
|
||||
pub(crate) inactive_render_dock: Option<Dock>,
|
||||
#[serde(default)]
|
||||
pub(crate) dock_is_rendering: bool,
|
||||
/// Window ▸ Toolbars ▸ Docks: the right bar of panel icons
|
||||
#[serde(default = "default_true")]
|
||||
pub toolbar_docks: bool,
|
||||
@@ -615,8 +623,20 @@ pub struct UiState {
|
||||
}
|
||||
|
||||
impl UiState {
|
||||
/// Keep recent-file history bounded, including values supplied through automation or old settings.
|
||||
pub(crate) fn trim_recent(&mut self) {
|
||||
self.prefs.recent_projects_limit = self.prefs.recent_projects_limit.min(100);
|
||||
self.recent.truncate(usize::from(self.prefs.recent_projects_limit));
|
||||
}
|
||||
|
||||
/// Replace an outdated or unreadable saved bake dock by the bake layout, then give the mode its dock
|
||||
pub(crate) fn sync_mode_dock(&mut self) {
|
||||
if self.dock_is_rendering {
|
||||
if let Some(other) = self.inactive_render_dock.as_mut() {
|
||||
std::mem::swap(&mut self.dock, other);
|
||||
}
|
||||
self.dock_is_rendering = false;
|
||||
}
|
||||
self.reset_outdated_bake_dock();
|
||||
|
||||
let baking = self.mode == Mode::Baking;
|
||||
@@ -624,6 +644,11 @@ impl UiState {
|
||||
std::mem::swap(&mut self.dock, &mut self.inactive_mode_dock);
|
||||
self.dock_is_baking = baking;
|
||||
}
|
||||
if self.mode == Mode::Rendering {
|
||||
let other = self.inactive_render_dock.get_or_insert_with(|| self.dock.clone());
|
||||
std::mem::swap(&mut self.dock, other);
|
||||
self.dock_is_rendering = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Replace a bake dock saved with an older bake layout, or one that could not be read, by the bake default
|
||||
@@ -642,6 +667,7 @@ impl UiState {
|
||||
pub fn reset_panel_layout(&mut self) {
|
||||
let (painting, baking) = (Dock::default(), Dock::for_baking());
|
||||
(self.dock, self.inactive_mode_dock) = if self.dock_is_baking { (baking, painting) } else { (painting, baking) };
|
||||
self.inactive_render_dock = self.dock_is_rendering.then(Dock::default);
|
||||
self.bake_layout_version = BAKE_LAYOUT_VERSION;
|
||||
self.rail_panel = None;
|
||||
}
|
||||
@@ -690,6 +716,8 @@ impl Default for UiState {
|
||||
rail_panel: None,
|
||||
inactive_mode_dock: Dock::for_baking(),
|
||||
dock_is_baking: false,
|
||||
inactive_render_dock: None,
|
||||
dock_is_rendering: false,
|
||||
toolbar_docks: true,
|
||||
toolbar_tools: true,
|
||||
bake_layout_version: BAKE_LAYOUT_VERSION,
|
||||
|
||||
@@ -6,7 +6,6 @@ use serde_json::json;
|
||||
use texturecraft_engine::Tool;
|
||||
|
||||
use crate::TextureCraftApp;
|
||||
use crate::docking::Panel;
|
||||
use crate::i18n::{tr, trf};
|
||||
use crate::keymap::{shortcut_of, tip};
|
||||
use crate::state::{Mode, ViewLayout};
|
||||
@@ -435,10 +434,14 @@ pub fn tool_shelf(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
|
||||
ui.spacing_mut().item_spacing.y = SHELF_BUTTON_SPACING;
|
||||
|
||||
// Rendering has nothing to paint, so its shelf keeps only the buttons below the tools
|
||||
let tools: &[Tool] = match app.ui.mode {
|
||||
Mode::Painting => &SHELF_TOOLS,
|
||||
Mode::Baking => &BAKING_SHELF_TOOLS,
|
||||
Mode::Rendering => &[],
|
||||
let tools: &[Tool] = if !app.ui.toolbar_tools {
|
||||
&[]
|
||||
} else {
|
||||
match app.ui.mode {
|
||||
Mode::Painting => &SHELF_TOOLS,
|
||||
Mode::Baking => &BAKING_SHELF_TOOLS,
|
||||
Mode::Rendering => &[],
|
||||
}
|
||||
};
|
||||
if !tools.is_empty() {
|
||||
for &tool in tools {
|
||||
@@ -467,26 +470,10 @@ pub fn tool_shelf(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
|
||||
ui.add_space(SHELF_GROUP_GAP);
|
||||
}
|
||||
|
||||
let quick_mask = &app.session.quick_mask;
|
||||
for (command, icon, label, selected) in [
|
||||
("viewport.quickMask", ic::SELECTION_BACKGROUND, tr("Quick mask"), quick_mask.enabled),
|
||||
("viewport.quickMask.edit", ic::SELECTION, tr("Edit quick mask"), quick_mask.editing),
|
||||
("viewport.quickMask.invert", ic::SELECTION_INVERSE, tr("Invert quick mask"), quick_mask.inverted),
|
||||
] {
|
||||
let hint = tip(&app.ui.keymap, label, command);
|
||||
let button = ui.add_enabled_ui(crate::menus::enabled(app, command), |ui| icon_button(ui, icon, &hint, selected, SHELF_BUTTON_SIZE)).inner;
|
||||
if button.on_disabled_hover_text(label).clicked() {
|
||||
app.run(command, json!({}));
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_space(SHELF_GROUP_GAP);
|
||||
ui.separator();
|
||||
ui.add_space(SHELF_GROUP_GAP);
|
||||
let painting = app.ui.mode == Mode::Painting;
|
||||
if ui.add_enabled_ui(painting, |ui| icon_button(ui, ic::SPHERE, tr("Add smart material from the shelf"), false, SHELF_BUTTON_SIZE)).inner.clicked()
|
||||
{
|
||||
app.ui.dock.focus(Panel::Assets);
|
||||
for (icon, label) in [(ic::HOURGLASS, "Snooze Autosave"), (ic::ARROWS_CLOCKWISE, "Resources Updater")] {
|
||||
ui.add_enabled_ui(false, |ui| icon_button(ui, icon, tr(label), false, SHELF_BUTTON_SIZE))
|
||||
.inner
|
||||
.on_disabled_hover_text(tr(crate::unavailable::NOT_AVAILABLE));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -245,7 +245,8 @@ fn read_bytes(_file: &Path) -> std::io::Result<Vec<u8>> {
|
||||
|
||||
/// Whether every dock, the two in use and those of the named layouts, was read rather than replaced by a default
|
||||
fn fully_read(ui: &UiState) -> bool {
|
||||
!ui.dock.replaced_unreadable()
|
||||
ui.inactive_render_dock.as_ref().is_none_or(|dock| !dock.replaced_unreadable())
|
||||
&& !ui.dock.replaced_unreadable()
|
||||
&& !ui.inactive_mode_dock.replaced_unreadable()
|
||||
&& ui.named_layouts.iter().all(|layout| !layout.painting.replaced_unreadable() && !layout.baking.replaced_unreadable())
|
||||
}
|
||||
|
||||
@@ -199,13 +199,13 @@ mod tests {
|
||||
assert_eq!(h.state().ui.mode, Mode::Painting);
|
||||
offer(&mut h);
|
||||
assert!(crate::docking::input_blocked(h.state(), &h.ctx), "floating panels stop taking input");
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND | egui::Modifiers::SHIFT, egui::Key::B);
|
||||
h.key_press(egui::Key::F8);
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.mode, Mode::Painting, "the prompt holds the keyboard");
|
||||
h.get_by_label("LATER").click();
|
||||
h.run_steps(2);
|
||||
assert!(!crate::docking::input_blocked(h.state(), &h.ctx));
|
||||
h.key_press_modifiers(egui::Modifiers::COMMAND | egui::Modifiers::SHIFT, egui::Key::B);
|
||||
h.key_press(egui::Key::F8);
|
||||
h.step();
|
||||
assert_eq!(h.state().ui.mode, Mode::Baking, "the key works once the prompt is closed");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
//! Floating windows and the dockable History panel
|
||||
|
||||
use egui::{RichText, Ui, vec2};
|
||||
#[cfg(any(target_arch = "wasm32", test))]
|
||||
use egui::vec2;
|
||||
use egui::{RichText, Ui};
|
||||
use egui_phosphor::regular as ic;
|
||||
use serde_json::json;
|
||||
|
||||
@@ -50,8 +52,8 @@ fn reset_ui(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
|
||||
let mut open = true;
|
||||
let (mut reset, mut cancel) = (false, false);
|
||||
dialog("reset_ui", tr("Reset UI"), &mut open).show(ctx, |ui| {
|
||||
ui.label(tr("Reset the panels, view layout, zoom and every other view setting to their defaults? Settings and shortcuts stay. To reset only the panels, use Reset panel layout."));
|
||||
dialog(ctx, "reset_ui", tr("Reset UI"), &mut open).show(ctx, |ui| {
|
||||
ui.label(tr("Reset the panels, view layout, zoom and every other view setting to their defaults? Settings and shortcuts stay."));
|
||||
ui.add_space(8.0);
|
||||
|
||||
// One row keeps the window to its contents; a bare right-to-left layout fills the screen height
|
||||
@@ -123,7 +125,7 @@ fn unsaved(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
} else {
|
||||
trf("Save the changes to {name} first?", &question_args)
|
||||
};
|
||||
dialog("unsaved", tr("Unsaved changes"), &mut open).show(ctx, |ui| {
|
||||
dialog(ctx, "unsaved", tr("Unsaved Changes"), &mut open).show(ctx, |ui| {
|
||||
ui.label(question);
|
||||
ui.add_space(8.0);
|
||||
|
||||
@@ -199,14 +201,29 @@ pub(crate) fn window<'a>(id: &str, title: &str, open: &'a mut bool) -> egui::Win
|
||||
.default_width(300.0)
|
||||
}
|
||||
|
||||
/// A centered dialog; `id` keeps its place across UI languages.
|
||||
pub(crate) fn dialog<'a>(id: &str, title: &str, open: &'a mut bool) -> egui::Window<'a> {
|
||||
/// A movable, resizable dialog, initially centered; `id` keeps its place across UI languages.
|
||||
pub(crate) fn dialog<'a>(ctx: &egui::Context, id: &str, title: &str, open: &'a mut bool) -> egui::Window<'a> {
|
||||
egui::Window::new(title.to_owned())
|
||||
.id(egui::Id::unique(id))
|
||||
.open(open)
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.anchor(egui::Align2::CENTER_CENTER, vec2(0.0, 0.0))
|
||||
.resizable(true)
|
||||
.default_height(0.0)
|
||||
.default_pos(ctx.content_rect().center())
|
||||
.pivot(egui::Align2::CENTER_CENTER)
|
||||
}
|
||||
|
||||
/// Keep form controls clear of the scrollbar even when its floating handle expands.
|
||||
pub(crate) fn dialog_scroll_margin(ui: &egui::Ui) -> egui::Margin {
|
||||
let scroll = &ui.spacing().scroll;
|
||||
let mut margin = scroll.content_margin;
|
||||
let clearance = (scroll.bar_width + ui.spacing().item_spacing.x).ceil() as i8;
|
||||
if ui.style().right_to_left {
|
||||
margin.left = margin.left.max(clearance);
|
||||
} else {
|
||||
margin.right = margin.right.max(clearance);
|
||||
}
|
||||
margin
|
||||
}
|
||||
|
||||
/// The History panel body (a dock tab)
|
||||
@@ -271,7 +288,7 @@ fn export_mesh(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
|
||||
let mut open = true;
|
||||
let mut picked = None;
|
||||
dialog("export_mesh", tr("Export mesh"), &mut open).show(ctx, |ui| {
|
||||
dialog(ctx, "export_mesh", tr("Export Mesh"), &mut open).show(ctx, |ui| {
|
||||
ui.label(crate::theme::caption(tr("Download as")));
|
||||
for (extension, label, hint) in formats {
|
||||
if ui.add_sized(vec2(220.0, ui.spacing().interact_size.y), egui::Button::new(label)).on_hover_text(hint).clicked() {
|
||||
@@ -290,7 +307,7 @@ fn export_mesh(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
fn about(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
let tk = Tokens::get(ctx);
|
||||
let mut open = app.ui.windows.about;
|
||||
dialog("about", tr("About TextureCraft"), &mut open).show(ctx, |ui| {
|
||||
dialog(ctx, "about", tr("About TextureCraft"), &mut open).show(ctx, |ui| {
|
||||
ui.vertical_centered(|ui| {
|
||||
ui.label(RichText::new("TextureCraft").size(22.0).strong().color(tk.text_strong));
|
||||
ui.label(trf("Version {version}", &[("version", &texturecraft_engine::VERSION)]));
|
||||
@@ -308,7 +325,7 @@ fn about(app: &mut TextureCraftApp, ctx: &egui::Context) {
|
||||
}
|
||||
|
||||
/// Render the session log as text, preserving each entry's occurrence time, severity and source.
|
||||
fn log_text(entries: &[texturecraft_engine::LogEntry]) -> String {
|
||||
pub(crate) fn log_text(entries: &[texturecraft_engine::LogEntry]) -> String {
|
||||
use std::fmt::Write as _;
|
||||
|
||||
const UTC_FORMAT: &str = "%Y-%m-%dT%H:%M:%S%.6fZ";
|
||||
@@ -328,11 +345,43 @@ fn log_text(entries: &[texturecraft_engine::LogEntry]) -> String {
|
||||
text
|
||||
}
|
||||
|
||||
/// Open the current run's log in the desktop's text-file handler.
|
||||
pub(crate) fn show_log(app: &mut TextureCraftApp, _ctx: &egui::Context) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
let result = match app.session_log_file.as_mut() {
|
||||
Some(file) => file.sync(app.session.log_id, app.session.log.entries()).map(|()| file.path.clone()),
|
||||
None => Err(std::io::Error::other(tr("No session log file is available"))),
|
||||
};
|
||||
match result.and_then(|path| app.file_dialogs.show_folder(&path)) {
|
||||
Ok(()) => {}
|
||||
Err(error) => app.toast(trf("Could not open the log: {error}", &[("error", &error)]), true),
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
export_log(app);
|
||||
}
|
||||
|
||||
/// Help ▸ Export log...: saves the whole log to a text file chosen in a save dialog.
|
||||
pub(crate) fn export_log(app: &mut TextureCraftApp) {
|
||||
let text = log_text(app.session.log.entries());
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
app.ask_file(FileDialog::save().filter(tr("Text file"), &["txt"]).file_name("texturecraft-log.txt"), Bound::App, move |app, paths| {
|
||||
let text = if let Some(file) = &mut app.session_log_file {
|
||||
match file.sync(app.session.log_id, app.session.log.entries()).and_then(|()| file.text()) {
|
||||
Ok(lines) => format!("{}{lines}", log_text(&[])),
|
||||
Err(error) => {
|
||||
app.toast(trf("Could not export the log: {error}", &[("error", &error)]), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
text
|
||||
};
|
||||
let backend = app.render_state.as_ref().map(|state| format!("{:?}", state.adapter.get_info().backend)).unwrap_or_else(|| "CPU".into());
|
||||
let name =
|
||||
format!("Log_TextureCraft_{}_{}_{}_{}.txt", env!("CARGO_PKG_VERSION"), chrono::Utc::now().format("%Y-%m-%d_%H-%M-%S"), std::env::consts::OS, backend);
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
app.ask_file(FileDialog::save().filter(tr("Text file"), &["txt"]).file_name(&name), Bound::App, move |app, paths| {
|
||||
let Some(path) = paths.first() else { return };
|
||||
match std::fs::write(path, &text) {
|
||||
Ok(()) => app.toast(trf("Exported the log to {path}", &[("path", &path.display().to_string())]), false),
|
||||
@@ -340,7 +389,7 @@ pub(crate) fn export_log(app: &mut TextureCraftApp) {
|
||||
}
|
||||
});
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
match crate::web_files::download("texturecraft-log.txt", text.as_bytes()) {
|
||||
match crate::web_files::download(&name, text.as_bytes()) {
|
||||
Ok(()) => app.toast(tr("Exported the log"), false),
|
||||
Err(e) => app.toast(trf("Could not export the log: {error}", &[("error", &e)]), true),
|
||||
}
|
||||
@@ -357,7 +406,7 @@ pub fn file_dialogs_available() -> bool {
|
||||
pub fn remember(app: &mut TextureCraftApp, path: &str) {
|
||||
app.ui.recent.retain(|p| p != path);
|
||||
app.ui.recent.insert(0, path.to_string());
|
||||
app.ui.recent.truncate(10);
|
||||
app.ui.trim_recent();
|
||||
}
|
||||
|
||||
/// Start a save picker in its library folder when available.
|
||||
@@ -387,9 +436,7 @@ pub fn save_layout(app: &mut TextureCraftApp, mode: crate::state::Mode) {
|
||||
app.ask_file(dialog, Bound::App, move |app, paths| {
|
||||
let Some(path) = paths.first() else { return };
|
||||
|
||||
// The file carries both docks; the mode's own is the one in use when it is loaded
|
||||
let mut layout = crate::UiState { recent: Vec::new(), named_layouts: Vec::new(), mode, ..app.ui.clone() };
|
||||
layout.sync_mode_dock();
|
||||
let layout = crate::mode_layout::ModeLayout::of(&app.ui, mode);
|
||||
let result = serde_json::to_vec_pretty(&layout)
|
||||
.map_err(|error| error.to_string())
|
||||
.and_then(|bytes| texturecraft_engine::formats::write_atomic(path, &bytes).map_err(|error| error.to_string()))
|
||||
@@ -405,16 +452,13 @@ pub fn save_layout(app: &mut TextureCraftApp, mode: crate::state::Mode) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn load_layout(app: &mut TextureCraftApp) {
|
||||
let dir = crate::user_dir("layouts");
|
||||
let dialog = FileDialog::open().title(tr("Select a UI layout file.")).filter(tr("UI layout"), &["json"]).directory(dir);
|
||||
let dialog = FileDialog::open().title(tr("Load UI Layout")).filter(tr("UI layout"), &["json"]).directory(dir);
|
||||
app.ask_file(dialog, Bound::App, move |app, paths| {
|
||||
let Some(path) = paths.first() else { return };
|
||||
let result = std::fs::read(path)
|
||||
.map_err(|e| e.to_string())
|
||||
.and_then(|bytes| serde_json::from_slice::<crate::UiState>(&bytes).map_err(|e| e.to_string()))
|
||||
.map(|layout| {
|
||||
app.ui.adopt_layout(layout);
|
||||
trf("Loaded UI layout {path}", &[("path", &path.display())])
|
||||
});
|
||||
let result = std::fs::read(path).map_err(|e| e.to_string()).and_then(|bytes| crate::mode_layout::ModeLayout::read(&bytes)).map(|layout| {
|
||||
layout.apply(&mut app.ui);
|
||||
trf("Loaded UI layout {path}", &[("path", &path.display())])
|
||||
});
|
||||
match result {
|
||||
Ok(msg) => app.toast(msg, false),
|
||||
Err(e) => app.toast(trf("UI layout: {error}", &[("error", &e)]), true),
|
||||
@@ -437,7 +481,7 @@ pub(crate) fn template_name_of(file_name: &str) -> &str {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn save_as_template(app: &mut TextureCraftApp) {
|
||||
let dir = app.session.templates.dir.clone().unwrap_or_else(|| crate::user_dir("templates"));
|
||||
let dialog = in_save_folder(app, FileDialog::save().title(tr("Save template")).filter(tr("Project template"), &["json"]), dir);
|
||||
let dialog = in_save_folder(app, FileDialog::save().title(tr("Save As Template")).filter(tr("Project template"), &["json"]), dir);
|
||||
app.ask_file(dialog, Bound::Project, |app, paths| {
|
||||
let Some(path) = paths.first() else { return };
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! F5 and F6 switch the projection, the Viewport menu goes to fixed views, and Alt+Shift+drag orbits
|
||||
//! F5 and F6 switch the projection, bound shortcuts go to fixed views, and Alt+Shift+drag orbits
|
||||
//! in 90° steps.
|
||||
|
||||
use std::f32::consts::FRAC_PI_2;
|
||||
@@ -54,7 +54,7 @@ fn f6_switches_to_orthographic_and_f5_back_to_perspective_keeping_the_view() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_viewport_menu_goes_to_the_front_view_and_orbit_works_afterwards() {
|
||||
fn a_bound_front_view_shortcut_keeps_orbit_working_afterwards() {
|
||||
let mut h = harness();
|
||||
h.state_mut().run("camera.set", json!({"yaw": 70, "pitch": 30, "ortho": true}));
|
||||
h.run_steps(2);
|
||||
@@ -62,7 +62,11 @@ fn the_viewport_menu_goes_to_the_front_view_and_orbit_works_afterwards() {
|
||||
// The menu bar's "Viewport", above the dock's tab of the same name
|
||||
h.get_all_by_label("Viewport").min_by(|a, b| a.rect().top().total_cmp(&b.rect().top())).unwrap().click();
|
||||
h.run_steps(2);
|
||||
h.get_by_label_contains("Front view").click();
|
||||
assert!(h.query_by_label_contains("Front view").is_none(), "fixed views are absent from the menu");
|
||||
h.key_press(Key::Escape);
|
||||
h.run_steps(2);
|
||||
h.state_mut().ui.keymap.insert("camera.view.front".into(), "F12".into());
|
||||
h.key_press(Key::F12);
|
||||
|
||||
// The UI glides there over about a third of a second
|
||||
h.run_steps(6);
|
||||
|
||||
@@ -120,7 +120,7 @@ fn pick_mode_shows_the_id_map_and_a_click_on_the_mesh_adds_its_color() {
|
||||
#[test]
|
||||
fn without_an_id_map_picking_is_off_and_a_warning_says_why() {
|
||||
let (mut harness, _) = app_with_color_selection(false);
|
||||
let warning = format!("{} Bake an ID map (Ctrl+Shift+B) to pick colors from the mesh.", egui_phosphor::regular::WARNING);
|
||||
let warning = format!("{} Bake an ID map (F8) to pick colors from the mesh.", egui_phosphor::regular::WARNING);
|
||||
assert!(harness.query_by_label(&warning).is_some());
|
||||
|
||||
harness.get_by_label(&pick_color_label()).click();
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
//! Empty-project menu behavior and the layout restored by Reset UI.
|
||||
use egui::accesskit::Toggled;
|
||||
use egui_kittest::{
|
||||
Harness,
|
||||
kittest::{NodeT, Queryable},
|
||||
};
|
||||
use texturecraft_engine::Session;
|
||||
use texturecraft_ui_egui::{TextureCraftApp, docking::Panel, menus};
|
||||
|
||||
fn app() -> Harness<'static, TextureCraftApp> {
|
||||
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|cc| TextureCraftApp::new(cc, Session::closed().unwrap()));
|
||||
h.state_mut().ui.prefs.language = "en".into();
|
||||
h.run_steps(4);
|
||||
h
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_projects_stays_openable_and_clear_tracks_the_list() {
|
||||
let mut h = app();
|
||||
h.get_by_label("File").click();
|
||||
h.run_steps(3);
|
||||
let recent = h.get_by_label("Recent Projects");
|
||||
assert!(!recent.accesskit_node().is_disabled());
|
||||
recent.click();
|
||||
h.run_steps(3);
|
||||
assert!(h.get_by_label("Clear").accesskit_node().is_disabled());
|
||||
h.state_mut().ui.recent.push("/projects/painted-crate.tcraft".into());
|
||||
h.run_steps(3);
|
||||
assert!(h.query_by_label("/projects/painted-crate.tcraft").is_some());
|
||||
assert!(!h.get_by_label("Clear").accesskit_node().is_disabled());
|
||||
h.get_by_label("Clear").click();
|
||||
h.run_steps(3);
|
||||
assert!(h.state().ui.recent.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shortcuts_list_opens_settings_on_the_shortcuts_page() {
|
||||
let mut h = app();
|
||||
h.get_by_label("Help").click();
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Shortcuts List").click();
|
||||
h.run_steps(4);
|
||||
assert!(h.state().ui.windows.settings);
|
||||
assert!(!h.state().ui.windows.shortcuts);
|
||||
assert!(h.query_by_label("Mouse shortcuts").is_some());
|
||||
assert!(h.query_by_label("General").is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_file_menu_disables_the_save_group_and_opens_import() {
|
||||
let mut h = app();
|
||||
h.get_by_label("File").click();
|
||||
h.run_steps(3);
|
||||
assert!(h.get_by_label("More Save Options").accesskit_node().is_disabled());
|
||||
let import = h.get_all_by_label("Import Resources").find(|node| node.accesskit_node().toggled().is_none()).unwrap();
|
||||
assert!(!import.accesskit_node().is_disabled());
|
||||
import.click();
|
||||
h.run_steps(4);
|
||||
assert!(h.state().ui.windows.import_resources.is_some());
|
||||
assert!(h.get_by_label("Import").accesskit_node().is_disabled());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_restores_the_empty_workspace_and_checked_disabled_quick_mask() {
|
||||
let mut h = app();
|
||||
h.state_mut().ui.dock.close(Panel::Assets);
|
||||
h.state_mut().ui.dock.focus(Panel::History);
|
||||
h.state_mut().ui.toolbar_tools = false;
|
||||
h.state_mut().ui.toolbar_docks = false;
|
||||
let ctx = h.ctx.clone();
|
||||
menus::invoke(h.state_mut(), &ctx, "ui.resetUi");
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Reset").click();
|
||||
h.run_steps(4);
|
||||
for panel in [Panel::Assets, Panel::Layers, Panel::Properties, Panel::TextureSetList, Panel::TextureSetSettings] {
|
||||
assert!(h.state().ui.dock.is_open(panel));
|
||||
}
|
||||
for panel in [Panel::History, Panel::Display, Panel::Shader, Panel::Log, Panel::Export] {
|
||||
assert!(!h.state().ui.dock.is_open(panel));
|
||||
}
|
||||
assert!(h.state().ui.toolbar_tools && h.state().ui.toolbar_docks);
|
||||
h.get_by_label("Viewport").click();
|
||||
h.run_steps(3);
|
||||
let quick = h.get_by_label_contains("Enable Quick Mask");
|
||||
assert!(quick.accesskit_node().is_disabled());
|
||||
assert_eq!(quick.accesskit_node().toggled(), Some(Toggled::True));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tools_hides_painting_controls_but_keeps_disabled_utilities() {
|
||||
let mut h = app();
|
||||
let ctx = h.ctx.clone();
|
||||
for visible in [true, false, true] {
|
||||
if h.state().ui.toolbar_tools != visible {
|
||||
menus::invoke(h.state_mut(), &ctx, "ui.toolbar.tools");
|
||||
}
|
||||
h.run_steps(3);
|
||||
assert_eq!(h.query_by_label_contains("Eraser").is_some(), visible);
|
||||
for label in ["Snooze Autosave", "Resources Updater"] {
|
||||
assert!(h.get_by_label(label).accesskit_node().is_disabled(), "{label}");
|
||||
}
|
||||
assert!(h.query_by_label_contains("Online assets").is_none());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn loading_a_mode_layout_preserves_the_other_modes_and_preferences() {
|
||||
use texturecraft_ui_egui::{file_dialogs::Answer, state::Mode};
|
||||
let dir = super::temp_dir::TempDir::new("mode-layout-isolation");
|
||||
let file = dir.join("rendering.json");
|
||||
let mut h = app();
|
||||
h.state_mut().run("project.new", serde_json::json!({"mesh":"cube", "resolution":128})).unwrap();
|
||||
h.state_mut().ui.mode = Mode::Rendering;
|
||||
h.run_steps(3);
|
||||
h.state_mut().ui.dock.focus(Panel::Renderer);
|
||||
let target = file.clone();
|
||||
h.state_mut().file_dialogs.set_override(Some(Box::new(move |_| Answer::Paths(vec![target.clone()]))));
|
||||
let ctx = h.ctx.clone();
|
||||
menus::invoke(h.state_mut(), &ctx, "ui.layout.save.rendering");
|
||||
h.run_steps(4);
|
||||
h.state_mut().ui.mode = Mode::Painting;
|
||||
h.run_steps(3);
|
||||
h.state_mut().ui.dock.close(Panel::Assets);
|
||||
h.state_mut().ui.prefs.autosave_minutes = 17;
|
||||
h.state_mut().ui.mode = Mode::Baking;
|
||||
h.run_steps(3);
|
||||
h.state_mut().ui.dock.close(Panel::MeshMapBakers);
|
||||
menus::invoke(h.state_mut(), &ctx, "ui.layout.load");
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().ui.mode, Mode::Rendering);
|
||||
assert!(h.state().ui.dock.is_open(Panel::Renderer));
|
||||
assert_eq!(h.state().ui.prefs.autosave_minutes, 17);
|
||||
h.state_mut().ui.mode = Mode::Painting;
|
||||
h.run_steps(3);
|
||||
assert!(!h.state().ui.dock.is_open(Panel::Assets));
|
||||
h.state_mut().ui.mode = Mode::Baking;
|
||||
h.run_steps(3);
|
||||
assert!(!h.state().ui.dock.is_open(Panel::MeshMapBakers));
|
||||
}
|
||||
@@ -83,14 +83,23 @@ fn project_items_are_disabled_without_a_project() {
|
||||
"layer.add.fill",
|
||||
"layer.remove",
|
||||
"bake.run",
|
||||
"resource.import",
|
||||
"material.load",
|
||||
] {
|
||||
assert!(!menus::enabled(app, id), "{id} needs a project");
|
||||
}
|
||||
for id in
|
||||
["ui.newProject", "file.open", "project.sample", "ui.settings", "ui.about", "ui.quit", "ui.hideUi", "ui.resetUi", "viewport.frame", "ui.layout.split"]
|
||||
{
|
||||
for id in [
|
||||
"resource.import",
|
||||
"ui.newProject",
|
||||
"file.open",
|
||||
"project.sample",
|
||||
"ui.settings",
|
||||
"ui.about",
|
||||
"ui.quit",
|
||||
"ui.hideUi",
|
||||
"ui.resetUi",
|
||||
"viewport.frame",
|
||||
"ui.layout.split",
|
||||
] {
|
||||
assert!(menus::enabled(app, id), "{id} works without a project");
|
||||
}
|
||||
let open = open_project();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Help ▸ Release notes... opens the releases page; Help ▸ Export log... saves the log to a text file;
|
||||
//! Help ▸ Join the community (Discord)... opens the community Discord.
|
||||
//! Help ▸ Release Notes opens the releases page; Help ▸ Export Log saves the log to a text file;
|
||||
//! Help ▸ Discord opens the community Discord.
|
||||
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
@@ -34,7 +34,7 @@ fn release_notes_opens_the_releases_page() {
|
||||
let mut h = harness();
|
||||
h.get_by_label("Help").click();
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Release notes...").click();
|
||||
h.get_by_label("Release Notes").click();
|
||||
|
||||
// The open-url command is in the output of the frame that handled the click only
|
||||
h.step();
|
||||
@@ -58,7 +58,7 @@ fn join_the_community_opens_the_discord() {
|
||||
let mut h = harness();
|
||||
h.get_by_label("Help").click();
|
||||
h.run_steps(3);
|
||||
h.get_by_label("Join the community (Discord)...").click();
|
||||
h.get_by_label("Discord").click();
|
||||
h.step();
|
||||
assert!(opened(&h, DISCORD), "the community Discord was opened");
|
||||
}
|
||||
@@ -82,7 +82,7 @@ fn export_log_writes_every_line_with_time_and_level() {
|
||||
let file = dir.join("log.txt");
|
||||
let answer = file.clone();
|
||||
h.state_mut().file_dialogs.set_override(Some(Box::new(move |_| Answer::Paths(vec![answer.clone()]))));
|
||||
click_help_item(&mut h, "Export log...");
|
||||
click_help_item(&mut h, "Export Log");
|
||||
|
||||
let text = std::fs::read_to_string(&file).expect("the log file was written");
|
||||
let lines: Vec<&str> = text.lines().collect();
|
||||
@@ -102,6 +102,6 @@ fn export_log_writes_every_line_with_time_and_level() {
|
||||
fn a_canceled_export_log_dialog_writes_nothing() {
|
||||
let mut h = harness();
|
||||
h.state_mut().file_dialogs.set_override(Some(Box::new(|_| Answer::Cancelled)));
|
||||
click_help_item(&mut h, "Export log...");
|
||||
click_help_item(&mut h, "Export Log");
|
||||
assert!(h.state().toasts.is_empty());
|
||||
}
|
||||
@@ -20,6 +20,7 @@ mod display_post_effects;
|
||||
mod effect_decal;
|
||||
mod effect_rows;
|
||||
mod effect_sliders;
|
||||
mod empty_menus;
|
||||
mod empty_start;
|
||||
mod export_file_types;
|
||||
mod export_map_overrides;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Window > Layouts: save the panel arrangement under a name and switch to it from the menu.
|
||||
//! Saved named-layout commands remain available to shortcuts and automation after their menu is removed.
|
||||
|
||||
use egui::Role;
|
||||
use egui_kittest::Harness;
|
||||
@@ -15,14 +15,23 @@ fn app() -> Harness<'static, TextureCraftApp> {
|
||||
harness
|
||||
}
|
||||
|
||||
/// Open Window > Layouts, click `entry`, and let the app answer
|
||||
/// Exercise the existing dialog through a bound shortcut; named layouts are no longer in the menu.
|
||||
fn layouts_menu(harness: &mut Harness<'_, TextureCraftApp>, entry: &str) {
|
||||
harness.get_by_role_and_label(Role::Button, "Window").click();
|
||||
harness.run_steps(3);
|
||||
harness.get_by_role_and_label(Role::Button, "Layouts").click();
|
||||
harness.run_steps(3);
|
||||
harness.get_by_role_and_label(Role::Button, entry).click();
|
||||
let id = match entry {
|
||||
"Save current layout as..." => "ui.layout.saveAs",
|
||||
"Manage layouts..." => "ui.layout.manage",
|
||||
name => {
|
||||
let reply = invoke(harness, serde_json::json!({"id": "ui.layout.apply", "name": name}));
|
||||
assert_eq!(reply["ok"], true);
|
||||
harness.run_steps(3);
|
||||
return;
|
||||
}
|
||||
};
|
||||
harness.state_mut().ui.keymap.insert(id.into(), "F12".into());
|
||||
harness.run_steps(2);
|
||||
harness.key_press(egui::Key::F12);
|
||||
harness.run_steps(3);
|
||||
harness.state_mut().ui.keymap.remove(id);
|
||||
}
|
||||
|
||||
/// The dialog's text field: the one nearest the window center, where dialogs open (the shelf search is another)
|
||||
@@ -43,7 +52,7 @@ fn save_as(harness: &mut Harness<'_, TextureCraftApp>, name: &str) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_layout_saved_from_the_menu_comes_back_from_the_menu() {
|
||||
fn a_layout_saved_from_a_shortcut_comes_back_through_automation() {
|
||||
let mut harness = app();
|
||||
harness.state_mut().ui.dock.close(Panel::Assets);
|
||||
save_as(&mut harness, "No shelf");
|
||||
@@ -110,12 +119,12 @@ fn invoke(harness: &mut Harness<'_, TextureCraftApp>, params: serde_json::Value)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_layout_items_are_in_the_menu_catalog_and_open_their_dialogs() {
|
||||
fn legacy_layout_commands_stay_out_of_the_menu_and_open_their_dialogs() {
|
||||
use texturecraft_ui_egui::menus::CATALOG;
|
||||
use texturecraft_ui_egui::named_layouts::LayoutDialog;
|
||||
|
||||
for id in ["ui.layout.saveAs", "ui.layout.manage"] {
|
||||
assert!(CATALOG.iter().any(|item| item.id == id && item.menu == "Window" && item.sub == Some("Layouts")), "{id}");
|
||||
assert!(!CATALOG.iter().any(|item| item.id == id), "{id} is no longer a menu entry");
|
||||
}
|
||||
let mut harness = app();
|
||||
assert!(!texturecraft_ui_egui::menus::enabled(harness.state(), "ui.layout.manage"), "nothing to manage yet");
|
||||
|
||||
@@ -393,7 +393,7 @@ fn create_asks_before_discarding_edits_made_after_the_form_opened() {
|
||||
h.get_by_role_and_label(Role::Button, "Create").click();
|
||||
h.run_steps(3);
|
||||
|
||||
assert!(h.query_by_label("Unsaved changes").is_some());
|
||||
assert!(h.query_by_label("Unsaved Changes").is_some());
|
||||
assert_eq!(h.state().session.doc.project.name, "Open");
|
||||
|
||||
h.get_by_role_and_label(Role::Button, "Don't save").click();
|
||||
|
||||
@@ -35,12 +35,12 @@ fn named<'a>(found: &'a [(f32, String, bool)], name: &str) -> Option<&'a (f32, S
|
||||
fn every_menu_lists_its_items_in_the_reference_order() {
|
||||
// Items the reference has and TextureCraft lacks are absent; TextureCraft's own sit where they fit
|
||||
let expected = [
|
||||
"File: New project... | Open... | - | Open sample project... | - | Close | - | Save | Save as... | More save options > Save as template... | More save options > Save and reduce file size | More save options > Save as copy... | Remove unused resources... | - | Import resources... | Import MaterialX material... | Import PBR texture folder... | Import material... | Export Textures... | Export Mesh... | - | Quit",
|
||||
"Edit: Undo | Redo | Project Configuration... | Reimport mesh | Settings...",
|
||||
"Mode: Bake Mesh Maps | Painting | Rendering (path traced)",
|
||||
"Window: Views > Assets | Views > Common Settings | Views > Display Settings | Views > Export | Views > History | Views > Layers | Views > Log | Views > Mesh Map Bakers | Views > Mesh Map Settings | Views > Properties | Views > Python Console | Views > Renderer Settings | Views > Shader Settings | Views > Online assets | Views > Texture Sets | Views > Texture Set Settings | Toolbars > Docks | Toolbars > Plugins | Toolbars > Tools | - | Save UI Layout > Painting mode | Save UI Layout > Rendering mode | Save UI Layout > Baking mode | Load UI Layout | Layouts > Save current layout as... | Layouts > Manage layouts... | - | Hide UI | Reset panel layout | Reset UI",
|
||||
"Viewport: Display material | Display next channel | Display previous channel | Display next mesh map | Display previous mesh map | UV checker | - | Frame texture set | Show entire mesh | Front view | Back view | Left view | Right view | Top view | Bottom view | - | Perspective | Orthographic | - | 3D/2D views | 3D view only | 2D view only | Swap 3D/2D | - | Navigation buttons | - | Enable quick mask | Edit quick mask | Invert quick mask",
|
||||
"Help: Release notes... | Documentation... | Shortcuts list... | - | Join the community (Discord)... | ArtCraft website... | Report a bug... | Show log... | Export log... | - | Check for Updates... | About TextureCraft...",
|
||||
"File: New Project | Open | Recent Projects > Clear | - | Open Sample Project | - | Close | - | Save | Save As | More Save Options > Save As Template | More Save Options > Save and Reduce File Size | More Save Options > Save As Copy | Remove Unused Resources | - | Import Resources | Export Textures | Export Mesh | - | Quit",
|
||||
"Edit: Undo | Redo | Project Configuration | Reimport Mesh | Settings",
|
||||
"Mode: Bake Mesh Maps | Painting | Rendering",
|
||||
"Window: Views > Assets | Views > Baking Log | Views > Common Settings | Views > Display Settings | Views > Export | Views > History | Views > Layers | Views > Log | Views > Mesh Map Bakers | Views > Mesh Map Settings | Views > Properties | Views > Renderer Settings | Views > Shader Settings | Views > Texture Set List | Views > Texture Set Settings | Toolbars > Docks | Toolbars > Tools | - | Save UI Layout > Painting Mode | Save UI Layout > Rendering Mode | Save UI Layout > Baking Mode | Load UI Layout | - | Hide UI | Reset UI",
|
||||
"Viewport: Display Material | Display Next Channel | Display Previous Channel | Display Next Mesh Map | Display Previous Mesh Map | - | Show Entire Mesh/Path | - | Enable Quick Mask | Edit Quick Mask | Invert Quick Mask",
|
||||
"Help: Release Notes | Documentation | Shortcuts List | - | Discord | Report a Bug | Show Log | Export Log | - | Check for Updates | About TextureCraft",
|
||||
];
|
||||
let actual: Vec<String> = menus::TOP
|
||||
.iter()
|
||||
@@ -168,7 +168,7 @@ fn the_blank_screen_menus_match_the_measured_enabled_states() {
|
||||
assert!(menus::enabled(app, id), "{id} is enabled on the blank screen");
|
||||
}
|
||||
for id in ["ui.view.bakeSettings", "ui.view.bakeMaps", "ui.view.meshMapBakers"] {
|
||||
assert!(!menus::enabled(app, id), "{id} belongs to Baking mode");
|
||||
assert!(!menus::enabled(app, id), "{id} belongs to Baking Mode");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -482,3 +482,31 @@ fn the_baking_options_say_when_there_is_no_gpu_to_trace_on() {
|
||||
let no_gpu = h.query_by_label("no GPU").is_some();
|
||||
assert_eq!(h.query_by_label(GPU_RAYTRACING_UNAVAILABLE).is_some(), no_gpu, "the note shows with no GPU and only then");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_project_limit_applies_on_ok_and_persists() {
|
||||
let mut h = harness(Session::closed().unwrap());
|
||||
h.state_mut().ui.recent = (0..8).map(|i| format!("/projects/{i}.tcraft")).collect();
|
||||
open_settings(&mut h);
|
||||
h.get_by_label("Recent projects limit").scroll_to_me();
|
||||
h.run_steps(3);
|
||||
assert!(!h.get_by_label("Recent projects limit").accesskit_node().is_disabled());
|
||||
h.state_mut().ui.windows.settings_draft.as_mut().unwrap().prefs.recent_projects_limit = 3;
|
||||
click(&mut h, "Cancel");
|
||||
assert_eq!(h.state().ui.recent.len(), 8);
|
||||
open_settings(&mut h);
|
||||
h.state_mut().ui.windows.settings_draft.as_mut().unwrap().prefs.recent_projects_limit = 3;
|
||||
click(&mut h, "OK");
|
||||
assert_eq!(h.state().ui.recent, ["/projects/0.tcraft", "/projects/1.tcraft", "/projects/2.tcraft"]);
|
||||
texturecraft_ui_egui::windows::remember(h.state_mut(), "/projects/new.tcraft");
|
||||
assert_eq!(h.state().ui.recent, ["/projects/new.tcraft", "/projects/0.tcraft", "/projects/1.tcraft"]);
|
||||
let mut storage = MemoryStorage::default();
|
||||
eframe::App::save(h.state_mut(), &mut storage);
|
||||
let restored: UiState = serde_json::from_str(&storage.values["ui.json"]).unwrap();
|
||||
assert_eq!(restored.prefs.recent_projects_limit, 3);
|
||||
let ctx = h.ctx.clone();
|
||||
let reply = texturecraft_ui_egui::control::handle(h.state_mut(), &ctx, "ui.set", &serde_json::json!({"prefs":{"recent_projects_limit":0}}));
|
||||
assert_eq!(reply["ok"], true);
|
||||
texturecraft_ui_egui::windows::remember(h.state_mut(), "/projects/another.tcraft");
|
||||
assert!(h.state().ui.recent.is_empty());
|
||||
}
|
||||
@@ -35,23 +35,23 @@ fn the_list_starts_with_the_reference_names_and_keys_in_the_reference_order() {
|
||||
("Quit application", "Ctrl+Q"),
|
||||
("Export Textures...", "Ctrl+Shift+E"),
|
||||
("Reimport mesh", "Ctrl+Shift+R"),
|
||||
("Switch to baking mode", "Ctrl+Shift+B"),
|
||||
("Switch to baking mode", "F8"),
|
||||
("Switch to edition mode", "F9"),
|
||||
("Switch to rendering mode (path traced)", "F10"),
|
||||
("Show mesh wireframe", ""),
|
||||
("Camera projection: Perspective view", "F5"),
|
||||
("Camera projection: Orthographic view", "F6"),
|
||||
("Display next channel", "C"),
|
||||
("Display previous channel", "Shift+C"),
|
||||
("Display material", "M"),
|
||||
("Display next mesh map", "B"),
|
||||
("Display previous mesh map", "Shift+B"),
|
||||
("Show entire mesh/path", "F"),
|
||||
("Display Next Channel", "C"),
|
||||
("Display Previous Channel", "Shift+C"),
|
||||
("Display Material", "M"),
|
||||
("Display Next Mesh Map", "B"),
|
||||
("Display Previous Mesh Map", "Shift+B"),
|
||||
("Show Entire Mesh/Path", "F"),
|
||||
("Select next camera", ">"),
|
||||
("Select previous camera", "<"),
|
||||
("Enable quick mask", "Y"),
|
||||
("Edit quick mask", "U"),
|
||||
("Invert quick mask", "Ctrl+Shift+I"),
|
||||
("Enable Quick Mask", "Y"),
|
||||
("Edit Quick Mask", "U"),
|
||||
("Invert Quick Mask", "Ctrl+Shift+I"),
|
||||
("Viewers layout: 3D/2D", "F1"),
|
||||
("Viewers layout: 3D only", "F2"),
|
||||
("Viewers layout: 2D only", "F3"),
|
||||
@@ -82,9 +82,9 @@ fn the_menus_keep_their_texts_and_quit_keeps_ctrl_q() {
|
||||
assert_eq!(label("file.saveAs"), Some("Save as..."));
|
||||
assert_eq!(label("ui.quit"), Some("Quit"));
|
||||
assert_eq!(label("ui.mode.bake"), Some("Bake Mesh Maps"));
|
||||
assert_eq!(label("viewport.frame"), Some("Show entire mesh"));
|
||||
assert_eq!(label("viewport.frame"), Some("Show Entire Mesh/Path"));
|
||||
assert_eq!(shortcut_of(&keymap::Keymap::new(), "ui.quit"), Some("Ctrl+Q"));
|
||||
assert_eq!(shortcut_of(&keymap::Keymap::new(), "ui.mode.bake"), Some("Ctrl+Shift+B"));
|
||||
assert_eq!(shortcut_of(&keymap::Keymap::new(), "ui.mode.bake"), Some("F8"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -95,7 +95,7 @@ fn the_settings_page_lists_the_reference_names_and_shows_the_missing_functions_d
|
||||
h.run_steps(4);
|
||||
h.get_by_role_and_label(Role::Tab, "Shortcuts").click();
|
||||
h.run_steps(4);
|
||||
for name in ["Open project", "Save as project", "Quit application", "Switch to baking mode", "Show entire mesh/path", "Viewers layout: Swap 3D/2D"] {
|
||||
for name in ["Open project", "Save as project", "Quit application", "Switch to baking mode", "Show Entire Mesh/Path", "Viewers layout: Swap 3D/2D"] {
|
||||
assert!(h.query_by_label(name).is_some(), "{name} is listed");
|
||||
}
|
||||
assert!(h.query_by_label("Open...").is_none(), "the menu's text is not the list's");
|
||||
@@ -110,8 +110,8 @@ fn the_settings_page_lists_the_reference_names_and_shows_the_missing_functions_d
|
||||
#[test]
|
||||
fn the_listed_keys_run_their_commands() {
|
||||
let mut h = harness();
|
||||
press(&mut h, Key::B, Modifiers::COMMAND | Modifiers::SHIFT);
|
||||
assert_eq!(h.state().ui.mode, Mode::Baking, "Ctrl+Shift+B switches to baking mode");
|
||||
press(&mut h, Key::F8, Modifiers::NONE);
|
||||
assert_eq!(h.state().ui.mode, Mode::Baking, "F8 switches to baking mode");
|
||||
press(&mut h, Key::F9, Modifiers::NONE);
|
||||
assert_eq!(h.state().ui.mode, Mode::Painting, "F9 switches to edition mode");
|
||||
press(&mut h, Key::F10, Modifiers::NONE);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Project templates: File > More save options (Save as template..., Save and reduce file size,
|
||||
//! Save as copy...), the New project list's reference names and the remembered template
|
||||
//! Project templates: File > More Save Options (Save As Template, Save and Reduce File Size,
|
||||
//! Save As Copy), the New project list's reference names and the remembered template
|
||||
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
@@ -23,7 +23,7 @@ fn app() -> Harness<'static, TextureCraftApp> {
|
||||
fn open_more_save_options(h: &mut Harness<'_, TextureCraftApp>) {
|
||||
h.get_by_label("File").click();
|
||||
h.run_steps(3);
|
||||
h.get_by_label("More save options").click();
|
||||
h.get_by_label("More Save Options").click();
|
||||
h.run_steps(3);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ fn save_as_template_asks_in_the_templates_folder_and_saves_without_a_message() {
|
||||
})));
|
||||
|
||||
open_more_save_options(&mut h);
|
||||
h.get_by_label_contains("Save as template...").click();
|
||||
h.get_by_label_contains("Save As Template").click();
|
||||
h.run_steps(4);
|
||||
|
||||
let asked = asked.borrow();
|
||||
@@ -83,12 +83,12 @@ fn a_saved_template_appears_in_new_project_with_the_your_assets_suffix() {
|
||||
fn save_and_reduce_file_size_is_greyed_with_the_hint() {
|
||||
let mut h = app();
|
||||
open_more_save_options(&mut h);
|
||||
let item = h.get_by_label_contains("Save and reduce file size");
|
||||
let item = h.get_by_label_contains("Save and Reduce File Size");
|
||||
let at = item.rect().center();
|
||||
h.hover_at(at);
|
||||
h.run_steps(30);
|
||||
assert!(h.query_by_label(NOT_AVAILABLE).is_some(), "the hint shows on hover");
|
||||
assert!(h.get_by_label_contains("Save and reduce file size").accesskit_node().is_disabled(), "the item is greyed");
|
||||
assert!(h.get_by_label_contains("Save and Reduce File Size").accesskit_node().is_disabled(), "the item is greyed");
|
||||
assert!(!menus::enabled(h.state(), "ui.saveReduced"));
|
||||
assert!(!menus::implemented("ui.saveReduced"));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ fn narrow_toolbars_keep_scroll_arrows_and_mode_buttons_separate() {
|
||||
harness.run_steps(4);
|
||||
let left = harness.get_by_label("Scroll left").rect();
|
||||
let right = harness.get_by_label("Scroll right").rect();
|
||||
let bake = harness.get_by_label("Bake Mesh Maps (Ctrl+Shift+B)").rect();
|
||||
let bake = harness.get_by_label("Bake Mesh Maps (F8)").rect();
|
||||
let (_, clip) = size_label(&harness);
|
||||
for button in [left, right, bake] {
|
||||
assert_eq!(button.size(), egui::Vec2::splat(button_size));
|
||||
@@ -135,10 +135,8 @@ fn compact_view_buttons_can_be_scrolled_into_view_and_clicked() {
|
||||
#[test]
|
||||
fn mode_buttons_keep_their_order_and_dispatch_commands() {
|
||||
let mut harness = toolbar_harness(700.0, Tool::Paint);
|
||||
for (label, mode) in
|
||||
[("Bake Mesh Maps (Ctrl+Shift+B)", Mode::Baking), ("Rendering (path traced) (F10)", Mode::Rendering), ("Painting (F9)", Mode::Painting)]
|
||||
{
|
||||
let bake = harness.get_by_label("Bake Mesh Maps (Ctrl+Shift+B)").rect();
|
||||
for (label, mode) in [("Bake Mesh Maps (F8)", Mode::Baking), ("Rendering (path traced) (F10)", Mode::Rendering), ("Painting (F9)", Mode::Painting)] {
|
||||
let bake = harness.get_by_label("Bake Mesh Maps (F8)").rect();
|
||||
let paint = harness.get_by_label("Painting (F9)").rect();
|
||||
let render = harness.get_by_label("Rendering (path traced) (F10)").rect();
|
||||
assert!(bake.right() < paint.left() && paint.right() < render.left());
|
||||
|
||||
@@ -10,7 +10,6 @@ use std::rc::Rc;
|
||||
use texturecraft_engine::Session;
|
||||
use texturecraft_ui_egui::file_dialogs::{Answer, Request};
|
||||
use texturecraft_ui_egui::state::Mode;
|
||||
use texturecraft_ui_egui::unavailable::NOT_AVAILABLE;
|
||||
use texturecraft_ui_egui::{TextureCraftApp, menus};
|
||||
|
||||
use super::temp_dir::TempDir;
|
||||
@@ -37,25 +36,16 @@ fn open_sub(h: &mut Harness<'_, TextureCraftApp>, name: &str) {
|
||||
h.run_steps(3);
|
||||
}
|
||||
|
||||
fn hover_hint(h: &mut Harness<'_, TextureCraftApp>, label: &str) -> bool {
|
||||
let at = h.get_by_label_contains(label).rect().center();
|
||||
h.hover_at(egui::pos2(1.0, 1.0));
|
||||
h.run_steps(2);
|
||||
h.hover_at(at);
|
||||
h.run_steps(30);
|
||||
h.query_by_label(NOT_AVAILABLE).is_some()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn views_lists_renderer_settings_and_the_greyed_entries_with_a_hint() {
|
||||
let mut h = app();
|
||||
fn views_omit_unrequested_entries_and_disable_mode_specific_panels() {
|
||||
let mut h = app_with(Session::closed().unwrap());
|
||||
open_sub(&mut h, "Views");
|
||||
assert!(h.query_by_label_contains("Renderer Settings").is_some());
|
||||
for label in ["Baking Log", "Common Settings", "Mesh Map Bakers", "Mesh Map Settings", "Renderer Settings"] {
|
||||
assert!(h.get_by_label_contains(label).accesskit_node().is_disabled(), "{label}");
|
||||
}
|
||||
for label in ["Python Console", "Online assets"] {
|
||||
assert!(h.get_by_label_contains(label).accesskit_node().is_disabled(), "{label} is greyed");
|
||||
assert!(h.query_by_label_contains(label).is_none());
|
||||
}
|
||||
assert!(hover_hint(&mut h, "Python Console"), "Python Console says it is not available yet");
|
||||
assert!(hover_hint(&mut h, "Online assets"), "Online assets says it is not available yet");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -71,14 +61,13 @@ fn properties_names_the_tool_while_a_project_is_open() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toolbars_lists_docks_plugins_and_tools() {
|
||||
fn toolbars_lists_only_docks_and_tools() {
|
||||
let mut h = app();
|
||||
open_sub(&mut h, "Toolbars");
|
||||
for label in ["Docks", "Tools"] {
|
||||
assert!(!h.get_by_label_contains(label).accesskit_node().is_disabled(), "{label}");
|
||||
}
|
||||
assert!(h.get_by_label_contains("Plugins").accesskit_node().is_disabled());
|
||||
assert!(hover_hint(&mut h, "Plugins"));
|
||||
assert!(h.query_by_label_contains("Plugins").is_none());
|
||||
|
||||
assert!(h.state().ui.toolbar_docks && h.state().ui.toolbar_tools, "both bars start shown");
|
||||
h.get_by_label_contains("Docks").click();
|
||||
@@ -116,9 +105,9 @@ fn hide_ui_shows_its_check_mark() {
|
||||
fn save_ui_layout_has_one_entry_per_mode_and_writes_that_modes_layout() {
|
||||
let dir = TempDir::new("layout-per-mode");
|
||||
for (item, file, mode, baking) in [
|
||||
("Painting mode", "p.json", Mode::Painting, false),
|
||||
("Rendering mode", "r.json", Mode::Rendering, false),
|
||||
("Baking mode", "b.json", Mode::Baking, true),
|
||||
("Painting Mode", "p.json", Mode::Painting, false),
|
||||
("Rendering Mode", "r.json", Mode::Rendering, false),
|
||||
("Baking Mode", "b.json", Mode::Baking, true),
|
||||
] {
|
||||
let mut h = app();
|
||||
let path = dir.join(file);
|
||||
@@ -130,7 +119,10 @@ fn save_ui_layout_has_one_entry_per_mode_and_writes_that_modes_layout() {
|
||||
|
||||
let saved: serde_json::Value = serde_json::from_slice(&std::fs::read(&path).unwrap_or_else(|e| panic!("{item}: {e}"))).unwrap();
|
||||
assert_eq!(saved["mode"], serde_json::to_value(mode).unwrap(), "{item}");
|
||||
assert_eq!(saved["dock_is_baking"], baking, "{item}: the file's dock is the mode's own");
|
||||
assert!(saved.get("inactive_mode_dock").is_none(), "only one mode is saved");
|
||||
assert!(saved.get("prefs").is_none(), "preferences are not a layout");
|
||||
let dock = texturecraft_ui_egui::docking::Dock::from_value(saved["dock"].clone());
|
||||
assert_eq!(dock.is_open(texturecraft_ui_egui::docking::Panel::MeshMapBakers), baking);
|
||||
assert_eq!(h.state().ui.mode, Mode::Painting, "saving does not switch the mode");
|
||||
}
|
||||
}
|
||||
@@ -152,7 +144,7 @@ fn the_legacy_layout_save_command_saves_the_active_mode() {
|
||||
assert_eq!(reply["ok"], true);
|
||||
let saved: serde_json::Value = serde_json::from_slice(&std::fs::read(path).unwrap()).unwrap();
|
||||
assert_eq!(saved["mode"], serde_json::to_value(Mode::Baking).unwrap());
|
||||
assert_eq!(saved["dock_is_baking"], true);
|
||||
assert!(saved.get("inactive_mode_dock").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use egui_kittest::kittest::{NodeT, Queryable};
|
||||
use texturecraft_engine::core::{BakeResolution, BakedMap, CurvatureMethod, HeightNormalization};
|
||||
use texturecraft_ui_egui::TextureCraftApp;
|
||||
use texturecraft_ui_egui::docking::Panel;
|
||||
@@ -28,6 +28,16 @@ fn save(harness: &mut Harness<'_, TextureCraftApp>, dir: &Path, name: &str) {
|
||||
let img = harness.render().unwrap_or_else(|e| panic!("{name}: {e}"));
|
||||
let path = dir.join(format!("{name}.png"));
|
||||
img.save(&path).unwrap_or_else(|e| panic!("{}: {e}", path.display()));
|
||||
let tree = [egui::Role::Button, egui::Role::SpinButton, egui::Role::CheckBox]
|
||||
.into_iter()
|
||||
.flat_map(|role| harness.get_all_by_role(role))
|
||||
.filter_map(|button| {
|
||||
let node = button.accesskit_node();
|
||||
node.label().map(|label| format!("{label}: disabled={}, checked={:?}", node.is_disabled(), node.toggled()))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n");
|
||||
std::fs::write(dir.join(format!("{name}.txt")), tree).unwrap();
|
||||
eprintln!("wrote {}", path.display());
|
||||
}
|
||||
|
||||
@@ -41,6 +51,28 @@ fn empty_start_snapshot() {
|
||||
harness.state_mut().ui.prefs.language = "en".into();
|
||||
|
||||
save(&mut harness, &output_dir, "empty-start");
|
||||
for top in ["File", "Edit", "Mode", "Window", "Viewport", "Help"] {
|
||||
harness.get_by_label(top).click();
|
||||
harness.run_steps(4);
|
||||
save(&mut harness, &output_dir, &format!("empty-menu-{top}"));
|
||||
if top == "Window" {
|
||||
harness.get_by_label("Views").click();
|
||||
save(&mut harness, &output_dir, "empty-menu-views");
|
||||
}
|
||||
harness.key_press(egui::Key::Escape);
|
||||
harness.key_press(egui::Key::Escape);
|
||||
harness.run_steps(3);
|
||||
}
|
||||
harness.state_mut().ui.toolbar_tools = false;
|
||||
save(&mut harness, &output_dir, "empty-tools-off");
|
||||
for label in ["Snooze Autosave", "Resources Updater"] {
|
||||
assert!(harness.get_by_label(label).accesskit_node().is_disabled());
|
||||
}
|
||||
harness.get_by_label("Edit").click();
|
||||
harness.run_steps(3);
|
||||
harness.get_by_label("Settings").click();
|
||||
save(&mut harness, &output_dir, "settings-recent-project-limit");
|
||||
assert!(!harness.get_by_label("Recent projects limit").accesskit_node().is_disabled());
|
||||
}
|
||||
|
||||
/// Closing rejects a same-frame capture, then releases both rendered view targets.
|
||||
|
||||
@@ -173,21 +173,31 @@ keeps its state in a throwaway file.
|
||||
| `command.list` | `{filter?}` | `[{id, label, menu, shortcut, params, enabled}]` |
|
||||
| `session.inspect` | | project, mesh, texture sets, layer stack, tool, camera, display, history |
|
||||
| `ui.inspect` | | UI state, viewport rect, fps, bake progress (`baking`, 0..1), the running bake's stage (`bakeStatus`, e.g. "Baking Ambient Occlusion (2/4)") and live preview (`bakePreview`, see *Live bake preview*), toasts, `titleBar` (who draws the title bar this run: `app`, `integrated` on macOS, or `system`) |
|
||||
| `ui.menu.list` | | the menu catalog: `{menu, submenu, label, id, shortcut, implemented, enabled}` |
|
||||
| `ui.menu.invoke` | `{id}` | behaves like a menu click (may open a window; `ui.resetUi` opens its question; `file.exportMesh` opens the Mesh Export Options prompt, whose Export asks for the file; `ui.view.export` opens the right bar's Export panel). `{"id": "ui.layout.apply", "name": "<layout>"}` switches to a panel layout saved under Window > Layouts (panels only; mode, zoom and wireframes stay) and errors when no layout has that name. `ui.layout.save` still saves the active mode; `ui.layout.save.painting`, `ui.layout.save.rendering` and `ui.layout.save.baking` ask where to save that mode's layout as a JSON file, `ui.layout.load` asks for one to load ("Select a UI layout file."); `ui.toolbar.docks` and `ui.toolbar.tools` show or hide the right bar and the tool shelf (`ui.toolbar.plugins`, `ui.view.pythonConsole` and `ui.view.onlineAssets` are listed as not implemented and not enabled); `ui.view.renderer` toggles the Renderer Settings panel (Rendering mode only). `{"id": "ui.layout.swap"}` swaps the 3D and 2D views of the split layout (F4) |
|
||||
| `ui.menu.invoke` id `ui.saveAsTemplate` | `{id}` | File > More save options > Save as template... opens a save dialog in the user templates folder. The choice supplies the file path and template name to `project.template.save`. `ui.saveReduced` (Save and reduce file size) is listed as not implemented and not enabled |
|
||||
| `ui.menu.invoke` ids `ui.help.releaseNotes`, `ui.help.exportLog` | `{id}` | Help > Release notes... opens the releases page in the browser; Help > Export log... exports the session log with each entry’s recorded UTC time, severity and source (a save dialog on desktop, a download on the web) |
|
||||
| `ui.menu.invoke` id `ui.wireframe` | `{id}` | Show mesh wireframe: shows or hides the mesh wireframe in the 3D and 2D views (the Display Settings check box). It has no menu entry and no default key; bind it in Settings > Shortcuts. The key bindings `camera.next` and `camera.previous` (Select next camera `>`, Select previous camera `<`) and `ui.mode.bake` (Ctrl+Shift+B) run the same commands as before |
|
||||
| `ui.menu.list` | | the menu catalog: `{menu, submenu, label, id, shortcut, implemented, enabled, checked}` |
|
||||
| `ui.menu.invoke` | `{id}` | behaves like a menu click (may open a window; `ui.resetUi` opens its question; `file.exportMesh` opens the Mesh Export Options prompt, whose Export asks for the file; `ui.view.export` opens the right bar's Export panel). `{"id": "ui.layout.apply", "name": "<layout>"}` switches to a legacy named panel layout (still accessible through assigned shortcuts) (panels only; mode, zoom and wireframes stay) and errors when no layout has that name. `ui.layout.save` still saves the active mode; `ui.layout.save.painting`, `ui.layout.save.rendering` and `ui.layout.save.baking` ask where to save only that mode's panels and view arrangement as a JSON file (without preferences or recent projects); loading preserves the other modes, `ui.layout.load` asks for one to load ("Select a UI layout file."); `ui.toolbar.docks` and `ui.toolbar.tools` show or hide the right bar and the painting tools; the disabled Snooze Autosave and Resources Updater buttons stay visible when Tools is off; `ui.view.renderer` toggles the Renderer Settings panel (Rendering Mode only). `{"id": "ui.layout.swap"}` swaps the 3D and 2D views of the split layout (F4) |
|
||||
| `ui.menu.invoke` id `ui.saveAsTemplate` | `{id}` | File > More Save Options > Save As Template opens a save dialog in the user templates folder. The choice supplies the file path and template name to `project.template.save`. `ui.saveReduced` (Save and Reduce File Size) is listed as not implemented and not enabled |
|
||||
| `ui.menu.invoke` ids `ui.help.releaseNotes`, `ui.help.showLog`, `ui.help.exportLog` | `{id}` | Help > Release Notes opens the releases page in the browser; Help > Show Log opens the current desktop run's rolling `log.txt` in the system text-file handler; Help > Export Log exports the session log with each entry’s recorded UTC time, severity and source (a save dialog on desktop with a `Log_TextureCraft_<version>_<date>_<os>_<gpuMode>.txt` name, a download on the web) |
|
||||
| `ui.menu.invoke` id `ui.wireframe` | `{id}` | Show mesh wireframe: shows or hides the mesh wireframe in the 3D and 2D views (the Display Settings check box). It has no menu entry and no default key; bind it in Settings > Shortcuts. The key bindings `camera.next` and `camera.previous` (Select next camera `>`, Select previous camera `<`) and `ui.mode.bake` (F8) run the same commands as before |
|
||||
| `ui.reset` | | resets the panels, view layout, zoom and every other view setting at once, without the question the Reset UI menu item asks; settings and shortcuts stay |
|
||||
| `ui.bake.start` | `{ts?: index \| [indices]}` (default: the sets ticked in Bake mode) | Opens Bake mode and bakes in the background like the Bake button: the 3D view shows the maps landing on the model as they finish (see *Live bake preview*). → the `bake.preview` state. Errors when a bake is already running |
|
||||
| `ui.bake.cancel` | | Stops the running bake; the set being baked keeps the maps it had, sets already finished stay applied, and the previous view mode comes back |
|
||||
| `ui.set` | fields of the UI state, e.g. `{"layout": "Only3D"}`; `dock` is the panel layout, a craft-ui docking `Workspace` (`{version, layout: {root, floating}, hidden}`; `root` is a tree of `Split`, `Tabs` and `Stack` nodes over the panels `Viewport`, `Assets`, `TextureSetList`, `Layers`, `TextureSetSettings`, `Properties`, `Display`, `Shader`, `History`, `Log`, `Export` and `Renderer` (a floating window holding one right-bar panel is that panel undocked); `hidden` lists where each closed panel was, so reopening it puts it back; a layout that does not read or has no docked `Viewport` becomes the default), `prefs` the settings (`{"language": "ja", "viewport_texture": 1, "brightness": "light", "accent": "blue"}`; missing fields take their defaults; `brightness` is `dark`, `mediumDark` (default), `mediumLight` or `light`, `accent` `copper` (default), `coral`, `blue`, `violet`, `green`, `amber` or `pink`, applied on the next frame; `system_title_bar` `true` has the system draw the title bar from the next start), `keymap` the custom shortcuts (`{"file.save": "F5"}`, `""` unbinds), `log_channel` the Log panel's tab (`General` or `Assets`) | `null` |
|
||||
| `ui.set` | fields of the UI state, e.g. `{"layout": "Only3D"}`; `dock` is the panel layout, a craft-ui docking `Workspace` (`{version, layout: {root, floating}, hidden}`; `root` is a tree of `Split`, `Tabs` and `Stack` nodes over the panels `Viewport`, `Assets`, `TextureSetList`, `Layers`, `TextureSetSettings`, `Properties`, `Display`, `Shader`, `History`, `Log`, `BakingLog`, `MeshMapBakers`, `MeshMapSettings`, `CommonSettings`, `Export` and `Renderer` (a floating window holding one right-bar panel is that panel undocked); `hidden` lists where each closed panel was, so reopening it puts it back; a layout that does not read or has no docked `Viewport` becomes the default), `prefs` the settings (`{"language": "ja", "viewport_texture": 1, "brightness": "light", "accent": "blue"}`; missing fields take their defaults; `brightness` is `dark`, `mediumDark` (default), `mediumLight` or `light`, `accent` `copper` (default), `coral`, `blue`, `violet`, `green`, `amber` or `pink`, applied on the next frame; `system_title_bar` `true` has the system draw the title bar from the next start), `keymap` the custom shortcuts (`{"file.save": "F5"}`, `""` unbinds), `log_channel` the Log panel's tab (`General` or `Assets`) | `null` |
|
||||
| `viewport.screenshot` | `{view?: "3d" \| "2d"}` | `{width, height, png}` (PNG, base64) |
|
||||
| `ui.screenshot` | | `{width, height, png}` of the whole window, after the next frame |
|
||||
| `ui.resize` | `{width, height}` | Sets the window's inner size in points (640–7680), leaving maximized state; for recordings and screenshots at a fixed size |
|
||||
| `debug.paintTest` | `{from: [x, y], to: [x, y], frames?: 120}` | Paints a straight stroke through the real frame loop (viewport pixels, one point per frame) for performance work |
|
||||
| `debug.frames` | | Frame timing since the last call (then cleared): `{frames, intervalMs, uiMs, syncMs, logicMs}` each `{avg, p95, max}`; `syncMs` is compositing plus display tile conversion, `logicMs` input, control requests and scripted strokes before the UI is built; `worst` breaks down the slowest frame; `strokeEnd` lists the frame that committed a `debug.paintTest` stroke and the one after it (null without one) |
|
||||
|
||||
The empty-project menus keep Recent Projects openable with Clear disabled when the list is empty.
|
||||
`ui.recent.clear` clears that list. More Save Options is disabled until a project is open.
|
||||
Help > Shortcuts list opens Settings on its Shortcuts page. Window > Reset UI restores the
|
||||
Assets, Layers, Properties, Texture Set List and Texture Set Settings panels and both toolbars.
|
||||
Baking Log and the bake/render settings views are disabled without a project. Import resources
|
||||
can open its dialog on desktop without a project; importing still requires an open project,
|
||||
and the dialog explains that asset-library import is not available yet.
|
||||
|
||||
Settings > General > Recent Projects limit controls the retained history (default 10, range 0–100; 0 disables history). Automation uses `ui.set {"prefs":{"recent_projects_limit":10}}`. A lower limit trims the oldest paths immediately.
|
||||
|
||||
Example session:
|
||||
|
||||
```text
|
||||
@@ -527,13 +537,13 @@ In the app, `viewport.frame` also resets the 2D view (pan, zoom and rotation), a
|
||||
|
||||
`camera.view {view}` looks at the mesh from one side (`front` from +Z, `back`, `left` from -X,
|
||||
`right`, `top` and `bottom` at the orbit's ±89° pitch limit) and frames it; the projection stays.
|
||||
`camera.view.front` … `camera.view.bottom` do the same without params (Viewport menu, no default
|
||||
`camera.view.front` … `camera.view.bottom` do the same without params (no default
|
||||
shortcut, bindable in Settings ▸ Shortcuts). `camera.perspective` (F5) and `camera.orthographic` (F6)
|
||||
change only the projection; position and rotation stay. None of them is an undo step. In the 3D
|
||||
view, Alt+Shift+left drag orbits in 90° steps.
|
||||
|
||||
`camera.rotation {mode: constrained|free}` (or `camera.rotation.constrained` / `camera.rotation.free`,
|
||||
Viewport menu and the rotation dropdown of the top bar) picks the orbit: constrained (the default) keeps
|
||||
the rotation dropdown of the top bar) picks the orbit: constrained (the default) keeps
|
||||
the horizon level and stops at the poles; free is a trackball that turns the camera about its own axes,
|
||||
so the model can be turned over and rolled. `camera.get` shows it as `rotation`; `camera.set` takes
|
||||
`rotation` too. Switching keeps the direction of view; going back to constrained drops the roll.
|
||||
|
||||
+41
-64
@@ -2,28 +2,26 @@
|
||||
|
||||
Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Each row is a menu item of the target menu layout with TextureCraft's command id; **live** means the id is implemented. Feature parity beyond menus is tracked in [`ROADMAP.md`](../ROADMAP.md).
|
||||
|
||||
**83 of 87 menu items live (95%).**
|
||||
**63 of 64 menu items live (98%).**
|
||||
|
||||
## File
|
||||
|
||||
| Item | Id | Shortcut | Status |
|
||||
|---|---|---|---|
|
||||
| New project... | `ui.newProject` | Ctrl+N | live |
|
||||
| Open... | `file.open` | Ctrl+O | live |
|
||||
| Open sample project... | `project.sample` | | live |
|
||||
| New Project | `ui.newProject` | Ctrl+N | live |
|
||||
| Open | `file.open` | Ctrl+O | live |
|
||||
| Recent Projects ▸ Clear | `ui.recent.clear` | | live |
|
||||
| Open Sample Project | `project.sample` | | live |
|
||||
| Close | `file.close` | Ctrl+F4 | live |
|
||||
| Save | `file.save` | Ctrl+S | live |
|
||||
| Save as... | `file.saveAs` | Ctrl+Shift+S | live |
|
||||
| More save options ▸ Save as template... | `ui.saveAsTemplate` | | live |
|
||||
| More save options ▸ Save and reduce file size | `ui.saveReduced` | | missing |
|
||||
| More save options ▸ Save as copy... | `file.saveCopy` | | live |
|
||||
| Remove unused resources... | `file.removeUnused` | | live |
|
||||
| Import resources... | `resource.import` | | live |
|
||||
| Import MaterialX material... | `file.importMaterialX` | | live |
|
||||
| Import PBR texture folder... | `file.importPbrFolder` | | live |
|
||||
| Import material... | `material.load` | | live |
|
||||
| Export Textures... | `ui.export` | Ctrl+Shift+E | live |
|
||||
| Export Mesh... | `file.exportMesh` | | live |
|
||||
| Save As | `file.saveAs` | Ctrl+Shift+S | live |
|
||||
| More Save Options ▸ Save As Template | `ui.saveAsTemplate` | | live |
|
||||
| More Save Options ▸ Save and Reduce File Size | `ui.saveReduced` | | missing |
|
||||
| More Save Options ▸ Save As Copy | `file.saveCopy` | | live |
|
||||
| Remove Unused Resources | `file.removeUnused` | | live |
|
||||
| Import Resources | `resource.import` | | live |
|
||||
| Export Textures | `ui.export` | Ctrl+Shift+E | live |
|
||||
| Export Mesh | `file.exportMesh` | | live |
|
||||
| Quit | `ui.quit` | Ctrl+Q | live |
|
||||
|
||||
## Edit
|
||||
@@ -32,23 +30,24 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Eac
|
||||
|---|---|---|---|
|
||||
| Undo | `edit.undo` | Ctrl+Z | live |
|
||||
| Redo | `edit.redo` | Ctrl+Y | live |
|
||||
| Project Configuration... | `ui.projectConfig` | | live |
|
||||
| Reimport mesh | `file.reimportMesh` | Ctrl+Shift+R | live |
|
||||
| Settings... | `ui.settings` | | live |
|
||||
| Project Configuration | `ui.projectConfig` | | live |
|
||||
| Reimport Mesh | `file.reimportMesh` | Ctrl+Shift+R | live |
|
||||
| Settings | `ui.settings` | | live |
|
||||
|
||||
## Mode
|
||||
|
||||
| Item | Id | Shortcut | Status |
|
||||
|---|---|---|---|
|
||||
| Bake Mesh Maps | `ui.mode.bake` | Ctrl+Shift+B | live |
|
||||
| Bake Mesh Maps | `ui.mode.bake` | F8 | live |
|
||||
| Painting | `ui.mode.paint` | F9 | live |
|
||||
| Rendering (path traced) | `ui.mode.render` | F10 | live |
|
||||
| Rendering | `ui.mode.render` | F10 | live |
|
||||
|
||||
## Window
|
||||
|
||||
| Item | Id | Shortcut | Status |
|
||||
|---|---|---|---|
|
||||
| Views ▸ Assets | `ui.view.assets` | | live |
|
||||
| Views ▸ Baking Log | `ui.view.bakingLog` | | live |
|
||||
| Views ▸ Common Settings | `ui.view.bakeSettings` | | live |
|
||||
| Views ▸ Display Settings | `ui.view.display` | | live |
|
||||
| Views ▸ Export | `ui.view.export` | | live |
|
||||
@@ -58,66 +57,44 @@ Generated by `TC_UPDATE_PARITY=1 cargo test -p texturecraft-ui-egui parity`. Eac
|
||||
| Views ▸ Mesh Map Bakers | `ui.view.meshMapBakers` | | live |
|
||||
| Views ▸ Mesh Map Settings | `ui.view.bakeMaps` | | live |
|
||||
| Views ▸ Properties | `ui.view.properties` | | live |
|
||||
| Views ▸ Python Console | `ui.view.pythonConsole` | | missing |
|
||||
| Views ▸ Renderer Settings | `ui.view.renderer` | | live |
|
||||
| Views ▸ Shader Settings | `ui.view.shader` | | live |
|
||||
| Views ▸ Online assets | `ui.view.onlineAssets` | | missing |
|
||||
| Views ▸ Texture Sets | `ui.view.textureSetList` | | live |
|
||||
| Views ▸ Texture Set List | `ui.view.textureSetList` | | live |
|
||||
| Views ▸ Texture Set Settings | `ui.view.textureSetSettings` | | live |
|
||||
| Toolbars ▸ Docks | `ui.toolbar.docks` | | live |
|
||||
| Toolbars ▸ Plugins | `ui.toolbar.plugins` | | missing |
|
||||
| Toolbars ▸ Tools | `ui.toolbar.tools` | | live |
|
||||
| Save UI Layout ▸ Painting mode | `ui.layout.save.painting` | | live |
|
||||
| Save UI Layout ▸ Rendering mode | `ui.layout.save.rendering` | | live |
|
||||
| Save UI Layout ▸ Baking mode | `ui.layout.save.baking` | | live |
|
||||
| Save UI Layout ▸ Painting Mode | `ui.layout.save.painting` | | live |
|
||||
| Save UI Layout ▸ Rendering Mode | `ui.layout.save.rendering` | | live |
|
||||
| Save UI Layout ▸ Baking Mode | `ui.layout.save.baking` | | live |
|
||||
| Load UI Layout | `ui.layout.load` | | live |
|
||||
| Layouts ▸ Save current layout as... | `ui.layout.saveAs` | | live |
|
||||
| Layouts ▸ Manage layouts... | `ui.layout.manage` | | live |
|
||||
| Hide UI | `ui.hideUi` | Tab | live |
|
||||
| Reset panel layout | `ui.resetPanelLayout` | | live |
|
||||
| Reset UI | `ui.resetUi` | | live |
|
||||
|
||||
## Viewport
|
||||
|
||||
| Item | Id | Shortcut | Status |
|
||||
|---|---|---|---|
|
||||
| Display material | `viewport.displayMaterial` | M | live |
|
||||
| Display next channel | `viewport.nextChannel` | C | live |
|
||||
| Display previous channel | `viewport.previousChannel` | Shift+C | live |
|
||||
| Display next mesh map | `viewport.nextMeshMap` | B | live |
|
||||
| Display previous mesh map | `viewport.previousMeshMap` | Shift+B | live |
|
||||
| UV checker | `ui.uvChecker` | | live |
|
||||
| Frame texture set | `viewport.frameSelection` | Shift+F | live |
|
||||
| Show entire mesh | `viewport.frame` | F | live |
|
||||
| Front view | `camera.view.front` | | live |
|
||||
| Back view | `camera.view.back` | | live |
|
||||
| Left view | `camera.view.left` | | live |
|
||||
| Right view | `camera.view.right` | | live |
|
||||
| Top view | `camera.view.top` | | live |
|
||||
| Bottom view | `camera.view.bottom` | | live |
|
||||
| Perspective | `camera.perspective` | F5 | live |
|
||||
| Orthographic | `camera.orthographic` | F6 | live |
|
||||
| 3D/2D views | `ui.layout.split` | F1 | live |
|
||||
| 3D view only | `ui.layout.3d` | F2 | live |
|
||||
| 2D view only | `ui.layout.2d` | F3 | live |
|
||||
| Swap 3D/2D | `ui.layout.swap` | F4 | live |
|
||||
| Navigation buttons | `ui.navButtons` | | live |
|
||||
| Enable quick mask | `viewport.quickMask` | Y | live |
|
||||
| Edit quick mask | `viewport.quickMask.edit` | U | live |
|
||||
| Invert quick mask | `viewport.quickMask.invert` | Ctrl+Shift+I | live |
|
||||
| Display Material | `viewport.displayMaterial` | M | live |
|
||||
| Display Next Channel | `viewport.nextChannel` | C | live |
|
||||
| Display Previous Channel | `viewport.previousChannel` | Shift+C | live |
|
||||
| Display Next Mesh Map | `viewport.nextMeshMap` | B | live |
|
||||
| Display Previous Mesh Map | `viewport.previousMeshMap` | Shift+B | live |
|
||||
| Show Entire Mesh/Path | `viewport.frame` | F | live |
|
||||
| Enable Quick Mask | `viewport.quickMask` | Y | live |
|
||||
| Edit Quick Mask | `viewport.quickMask.edit` | U | live |
|
||||
| Invert Quick Mask | `viewport.quickMask.invert` | Ctrl+Shift+I | live |
|
||||
|
||||
## Help
|
||||
|
||||
| Item | Id | Shortcut | Status |
|
||||
|---|---|---|---|
|
||||
| Release notes... | `ui.help.releaseNotes` | | live |
|
||||
| Documentation... | `ui.help.docs` | | live |
|
||||
| Shortcuts list... | `ui.help.shortcuts` | | live |
|
||||
| Join the community (Discord)... | `ui.help.discord` | | live |
|
||||
| ArtCraft website... | `ui.help.website` | | live |
|
||||
| Report a bug... | `ui.help.bug` | | live |
|
||||
| Show log... | `ui.view.log` | | live |
|
||||
| Export log... | `ui.help.exportLog` | | live |
|
||||
| Check for Updates... | `ui.help.checkForUpdates` | | live |
|
||||
| About TextureCraft... | `ui.about` | | live |
|
||||
| Release Notes | `ui.help.releaseNotes` | | live |
|
||||
| Documentation | `ui.help.docs` | | live |
|
||||
| Shortcuts List | `ui.help.shortcuts` | | live |
|
||||
| Discord | `ui.help.discord` | | live |
|
||||
| Report a Bug | `ui.help.bug` | | live |
|
||||
| Show Log | `ui.help.showLog` | | live |
|
||||
| Export Log | `ui.help.exportLog` | | live |
|
||||
| Check for Updates | `ui.help.checkForUpdates` | | live |
|
||||
| About TextureCraft | `ui.about` | | live |
|
||||
|
||||
Reference in new issue
Block a user