style: apply cargo fmt across workspace

This commit is contained in:
Karim Jerbi committed 2026-10-11 03:14:29 +01:00
1 parent 85710e5454
commit 9cf9ff2c5c
531 files changed
+57740 -33906

No files matched your search

+38 -17
View File
@@ -2,13 +2,14 @@ use codec::entities::{AttachmentPoint, DrawingDirection, MText};
use crate::command::EntityTransform;
use crate::entities::common::{
edit_angle_prop as edit_angle, edit_prop as edit, num_prop as num_row, ro_prop as ro, square_grip, triangle_grip,
edit_angle_prop as edit_angle, edit_prop as edit, num_prop as num_row, ro_prop as ro,
square_grip, triangle_grip,
};
use crate::entities::text_support::{
clamp_mtext_column_count, layout_mtext, resolve_text_style, GlyphBox, MTextColumns,
MTextRenderOpts, MTextVAnchor,
};
use crate::entities::traits::{Grippable, PropertyEditable, Transformable, RenderConvertible};
use crate::entities::traits::{Grippable, PropertyEditable, RenderConvertible, Transformable};
use crate::scene::convert::acad_to_render::{RenderEntity, RenderObject};
use crate::scene::model::object::{GripApply, GripDef, PropSection, PropValue, Property};
use crate::scene::model::wire_model::SnapHint;
@@ -100,7 +101,9 @@ fn display_text(t: &MText, document: &codec::CadDocument) -> String {
if gap == 0 || !after.chars().next().is_some_and(is_rtl_char) {
continue;
}
let word = after.find(|c: char| c == ' ' || c == '\\').unwrap_or(after.len());
let word = after
.find(|c: char| c == ' ' || c == '\\')
.unwrap_or(after.len());
let moved = format!("{}{}{}", &after[..word], &rest[..gap], &after[word..]);
out.replace_range(span.end.., &moved);
}
@@ -261,7 +264,11 @@ pub(crate) fn explode_mtext(t: &MText, document: &codec::CadDocument) -> Vec<cod
text.common.handle = codec::Handle::NULL;
if let Some([r, g, b]) = stroke.color {
let byte = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8;
text.common.color = codec::types::Color::Rgb { r: byte(r), g: byte(g), b: byte(b) };
text.common.color = codec::types::Color::Rgb {
r: byte(r),
g: byte(g),
b: byte(b),
};
}
text.style = t.style.clone();
text.height = run.height as f64;
@@ -321,8 +328,7 @@ fn grips(t: &MText) -> Vec<GripDef> {
let columns_active =
t.column_data.column_type != 0 && column_count > 1 && t.column_data.width > 0.0;
let block_width = if columns_active {
t.column_data.width * column_count as f64
+ t.column_data.gutter * (column_count - 1) as f64
t.column_data.width * column_count as f64 + t.column_data.gutter * (column_count - 1) as f64
} else {
t.rectangle_width.max(0.0)
};
@@ -338,9 +344,9 @@ fn grips(t: &MText) -> Vec<GripDef> {
let down = glam::DVec3::new(sin, -cos, 0.0);
let (_, vertical) = attach_anchors(t);
let factor = match vertical {
MTextVAnchor::Top
| MTextVAnchor::MiddleOfTopLine
| MTextVAnchor::BottomOfTopLine => 1.0,
MTextVAnchor::Top | MTextVAnchor::MiddleOfTopLine | MTextVAnchor::BottomOfTopLine => {
1.0
}
MTextVAnchor::Middle => 0.5,
MTextVAnchor::Bottom | MTextVAnchor::MiddleOfBottomLine => -1.0,
};
@@ -439,8 +445,16 @@ fn properties(t: &MText, text_style_names: &[String]) -> Vec<PropSection> {
crate::entities::common::style_fixed_height(&t.style).is_none(),
),
edit_angle(t!("Rotation").as_ref(), "rotation", t.rotation.to_degrees()),
edit(t!("Line space factor").as_ref(), "line_spacing", t.line_spacing_factor),
edit(t!("Line space distance").as_ref(), "line_space_distance", line_space_distance),
edit(
t!("Line space factor").as_ref(),
"line_spacing",
t.line_spacing_factor,
),
edit(
t!("Line space distance").as_ref(),
"line_space_distance",
line_space_distance,
),
Property {
label: t!("Line space style").into_owned(),
field: "line_space_style",
@@ -473,7 +487,12 @@ fn properties(t: &MText, text_style_names: &[String]) -> Vec<PropSection> {
.collect(),
},
},
num_row(t!("Defined width").as_ref(), "rect_w", t.rectangle_width, false),
num_row(
t!("Defined width").as_ref(),
"rect_w",
t.rectangle_width,
false,
),
num_row(
t!("Defined height").as_ref(),
"rect_h",
@@ -652,8 +671,7 @@ fn apply_grip(t: &mut MText, grip_id: usize, apply: GripApply) {
t.column_data.column_count = column_count;
let gaps = (column_count - 1) as f64;
t.column_data.width =
((width - t.column_data.gutter * gaps) / column_count as f64)
.max(0.01);
((width - t.column_data.gutter * gaps) / column_count as f64).max(0.01);
} else {
t.rectangle_width = width;
}
@@ -698,8 +716,7 @@ fn apply_grip(t: &mut MText, grip_id: usize, apply: GripApply) {
p.y as f64 - t.insertion_point.y,
0.0,
);
t.column_data.gutter =
(delta.dot(dir) / k - t.column_data.width).max(0.0);
t.column_data.gutter = (delta.dot(dir) / k - t.column_data.width).max(0.0);
}
_ => {}
}
@@ -762,7 +779,11 @@ impl Grippable for MText {
}
}
fn apply_grip_menu(&mut self, _grip_id: usize, _action: crate::scene::model::object::GripMenuAction) {
fn apply_grip_menu(
&mut self,
_grip_id: usize,
_action: crate::scene::model::object::GripMenuAction,
) {
// Rotate needs a follow-up angle handled by
// `apply_grip_menu_value`; Move-with-Text is the default drag.
}