Tech ENABLE_OBJECT_MANIPULATOR_FOCUS - 1st installment - Do not automatically set focus on 3D scene while hovering on it while the focus is into a field of the object manipulator

This commit is contained in:
enricoturri1966 2022-01-17 12:17:59 +01:00
parent 403f6d45f9
commit cfe8aa4818
3 changed files with 36 additions and 1 deletions

View file

@ -58,6 +58,8 @@
#define ENABLE_PREVIEW_LAYER_TIME (1 && ENABLE_2_5_0_ALPHA1)
// Enable showing time estimate for travel moves in legend
#define ENABLE_TRAVEL_TIME (1 && ENABLE_2_5_0_ALPHA1)
// Enable not killing focus in object manipulator fields when hovering over 3D scene
#define ENABLE_OBJECT_MANIPULATOR_FOCUS (1 && ENABLE_2_5_0_ALPHA1)
#endif // _prusaslicer_technologies_h_

View file

@ -2934,6 +2934,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
m_mouse.set_start_position_3D_as_invalid();
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
handle_sidebar_focus_event("", false);
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
return;
}
@ -2941,6 +2944,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
m_mouse.set_start_position_3D_as_invalid();
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
handle_sidebar_focus_event("", false);
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
return;
}
@ -2948,6 +2954,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
m_mouse.set_start_position_3D_as_invalid();
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
handle_sidebar_focus_event("", false);
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
return;
}
@ -2955,6 +2964,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
m_mouse.set_start_position_3D_as_invalid();
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
handle_sidebar_focus_event("", false);
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
return;
}
@ -3008,6 +3020,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
}
}
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
handle_sidebar_focus_event("", false);
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
return;
}
@ -3022,15 +3037,27 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
m_mouse.set_move_start_threshold_position_2D_as_invalid();
}
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
if (evt.ButtonDown()) {
handle_sidebar_focus_event("", false);
if (wxWindow::FindFocus() != m_canvas)
// Grab keyboard focus on any mouse click event.
m_canvas->SetFocus();
}
#else
if (evt.ButtonDown() && wxWindow::FindFocus() != m_canvas)
// Grab keyboard focus on any mouse click event.
m_canvas->SetFocus();
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
if (evt.Entering()) {
//#if defined(__WXMSW__) || defined(__linux__)
// // On Windows and Linux needs focus in order to catch key events
#if !ENABLE_OBJECT_MANIPULATOR_FOCUS
// Set focus in order to remove it from sidebar fields
#endif // !ENABLE_OBJECT_MANIPULATOR_FOCUS
if (m_canvas != nullptr) {
#if !ENABLE_OBJECT_MANIPULATOR_FOCUS
// Only set focus, if the top level window of this canvas is active.
auto p = dynamic_cast<wxWindow*>(evt.GetEventObject());
while (p->GetParent())
@ -3038,6 +3065,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
auto *top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p);
if (top_level_wnd && top_level_wnd->IsActive())
m_canvas->SetFocus();
#endif // !ENABLE_OBJECT_MANIPULATOR_FOCUS
m_mouse.position = pos.cast<double>();
m_tooltip_enabled = false;
// 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while

View file

@ -1103,9 +1103,14 @@ ManipulationEditor::ManipulationEditor(ObjectManipulation* parent,
{
parent->set_focused_editor(nullptr);
#if ENABLE_OBJECT_MANIPULATOR_FOCUS
// if the widget loosing focus is not a manipulator field, call kill_focus
if (dynamic_cast<ManipulationEditor*>(e.GetWindow()) == nullptr)
#else
if (!m_enter_pressed)
#endif // ENABLE_OBJECT_MANIPULATOR_FOCUS
kill_focus(parent);
e.Skip();
}, this->GetId());