forked from 1b-agent/opencadstudio-upstream
Merge pull request #1251
This commit is contained in:
commit
2d20bdd51c
8 files changed
+864
-42
No files matched your search
@@ -178,6 +178,7 @@ pub enum GripMenuAction {
|
||||
RectangleWidth,
|
||||
RectangleHeight,
|
||||
RectangleResize,
|
||||
MoveParallel,
|
||||
AddVertex,
|
||||
RemoveVertex,
|
||||
ConvertToArc,
|
||||
|
||||
@@ -61,6 +61,22 @@ pub enum GripEditMode {
|
||||
RectangleWidth,
|
||||
RectangleHeight,
|
||||
RectangleResize,
|
||||
MoveParallel,
|
||||
}
|
||||
|
||||
impl GripEditMode {
|
||||
/// Whether typed text belongs in the grip's single dynamic-input field.
|
||||
pub fn uses_scalar_dynamic_input(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::Lengthen
|
||||
| Self::Radius
|
||||
| Self::ArcLength
|
||||
| Self::RectangleWidth
|
||||
| Self::RectangleHeight
|
||||
| Self::MoveParallel
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
@@ -125,6 +141,12 @@ impl GripEdit {
|
||||
edit
|
||||
}
|
||||
|
||||
pub fn move_parallel(handle: Handle, grip_id: usize, world: DVec3) -> Self {
|
||||
let mut edit = Self::single(handle, grip_id, false, world);
|
||||
edit.mode = GripEditMode::MoveParallel;
|
||||
edit
|
||||
}
|
||||
|
||||
pub fn rectangle_resize(
|
||||
handle: Handle,
|
||||
grip_id: usize,
|
||||
@@ -342,3 +364,16 @@ pub fn find_hit_grip_rte(
|
||||
}
|
||||
best
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::GripEditMode;
|
||||
|
||||
#[test]
|
||||
fn scalar_dynamic_input_modes_include_move_parallel() {
|
||||
assert!(GripEditMode::MoveParallel.uses_scalar_dynamic_input());
|
||||
assert!(GripEditMode::Radius.uses_scalar_dynamic_input());
|
||||
assert!(!GripEditMode::Stretch.uses_scalar_dynamic_input());
|
||||
assert!(!GripEditMode::RectangleResize.uses_scalar_dynamic_input());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user