mirror of
https://github.com/storytold/photocraft.git
synced 2026-11-21 09:26:43 +00:00
Merge branch 'storytold:main' into fix/5806-displace-asks-for-map
This commit is contained in:
5 files changed
+28
-31
No files matched your search
@@ -242,14 +242,9 @@ pub fn isolated_curve_channel_for(st: &DocState, layers_panel_mask: bool) -> Opt
|
||||
translate: false,
|
||||
gray: Some(GraySurface::Alpha(i)),
|
||||
}),
|
||||
ChannelTarget::Composite if doc.quick_mask.is_some() => Some(IsolatedCurveChannel {
|
||||
name: "Quick Mask".into(),
|
||||
key: "",
|
||||
hist: 0,
|
||||
tint: false,
|
||||
translate: true,
|
||||
gray: Some(GraySurface::QuickMask),
|
||||
}),
|
||||
ChannelTarget::Composite if doc.quick_mask.is_some() => {
|
||||
Some(IsolatedCurveChannel { name: "Quick Mask".into(), key: "", hist: 0, tint: false, translate: true, gray: Some(GraySurface::QuickMask) })
|
||||
}
|
||||
ChannelTarget::LayerMask => layer_mask_curve_channel(st),
|
||||
ChannelTarget::Composite if crate::mask_view_cmds::current(st).is_some() || layers_panel_mask => layer_mask_curve_channel(st),
|
||||
_ => None,
|
||||
|
||||
@@ -422,10 +422,7 @@ pub fn render_video_with(
|
||||
let frames = base.timeline.as_ref().map_or(1, |t| t.duration).max(1);
|
||||
// Loaded timelines bypass the duration validation used by timeline.create/setProps.
|
||||
if frames > crate::timeline_cmds::MAX_DURATION {
|
||||
return Err(EngineError::Other(format!(
|
||||
"the timeline is {frames} frames; Render Video is limited to {} frames",
|
||||
crate::timeline_cmds::MAX_DURATION
|
||||
)));
|
||||
return Err(EngineError::Other(format!("the timeline is {frames} frames; Render Video is limited to {} frames", crate::timeline_cmds::MAX_DURATION)));
|
||||
}
|
||||
let fps = base.timeline.as_ref().map_or(30.0, |t| t.fps).max(1.0);
|
||||
let stem = base.name.rsplit_once('.').map_or(base.name.as_str(), |(a, _)| a).to_string();
|
||||
@@ -443,9 +440,7 @@ pub fn render_video_with(
|
||||
// The whole canvas is staged as f32 RGBA for each frame; reject over-budget
|
||||
// dimensions before an infallible allocation can abort the process.
|
||||
if (w as u64) * (h as u64) > MAX_GIF_FRAME_PIXELS {
|
||||
return Err(EngineError::Other(format!(
|
||||
"{w} × {h} is too large to render as an animated GIF (limit {MAX_GIF_FRAME_PIXELS} pixels per frame)"
|
||||
)));
|
||||
return Err(EngineError::Other(format!("{w} × {h} is too large to render as an animated GIF (limit {MAX_GIF_FRAME_PIXELS} pixels per frame)")));
|
||||
}
|
||||
let delay = (100.0 / fps).round().clamp(1.0, 65535.0) as u16;
|
||||
let mut gframes = Vec::with_capacity(frames);
|
||||
|
||||
@@ -196,11 +196,7 @@ fn isolated(app: &PhotocraftApp) -> Option<photocraft_engine::channel_cmds::Isol
|
||||
/// and the fields carry no Lab or CMYK records (#5335).
|
||||
fn curve_mode(app: &PhotocraftApp, kind: &str) -> photocraft_doc::ColorMode {
|
||||
let mode = app.session.active().map_or(photocraft_doc::ColorMode::Rgb, |s| s.doc.mode);
|
||||
if kind == "curves" && isolated(app).is_some_and(|c| c.gray.is_some()) {
|
||||
photocraft_doc::ColorMode::Grayscale
|
||||
} else {
|
||||
mode
|
||||
}
|
||||
if kind == "curves" && isolated(app).is_some_and(|c| c.gray.is_some()) { photocraft_doc::ColorMode::Grayscale } else { mode }
|
||||
}
|
||||
|
||||
/// Dialog body: the kind's editor over the fields, then the Preview checkbox.
|
||||
@@ -874,8 +870,6 @@ mod tests {
|
||||
|
||||
/// The Channel popup's selected value (its option labels are what it shows).
|
||||
fn popup_channels(h: &mut Harness<'static, PhotocraftApp>) -> Vec<String> {
|
||||
h.query_all_by_role(egui::accesskit::Role::ComboBox)
|
||||
.filter_map(|n| n.value().map(|s| s.to_string()))
|
||||
.collect()
|
||||
h.query_all_by_role(egui::accesskit::Role::ComboBox).filter_map(|n| n.value().map(|s| s.to_string())).collect()
|
||||
}
|
||||
}
|
||||
@@ -76,11 +76,14 @@ fn isolate(layers: &mut [Layer], id: LayerId) -> bool {
|
||||
|
||||
/// Histograms of `doc` as seen by `source`, in the channels of `space`.
|
||||
pub fn compute_histograms(doc: &Document, source: HistSource, space: ToneSpace) -> Histograms {
|
||||
let mut h = vec![[0u32; 256]; match space {
|
||||
ToneSpace::Rgb => 4,
|
||||
ToneSpace::Cmyk => 5,
|
||||
ToneSpace::Lab => 3,
|
||||
}];
|
||||
let mut h = vec![
|
||||
[0u32; 256];
|
||||
match space {
|
||||
ToneSpace::Rgb => 4,
|
||||
ToneSpace::Cmyk => 5,
|
||||
ToneSpace::Lab => 3,
|
||||
}
|
||||
];
|
||||
match source {
|
||||
// The gray plane itself: its levels are what the curve edits, whatever the document's
|
||||
// colour mode (#5335).
|
||||
@@ -443,8 +446,10 @@ mod tests {
|
||||
let m = compute_histograms(&st.doc, HistSource::Channel { layer, surface: GraySurface::LayerMask }, ToneSpace::Rgb);
|
||||
assert!(m[0][0] > 0, "the hidden mask is black");
|
||||
// Each plane keeps its own cache entry: switching targets recomputes.
|
||||
assert_ne!(tag(HistSource::Channel { layer, surface: GraySurface::Alpha(0) }, ToneSpace::Rgb),
|
||||
tag(HistSource::Channel { layer, surface: GraySurface::LayerMask }, ToneSpace::Rgb));
|
||||
assert_ne!(
|
||||
tag(HistSource::Channel { layer, surface: GraySurface::Alpha(0) }, ToneSpace::Rgb),
|
||||
tag(HistSource::Channel { layer, surface: GraySurface::LayerMask }, ToneSpace::Rgb)
|
||||
);
|
||||
assert_ne!(tag(HistSource::Channel { layer, surface: GraySurface::LayerMask }, ToneSpace::Rgb), tag(HistSource::Layer(layer), ToneSpace::Rgb));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1358,7 +1358,15 @@ pub fn dropdown_wheel_hovered<T: PartialEq + Clone>(ui: &mut Ui, id: &str, curre
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn dropdown_with<T: PartialEq + Clone>(ui: &mut Ui, id: &str, current: &mut T, options: &[(T, &str)], width: f32, wheel: bool, translate: bool) -> (Vec<T>, Option<T>) {
|
||||
fn dropdown_with<T: PartialEq + Clone>(
|
||||
ui: &mut Ui,
|
||||
id: &str,
|
||||
current: &mut T,
|
||||
options: &[(T, &str)],
|
||||
width: f32,
|
||||
wheel: bool,
|
||||
translate: bool,
|
||||
) -> (Vec<T>, Option<T>) {
|
||||
let shown = |l: &str| if translate { tl!(l).to_string() } else { l.to_string() };
|
||||
let label = options.iter().find(|(v, _)| v == current).map(|(_, l)| shown(l)).unwrap_or_else(|| "—".into());
|
||||
let (mut chosen, mut hovered) = (Vec::new(), None);
|
||||
|
||||
Reference in new issue
Block a user