pub trait View {
Show 19 methods
// Required methods
fn open(
&mut self,
ctx: &Context,
bytes: &[u8],
path: &Path,
) -> Result<(), String>;
fn close(&mut self);
fn is_open(&self) -> bool;
fn title(&self) -> Option<String>;
fn document_mut(&mut self) -> Option<&mut Document>;
fn central(&mut self, ui: &mut Ui, zoom: f32, editing: &mut Editing);
// Provided methods
fn reindex(&mut self) { ... }
fn caret(&self) -> Option<Caret> { ... }
fn restore_caret(&mut self, _caret: Caret) { ... }
fn menus(&mut self, _ui: &mut Ui, _editing: &Editing) { ... }
fn presenting(&self) -> bool { ... }
fn find(&mut self, _query: &str) -> usize { ... }
fn can_replace(&self, _editing: &Editing) -> bool { ... }
fn replace(
&mut self,
_with: &str,
_all: bool,
_editing: &mut Editing,
) -> Replaced { ... }
fn show_match(&mut self, _index: usize) { ... }
fn side(&mut self, _ui: &mut Ui) -> bool { ... }
fn view_menu(&mut self, _ui: &mut Ui) { ... }
fn file_menu(&mut self, _ui: &mut Ui, _path: Option<&Path>) { ... }
fn take_notice(&mut self) -> Option<Notice> { ... }
}Expand description
What the shell needs from the view that draws a particular format.
Required Methods§
Sourcefn open(
&mut self,
ctx: &Context,
bytes: &[u8],
path: &Path,
) -> Result<(), String>
fn open( &mut self, ctx: &Context, bytes: &[u8], path: &Path, ) -> Result<(), String>
Take a document’s bytes. The path is for the window’s title and for reloading, and is never read from here: this is given the bytes.
The context is for the work a new document makes necessary before it can be drawn — loading the font faces its styles name, which rebuilds egui’s glyph atlas and so belongs to opening rather than to drawing.
§Errors
A message to show the person, already translated.
Sourcefn document_mut(&mut self) -> Option<&mut Document>
fn document_mut(&mut self) -> Option<&mut Document>
The document, for saving and for undo. None while nothing is open.
Provided Methods§
Sourcefn reindex(&mut self)
fn reindex(&mut self)
The content tree was replaced under the document, by undo or redo. A view that derives anything from the tree rebuilds it here.
Sourcefn caret(&self) -> Option<Caret>
fn caret(&self) -> Option<Caret>
Where the caret is, for a view that has one, so that an undo can bring it back there.
Sourcefn restore_caret(&mut self, _caret: Caret)
fn restore_caret(&mut self, _caret: Caret)
Put the caret where an undo or a redo says it was, after
Self::reindex.
Draw the view’s own menus, after Edit: each a menu_button of its
own. A command chosen is kept by the view and applied when it next
draws its page, where the document and the editing state are.
Sourcefn presenting(&self) -> bool
fn presenting(&self) -> bool
Whether the view is showing the document full screen and nothing else, as a slideshow does: the shell takes its menu, its panels and its keys away until it is not.
Sourcefn find(&mut self, _query: &str) -> usize
fn find(&mut self, _query: &str) -> usize
Look for text in the document and keep what is found, to draw highlighted; an empty query forgets the search. Answers how many matches there are. Asked again whenever the query or the text changes, and the current match is kept if there are still that many.
Sourcefn can_replace(&self, _editing: &Editing) -> bool
fn can_replace(&self, _editing: &Editing) -> bool
Whether the search bar offers to replace: where the document can be changed now.
Sourcefn replace(
&mut self,
_with: &str,
_all: bool,
_editing: &mut Editing,
) -> Replaced
fn replace( &mut self, _with: &str, _all: bool, _editing: &mut Editing, ) -> Replaced
Replace the current match, or every match, with a text, as one step to undo, and answer how many were replaced and how many left alone.
Sourcefn show_match(&mut self, _index: usize)
fn show_match(&mut self, _index: usize)
Make one of the matches the current one, and bring it into view.
Sourcefn side(&mut self, _ui: &mut Ui) -> bool
fn side(&mut self, _ui: &mut Ui) -> bool
Draw the panel beside the document — an outline, a sheet list, a slide list — and answer whether there is one to draw.
Add the application’s own items to the View menu.
Add the application’s own items to the File menu, after saving: what the document can be written out as. Given the file the document was read from, which is where such a file is offered to go.
Sourcefn take_notice(&mut self) -> Option<Notice>
fn take_notice(&mut self) -> Option<Notice>
Something the view has to tell the person, for the bar at the foot of the window, once.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".