Merge pull request #5331 from dotCooCoo/feat/font-field-scroll-preview

Type: step font families with the mouse wheel
This commit is contained in:
BFlat
2026-11-03 16:35:38 +07:00
committed by GitHub
15 changed files with 1070 additions and 38 deletions
+3 -1
View File
@@ -9,7 +9,7 @@
**Stage: alpha** · next: beta, ~13 points (ready for real work ~62% → ~75%, and reliable `.ai` exchange) and ~170–270 h away
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-01 · **Change:** minor (Progress log row for the Color Effects add-on's Find Nearest Swatch; headline numbers unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** minor (font-family fields accept the mouse wheel, #5253; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
VectorCraft is a clean-room, open-source, pure-Rust reimplementation of the Adobe Illustrator workflow. It runs
on macOS, Windows, Linux, FreeBSD and the web (WASM), and agents can drive all of it over MCP, the CLI and a JSON
@@ -129,6 +129,7 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap
## Progress log
- 2026-11-02: Mouse wheel over a closed font-family field in Character, Properties or Control changes selected text through the family list using saved font filters (excluding search text), one undo step per notch, stopping at the ends (#5253). Scores and estimates unchanged.
- 2026-10-31: Pattern libraries: Window › Swatch Libraries › Patterns and the Swatches panel's library menu open Geometric Patterns, a built-in library of eleven pattern swatches (dots, stripes, checks, a grid and shapes); clicking one adds its pattern and swatch to the document, once, and applies it to the active fill or stroke (`swatch.library.add`).
- 2026-11-01: Find Nearest Swatch joins the Color Effects add-on (Object › Plug-ins › Color Effects): for each colour of the selection, the closest swatches of the document, a built-in library or a library or colour book the user loaded, with their CIEDE2000 difference; Apply gives each colour its nearest swatch as one undo step, linking global and spot swatches and adding a library's to the document first, so a process colour becomes the closest spot colour (`addon.color.nearestSwatch`, `addon.color.applyNearestSwatch`, #4923).
- 2026-11-01: Expand Dashes into Paths joins the Path Precision Tools add-on (Object › Plug-ins › Path Precision Tools): each selected path's dashed stroke becomes separate open paths, one per dash, laid out exactly as the stroke draws them (pattern, offset, Align Dashes to Corners and Path Ends), each keeping the stroke with the dashes off, so the gaps are real gaps for cutters and plotters, as one undo step (`addon.pathtools.expandDashes`, #4922).
@@ -214,6 +215,7 @@ The full earlier record of what landed is kept in [docs/roadmap.md](docs/roadmap
| Date | Change | Summary |
|---|---|---|
| 2026-11-02 | minor | Closed font-family fields accept wheel input for selected text in Character, Properties and Control (#5253); scores and estimates unchanged. |
| 2026-11-01 | minor | Progress log row for the Color Effects add-on's Find Nearest Swatch (#4923); headline numbers unchanged. |
| 2026-11-01 | minor | Progress log row for the Path Precision Tools add-on's Expand Dashes into Paths (#4922); headline numbers unchanged. |
| 2026-11-01 | minor | Progress log row for the Arrange Tools add-on's Randomize Opacity (#4925); headline numbers unchanged. |
+1 -1
View File
@@ -63,7 +63,7 @@ impl VectorcraftApp {
/// Identify the document, modal dialog and focused widget that the current accepted input batch
/// belongs to.
pub(super) fn input_generation(&self) -> InputGeneration {
pub(crate) fn input_generation(&self) -> InputGeneration {
InputGeneration {
document: self.session.active().map_or(0, |document| document.uid),
dialog: self.ui.dialog.as_ref().map(|dialog| egui::Id::unique(&dialog.kind)),
+6
View File
@@ -175,6 +175,12 @@ impl VectorcraftApp {
/// injected until the batch was actually applied, so a burst of hidden ticks cannot queue
/// several steps of a drag or replay them together later.
pub fn raw_input_hook(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
self.fill_raw_input(ctx, raw);
crate::font_menu::sync_wheel_target(self, ctx, raw.viewport_id);
crate::font_menu::take_raw_wheel(ctx, raw);
}
fn fill_raw_input(&mut self, ctx: &egui::Context, raw: &mut egui::RawInput) {
// Both hosts call this hook once per host iteration, before deciding whether a UI pass
// follows; it is the iteration boundary, not a UI-phase marker.
self.begin_host_iteration();
+369 -22
View File
@@ -8,7 +8,10 @@
//! Technology filter's Variable lists only variable font families. Preferences › Type › Enable
//! in-menu font previews and Font Preview Size turn the samples off or size the rows. Recently
//! used families appear first, in the order they were last applied, within the same search and
//! filters as the remaining families.
//! filters as the remaining families. In the Character and Properties panels and the Control bar,
//! the mouse wheel turned over the closed field applies the next family (or previous one) to the
//! selected text, one undo step per notch. The menu's order at the first turn stays fixed until the
//! pointer leaves the field or the text selection changes; steps stop at its first and last family.
use std::collections::HashMap;
use std::sync::Arc;
@@ -33,9 +36,50 @@ pub enum FontPick {
EndPreview,
/// The star of a family was clicked: add it to the favourites, or take it out.
Favorite(String),
/// The mouse wheel turned over the closed field: apply each of these families in turn, one
/// undo step each.
Wheel(Vec<String>),
}
/// How the menu looks: from the preferences and the favourites.
/// The UI that contains a font family field.
#[derive(Clone, Copy, Debug)]
pub enum WheelOwner {
Character,
Properties,
Control,
/// The Character popover attached to this Control bar link.
ControlPopover(egui::Id),
}
impl WheelOwner {
fn visible(self, app: &VectorcraftApp, ctx: &egui::Context) -> bool {
if crate::panels::character::text_style(app).is_none() {
return false;
}
let panel = match self {
Self::Control | Self::ControlPopover(_) | Self::Properties if app.session.tool_id() == "artboard" => return false,
Self::Control => return app.ui.control_bar && app.ui.screen_mode < 2,
Self::ControlPopover(anchor) => {
return app.ui.control_bar && app.ui.screen_mode < 2 && widgets::popover_is_open(ctx, anchor);
}
Self::Character => "character",
Self::Properties => {
let selected = app.session.active().and_then(|document| document.selection.objects.first().and_then(|id| document.doc.node(*id)));
if !selected.is_some_and(|n| matches!(&n.kind, vectorcraft_doc::NodeKind::Text(_))) {
return false;
}
"properties"
}
};
app.ui.dock
&& app.ui.screen_mode < 3
&& (crate::panel_docking::showing(&app.ui, panel)
|| (app.ui.transient_panel.as_deref() == Some(panel) && crate::panel_docking::showing(&app.ui, "appearance")))
}
}
/// How the menu looks (from the preferences and the favourites) and whether its closed field
/// takes the mouse wheel.
#[derive(Clone, Copy, Debug)]
pub struct MenuLook<'a> {
/// Show each family's sample (Preferences › Type › Enable in-menu font previews).
@@ -48,12 +92,17 @@ pub struct MenuLook<'a> {
pub favorites: &'a [String],
/// Recently applied families, newest first, limited by Number of Recent Fonts.
pub recent: &'a [String],
/// The mouse wheel turned over the closed field steps through the families in the menu's
/// order ([`FontPick::Wheel`]): the Character and Properties panels and the Control bar.
pub wheel: bool,
/// Its owner, so a field hidden before the next layout cannot capture wheel input.
pub wheel_owner: Option<WheelOwner>,
}
impl Default for MenuLook<'static> {
/// Samples on, English names, medium rows, no favourites.
/// Samples on, English names, medium rows, no favourites, no wheel.
fn default() -> Self {
Self { samples: true, english_names: true, row: ROW, favorites: &[], recent: &[] }
Self { samples: true, english_names: true, row: ROW, favorites: &[], recent: &[], wheel: false, wheel_owner: None }
}
}
@@ -70,6 +119,8 @@ impl<'a> MenuLook<'a> {
row,
favorites: &app.ui.favorite_fonts,
recent: app.recent_fonts(),
wheel: false,
wheel_owner: None,
}
}
}
@@ -235,6 +286,11 @@ struct MenuState {
rows_key: Option<RowsKey>,
/// The height of the search field and filters last frame.
header: f32,
/// The families the wheel steps through, listed at its first notch over the closed field and
/// kept for that text selection while the pointer stays on it: each step makes its family a recent one, which would
/// otherwise move it in the order.
wheel_order: Option<Arc<[String]>>,
wheel_target: Option<WheelTarget>,
}
/// The font family menu showing `current`, `width` points wide, rows sampling `sample` (the
@@ -249,12 +305,18 @@ pub fn font_menu(
) -> Option<FontPick> {
let state_id = ui.scope_id().with(&id).with("font-menu");
let mut st: MenuState = ui.data(|d| d.get_temp(state_id)).unwrap_or_default();
let target = ui.data(|d| d.get_temp(wheel_fields_id(ui.ctx().viewport_id()).with("target")));
let target_changed = st.wheel_target != target;
if target_changed {
st.wheel_order = None;
st.wheel_target = target;
}
let height = st.header + LIST_HEIGHT;
let state = &mut st;
// The search field and filters stay in place over the rows, which scroll. The rows are all
// one height (a family's styles too), so only those in view are laid out: there are thousands
// of families.
let shown = widgets::combo_menu(ui, &id, current, width, |menu| {
let (field, shown) = widgets::combo_menu_field(ui, &id, current, width, |menu| {
menu.height(height).show_rows_with_header(
|ui| header(ui, state_id, state, current, look),
look.row,
@@ -263,11 +325,54 @@ pub fn font_menu(
)
});
let drawn = shown.is_some();
if target_changed {
ui.data_mut(|d| d.remove::<f32>(field.id.with("wheel")));
}
let mut out = shown.flatten();
if !drawn && out.is_none() && st.previewed.take().is_some() {
// Closed (Escape, a click outside) with a preview showing.
out = Some(FontPick::EndPreview);
}
let turns = remember_owned_wheel_field(ui, &field, look.wheel && !drawn && field.enabled(), state_id, look.wheel_owner);
if !look.wheel || !field.enabled() {
st.wheel_order = None;
ui.data_mut(|d| d.remove::<f32>(field.id.with("wheel")));
} else if out.is_none() || drawn {
if !turns.is_empty() {
let mut own = vectorcraft_text::FontDb::global().canonical(current, "").0;
let mut steps = Vec::new();
for turn in turns {
match turn {
WheelInput::Leave => st.wheel_order = None,
WheelInput::Notches(notches) => {
if st.wheel_order.is_none() {
st.wheel_order = Some(wheel_order(&st, look).into());
}
if let Some(order) = st.wheel_order.as_deref() {
let next = wheel_steps(order, &own, notches);
if let Some(last) = next.last() {
own.clone_from(last);
}
steps.extend(next);
}
}
}
}
if !steps.is_empty() {
if drawn {
// These turns preceded the opener. The popup cancels back to the newly
// applied family, and any preview drawn this pass has not been applied.
st.current.clone_from(&own);
st.previewed = None;
}
out = Some(FontPick::Wheel(steps));
}
}
if drawn || !field.contains_pointer() {
st.wheel_order = None;
ui.data_mut(|d| d.remove::<f32>(field.id.with("wheel")));
}
}
if matches!(out, Some(FontPick::Chosen(..))) {
st.previewed = None;
}
@@ -275,6 +380,248 @@ pub fn font_menu(
out
}
/// Does the menu list family `f` for search `query` (lowercase) under the filters of `st`?
fn listed(db: &vectorcraft_text::FontDb, f: &str, query: &str, st: &MenuState, look: MenuLook) -> bool {
let label = db.family_display_name(f, look.english_names);
if !(query.is_empty() || f.to_lowercase().contains(query) || label.to_lowercase().contains(query)) {
return false;
}
if st.favorites_only && !look.favorites.iter().any(|x| x.eq_ignore_ascii_case(f)) {
return false;
}
if st.script == 0 && st.class.is_none() && !st.variable_only {
return true;
}
let traits = db.family_traits(f);
script_matches(st.script, traits) && st.class.is_none_or(|c| c == traits.class) && (!st.variable_only || traits.variable)
}
/// The families the closed field's wheel steps through, in the open menu's order with no search:
/// the recent families first, then the others, under the menu's filters.
fn wheel_order(st: &MenuState, look: MenuLook) -> Vec<String> {
let db = vectorcraft_text::FontDb::global();
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, "", st, look)).cloned().collect();
grouped_rows(&families, look.recent, &[], |_| vec![])
.into_iter()
.filter_map(|r| match r {
Row::Family(f) => Some(f),
Row::Heading(_) | Row::Style(..) => None,
})
.collect()
}
/// The families `notches` turns of the wheel step to from family `current` in `order`, one per
/// notch: forward (down the menu) when positive, back when negative. The steps stop at either end
/// of the order, and there are none when `current` is not in it.
fn wheel_steps(order: &[String], current: &str, notches: i32) -> Vec<String> {
let Some(at) = order.iter().position(|f| f.eq_ignore_ascii_case(current)) else { return vec![] };
let last = order.len().saturating_sub(1);
let n = notches.unsigned_abs() as usize;
let to = if notches >= 0 { at.saturating_add(n).min(last) } else { at.saturating_sub(n) };
if to >= at { order.iter().skip(at + 1).take(to - at).cloned().collect() } else { order.iter().take(at).skip(to).rev().cloned().collect() }
}
#[derive(Clone)]
enum WheelInput {
Leave,
Notches(i32),
}
#[derive(Clone, Copy)]
struct WheelField {
id: egui::Id,
menu: egui::Id,
owner: Option<WheelOwner>,
rect: egui::Rect,
layer: egui::LayerId,
}
#[derive(Clone, Default)]
struct WheelFields {
pass: u64,
pending_frame: u64,
activation_pass: u64,
activating: Vec<egui::Id>,
pointer: Option<egui::Pos2>,
fields: Vec<WheelField>,
pending: HashMap<egui::Id, Vec<WheelInput>>,
}
fn wheel_fields_id(viewport: egui::ViewportId) -> egui::Id {
egui::Id::unique("font-wheel-fields").with(viewport)
}
#[derive(Clone, PartialEq)]
struct WheelTarget {
input: crate::state::InputGeneration,
workspace: u64,
selection: Vec<vectorcraft_doc::NodeId>,
range: Option<(vectorcraft_doc::NodeId, usize, usize)>,
}
/// Pending turns and field rectangles belong to their input target and visible workspace.
pub(crate) fn sync_wheel_target(app: &VectorcraftApp, ctx: &egui::Context, viewport: egui::ViewportId) {
let target = WheelTarget {
input: app.input_generation(),
workspace: app.ui.docking_generation,
selection: app.session.active().map_or_else(Vec::new, |document| document.selection.objects.clone()),
range: crate::panels::character::text_editing(app),
};
let key = wheel_fields_id(viewport);
let (previous, mut fields) = ctx.data(|d| (d.get_temp::<WheelTarget>(key.with("target")), d.get_temp::<WheelFields>(key)));
if previous.is_some_and(|old| old != target) {
fields = None;
}
let mut hidden = Vec::new();
if let Some(fields) = &mut fields {
fields.fields.retain(|field| {
if field.owner.is_none_or(|owner| owner.visible(app, ctx)) {
true
} else {
hidden.push(*field);
false
}
});
for field in &hidden {
fields.pending.remove(&field.id);
}
}
ctx.data_mut(|d| {
if let Some(fields) = fields {
d.insert_temp(key, fields);
} else {
d.remove::<WheelFields>(key);
}
for field in hidden {
d.remove::<f32>(field.id.with("wheel"));
if let Some(mut state) = d.get_temp::<MenuState>(field.menu) {
state.wheel_order = None;
d.insert_temp(field.menu, state);
}
}
d.insert_temp(key.with("target"), target);
});
}
/// Remember the visible closed fields for the next input batch and take this field's turns.
#[cfg(test)]
fn remember_wheel_field(ui: &Ui, resp: &egui::Response, enabled: bool) -> Vec<WheelInput> {
remember_owned_wheel_field(ui, resp, enabled, resp.id, None)
}
fn remember_owned_wheel_field(ui: &Ui, resp: &egui::Response, enabled: bool, menu: egui::Id, owner: Option<WheelOwner>) -> Vec<WheelInput> {
let key = wheel_fields_id(ui.ctx().viewport_id());
let pass = ui.ctx().cumulative_pass_nr();
ui.data_mut(|d| {
let mut fields: WheelFields = d.get_temp(key).unwrap_or_default();
if fields.pass != pass {
fields.pass = pass;
fields.fields.clear();
}
fields.fields.retain(|f| f.id != resp.id);
if enabled {
fields.fields.push(WheelField { id: resp.id, menu, owner, rect: resp.interact_rect, layer: resp.layer_id });
}
let turns = fields.pending.remove(&resp.id).unwrap_or_default();
d.insert_temp(key, fields);
turns
})
}
/// Take the closed font fields' wheel events before egui smooths and combines them. Other
/// events stay in the input, so scrolling elsewhere keeps its own delta and event order.
pub(crate) fn take_raw_wheel(ctx: &egui::Context, raw: &mut egui::RawInput) {
let key = wheel_fields_id(raw.viewport_id);
let Some(mut fields) = ctx.data(|d| d.get_temp::<WheelFields>(key)) else { return };
if !ctx.input(|i| i.raw.viewports.contains_key(&raw.viewport_id)) {
ctx.data_mut(|d| d.remove::<WheelFields>(key));
return;
}
let frame = ctx.cumulative_frame_nr_for(raw.viewport_id);
let pass = ctx.cumulative_pass_nr_for(raw.viewport_id);
if pass < fields.pass || pass.saturating_sub(fields.pass) > 1 {
fields.fields.clear();
fields.pointer = None;
}
if fields.pending_frame != frame {
fields.pending_frame = frame;
fields.pending.clear();
}
let line = ctx.options(|o| o.input_options.line_scroll_speed).max(1.0);
let mut pointer = fields.pointer.or_else(|| ctx.input(|i| i.pointer.latest_pos()));
let over =
|field: &WheelField, point: Option<egui::Pos2>| point.is_some_and(|p| field.rect.contains(p) && ctx.layer_id_at(p) == Some(field.layer));
// An activation batch belongs to the popup, including a release after a prior press.
if fields.activation_pass != pass {
fields.activation_pass = pass;
fields.activating.clear();
let pressed = ctx.input(|i| if i.pointer.button_down(egui::PointerButton::Primary) { i.pointer.press_origin() } else { None });
if let Some(field) = fields.fields.iter().find(|f| over(f, pressed)) {
fields.activating.push(field.id);
}
}
let focused = ctx.memory(|m| m.focused());
let mut captured = false;
raw.events.retain(|event| {
let opening = match event {
egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, .. } => {
fields.fields.iter().rev().find(|f| over(f, Some(*pos))).map(|f| f.id)
}
egui::Event::Key { key: egui::Key::Enter | egui::Key::Space, pressed: true, .. } if raw.focused => {
focused.filter(|id| fields.fields.iter().any(|f| f.id == *id))
}
_ => None,
};
if let Some(id) = opening
&& !fields.activating.contains(&id)
{
fields.activating.push(id);
}
match event {
egui::Event::PointerMoved(p) | egui::Event::PointerButton { pos: p, .. } => {
for field in &fields.fields {
if over(field, pointer) && !over(field, Some(*p)) {
ctx.data_mut(|d| d.remove::<f32>(field.id.with("wheel")));
fields.pending.entry(field.id).or_default().push(WheelInput::Leave);
}
}
pointer = Some(*p);
}
egui::Event::PointerGone => {
pointer = None;
for field in &fields.fields {
ctx.data_mut(|d| d.remove::<f32>(field.id.with("wheel")));
fields.pending.entry(field.id).or_default().push(WheelInput::Leave);
}
}
egui::Event::MouseWheel { unit, delta, modifiers, .. } if modifiers.is_none() && delta.y != 0.0 => {
if let Some(field) = fields.fields.iter().rev().find(|f| !fields.activating.contains(&f.id) && over(f, pointer)).copied() {
let id = field.id.with("wheel");
let mut notches: f32 = ctx.data(|d| d.get_temp(id)).unwrap_or(0.0);
notches -= match unit {
egui::MouseWheelUnit::Point => delta.y / line,
egui::MouseWheelUnit::Line | egui::MouseWheelUnit::Page => delta.y,
};
let whole = notches.trunc();
ctx.data_mut(|d| d.insert_temp(id, notches - whole));
if whole != 0.0 {
fields.pending.entry(field.id).or_default().push(WheelInput::Notches(whole as i32));
}
captured = true;
return false;
}
}
_ => {}
}
true
});
fields.pointer = pointer;
ctx.data_mut(|d| d.insert_temp(key, fields));
if captured {
ctx.request_repaint();
}
}
/// What the menu's header hands its rows.
struct Listed<'s> {
st: &'s mut MenuState,
@@ -372,7 +719,6 @@ fn header<'s>(ui: &mut Ui, state_id: egui::Id, st: &'s mut MenuState, current: &
// as it was before any preview.
let current = db.canonical(&st.current, "").0;
let current = current.as_str();
let favorite = |f: &str| look.favorites.iter().any(|x| x.eq_ignore_ascii_case(f));
// The generation is read first: fonts that load meanwhile make the next frame list them.
let key: RowsKey = (
query.clone(),
@@ -387,21 +733,7 @@ fn header<'s>(ui: &mut Ui, state_id: egui::Id, st: &'s mut MenuState, current: &
db.generation(),
);
if st.rows_key.as_ref() != Some(&key) {
let wanted = |f: &str| {
let label = db.family_display_name(f, look.english_names);
if !(query.is_empty() || f.to_lowercase().contains(&query) || label.to_lowercase().contains(&query)) {
return false;
}
if st.favorites_only && !favorite(f) {
return false;
}
if st.script == 0 && st.class.is_none() && !st.variable_only {
return true;
}
let traits = db.family_traits(f);
script_matches(st.script, traits) && st.class.is_none_or(|c| c == traits.class) && (!st.variable_only || traits.variable)
};
let families: Vec<_> = db.menu_family_list().iter().filter(|f| wanted(f)).cloned().collect();
let families: Vec<_> = db.menu_family_list().iter().filter(|f| listed(db, f, &query, st, look)).cloned().collect();
let rows = grouped_rows(&families, look.recent, &st.expanded, |f| db.styles(f));
// Filter changes (including un-starring a favourite) may remove rows; expanding
// another family or a background font scan can insert rows before the highlight.
@@ -823,6 +1155,21 @@ pub(crate) fn apply(app: &mut VectorcraftApp, ctx: &egui::Context, pick: FontPic
}
}
FontPick::Favorite(f) => toggle_favorite(app, f),
FontPick::Wheel(families) => {
if previewing {
app.session.cancel_interaction().ok();
crate::panels::set_pstate(ctx, PREVIEWING, false);
}
crate::panels::character::end_typing(app);
// Each family is its own step, keeping the style when the family has it, else the
// closest it has.
for f in families {
let (cmd, params) = font_command(app, &f, None);
if app.run(cmd, params).is_err() {
break;
}
}
}
FontPick::Chosen(f, style) => {
if previewing {
app.session.cancel_interaction().ok();
@@ -856,7 +1203,7 @@ pub(crate) fn picked(app: &mut VectorcraftApp, pick: Option<FontPick>) -> Option
toggle_favorite(app, f);
None
}
FontPick::Preview(..) | FontPick::EndPreview => None,
FontPick::Preview(..) | FontPick::EndPreview | FontPick::Wheel(_) => None,
}
}
+130
View File
@@ -225,6 +225,136 @@ fn expanded_style_rows_do_not_retarget_the_highlight() {
assert_eq!(remap_highlight(&after, Some(1), &before), None);
}
/// #5253: each wheel notch over the closed field steps one family, down the menu or up it, and the
/// steps stop at its first and last family without going round.
#[test]
fn the_wheel_steps_one_family_per_notch_and_stops_at_the_ends() {
let order: Vec<String> = ["Alpha", "Bravo", "Charlie", "Delta"].map(str::to_string).into();
let steps = |current, notches| super::wheel_steps(&order, current, notches);
assert_eq!(steps("Bravo", 1), ["Charlie"]);
assert_eq!(steps("bravo", -1), ["Alpha"], "any case");
assert_eq!(steps("Alpha", 2), ["Bravo", "Charlie"], "a step for each notch");
assert_eq!(steps("Bravo", 5), ["Charlie", "Delta"], "stops at the last family");
assert_eq!(steps("Charlie", -5), ["Bravo", "Alpha"], "stops at the first family");
assert!(steps("Delta", 1).is_empty() && steps("Alpha", -1).is_empty(), "no wrapping");
assert!(steps("Missing", 1).is_empty() && steps("Bravo", 0).is_empty());
}
/// #5253: the wheel follows the open menu's order and filters: the recent families first, then the
/// others in the database's order, under the favourites (and other) filters.
#[test]
fn the_wheel_follows_the_menus_order_and_filters() {
let names = vectorcraft_text::FontDb::global().menu_family_list();
if names.len() < 3 {
return;
}
let recent = vec![names[2].clone()];
let look = super::MenuLook { samples: false, recent: &recent, ..Default::default() };
let order = super::wheel_order(&super::MenuState::default(), look);
assert_eq!(order.first(), Some(&names[2]), "the recent family first");
// Other tests add fonts to the process-wide database meanwhile: compare places, not neighbours.
let at = |f: &String| order.iter().position(|x| x == f);
assert!(matches!((at(&names[0]), at(&names[1])), (Some(a), Some(b)) if 0 < a && a < b), "then the others in the menu's order");
assert_eq!(order.iter().filter(|f| **f == names[2]).count(), 1, "once each");
let favorites = vec![names[0].clone(), names[1].clone()];
let st = super::MenuState { favorites_only: true, ..Default::default() };
let order = super::wheel_order(&st, super::MenuLook { favorites: &favorites, ..look });
assert_eq!(order, favorites, "the favourites filter");
}
/// A field removed by a later layout pass must not intercept the next wheel event.
#[test]
fn a_family_field_omitted_from_the_last_pass_leaves_the_wheel_to_its_owner() {
let ctx = egui::Context::default();
let mut point = egui::Pos2::ZERO;
for _ in 0..3 {
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
let resp = ui.button("Family");
point = resp.rect.center();
super::remember_wheel_field(ui, &resp, true);
});
out.textures_delta.clear();
}
let mut pass = 0;
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
if pass == 0 {
let resp = ui.button("Family");
point = resp.rect.center();
super::remember_wheel_field(ui, &resp, true);
ui.ctx().request_discard("the next pass removes the field");
}
pass += 1;
});
out.textures_delta.clear();
assert!(pass > 1);
let mut raw = egui::RawInput {
events: vec![
egui::Event::PointerMoved(point),
egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Line,
delta: egui::vec2(0.0, -1.0),
phase: egui::TouchPhase::Move,
modifiers: Default::default(),
source: egui::MouseWheelSource::Unknown,
},
],
..Default::default()
};
super::take_raw_wheel(&ctx, &mut raw);
assert!(raw.events.iter().any(|e| matches!(e, egui::Event::MouseWheel { .. })));
}
/// Activation leaves later wheel input to the popup; an earlier turn still belongs to the field.
#[test]
fn activating_the_family_popup_leaves_its_wheel_input_available() {
let activations = [None, Some((egui::Key::Enter, egui::Modifiers::NONE)), Some((egui::Key::Space, egui::Modifiers::SHIFT))];
for activation in activations {
let ctx = egui::Context::default();
let frame = |events| {
let mut raw = egui::RawInput { events, ..Default::default() };
super::take_raw_wheel(&ctx, &mut raw);
let mut point = egui::Pos2::ZERO;
let mut out = ctx.run_ui(raw, |ui| {
let resp = ui.button("Family");
point = resp.rect.center();
if activation.is_some() {
resp.request_focus();
}
super::remember_wheel_field(ui, &resp, true);
});
out.textures_delta.clear();
point
};
let mut point = egui::Pos2::ZERO;
for _ in 0..3 {
point = frame(vec![]);
}
let button =
|pressed| egui::Event::PointerButton { pos: point, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
let opener = if let Some((key, modifiers)) = activation {
egui::Event::Key { key, physical_key: None, pressed: true, repeat: false, modifiers }
} else {
frame(vec![egui::Event::PointerMoved(point), button(true)]);
button(false)
};
let turn = || egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Line,
delta: egui::vec2(0.0, -1.0),
phase: egui::TouchPhase::Move,
modifiers: Default::default(),
source: egui::MouseWheelSource::Unknown,
};
let mut events = vec![egui::Event::PointerMoved(point)];
if activation.is_some() {
events.push(turn());
}
events.extend([opener, turn()]);
let mut raw = egui::RawInput { events, ..Default::default() };
super::take_raw_wheel(&ctx, &mut raw);
assert_eq!(raw.events.iter().filter(|e| matches!(e, egui::Event::MouseWheel { .. })).count(), 1);
}
}
/// The Font Technology filter's Variable is the font adjective, not the Variables panel's noun.
#[test]
fn the_variable_filter_is_named_as_fonts_are() {
+30 -6
View File
@@ -801,10 +801,30 @@ fn font_height_reference(app: &mut VectorcraftApp, ui: &mut Ui, width: f32) {
}
/// The font family menu and the font style dropdown of style `s` (Character and Properties panels,
/// Control bar), with their `ids` and `widths`.
/// Control bar), with their `ids` and `widths`. The mouse wheel over the closed family field steps
/// the text through the families.
pub(crate) fn font_pickers(app: &mut VectorcraftApp, ui: &mut Ui, s: &CharStyle, ids: (&str, &str), widths: (f32, f32)) {
let wheel_owner = match ids.0 {
"ch-font" => Some(crate::font_menu::WheelOwner::Character),
"font" => Some(crate::font_menu::WheelOwner::Properties),
"cb-font" => Some(crate::font_menu::WheelOwner::Control),
_ => None,
};
font_pickers_owned(app, ui, s, ids, widths, wheel_owner);
}
fn font_pickers_owned(
app: &mut VectorcraftApp,
ui: &mut Ui,
s: &CharStyle,
ids: (&str, &str),
widths: (f32, f32),
wheel_owner: Option<crate::font_menu::WheelOwner>,
) {
crate::font_menu::sync_wheel_target(app, ui.ctx(), ui.ctx().viewport_id());
let sample = crate::font_menu::sample_text(app);
if let Some(pick) = crate::font_menu::font_menu(ui, ids.0, &s.font_family, widths.0, sample.as_deref(), crate::font_menu::MenuLook::of(app)) {
let look = crate::font_menu::MenuLook { wheel: true, wheel_owner, ..crate::font_menu::MenuLook::of(app) };
if let Some(pick) = crate::font_menu::font_menu(ui, ids.0, &s.font_family, widths.0, sample.as_deref(), look) {
crate::font_menu::apply(app, ui.ctx(), pick);
}
let styles = vectorcraft_text::FontDb::global().styles(&s.font_family);
@@ -892,7 +912,7 @@ pub(crate) fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
.on_hover_text(tl!("Character options"));
widgets::popover(&link, link.clicked(), |ui| {
ui.set_width(260.0);
show(app, ui);
show_owned(app, ui, crate::font_menu::WheelOwner::ControlPopover(link.id));
});
font_pickers(app, ui, &s, ("cb-font", "cb-font-style"), (150.0, 96.0));
size_field(app, ui, "cb-font-size", 96.0);
@@ -904,7 +924,11 @@ pub(crate) fn control_bar(app: &mut VectorcraftApp, ui: &mut Ui) {
const SNAP_TO_GLYPH_OPTIONS: &str = "ch-snap-to-glyph-options";
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
attributes(app, ui);
show_owned(app, ui, crate::font_menu::WheelOwner::Character);
}
fn show_owned(app: &mut VectorcraftApp, ui: &mut Ui, owner: crate::font_menu::WheelOwner) {
attributes(app, ui, owner);
// Drawing over type needs no type selected, so the options show without one too.
if pstate::<bool>(ui.ctx(), SNAP_TO_GLYPH_OPTIONS) {
snap_to_glyph_options(app, ui);
@@ -942,7 +966,7 @@ fn snap_to_glyph_options(app: &mut VectorcraftApp, ui: &mut Ui) {
}
/// The character attributes of the type selected (an empty state without any).
fn attributes(app: &mut VectorcraftApp, ui: &mut Ui) {
fn attributes(app: &mut VectorcraftApp, ui: &mut Ui, owner: crate::font_menu::WheelOwner) {
let Some((s, _)) = text_style(app) else {
app.character_focus = None;
super::empty_state(ui, "type", tl!("No text selected"), tl!("Select a text object to edit its character attributes."));
@@ -954,7 +978,7 @@ fn attributes(app: &mut VectorcraftApp, ui: &mut Ui) {
if let Some(f) = app.character_focus {
widgets::arm_field_focus(ui.ctx(), f.salt());
}
font_pickers(app, ui, &s, ("ch-font", "ch-style"), (w - 4.0, w - 4.0));
font_pickers_owned(app, ui, &s, ("ch-font", "ch-style"), (w - 4.0, w - 4.0), Some(owner));
variable_font(app, ui, &s, w - 4.0);
ui.add_space(2.0);
let hidden = pstate::<bool>(ui.ctx(), "ch-hide-options");
+327
View File
@@ -203,6 +203,333 @@ fn a_press_outside_the_menu_ends_the_preview_at_once() {
assert!(!frame(vec![button(outside, false)]).1);
}
/// A document with point type in Inter, selected; its id.
fn selected_inter(app: &mut VectorcraftApp) -> u64 {
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
let id = app.session.execute("text.create", &json!({"x": 20, "y": 50, "text": "Gagaku", "font": "Inter"})).unwrap()["id"].as_u64().unwrap();
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
if !crate::panel_docking::showing(&app.ui, "character") {
app.run("window.panel", json!({"panel": "character"})).unwrap();
}
id
}
fn first_style(app: &VectorcraftApp, id: u64) -> vectorcraft_doc::CharStyle {
match &app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().kind {
NodeKind::Text(t) => t.first_style(),
_ => panic!("not type"),
}
}
fn wheel(unit: egui::MouseWheelUnit, dy: f32, modifiers: egui::Modifiers) -> egui::Event {
egui::Event::MouseWheel { unit, delta: egui::vec2(0.0, dy), modifiers, phase: egui::TouchPhase::Move, source: egui::MouseWheelSource::Unknown }
}
/// One frame of `draw` over `app`, as the shell runs it; the middle of the text naming `family`
/// lowest on the screen (the closed family field), if drawn, and whether the menu's search field
/// is drawn (the menu is open).
fn panel_frame(
ctx: &egui::Context,
app: &mut VectorcraftApp,
events: Vec<egui::Event>,
family: &str,
draw: &dyn Fn(&mut VectorcraftApp, &mut egui::Ui),
) -> (Option<egui::Pos2>, bool) {
let mut input =
egui::RawInput { events, screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 800.0))), ..Default::default() };
app.raw_input_hook(ctx, &mut input);
let mut out = ctx.run_ui(input, |ui| {
crate::font_menu::end_stale_preview(app, ui.ctx());
draw(app, ui);
});
out.textures_delta.clear();
let text = |label: &str| {
out.shapes.iter().find_map(|s| match &s.shape {
egui::Shape::Text(t) if t.galley.text() == label => Some(t.pos + egui::vec2(4.0, t.galley.size().y * 0.5)),
_ => None,
})
};
(text(family), text("Search").is_some())
}
/// #5253: in the Character panel, each notch of the mouse wheel over the closed font family field
/// applies the next family down the menu (up it when turned up) to the selected type, each its own
/// undo step, with the menu closed. Leaving the field or Escape keeps it; Undo puts it back.
#[test]
fn the_wheel_over_the_family_field_steps_the_selected_type_through_the_families() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
let font = |app: &VectorcraftApp| first_style(app, id).font_family;
let steps = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len();
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.expect("the Character panel shows the family field");
// Other tests add fonts to the process-wide database meanwhile: compare places, not neighbours.
let place = |f: &str| FontDb::global().menu_family_list().iter().position(|x| x == f);
let before = steps(&app);
let line = egui::MouseWheelUnit::Line;
let (_, open) = panel_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(field), wheel(line, -1.0, Default::default())], "Inter", &draw);
let next = font(&app);
assert!(place(&next) > place("Inter") && steps(&app) == before + 1, "a notch down applies a family below, one step: {next}");
assert!(!open && !app.session.in_interaction(), "the menu stays closed and nothing is left previewed");
// The family is now a recent one: the order stays as it was while the pointer stays on the field.
panel_frame(&ctx, &mut app, vec![wheel(line, -1.0, Default::default())], &next, &draw);
let after = font(&app);
assert!(place(&after) > place(&next) && steps(&app) == before + 2, "{after}");
panel_frame(&ctx, &mut app, vec![wheel(line, 1.0, Default::default())], &after, &draw);
assert_eq!((font(&app), steps(&app)), (next.clone(), before + 3), "a notch up, back");
// A turn of a fine wheel in points: a notch is `line_scroll_speed` points, the rest carries over.
let speed = ctx.options(|o| o.input_options.line_scroll_speed);
panel_frame(&ctx, &mut app, vec![wheel(egui::MouseWheelUnit::Point, speed * 0.5, Default::default())], &next, &draw);
assert_eq!(font(&app), next, "less than a notch");
panel_frame(&ctx, &mut app, vec![wheel(egui::MouseWheelUnit::Point, speed * 0.5, Default::default())], &next, &draw);
assert_eq!((font(&app), steps(&app)), ("Inter".to_string(), before + 4), "the rest of the notch");
// A turn with a modifier key is not the field's.
panel_frame(&ctx, &mut app, vec![wheel(line, -1.0, egui::Modifiers::COMMAND)], "Inter", &draw);
assert_eq!((font(&app), steps(&app)), ("Inter".to_string(), before + 4), "Ctrl/Cmd-wheel");
// Two notches at once: two families, two steps.
panel_frame(&ctx, &mut app, vec![wheel(line, -2.0, Default::default())], "Inter", &draw);
assert_eq!((font(&app), steps(&app)), (after.clone(), before + 6));
// Escape and leaving the field keep the family.
panel_frame(&ctx, &mut app, key(egui::Key::Escape), &after, &draw);
panel_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(egui::pos2(580.0, 780.0))], &after, &draw);
panel_frame(&ctx, &mut app, vec![], &after, &draw);
assert_eq!((font(&app), steps(&app)), (after, before + 6), "the family stays applied");
// The wheel away from the field does not change the font.
let shown = font(&app);
panel_frame(&ctx, &mut app, vec![wheel(line, -1.0, Default::default())], &shown, &draw);
assert_eq!(steps(&app), before + 6, "the wheel off the field");
app.run("edit.undo", json!({})).unwrap();
assert_eq!(font(&app), next, "Undo takes back one notch");
app.run("edit.undo", json!({})).unwrap();
assert_eq!(font(&app), "Inter");
}
/// Opposite wheel notches in one frame apply in order, each with its own undo step.
#[test]
fn opposite_wheel_notches_in_one_frame_keep_their_undo_steps() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.expect("the Character panel shows the family field");
let before = app.session.active().unwrap().history.undo.len();
let line = egui::MouseWheelUnit::Line;
panel_frame(
&ctx,
&mut app,
vec![egui::Event::PointerMoved(field), wheel(line, -1.0, Default::default()), wheel(line, 1.0, Default::default())],
"Inter",
&draw,
);
assert_eq!(first_style(&app, id).font_family, "Inter");
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 2);
app.run("edit.undo", json!({})).unwrap();
assert_ne!(first_style(&app, id).font_family, "Inter");
app.run("edit.redo", json!({})).unwrap();
assert_eq!(first_style(&app, id).font_family, "Inter");
}
/// A turn before opening applies once; the popup keeps the later wheel and cancels to that font.
#[test]
fn a_wheel_before_opening_the_family_popup_keeps_its_committed_change() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.unwrap();
let before = app.session.active().unwrap().history.undo.len();
let button = |pressed| egui::Event::PointerButton { pos: field, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
let turn = || wheel(egui::MouseWheelUnit::Line, -1.0, Default::default());
panel_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(field), turn(), button(true), button(false), turn()], "Inter", &draw);
let applied = first_style(&app, id).font_family;
assert_ne!(applied, "Inter");
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
for _ in 0..3 {
panel_frame(&ctx, &mut app, vec![], &applied, &draw);
}
panel_frame(&ctx, &mut app, key(egui::Key::Escape), &applied, &draw);
assert_eq!(first_style(&app, id).font_family, applied);
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
app.run("edit.undo", json!({})).unwrap();
assert_eq!(first_style(&app, id).font_family, "Inter");
}
/// A later pointer move must not change which field owns an earlier wheel event.
#[test]
fn wheel_events_use_the_pointer_position_when_they_occurred() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.expect("the Character panel shows the family field");
let outside = egui::pos2(580.0, 780.0);
panel_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(outside)], "Inter", &draw);
let before = app.session.active().unwrap().history.undo.len();
let line = egui::MouseWheelUnit::Line;
panel_frame(&ctx, &mut app, vec![wheel(line, -1.0, Default::default()), egui::Event::PointerMoved(field)], "Inter", &draw);
assert_eq!(first_style(&app, id).font_family, "Inter", "the wheel was outside the field");
assert_eq!(app.session.active().unwrap().history.undo.len(), before);
assert!(ctx.input(|i| i.events.iter().any(|e| matches!(e, egui::Event::MouseWheel { .. }))), "outside wheel input is left for its owner");
panel_frame(&ctx, &mut app, vec![wheel(line, -1.0, Default::default()), egui::Event::PointerMoved(outside)], "Inter", &draw);
assert_ne!(first_style(&app, id).font_family, "Inter", "the wheel was over the field before the pointer left");
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
app.run("edit.undo", json!({})).unwrap();
assert_eq!(first_style(&app, id).font_family, "Inter");
let button = |pos| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() };
panel_frame(&ctx, &mut app, vec![button(field), wheel(line, -1.0, Default::default()), button(outside)], "Inter", &draw);
assert_ne!(first_style(&app, id).font_family, "Inter", "button events also carry the pointer's position");
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
app.run("edit.undo", json!({})).unwrap();
let end = egui::Event::MouseWheel {
unit: egui::MouseWheelUnit::Point,
delta: egui::Vec2::ZERO,
modifiers: Default::default(),
phase: egui::TouchPhase::End,
source: egui::MouseWheelSource::Unknown,
};
panel_frame(&ctx, &mut app, vec![end], "Inter", &draw);
panel_frame(
&ctx,
&mut app,
vec![
wheel(egui::MouseWheelUnit::Point, -2.0, Default::default()),
egui::Event::PointerMoved(field),
wheel(line, -1.0, Default::default()),
egui::Event::PointerMoved(outside),
],
"Inter",
&draw,
);
assert_eq!(app.session.active().unwrap().history.undo.len(), before + 1);
assert_eq!(ctx.input(|i| i.smooth_scroll_delta.y), -2.0, "only the outside wheel contributes to panel scrolling");
}
/// A turn queued for one document cannot restyle another document opened before its UI pass.
#[test]
fn a_wheel_queued_for_another_document_is_discarded() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
selected_inter(&mut app);
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.expect("the Character panel shows the family field");
let mut raw = egui::RawInput {
events: vec![egui::Event::PointerMoved(field), wheel(egui::MouseWheelUnit::Line, -1.0, Default::default())],
screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 800.0))),
..Default::default()
};
app.raw_input_hook(&ctx, &mut raw);
assert!(!raw.events.iter().any(|e| matches!(e, egui::Event::MouseWheel { .. })));
let id = selected_inter(&mut app);
let before = app.session.active().unwrap().history.undo.len();
let mut out = ctx.run_ui(raw, |ui| draw(&mut app, ui));
out.textures_delta.clear();
assert_eq!(first_style(&app, id).font_family, "Inter");
assert_eq!(app.session.active().unwrap().history.undo.len(), before);
}
/// Presentation mode hides an Appearance row's Character popup even if its state is still open.
#[test]
fn presentation_mode_leaves_a_transient_font_fields_wheel_available() {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
selected_inter(&mut app);
app.run("window.panel.close", json!({"panel": "character"})).unwrap();
app.run("window.panel.close", json!({"panel": "properties"})).unwrap();
app.run("window.panel", json!({"panel": "appearance"})).unwrap();
assert!(!crate::panel_docking::showing(&app.ui, "character"));
assert!(!crate::panel_docking::showing(&app.ui, "properties"));
assert!(crate::panel_docking::showing(&app.ui, "appearance"));
app.ui.transient_panel = Some("character".into());
let draw = |app: &mut VectorcraftApp, ui: &mut egui::Ui| crate::panels::character::show(app, ui);
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
app.ui.screen_mode = 3;
let mut raw = egui::RawInput {
events: vec![egui::Event::PointerMoved(field.unwrap()), wheel(egui::MouseWheelUnit::Line, -1.0, Default::default())],
..Default::default()
};
app.raw_input_hook(&ctx, &mut raw);
assert!(raw.events.iter().any(|e| matches!(e, egui::Event::MouseWheel { .. })));
}
/// #5253: the Properties panel and the Control bar have the same family field, and the wheel steps
/// the families over it too.
#[test]
fn the_wheel_steps_the_families_in_properties_and_the_control_bar() {
type Draw = fn(&mut VectorcraftApp, &mut egui::Ui);
let places: [(&str, Draw); 2] = [
("Properties", |app, ui| crate::panels::properties::type_sections(app, ui)),
("Control bar", |app, ui| crate::panels::character::control_bar(app, ui)),
];
let at = |f: &str| FontDb::global().menu_family_list().iter().position(|x| x == f);
for (place, draw) in places {
let ctx = egui::Context::default();
crate::theme::install_fonts(&ctx);
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
app.ui.control_bar = true;
let mut field = None;
for _ in 0..3 {
field = panel_frame(&ctx, &mut app, vec![], "Inter", &draw).0;
}
let field = field.unwrap_or_else(|| panic!("{place} shows the family field"));
let steps = app.session.active().unwrap().history.undo.len();
let notch = wheel(egui::MouseWheelUnit::Line, -1.0, Default::default());
panel_frame(&ctx, &mut app, vec![egui::Event::PointerMoved(field), notch], "Inter", &draw);
let next = first_style(&app, id).font_family;
assert!(at(&next) > at("Inter"), "{place}: {next}");
assert_eq!(app.session.active().unwrap().history.undo.len(), steps + 1, "{place}");
}
}
/// #5253: a family the wheel steps to keeps the type's style when it has that style, else takes the
/// closest it has, as a family picked from the menu does. The menus that only pick a font ignore
/// the wheel.
#[test]
fn a_family_stepped_to_keeps_the_style_it_has() {
let ctx = egui::Context::default();
let mut app = VectorcraftApp::new(Session::new(), Default::default());
let id = selected_inter(&mut app);
let db = FontDb::global();
let bold: Vec<String> = db.menu_family_list().iter().filter(|f| db.styles(f).iter().any(|s| s == "Bold")).take(2).cloned().collect();
let [from, to] = bold.as_slice() else { panic!("two families with a Bold style: {bold:?}") };
app.run("text.setStyle", json!({"font": from, "style": "Bold"})).unwrap();
crate::font_menu::apply(&mut app, &ctx, FontPick::Wheel(vec![to.clone()]));
let s = first_style(&app, id);
assert_eq!((&s.font_family, s.font_style.as_str()), (to, "Bold"));
assert_eq!(crate::font_menu::picked(&mut app, Some(FontPick::Wheel(vec![from.clone()]))), None);
assert_eq!(&first_style(&app, id).font_family, to, "picking menus leave the document alone");
}
#[test]
fn bundled_families_are_classified() {
use vectorcraft_text::FontClass;
+1 -1
View File
@@ -43,7 +43,7 @@ pub use drag::{
};
#[cfg(test)]
use dropdowns::combo_button_id;
pub(crate) use dropdowns::{combo, combo_menu, combo_named};
pub(crate) use dropdowns::{combo, combo_menu, combo_menu_field, combo_named, popover_is_open};
pub use dropdowns::{
dropdown, dropdown_named, dropdown_names, dropdown_names_named, dropdown_with, dropdown_with_named, list_scroll_style, menu_room, menu_scroll,
panel_scroll, popover, set_menu_floor, strip_scroll,
+21 -2
View File
@@ -135,6 +135,18 @@ pub(crate) fn combo_menu<R>(
width: f32,
menu: impl FnOnce(craft_ui::combo::Menu<'_>) -> Option<R>,
) -> Option<R> {
combo_menu_field(ui, id, current, width, menu).1
}
/// [`combo_menu`], also returning the closed field's response (the font family field reads the
/// mouse wheel turned over it).
pub(crate) fn combo_menu_field<R>(
ui: &mut Ui,
id: impl std::hash::Hash,
current: &str,
width: f32,
menu: impl FnOnce(craft_ui::combo::Menu<'_>) -> Option<R>,
) -> (Response, Option<R>) {
let t = Tokens::get(ui.ctx());
let label = take_previous_label(ui);
egui::Frame::NONE
@@ -148,7 +160,8 @@ pub(crate) fn combo_menu<R>(
egui::Popup::open_id(ui.ctx(), egui::Popup::default_response_id(&resp));
ui.memory_mut(|m| m.stop_text_input());
}
menu(craft_ui::combo::Menu::new(ui, &resp).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside))
let shown = menu(craft_ui::combo::Menu::new(ui, &resp).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside));
(resp, shown)
})
.inner
}
@@ -204,7 +217,7 @@ pub fn popover<R>(resp: &Response, toggle: bool, content: impl FnOnce(&mut Ui) -
let ctx = &resp.ctx;
let id = resp.id.with("popover");
let frame = ctx.cumulative_frame_nr();
let was_open = ctx.data(|d| d.get_temp::<u64>(id)).is_some_and(|f| f + 1 >= frame);
let was_open = popover_is_open(ctx, resp.id);
let mut open = if toggle {
!was_open
} else {
@@ -233,6 +246,12 @@ pub fn popover<R>(resp: &Response, toggle: bool, content: impl FnOnce(&mut Ui) -
inner
}
/// Whether the popover for this anchor was open in the latest completed frame.
pub(crate) fn popover_is_open(ctx: &egui::Context, anchor: egui::Id) -> bool {
let frame = ctx.cumulative_frame_nr();
ctx.data(|d| d.get_temp::<u64>(anchor.with("popover"))).is_some_and(|f| f + 1 >= frame)
}
/// Records where the bottom bars (status and hint bars) start this frame, so menus can stop above
/// them (#2086). Without bars it is the bottom of the window.
pub fn set_menu_floor(ctx: &egui::Context, y: f32) {
+162
View File
@@ -0,0 +1,162 @@
//! Wheel routing when a font field disappears before the next layout pass.
// Integration tests: unwrapping and panicking on failure is fine here, unlike in shipped code (AGENTS.md › Robustness).
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
use egui::{Event, MouseWheelSource, MouseWheelUnit, Pos2, RawInput, Rect, Shape, TouchPhase, vec2};
use serde_json::{Value, json};
use vectorcraft_engine::Session;
use vectorcraft_ui_egui::VectorcraftApp;
#[test]
fn hiding_control_between_passes_leaves_its_old_fields_wheel_available() {
assert!(control_wheel_available_after("window.control", json!({})));
}
#[test]
fn hiding_properties_preserves_the_visible_control_fields_wheel() {
assert!(!control_wheel_available_after("window.panel.close", json!({"panel": "properties"})));
}
#[test]
fn deselecting_type_leaves_the_missing_control_fields_wheel_available() {
assert!(control_wheel_available_after("select.set", json!({"ids": []})));
}
#[test]
fn a_queued_font_wheel_does_not_restyle_a_new_object_selection() {
assert_queued_wheel_discarded_after_target_change(false);
}
#[test]
fn a_queued_font_wheel_does_not_restyle_a_new_character_range() {
assert_queued_wheel_discarded_after_target_change(true);
}
fn assert_queued_wheel_discarded_after_target_change(range: bool) {
let (ctx, mut app) = selected_type_with_control();
let first = app.session.active().unwrap().selection.objects.first().unwrap().0;
let second = app.run("text.create", json!({"x": 30, "y": 120, "text": "Other text", "font": "Inter"})).unwrap()["id"].clone();
app.run("select.set", json!({"ids": [first]})).unwrap();
if range {
app.select_tool("type");
app.session.set_tool_option("textSelection", &json!({"editing": first, "anchor": 0, "caret": 2}));
}
let mut texts = Vec::new();
for _ in 0..8 {
texts = frame(&mut app, &ctx, vec![]);
}
let point = texts.iter().find(|(t, p)| t == "Inter" && p.y < 150.0).unwrap().1;
let mut raw = wheel_input(point);
app.raw_input_hook(&ctx, &mut raw);
assert!(!raw.events.iter().any(|e| matches!(e, Event::MouseWheel { .. })), "the original field captured its turn");
if range {
app.session.set_tool_option("textSelection", &json!({"editing": first, "anchor": 2, "caret": 4}));
} else {
app.run("select.set", json!({"ids": [second]})).unwrap();
}
let before = app.session.active().unwrap().history.undo.len();
let mut out = ctx.run_ui(raw, |ui| app.ui(ui));
out.textures_delta.clear();
assert_eq!(app.session.active().unwrap().history.undo.len(), before, "the captured turn cannot restyle the new target");
}
#[test]
fn artboard_controls_leave_replaced_font_fields_wheel_available() {
let (ctx, mut app) = selected_type_with_control();
let mut texts = Vec::new();
for _ in 0..8 {
texts = frame(&mut app, &ctx, vec![]);
}
let fields: Vec<_> = texts.iter().filter(|(t, _)| t == "Inter").map(|(_, point)| *point).collect();
assert_eq!(fields.len(), 2, "Control and Properties each show a font field");
app.select_tool("artboard");
for point in fields {
let mut raw = wheel_input(point);
app.raw_input_hook(&ctx, &mut raw);
assert!(raw.events.iter().any(|e| matches!(e, Event::MouseWheel { .. })), "the Artboard tool replaces this font field");
}
}
#[test]
fn the_control_character_popover_keeps_its_visible_font_wheel() {
let (ctx, mut app) = selected_type_with_control();
app.run("window.panel.close", json!({"panel": "character"})).unwrap();
let mut texts = Vec::new();
for _ in 0..8 {
texts = frame(&mut app, &ctx, vec![]);
}
let link = texts.iter().find(|(t, p)| t == "Character:" && p.y < 100.0).unwrap().1;
let button = |pressed| Event::PointerButton { pos: link, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() };
frame(&mut app, &ctx, vec![Event::PointerMoved(link), button(true)]);
frame(&mut app, &ctx, vec![button(false)]);
for _ in 0..3 {
texts = frame(&mut app, &ctx, vec![]);
}
let point = texts
.iter()
.find(|(t, p)| t == "Inter" && p.y > link.y + 10.0 && p.y < link.y + 100.0 && (p.x - link.x).abs() < 100.0)
.expect("the Character popover shows its family field")
.1;
let mut raw = wheel_input(point);
app.raw_input_hook(&ctx, &mut raw);
assert!(!raw.events.iter().any(|e| matches!(e, Event::MouseWheel { .. })), "the visible popover keeps font wheel input");
app.run("window.control", json!({})).unwrap();
let mut raw = wheel_input(point);
app.raw_input_hook(&ctx, &mut raw);
assert!(raw.events.iter().any(|e| matches!(e, Event::MouseWheel { .. })), "hiding Control also hides its popover");
}
fn selected_type_with_control() -> (egui::Context, VectorcraftApp) {
let ctx = egui::Context::default();
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 400, "height": 250})).unwrap();
let text = app.run("text.create", json!({"x": 30, "y": 70, "text": "Control wheel", "font": "Inter"})).unwrap();
app.run("select.set", json!({"ids": [text["id"]]})).unwrap();
app.run("window.control", json!({})).unwrap();
(ctx, app)
}
fn frame(app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec<Event>) -> Vec<(String, Pos2)> {
let mut raw = RawInput { events, screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1440.0, 900.0))), ..Default::default() };
app.raw_input_hook(ctx, &mut raw);
let mut out = ctx.run_ui(raw, |ui| app.ui(ui));
let texts = out
.shapes
.iter()
.filter_map(|s| match &s.shape {
Shape::Text(t) => Some((t.galley.text().to_string(), t.pos + vec2(4.0, 6.0))),
_ => None,
})
.collect();
out.textures_delta.clear();
texts
}
fn control_wheel_available_after(command: &str, params: Value) -> bool {
let (ctx, mut app) = selected_type_with_control();
let mut texts = Vec::new();
for _ in 0..8 {
texts = frame(&mut app, &ctx, vec![]);
}
let point = texts.iter().find(|(t, p)| t == "Inter" && p.y < 150.0).expect("the Control bar's family field is rendered").1;
app.run(command, params).unwrap();
let mut raw = wheel_input(point);
app.raw_input_hook(&ctx, &mut raw);
raw.events.iter().any(|e| matches!(e, Event::MouseWheel { .. }))
}
fn wheel_input(point: Pos2) -> RawInput {
RawInput {
events: vec![
Event::PointerMoved(point),
Event::MouseWheel {
unit: MouseWheelUnit::Line,
delta: vec2(0.0, -1.0),
phase: TouchPhase::Move,
modifiers: Default::default(),
source: MouseWheelSource::Unknown,
},
],
..Default::default()
}
}
+9 -1
View File
@@ -1,9 +1,16 @@
# Gaps
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Symbol editing shows draggable 9-slice guides; G5: dynamic symbols, #4938; estimate 15–26 → 14–24 h) · **Target:** Adobe Illustrator 2026 (30.x; G12: Units › East Asian Type acts, with Q and Ha units; estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (font-family fields accept the mouse wheel, #5253; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; G12: Units › East Asian Type acts, with Q and Ha units; estimate unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
## Feature submission evidence
The closed font-family fields in Character, Properties and Control now accept the
mouse wheel for selected text (#5253). Each effective notch applies one family and
adds one undo step; the list follows saved font filters, ignores search text, and
stops at its ends. These interaction details
are VectorCraft's choices. Scores and estimates are unchanged.
**Feature evidence last updated:** 2026-11-02.
**Feature evidence last updated:** 2026-11-03.
The shared assessment status line and revision history are current upstream; this dated section records the submission's feature evidence and revisions without rescoring upstream or claiming a new combined build or runtime measurement.
@@ -19,6 +26,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard
| Date | Change | Summary |
|---|---|---|
| 2026-11-02 | minor | Font-family fields step selected text with the mouse wheel (#5253); no scored gap or estimate reassessed. |
| 2026-10-24 | minor | G12: General › Corner Radius is the Rounded Rectangle tool's radius, a change while the tool is active reaches it, and the radius ↑/↓ set while drawing (or a Tool Options value) becomes the preference, within 0–1296 pt (#394, `crates/engine/src/tests/constrain_tools.rs`); no entry closed, estimate unchanged. |
| 2026-10-22 | minor | Reconcile upstream documentation after review F-3; preserve every dated revision and the original scaleArt runtime evidence without repeating completed jobs. |
| 2026-10-22 | minor | Reconcile upstream documentation after review F-2; preserve every dated revision and the original scaleArt runtime evidence without repeating completed jobs. |
+2 -1
View File
@@ -1,6 +1,6 @@
# Roadmap: milestones and what's next
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Symbol editing shows draggable 9-slice guides; M5: supersampled exports avoid redundant opaque knockout layers; File formats: `.ai`/EPS import fidelity from a user's file audit; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (font-family fields accept the mouse wheel, #5253; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
## Feature submission evidence
@@ -145,6 +145,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development
| Date | Change | Summary |
|---|---|---|
| 2026-11-02 | minor | Font-family fields in Character, Properties and Control step selected text with the wheel (#5253), with one undo step per notch; scores and estimates unchanged. |
| 2026-11-03 | minor | Symbol editing shows draggable 9-slice guides (#5280). Guides outside the artwork remain unsupported. Scores and hours remain unchanged. |
| 2026-10-30 | patch | M5: opaque solid-fill knockout paths avoid redundant erase/add layers in hard-edge frames and supersampled raster export; exact-pixel regression coverage retains analytical-AA rounding and translucent knockout behavior; scores and estimates unchanged |
| 2026-10-30 | minor | M4: G9: `.ai`/EPS editing data: a blend takes the transparency (opacity, blend mode, knockout) in its state block after its record, so its steps knock each other out as the page draws them; a user's file comes in 0.6% from its page instead of 1.3%. Scores and estimates unchanged. |
File diff suppressed because one or more lines are too long
+3 -1
View File
@@ -1,6 +1,6 @@
# Type parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-01 · **Change:** minor (the Type tools make area type or type on a path from a clicked path; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** minor (font-family fields accept the mouse wheel, #5253; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
Type is Illustrator's largest single area by use (weight 13 of 105 across "Type core" and "Type advanced" in
[target-app-parity.md](target-app-parity.md)). This checklist lists the features one by one. Status is from the
@@ -18,6 +18,7 @@ against Illustrator's public documentation; **estimated** unless noted.
| Feature | Status | Notes |
|---|---|---|
| Mouse wheel over the closed font-family field | done | #5253: Character, Properties and Control step selected text through the family list using saved font filters (excluding search text), one undo step per notch; the style is matched and the list stops at either end. Escape and leaving the field keep the change. Order, bounds and Undo grouping are VectorCraft's choices; scores unchanged. |
| Soft return (forced line break, Shift+Enter) | done | Shift+Enter inserts a soft return (U+2028), breaking the line without starting a new paragraph; paragraph spacing (space before/after) and first-line indents apply only at paragraph ends; continuation lines in lists do not repeat the marker; soft return lines in justified text do not spread (#2754) |
| Native font-family labels | partial | With Show Font Names in English off, localized legacy names are used when typographic names contain no native label (#2208); loaded-font and catalog-only regressions. Choosing among multiple native languages is unchanged. |
| Point, area and type-on-a-path type; vertical variants | done / partial | vertical point, area and path type have initial support; fullwidth `!` / `?` keep the nominal glyph upright when no vertical alternate exists (Unicode Tu); in a non-rectangular area a word too wide for the top lines moves down to the first line that holds it (#1615); Escape while typing ends the edit, keeps the type selected and switches to the Selection tool (#1802); `text.create` and `text.createInPath` take `justify` (#1752); MCP `add_text` forwards `vertical` to both commands; the Type and Vertical Type tools make area type when a closed path's outline is clicked and type on a path when an open one is, with pointers that say which, as the public help describes ([Create text](https://web.archive.org/web/20220127090642/https://helpx.adobe.com/illustrator/using/creating-text.html), [Create type on a path](https://web.archive.org/web/20220127090635/https://helpx.adobe.com/illustrator/using/creating-type-path.html)) |
@@ -75,6 +76,7 @@ Character Styles menu New/Redefine and footer New capture the first selected cha
| Date | Change | Summary |
|---|---|---|
| 2026-11-02 | minor | The wheel over Character, Properties and Control font-family fields changes selected text, one undo step per notch (#5253); scores and estimates unchanged. |
| 2026-11-01 | minor | The Type and Vertical Type tools make area type in a clicked closed path and type on a path along a clicked open one, with their own pointers; each type tool has its own icon; scores unchanged (estimated) |
| 2026-10-31 | minor | Units › East Asian Type acts (#394): Q and Ha (a quarter of a millimetre each) are units that preference offers; scores unchanged |
| 2026-11-01 | minor | Glyphs panel (#4908): the character selected with the Type tool (a range's first, else the one before the caret) is highlighted in the grid and scrolled into view when the selection moves to another character; Show › Alternates for Current Selection not yet; scores unchanged |
+3 -1
View File
@@ -1,6 +1,6 @@
# UI and interaction parity
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (Symbol editing shows draggable 9-slice guides; Color Effects add-on: Find Nearest Swatch, #4923) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-03 · **Change:** minor (font-family fields accept the mouse wheel, #5253; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) · **Target:** Adobe Illustrator 2026 (30.x)
## Feature submission evidence
@@ -194,6 +194,7 @@ tools, never checked side by side) isn't captured row by row.
| Behaviour | Status | Notes |
|---|---|---|
| Wheel over a closed font-family field in Character, Properties or Control | done | #5253: applies the next or previous family to selected text, one undo step per notch; uses saved font filters, ignores search text and stops at the list's ends. Escape and pointer departure keep the change. Other font-picking menus and modifier-wheel input keep their existing behavior. |
| Arrow keys nudge by Keyboard Increment (0.001–1296 pt); Shift ×10; Alt copies | done | |
| Fields commit what was typed on a click away or a move to another field, as Enter does; Escape discards it | done | #1787 |
| Number fields: Up/Down step, Shift ×10, Cmd/Ctrl ÷10, wheel over a focused field; steps, the wheel and label scrubs stop at the field's bounds (a stroke weight at 0, a miter limit at 1) | done | Shift+arrow in the Stroke weight field doesn't step by 10 (#991); bounds #3370 |
@@ -400,6 +401,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development
| Date | Change | Summary |
|---|---|---|
| 2026-11-02 | minor | Font-family fields in Character, Properties and Control accept the wheel without opening the menu (#5253); scores and estimates unchanged. |
| 2026-11-03 | minor | Symbol editing draws and drags 9-slice guides on the canvas (#5280). Guides outside the artwork remain unsupported. Scores and hours remain unchanged. |
| 2026-11-01 | minor | A double-click on a Repeat with the Selection tool enters isolation mode on it, where its source art (type included: a double-click there edits the text) is edited and every copy follows (#5054); scores and estimates unchanged |
| 2026-11-01 | minor | Live Corners: while a corner widget is pressed or dragged with the Selection or Direct Selection tool, the Up and Down arrows step the corners' kind (round, inverted round, chamfer) with the radius, as one undo step (#2898); scores and estimates unchanged |