Split bundled palettes into video-game and classic theme packs
This commit is contained in:
parent
b20e88e917
commit
dfbfc89945
|
|
@ -548,7 +548,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.44"
|
||||
version = "0.9.45"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"]
|
|||
resolver = "3"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.9.44"
|
||||
version = "0.9.45"
|
||||
edition = "2024"
|
||||
license = "MIT"
|
||||
repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot"
|
||||
|
|
|
|||
|
|
@ -470,20 +470,31 @@ mod tests {
|
|||
assert_eq!(Theme::current(&ctx), missing);
|
||||
}
|
||||
#[test]
|
||||
fn complete_collection_imports_every_theme_and_survives_restart() {
|
||||
let bytes = include_bytes!("../../../docs/theme-packs/extra-themes.zip");
|
||||
fn categorized_collections_coexist_and_survive_restart() {
|
||||
let collections: [(&str, &[u8]); 2] = [
|
||||
(
|
||||
"video-game-themes",
|
||||
include_bytes!("../../../docs/theme-packs/video-game-themes.zip"),
|
||||
),
|
||||
(
|
||||
"classic-themes",
|
||||
include_bytes!("../../../docs/theme-packs/classic-themes.zip"),
|
||||
),
|
||||
];
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let source = dir.path().join("extra-themes.zip");
|
||||
let packs = dir.path().join("installed");
|
||||
std::fs::write(&source, bytes).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
install(&ctx, &packs, &source).unwrap();
|
||||
assert_eq!(installed(&ctx).len(), 1);
|
||||
assert_eq!(choices(&ctx).len(), 16);
|
||||
assert_eq!(
|
||||
std::fs::read(packs.join("extra-themes.zip")).unwrap(),
|
||||
bytes
|
||||
);
|
||||
for (id, bytes) in collections {
|
||||
let source = dir.path().join(format!("{id}.zip"));
|
||||
std::fs::write(&source, bytes).unwrap();
|
||||
install(&ctx, &packs, &source).unwrap();
|
||||
assert_eq!(
|
||||
std::fs::read(packs.join(format!("{id}.zip"))).unwrap(),
|
||||
bytes
|
||||
);
|
||||
}
|
||||
assert_eq!(installed(&ctx).len(), 2);
|
||||
assert_eq!(choices(&ctx).len(), 17);
|
||||
let restarted = egui::Context::default();
|
||||
assert!(load(&restarted, &packs).is_empty());
|
||||
assert_eq!(choices(&ctx), choices(&restarted));
|
||||
|
|
@ -498,19 +509,21 @@ mod tests {
|
|||
});
|
||||
rgb[0] * 0.2126 + rgb[1] * 0.7152 + rgb[2] * 0.0722
|
||||
};
|
||||
for theme in parse(bytes).unwrap().manifest.themes {
|
||||
let choice = Theme::Pack(format!("extra-themes/{}", theme.id));
|
||||
choice.select(&restarted);
|
||||
assert_eq!(Theme::current(&restarted), choice);
|
||||
assert_eq!(choice.display_name(&restarted), theme.name);
|
||||
let p = choice.resolved_palette(&restarted);
|
||||
for bg in [p.bg, p.panel, p.field, p.purple, p.pattern[0], p.pattern[1]] {
|
||||
let (fg, bg) = (luminance(p.text), luminance(bg));
|
||||
assert!(
|
||||
(fg.max(bg) + 0.05) / (fg.min(bg) + 0.05) >= 4.5,
|
||||
"{} contrast",
|
||||
theme.name
|
||||
);
|
||||
for (id, bytes) in collections {
|
||||
for theme in parse(bytes).unwrap().manifest.themes {
|
||||
let choice = Theme::Pack(format!("{id}/{}", theme.id));
|
||||
choice.select(&restarted);
|
||||
assert_eq!(Theme::current(&restarted), choice);
|
||||
assert_eq!(choice.display_name(&restarted), theme.name);
|
||||
let p = choice.resolved_palette(&restarted);
|
||||
for bg in [p.bg, p.panel, p.field, p.purple, p.pattern[0], p.pattern[1]] {
|
||||
let (fg, bg) = (luminance(p.text), luminance(bg));
|
||||
assert!(
|
||||
(fg.max(bg) + 0.05) / (fg.min(bg) + 0.05) >= 4.5,
|
||||
"{} contrast",
|
||||
theme.name
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,14 @@
|
|||
|
||||
## Unreleased
|
||||
|
||||
### v0.9.45
|
||||
|
||||
- Split bundled themes into video-game-themes (6, including Ravenswatch) and
|
||||
classic-themes (11). Retired the combined extra-themes download; standalone
|
||||
palettes are unchanged. New pack IDs coexist with old installations, with
|
||||
explicit selection/removal instructions. Checked partitioning, notices,
|
||||
reproducible archives, simultaneous installation, restart and contrast.
|
||||
|
||||
### v0.9.44
|
||||
|
||||
- Added a separate, reproducible Lumen Forum showcase kit: polished PIP infodecor,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ Theme packs add palettes without rebuilding Canvas Pilot. They change the app,
|
|||
viewport and source-coordinate helper colors; they do not change projects,
|
||||
device transfers, imported pictures, fonts or interface size.
|
||||
|
||||
## Install and try the collection
|
||||
## Install and try the collections
|
||||
|
||||
Download a ZIP, leave it zipped, then open **Settings → Theme packs → Install theme
|
||||
pack…**. Select a pack, then click one of its themes to try it immediately. It also
|
||||
|
|
@ -12,27 +12,41 @@ appears in **More themes…** and recent themes. The picker stays open while you
|
|||
try alternatives. Selecting **High Contrast** twice returns to your last theme,
|
||||
including an installed one.
|
||||
|
||||
Download [extra-themes.zip](../../theme-packs/extra-themes.zip) to install **16 themes in one operation**. It is a single pack: select **extra-themes** in the
|
||||
manager and scroll its contents to try each palette. Removal or replacement applies
|
||||
to the whole collection. Individual packs remain available below; installing both
|
||||
keeps separate copies, so you only need one option for those themes.
|
||||
**Ravenswatch** is available separately: the collection is at the version-1 limit
|
||||
of 16 themes. Install its standalone ZIP alongside the collection.
|
||||
Choose either collection, or install both:
|
||||
|
||||
- [Video-game themes](../../theme-packs/video-game-themes.zip): **6 themes** —
|
||||
Deep Rock Galactic, Detroit: Become Human, Dispatch, Helldivers, Ravenswatch
|
||||
and Vivid World.
|
||||
- [Classic themes](../../theme-packs/classic-themes.zip): **11 themes** —
|
||||
Catppuccin Mocha, Dracula, GitHub Dark/Light, Gruvbox Dark, Monokai, Nord,
|
||||
One Dark, Solarized Dark/Light and Tokyo Night.
|
||||
|
||||
Each ZIP is one normal theme pack. Select **video-game-themes** or **classic-themes**
|
||||
in the manager to try its palettes. Removal or replacement applies to that whole
|
||||
collection. Individual downloads below remain available; installing both an
|
||||
individual pack and its collection keeps separate copies.
|
||||
|
||||
### Video-game themes
|
||||
|
||||
| Pack | Palette | Editable manifest |
|
||||
| --- | --- | --- |
|
||||
| [Detroit: Become Human](../../theme-packs/detroit-become-human.zip) | Deep blue, pale text and cyan android-inspired accents | [manifest.json](../../theme-packs/detroit-become-human/manifest.json) |
|
||||
| [Ravenswatch](../../theme-packs/ravenswatch.zip) | Midnight blue, ivory and crimson | [manifest.json](../../theme-packs/ravenswatch/manifest.json) |
|
||||
| [Vivid World](../../theme-packs/vivid-world.zip) | Midnight navy, violet, pink and cyan crystal accents | [manifest.json](../../theme-packs/vivid-world/manifest.json) |
|
||||
| [Deep Rock Galactic](../../theme-packs/deep-rock-galactic.zip) | Dark, gold/molten-orange accents | [manifest.json](../../theme-packs/deep-rock-galactic/manifest.json) |
|
||||
| [Dispatch](../../theme-packs/dispatch.zip) | Dark, yellow/cyan accents | [manifest.json](../../theme-packs/dispatch/manifest.json) |
|
||||
| [Helldivers](../../theme-packs/helldivers.zip) | Dark | [manifest.json](../../theme-packs/helldivers/manifest.json) |
|
||||
|
||||
### Classic themes
|
||||
|
||||
| Pack | Palette | Editable manifest |
|
||||
| --- | --- | --- |
|
||||
| [Tokyo Night](../../theme-packs/tokyo-night.zip) | Dark blue with cool cyan accents | [manifest.json](../../theme-packs/tokyo-night/manifest.json) |
|
||||
| [Catppuccin Mocha](../../theme-packs/catppuccin.zip) | Soft charcoal and pastel accents | [manifest.json](../../theme-packs/catppuccin/manifest.json) |
|
||||
| [Detroit: Become Human](../../theme-packs/detroit-become-human.zip) | Deep blue, pale text and cyan android-inspired accents | [manifest.json](../../theme-packs/detroit-become-human/manifest.json) |
|
||||
| [Ravenswatch](../../theme-packs/ravenswatch.zip) | Midnight blue, ivory and crimson (standalone) | [manifest.json](../../theme-packs/ravenswatch/manifest.json) |
|
||||
| [Vivid World](../../theme-packs/vivid-world.zip) | Midnight navy, violet, pink and cyan crystal accents | [manifest.json](../../theme-packs/vivid-world/manifest.json) |
|
||||
| [Deep Rock Galactic](../../theme-packs/deep-rock-galactic.zip) | Dark, gold/molten-orange accents | [manifest.json](../../theme-packs/deep-rock-galactic/manifest.json) |
|
||||
| [Dispatch](../../theme-packs/dispatch.zip) | Dark, yellow/cyan accents | [manifest.json](../../theme-packs/dispatch/manifest.json) |
|
||||
| [Dracula](../../theme-packs/dracula.zip) | Dark | [manifest.json](../../theme-packs/dracula/manifest.json) |
|
||||
| [GitHub Dark](../../theme-packs/github-dark.zip) | Dark | [manifest.json](../../theme-packs/github-dark/manifest.json) |
|
||||
| [GitHub Light](../../theme-packs/github-light.zip) | Light | [manifest.json](../../theme-packs/github-light/manifest.json) |
|
||||
| [Gruvbox Dark](../../theme-packs/gruvbox-dark.zip) | Dark | [manifest.json](../../theme-packs/gruvbox-dark/manifest.json) |
|
||||
| [Helldivers](../../theme-packs/helldivers.zip) | Dark | [manifest.json](../../theme-packs/helldivers/manifest.json) |
|
||||
| [Monokai](../../theme-packs/monokai.zip) | Dark | [manifest.json](../../theme-packs/monokai/manifest.json) |
|
||||
| [Nord](../../theme-packs/nord.zip) | Dark | [manifest.json](../../theme-packs/nord/manifest.json) |
|
||||
| [One Dark](../../theme-packs/one-dark.zip) | Dark | [manifest.json](../../theme-packs/one-dark/manifest.json) |
|
||||
|
|
@ -46,9 +60,14 @@ The Detroit, Vivid World, Ravenswatch, Dispatch, Helldivers and Deep Rock Galact
|
|||
original, unofficial color interpretations;
|
||||
they include no game artwork, fonts or code and are not endorsed by the games' owners.
|
||||
|
||||
The current collection replaces Minecraft with Vivid World. Reimport the collection
|
||||
to update; if Minecraft was selected, choose Vivid World after the update returns
|
||||
to Midra Dark. A separately installed Minecraft pack remains until you remove it.
|
||||
### Moving from the old combined pack
|
||||
|
||||
The two collections replace the former `extra-themes.zip` download and have new
|
||||
pack IDs. Install the desired collections, select a theme from one of them, then
|
||||
remove **extra-themes** in Settings if you no longer need its duplicate entries.
|
||||
Existing installations and saved choices are not renamed or deleted automatically.
|
||||
Removing a pack while its theme is active falls back to Midra Dark. Standalone
|
||||
packs, including older Minecraft installations, remain user-managed.
|
||||
|
||||
## Manage packs
|
||||
|
||||
|
|
@ -88,4 +107,4 @@ poorly contrasted colors automatically.
|
|||
|
||||
The [theme-pack contract](../../interfaces/theme-packs.md) lists all palette roles,
|
||||
validation limits, settings compatibility and round-trip behavior. Repository
|
||||
contributors regenerate the individual ZIPs and the combined collection with `python3 scripts/build-theme-packs.py`.
|
||||
contributors regenerate the individual ZIPs and both collections with `python3 scripts/build-theme-packs.py`.
|
||||
|
|
|
|||
|
|
@ -101,20 +101,26 @@ and Unix file metadata so exact rebuilds do not depend on the host or zlib versi
|
|||
Their manifest bytes, pack revisions and version-1 representation are unchanged;
|
||||
the importer continues to accept both stored and DEFLATE-compressed packs.
|
||||
|
||||
## Bundled collection
|
||||
## Bundled collections
|
||||
|
||||
`docs/theme-packs/extra-themes.zip` is a normal version-1 pack (`extra-themes`,
|
||||
revision 4), containing 16 curated themes. One import validates and installs
|
||||
all entries atomically; it does not unpack nested ZIPs. The build script combines
|
||||
the explicitly listed collection manifests in sorted path order, prefixes theme IDs with their source
|
||||
pack ID and preserves all notices. Individual packs and the collection have distinct
|
||||
saved choices and can coexist. Updates and removal operate on the whole collection.
|
||||
Two normal version-1 packs partition the 17 distributed themes, with no duplicate
|
||||
membership and each below the 16-theme limit:
|
||||
|
||||
Collection revision 4 replaces `minecraft-overworld` with `vivid-world-default`.
|
||||
Updating while Minecraft is active uses the existing removed-theme fallback to
|
||||
Midra Dark; Vivid World can then be selected explicitly. Older standalone Minecraft
|
||||
installations are not deleted or remapped by this collection update.
|
||||
| File / pack ID | Revision | Contents |
|
||||
| --- | --- | --- |
|
||||
| `video-game-themes.zip` / `video-game-themes` | 1 | 6: Deep Rock Galactic, Detroit: Become Human, Dispatch, Helldivers, Ravenswatch, Vivid World |
|
||||
| `classic-themes.zip` / `classic-themes` | 1 | 11: Catppuccin, Dracula, GitHub Dark/Light, Gruvbox Dark, Monokai, Nord, One Dark, Solarized Dark/Light, Tokyo Night |
|
||||
|
||||
Ravenswatch is a separate version-1 pack, not a seventeenth collection entry.
|
||||
The build script validates every standalone archive and requires every listed
|
||||
collection manifest; adding a standalone pack does not change collection contents.
|
||||
The build script combines explicitly assigned manifests in sorted path order,
|
||||
prefixes each theme ID with its source pack ID and preserves notices. Missing or
|
||||
uncategorized sources fail the build. Import installs each collection atomically;
|
||||
it does not unpack nested archives. Individual packs and collections have distinct
|
||||
saved choices and can coexist. Updates and removal operate on the chosen pack.
|
||||
|
||||
These replace the distributed `extra-themes.zip` (last revision 4), without
|
||||
reusing or silently reinterpreting its ID. Old saved `extra-themes/<theme-id>`
|
||||
choices continue to resolve while the old pack is installed. Users install the
|
||||
new collections, explicitly select their new choice, and optionally remove the
|
||||
old pack. Removing an active old pack uses the existing Midra Dark fallback.
|
||||
No settings/project version or automatic migration changes. Standalone pack IDs,
|
||||
revisions, palette bytes and installed copies remain unchanged.
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -7,13 +7,17 @@ import json
|
|||
import zipfile
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
# Curated v1 collection: new standalone packs must not silently replace its entries.
|
||||
COLLECTION_PACKS = frozenset({
|
||||
'catppuccin', 'deep-rock-galactic', 'detroit-become-human', 'dispatch',
|
||||
'dracula', 'github-dark', 'github-light', 'gruvbox-dark', 'helldivers',
|
||||
'monokai', 'nord', 'one-dark', 'solarized-dark', 'solarized-light',
|
||||
'tokyo-night', 'vivid-world',
|
||||
})
|
||||
# Explicit membership keeps each normal v1 pack below its 16-theme limit.
|
||||
COLLECTIONS = {
|
||||
'video-game-themes': frozenset({
|
||||
'deep-rock-galactic', 'detroit-become-human', 'dispatch', 'helldivers',
|
||||
'ravenswatch', 'vivid-world',
|
||||
}),
|
||||
'classic-themes': frozenset({
|
||||
'catppuccin', 'dracula', 'github-dark', 'github-light', 'gruvbox-dark',
|
||||
'monokai', 'nord', 'one-dark', 'solarized-dark', 'solarized-light', 'tokyo-night',
|
||||
}),
|
||||
}
|
||||
|
||||
|
||||
def archive(manifest):
|
||||
|
|
@ -28,10 +32,14 @@ def archive(manifest):
|
|||
return buffer.getvalue()
|
||||
|
||||
|
||||
def collection(sources):
|
||||
def collection(sources, collection_id):
|
||||
"""One normal v1 pack: the existing importer installs every contained theme."""
|
||||
sources = [source for source in sources if source.parent.name in COLLECTION_PACKS]
|
||||
if {source.parent.name for source in sources} != COLLECTION_PACKS:
|
||||
members = COLLECTIONS[collection_id]
|
||||
sources = list(sources)
|
||||
if {source.parent.name for source in sources} - set().union(*COLLECTIONS.values()):
|
||||
raise ValueError('A theme has no collection assignment')
|
||||
sources = [source for source in sources if source.parent.name in members]
|
||||
if {source.parent.name for source in sources} != members:
|
||||
raise ValueError('A required collection manifest is missing')
|
||||
themes = []
|
||||
notices = []
|
||||
|
|
@ -42,7 +50,7 @@ def collection(sources):
|
|||
notices.append(manifest['id'] + '\n' + manifest.get('notices', ''))
|
||||
if not 1 <= len(themes) <= 16:
|
||||
raise ValueError('The collection must respect the v1 limit of 16 themes')
|
||||
manifest = dict(version=1, id='extra-themes', revision=4,
|
||||
manifest = dict(version=1, id=collection_id, revision=1,
|
||||
themes=themes, notices='\n\n'.join(notices))
|
||||
return (json.dumps(manifest, indent=2) + '\n').encode()
|
||||
|
||||
|
|
@ -53,7 +61,8 @@ def main():
|
|||
args = parser.parse_args()
|
||||
sources = sorted((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
|
||||
outputs = [(source.parent.with_suffix('.zip'), source.read_bytes()) for source in sources]
|
||||
outputs.append((ROOT / 'docs/theme-packs/extra-themes.zip', collection(sources)))
|
||||
outputs.extend((ROOT / f'docs/theme-packs/{name}.zip', collection(sources, name))
|
||||
for name in COLLECTIONS)
|
||||
for target, manifest in outputs:
|
||||
data = archive(manifest)
|
||||
if args.check:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ThemePackExamples(unittest.TestCase):
|
|||
def test_rebuild_does_not_depend_on_zlib_or_host_platform(self):
|
||||
sources = sorted((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
|
||||
manifests = [source.read_bytes() for source in sources]
|
||||
manifests.append(module.collection(sources))
|
||||
manifests.extend(module.collection(sources, name) for name in module.COLLECTIONS)
|
||||
for manifest in manifests:
|
||||
expected = module.archive(manifest)
|
||||
with mock.patch.object(zipfile, 'zlib', None), mock.patch('sys.platform', 'win32'):
|
||||
|
|
@ -39,25 +39,36 @@ class ThemePackExamples(unittest.TestCase):
|
|||
self.assertEqual(archive.namelist(), ['manifest.json'])
|
||||
self.assertEqual(archive.read('manifest.json'), source.read_bytes())
|
||||
|
||||
def test_collection_contains_curated_themes_and_notices(self):
|
||||
def test_collections_partition_every_theme_and_preserve_notices(self):
|
||||
sources = list((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
|
||||
data = module.collection(sources)
|
||||
self.assertEqual(data, module.collection(reversed(sources)))
|
||||
self.assertEqual(module.archive(data), (ROOT / 'docs/theme-packs/extra-themes.zip').read_bytes())
|
||||
combined = json.loads(data)
|
||||
self.assertEqual(combined['id'], 'extra-themes')
|
||||
self.assertEqual(len(combined['themes']), 16)
|
||||
self.assertEqual(len({t['id'] for t in combined['themes']}), 16)
|
||||
self.assertNotIn('ravenswatch-default', {t['id'] for t in combined['themes']})
|
||||
for source in sources:
|
||||
if source.parent.name not in module.COLLECTION_PACKS:
|
||||
continue
|
||||
manifest = json.loads(source.read_bytes())
|
||||
self.assertIn(manifest['notices'], combined['notices'])
|
||||
for theme in manifest['themes']:
|
||||
self.assertIn({**theme, 'id': manifest['id'] + '-' + theme['id']}, combined['themes'])
|
||||
assigned = set()
|
||||
for name, members in module.COLLECTIONS.items():
|
||||
self.assertFalse(assigned & members)
|
||||
assigned.update(members)
|
||||
data = module.collection(sources, name)
|
||||
self.assertEqual(data, module.collection(reversed(sources), name))
|
||||
self.assertEqual(module.archive(data), (ROOT / f'docs/theme-packs/{name}.zip').read_bytes())
|
||||
combined = json.loads(data)
|
||||
self.assertEqual(combined['id'], name)
|
||||
self.assertEqual(len(combined['themes']), len(members))
|
||||
self.assertLessEqual(len(combined['themes']), 16)
|
||||
self.assertEqual(len({t['id'] for t in combined['themes']}), len(members))
|
||||
for source in sources:
|
||||
if source.parent.name not in members:
|
||||
continue
|
||||
manifest = json.loads(source.read_bytes())
|
||||
self.assertIn(manifest['notices'], combined['notices'])
|
||||
for theme in manifest['themes']:
|
||||
self.assertIn({**theme, 'id': manifest['id'] + '-' + theme['id']}, combined['themes'])
|
||||
self.assertEqual(assigned, {source.parent.name for source in sources})
|
||||
self.assertIn('ravenswatch', module.COLLECTIONS['video-game-themes'])
|
||||
self.assertEqual(len(module.COLLECTIONS['video-game-themes']), 6)
|
||||
self.assertEqual(len(module.COLLECTIONS['classic-themes']), 11)
|
||||
self.assertFalse((ROOT / 'docs/theme-packs/extra-themes.zip').exists())
|
||||
|
||||
def test_missing_collection_manifest_is_rejected(self):
|
||||
def test_missing_or_uncategorized_collection_manifest_is_rejected(self):
|
||||
sources = list((ROOT / 'docs/theme-packs').glob('*/manifest.json'))
|
||||
with self.assertRaisesRegex(ValueError, 'required collection manifest'):
|
||||
module.collection(source for source in sources if source.parent.name != 'dispatch')
|
||||
module.collection((source for source in sources if source.parent.name != 'dispatch'), 'video-game-themes')
|
||||
with self.assertRaisesRegex(ValueError, 'no collection assignment'):
|
||||
module.collection(sources + [ROOT / 'docs/theme-packs/unknown/manifest.json'], 'classic-themes')
|
||||
|
|
|
|||
Loading…
Reference in New Issue