mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 12:21:08 +01:00
Layers: a horizontal and a vertical ruler guide's rows show a glyph of their own, a line across or down from a ruler, as production's rows drew a line across or down
This commit is contained in:
1 parent
b1a1c0b7a8
commit
6ac3f3a6c4
6 files changed
+38
-1
No files matched your search
@@ -207,6 +207,8 @@ Generated-in-code art is original and has no file to list. This covers the defau
|
||||
| `assets/icons/dc-graphic-styles.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-grid-view.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-group-select.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-guide-horizontal.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a ruler down the left with a line across) | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-guide-vertical.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a ruler along the top with a line down) | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-help.svg` | VectorCraft contributors | Original work, drawn for VectorCraft (a question mark in a circle) | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-join-bevel.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
| `assets/icons/dc-join-miter.svg` | VectorCraft contributors | Original work, drawn for VectorCraft | MIT OR Apache-2.0 | |
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="4" height="18"/><path d="M5 6.5h2M5 9.5h2M5 14.5h2M5 17.5h2"/><path d="M9.5 12H21"/></svg>
|
||||
|
After Width: | Height: | Size: 299 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="4"/><path d="M6.5 5v2M9.5 5v2M14.5 5v2M17.5 5v2"/><path d="M12 9.5V21"/></svg>
|
||||
|
After Width: | Height: | Size: 299 B |
@@ -119,6 +119,8 @@ pub static ICONS: &[(&str, &[u8])] = &[
|
||||
("dc-graphic-styles", include_bytes!("../../../assets/icons/dc-graphic-styles.svg")),
|
||||
("dc-grid-view", include_bytes!("../../../assets/icons/dc-grid-view.svg")),
|
||||
("dc-group-select", include_bytes!("../../../assets/icons/dc-group-select.svg")),
|
||||
("dc-guide-horizontal", include_bytes!("../../../assets/icons/dc-guide-horizontal.svg")),
|
||||
("dc-guide-vertical", include_bytes!("../../../assets/icons/dc-guide-vertical.svg")),
|
||||
("dc-help", include_bytes!("../../../assets/icons/dc-help.svg")),
|
||||
("dc-join", include_bytes!("../../../assets/icons/dc-join.svg")),
|
||||
("dc-join-bevel", include_bytes!("../../../assets/icons/dc-join-bevel.svg")),
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::collections::{HashMap, HashSet};
|
||||
use std::hash::{Hash as _, Hasher as _};
|
||||
use std::ops::Deref;
|
||||
|
||||
use craft::behavior::IconId;
|
||||
use craft::keymap::Mods;
|
||||
pub(super) use craft::layers::ui::filter::{FilterObject, FilterState};
|
||||
use craft::layers::ui::filter::{LayerFilter, SmartSource};
|
||||
@@ -36,6 +37,12 @@ pub(crate) fn shown_name(app: &VectorcraftApp, n: &Node, lang: crate::i18n::Lang
|
||||
listed_name(n, by_xml_id(app), lang)
|
||||
}
|
||||
|
||||
/// The glyph of a horizontal ruler guide's row: a line across from a ruler.
|
||||
const HORIZONTAL_GUIDE_ICON: &str = "dc-guide-horizontal";
|
||||
|
||||
/// The glyph of a vertical ruler guide's row: a line down from a ruler.
|
||||
const VERTICAL_GUIDE_ICON: &str = "dc-guide-vertical";
|
||||
|
||||
/// Whether Identify Objects By is XML ID.
|
||||
fn by_xml_id(app: &VectorcraftApp) -> bool {
|
||||
app.session.prefs.identify_objects_by == "xmlId"
|
||||
@@ -411,7 +418,7 @@ impl LayerRows {
|
||||
info.dimmed = !self.shown(layer) || !info.visible;
|
||||
info.color = Some(self.color(layer));
|
||||
}
|
||||
// PLAN: dp.L12's horizontal and vertical guide marks need app icons the icon set lacks; the row keeps the kind's ruler glyph.
|
||||
info.icon = Some(IconId::new(if vertical { VERTICAL_GUIDE_ICON } else { HORIZONTAL_GUIDE_ICON }));
|
||||
info.renamable = false;
|
||||
info.thumbnail = false;
|
||||
info
|
||||
|
||||
@@ -343,6 +343,30 @@ fn rows_list_by_depth_and_ruler_guide_nodes_get_no_object_row() {
|
||||
assert_eq!(ids, [second, first, rect]);
|
||||
}
|
||||
|
||||
/// A horizontal and a vertical ruler guide's rows each show a glyph of their own, in place of the
|
||||
/// guide kind's ruler, and both glyphs are in the app's icon set.
|
||||
#[test]
|
||||
fn horizontal_and_vertical_guide_rows_show_their_own_drawn_glyphs() {
|
||||
use craft::ui::primitives::{has_icon, register_app_icons};
|
||||
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap();
|
||||
app.session.execute("guide.add", &json!({"vertical": false, "pos": 40})).unwrap();
|
||||
app.session.execute("guide.add", &json!({"vertical": true, "pos": 60})).unwrap();
|
||||
let st = app.session.active().unwrap();
|
||||
let rows = LayerRows::new(&app, st);
|
||||
let icon_of = |vertical: bool| {
|
||||
let i = st.doc.ruler_guides().iter().position(|g| g.vertical == vertical).unwrap();
|
||||
rows.info(&RowId::Guide(i)).icon.unwrap_or_else(|| panic!("the vertical: {vertical} guide row has no glyph of its own"))
|
||||
};
|
||||
let (across, down) = (icon_of(false), icon_of(true));
|
||||
assert_ne!(across, down, "the two kinds of guide rows look alike");
|
||||
register_app_icons(&crate::icons::APP_ICONS);
|
||||
for icon in [&across, &down] {
|
||||
assert!(has_icon(icon), "{icon:?} is in no icon set, so the row draws nothing");
|
||||
}
|
||||
}
|
||||
|
||||
/// The undo steps of the active document.
|
||||
pub(super) fn undo_len(app: &VectorcraftApp) -> usize {
|
||||
app.session.active().unwrap().history.undo.len()
|
||||
|
||||
Reference in new issue
Block a user