mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 05:37:52 -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
|
@ -68,9 +68,16 @@
|
||||||
|
|
||||||
// Enable tooltips for GLCanvas3D using ImGUI
|
// Enable tooltips for GLCanvas3D using ImGUI
|
||||||
#define ENABLE_CANVAS_TOOLTIP_USING_IMGUI (1 && ENABLE_2_2_0_FINAL)
|
#define ENABLE_CANVAS_TOOLTIP_USING_IMGUI (1 && ENABLE_2_2_0_FINAL)
|
||||||
|
// Enable constraining tooltips for GLCanvas3D using ImGUI into canvas area
|
||||||
#define ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
#define ENABLE_CANVAS_CONSTRAINED_TOOLTIP_USING_IMGUI (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
||||||
|
// Enable delay for showing tooltips for GLCanvas3D using ImGUI
|
||||||
#define ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
#define ENABLE_CANVAS_DELAYED_TOOLTIP_USING_IMGUI (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
||||||
|
// Enable modified mouse events handling for toolbars
|
||||||
#define ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
#define ENABLE_MODIFIED_TOOLBAR_MOUSE_EVENT_HANDLING (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
||||||
|
// Enable modified mouse events handling for gizmobar
|
||||||
|
#define ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING (1 && ENABLE_CANVAS_TOOLTIP_USING_IMGUI)
|
||||||
|
// Enable fix for dragging mouse event handling for gizmobar
|
||||||
|
#define ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX (1 && ENABLE_2_2_0_FINAL)
|
||||||
|
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
|
@ -456,6 +456,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
int selected_object_idx = selection.get_object_idx();
|
int selected_object_idx = selection.get_object_idx();
|
||||||
bool processed = false;
|
bool processed = false;
|
||||||
|
|
||||||
|
#if !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
// mouse anywhere
|
// mouse anywhere
|
||||||
if (!evt.Dragging() && !evt.Leaving() && !evt.Entering() && (m_mouse_capture.parent != nullptr))
|
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();
|
m_mouse_capture.reset();
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
|
|
||||||
// mouse anywhere
|
// mouse anywhere
|
||||||
if (evt.Moving())
|
if (evt.Moving())
|
||||||
m_tooltip = update_hover_state(mouse_pos);
|
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())
|
else if (evt.LeftUp())
|
||||||
m_mouse_capture.left = false;
|
m_mouse_capture.left = false;
|
||||||
else if (evt.MiddleUp())
|
else if (evt.MiddleUp())
|
||||||
|
@ -485,48 +557,8 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
else if (evt.Dragging() && m_mouse_capture.any())
|
else if (evt.Dragging() && m_mouse_capture.any())
|
||||||
// if the button down was done on this toolbar, prevent from dragging into the scene
|
// if the button down was done on this toolbar, prevent from dragging into the scene
|
||||||
processed = true;
|
processed = true;
|
||||||
|
#endif // ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
if (get_gizmo_idx_from_mouse(mouse_pos) == Undefined)
|
#if ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||||
{
|
|
||||||
// mouse is outside the toolbar
|
|
||||||
m_tooltip = "";
|
|
||||||
|
|
||||||
if (evt.LeftDown())
|
|
||||||
{
|
|
||||||
if ((m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::LeftDown, mouse_pos, evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
|
|
||||||
// the gizmo got the event and took some action, there is no need to do anything more
|
|
||||||
processed = true;
|
|
||||||
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
|
||||||
update_data();
|
|
||||||
selection.start_dragging();
|
|
||||||
start_dragging();
|
|
||||||
|
|
||||||
if (m_current == Flatten) {
|
|
||||||
// Rotate the object so the normal points downward:
|
|
||||||
m_parent.do_flatten(get_flattening_normal(), L("Gizmo-Place on Face"));
|
|
||||||
wxGetApp().obj_manipul()->set_dirty();
|
|
||||||
}
|
|
||||||
|
|
||||||
m_parent.set_as_dirty();
|
|
||||||
processed = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (evt.RightDown() && (selected_object_idx != -1) && (m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::RightDown))
|
|
||||||
{
|
|
||||||
// we need to set the following right up as processed to avoid showing the context menu if the user release the mouse over the object
|
|
||||||
pending_right_up = true;
|
|
||||||
// event was taken care of by the SlaSupports gizmo
|
|
||||||
processed = true;
|
|
||||||
}
|
|
||||||
else if (evt.Dragging() && (m_parent.get_move_volume_id() != -1) && (m_current == SlaSupports || m_current == Hollow))
|
|
||||||
// don't allow dragging objects with the Sla gizmo on
|
|
||||||
processed = true;
|
|
||||||
else if (evt.Dragging() && (m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::Dragging, mouse_pos, evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
|
|
||||||
{
|
|
||||||
// the gizmo got the event and took some action, no need to do anything more here
|
|
||||||
m_parent.set_as_dirty();
|
|
||||||
processed = true;
|
|
||||||
}
|
|
||||||
else if (evt.Dragging() && is_dragging())
|
else if (evt.Dragging() && is_dragging())
|
||||||
{
|
{
|
||||||
if (!m_parent.get_wxglcanvas()->HasCapture())
|
if (!m_parent.get_wxglcanvas()->HasCapture())
|
||||||
|
@ -573,6 +605,98 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
m_parent.set_as_dirty();
|
m_parent.set_as_dirty();
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GIZMO_TOOLBAR_DRAGGING_FIX
|
||||||
|
|
||||||
|
if (get_gizmo_idx_from_mouse(mouse_pos) == Undefined)
|
||||||
|
{
|
||||||
|
// mouse is outside the toolbar
|
||||||
|
m_tooltip = "";
|
||||||
|
|
||||||
|
if (evt.LeftDown())
|
||||||
|
{
|
||||||
|
if ((m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::LeftDown, mouse_pos, evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
|
||||||
|
// the gizmo got the event and took some action, there is no need to do anything more
|
||||||
|
processed = true;
|
||||||
|
else if (!selection.is_empty() && grabber_contains_mouse()) {
|
||||||
|
update_data();
|
||||||
|
selection.start_dragging();
|
||||||
|
start_dragging();
|
||||||
|
|
||||||
|
if (m_current == Flatten) {
|
||||||
|
// Rotate the object so the normal points downward:
|
||||||
|
m_parent.do_flatten(get_flattening_normal(), L("Gizmo-Place on Face"));
|
||||||
|
wxGetApp().obj_manipul()->set_dirty();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_parent.set_as_dirty();
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (evt.RightDown() && (selected_object_idx != -1) && (m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::RightDown))
|
||||||
|
{
|
||||||
|
// we need to set the following right up as processed to avoid showing the context menu if the user release the mouse over the object
|
||||||
|
pending_right_up = true;
|
||||||
|
// event was taken care of by the SlaSupports gizmo
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
else if (evt.Dragging() && (m_parent.get_move_volume_id() != -1) && (m_current == SlaSupports || m_current == Hollow))
|
||||||
|
// don't allow dragging objects with the Sla gizmo on
|
||||||
|
processed = true;
|
||||||
|
else if (evt.Dragging() && (m_current == SlaSupports || m_current == Hollow) && gizmo_event(SLAGizmoEventType::Dragging, mouse_pos, evt.ShiftDown(), evt.AltDown(), evt.ControlDown()))
|
||||||
|
{
|
||||||
|
// the gizmo got the event and took some action, no need to do anything more here
|
||||||
|
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())
|
||||||
|
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 !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
else if (evt.LeftUp() && is_dragging())
|
else if (evt.LeftUp() && is_dragging())
|
||||||
{
|
{
|
||||||
switch (m_current) {
|
switch (m_current) {
|
||||||
|
@ -594,6 +718,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||||
|
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
else if (evt.LeftUp() && (m_current == SlaSupports || m_current == Hollow) && !m_parent.is_mouse_dragging())
|
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
|
// 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.right = true;
|
||||||
m_mouse_capture.parent = &m_parent;
|
m_mouse_capture.parent = &m_parent;
|
||||||
}
|
}
|
||||||
|
#if !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
else if (evt.LeftUp())
|
else if (evt.LeftUp())
|
||||||
processed = true;
|
processed = true;
|
||||||
|
#endif // !ENABLE_MODIFIED_GIZMOBAR_MOUSE_EVENT_HANDLING
|
||||||
}
|
}
|
||||||
|
|
||||||
return processed;
|
return processed;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue