Expand description
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.
- Channels: each
Channelhas its bins (any scale; they are normalised together) and its colour. - Clipping:
Histogram::clippinglights a marker in a bottom corner when shadows or highlights are clipped (the fractions the application measured), in thehistogram.clip-*colours. - Drag:
Histogram::draggablemakes the histogram a control, as in darktable where dragging the histogram drags the exposure. The widget owns no value: it hands the gesture back asChanges of aDrag(where the gesture began, and how far it moved, in widths of the histogram). Ctrl (Cmd) is ten times finer, Shift ten times coarser; Escape gives the gesture up. When focused, the left and right arrows move by a step. - Edit area: a draggable histogram registers as an edit area
(
egui_pop_core::areas): the framework draws its grip at rest on its right edge, and a hover card naming what the drag writes (Histogram::edits: “Exposure +0.30 EV”); a histogram that is not draggable registers as a display area, without a grip. Inside a panel whose state is not current the drag is inert: no grip, no drag, and a drag under way is given up.
The changes in HistogramOutput::changes say how far the gesture
has moved so far, from from to to: applying to.delta - from.delta to the application’s value each time
(HistogramOutput::moved) keeps it in step, including when a hook
vetoes or redirects the gesture at its end, or when Escape gives it
up (a change back to 0 comes then).
The on_change hook sees the drag’s frames
(done: false), its end once more from 0 (done: true), and each
key; egui-pop-imaging runs the finished ones as the
histogram.drag step of an application.
use egui_pop_viewport::histogram::{Channel, Clipping, Histogram};
fn ui(ui: &mut egui::Ui, luma: &[f32], exposure: &mut f64) {
let out = Histogram::new([Channel::new("Luminance", luma, egui::Color32::GRAY)])
.log(true)
.clipping(Clipping { shadows: 0.0, highlights: 0.004 })
.draggable(true)
.show(ui);
// Four stops per width of the histogram.
*exposure += f64::from(out.moved()) * 4.0;
}Structs§
- Channel
- One channel: its bins (any scale; they are normalised) and colour.
- Clipping
- What is clipped, as the application measured it: the fraction of pixels (0 to 1) at or below black, and at or above white.
- Drag
- A drag on the histogram: where it began (a fraction of the width, 0
on the left;
Nonefor keys and assistive actions) and how far it has moved, in widths of the histogram (positive to the right). - Histogram
- The histogram widget.
- Histogram
Output - What the histogram did in a frame.
- Histogram
Tokens - The histogram’s colours, from the theme (
histogram.*).
Functions§
- heights
- The heights (0..1) of a channel’s bins, normalised by
max.