Skip to content

Feature: Default / startup project, mode persistence, selectable log #52

Description

@trailcode

Summary

This work adds a bundled default .ezy that loads on startup, an optional user-specific startup project (Blender-style), correct persistence and restoration of UI mode in project files, startup diagnostics in the log panel, a selectable / copyable log (read-only multiline ImGui input), and CMake/copy/preload wiring for native and Emscripten builds. Documentation in usage.md describes the startup-project flow.


What changed

Build & resources (CMakeLists.txt)

  • Preload res/default.ezy into the Emscripten virtual FS (Release and Debug linker flags).
  • Post-build copy of res/default.ezy next to the executable for native and Emscripten output (alongside existing res/ezycad_settings.json copy).

Bundled template (res/default.ezy)

  • New committed default project (includes sample geometry, sketch, view block, mode).

Startup & user override (src/gui.cpp, src/gui.h, src/settings.cpp, src/settings.h)

  • load_default_project_() after init: tries saved startup first, then res/default.ezy, with JSON validation and fallback messaging.
  • User startup: startup.ezy under OS config dir (Windows %APPDATA%\EzyCad\, macOS ~/Library/Application Support/EzyCad/, Linux $XDG_CONFIG_HOME/EzyCad or ~/.config/EzyCad/); Emscripten: localStorage key ezycad_startup_ezy.
  • Settings window: Startup project section — “Save current as startup project” / “Clear saved startup”.
  • After loading a startup template, m_last_saved_path is cleared so Save does not target the startup file by default.
  • on_file(..., announce_load) — startup loads use announce_load = false (no “Opened” toast).
  • serialized_project_json_() — shared serialization for Save and save-startup (includes mode).
  • Startup logging to the log panel (ASCII-only punctuation so the bundled font does not show ? for Unicode ellipsis/arrows).

Mode after open (src/occt_view.cpp, src/gui.cpp)

  • Removed gui().set_mode(Mode::Normal) at end of Occt_view::load(), which previously overwrote mode restored from the file.
  • on_file applies mode from JSON after m_view->load(); missing/invalid modeNormal.

Log panel (src/gui.cpp, src/gui.h)

  • Replaced per-line TextWrapped with a single InputTextMultiline buffer (read-only) for text selection and copy (Ctrl+C when focused).
  • ImGuiInputTextFlags_CallbackAlways + small callback to scroll caret to end when new lines are appended.

Docs (usage.md)

  • New “Startup project (defaults)” section (Settings-based workflow, paths, web storage).

Suggested testing

  1. Clean profile: No startup.ezy / no localStorage entry — app loads res/default.ezy, log shows bundled path; mode matches file.
  2. Save startup: Settings → save startup — restart — saved project loads; Save still prompts or uses last path only after a normal Open/Save-as.
  3. Clear startup — next run uses bundled default again.
  4. .ezy round-trip: Save with a non-Normal mode, reopen — mode restored.
  5. Log: Select log text, copy with Ctrl+C.
  6. Wasm: Preload present; startup from localStorage if set.
  7. Native: POST_BUILD copy places res/default.ezy beside the binary; run CWD as build output (existing VS debug layout).

Optional follow-ups

  • Add trailing newline to res/default.ezy if tooling complains (\ No newline at end of file in diff).
  • Consider factory reset that reloads bundled default in-session without restart.
  • localStorage size limits for very large startup projects on web.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions