Skip to main content

Crate egui_pop_viewport

Crate egui_pop_viewport 

Source
Expand description

A generic image viewport for egui-pop: pan and zoom measured in physical pixels, tiles from an asynchronous source, overlays in image coordinates.

Experimental: may change in any release (docs/stability.md).
  • view: the view model (zoom in physical pixels per image pixel, the zoom ladder, fit) and view::Mapping, the one mapping between image and screen that drawing, hit tests and the readout share;
  • gestures: the gestures as data, remappable per profile;
  • widget: the Viewport widget and the Signals it emits;
  • cursor: what the active tool shows under the pointer (system cursors, tool cursors drawn at the window’s scale, an application’s bitmaps, a brush outline that follows the zoom);
  • loupe: the pixels under the pointer, magnified, with a grid and their values;
  • display: the display target of each window and the display transform hook where the application plugs its colour management;
  • source: the TileSource an application implements (asynchronous, live) and the sink it delivers to;
  • tiles: the tile cache (proxy then exact, cancellation, a texture budget, tiles within the device’s largest texture);
  • gpu (feature wgpu): scene tiles as half-float textures, the display transform in a shader;
  • device (feature wgpu): device tiles, a texture or a storage buffer already on the render device, drawn with no copy;
  • image_surface (feature wayland): the image on a surface of its own, tagged with a wide encoding through the Wayland compositor, below an sRGB interface;
  • demo: a procedural source for galleries and examples;
  • overlay: overlays in image coordinates and the handle kit;
  • thumbnail and histogram: thumbnails in a virtualised grid and a histogram, from images and bins the application supplies (with clipping markers, and a drag handed back to the application);
  • curve: a curve editor (points added, moved and deleted, a spline the application supplies, a histogram behind, the value picked in the image);
  • wheel: colour wheels (lift, gamma, gain) and a hue and saturation picker, each with a luminance slider;
  • navigator: a zoom control and a navigator (a minimap), sharing the viewport’s state;
  • graph: a node graph editor over an application’s graph (typed ports, wires, groups, an overview and a detail view with inline sliders), every edit handed back as a request, with its minimap;
  • change: what the image tools share, the change they propose and the hook that sees it (a veto, a redirect), and the form their values take in a step;
  • hooks: the application’s way into each step (veto, redirect, replace, extend), traced;
  • debug: the viewport collector of the debug bridge;
  • mounts: what its components need and what its overlays offer (the mount contract, ADR 0013);
  • strings: the text it shows, translatable;
  • tokens: the component tokens it draws with.

Layer: a component crate on top of egui-pop-core (beside egui-pop-api, see ADR 0001). Nothing here knows about raw files, colour science or an engine: an application supplies the pixels.

use egui_pop_viewport::{View, Viewport, ViewportState};

fn ui(ui: &mut egui::Ui, state: &mut ViewportState, view: &mut View) {
    let out = Viewport::new("main").image_size([6000, 4000]).show(ui, state, view);
    for signal in out.signals {
        // Record the view, keep a gesture in one undo step...
        let _ = signal;
    }
}

Re-exports§

pub use hooks::Hooks;
pub use hooks::Verdict;
pub use hooks::ViewChange;
pub use widget::Compare;
pub use widget::Signal;
pub use widget::Viewport;
pub use widget::ViewportOutput;
pub use widget::ViewportState;

Modules§

