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
fn cursor_2d(&self) -> Option<[f64; 2]>
Gets the current cursor position in 2D.
fn cursor_3d(&self) -> Option<[f64; 3]>
Gets the current cursor position in 3D world coordinates.
fn hit_2d(&self, pos: [f64; 2]) -> Vec<(Type, Object)>
Try to hit objects at 2D position.
fn hit_3d(&self, pos: [f64; 3]) -> Vec<(Type, Object)>
Try to hit objects at 3D position.
fn select(&mut self, ty: Type, obj: Object) -> Result<(), ()>
Select a single object.
fn select_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
Select multiple objects. Adds to the current selection.
fn deselect_multiple(&mut self, ty: Type, objs: &[Object]) -> Result<(), ()>
Deselect multiple objects. Removes from the current selection.
fn select_none(&mut self, ty: Type) -> Result<(), ()>
Deselect everything of a type.
fn insert(&mut self, ty: Type, args: &Any) -> Result<Object, ()>
Inserts a new object.
fn delete(&mut self, ty: Type, obj: Object) -> Result<(), ()>
Returns an object which references must be updated when using swap-remove by replacing object with last one in same table.
fn update(&mut self, ty: Type, obj: Object, args: &Any) -> Result<(), ()>
Updates an object with new values.
fn replace(&mut self, ty: Type, from: Object, to: Object) -> Result<(), ()>
Replaces an object with another.
fn get<'a>(&'a self, ty: Type, obj: Object) -> Result<&'a Any, ()>
Get the value of an object.
fn visible(&self, ty: Type) -> Vec<Object>
Get the visible objects of a type.
fn selected(&self, ty: Type) -> Option<Object>
Gets the selected object of a type. If the editor supports multiple selection, the selected object is usually the among the multiple-selected ones.
fn multiple_selected(&self, ty: Type) -> Vec<Object>
Gets the multiple selected objects of a type. The order of the selected objects matter.
fn all(&self, ty: Type) -> Vec<Object>
Get all objects of a type.
Navigate to an object such that it becomes visible.