Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
EditorShellInternal.h File Reference
#include <optional>
#include <ostream>
#include <span>
#include <string>
#include <string_view>
#include <utility>
#include <vector>
#include "donner/base/Box.h"
#include "donner/base/Transform.h"
#include "donner/css/Color.h"
#include "donner/editor/CanvasScrollbars.h"
#include "donner/editor/EditorApp.h"
#include "donner/editor/FocusView.h"
#include "donner/editor/FrameMissTelemetry.h"
#include "donner/editor/GlTextureCache.h"
#include "donner/editor/ImGuiIncludes.h"
#include "donner/editor/PenTool.h"
#include "donner/editor/RotateCursorSet.h"
#include "donner/editor/SelectionTransformHandles.h"
#include "donner/editor/SourceSelection.h"
#include "donner/editor/ViewportInteractionController.h"
#include "donner/svg/SVGDocument.h"
#include "donner/svg/SVGElement.h"
#include "donner/svg/properties/PaintServer.h"
Include dependency graph for EditorShellInternal.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::internal::ToolbarPaintReferenceState
 Source range for a referenced paint server shown by the toolbar. More...
struct  donner::editor::internal::ToolbarPaintSlotState
 Paint slot presentation state for the fill/stroke toolbar. More...
struct  donner::editor::internal::ToolbarPaintState
 Fill and stroke toolbar paint state. More...
struct  donner::editor::internal::DocumentLoadFailureNotice
 Copy for the canvas notice shown when an opened document could not be loaded. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::editor::internal::PendingClickBusyAction {
  RunIdleClickPath ,
  CompleteFastRedrag ,
  CancelBusyRender
}
 High-level action for a buffered canvas click before the idle-only hit-test path.
enum class  donner::editor::internal::PendingClickIdleAction {
  DispatchSlowPath ,
  BeginMarquee ,
  WaitForMarqueeIntent
}
 High-level action for a buffered click once the renderer is idle.
enum class  donner::editor::internal::DeferredRenderAction {
  ClearRequest ,
  WakeForPenDrag ,
  SubmitRender ,
  WaitForRendererCompletion
}
 End-of-frame action for a deferred document render.

Functions

FrameMemorySample donner::editor::internal::MemorySampleFromPresentationResources (const PresentationResourceStats &resources)
 Copy presentation resource counters into a frame-history sample.
FrameMissResourceTelemetry donner::editor::internal::FrameMissTelemetryFromPresentationResources (const PresentationResourceStats &resources)
 Copy presentation resource counters into frame-miss telemetry.
ImGuiMouseCursor donner::editor::internal::CursorForTransformHandleIntent (const SelectionTransformHandleIntent &intent)
 Select the ImGui cursor for a transform-handle hit.
PenCursorHint donner::editor::internal::PenCursorHintForIntent (PenHoverIntent intent)
 Pen nib variant to show for intent.
bool donner::editor::internal::ContainsScreenPoint (const Box2d &rect, const ImVec2 &point)
 Test inclusive containment in a screen-space rectangle.
std::optional< Box2d > donner::editor::internal::TextFormatBarScreenRect (const ImVec2 &paneOrigin, const ImVec2 &contentRegion, const Box2d &toolPaletteRect, bool visible, float barHeight)
 Place the format bar below the tool palette, or return no rectangle when hidden or empty.
bool donner::editor::internal::CanvasChromeCapturesInput (const ImVec2 &point, const std::optional< Box2d > &referenceChipRect, const Box2d &toolPaletteRect, const std::optional< Box2d > &textFormatBarRect, const std::optional< Box2d > &editingScopeBreadcrumbRect, const Box2d &canvasZoomControlRect, const std::optional< Box2d > &compactPanelRect=std::nullopt)
 Test whether a pointer lies in any visible canvas chrome control.
bool donner::editor::internal::CanvasScrollbarsCaptureInput (bool scrollbarsVisible, const ViewportState &viewport, const Vector2d &screenPoint) noexcept
 Test whether visible canvas scrollbars capture a screen-space pointer.
