Double click on a SimpleShape to path edit (#507)
This commit is contained in:
parent
599a9d076b
commit
492025e79b
|
|
@ -46,7 +46,7 @@ impl Default for Mapping {
|
||||||
entry! {action=SelectMessage::MouseMove { axis_align: KeyShift, snap_angle: KeyControl }, message=InputMapperMessage::PointerMove},
|
entry! {action=SelectMessage::MouseMove { axis_align: KeyShift, snap_angle: KeyControl }, message=InputMapperMessage::PointerMove},
|
||||||
entry! {action=SelectMessage::DragStart { add_to_selection: KeyShift }, key_down=Lmb},
|
entry! {action=SelectMessage::DragStart { add_to_selection: KeyShift }, key_down=Lmb},
|
||||||
entry! {action=SelectMessage::DragStop, key_up=Lmb},
|
entry! {action=SelectMessage::DragStop, key_up=Lmb},
|
||||||
entry! {action=SelectMessage::EditText, message=InputMapperMessage::DoubleClick},
|
entry! {action=SelectMessage::EditLayer, message=InputMapperMessage::DoubleClick},
|
||||||
entry! {action=SelectMessage::Abort, key_down=Rmb},
|
entry! {action=SelectMessage::Abort, key_down=Rmb},
|
||||||
entry! {action=SelectMessage::Abort, key_down=KeyEscape},
|
entry! {action=SelectMessage::Abort, key_down=KeyEscape},
|
||||||
// Navigate
|
// Navigate
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use crate::viewport_tools::tool::{DocumentToolData, Fsm, ToolActionHandlerData,
|
||||||
use graphene::color::Color;
|
use graphene::color::Color;
|
||||||
use graphene::document::Document;
|
use graphene::document::Document;
|
||||||
use graphene::intersection::Quad;
|
use graphene::intersection::Quad;
|
||||||
|
use graphene::layers::layer_info::LayerDataType;
|
||||||
use graphene::layers::style::{self, Fill, Stroke};
|
use graphene::layers::style::{self, Fill, Stroke};
|
||||||
use graphene::Operation;
|
use graphene::Operation;
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ pub enum SelectMessage {
|
||||||
add_to_selection: Key,
|
add_to_selection: Key,
|
||||||
},
|
},
|
||||||
DragStop,
|
DragStop,
|
||||||
EditText,
|
EditLayer,
|
||||||
FlipHorizontal,
|
FlipHorizontal,
|
||||||
FlipVertical,
|
FlipVertical,
|
||||||
MouseMove {
|
MouseMove {
|
||||||
|
|
@ -252,11 +253,11 @@ impl<'a> MessageHandler<ToolMessage, ToolActionHandlerData<'a>> for Select {
|
||||||
use SelectToolFsmState::*;
|
use SelectToolFsmState::*;
|
||||||
|
|
||||||
match self.fsm_state {
|
match self.fsm_state {
|
||||||
Ready => actions!(SelectMessageDiscriminant; DragStart, MouseMove, EditText),
|
Ready => actions!(SelectMessageDiscriminant; DragStart, MouseMove, EditLayer),
|
||||||
Dragging => actions!(SelectMessageDiscriminant; DragStop, MouseMove, EditText),
|
Dragging => actions!(SelectMessageDiscriminant; DragStop, MouseMove, EditLayer),
|
||||||
DrawingBox => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditText),
|
DrawingBox => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditLayer),
|
||||||
ResizingBounds => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditText),
|
ResizingBounds => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditLayer),
|
||||||
RotatingBounds => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditText),
|
RotatingBounds => actions!(SelectMessageDiscriminant; DragStop, MouseMove, Abort, EditLayer),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -553,20 +554,22 @@ impl Fsm for SelectToolFsmState {
|
||||||
buffer.into_iter().rev().for_each(|message| responses.push_front(message));
|
buffer.into_iter().rev().for_each(|message| responses.push_front(message));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
(_, EditText) => {
|
(_, EditLayer) => {
|
||||||
let mouse_pos = input.mouse.position;
|
let mouse_pos = input.mouse.position;
|
||||||
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
let tolerance = DVec2::splat(SELECTION_TOLERANCE);
|
||||||
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
let quad = Quad::from_box([mouse_pos - tolerance, mouse_pos + tolerance]);
|
||||||
|
|
||||||
if document
|
if let Some(Ok(intersect)) = document.graphene_document.intersects_quad_root(quad).last().map(|path| document.graphene_document.layer(path)) {
|
||||||
.graphene_document
|
match intersect.data {
|
||||||
.intersects_quad_root(quad)
|
LayerDataType::Text(_) => {
|
||||||
.last()
|
responses.push_front(ToolMessage::ActivateTool { tool_type: ToolType::Text }.into());
|
||||||
.map(|l| document.graphene_document.layer(l).map(|l| l.as_text().is_ok()).unwrap_or(false))
|
responses.push_back(TextMessage::Interact.into());
|
||||||
.unwrap_or(false)
|
}
|
||||||
{
|
LayerDataType::Shape(_) => {
|
||||||
responses.push_front(ToolMessage::ActivateTool { tool_type: ToolType::Text }.into());
|
responses.push_front(ToolMessage::ActivateTool { tool_type: ToolType::Path }.into());
|
||||||
responses.push_back(TextMessage::Interact.into());
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue