Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::editor::SidebarPresenter Class Reference

Renders the editor's tree view and inspector panes. More...

#include "donner/editor/SidebarPresenter.h"

Classes

struct  IconTexture
 Maps a static path-operation icon bitmap to an ImGui texture handle for display. The icon bitmaps are rendered from embedded Bootstrap SVG resources through Donner; ImGui only receives the final raster texture for the image button. More...

Public Types

enum class  TransformField : std::uint8_t {
  PositionX ,
  PositionY ,
  Width ,
  Height ,
  Rotation ,
  Matrix
}
 Which inspector transform widget owns the in-progress edit. More...
using IconTextureProvider
 Callback that uploads a static icon bitmap and returns its ImGui handle and valid UV range.

Public Member Functions

void refreshSnapshot (const EditorApp &app)
 Refresh the tree / inspector snapshot from live app state. Safe to call only when the async renderer is idle.
void renderTreeView (EditorApp *liveApp, TreeViewState &state, const IconTextureProvider &iconTextureProvider={}) const
 Render the tree pane from the current snapshot. When liveApp is non-null, click-induced selection mutations are applied to it; when null, clicks are dropped (the render is "read-only" because the worker thread owns the document).
bool renderInspector (EditorApp *liveApp, const ViewportState &viewport, const IconTextureProvider &iconTextureProvider={})
 Render the inspector pane from the current snapshot.
bool inspectorHasSelectionForTesting () const
 Return whether the captured inspector snapshot has a selection.
bool hasTreeSnapshotForTesting () const
 Return whether a tree snapshot has been captured.
bool isTreeNodeExpandedForTesting (std::uint32_t entityId) const
 Whether the tree node for entityId is expanded. Keyed by the element's 32-bit entity id (entity cast). Drives the disclosure round-trip test.
void toggleTreeNodeExpandedForTesting (std::uint32_t entityId)
 Toggle the tree disclosure for entityId, exactly as clicking the row's chevron does.
std::string_view inspectorTitleForTesting () const
 Return the borrowed title from the captured inspector snapshot.
std::span< const std::pair< std::string, std::string > > inspectorXmlAttributesForTesting () const
 Return the borrowed authored-attribute rows from the inspector snapshot.
std::span< const std::pair< std::string, std::string > > inspectorComputedStyleForTesting () const
 Return the borrowed computed-style rows from the inspector snapshot.
std::span< const std::optional< ImU32 > > inspectorComputedStyleSwatchesForTesting () const
 Return optional color swatches aligned with the computed-style rows.
std::size_t resizeBoundsEvaluationCountForTesting () const
 Return painted-bounds evaluations used by the active resize edit.
const std::optional< Box2d > & inspectorBoundsForTesting () const
 Return document-space bounds captured for the inspector selection.
const std::optional< Transform2d > & inspectorTransformForTesting () const
 Return the transform captured for the inspector selection.
std::optional< Box2d > strokeIncrementRectForTesting () const
 Screen rectangle of the stroke-width increment button from the last inspector frame.
std::optional< Box2d > strokeDecrementRectForTesting () const
 Screen rectangle of the stroke-width decrement button from the last inspector frame.
std::optional< Box2d > strokeWidthRectForTesting () const
 Last rendered width value field, for drag and unit-preservation checks.
std::optional< Box2d > strokeWidthPresetRectForTesting (std::size_t index) const
 Quick-width preset row bounds while the hybrid popup is open.
std::optional< Box2d > strokeCapRectForTesting (std::size_t index) const
 Last rendered cap/join icon rectangle, for interaction and alignment checks.
std::optional< Box2d > strokeJoinRectForTesting (std::size_t index) const
 Return a stroke-join control's screen rectangle, or no value for an absent index.
std::optional< Box2d > strokeDashToggleRectForTesting () const
 Last rendered dashed-line toggle rectangle.
std::optional< Box2d > strokeDashPreviewRectForTesting () const
 Current dash-line preview and the three visual preset hit boxes.
std::optional< Box2d > strokeDashPresetRectForTesting (std::size_t index) const
 Return a dash-preset control's screen rectangle, or no value for an absent index.
bool strokeCustomDashSelectedForTesting () const
 Whether the current dashed style uses a pattern outside the visual presets.
bool strokeMiterLimitVisibleForTesting () const
 Whether the miter limit is shown for the selected join style.
std::optional< Box2d > strokeMiterLimitRectForTesting () const
 Last rendered sharp-join limit field, absent for rounded/beveled joins.
std::optional< Box2d > strokeMiterIncrementRectForTesting () const
 Screen rectangle of the miter-limit increment button from the last inspector frame.
std::optional< Box2d > strokeMiterDecrementRectForTesting () const
 Screen rectangle of the miter-limit decrement button from the last inspector frame.
std::optional< Box2d > strokeDashOffsetIncrementRectForTesting () const
 Last rendered dash offset increment button.
std::optional< Box2d > strokeDashOffsetRectForTesting () const
 Last rendered dash-offset field when its advanced row is visible.
bool dashPatternEditableForTesting () const
 Whether the captured dash pattern fits the bounded text editor.
std::span< const std::string > markerIdsForTesting () const
 Cached IDs offered by the marker selectors.
std::optional< Box2d > markerDisclosureRectForTesting () const
 Screen rectangle of the Markers disclosure row from the last inspector frame.
std::optional< Box2d > markerPickerRectForTesting (std::size_t index) const
 Screen rectangle of a marker picker from the last inspector frame, or no value when absent.
std::optional< Box2d > markerPrefabRectForTesting (std::size_t index) const
 Screen rectangle of a marker preset row in an open picker popup, or no value when absent.
std::size_t markerScanCountForTesting () const
 Number of bounded marker scans performed by this presenter.
