Trait ambient_ui::editor::Editor

source ·
pub trait Editor {
    // Required method
    fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element;

    // Provided methods
    fn edit_or_view(
        self,
        on_change: Option<ChangeCb<Self>>,
        opts: EditorOpts
    ) -> Element
       where Self: Sized { ... }
    fn view(self, opts: EditorOpts) -> Element
       where Self: Sized { ... }
}
Expand description

A trait for types that can be edited in the UI.

Implementing this trait allows you to make a UI editor for any value of your type.

Required Methods§

source

fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element

Create an editor Element for this value.

Provided Methods§

source

fn edit_or_view( self, on_change: Option<ChangeCb<Self>>, opts: EditorOpts ) -> Element
where Self: Sized,

Creates an editor Element for this value, or a view Element if on_change is None.

source

fn view(self, opts: EditorOpts) -> Element
where Self: Sized,

Viewer for this value.

By default, this will call Editor::editor with a no-op callback.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Editor for bool

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for f32

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for i32

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for u32

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for u64

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for ()

source§

fn editor(self, _on_change: ChangeCb<Self>, _opts: EditorOpts) -> Element

source§

impl Editor for usize

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl Editor for Vec4

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

impl Editor for Vec2

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

impl Editor for Vec3

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

impl Editor for String

source§

fn editor( self, on_change: Cb<dyn Fn(Self) + Sync + Send>, _: EditorOpts ) -> Element

source§

fn view(self, _opts: EditorOpts) -> Element

source§

impl Editor for Duration

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

source§

fn view(self, _: EditorOpts) -> Element
where Self: Sized,

source§

impl Editor for SystemTime

source§

fn editor(self, _: ChangeCb<Self>, _: EditorOpts) -> Element

source§

impl<K, V> Editor for IndexMap<K, V>
where K: Hash + Eq + Send + Sync + Debug + 'static + Clone + Editor + Default, V: Send + Sync + Debug + 'static + Clone + Editor + Default,

source§

fn editor( self, on_change: Cb<dyn Fn(Self) + Send + Sync>, _opts: EditorOpts ) -> Element

source§

fn view(self, opts: EditorOpts) -> Element

source§

impl<K: Editor + Debug + Clone + Default + Hash + PartialEq + Eq + PartialOrd + Ord + Sync + Send + 'static, V: Editor + Debug + Clone + Default + Sync + Send + 'static> Editor for HashMap<K, V>

source§

fn editor( self, on_change: Cb<dyn Fn(Self) + Sync + Send>, _: EditorOpts ) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl<T> Editor for Arc<Mutex<T>>
where T: 'static + Send + Sync + Clone + Editor,

source§

fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element

source§

impl<T> Editor for Arc<T>
where T: 'static + Send + Sync + Clone + Editor,

source§

fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element

source§

impl<T: Default + Editor + 'static> Editor for Option<T>

source§

fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element

source§

fn view(self, opts: EditorOpts) -> Element
where Self: Sized,

source§

impl<T: Editor + 'static> Editor for Box<T>

source§

fn editor(self, on_change: ChangeCb<Self>, opts: EditorOpts) -> Element

source§

impl<T: Editor + Debug + Clone + Default + Sync + Send + 'static> Editor for Vec<T>

source§

fn editor( self, on_change: Cb<dyn Fn(Self) + Sync + Send>, _: EditorOpts ) -> Element

source§

fn view(self, _: EditorOpts) -> Element

source§

impl<const C: usize, T: 'static + Clone + Debug + Editor + Send + Sync> Editor for [T; C]

source§

fn editor(self, on_change: ChangeCb<Self>, _: EditorOpts) -> Element

Implementors§