mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 13:47:21 -06:00
Type: font menu previews end safely, rows and samples cost less per frame (review of #339)
- A preview whose menu has gone (the panel isn't drawn: text deselected, panel closed) or is closing (Escape, a press outside the menu) is undone at the start of the frame, before the canvas sees the input: a canvas drag no longer runs inside the preview's interaction and gets rolled back with it. The menu also ends the preview in the frame it closes. - The list fits the popup (it was taller than the popup, which then scrolled too), so the current family is centred in view on opening; ↑/↓ scroll only as far as needed. - Type › Font (in-window menu bar): each item keeps room for its sample after the name, so long family names no longer run under it. - Rows are listed again only when the query, filters, expanded families, favourites or font list change, not every frame. - Samples: one budget per frame across every menu (Type › Font gave each item its own), at most 8 rendering at once, the worker asks for a repaint when it is done instead of polling, the cache holds 512, and one function draws a sample for both menus. - Font menus use menu_family_list (the hidden-family rule lives there); FontClass::label is gone (the menu's translated labels are the only ones). - Tests: a preview left by a menu that is gone is undone; a press outside the open menu ends the preview in that frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
8f7949c30b
commit
cea2ee6a54
@@ -379,20 +379,9 @@ pub enum FontClass {
|
||||
}
|
||||
|
||||
impl FontClass {
|
||||
/// The kinds a font menu filters by (all but `Other`).
|
||||
pub const ALL: [FontClass; 6] =
|
||||
[FontClass::Serif, FontClass::Sans, FontClass::Rounded, FontClass::Script, FontClass::Monospaced, FontClass::Decorative];
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
FontClass::Serif => "Serif / Mincho",
|
||||
FontClass::Sans => "Sans Serif / Gothic",
|
||||
FontClass::Rounded => "Rounded",
|
||||
FontClass::Script => "Script / Brush",
|
||||
FontClass::Monospaced => "Monospaced",
|
||||
FontClass::Decorative => "Decorative",
|
||||
FontClass::Other => "Other",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What a font menu filters on: whether a family sets Japanese, and its kind.
|
||||
|
||||
Reference in New Issue
Block a user