Skip to main content

default_editor

Function default_editor 

Source
pub fn default_editor<P: Params + 'static>(
    params: Arc<P>,
    layout: GridLayout,
) -> Box<dyn Editor>
Expand description

Construct truce’s default editor for a plugin’s editor() impl.

Picks the renderer based on which feature is enabled:

  • gpu (opt-in): wraps a BuiltinEditor in a GpuEditor that renders directly through truce_gpu::WgpuBackend.
  • cpu (default): returns a BuiltinEditor whose Editor impl rasterises to a tiny-skia pixmap and blits it to a wgpu surface.
  • iOS: always returns the iOS BuiltinEditor (UIView-hosted CAMetalLayer); the gpu feature has no effect on iOS.

Most layout-only plugins implement truce_plugin::PluginLogic::editor as:

fn editor(&self) -> Box<dyn truce_core::Editor> {
    truce_gui::default_editor(
        self.params.clone(),
        GridLayout::build(vec![ /* widgets */ ]),
    )
}

Only compiled when a renderer feature (cpu or gpu) is on. Crates that depend on truce-gui purely for its types / platform helpers (e.g. truce-egui, truce-iced, truce-slint) can build it with neither feature and simply not call this function.