bool donner::editor::internal::GroupOperationCanDispatch (bool rendererBusy, const GroupOperationAvailability &availability) noexcept
 Permit a group command only when the renderer is idle and the operation is available.
bool donner::editor::internal::PendingDocumentReplacementCanProcess (bool hasPendingRequest, bool documentWriteAvailable, bool hasPendingMutations) noexcept
 Permit a queued replacement only when document writes are available and mutations are drained.
bool donner::editor::internal::ShouldRefreshSidebarSnapshots (bool rendererBusy, bool interactionActive, bool previewsPaused) noexcept
 Refresh sidebar captures only while both rendering and interaction are idle.
bool donner::editor::internal::SidebarSnapshotRefreshPendingAfterPass (std::size_t deferredThumbnailCount) noexcept
 Report whether deferred thumbnails require another snapshot refresh.
template<typename Resolver>
bool donner::editor::internal::ResolveCachedDocumentBoolForFrame (bool rendererBusy, bool cachedValue, Resolver &&resolveWhenIdle)
 Resolve a document-derived UI boolean without ever entering the live document while the renderer owns it. Busy frames replay the value from the last complete UI epoch.
bool donner::editor::internal::SamplePickerActionsNeedFollowupFrame (bool dismiss, bool openFile, bool newDocument) noexcept
 Request another frame when the picker dismisses, opens a file, or creates a document.
bool donner::editor::internal::ShouldAdvanceSampleThumbnails (bool showSamplePicker, bool samplePresentationPending) noexcept
 Background carousel work yields while a selected sample owns the next document render.
DeferredRenderAction donner::editor::internal::DeferredRenderActionForState (bool hasDocument, bool penDragFlushed, bool rendererBusy) noexcept
 Choose how to advance a deferred render request from the current document and worker state.
PendingClickBusyAction donner::editor::internal::PendingClickBusyActionForState (bool tookFastRedrag, bool documentWriteUnavailable)
 Choose the buffered-click action while the renderer owns the document.
PendingClickIdleAction donner::editor::internal::PendingClickIdleActionForState (bool leftMouseDown, bool pendingClickCanStartMarquee, bool selectHoldElapsed, bool selectDragIntent)
 Choose the buffered-click action after the renderer releases the document.
DocumentLoadFailureNotice donner::editor::internal::DocumentLoadFailureNoticeFor (std::string_view reason, std::optional< std::size_t > line)
 Explain a fatal parse diagnostic for the canvas notice.
std::string_view donner::editor::internal::TextToolHintLabel (bool isEditing, bool isDraggingBox, bool touchPreferred=false)
 Discoverability hint for the idle text tool ("double-click places point text, drag draws a box"). Empty while a session or box drag is active - the hint only shows when the next click/drag would act on empty canvas.
css::RGBA donner::editor::internal::PaintServerFallbackColor ()
 Return the neutral toolbar color used for paint that lacks a solid-color preview.
ToolbarPaintSlotState donner::editor::internal::ToolbarPaintSlotStateForActiveAttribute (std::string_view value)
 Build a toolbar swatch from an authored paint value, retaining custom values as labels.
ToolbarPaintReferenceState donner::editor::internal::ToolbarPaintReferenceStateFor (svg::SVGDocument *document, std::optional< std::string_view > source, const svg::Reference &reference)
 Capture a paint reference and its available source location for the toolbar.
ToolbarPaintSlotState donner::editor::internal::ToolbarPaintSlotStateForPaintServer (const svg::PaintServer &paint, const css::RGBA &currentColor, svg::SVGDocument *document, std::optional< std::string_view > source)
 Build a toolbar swatch and reference metadata from resolved paint.
ToolbarPaintState donner::editor::internal::ToolbarPaintStateForActivePaint (const ActivePaintStyle &paintStyle)
 Build fill and stroke toolbar presentation from the active paint style.
std::string donner::editor::internal::PaintChipLabel (std::string_view prefix, const ToolbarPaintSlotState &state)
 Format the label of a toolbar paint chip.
std::string donner::editor::internal::SelectionSizeChipLabel (const Box2d &screenBounds)
 Format the selection bounds width and height for a toolbar chip.
