Select Color: one fixed colour book folder instead of a folder list setting

The color_book_dirs setting is gone. Colour books live in color_books in
the config folder (book::folder()), like the other fixed locations;
Options > Files shows it through Folders::color_books. read_all() and
load_from_dialog() use that folder directly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013rGmDUNr1hUf4zo1X3dak8
This commit is contained in:
Claude committed 2026-10-14 20:15:53 +00:00
1 parent a9d8d4b531
commit 6e05c7e2e5
7 files changed
+47 -72

No files matched your search

+2 -4
View File
@@ -1067,10 +1067,9 @@ pub(super) struct OpenCADStudio {
// ── Floating panel windows ────────────────────────────────────────────
/// The open Select Color panel, if any.
color_picker: Option<crate::ui::color_select::ColorPicker>,
/// The built-in colour books and those in `color_book_dirs`, read
/// lazily when the Select Color panel opens.
/// The built-in colour book and those in the colour book folder, read
/// lazily when the Select Color panel first opens.
color_books: std::sync::Arc<Vec<crate::ui::color_select::book::ColorBook>>,
color_book_dirs: Vec<String>,
color_books_read: bool,
/// Recently committed real colours, newest first.
/// ACI and True Color remain semantically distinct even when their RGB matches.
@@ -4793,7 +4792,6 @@ impl OpenCADStudio {
web_autosave_clear_after: Vec::new(),
color_picker: None,
color_books: Default::default(),
color_book_dirs: Vec::new(),
color_books_read: false,
active_modal: None,
hyperlink_editor_handles: Vec::new(),
-14
View File
@@ -636,10 +636,6 @@ pub struct UserSettings {
/// Blocks palette: library folders or drawings, last used first.
#[serde(default)]
pub block_libraries: Vec<String>,
/// Folders searched for `.acb` colour books. Books loaded in the Select
/// Color panel are copied into the first one.
#[serde(default = "default_color_book_dirs")]
pub color_book_dirs: Vec<String>,
/// Blocks palette view: 0 extra large, 1 large, 2 medium, 3 small icons,
/// 4 details, 5 list.
#[serde(default = "default_block_view")]
@@ -801,15 +797,6 @@ fn default_grid_major() -> u32 {
5
}
/// One folder in the config directory; none on the web, which has no folders.
fn default_color_book_dirs() -> Vec<String> {
#[cfg(not(target_arch = "wasm32"))]
if let Some(dir) = crate::config::config_dir() {
return vec![dir.join("color_books").display().to_string()];
}
Vec::new()
}
fn default_true() -> bool {
true
}
@@ -973,7 +960,6 @@ impl Default for UserSettings {
block_recent: Vec::new(),
block_favorites: Vec::new(),
block_libraries: Vec::new(),
color_book_dirs: default_color_book_dirs(),
block_palette_view: 1,
block_insert: BlockInsertOptions::default(),
block_mru_list: 50,
-5
View File
@@ -868,7 +868,6 @@ impl OpenCADStudio {
block_recent: self.block_palette.recent.clone(),
block_favorites: self.block_palette.favorites.clone(),
block_libraries: self.block_palette.libraries.clone(),
color_book_dirs: self.color_book_dirs.clone(),
block_palette_view: self.block_palette.view as u8,
block_insert: self.block_palette.options.clone(),
block_mru_list: self.block_mru_list,
@@ -1047,10 +1046,6 @@ impl OpenCADStudio {
self.block_palette.recent = s.block_recent.clone();
self.block_palette.favorites = s.block_favorites.clone();
self.block_palette.libraries = s.block_libraries.clone();
if self.color_book_dirs != s.color_book_dirs {
self.color_book_dirs = s.color_book_dirs.clone();
self.color_books_read = false;
}
self.block_palette.view =
crate::ui::window::block_palette::ViewMode::from_u8(s.block_palette_view);
self.block_palette.set_options(s.block_insert.clone());
+5 -9
View File
@@ -11935,9 +11935,7 @@ impl OpenCADStudio {
self.update(Message::ColorWindowPick(color, name))
}
Some(crate::ui::color_select::Outcome::LoadBook) => Task::perform(
crate::ui::color_select::book::load_from_dialog(
self.color_book_dirs.first().cloned(),
),
crate::ui::color_select::book::load_from_dialog(),
Message::ColorBookLoaded,
),
Some(crate::ui::color_select::Outcome::Cancel) => {
@@ -12070,16 +12068,14 @@ impl OpenCADStudio {
document.layers.get(layer).map(|layer| layer.color)
}
/// Read the built-in colour books and every `.acb` in the colour book
/// folders, once until the folders change. A book in a folder replaces a
/// built-in one of the same name.
/// Read the built-in colour book and every `.acb` in the colour book
/// folder, once per session. A book in the folder replaces a built-in
/// one of the same name.
fn read_color_books(&mut self) {
if std::mem::replace(&mut self.color_books_read, true) {
return;
}
self.color_books = std::sync::Arc::new(crate::ui::color_select::book::read_all(
&self.color_book_dirs,
));
self.color_books = std::sync::Arc::new(crate::ui::color_select::book::read_all());
}
/// Colour the selected objects (or set the current colour when nothing
+2 -1
View File
@@ -373,6 +373,8 @@ impl OpenCADStudio {
.map(|_| std::env::temp_dir().display().to_string()),
fonts: crate::io::font_repo::fonts_dir()
.map(|p| p.display().to_string()),
color_books: crate::ui::color_select::book::folder()
.map(|p| p.display().to_string()),
}
}
#[cfg(target_arch = "wasm32")]
@@ -381,7 +383,6 @@ impl OpenCADStudio {
}
},
&self.qnew_template,
&self.color_book_dirs,
self.double_click_block_refedit,
self.double_click_block_attedit,
self.cursor_type,