Fix properties deselect (#606)
* Fix properties panel deselect * Fix arrow cursors on select tool * Fix drag from UI to document causing mouse down * Fix tests * Cleanup
This commit is contained in:
parent
f38289f036
commit
ec43b7945e
|
|
@ -148,6 +148,7 @@ impl<'a> MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageHandlerDat
|
||||||
}
|
}
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
|
self.active_selection = None;
|
||||||
}
|
}
|
||||||
ModifyFont {
|
ModifyFont {
|
||||||
font_family,
|
font_family,
|
||||||
|
|
@ -231,11 +232,12 @@ impl<'a> MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageHandlerDat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ResendActiveProperties => {
|
ResendActiveProperties => {
|
||||||
let (path, target_document) = self.active_selection.clone().expect("Received update for properties panel with no active layer");
|
if let Some((path, target_document)) = self.active_selection.clone() {
|
||||||
let layer = get_document(target_document).layer(&path).unwrap();
|
let layer = get_document(target_document).layer(&path).unwrap();
|
||||||
match target_document {
|
match target_document {
|
||||||
TargetDocument::Artboard => register_artboard_layer_properties(layer, responses, &get_document(target_document).font_cache),
|
TargetDocument::Artboard => register_artboard_layer_properties(layer, responses, &get_document(target_document).font_cache),
|
||||||
TargetDocument::Artwork => register_artwork_layer_properties(layer, responses, &get_document(target_document).font_cache),
|
TargetDocument::Artwork => register_artwork_layer_properties(layer, responses, &get_document(target_document).font_cache),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
|
||||||
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
|
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
|
||||||
self.mouse.position = mouse_state.position;
|
self.mouse.position = mouse_state.position;
|
||||||
|
|
||||||
self.translate_mouse_event(mouse_state, responses);
|
self.translate_mouse_event(mouse_state, true, responses);
|
||||||
}
|
}
|
||||||
InputPreprocessorMessage::PointerMove { editor_mouse_state, modifier_keys } => {
|
InputPreprocessorMessage::PointerMove { editor_mouse_state, modifier_keys } => {
|
||||||
self.handle_modifier_keys(modifier_keys, responses);
|
self.handle_modifier_keys(modifier_keys, responses);
|
||||||
|
|
@ -94,7 +94,7 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
|
||||||
responses.push_back(InputMapperMessage::PointerMove.into());
|
responses.push_back(InputMapperMessage::PointerMove.into());
|
||||||
|
|
||||||
// While any pointer button is already down, additional button down events are not reported, but they are sent as `pointermove` events
|
// While any pointer button is already down, additional button down events are not reported, but they are sent as `pointermove` events
|
||||||
self.translate_mouse_event(mouse_state, responses);
|
self.translate_mouse_event(mouse_state, false, responses);
|
||||||
}
|
}
|
||||||
InputPreprocessorMessage::PointerUp { editor_mouse_state, modifier_keys } => {
|
InputPreprocessorMessage::PointerUp { editor_mouse_state, modifier_keys } => {
|
||||||
self.handle_modifier_keys(modifier_keys, responses);
|
self.handle_modifier_keys(modifier_keys, responses);
|
||||||
|
|
@ -102,7 +102,7 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
|
||||||
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
|
let mouse_state = editor_mouse_state.to_mouse_state(&self.viewport_bounds);
|
||||||
self.mouse.position = mouse_state.position;
|
self.mouse.position = mouse_state.position;
|
||||||
|
|
||||||
self.translate_mouse_event(mouse_state, responses);
|
self.translate_mouse_event(mouse_state, false, responses);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -114,12 +114,12 @@ impl MessageHandler<InputPreprocessorMessage, ()> for InputPreprocessorMessageHa
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputPreprocessorMessageHandler {
|
impl InputPreprocessorMessageHandler {
|
||||||
fn translate_mouse_event(&mut self, new_state: MouseState, responses: &mut VecDeque<Message>) {
|
fn translate_mouse_event(&mut self, new_state: MouseState, allow_first_button_down: bool, responses: &mut VecDeque<Message>) {
|
||||||
for (bit_flag, key) in [(MouseKeys::LEFT, Key::Lmb), (MouseKeys::RIGHT, Key::Rmb), (MouseKeys::MIDDLE, Key::Mmb)] {
|
for (bit_flag, key) in [(MouseKeys::LEFT, Key::Lmb), (MouseKeys::RIGHT, Key::Rmb), (MouseKeys::MIDDLE, Key::Mmb)] {
|
||||||
// Calculate the intersection between the two key states
|
// Calculate the intersection between the two key states
|
||||||
let old_down = self.mouse.mouse_keys & bit_flag == bit_flag;
|
let old_down = self.mouse.mouse_keys & bit_flag == bit_flag;
|
||||||
let new_down = new_state.mouse_keys & bit_flag == bit_flag;
|
let new_down = new_state.mouse_keys & bit_flag == bit_flag;
|
||||||
if !old_down && new_down {
|
if !old_down && new_down && (allow_first_button_down || self.mouse.mouse_keys != MouseKeys::NONE) {
|
||||||
responses.push_back(InputMapperMessage::KeyDown(key).into());
|
responses.push_back(InputMapperMessage::KeyDown(key).into());
|
||||||
}
|
}
|
||||||
if old_down && !new_down {
|
if old_down && !new_down {
|
||||||
|
|
|
||||||
|
|
@ -108,10 +108,8 @@ export function createInputManager(editor: EditorState, container: HTMLElement,
|
||||||
const onPointerMove = (e: PointerEvent): void => {
|
const onPointerMove = (e: PointerEvent): void => {
|
||||||
if (!e.buttons) viewportPointerInteractionOngoing = false;
|
if (!e.buttons) viewportPointerInteractionOngoing = false;
|
||||||
|
|
||||||
if (viewportPointerInteractionOngoing) {
|
const modifiers = makeModifiersBitfield(e);
|
||||||
const modifiers = makeModifiersBitfield(e);
|
editor.instance.on_mouse_move(e.clientX, e.clientY, e.buttons, modifiers);
|
||||||
editor.instance.on_mouse_move(e.clientX, e.clientY, e.buttons, modifiers);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onPointerDown = (e: PointerEvent): void => {
|
const onPointerDown = (e: PointerEvent): void => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue