Trait editor::Editor [] [src]

pub trait Editor {
    fn cursor_2d(&self) -> Option<[f64; 2]>;
    fn cursor_3d(&self) -> Option<[f64; 3]>;
    fn hit_2d(&self, pos: [f64; 2]) -> Vec<(Type, Object)>;
    fn hit_3d(&self, pos: [f64; 3]) -> Vec<(Type, Object)>;
    fn select(&mut self, ty: Type, obj: Object) -> Result<(), ()>;
    fn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>;
    fn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>;
    fn select_none(&mut self, ty: Type) -> Result<(), ()>;
    fn insert(&mut self, ty: Type, args: &Any) -> Result<Object, ()>;
    fn delete(&mut self, ty: Type, obj: Object) -> Result<(), ()>;
    fn update(&mut self, ty: Type, obj: Object, args: &Any) -> Result<(), ()>;
    fn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>;
    fn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a Any, ()>;
    fn visible(&self, ty: Type) -> Vec<Object>;
    fn selected(&self, ty: Type) -> Option<Object>;
    fn multiple_selected(&self, ty: Type) -> Vec<Object>;
    fn all(&self, ty: Type) -> Vec<Object>;
    fn navigate_to(&mut self, ty: Type, obj: Object) -> Result<(), ()>;
}

A generic interface for editors, implemented on controllers.

Provides all information necessary to execute actions, select objects, navigate and update. This makes it possible to write reusable generic actions.

Methods that returns Result can trigger a rollback in actions. This is to prevent logical errors from affecting data. Concurrent actions are not permitted at the same time.

View information must be stored internally in the editor. If the editor state depends on the view state, then it should not be updated before refresh_views is called.

Required Methods

Gets the current cursor position in 2D.

Gets the current cursor position in 3D world coordinates.

Try to hit objects at 2D position.

Try to hit objects at 3D position.

Select a single object.

Select multiple objects. Adds to the current selection.

Deselect multiple objects. Removes from the current selection.

Deselect everything of a type.

Inserts a new object.

Returns an object which references must be updated when using swap-remove by replacing object with last one in same table.

Updates an object with new values.

Replaces an object with another.

Get the value of an object.

Get the visible objects of a type.

Gets the selected object of a type. If the editor supports multiple selection, the selected object is usually the among the multiple-selected ones.

Gets the multiple selected objects of a type. The order of the selected objects matter.

Get all objects of a type.

Navigate to an object such that it becomes visible.

Implementors