Skip to main content

View

Trait View 

Source
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§

Source

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.

Source

fn close(&mut self)

Forget the document.

Source

fn is_open(&self) -> bool

Whether a document is open.

Source

fn title(&self) -> Option<String>

What the document calls itself, for the window’s title.

Source

fn document_mut(&mut self) -> Option<&mut Document>

The document, for saving and for undo. None while nothing is open.

Source

fn central(&mut self, ui: &mut Ui, zoom: f32, editing: &mut Editing)

Draw the document. The shell has already put a scroll area or a panel around whatever this needs. The editing state says whether edit mode is on and takes the snapshot an edit records before it changes the tree.

Provided Methods§

Source

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.

Source

fn caret(&self) -> Option<Caret>

Where the caret is, for a view that has one, so that an undo can bring it back there.

Source

fn restore_caret(&mut self, _caret: Caret)

Put the caret where an undo or a redo says it was, after Self::reindex.

Source

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.

Source

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.

Source

fn show_match(&mut self, _index: usize)

Make one of the matches the current one, and bring it into view.

Source

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.

Source

fn view_menu(&mut self, _ui: &mut Ui)

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".

Implementors§