forked from 1b-agent/opencadstudio-upstream
Position rectangle dimension labels away from geometry
This commit is contained in:
1 parent
913705106e
commit
01af9d9fb8
2 files changed
+31
-3
No files matched your search
+21
-1
@@ -1024,6 +1024,9 @@ bg={bg_ms:.1}ms n={view_count}"
|
|||||||
let height_center = opposite
|
let height_center = opposite
|
||||||
+ width_axis * width
|
+ width_axis * width
|
||||||
+ height_axis * (height * 0.5);
|
+ height_axis * (height * 0.5);
|
||||||
|
let rectangle_center = opposite
|
||||||
|
+ width_axis * (width * 0.5)
|
||||||
|
+ height_axis * (height * 0.5);
|
||||||
let (vw, vh) = tab.scene.selection.borrow().vp_size;
|
let (vw, vh) = tab.scene.selection.borrow().vp_size;
|
||||||
let (camera, bounds) = tab
|
let (camera, bounds) = tab
|
||||||
.scene
|
.scene
|
||||||
@@ -1040,7 +1043,24 @@ bg={bg_ms:.1}ms n={view_count}"
|
|||||||
bounds.y + screen.y,
|
bounds.y + screen.y,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
Some((project(width_center)?, project(height_center)?))
|
let center = project(rectangle_center)?;
|
||||||
|
let offset_from_center = |side: iced::Point, pixels: f32| {
|
||||||
|
let dx = side.x - center.x;
|
||||||
|
let dy = side.y - center.y;
|
||||||
|
let length = dx.hypot(dy);
|
||||||
|
if length > 1.0e-3 {
|
||||||
|
iced::Point::new(
|
||||||
|
side.x + dx / length * pixels,
|
||||||
|
side.y + dy / length * pixels,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
side
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Some((
|
||||||
|
offset_from_center(project(width_center)?, 14.0),
|
||||||
|
offset_from_center(project(height_center)?, 18.0),
|
||||||
|
))
|
||||||
});
|
});
|
||||||
let boxes: Vec<crate::ui::overlay::DynBox> = tab
|
let boxes: Vec<crate::ui::overlay::DynBox> = tab
|
||||||
.dyn_fields
|
.dyn_fields
|
||||||
|
|||||||
+10
-2
@@ -3051,10 +3051,18 @@ impl DynInputCanvas {
|
|||||||
}),
|
}),
|
||||||
DynRole::X | DynRole::Width => Point {
|
DynRole::X | DynRole::Width => Point {
|
||||||
x: (base.x + cursor.x) * 0.5,
|
x: (base.x + cursor.x) * 0.5,
|
||||||
y: base.y + 14.0,
|
y: if self.guide == DynGuide::RectSides {
|
||||||
|
base.y - (cursor.y - base.y).signum() * 14.0
|
||||||
|
} else {
|
||||||
|
base.y + 14.0
|
||||||
|
},
|
||||||
},
|
},
|
||||||
DynRole::Y | DynRole::Height => Point {
|
DynRole::Y | DynRole::Height => Point {
|
||||||
x: corner.x + 18.0,
|
x: if self.guide == DynGuide::RectSides {
|
||||||
|
corner.x + (cursor.x - base.x).signum() * 18.0
|
||||||
|
} else {
|
||||||
|
corner.x + 18.0
|
||||||
|
},
|
||||||
y: (base.y + cursor.y) * 0.5,
|
y: (base.y + cursor.y) * 0.5,
|
||||||
},
|
},
|
||||||
// Perpendicular measure: on the measured segment / dim line.
|
// Perpendicular measure: on the measured segment / dim line.
|
||||||
|
|||||||
Reference in new issue
Block a user