Crate egui_transition_animation

Crate egui_transition_animation 

Source
Expand description

This crate allows you to have animated transitions between multiple “pages” in egui.
You will mostly use the animated_pager function.

See the README for a video of the animations.

§Quickstart

use eframe::egui;
use egui_transition_animation::prelude::*;

#[derive(PartialEq, PartialOrd, Clone, Eq)]
enum Page {
    Page1,
    Page2,
    Page3,
}

let mut page = Page::Page1;

eframe::run_simple_native(
    "Egui transition animation example",
    Default::default(),
    move |ctx, _frame| {
        ctx.style_mut(|style| style.animation_time = 0.2);
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.horizontal(|ui| {
                ui.selectable_value(&mut page, Page::Page1, "Page 1");
                ui.selectable_value(&mut page, Page::Page2, "Page 2");
                ui.selectable_value(&mut page, Page::Page3, "Page 3");
            });

            animated_pager(
                ui,
                page.clone(),
                &TransitionStyle::horizontal(ui),
                egui::Id::new("pager"),
                |ui, page| match page {
                    Page::Page1 => ui.label("Hello from page 1"),
                    Page::Page2 => ui.heading("Hello from page 2"),
                    Page::Page3 => ui.monospace("Hello from page 3"),
                },
            );
        });
    },
).unwrap();

Modules§

prelude
Re-exports of the most commonly used types and functions.

Structs§

PagerRet
Return type of the animated_pager family of functions.
TransitionStyle
Defines the style of the transition animation used by animated_pager.

Enums§

TransitionType
Type of transition animation.

Functions§

animated_pager
Shows one of several possible pages with transition animation between them, automatically determining direction.
animated_pager_backward
Shows one of several possible pages with a backward transition animation.
animated_pager_forward
Shows one of several possible pages with a forward transition animation.
animated_pager_with_direction
Shows one of several possible pages with transition animation between them, with explicit direction control.
page_transition
Applies a page transition animation to the given UI contents.