|
|
std::vector< FormatBarFontFamily > | donner::editor::BuildFormatBarFamilies (const std::vector< svg::FontFamilyInfo > &catalogFamilies, const std::function< ImFont *(const svg::FontFamilyInfo &)> &previewForFamily) |
| | Build the picker's family list from a catalog listing (see FontCatalog::families(), which already orders Embedded before System and sorts within each group). Each entry keeps its CSS family name and source; previewFont is filled from previewForFamily for families the editor has a loaded face for, and left null otherwise (the entry then renders in the default UI font). Families the catalog lacks are still reachable through the bar's free-text box, so this list is additive, not a whitelist.
|
| bool | donner::editor::FormatBarShouldShow (bool hasSingleTextSelection, bool textEditingActive) |
| | Whether the format bar should be shown, given the styling context.
|
|
void | donner::editor::ReadTextFormatState (const svg::SVGElement &text, FormatBarState *state) |
| | Populate the attribute-derived fields (fontFamily, fontSize, hasFontSize, bold, italic, underline) of state from a single selected/edited <text> element. Reads under a scoped read access so it is safe while the live editor keeps the document in ConcurrentDom. Leaves visible, families, and boldToggleFont untouched (owned by the shell).
|
| bool | donner::editor::ApplyFormatBarActionsToSelection (const FormatBarActions &actions, const FormatBarState &state, bool routeTogglesToSelection, EditorApp &app) |
| | Route the attribute-write half of the bar's actions onto the app's current selection (the TextInspectorPanel seam): font family, font size, and - when routeTogglesToSelection is true - the B/I/U toggles. During an editing session the shell handles B/I/U through TextTool instead and passes routeTogglesToSelection=false, so this only writes family/size.
|
TextFormatBarPresenter renders a contextual floating text-formatting bar below the canvas tool palette. The bar is shown only while text styling is in context: when the canvas selection is a single <text> element or an in-canvas text editing session is active. It offers a searchable font-family picker (each known family previewed in its own face, with a free-text fallback for families the editor lacks), a font-size combo with drag and preset behavior, and Bold/Italic/Underline toggles.
Following the MenuBarPresenter pattern, the presenter is a thin, testable surface: render() draws the imgui controls and returns edge-triggered FormatBarActions, which the shell routes to the existing styling commands. B/I/U during an editing session go through the TextTool style toggles; family, size, and the selection-only B/I/U path go through the TextInspectorPanel attribute-write seam (setAttributeOnSelection). This bar is a second surface over those commands, not a new styling pipeline.
Route the attribute-write half of the bar's actions onto the app's current selection (the TextInspectorPanel seam): font family, font size, and - when routeTogglesToSelection is true - the B/I/U toggles. During an editing session the shell handles B/I/U through TextTool instead and passes routeTogglesToSelection=false, so this only writes family/size.
Toggle-off writes the "normal"/"none" value (rather than removing the attribute) to stay on the pure attribute-write path; the value that flips is derived from state's current B/I/U flags.
- Returns
- true if any document mutation was queued.
| bool donner::editor::FormatBarShouldShow |
( |
bool | hasSingleTextSelection, |
|
|
bool | textEditingActive ) |
|
nodiscard |
Whether the format bar should be shown, given the styling context.
The bar is contextual: it appears while the selection is a single <text> element, or while an in-canvas text editing session is active (which also makes that element the selection, but the session predicate is kept explicit so the bar stays up through selection churn during editing).
- Parameters
-
| hasSingleTextSelection | True when exactly one <text> is selected. |
| textEditingActive | True when an in-canvas text session owns the caret. |