Skip to main content

Viewer

Trait Viewer 

Source
pub trait Viewer {
    // 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 central(&mut self, ui: &mut Ui, zoom: f32);

    // Provided methods
    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 central(&mut self, ui: &mut Ui, zoom: f32)

Draw the document. The shell has already put a scroll area or a panel around whatever this needs.

Provided Methods§

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§