mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 18:27:58 -06:00
Modified mouse events handling for gizmobar
The gizmobar was consuming the mouse up event preventing the gizmos to update their tooltip The gizmobar was also consuming the mouse dragging event transforming a gizmo manipulation into a scene rotation
This commit is contained in:
parent
966b2ce371
commit
2501cf64c0
2 changed files with 134 additions and 0 deletions
|
@ -456,6 +456,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
int selected_object_idx = selection.get_object_idx();
|
||||
bool processed = false;
|
||||
|
||||
#if !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
// mouse anywhere
|
||||
if (!evt.Dragging() && !evt.Leaving() && !evt.Entering() && (m_mouse_capture.parent != nullptr))
|
||||
{
|
||||
|
@ -465,10 +466,81 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
m_mouse_capture.reset();
|
||||
}
|
||||
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
|
||||
// mouse anywhere
|
||||
if (evt.Moving())
|
||||
m_tooltip = update_hover_state(mouse_pos);
|
||||
#if ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
else if (evt.LeftUp())
|
||||
{
|
||||
if (m_mouse_capture.left)
|
||||
{
|
||||
processed = true;
|
||||
m_mouse_capture.left = false;
|
||||
}
|
||||
else if (is_dragging())
|
||||
{
|
||||
switch (m_current) {
|
||||
case Move: m_parent.do_move(L("Gizmo-Move")); break;
|
||||
case Scale: m_parent.do_scale(L("Gizmo-Scale")); break;
|
||||
case Rotate: m_parent.do_rotate(L("Gizmo-Rotate")); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
stop_dragging();
|
||||
update_data();
|
||||
|
||||
wxGetApp().obj_manipul()->set_dirty();
|
||||
// Let the plater know that the dragging finished, so a delayed refresh
|
||||
// of the scene with the background processing data should be performed.
|
||||
m_parent.post_event(SimpleEvent(EVT_GLCANVAS_MOUSE_DRAGGING_FINISHED));
|
||||
// updates camera target constraints
|
||||
m_parent.refresh_camera_scene_box();
|
||||
|
||||
processed = true;
|
||||
}
|
||||
// else
|
||||
// return false;
|
||||
}
|
||||
else if (evt.MiddleUp())
|
||||
{
|
||||
if (m_mouse_capture.middle)
|
||||
{
|
||||
processed = true;
|
||||
m_mouse_capture.middle = false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else if (evt.RightUp())
|
||||
{
|
||||
if (pending_right_up)
|
||||
{
|
||||
pending_right_up = false;
|
||||
return true;
|
||||
}
|
||||
if (m_mouse_capture.right)
|
||||
{
|
||||
processed = true;
|
||||
m_mouse_capture.right = false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#if ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
else if (evt.Dragging() && !is_dragging())
|
||||
#else
|
||||
else if (evt.Dragging()))
|
||||
#endif // ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
{
|
||||
if (m_mouse_capture.any())
|
||||
// if the button down was done on this toolbar, prevent from dragging into the scene
|
||||
processed = true;
|
||||
// else
|
||||
// return false;
|
||||
}
|
||||
#else
|
||||
else if (evt.LeftUp())
|
||||
m_mouse_capture.left = false;
|
||||
else if (evt.MiddleUp())
|
||||
|
@ -485,6 +557,55 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
else if (evt.Dragging() && m_mouse_capture.any())
|
||||
// if the button down was done on this toolbar, prevent from dragging into the scene
|
||||
processed = true;
|
||||
#endif // ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
#if ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
else if (evt.Dragging() && is_dragging())
|
||||
{
|
||||
if (!m_parent.get_wxglcanvas()->HasCapture())
|
||||
m_parent.get_wxglcanvas()->CaptureMouse();
|
||||
|
||||
m_parent.set_mouse_as_dragging();
|
||||
update(m_parent.mouse_ray(pos), pos);
|
||||
|
||||
switch (m_current)
|
||||
{
|
||||
case Move:
|
||||
{
|
||||
// Apply new temporary offset
|
||||
selection.translate(get_displacement());
|
||||
wxGetApp().obj_manipul()->set_dirty();
|
||||
break;
|
||||
}
|
||||
case Scale:
|
||||
{
|
||||
// Apply new temporary scale factors
|
||||
TransformationType transformation_type(TransformationType::Local_Absolute_Joint);
|
||||
if (evt.AltDown())
|
||||
transformation_type.set_independent();
|
||||
selection.scale(get_scale(), transformation_type);
|
||||
if (evt.ControlDown())
|
||||
selection.translate(get_scale_offset(), true);
|
||||
wxGetApp().obj_manipul()->set_dirty();
|
||||
break;
|
||||
}
|
||||
case Rotate:
|
||||
{
|
||||
// Apply new temporary rotations
|
||||
TransformationType transformation_type(TransformationType::World_Relative_Joint);
|
||||
if (evt.AltDown())
|
||||
transformation_type.set_independent();
|
||||
selection.rotate(get_rotation(), transformation_type);
|
||||
wxGetApp().obj_manipul()->set_dirty();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_parent.set_as_dirty();
|
||||
processed = true;
|
||||
}
|
||||
#endif // ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
|
||||
if (get_gizmo_idx_from_mouse(mouse_pos) == Undefined)
|
||||
{
|
||||
|
@ -527,6 +648,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
m_parent.set_as_dirty();
|
||||
processed = true;
|
||||
}
|
||||
#if !ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
else if (evt.Dragging() && is_dragging())
|
||||
{
|
||||
if (!m_parent.get_wxglcanvas()->HasCapture())
|
||||
|
@ -573,6 +695,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
m_parent.set_as_dirty();
|
||||
processed = true;
|
||||
}
|
||||
#endif // !ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||
#if !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
else if (evt.LeftUp() && is_dragging())
|
||||
{
|
||||
switch (m_current) {
|
||||
|
@ -594,6 +718,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
|
||||
processed = true;
|
||||
}
|
||||
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
else if (evt.LeftUp() && (m_current == SlaSupports || m_current == Hollow) && !m_parent.is_mouse_dragging())
|
||||
{
|
||||
// in case SLA gizmo is selected, we just pass the LeftUp event and stop processing - neither
|
||||
|
@ -632,8 +757,10 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
|||
m_mouse_capture.right = true;
|
||||
m_mouse_capture.parent = &m_parent;
|
||||
}
|
||||
#if !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
else if (evt.LeftUp())
|
||||
processed = true;
|
||||
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||
}
|
||||
|
||||
return processed;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue