Skip to main content

Module sliders

Module sliders 

Source
Expand description

Sliders’ steps (ADR 0011). egui-pop’s sliders (egui_pop_core::slider) are egui widgets: they see their changes through a hook (Slider::on_change), and hook makes that hook run each finished change as the slider.change step of the application:

StepArgumentsDefault
slider.changeslider (the name given to hook), thumb (value, low, high), from, to, cause (drag, key, wheel, typed, reset, access)writes to

A change is finished at the end of its gesture: a drag’s release (from the value before the drag), a key, a wheel notch, a typed value, a reset. A before-hook vetoes it (the slider keeps or goes back to from) or redirects it (another to: snap, clamp); a run-hook gives the value to write (its result); an after-hook follows it. Every run publishes slider.change on the journal, so the value-change event is observed there. The frames of a drag are not steps: the slider follows the pointer, and the step decides at the release.

use egui_pop_api::sliders;
use egui_pop_core::slider::Slider;

fn exposure(ui: &mut egui::Ui, app: &egui_pop_api::AppHandle, ev: &mut f64) {
    ui.add(Slider::new(ev, "Exposure", -3.0..=4.0).on_change(sliders::hook(app, "exposure")));
}

Constants§

STEP_CHANGE
A slider’s value changes, at the end of a gesture.

Functions§

hook
A slider hook (Slider::on_change, RangeSlider::on_change) running each finished change as the slider.change step, the slider named slider in its arguments. A drag’s frames go through.