pub struct Number {
pub label: String,
pub value: f64,
pub unit: Unit,
pub range: Option<[f64; 2]>,
pub step: f64,
pub text: Option<String>,
pub error: Option<String>,
pub handle: Option<Track>,
}Expand description
A number field — of a plain number, or of one that may also be given
as a formula of the part’s parameters (see Number::text).
Fields§
§label: String§value: f64The value — of a formula, what it evaluates to now.
unit: Unit§range: Option<[f64; 2]>What a slider offers, not what is valid.
step: f64§text: Option<String>For a field that takes formulas, the value as given — a plain
number or a formula — shown and edited in place of value, and sent
back as super::Value::Text.
error: Option<String>Why its formula does not evaluate, if it does not.
handle: Option<Track>The handle to drag it by, drawn by the editor.
Implementations§
Source§impl Number
impl Number
pub fn new(label: impl Into<String>, value: f64, unit: Unit) -> Self
Sourcepub fn numeric(
input: &NumericInput,
label: impl Into<String>,
reader: &Reader<'_>,
unit: Unit,
) -> Self
pub fn numeric( input: &NumericInput, label: impl Into<String>, reader: &Reader<'_>, unit: Unit, ) -> Self
A number field of input, labelled label, showing what it comes
to as reader reads the parameters — or, where it does not
evaluate, why.
A value that follows a formula is neither slid nor dragged: moving it
would have to either break the formula or move the parameters it
reads, and neither is what a drag means. So such a field has no
slider and no handle (Number::range and Number::handle keep
none); to drag the value again, type a number.
Sourcepub fn follows_formula(&self) -> bool
pub fn follows_formula(&self) -> bool
Whether its value follows a formula.