forked from 1b-agent/opencadstudio-upstream
feat(thumbnail): embed a DWG preview on save, show it on the Start page
Generate a small wire-raster thumbnail when saving a DWG and embed it via acadrust's preview API, so OCS drawings show a thumbnail in file browsers and other CAD applications. Read the embedded preview back cheaply (file header + preview bytes only, no full parse) to show a thumbnail per file in the Start page's Recent Documents panel. - io/thumbnail.rs: CPU rasterizer (current-layout wires -> BMP DIB) plus a preview-only reader/decoder (BMP/PNG -> iced handle) for the Start page. - Embedded on save via stamp_thumbnail on both save paths. - recent_thumbs cache filled on config load / recents change (never from a view); a thumbnail is drawn beside each recent file. Requires acadrust at 3111694 (preview read/write), already pinned in Cargo.lock. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
d38fcda07c
commit
5c4ba97c5f
7 files changed
+326
-10
No files matched your search
@@ -227,6 +227,11 @@ pub(super) struct OpenCADStudio {
|
||||
ribbon: Ribbon,
|
||||
/// Recently opened files, newest first — backs the Start page panel.
|
||||
recent_files: Vec<std::path::PathBuf>,
|
||||
/// Decoded DWG preview thumbnails for the Start page, keyed by path.
|
||||
/// `None` = the file has no readable preview (DXF, missing, WMF). Filled
|
||||
/// lazily by `refresh_recent_thumbs`; never read from a `view` call.
|
||||
recent_thumbs:
|
||||
std::collections::HashMap<std::path::PathBuf, Option<iced::widget::image::Handle>>,
|
||||
/// How many recent files to keep (user-set on the Start page, persisted).
|
||||
recent_limit: usize,
|
||||
/// Live text of the recent-limit input box (may differ from `recent_limit`
|
||||
@@ -2090,6 +2095,7 @@ impl OpenCADStudio {
|
||||
// Populated from the consolidated config after construction
|
||||
// (`apply_config`); default empty here.
|
||||
recent_files: Vec::new(),
|
||||
recent_thumbs: std::collections::HashMap::new(),
|
||||
recent_limit: recent::RECENT_DEFAULT,
|
||||
recent_limit_input: recent::RECENT_DEFAULT.to_string(),
|
||||
command_line: CommandLine::new(),
|
||||
|
||||
Reference in new issue
Block a user