pub trait View {
Show 14 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 presenting(&self) -> bool { ... }
fn find(&mut self, _query: &str) -> usize { ... }
fn show_match(&mut self, _index: usize) { ... }
fn side(&mut self, _ui: &mut Ui) -> bool { ... }
fn view_menu(&mut self, _ui: &mut Ui) { ... }
}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.
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 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.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".