std::string donner::editor::internal::SelectionPositionChipLabel (const Box2d &documentBounds)
 Format the document-space selection position for a toolbar chip.
std::string donner::editor::internal::SelectionAngleChipLabel (const Transform2d &documentFromStartDocument)
 Format the rotation represented by a selection transform.
Box2d donner::editor::internal::TransformDocumentBox (const Box2d &box, const Transform2d &documentFromBoundsDocument)
 Transform every box corner and return their axis-aligned document-space bounds.
bool donner::editor::internal::DeferSourceFocusWhileAwaitingEdits (TextEditor &textEditor, bool focusEnabled)
 Preserve enabled source focus while document edits await source-pane writeback. Disabled focus clears the view-only partition immediately.
float donner::editor::internal::ClampSourcePaneWidthForWindow (float requestedWidth, float windowWidth)
 Clamp a requested source-pane width to the usable window range.
std::string donner::editor::internal::ReferenceHighlightChipLabel (const ReferenceHighlightSummary &summary)
 Format the toolbar label for the current reference-highlight summary.
void donner::editor::internal::AddUniqueElements (std::vector< svg::SVGElement > *target, std::span< const svg::SVGElement > elements)
 Append elements not already present in a destination list.
bool donner::editor::internal::ContainsElement (std::span< const svg::SVGElement > elements, const svg::SVGElement &element)
 Test whether an element handle is present in a list.
std::string donner::editor::internal::ElementContextMenuLabel (const svg::SVGElement &element)
 Build the display label for an element in the context menu.
std::string donner::editor::internal::InitialDocumentSyncSource (const ::donner::editor::EditorShellOptions &options)
 Use host-provided initial source, otherwise load the requested file or return empty text.
std::string donner::editor::internal::CanonicalizeForTextEditor (std::string_view source)
 Remove one final newline to match the text editor source representation.
Box2d donner::editor::internal::ResolveDocumentViewBox (svg::SVGDocument &document)
 Resolve the authored viewBox, intrinsic dimensions, canvas size, or unit-box fallback under read access.
std::optional< Box2d > donner::editor::internal::ResolveDocumentViewBoxForFrame (svg::SVGDocument &document, bool rendererBusy)
 Return no update while rendering is busy; otherwise resolve the document viewBox.

Function Documentation

◆ AddUniqueElements()

void donner::editor::internal::AddUniqueElements ( std::vector< svg::SVGElement > * target,
std::span< const svg::SVGElement > elements )

Append elements not already present in a destination list.

Parameters
targetNon-null destination list to update.
elementsElements to append without duplicates.

◆ CanonicalizeForTextEditor()

std::string donner::editor::internal::CanonicalizeForTextEditor ( std::string_view source)
nodiscard

Remove one final newline to match the text editor source representation.

Parameters
sourceSource text to copy and normalize.

◆ CanvasChromeCapturesInput()

bool donner::editor::internal::CanvasChromeCapturesInput ( const ImVec2 & point,
const std::optional< Box2d > & referenceChipRect,
const Box2d & toolPaletteRect,
const std::optional< Box2d > & textFormatBarRect,
const std::optional< Box2d > & editingScopeBreadcrumbRect,
const Box2d & canvasZoomControlRect,
const std::optional< Box2d > & compactPanelRect = std::nullopt )
nodiscard

Test whether a pointer lies in any visible canvas chrome control.

Parameters
pointPointer position in logical screen pixels.
referenceChipRectOptional reference-chip bounds.
toolPaletteRectTool-palette bounds.
textFormatBarRectOptional text-format bar bounds.
editingScopeBreadcrumbRectOptional editing-scope breadcrumb bounds.
canvasZoomControlRectZoom-control bounds.
compactPanelRectOptional compact-panel bounds.

◆ CanvasScrollbarsCaptureInput()

bool donner::editor::internal::CanvasScrollbarsCaptureInput ( bool scrollbarsVisible,
const ViewportState & viewport,
const Vector2d & screenPoint )
nodiscardnoexcept

Test whether visible canvas scrollbars capture a screen-space pointer.