change
What the image tools share: the change a tool proposes, the hook that sees it before it is written, and the value’s form in a step’s arguments.
cursor
Cursors over the viewport: what the active tool shows under the pointer, resolved each time the situation changes (the tool, the keys held, a drag, a handle under the pointer) and drawn crisp at the window’s scale.
curve
A curve editor: control points the user adds, moves and deletes, through a spline the application supplies (Spline), over an optional histogram, with the targeted adjustment of photo editors (a value picked under the pointer in the image selects or adds the point to drag).
debug
The viewports seen by egui-pop’s debug bridge: register collector and its viewport snapshot lists every viewport drawn (view, mapping, hooks set, what the hooks decided, the last signals, the tiles and the bytes their uploads copied, tiles.uploads, and the device tiles the render device takes, tiles.device); its set_view action moves a viewport as a command would (through its before_view hook, on the next frame).
demo
A procedural tile source, for galleries, examples and benchmarks: an image of any size computed on worker threads, scene-referred (linear floats), with a parameter that changes the whole image.
device
Device tiles (feature wgpu): a tile that already lives on the render device, handed to the viewport with no copy through the CPU.
display
The display transform: the last step from the source’s pixels to the window, where the application plugs in its colour management.
gestures
The viewport’s gestures, as data so an input profile can remap them. The pointer’s come from the pointer profile in force (egui_pop_core::pointer, docs/pointer-gestures.md): what the wheel, a scroll, a pinch, each click, double click and drag does with each set of modifiers (ViewGestures); set_gestures sets them outright. They follow the shared interaction grammar:
gpu
The GPU path (feature wgpu): scene tiles as half-float textures, drawn by an egui_wgpu paint callback whose shader runs the display transform’s Stage.
graph
A node graph editor over an application’s graph, drawn in egui’s Scene, its pan and zoom driven by the pointer profile.
histogram
A histogram drawn from bins the application computed (the scopes’ computation stays with the application): one filled curve per channel, linear or logarithmic, with clipping markers and a drag handed back to the application.
hooks
The application’s way into each step of the viewport’s lifecycle.
image_surface
The image’s own surface (feature wayland): on a Wayland compositor with colour management, the viewport draws its image into a surface of its own, below the window, that the compositor is told the encoding of; egui’s interface stays sRGB on the window’s surface (docs/wayland-colour.md).
loupe
The loupe: the pixels under the pointer, magnified, in a square that follows it.
mounts
What this crate’s components need, and what its overlays offer, in the mount contract’s terms (ADR 0013): docs/hosts.md and AppHandle::where_can are made from these.
navigation
One navigation model for every canvas larger than its view (the node graph, the image viewport, plots): what docs/design/navigation.md proposes, in one place so each canvas behaves the same.
navigator
The zoom control and the navigator (a minimap): two views of a viewport’s View, sharing its ViewportState. What they change goes through the viewport’s before_view hook, like the viewport’s own gestures (ViewportState::propose), and comes out as the viewport’s Signal::View with the next frame.
overlay
Overlays in image coordinates, edited through one handle kit.
source
Where the pixels come from: a TileSource the application implements, asynchronous and live.
strings
The strings the viewport shows, by key with English fallbacks, translated through the provider installed with egui_pop_core::strings::install (see that module for the key and placeholder conventions).
thumbnail
Thumbnails and a virtualised grid of them, from images the application supplies. The drawing lives in the egui layer (egui_pop_core::thumbnail), where the file picker of the application API uses it too (ADR 0001).
tiles
The tile cache: what to ask the source for, what arrived, what is drawn, and what to forget when over budget.
tokens
The viewport’s component tokens (viewport.* in the theme files), each an alias of a system token.
view
The view model: what part of the image is shown, at what zoom, and the one mapping between image and screen that drawing, hit testing and the pixel readout all use.
wheel
Colour wheels: the lift, gamma and gain wheels of colour grading, and a hue and saturation picker, each with a luminance slider (egui-pop’s slider, egui_pop_core::slider).
widget
The viewport widget: draws a view of an image and turns gestures into changes of the View, reported as Signals.

Structs§

Mapping
The mapping between image pixels, physical pixels and points for one frame of one viewport in one window. Build it with Mapping::new; every conversion of the viewport (drawing, tiles, hit tests, the readout) goes through it.
View
What is shown: a zoom and the image point at the centre of the view. The application owns it (a window, a document); the viewport changes it through gestures and says so with signals.

Enums§

Cause
What made the view change (shared with every image canvas, egui_pop_core::pointer::view). What made a view change.
Phase
Where a change stands in its gesture (shared with every image canvas, egui_pop_core::pointer::view). Where a change stands in its gesture.
Zoom
How the zoom is chosen.