mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 20:25:06 +00:00
wip
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
//! [`AdjustmentKind`] and the Adjustments panel: a grid of icon buttons, one per adjustment.
|
||||
|
||||
use craft_behavior::IconId;
|
||||
use craft_ui::contract::{NoValue, Outcome, Pattern};
|
||||
use craft_ui::runtime::env::Label;
|
||||
use egui::{Response, Ui};
|
||||
|
||||
use super::AdjustWords;
|
||||
|
||||
/// One of the adjustments the Adjustments panel offers.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
#[non_exhaustive]
|
||||
pub enum AdjustmentKind {
|
||||
/// Brightness/Contrast.
|
||||
BrightnessContrast,
|
||||
/// Levels.
|
||||
Levels,
|
||||
/// Curves.
|
||||
Curves,
|
||||
/// Exposure.
|
||||
Exposure,
|
||||
/// Vibrance.
|
||||
Vibrance,
|
||||
/// Hue/Saturation.
|
||||
HueSaturation,
|
||||
/// Color Balance.
|
||||
ColorBalance,
|
||||
/// Black & White.
|
||||
BlackWhite,
|
||||
/// Photo Filter.
|
||||
PhotoFilter,
|
||||
/// Channel Mixer.
|
||||
ChannelMixer,
|
||||
/// Invert.
|
||||
Invert,
|
||||
/// Posterize.
|
||||
Posterize,
|
||||
/// Threshold.
|
||||
Threshold,
|
||||
/// Gradient Map.
|
||||
GradientMap,
|
||||
/// Selective Color.
|
||||
SelectiveColor,
|
||||
/// Color Lookup.
|
||||
ColorLookup,
|
||||
}
|
||||
|
||||
impl AdjustmentKind {
|
||||
/// Every kind, in the panel's order.
|
||||
pub const ALL: [AdjustmentKind; 16] = [
|
||||
AdjustmentKind::BrightnessContrast,
|
||||
AdjustmentKind::Levels,
|
||||
AdjustmentKind::Curves,
|
||||
AdjustmentKind::Exposure,
|
||||
AdjustmentKind::Vibrance,
|
||||
AdjustmentKind::HueSaturation,
|
||||
AdjustmentKind::ColorBalance,
|
||||
AdjustmentKind::BlackWhite,
|
||||
AdjustmentKind::PhotoFilter,
|
||||
AdjustmentKind::ChannelMixer,
|
||||
AdjustmentKind::Invert,
|
||||
AdjustmentKind::Posterize,
|
||||
AdjustmentKind::Threshold,
|
||||
AdjustmentKind::GradientMap,
|
||||
AdjustmentKind::SelectiveColor,
|
||||
AdjustmentKind::ColorLookup,
|
||||
];
|
||||
|
||||
/// The kind's key (`"brightnessContrast"`).
|
||||
pub fn key(self) -> &'static str {
|
||||
let _ = self;
|
||||
todo!("pn.C44")
|
||||
}
|
||||
|
||||
/// The kind's icon from the catalog.
|
||||
pub fn icon(self) -> IconId {
|
||||
let _ = self;
|
||||
todo!("pn.C44")
|
||||
}
|
||||
|
||||
/// The kind's title.
|
||||
pub fn label(self, words: &AdjustWords) -> Label {
|
||||
let _ = (self, words);
|
||||
todo!("pn.C44")
|
||||
}
|
||||
}
|
||||
|
||||
/// What the Adjustments panel reports.
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
pub struct AdjustmentsPanelOutput {
|
||||
/// The panel's response.
|
||||
pub response: Response,
|
||||
/// The kind the user picked this pass.
|
||||
pub picked: Option<AdjustmentKind>,
|
||||
}
|
||||
|
||||
impl Outcome for AdjustmentsPanelOutput {
|
||||
type Value = NoValue;
|
||||
|
||||
fn response(&self) -> &Response {
|
||||
&self.response
|
||||
}
|
||||
}
|
||||
|
||||
/// A grid of icon buttons in one roving group; the app picks which kinds it offers (default all).
|
||||
#[must_use = "show the panel with `show`"]
|
||||
#[derive(Pattern)]
|
||||
#[allow(dead_code)] // P3(panels-w11): pn.C44
|
||||
pub struct AdjustmentsPanel<'a> {
|
||||
label: Label,
|
||||
kinds: &'a [AdjustmentKind],
|
||||
}
|
||||
|
||||
impl<'a> AdjustmentsPanel<'a> {
|
||||
/// A panel named `label` offering every kind.
|
||||
pub fn new(label: impl Into<Label>) -> Self {
|
||||
let _ = label.into();
|
||||
todo!("pn.C44")
|
||||
}
|
||||
|
||||
/// Offers only `kinds`.
|
||||
#[must_use]
|
||||
pub fn kinds(mut self, kinds: &'a [AdjustmentKind]) -> Self {
|
||||
let _ = (&mut self, kinds);
|
||||
todo!("pn.C44")
|
||||
}
|
||||
|
||||
/// Draws the grid and reports the picked kind.
|
||||
pub fn show(self, ui: &mut Ui) -> AdjustmentsPanelOutput {
|
||||
let _ = (self, ui);
|
||||
todo!("pn.C44")
|
||||
}
|
||||
}
|
||||
@@ -145,5 +145,15 @@ craft_ui::words! {
|
||||
absolute: "adjust.absolute" = "Absolute";
|
||||
/// The Relative and Absolute radios' group name (AccessKit).
|
||||
relative_absolute: "adjust.relativeAbsolute" = "Relative / Absolute";
|
||||
|
||||
// The Adjustments panel's titles the editors above lack.
|
||||
brightness_contrast: "adjust.brightnessContrast" = "Brightness/Contrast";
|
||||
color_balance: "adjust.colorBalance" = "Color Balance";
|
||||
photo_filter: "adjust.photoFilter" = "Photo Filter";
|
||||
invert: "adjust.invert" = "Invert";
|
||||
posterize: "adjust.posterize" = "Posterize";
|
||||
threshold: "adjust.threshold" = "Threshold";
|
||||
gradient_map: "adjust.gradientMap" = "Gradient Map";
|
||||
color_lookup: "adjust.colorLookup" = "Color Lookup";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ mod context;
|
||||
mod curves_panel;
|
||||
mod hosted;
|
||||
mod hue_saturation;
|
||||
mod kinds;
|
||||
mod labels;
|
||||
mod levels_editor;
|
||||
mod levels_panel;
|
||||
@@ -36,6 +37,7 @@ pub use context::{AdjustContext, ToneChannel, ToneChannelCommands, ToneChannels,
|
||||
pub use curves_panel::{CurvesMode, CurvesPanel, CurvesPanelOutput, ToneCurves};
|
||||
pub use hosted::{AdjustDialogCx, EditPhase, HostedAdjustDialog};
|
||||
pub use hue_saturation::{HueRangeValue, HueSaturation, HueSaturationEditor, HueSaturationOutput};
|
||||
pub use kinds::{AdjustmentKind, AdjustmentsPanel, AdjustmentsPanelOutput};
|
||||
pub use labels::AdjustWords;
|
||||
pub use levels_editor::{Levels, LevelsClip, LevelsEditor, LevelsEditorOutput, LevelsWords};
|
||||
pub use levels_panel::{LevelsPanel, LevelsPanelOutput};
|
||||
|
||||
Reference in New Issue
Block a user