forked from 1b-agent/opencadstudio-upstream
ADJUST: images and underlays, -IMAGEADJUST and PDF/DWF/DGNADJUST
ADJUST gathers raster images or PDF/DWF/DGN underlays (other objects are dropped silently, pickfirst is used, a mixed set is refused), then asks the image option (Brightness default) or the underlay option (last used), with value prompts that offer the image's own value or the session's last underlay fade/contrast, and Monochrome Yes/No. Invalid values re-prompt. One undo step. -IMAGEADJUST, PDFADJUST, DWFADJUST and DGNADJUST take one kind each. Raster image Brightness/Contrast/Fade move to an Image Adjust section as whole numbers with 0-100 validation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b1d4c9bd9b
commit
a0a83ad681
32 files changed
+841
-311
No files matched your search
@@ -333,7 +333,20 @@ impl PropertyEditable for RasterImage {
|
||||
.contains(codec::entities::ImageDisplayFlags::USE_CLIPPING_BOUNDARY);
|
||||
let clip_inverted = self.clip_boundary.clip_mode == codec::entities::ClipMode::Inside;
|
||||
let transparency = self.common.transparency.to_string();
|
||||
let whole = |label: &str, field: &'static str, value: u8| Property {
|
||||
label: t!(label).into_owned(),
|
||||
field,
|
||||
value: PropValue::EditText(value.to_string()),
|
||||
};
|
||||
vec![
|
||||
PropSection {
|
||||
title: t!("Image Adjust").into_owned(),
|
||||
props: vec![
|
||||
whole("Brightness", "ri_bright", self.brightness),
|
||||
whole("Contrast", "ri_contrast", self.contrast),
|
||||
whole("Fade", "ri_fade", self.fade),
|
||||
],
|
||||
},
|
||||
PropSection {
|
||||
title: t!("Geometry").into_owned(),
|
||||
props: vec![
|
||||
@@ -362,13 +375,6 @@ impl PropertyEditable for RasterImage {
|
||||
title: t!("Misc").into_owned(),
|
||||
props: vec![
|
||||
ro(t!("Name").as_ref(), "ri_name", self.file_name().to_string()),
|
||||
edit(
|
||||
t!("Brightness").as_ref(),
|
||||
"ri_bright",
|
||||
self.brightness as f64,
|
||||
),
|
||||
edit(t!("Contrast").as_ref(), "ri_contrast", self.contrast as f64),
|
||||
edit(t!("Fade").as_ref(), "ri_fade", self.fade as f64),
|
||||
ro(t!("Transparency").as_ref(), "ri_transparency", transparency),
|
||||
Property {
|
||||
label: t!("Show image").into_owned(),
|
||||
@@ -449,9 +455,10 @@ impl PropertyEditable for RasterImage {
|
||||
"ri_ox" => self.insertion_point.x = v,
|
||||
"ri_oy" => self.insertion_point.y = v,
|
||||
"ri_oz" => self.insertion_point.z = v,
|
||||
"ri_bright" => self.brightness = v.clamp(0.0, 100.0) as u8,
|
||||
"ri_contrast" => self.contrast = v.clamp(0.0, 100.0) as u8,
|
||||
"ri_fade" => self.fade = v.clamp(0.0, 100.0) as u8,
|
||||
// Out-of-range values are refused before they get here.
|
||||
"ri_bright" if (0.0..=100.0).contains(&v) => self.brightness = v as u8,
|
||||
"ri_contrast" if (0.0..=100.0).contains(&v) => self.contrast = v as u8,
|
||||
"ri_fade" if (0.0..=100.0).contains(&v) => self.fade = v as u8,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,7 +227,8 @@ fn parse_flag(value: &str, current: bool) -> bool {
|
||||
pub(crate) fn validate_property(field: &str, value: &str) -> Result<(), &'static str> {
|
||||
let number = || value.trim().parse::<f64>().ok();
|
||||
match field {
|
||||
"ul_contrast" | "ul_fade" => match number() {
|
||||
// A raster image's Image Adjust rows take the same range.
|
||||
"ul_contrast" | "ul_fade" | "ri_bright" | "ri_contrast" | "ri_fade" => match number() {
|
||||
Some(v) if (0.0..=100.0).contains(&v) && v.fract() == 0.0 => Ok(()),
|
||||
_ => Err("Value must be an integer between 0 and 100"),
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user