This commit is contained in:
aiongg
2026-11-14 02:24:52 +00:00
parent 716a33764f
commit 73679e06ce
19 changed files with 1067 additions and 7 deletions
+9
View File
@@ -0,0 +1,9 @@
//! The cell order of a warp: one order for the preview and the render, without egui or kurbo.
/// The order the cells of a warp mesh row `row` are drawn in: turned-over cells last, then by increasing displacement,
/// a non-finite vertex under, a stable sort. `pos` are the displaced points and `rest` the points at rest, as
/// `[x, y]` pairs.
pub fn cell_order(pos: &[[f64; 2]], rest: &[[f64; 2]], row: usize) -> Vec<usize> {
let _ = (pos, rest, row);
todo!("tl.T13")
}
+2
View File
@@ -3,7 +3,9 @@
//! [`scopes`], [`selection`], [`trace`] and [`layer_style`] work without egui and build on every target. The widgets are behind the `ui` feature.
#![warn(missing_docs)]
pub mod fold_order;
pub mod layer_style;
pub mod raw;
pub mod scopes;
pub mod selection;
pub mod trace;
+144
View File
@@ -0,0 +1,144 @@
//! The RAW Develop settings: the typed session of the Camera Raw filter, without egui.
use serde::{Deserialize, Serialize};
/// One colour grading wheel.
#[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)]
#[serde(default)]
pub struct GradeWheel {
/// Degrees 0..360.
pub hue: f32,
/// 0..=100.
pub sat: f32,
/// -100..=100.
pub lum: f32,
}
/// What the vignette protects.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum VignetteStyle {
/// Highlight priority.
#[default]
HighlightPriority,
/// Colour priority.
ColorPriority,
/// Paint overlay.
PaintOverlay,
}
/// The settings the RAW Develop workspace edits and the develop reads: the field set and serde names of PhotoCraft's
/// `CameraRaw`, without its three develop inputs (`seed`, `pixel_scale`, `encoding_gamma`).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", default)]
#[non_exhaustive]
pub struct RawDevelopSettings {
// Basic
/// The temperature.
pub temperature: f32,
/// The tint.
pub tint: f32,
/// The exposure.
pub exposure: f32,
/// The contrast.
pub contrast: f32,
/// The highlights.
pub highlights: f32,
/// The shadows.
pub shadows: f32,
/// The whites.
pub whites: f32,
/// The blacks.
pub blacks: f32,
/// The texture.
pub texture: f32,
/// The clarity.
pub clarity: f32,
/// The dehaze.
pub dehaze: f32,
/// The vibrance.
pub vibrance: f32,
/// The saturation.
pub saturation: f32,
// Tone curve
/// The curve highlights.
pub curve_highlights: f32,
/// The curve lights.
pub curve_lights: f32,
/// The curve darks.
pub curve_darks: f32,
/// The curve shadows.
pub curve_shadows: f32,
/// Region splits (percent).
pub curve_splits: [f32; 3],
/// Point curves as `[input, output]` in 0..=255 (empty = linear).
pub point_curve: Vec<[f32; 2]>,
/// The point curve red.
pub point_curve_red: Vec<[f32; 2]>,
/// The point curve green.
pub point_curve_green: Vec<[f32; 2]>,
/// The point curve blue.
pub point_curve_blue: Vec<[f32; 2]>,
// Color mixer: red, orange, yellow, green, aqua, blue, purple, magenta.
/// The hsl hue.
pub hsl_hue: [f32; 8],
/// The hsl sat.
pub hsl_sat: [f32; 8],
/// The hsl lum.
pub hsl_lum: [f32; 8],
// Color grading
/// The grade shadows.
pub grade_shadows: GradeWheel,
/// The grade midtones.
pub grade_midtones: GradeWheel,
/// The grade highlights.
pub grade_highlights: GradeWheel,
/// The grade global.
pub grade_global: GradeWheel,
/// The grade blending.
pub grade_blending: f32,
/// The grade balance.
pub grade_balance: f32,
// Detail
/// The sharpen amount.
pub sharpen_amount: f32,
/// The sharpen radius.
pub sharpen_radius: f32,
/// The sharpen detail.
pub sharpen_detail: f32,
/// The sharpen masking.
pub sharpen_masking: f32,
/// The noise luminance.
pub noise_luminance: f32,
/// The noise luminance detail.
pub noise_luminance_detail: f32,
/// The noise color.
pub noise_color: f32,
/// The noise color detail.
pub noise_color_detail: f32,
// Effects
/// The grain amount.
pub grain_amount: f32,
/// The grain size.
pub grain_size: f32,
/// The grain roughness.
pub grain_roughness: f32,
/// The vignette amount.
pub vignette_amount: f32,
/// The vignette midpoint.
pub vignette_midpoint: f32,
/// The vignette roundness.
pub vignette_roundness: f32,
/// The vignette feather.
pub vignette_feather: f32,
/// The vignette highlights.
pub vignette_highlights: f32,
/// The vignette style.
pub vignette_style: VignetteStyle,
}
impl Default for RawDevelopSettings {
fn default() -> Self {
todo!("dl.K66")
}
}
@@ -0,0 +1,64 @@
//! The Color Range dialog's body.
use craft_ui::canvas::RasterSource;
use craft_ui::contract::{Bind, EditResponse, NoValue, Outcome, Pattern, Props};
use craft_ui::runtime::env::Label;
use egui::{Response, Ui};
use super::ColorRangeValue;
/// What the Color Range body reports.
#[derive(Debug)]
#[non_exhaustive]
pub struct ColorRangeOutput {
/// The edit of the value.
pub edit: EditResponse<ColorRangeValue>,
/// The body's response.
pub response: Response,
}
impl Outcome for ColorRangeOutput {
type Value = NoValue;
fn response(&self) -> &Response {
&self.response
}
}
/// The Color Range body: the select, the sliders, the selection preview and the sampling tools.
#[must_use = "show the dialog body with `show`"]
#[derive(Pattern, Props)]
#[allow(dead_code)] // P3(dialogs-w7): dl.K54
pub struct ColorRangeDialog<'a> {
label: Label,
value: Bind<'a, ColorRangeValue>,
/// The mask the preview shows.
#[prop]
mask: Option<&'a dyn RasterSource>,
/// The picture the preview shows.
#[prop]
image: Option<&'a dyn RasterSource>,
/// The integer proxy factor `k`, halved by integer division.
#[prop]
picture_scale: u32,
/// An error to show under the preview.
#[prop]
error: Option<Label>,
/// The canvas the sampling presses reach.
#[prop]
canvas: Option<egui::Id>,
}
impl<'a> ColorRangeDialog<'a> {
/// The body named `label` over `value`.
pub fn new(label: impl Into<Label>, value: Bind<'a, ColorRangeValue>) -> Self {
let _ = (label.into(), value);
todo!("dl.K54")
}
/// Draws the body.
pub fn show(self, ui: &mut Ui) -> ColorRangeOutput {
let _ = (self, ui);
todo!("dl.K54")
}
}
@@ -0,0 +1,79 @@
//! [`HostedColorRange`]: Color Range on the dialog host.
use craft_ui::dialog::{DialogId, DialogResult, DialogStack, StackDialog, dialog_id};
use craft_ui::runtime::env::Label;
use egui::{Context, Ui};
use super::ColorRangeValue;
/// The key of the hosted Color Range dialog.
const KEY: &str = "select.colorRange";
/// Color Range as a dialog the dialog host owns. It is not registered: the app opens it. It answers with the value at OK.
pub struct HostedColorRange {
id: DialogId,
value: ColorRangeValue,
}
impl HostedColorRange {
/// The dialog titled `title` over `value`, for a document of `size` pixels.
pub fn new(title: impl Into<Label>, value: ColorRangeValue, size: [u32; 2]) -> Self {
let _ = (title.into(), size);
HostedColorRange { id: dialog_id(KEY), value }
}
/// The canvas the sampling presses reach.
#[must_use]
pub fn canvas(self, canvas: egui::Id) -> Self {
let _ = canvas;
todo!("dl.K54")
}
/// The value the dialog shows.
pub fn value(&self) -> &ColorRangeValue {
&self.value
}
/// Sets the selection preview the app rendered.
pub fn set_preview(&mut self, mask: Option<std::sync::Arc<dyn craft_ui::canvas::RasterSource + Send + Sync>>) {
let _ = mask;
todo!("dl.K54")
}
/// A press on the canvas at `at` with `mods` held samples a colour. `false` for a press outside the document.
pub fn sample_canvas(&mut self, at: [f64; 2], mods: craft_keymap::Mods) -> bool {
let _ = (at, mods);
todo!("dl.K54")
}
}
impl StackDialog for HostedColorRange {
type Result = ColorRangeValue;
fn id(&self) -> DialogId {
self.id
}
fn show(&mut self, ui: &mut Ui, stack: &DialogStack) -> Option<DialogResult<ColorRangeValue>> {
let _ = (ui, stack);
todo!("dl.K54")
}
fn key(&self) -> Option<&str> {
Some(KEY)
}
fn confirm(&mut self, ctx: &Context) -> Option<ColorRangeValue> {
let _ = ctx;
todo!("dl.K54")
}
fn json_fields(&self) -> Option<serde_json::Value> {
todo!("dl.K54")
}
fn set_json_field(&mut self, ctx: &Context, field: &str, value: serde_json::Value) -> Result<(), String> {
let _ = (ctx, field, value);
todo!("dl.K54")
}
}
@@ -0,0 +1,14 @@
//! [`ColorRangeWords`]: the Color Range dialog's words.
craft_ui::words! {
/// The words of the Color Range dialog, in the installed language unless set.
pub struct ColorRangeWords {
/// The dialog's title.
name: "colorRange.name" = "Color Range";
select: "colorRange.select" = "Select";
fuzziness: "colorRange.fuzziness" = "Fuzziness";
range: "colorRange.range" = "Range";
invert: "colorRange.invert" = "Invert";
sampled: "colorRange.sampled" = "Sampled Colors";
}
}
+11
View File
@@ -0,0 +1,11 @@
//! Color Range: the Select menu's dialog that selects by sampled colours, colour families or tonal ranges.
mod dialog;
mod hosted;
mod labels;
mod value;
pub use dialog::{ColorRangeDialog, ColorRangeOutput};
pub use hosted::HostedColorRange;
pub use labels::ColorRangeWords;
pub use value::{ColorRangeSelect, ColorRangeValue, ColorSamples, RangeControls, SampleSign, SampleTool};
+144
View File
@@ -0,0 +1,144 @@
//! The Color Range value and its sampling rules.
use craft_behavior::CursorBadge;
use craft_keymap::Mods;
use serde::{Deserialize, Serialize};
/// What the Select menu's Color Range picks colours by: a sampled colour, a colour family or a tonal range.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub enum ColorRangeSelect {
/// Sampled colours.
#[default]
Sampled,
/// Reds.
Reds,
/// Yellows.
Yellows,
/// Greens.
Greens,
/// Cyans.
Cyans,
/// Blues.
Blues,
/// Magentas.
Magentas,
/// Highlights.
Highlights,
/// Midtones.
Midtones,
/// Shadows.
Shadows,
}
/// The sampling tool: the plain eyedropper, Add to Sample or Subtract from Sample.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum SampleTool {
/// The eyedropper: replaces the samples.
#[default]
Sample,
/// Add to Sample.
Add,
/// Subtract from Sample.
Subtract,
}
impl SampleTool {
/// The tool as `mods` change it: Shift adds, else Alt subtracts.
#[must_use]
pub fn with_mods(self, mods: Mods) -> SampleTool {
let _ = (self, mods);
todo!("dl.K54")
}
/// The mark the canvas cursor shows for the tool.
pub fn badge(self) -> Option<CursorBadge> {
let _ = self;
todo!("dl.K54")
}
}
/// Whether a sample adds to the range or subtracts from it.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub enum SampleSign {
/// An added sample.
Add,
/// A subtracted sample.
Subtract,
}
/// The points the user sampled, in document pixels, and the order they were made in.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ColorSamples {
/// The added samples.
pub add: Vec<[f64; 2]>,
/// The subtracted samples.
pub subtract: Vec<[f64; 2]>,
/// The order the samples were made in.
pub order: Vec<SampleSign>,
}
impl ColorSamples {
/// Takes a sample at `at` in a document of `size`: floored and clamped to the document, by `tool` as `mods` change
/// it. Also Replace Color's sampling rule.
pub fn pick(&mut self, at: [f64; 2], size: [u32; 2], tool: SampleTool, mods: Mods) {
let _ = (at, size, tool, mods);
todo!("dl.K54")
}
/// The order of the samples, `None` while they are all of one sign.
pub fn order(&self) -> Option<&[SampleSign]> {
todo!("dl.K54")
}
/// Drops every sample.
pub fn clear(&mut self) {
todo!("dl.K54")
}
}
/// The Color Range dialog's value.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub struct ColorRangeValue {
/// What the range picks by.
pub select: ColorRangeSelect,
/// Fuzziness, 0..=200.
pub fuzziness: f64,
/// Range, 0..=100 percent.
pub range: f64,
/// The lower bound of Midtones.
pub midtones_low: f64,
/// The upper bound of Midtones.
pub midtones_high: f64,
/// The sampled points.
pub samples: ColorSamples,
/// Whether the selection is inverted.
pub invert: bool,
}
impl ColorRangeValue {
/// Which controls the value's `select` shows.
pub fn controls(&self) -> RangeControls {
todo!("dl.K54")
}
}
/// Which controls Color Range shows.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct RangeControls {
/// The Fuzziness slider.
pub fuzziness: bool,
/// The sampling tools.
pub sampling: bool,
/// The Range slider.
pub range: bool,
/// The Midtones bounds.
pub tonal: bool,
}
+2
View File
@@ -27,6 +27,7 @@ pub mod adjust;
pub mod blend_keys;
pub mod blur_pins;
pub mod channels;
pub mod color_range;
pub mod curve;
pub mod fill;
pub mod filter_gallery;
@@ -35,6 +36,7 @@ pub mod layer_style;
pub mod liquify;
pub mod live_preview;
pub mod mask_view;
pub mod raw_develop;
#[cfg(feature = "screen-testing")]
pub(crate) mod mock_image;
pub mod scopes;
@@ -0,0 +1,22 @@
//! The workspace's keys, in its command scope.
use craft_ui::contract::CommandSet;
/// The keys of the RAW Develop workspace. The clipping warnings are the scope's own commands.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, CommandSet)]
#[command(prefix = "rawDevelop", scope = "rawDevelop")]
#[non_exhaustive]
pub enum RawDevelopCommands {
/// Shows the picture before the settings while held.
#[command(modal = "in_dialogs", label = "Before", default = "Y")]
Before,
/// The sampler tool.
#[command(modal = "in_dialogs", label = "Color Sampler Tool", default = "S")]
SamplerTool,
/// The hand tool.
#[command(modal = "in_dialogs", label = "Hand Tool", default = "H")]
Hand,
/// The zoom tool.
#[command(modal = "in_dialogs", label = "Zoom Tool", default = "Z")]
Zoom,
}
@@ -0,0 +1,53 @@
//! The control column: sections of sliders over the settings.
use craft_ui::contract::{Bind, EditResponse, NoValue, Outcome, Pattern, Props};
use egui::{Response, Ui};
use super::Demosaic;
use crate::raw::RawDevelopSettings;
/// What the control column reports.
#[derive(Debug)]
#[non_exhaustive]
pub struct RawDevelopPanelOutput {
/// The column's response.
pub response: Response,
/// The edit of the settings.
pub edit: EditResponse<RawDevelopSettings>,
/// The Auto button was pressed.
pub auto: bool,
}
impl Outcome for RawDevelopPanelOutput {
type Value = NoValue;
fn response(&self) -> &Response {
&self.response
}
}
/// The control column: Light, Color, Effects, Curve, Color Mixer, Color Grading, Detail and Calibration sections. Each
/// row shows `Bind::given(f64::from(value))` and writes its edit back as `f32`.
#[must_use = "show the panel with `show`"]
#[derive(Pattern, Props)]
#[allow(dead_code)] // P3(dialogs-w9): dl.K67
pub struct RawDevelopPanel<'a> {
settings: Bind<'a, RawDevelopSettings>,
/// The demosaic select shows while a raw is being opened.
#[prop]
demosaic: Option<Demosaic>,
}
impl<'a> RawDevelopPanel<'a> {
/// The panel over `settings`.
pub fn new(settings: Bind<'a, RawDevelopSettings>) -> Self {
let _ = settings;
todo!("dl.K67")
}
/// Draws the sections.
pub fn show(self, ui: &mut Ui) -> RawDevelopPanelOutput {
let _ = (self, ui);
todo!("dl.K67")
}
}
@@ -0,0 +1,39 @@
//! The filmstrip of the raws being opened.
use craft_ui::contract::{Bind, Pattern};
use egui::{Response, Ui, load::SizedTexture};
/// One filmstrip tile.
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct RawFilmItem {
/// The raw's name.
pub name: String,
/// The raw has edits.
pub edited: bool,
/// The tile's picture.
pub picture: Option<SizedTexture>,
}
/// A one-column grid of tiles at the start edge, shown for more than one raw: the edited dot and the current frame.
#[must_use = "show the filmstrip with `show`"]
#[derive(Pattern)]
#[allow(dead_code)] // P3(dialogs-w9): dl.K66
pub struct RawFilmstrip<'a> {
items: &'a [RawFilmItem],
current: Bind<'a, usize>,
}
impl<'a> RawFilmstrip<'a> {
/// The filmstrip over `items` with `current` picked.
pub fn new(items: &'a [RawFilmItem], current: Bind<'a, usize>) -> Self {
let _ = (items, current);
todo!("dl.K66")
}
/// Draws the tiles.
pub fn show(self, ui: &mut Ui) -> Response {
let _ = (self, ui);
todo!("dl.K66")
}
}
+185
View File
@@ -0,0 +1,185 @@
//! The RAW Develop workspace: a full-window editor of the Camera Raw settings over the app's develop.
mod commands;
mod controls;
mod filmstrip;
mod scopes;
mod source;
use craft_behavior::{EditEvent, PixelSize};
use craft_ui::canvas::NavigationOptions;
use craft_ui::contract::Pattern;
use craft_ui::primitives::Checker;
use craft_ui::runtime::env::Label;
pub use commands::RawDevelopCommands;
pub use controls::{RawDevelopPanel, RawDevelopPanelOutput};
pub use filmstrip::{RawFilmItem, RawFilmstrip};
pub use scopes::{RawFloatingScope, RawScopeStrip};
pub use source::{Demosaic, RawDevelopSource, RawPreviewRequest};
use crate::raw::RawDevelopSettings;
use crate::ui::scopes::{ScopePanelState, ScopeSettings};
/// Where the workspace's result goes: the footer's buttons follow it.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RawTarget {
/// A filter on a layer: OK and Cancel.
Filter,
/// A smart filter: OK and Cancel.
SmartFilter,
/// Raws being opened: Open, Cancel and Done.
OpenRaw,
}
/// What opens the workspace.
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct RawDevelopOpen {
/// The raw's or the layer's name: the title's subject.
pub subject: String,
/// The picture's size in document pixels.
pub size: PixelSize,
/// Where the result goes.
pub target: RawTarget,
/// The settings to start from.
pub settings: RawDevelopSettings,
/// The settings Reset restores.
pub original: RawDevelopSettings,
/// The demosaic, while raws are being opened.
pub demosaic: Option<Demosaic>,
/// The filmstrip tiles, one per raw.
pub filmstrip: Vec<RawFilmItem>,
/// The raw shown.
pub current: usize,
/// The scope's state.
pub scope: ScopePanelState,
/// The user's navigation options.
pub navigation: NavigationOptions,
/// The user's transparency grid.
pub checkerboard: Option<Checker>,
}
impl RawDevelopOpen {
/// Opens on `subject` of `size` with `settings`, for `target`.
pub fn new(subject: impl Into<String>, size: PixelSize, target: RawTarget, settings: RawDevelopSettings) -> Self {
let _ = (subject.into(), size, target, settings);
todo!("dl.K66")
}
}
/// What the workspace reports.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum RawDevelopEvent {
/// The settings changed.
Settings(EditEvent<RawDevelopSettings>),
/// A filmstrip pick: the app keeps the current raw's settings and calls `show_item`.
Show(usize),
/// Load Settings asks the app for a file.
LoadSettings,
/// Save Settings asks the app for a file.
SaveSettings,
/// The scope's settings changed: the app persists them.
ScopeSettings(ScopeSettings),
}
/// How the workspace finished.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum RawFinish {
/// OK of a filter or a smart filter.
Ok,
/// Open of raws being opened.
Open,
/// Done of raws being opened.
Done,
}
/// What OK answers.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct RawDevelopResult {
/// The button that finished it.
pub finish: RawFinish,
/// The settings at the end.
pub settings: RawDevelopSettings,
/// The demosaic, while raws are being opened.
pub demosaic: Option<Demosaic>,
}
/// The RAW Develop workspace, titled "RAW Develop (name)" or "RAW Develop Filter (layer)".
#[derive(Pattern)]
pub struct RawDevelopWorkspace {
settings: RawDevelopSettings,
}
impl RawDevelopWorkspace {
/// A workspace over `open`.
pub fn new(open: RawDevelopOpen) -> Self {
let _ = open;
todo!("dl.K66")
}
/// The settings as they are now.
pub fn session(&self) -> &RawDevelopSettings {
&self.settings
}
/// Loads `settings` as one history step.
pub fn load(&mut self, settings: RawDevelopSettings) {
let _ = settings;
todo!("dl.K66")
}
/// Shows raw `current` with its `settings`, the `original` Reset restores and its `demosaic`.
pub fn show_item(&mut self, current: usize, settings: RawDevelopSettings, original: RawDevelopSettings, demosaic: Option<Demosaic>) {
let _ = (current, settings, original, demosaic);
todo!("dl.K66")
}
/// Sets the picture of filmstrip tile `index` and whether the raw is edited.
pub fn set_item_picture(&mut self, index: usize, picture: egui::load::SizedTexture, edited: bool) {
let _ = (index, picture, edited);
todo!("dl.K66")
}
/// Shows `message` in the status line.
pub fn status(&mut self, message: Option<Label>) {
let _ = message;
todo!("dl.K66")
}
}
// P3(dialogs-w17): dl.K66 — the workspace's trait surface; `show` and the automation fields are written in phase 3.
impl craft_ui::dialog::FullWindowWorkspace for RawDevelopWorkspace {
type Source = dyn RawDevelopSource;
type Event = RawDevelopEvent;
type Result = RawDevelopResult;
const KEY: &'static str = "filter.cameraRaw";
fn show(
&mut self,
ui: &mut egui::Ui,
cx: craft_ui::dialog::WorkspaceCx<'_, Self::Source>,
) -> craft_ui::dialog::WorkspacePass<Self::Event, Self::Result> {
let _ = (ui, cx);
todo!("dl.K66")
}
fn json_fields(&self) -> Option<serde_json::Value> {
todo!("dl.K66")
}
fn set_json_field(&mut self, ctx: &egui::Context, source: &Self::Source, field: &str, value: serde_json::Value) -> Result<(), String> {
let _ = (ctx, source, field, value);
todo!("dl.K66")
}
fn confirm(&mut self, ctx: &egui::Context, source: &Self::Source) -> Option<Self::Result> {
let _ = (ctx, source);
todo!("dl.K66")
}
}
@@ -0,0 +1,58 @@
//! The docked and floating scope of the workspace.
use craft_ui::contract::{Bind, Pattern, Props};
use egui::Ui;
use crate::ui::scopes::{ScopeFrame, ScopePanelOutput, ScopePanelState};
/// The docked scope above the controls: a `ScopePanel` with Camera Raw's tone zones and typical histogram scale, its
/// context menu and a Float action in the section header.
#[must_use = "show the strip with `show`"]
#[derive(Pattern, Props)]
#[allow(dead_code)] // P3(dialogs-w9): dl.K67
pub struct RawScopeStrip<'a> {
state: &'a mut ScopePanelState,
frame: Option<&'a ScopeFrame<'a>>,
/// Whether the scope floats; its Float action sets it.
#[prop]
floating: Option<Bind<'a, bool>>,
}
impl<'a> RawScopeStrip<'a> {
/// The strip over `state` and the host's `frame`.
pub fn new(state: &'a mut ScopePanelState, frame: Option<&'a ScopeFrame<'a>>) -> Self {
let _ = (state, frame);
todo!("dl.K67")
}
/// Draws the scope.
pub fn show(self, ui: &mut Ui) -> ScopePanelOutput {
let _ = (self, ui);
todo!("dl.K67")
}
}
/// The floating scope: a modeless child dialog of the workspace, resizable and remembered; its Dock action clears
/// `floating`.
#[must_use = "show the scope with `show`"]
#[derive(Pattern)]
#[allow(dead_code)] // P3(dialogs-w9): dl.K67
pub struct RawFloatingScope<'a> {
state: &'a mut ScopePanelState,
frame: Option<&'a ScopeFrame<'a>>,
floating: Bind<'a, bool>,
}
impl<'a> RawFloatingScope<'a> {
/// The floating scope over `state` and the host's `frame`.
pub fn new(state: &'a mut ScopePanelState, frame: Option<&'a ScopeFrame<'a>>, floating: Bind<'a, bool>) -> Self {
let _ = (state, frame, floating);
todo!("dl.K67")
}
/// Draws the scope.
pub fn show(self, ui: &mut Ui) -> ScopePanelOutput {
let _ = (self, ui);
todo!("dl.K67")
}
}
@@ -0,0 +1,66 @@
//! What the app gives the RAW Develop workspace: the develop and its pictures.
use craft_ui::canvas::{PixelRect, RasterSource};
use craft_ui::primitives::Revision;
use craft_ui::runtime::pending::Job;
use serde::{Deserialize, Serialize};
use crate::raw::RawDevelopSettings;
use crate::scopes::ClippingMask;
use crate::ui::scopes::{ScopeFrame, ScopeReadout};
use crate::ui::wide_angle::PreviewDone;
/// The demosaic algorithm a raw is opened with.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[non_exhaustive]
pub enum Demosaic {
/// Adaptive homogeneity-directed.
Ahd,
/// Modified high-contrast.
Mhc,
/// Bilinear.
Bilinear,
}
/// One develop of the preview: the proxy, and the visible part at full resolution when the view shows more pixels than
/// the proxy has.
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct RawPreviewRequest {
/// Counts the source changes, so a late preview of old pixels is dropped.
pub revision: u64,
/// The settings to develop with.
pub settings: RawDevelopSettings,
/// The demosaic, while a raw is being opened.
pub demosaic: Option<Demosaic>,
/// The visible part in document pixels.
pub visible: PixelRect,
/// Screen pixels per document pixel.
pub zoom: f64,
}
/// The app's develop: GPU or CPU passes, proxies, detail refinement, histograms, clipping masks and samples stay the
/// app's.
pub trait RawDevelopSource: Send + Sync {
/// The picture as developed with the settings.
fn after(&self) -> &dyn RasterSource;
/// The picture before the settings (Before, Y).
fn before(&self) -> &dyn RasterSource;
/// The job that develops `request` into [`after`](Self::after).
fn develop(&self, request: &RawPreviewRequest) -> Job<PreviewDone, String>;
/// The settings Auto picks for `settings`.
fn auto(&self, settings: &RawDevelopSettings) -> RawDevelopSettings;
/// What the scope counted of the picture before or after, of the selected region or the whole picture.
fn scope(&self, before: bool, region: bool) -> Option<ScopeFrame<'_>>;
/// The clipping mask and its revision.
fn clipping(&self) -> Option<(&ClippingMask, Revision)>;
/// The sample at `at` in the form `lab` asks for; the host does the colour management.
fn sample(&self, at: [f64; 2], before: bool, lab: bool) -> Option<ScopeReadout>;
}
+18 -6
View File
@@ -63,16 +63,28 @@ impl<'a, M: MaskSource> From<&'a M> for OutlineSource<'a> {
}
/// A point to point map in document pixels: where a Free Transform puts the selection, or the app's warp.
pub struct PointMap<'a>(Box<dyn Fn(Point) -> Point + 'a>);
pub struct PointMap<'a> {
map: Box<dyn Fn(Point) -> Option<Point> + 'a>,
bends: bool,
}
impl<'a> PointMap<'a> {
/// The map that runs `map`.
pub fn new(map: impl Fn(Point) -> Point + 'a) -> Self {
PointMap(Box::new(map))
/// The map that runs `map`; it may drop a point (past a Distort's horizon). Without [`bends`](Self::bends), a segment
/// with an unmapped end is left out.
pub fn new(map: impl Fn(Point) -> Option<Point> + 'a) -> Self {
PointMap { map: Box::new(map), bends: false }
}
/// Marks the map as bending: the ants are cut into pieces of at most 8 pt and the pieces past the horizon dropped.
#[must_use]
pub fn bends(mut self) -> Self {
self.bends = true;
self
}
fn apply(&self, point: Point) -> Point {
(self.0)(point)
let _ = self.bends; // P3(tools-w?): tl.T14 — unmapped points and bending maps
(self.map)(point).unwrap_or(point)
}
}
@@ -127,7 +139,7 @@ pub struct SelectionOverlay<'a> {
#[prop(quantity = "reduction")]
reduction: u32,
/// Draws the outline through this map, document point to document point.
#[prop(func = "Fn(Point) -> Point")]
#[prop(func = "Fn(Point) -> Option<Point>")]
mapped: Option<PointMap<'a>>,
/// The Selection Preview mode (Color Range's modes, or Quick Mask).
#[prop]
+136
View File
@@ -0,0 +1,136 @@
//! The Cylinder warp editor: a canvas control with the cylinder's handles over a [`WarpMesh`].
use craft_behavior::Metrics;
use craft_ui::contract::{Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, MeasureCx, Outcome, Props as _, Role};
use craft_ui::runtime::env::Label;
use craft_ui::runtime::focus::KeyUse;
use craft_ui::style::{ComponentStyle, StyleColor, StyleCx};
use egui::{Response, Vec2};
use super::WarpMesh;
/// The cylinder's values: the box, the depths of its top and bottom edges and the wrap.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct CylinderValues {
/// The left edge of the box.
pub left: f64,
/// The bottom edge of the box.
pub bottom: f64,
/// The right edge of the box.
pub right: f64,
/// The top edge of the box.
pub top: f64,
/// How far the top edge curves in depth.
pub top_depth: f64,
/// How far the bottom edge curves in depth.
pub bottom_depth: f64,
/// How far the surface wraps around the cylinder.
pub wrap: f64,
}
impl CylinderValues {
/// The values of a flat cylinder over `rect` (left, top, right, bottom).
pub fn for_box(rect: [f64; 4]) -> Self {
let _ = rect;
todo!("tl.T16")
}
/// The values from `[left, bottom, right, top, top_depth, bottom_depth, wrap]`.
pub fn from_array(values: [f64; 7]) -> Self {
let _ = values;
todo!("tl.T16")
}
/// The values as `[left, bottom, right, top, top_depth, bottom_depth, wrap]`.
pub fn to_array(self) -> [f64; 7] {
todo!("tl.T16")
}
}
/// A handle of the cylinder editor.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum CylinderHandle {
/// The top right corner.
TopRight,
/// The bottom left corner.
BottomLeft,
/// The bend of the top edge.
Bend,
/// The bottom edge.
Bottom,
/// The wrap.
Wrap,
/// The surface.
Surface,
}
/// The look of the cylinder editor.
#[derive(Clone, Debug, PartialEq, ComponentStyle)]
#[non_exhaustive]
pub struct CylinderWarpStyle {
#[style(metrics)]
metrics: Metrics,
/// The box and the cylinder's outline.
line: StyleColor,
}
/// The cylinder editor over `values`, drawn over `mesh`.
#[derive(craft_ui::contract::Component, craft_ui::contract::Props)]
#[component(canvas_control)]
pub struct CylinderWarp<'a> {
#[common]
common: Common,
values: Bind<'a, CylinderValues>,
mesh: &'a WarpMesh,
}
impl<'a> CylinderWarp<'a> {
/// The cylinder editor named `label` over `values` and `mesh`.
pub fn new(label: impl Into<Label>, values: Bind<'a, CylinderValues>, mesh: &'a WarpMesh) -> Self {
CylinderWarp { common: Common::new(), values, mesh }.label(label)
}
}
/// What the cylinder editor reports.
#[derive(Debug)]
#[non_exhaustive]
pub struct CylinderWarpOutput {
/// The edit of the values.
pub values: EditResponse<CylinderValues>,
/// The handle under the pointer.
pub hovered: Option<CylinderHandle>,
}
impl Outcome for CylinderWarpOutput {
type Value = CylinderValues;
fn response(&self) -> &Response {
&self.values.response
}
}
impl Component for CylinderWarp<'_> {
const ROLE: Role = Role::GROUP;
const OVERLAYS: bool = false;
const KEYS: KeyUse = KeyUse::CANVAS;
type Style = CylinderWarpStyle;
type Output = CylinderWarpOutput;
fn style(cx: &StyleCx<'_>, _: CylinderWarpStyleKey) -> CylinderWarpStyle {
CylinderWarpStyle { metrics: Metrics::new(), line: cx.color(cx.tokens.color.overlay.line) }
}
fn measure(&mut self, _: &MeasureCx<'_, Self>) -> Vec2 {
Vec2::ZERO
}
fn bind(&mut self) -> Option<BindMut<'_, CylinderValues>> {
Some(self.values.reborrow())
}
fn finish(self, cx: Cx<'_, Self>) -> CylinderWarpOutput {
let _ = self.mesh;
CylinderWarpOutput { values: cx.edit_response(), hovered: None }
}
}
+19 -1
View File
@@ -58,12 +58,30 @@ pub struct WarpStyleEntry {
pub preset: bool,
/// The Custom style (the mesh edited by hand): hidden over a type layer.
pub custom: bool,
/// The style is offered over a type layer.
pub over_type: bool,
/// The style enables Split and Grid.
pub splits: bool,
}
impl WarpStyleEntry {
/// A style `key` shown as `label`, neither a preset nor Custom.
pub fn new(key: impl Into<String>, label: impl Into<String>) -> Self {
Self { key: key.into(), label: label.into(), preset: false, custom: false }
Self { key: key.into(), label: label.into(), preset: false, custom: false, over_type: false, splits: false }
}
/// Whether the style is offered over a type layer.
#[must_use]
pub fn over_type(mut self, on: bool) -> Self {
self.over_type = on;
self
}
/// Whether the style enables Split and Grid.
#[must_use]
pub fn splits(mut self, on: bool) -> Self {
self.splits = on;
self
}
/// Whether the orientation and Bend, H and V act on the style.
+2
View File
@@ -5,6 +5,7 @@
//! Perspective Warp ([`perspective`]) and the one painter of a deformed mesh's lines
//! ([`MeshLines`]).
mod cylinder;
mod fields;
mod grid;
mod mesh;
@@ -14,6 +15,7 @@ pub mod pin;
#[cfg(feature = "screen-testing")]
mod stories;
pub use cylinder::{CylinderHandle, CylinderValues, CylinderWarp, CylinderWarpOutput, CylinderWarpStyle};
pub use fields::{WarpFieldValues, WarpFields, WarpFieldsEdit, WarpFieldsOutput, WarpFieldsWords, WarpGridChoice, WarpStyleEntry};
pub use grid::{POINT, SURFACE, WarpGrid, WarpGridOutput, WarpGridStyle, WarpRule, WarpSurface, WarpWords};
pub(crate) use mesh::MeshLines;