Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
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

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
bool hasTreeSnapshotForTesting () const
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
std::span< const std::pair< std::string, std::string > > inspectorXmlAttributesForTesting () const
std::span< const std::pair< std::string, std::string > > inspectorComputedStyleForTesting () const
std::span< const std::optional< ImU32 > > inspectorComputedStyleSwatchesForTesting () const
const std::optional< Box2d > & inspectorBoundsForTesting () const
const std::optional< Transform2d > & inspectorTransformForTesting () const
std::optional< Box2dtransformFieldRectForTesting (TransformField field) const
 Last rendered screen rectangle for one decomposed Transform field. Matrix cells are excluded because they are indexed separately.
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

using donner::editor::SidebarPresenter::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:85
CPU-readable bitmap produced by a renderer snapshot.
Definition RendererInterface.h:59

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

◆ 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.

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