forked from 1b-agent/opencadstudio-upstream
feat(grip): value-prompt actions Lengthen/Radius/Arc Length
Lengthen / Radius / Arc Length need a number after the pick. Stash `grip_pending` on the picked action, push prompt to command line, route next `CommandSubmit` parse into `apply_grip_menu_value`. Escape cancels. - `Grippable::grip_menu_value_prompt` returns label when action wants value; `apply_grip_menu_value` runs the edit. Dispatched via `EntityTypeOps`. - Line: Lengthen extends either endpoint along line direction. - Arc: Radius sets radius; Arc Length redrives end angle from `value / radius`; Lengthen extends start / end angle the same way.
This commit is contained in:
1 parent
86ca1b7033
commit
559cd76369
5 files changed
+243
-5
No files matched your search
@@ -35,6 +35,28 @@ pub trait Grippable {
|
||||
/// Entities override this to mutate themselves when the user picks
|
||||
/// Add Vertex / Remove Vertex / Convert / Reverse / …
|
||||
fn apply_grip_menu(&mut self, _grip_id: usize, _action: GripMenuAction) {}
|
||||
/// Same as `apply_grip_menu` but for actions that need a numeric
|
||||
/// follow-up (Lengthen / Radius / Arc Length / Rotate Text / …).
|
||||
/// The app prompts the user for a value on the command line and
|
||||
/// calls this with the parsed `f64`.
|
||||
fn apply_grip_menu_value(
|
||||
&mut self,
|
||||
_grip_id: usize,
|
||||
_action: GripMenuAction,
|
||||
_value: f64,
|
||||
) {}
|
||||
/// If the popup action this entity defines for `grip_id` needs a
|
||||
/// numeric prompt, return the prompt string and the action so the
|
||||
/// app can stash a pending-value state and route the next typed
|
||||
/// number into `apply_grip_menu_value`. `None` for one-shot
|
||||
/// actions handled by `apply_grip_menu`.
|
||||
fn grip_menu_value_prompt(
|
||||
&self,
|
||||
_grip_id: usize,
|
||||
_action: GripMenuAction,
|
||||
) -> Option<&'static str> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PropertyEditable {
|
||||
@@ -78,6 +100,17 @@ pub trait EntityTypeOps {
|
||||
fn apply_geom_prop(&mut self, field: &str, value: &str);
|
||||
fn apply_grip(&mut self, grip_id: usize, apply: GripApply);
|
||||
fn apply_grip_menu(&mut self, grip_id: usize, action: GripMenuAction);
|
||||
fn grip_menu_value_prompt(
|
||||
&self,
|
||||
grip_id: usize,
|
||||
action: GripMenuAction,
|
||||
) -> Option<&'static str>;
|
||||
fn apply_grip_menu_value(
|
||||
&mut self,
|
||||
grip_id: usize,
|
||||
action: GripMenuAction,
|
||||
value: f64,
|
||||
);
|
||||
fn apply_transform(&mut self, t: &EntityTransform);
|
||||
fn mass_props(&self) -> Option<MassProps>;
|
||||
fn text_content(&self) -> Option<String>;
|
||||
@@ -287,6 +320,47 @@ impl EntityTypeOps for EntityType {
|
||||
)
|
||||
}
|
||||
|
||||
fn grip_menu_value_prompt(
|
||||
&self,
|
||||
grip_id: usize,
|
||||
action: GripMenuAction,
|
||||
) -> Option<&'static str> {
|
||||
dispatch!(self,
|
||||
|e| Grippable::grip_menu_value_prompt(e, grip_id, action),
|
||||
[
|
||||
Line, Circle, Arc, Ellipse, LwPolyline, Polyline, Polyline2D,
|
||||
Polyline3D, Ray, XLine, RasterImage, Wipeout,
|
||||
AttributeDefinition, AttributeEntity, MLine, Tolerance,
|
||||
Solid, Solid3D, Region, Body, Face3D, PolygonMesh,
|
||||
PolyfaceMesh, Mesh, Table, Point, Spline, Text, MText,
|
||||
Viewport, Insert, Leader, MultiLeader, Dimension, Hatch,
|
||||
Underlay, Shape, Ole2Frame,
|
||||
],
|
||||
_ => None,
|
||||
)
|
||||
}
|
||||
|
||||
fn apply_grip_menu_value(
|
||||
&mut self,
|
||||
grip_id: usize,
|
||||
action: GripMenuAction,
|
||||
value: f64,
|
||||
) {
|
||||
dispatch!(self,
|
||||
|e| Grippable::apply_grip_menu_value(e, grip_id, action, value),
|
||||
[
|
||||
Line, Circle, Arc, Ellipse, LwPolyline, Polyline, Polyline2D,
|
||||
Polyline3D, Ray, XLine, RasterImage, Wipeout,
|
||||
AttributeDefinition, AttributeEntity, MLine, Tolerance,
|
||||
Solid, Solid3D, Region, Body, Face3D, PolygonMesh,
|
||||
PolyfaceMesh, Mesh, Table, Point, Spline, Text, MText,
|
||||
Viewport, Insert, Leader, MultiLeader, Dimension, Hatch,
|
||||
Underlay, Shape, Ole2Frame,
|
||||
],
|
||||
_ => {},
|
||||
)
|
||||
}
|
||||
|
||||
fn apply_transform(&mut self, t: &EntityTransform) {
|
||||
dispatch!(self,
|
||||
|e| Transformable::apply_transform(e, t),
|
||||
|
||||
Reference in new issue
Block a user