Parameters
scrollbarsVisibleWhether scrollbars are currently shown.
viewportViewport used to compute scrollbar geometry.
screenPointPointer position in logical screen pixels.

◆ ClampSourcePaneWidthForWindow()

float donner::editor::internal::ClampSourcePaneWidthForWindow ( float requestedWidth,
float windowWidth )
nodiscard

Clamp a requested source-pane width to the usable window range.

Parameters
requestedWidthRequested width in logical pixels.
windowWidthAvailable window width in logical pixels.

◆ ContainsElement()

bool donner::editor::internal::ContainsElement ( std::span< const svg::SVGElement > elements,
const svg::SVGElement & element )
nodiscard

Test whether an element handle is present in a list.

Parameters
elementsHandles to search.
elementHandle to find.

◆ ContainsScreenPoint()

bool donner::editor::internal::ContainsScreenPoint ( const Box2d & rect,
const ImVec2 & point )
nodiscard

Test inclusive containment in a screen-space rectangle.

Parameters
rectRectangle in logical screen pixels.
pointPoint in the same coordinate system.

◆ CursorForTransformHandleIntent()

ImGuiMouseCursor donner::editor::internal::CursorForTransformHandleIntent ( const SelectionTransformHandleIntent & intent)
nodiscard

Select the ImGui cursor for a transform-handle hit.

Parameters
intentTransform action and corner under the pointer.

◆ DeferredRenderActionForState()

DeferredRenderAction donner::editor::internal::DeferredRenderActionForState ( bool hasDocument,
bool penDragFlushed,
bool rendererBusy )
nodiscardnoexcept

Choose how to advance a deferred render request from the current document and worker state.

Parameters
hasDocumentWhether a document is loaded.
penDragFlushedWhether this pass applied a pending pen drag.
rendererBusyWhether the render worker is busy.

◆ DeferSourceFocusWhileAwaitingEdits()

bool donner::editor::internal::DeferSourceFocusWhileAwaitingEdits ( TextEditor & textEditor,
bool focusEnabled )
nodiscard

Preserve enabled source focus while document edits await source-pane writeback. Disabled focus clears the view-only partition immediately.

Parameters
textEditorSource pane whose focus partition may be cleared.
focusEnabledWhether selected-element source focus is enabled.
Returns
True when the caller should defer focus recomputation until writeback completes.

◆ DocumentLoadFailureNoticeFor()

DocumentLoadFailureNotice donner::editor::internal::DocumentLoadFailureNoticeFor ( std::string_view reason,
std::optional< std::size_t > line )
nodiscard

Explain a fatal parse diagnostic for the canvas notice.

Parameters
reasonParser diagnostic text.
lineOne-based source line of the problem, when known.

◆ ElementContextMenuLabel()

std::string donner::editor::internal::ElementContextMenuLabel ( const svg::SVGElement & element)
nodiscard

Build the display label for an element in the context menu.

Parameters
elementElement whose tag and identity are displayed.

◆ FrameMissTelemetryFromPresentationResources()

FrameMissResourceTelemetry donner::editor::internal::FrameMissTelemetryFromPresentationResources ( const PresentationResourceStats & resources)
nodiscard

Copy presentation resource counters into frame-miss telemetry.

Parameters
resourcesCurrent presentation resource accounting.

◆ GroupOperationCanDispatch()

bool donner::editor::internal::GroupOperationCanDispatch ( bool rendererBusy,
const GroupOperationAvailability & availability )
nodiscardnoexcept

Permit a group command only when the renderer is idle and the operation is available.

Parameters
rendererBusyWhether the worker currently owns the document.
availabilityPrecomputed availability of the requested group operation.

◆ InitialDocumentSyncSource()

std::string donner::editor::internal::InitialDocumentSyncSource ( const ::donner::editor::EditorShellOptions & options)
nodiscard

Use host-provided initial source, otherwise load the requested file or return empty text.

Parameters
optionsInitial document source and path options.

◆ MemorySampleFromPresentationResources()

FrameMemorySample donner::editor::internal::MemorySampleFromPresentationResources ( const PresentationResourceStats & resources)
nodiscard

Copy presentation resource counters into a frame-history sample.

Parameters
resourcesCurrent presentation resource accounting.

◆ PaintChipLabel()

std::string donner::editor::internal::PaintChipLabel ( std::string_view prefix,
const ToolbarPaintSlotState & state )
nodiscard

Format the label of a toolbar paint chip.

Parameters
prefixRole label, such as fill or stroke.
statePaint-slot presentation to describe.

◆ PenCursorHintForIntent()

PenCursorHint donner::editor::internal::PenCursorHintForIntent ( PenHoverIntent intent)
nodiscard

Pen nib variant to show for intent.

PenHoverIntent::DragAnchor has no nib: grabbing an existing anchor is not a nib gesture, so the shell shows the anchor-point cursor for it and this returns the plain nib as an inert default.

Parameters
intentWhat a pen-tool click under the pointer would do.

◆ PendingClickBusyActionForState()

PendingClickBusyAction donner::editor::internal::PendingClickBusyActionForState ( bool tookFastRedrag,
bool documentWriteUnavailable )
nodiscard

Choose the buffered-click action while the renderer owns the document.

Parameters
tookFastRedragWhether the cached presentation accepted a fast redrag.
documentWriteUnavailableWhether live document mutation is unavailable.

◆ PendingClickIdleActionForState()

PendingClickIdleAction donner::editor::internal::PendingClickIdleActionForState ( bool leftMouseDown,
bool pendingClickCanStartMarquee,
bool selectHoldElapsed,
bool selectDragIntent )
nodiscard

Choose the buffered-click action after the renderer releases the document.

Parameters
leftMouseDownWhether the initiating mouse button remains held.
pendingClickCanStartMarqueeWhether the buffered click may start a marquee.
selectHoldElapsedWhether the selection hold interval elapsed.
selectDragIntentWhether pointer movement establishes a selection drag.

◆ PendingDocumentReplacementCanProcess()

bool donner::editor::internal::PendingDocumentReplacementCanProcess ( bool hasPendingRequest,
bool documentWriteAvailable,
bool hasPendingMutations )
nodiscardnoexcept

Permit a queued replacement only when document writes are available and mutations are drained.

Parameters
hasPendingRequestWhether a replacement is queued.
documentWriteAvailableWhether the caller can write the document now.
hasPendingMutationsWhether earlier mutations still need processing.

◆ ReferenceHighlightChipLabel()

std::string donner::editor::internal::ReferenceHighlightChipLabel ( const ReferenceHighlightSummary & summary)
nodiscard

Format the toolbar label for the current reference-highlight summary.

Parameters
summaryReference counts and highlight state.

◆ ResolveDocumentViewBox()

Box2d donner::editor::internal::ResolveDocumentViewBox ( svg::SVGDocument & document)
nodiscard

Resolve the authored viewBox, intrinsic dimensions, canvas size, or unit-box fallback under read access.

Parameters
documentDocument whose root geometry is inspected.

◆ ResolveDocumentViewBoxForFrame()

std::optional< Box2d > donner::editor::internal::ResolveDocumentViewBoxForFrame ( svg::SVGDocument & document,
bool rendererBusy )
nodiscard

Return no update while rendering is busy; otherwise resolve the document viewBox.

Parameters
documentDocument whose root geometry is inspected while idle.
rendererBusyWhether the worker currently owns the document.

◆ SamplePickerActionsNeedFollowupFrame()

bool donner::editor::internal::SamplePickerActionsNeedFollowupFrame ( bool dismiss,
bool openFile,
bool newDocument )
nodiscardnoexcept

Request another frame when the picker dismisses, opens a file, or creates a document.

Parameters
dismissWhether the picker was dismissed.
openFileWhether file opening was requested.
newDocumentWhether a new document was requested.

◆ SelectionAngleChipLabel()

std::string donner::editor::internal::SelectionAngleChipLabel ( const Transform2d & documentFromStartDocument)
nodiscard

Format the rotation represented by a selection transform.

Parameters
documentFromStartDocumentTransform from gesture-start document coordinates to current coordinates.

◆ SelectionPositionChipLabel()

std::string donner::editor::internal::SelectionPositionChipLabel ( const Box2d & documentBounds)
nodiscard

Format the document-space selection position for a toolbar chip.

Parameters
documentBoundsSelection bounds in document coordinates.

◆ SelectionSizeChipLabel()

std::string donner::editor::internal::SelectionSizeChipLabel ( const Box2d & screenBounds)
nodiscard

Format the selection bounds width and height for a toolbar chip.

Parameters
screenBoundsBounds whose dimensions are displayed.

◆ ShouldRefreshSidebarSnapshots()

bool donner::editor::internal::ShouldRefreshSidebarSnapshots ( bool rendererBusy,
bool interactionActive,
bool previewsPaused )
nodiscardnoexcept

Refresh sidebar captures only while both rendering and interaction are idle.

Parameters
rendererBusyWhether the renderer owns the document.
interactionActiveWhether an interaction is in progress.
previewsPausedWhether animation playback or its reset suspends auxiliary work.

◆ SidebarSnapshotRefreshPendingAfterPass()

bool donner::editor::internal::SidebarSnapshotRefreshPendingAfterPass ( std::size_t deferredThumbnailCount)
nodiscardnoexcept

Report whether deferred thumbnails require another snapshot refresh.

Parameters
deferredThumbnailCountNumber of thumbnails left pending by this pass.

◆ TextFormatBarScreenRect()

std::optional< Box2d > donner::editor::internal::TextFormatBarScreenRect ( const ImVec2 & paneOrigin,
const ImVec2 & contentRegion,
const Box2d & toolPaletteRect,
bool visible,
float barHeight )
nodiscard

Place the format bar below the tool palette, or return no rectangle when hidden or empty.

Parameters
paneOriginRender-pane origin in logical screen pixels.
contentRegionAvailable pane size in logical pixels.
toolPaletteRectScreen-space toolbar bounds used to align the format bar.
visibleWhether the format bar is requested.
barHeightRequested height in logical pixels.

◆ ToolbarPaintReferenceStateFor()

ToolbarPaintReferenceState donner::editor::internal::ToolbarPaintReferenceStateFor ( svg::SVGDocument * document,
std::optional< std::string_view > source,
const svg::Reference & reference )
nodiscard

Capture a paint reference and its available source location for the toolbar.

Parameters
documentDocument used to resolve local references, or null.
sourceSynchronized source text when available.
referenceAuthored paint-server reference.

◆ ToolbarPaintSlotStateForActiveAttribute()

ToolbarPaintSlotState donner::editor::internal::ToolbarPaintSlotStateForActiveAttribute ( std::string_view value)
nodiscard

Build a toolbar swatch from an authored paint value, retaining custom values as labels.

Parameters
valueAuthored fill or stroke value.

◆ ToolbarPaintSlotStateForPaintServer()

ToolbarPaintSlotState donner::editor::internal::ToolbarPaintSlotStateForPaintServer ( const svg::PaintServer & paint,
const css::RGBA & currentColor,
svg::SVGDocument * document,
std::optional< std::string_view > source )
nodiscard

Build a toolbar swatch and reference metadata from resolved paint.

Parameters
paintPaint server to display.
currentColorColor used to resolve currentColor paint.
documentDocument used to inspect local references, or null.
sourceSynchronized source text when available.

◆ ToolbarPaintStateForActivePaint()

ToolbarPaintState donner::editor::internal::ToolbarPaintStateForActivePaint ( const ActivePaintStyle & paintStyle)
nodiscard

Build fill and stroke toolbar presentation from the active paint style.

Parameters
paintStyleActive fill and stroke values.

◆ TransformDocumentBox()

Box2d donner::editor::internal::TransformDocumentBox ( const Box2d & box,
const Transform2d & documentFromBoundsDocument )
nodiscard

Transform every box corner and return their axis-aligned document-space bounds.

Parameters
boxBounds in the source coordinate system.
documentFromBoundsDocumentTransform into destination document coordinates.