bool submitDashPatternForTesting (EditorApp &app, std::string_view pattern)
 Submit a dash pattern through the same validation and style mutation path as the text field.
bool setStrokeDashOffsetForTesting (EditorApp &app, double value)
 Apply a dash offset in the currently captured SVG length unit.
std::optional< Box2d > transformFieldRectForTesting (TransformField field) const
 Last rendered screen rectangle for one decomposed Transform field. Matrix cells are excluded because they are indexed separately.
std::optional< Box2d > matrixFieldRectForTesting (int index) const
 Last rendered screen rectangle of one raw matrix component.
void beginTransformEditForTesting (EditorApp &app, TransformField field, int matrixIndex=0)
 Capture the edit baseline for field, as widget activation does.
bool hasTransformEditForTesting () const
 Whether a transform edit is currently in progress.
bool applyTransformEditForTesting (EditorApp &app, double value)
 Write value into the active edit and queue the resulting mutation, as one frame of dragging does. Returns true if a mutation was queued.
void commitTransformEditForTesting (EditorApp &app)
 Finalize the active edit into one undo entry, as widget deactivation does.

Detailed Description

Renders the editor's tree view and inspector panes.

The panes are always rendered from an internal snapshot so they stay visible even while the async renderer is mutating the document (the "(rendering...)" placeholder used to cover this gap, which made the panes flash to a disabled message on every render). The snapshot is refreshed from the live EditorApp when the caller indicates the worker thread isn't touching the document; otherwise the most recent capture is replayed unchanged. Click handling is gated the same way so mutations can't race the worker.


Class Documentation

◆ donner::editor::SidebarPresenter::IconTexture

struct donner::editor::SidebarPresenter::IconTexture

Maps a static path-operation icon bitmap to an ImGui texture handle for display. The icon bitmaps are rendered from embedded Bootstrap SVG resources through Donner; ImGui only receives the final raster texture for the image button.

Parameters
stableIdStable id of the static icon resource being uploaded.
bitmapThe Donner-rendered RGBA icon bitmap.
Returns
An ImGui texture handle plus the valid payload UV range, or an empty texture if upload failed.
Class Members
ImTextureID texture = 0 ImGui texture handle.
Vector2d uvBottomRight = Vector2d(1.0, 1.0) Bottom-right valid payload UV.

Member Typedef Documentation

◆ IconTextureProvider

Initial value:
std::function<IconTexture(std::uint64_t stableId, const svg::RendererBitmap& bitmap)>
Maps a static layer-affordance icon bitmap to an ImGui texture handle for display....
Definition LayersPanel.h:109
CPU-readable bitmap produced by a renderer snapshot.
Definition RendererInterface.h:67

Callback that uploads a static icon bitmap and returns its ImGui handle and valid UV range.

Member Enumeration Documentation

◆ TransformField

enum class donner::editor::SidebarPresenter::TransformField : std::uint8_t
strong

Which inspector transform widget owns the in-progress edit.

Enumerator
PositionX 

Bounds left edge, document space.

PositionY 

Bounds top edge, document space.

Width 

Bounds width, document space.

Height 

Bounds height, document space.

Rotation 

Decomposed rotation, degrees.

Matrix 

One raw matrix component (see matrixIndex).

Member Function Documentation

◆ markerPickerRectForTesting()

std::optional< Box2d > donner::editor::SidebarPresenter::markerPickerRectForTesting ( std::size_t index) const
inlinenodiscard

Screen rectangle of a marker picker from the last inspector frame, or no value when absent.

Parameters
index0 for the start-marker picker, 1 for the end-marker picker.

◆ markerPrefabRectForTesting()

std::optional< Box2d > donner::editor::SidebarPresenter::markerPrefabRectForTesting ( std::size_t index) const
inlinenodiscard

Screen rectangle of a marker preset row in an open picker popup, or no value when absent.

Parameters
indexIndex into kStrokeMarkerPrefabOptions.

◆ renderInspector()

bool donner::editor::SidebarPresenter::renderInspector ( EditorApp * liveApp,
const ViewportState & viewport,
const IconTextureProvider & iconTextureProvider = {} )

Render the inspector pane from the current snapshot.

Parameters
liveAppLive editor app for button actions, or null while the renderer owns the document.
viewportViewport state diagnostics.
iconTextureProviderUploads static Donner-rendered path operation icon bitmaps to ImGui textures for display, or null to keep blank hit areas in headless tests.
Returns
true if an inspector action queued a document mutation.

◆ renderTreeView()

void donner::editor::SidebarPresenter::renderTreeView ( EditorApp * liveApp,
TreeViewState & state,
const IconTextureProvider & iconTextureProvider = {} ) const

Render the tree pane from the current snapshot. When liveApp is non-null, click-induced selection mutations are applied to it; when null, clicks are dropped (the render is "read-only" because the worker thread owns the document).

Parameters
iconTextureProviderUploads the shared disclosure-chevron mask to an ImGui texture; pass null (e.g. headless tests) to skip chevron art while keeping the disclosure interaction.
liveAppLive application for mutations, or null while the renderer owns the document.
stateTree selection and scroll requests consumed or updated during rendering.

◆ strokeDashPresetRectForTesting()

std::optional< Box2d > donner::editor::SidebarPresenter::strokeDashPresetRectForTesting ( std::size_t index) const
inlinenodiscard

Return a dash-preset control's screen rectangle, or no value for an absent index.

Parameters
indexControl index to inspect.

◆ strokeJoinRectForTesting()

std::optional< Box2d > donner::editor::SidebarPresenter::strokeJoinRectForTesting ( std::size_t index) const
inlinenodiscard

Return a stroke-join control's screen rectangle, or no value for an absent index.

Parameters
indexControl index to inspect.

The documentation for this class was generated from the following file: