Let an operation say what it is about, so the panel can group without naming
Tool tabs need a taxonomy, and the taxonomy was the problem: a table in `ui/` mapping operation to tab breaks FR-DEV-3a, and a `group:` field risks what `ui-refinement.md` condemned `starts-group` for — the core deciding where the panel draws things. `Attribute` threads the needle. It says what an operation *is* — tone, colour, detail, optics, geometry, effect — which is the same category as `ParamKind` and squarely on the core's side of ARCH §4.3a's line. What is drawn, where it sits and whether it is visible stay the frontend's. There is no attribute for "the third tab", the enum's order is declaration order rather than screen order, and a frontend may render these as tabs, as headings, or ignore them. The payoff is that a tab strip can be *derived*: the groups are the attributes present in the capability list, so the interface names no operation and needs no table to keep in step. An operation joins the right group by declaring what it is, which is the one thing its author is well placed to say. Plural, because the tone curve is genuinely both — an RGB curve is tonal and the per-channel curves are chromatic, and filing it under one would hide it from half the people looking for it. Required and non-empty, enforced in `build.rs`, and the failure was checked by removing the line rather than assumed. An operation with no attribute is invisible to a panel that groups by them; a build that stops costs ten seconds, a control nobody can find costs more. The vocabulary is closed for the same reason: a typo would otherwise invent a category holding exactly one operation, which looks like a deliberate one until somebody counts. Six tests over the real chain, including the hand-written operations that `build.rs` never sees and so cannot check.
This commit is contained in:
@@ -452,18 +452,123 @@ impl ParamDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
/// What an operation *is about*.
|
||||
///
|
||||
/// A statement of the operation's nature, in the same category as
|
||||
/// [`ParamKind`]: the core saying what a thing is, not where it is drawn. A
|
||||
/// frontend may render these as tabs, as section headings, as a filter, or
|
||||
/// ignore them entirely — that choice is composition and belongs to whoever
|
||||
/// knows the window (ARCH §4.3a).
|
||||
///
|
||||
/// # Why the core may say this at all
|
||||
///
|
||||
/// The line §4.3a draws is between *what a thing is* and *what is drawn,
|
||||
/// where it sits, how wide it is, and whether it is visible*. "White balance
|
||||
/// is a colour operation" is the first kind. It is also knowledge the core is
|
||||
/// uniquely placed to hold: the person adding an operation knows what it does,
|
||||
/// and a frontend that had to work it out would be doing so by matching on the
|
||||
/// operation's name — which is the one thing `ui/` may never do (FR-DEV-3a).
|
||||
///
|
||||
/// What this deliberately is **not** is a tab name. There is no `Attribute`
|
||||
/// for "the third tab", the order below is declaration order rather than
|
||||
/// screen order, and an operation carrying two attributes appears wherever the
|
||||
/// frontend decides that means — twice, once, or nowhere.
|
||||
///
|
||||
/// # Plural on purpose
|
||||
///
|
||||
/// An operation may carry several. The tone curve is genuinely both tonal and
|
||||
/// chromatic — it has an RGB curve and per-channel curves — and forcing it to
|
||||
/// pick one would file it away from half the people looking for it.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub enum Attribute {
|
||||
/// Lightness and its distribution: exposure, contrast, the recovery
|
||||
/// controls, the tone curve.
|
||||
Tone,
|
||||
/// Hue and saturation: white balance, the colour mixer, vibrance.
|
||||
Colour,
|
||||
/// Acutance and noise — what the image is made of at the pixel level.
|
||||
/// Sharpening, noise reduction, texture, clarity.
|
||||
Detail,
|
||||
/// Corrections for the lens that took the photograph: distortion,
|
||||
/// chromatic aberration, vignetting.
|
||||
Optics,
|
||||
/// The shape of the frame: crop, straighten, rotation, flips.
|
||||
Geometry,
|
||||
/// Applied rather than corrected — a look, not a fix.
|
||||
Effect,
|
||||
}
|
||||
|
||||
impl Attribute {
|
||||
/// Every attribute, in declaration order.
|
||||
///
|
||||
/// Declaration order is roughly the order a photographer works in, which
|
||||
/// makes it a reasonable *default* for a frontend that wants one. It is
|
||||
/// not a screen order: nothing here obliges a frontend to show them all,
|
||||
/// show them in this sequence, or show them at all.
|
||||
pub const ALL: [Attribute; 6] = [
|
||||
Attribute::Tone,
|
||||
Attribute::Colour,
|
||||
Attribute::Detail,
|
||||
Attribute::Optics,
|
||||
Attribute::Geometry,
|
||||
Attribute::Effect,
|
||||
];
|
||||
|
||||
/// The localisation key naming this concept.
|
||||
///
|
||||
/// Naming the concept, the way an operation's own `label` names the
|
||||
/// operation. What a frontend *does* with the name — a tab, a heading,
|
||||
/// nothing — is still its own affair.
|
||||
pub fn label(self) -> LocalizedKey {
|
||||
LocalizedKey(match self {
|
||||
Self::Tone => "attr.tone",
|
||||
Self::Colour => "attr.colour",
|
||||
Self::Detail => "attr.detail",
|
||||
Self::Optics => "attr.optics",
|
||||
Self::Geometry => "attr.geometry",
|
||||
Self::Effect => "attr.effect",
|
||||
})
|
||||
}
|
||||
|
||||
/// Parse the name used in `ops/<id>.yaml`.
|
||||
pub fn from_name(name: &str) -> Option<Self> {
|
||||
Some(match name {
|
||||
"tone" => Self::Tone,
|
||||
"colour" => Self::Colour,
|
||||
"detail" => Self::Detail,
|
||||
"optics" => Self::Optics,
|
||||
"geometry" => Self::Geometry,
|
||||
"effect" => Self::Effect,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// The static description of an operation.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct OpDescriptor {
|
||||
pub id: OpId,
|
||||
pub label: LocalizedKey,
|
||||
pub params: &'static [ParamDescriptor],
|
||||
/// What this operation is about (ARCH §4.3a).
|
||||
///
|
||||
/// **Never empty**, and `build.rs` refuses to generate an operation that
|
||||
/// declares none. An operation with no attribute would be invisible to a
|
||||
/// frontend that filters by them, and a control that silently does not
|
||||
/// exist is a worse failure than a build that stops — particularly when
|
||||
/// the cause would be a missing line in a YAML file nobody looked at.
|
||||
pub attributes: &'static [Attribute],
|
||||
}
|
||||
|
||||
impl OpDescriptor {
|
||||
pub fn param(&self, id: ParamId) -> Option<&ParamDescriptor> {
|
||||
self.params.iter().find(|p| p.id == id)
|
||||
}
|
||||
|
||||
/// Whether this operation is about `attribute`.
|
||||
pub fn has(&self, attribute: Attribute) -> bool {
|
||||
self.attributes.contains(&attribute)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -41,10 +41,8 @@
|
||||
use std::f32::consts::PI;
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use crate::descriptor::{
|
||||
LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Presentation, Scale, Unit,
|
||||
WidgetDemand, WidgetKind,
|
||||
};
|
||||
use crate::descriptor::{Attribute, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Presentation, Scale, Unit,
|
||||
WidgetDemand, WidgetKind,};
|
||||
use crate::operation::Affects;
|
||||
|
||||
pub const ID: OpId = OpId("framing");
|
||||
@@ -74,6 +72,9 @@ static FRAMING_PARAMS: [ParamId; 8] = [
|
||||
];
|
||||
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
// The shape of the frame, and the only operation that changes the
|
||||
// output's dimensions.
|
||||
attributes: &[Attribute::Geometry],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.framing"),
|
||||
params: &[
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
//! so reordering the pipeline needs no code change.
|
||||
|
||||
use crate::descriptor::{
|
||||
Attribute,
|
||||
Facet, LocalizedKey, OpDescriptor, OpId, ParamId, ParamKind, Presentation,
|
||||
};
|
||||
use crate::framing::{CropRect, Framing};
|
||||
@@ -37,6 +38,17 @@ pub struct OpCapability {
|
||||
/// the named widget may ignore this and render sliders — the parameters
|
||||
/// are ordinary scalars either way, so nothing becomes unreachable.
|
||||
pub presentation: Option<Presentation>,
|
||||
/// TRACES: FR-DEV-3a | FR-DEV-3c
|
||||
/// What this operation is about.
|
||||
///
|
||||
/// **The whole point is that a panel can group by these without knowing
|
||||
/// what any operation is.** A tab strip built from the attributes present
|
||||
/// in this list names no operation and needs no table mapping one to the
|
||||
/// other, so a new operation joins the right group by declaring what it
|
||||
/// is — which is the only thing its author is well placed to say.
|
||||
///
|
||||
/// Never empty; `build.rs` refuses an operation that declares none.
|
||||
pub attributes: &'static [Attribute],
|
||||
}
|
||||
|
||||
/// TRACES: FR-DEV-3a | FR-DEV-3b
|
||||
@@ -182,6 +194,7 @@ impl EditGraph {
|
||||
})
|
||||
.collect(),
|
||||
presentation: op.presentation(),
|
||||
attributes: desc.attributes,
|
||||
}
|
||||
});
|
||||
|
||||
@@ -210,6 +223,7 @@ impl EditGraph {
|
||||
// sliders for framing *without naming framing* — see
|
||||
// `Framing::presentation`.
|
||||
presentation: self.framing.presentation(),
|
||||
attributes: desc.attributes,
|
||||
};
|
||||
|
||||
ops.chain(std::iter::once(framing)).collect()
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use crate::descriptor::{OpDescriptor, ParamId};
|
||||
use crate::descriptor::{Attribute, OpDescriptor, ParamId};
|
||||
use crate::operation::{Helper, Uniform};
|
||||
|
||||
/// A coordinate-domain operation, applied before the source is sampled.
|
||||
@@ -211,11 +211,13 @@ mod tests {
|
||||
id: OpId("warp_a"),
|
||||
label: LocalizedKey("a"),
|
||||
params: &[ParamDescriptor::amount("amount", "a.amount")],
|
||||
attributes: &[Attribute::Tone],
|
||||
};
|
||||
static DESC_B: OpDescriptor = OpDescriptor {
|
||||
id: OpId("warp_b"),
|
||||
label: LocalizedKey("b"),
|
||||
params: &[ParamDescriptor::amount("amount", "b.amount")],
|
||||
attributes: &[Attribute::Tone],
|
||||
};
|
||||
|
||||
struct Fake {
|
||||
|
||||
@@ -43,7 +43,7 @@ pub mod preset;
|
||||
pub mod sidecar;
|
||||
|
||||
pub use descriptor::{
|
||||
Facet, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, ParamKind, Presentation,
|
||||
Attribute, Facet, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, ParamKind, Presentation,
|
||||
Scale, Unit, WidgetDemand, WidgetKind,
|
||||
};
|
||||
pub use framing::{CropRect, Framing};
|
||||
|
||||
@@ -521,6 +521,7 @@ impl MaskLayer {
|
||||
})
|
||||
.collect(),
|
||||
presentation: op.presentation(),
|
||||
attributes: desc.attributes,
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::fmt::Write as _;
|
||||
|
||||
use dr_types::{ColourSpace, Transfer};
|
||||
|
||||
use crate::descriptor::{OpDescriptor, ParamId, Presentation};
|
||||
use crate::descriptor::{Attribute, OpDescriptor, ParamId, Presentation};
|
||||
use crate::framing::{Framing, FRAMING_UNIFORM_FIELDS};
|
||||
use crate::mask::MaskStack;
|
||||
|
||||
@@ -720,11 +720,13 @@ mod tests {
|
||||
id: OpId("op_a"),
|
||||
label: LocalizedKey("a"),
|
||||
params: &[ParamDescriptor::amount("amount", "a.amount")],
|
||||
attributes: &[Attribute::Tone],
|
||||
};
|
||||
static DESC_B: OpDescriptor = OpDescriptor {
|
||||
id: OpId("op_b"),
|
||||
label: LocalizedKey("b"),
|
||||
params: &[ParamDescriptor::amount("amount", "b.amount")],
|
||||
attributes: &[Attribute::Tone],
|
||||
};
|
||||
|
||||
struct Fake {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
//! least to perceived sharpness. Scaling all three about a virtual reference
|
||||
//! would soften the image even when the correction is right.
|
||||
|
||||
use crate::descriptor::{LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Scale, Unit};
|
||||
use crate::descriptor::{Attribute, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Scale, Unit};
|
||||
use crate::lens::Warp;
|
||||
use crate::operation::{Helper, Uniform};
|
||||
|
||||
@@ -48,6 +48,7 @@ pub const BLUE: ParamId = ParamId("blue");
|
||||
const MAX_SCALE: f32 = 0.005;
|
||||
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
attributes: &[Attribute::Optics],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.aberration"),
|
||||
params: &[
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
//! adjusted, each one's share depends on what the other is set to, so turning
|
||||
//! up one colour's saturation quietly weakened its neighbour's hue shift.
|
||||
|
||||
use crate::descriptor::{Facet, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId};
|
||||
use crate::descriptor::{Attribute, Facet, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId};
|
||||
use crate::operation::{Helper, Operation, Uniform};
|
||||
use crate::ops::helpers;
|
||||
|
||||
@@ -174,6 +174,7 @@ macro_rules! band_params {
|
||||
// cannot be read out of `BANDS` here. `facets_match_their_bands` below is
|
||||
// what keeps them from drifting.
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
attributes: &[Attribute::Colour],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.colour_mixer"),
|
||||
params: band_params![
|
||||
|
||||
@@ -31,10 +31,8 @@
|
||||
//! filter constrains the tangents so the interpolant is monotone wherever the
|
||||
//! data is, which is exactly the guarantee a tone curve needs.
|
||||
|
||||
use crate::descriptor::{
|
||||
LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Presentation, Scale, Unit,
|
||||
WidgetDemand, WidgetKind,
|
||||
};
|
||||
use crate::descriptor::{Attribute, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Presentation, Scale, Unit,
|
||||
WidgetDemand, WidgetKind,};
|
||||
use crate::operation::{Helper, Operation, Uniform};
|
||||
use crate::ops::helpers;
|
||||
|
||||
@@ -80,6 +78,10 @@ const fn coord(id: &'static str, label: &'static str, default: f32) -> ParamDesc
|
||||
}
|
||||
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
// Both, and this is the case the plural exists for: an RGB curve is
|
||||
// tonal and the per-channel curves are chromatic. Filing it under one
|
||||
// would hide it from half the people looking for it.
|
||||
attributes: &[Attribute::Tone, Attribute::Colour],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.tone_curve"),
|
||||
// Defaults lie on y = x, so a fresh curve is the identity and the
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//! profile is a "make the horizon straight" task, which one term does well.
|
||||
//! The full triple is reachable by loading a profile.
|
||||
|
||||
use crate::descriptor::{LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Scale, Unit};
|
||||
use crate::descriptor::{Attribute, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId, Scale, Unit};
|
||||
use crate::lens::Warp;
|
||||
use crate::operation::{Helper, Uniform};
|
||||
|
||||
@@ -34,6 +34,7 @@ pub const ID: OpId = OpId("distortion");
|
||||
pub const AMOUNT: ParamId = ParamId("amount");
|
||||
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
attributes: &[Attribute::Optics],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.distortion"),
|
||||
// ±100 maps to a ±0.25 cubic coefficient. That covers an uncorrected
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
//! stages: a corner recovered by two stops has to be recovered while the
|
||||
//! highlight headroom to hold it still exists (ARCH §5.2).
|
||||
|
||||
use crate::descriptor::{LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId};
|
||||
use crate::descriptor::{Attribute, LocalizedKey, OpDescriptor, OpId, ParamDescriptor, ParamId};
|
||||
use crate::operation::{Helper, Operation, Uniform};
|
||||
|
||||
pub const ID: OpId = OpId("vignetting");
|
||||
@@ -46,6 +46,10 @@ pub const AMOUNT: ParamId = ParamId("amount");
|
||||
const MAX_K1: f32 = -0.5;
|
||||
|
||||
static DESCRIPTOR: OpDescriptor = OpDescriptor {
|
||||
// Optics rather than effect: this carries lens-profile coefficients
|
||||
// and corrects what the lens did. A *creative* vignette is a different
|
||||
// operation that does not exist yet, and would be `Effect`.
|
||||
attributes: &[Attribute::Optics],
|
||||
id: ID,
|
||||
label: LocalizedKey("op.vignetting"),
|
||||
// Bidirectional deliberately. Negative values *add* falloff, which is a
|
||||
|
||||
Reference in New Issue
Block a user