Handling of gizmos related key events moved into new method GLGizmosManager::on_key()
This commit is contained in:
parent
52f11a6f0d
commit
47c39f51e5
@ -2310,18 +2310,22 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
||||
auto imgui = wxGetApp().imgui();
|
||||
if (imgui->update_key_data(evt)) {
|
||||
render();
|
||||
} else
|
||||
if (evt.GetEventType() == wxEVT_KEY_UP) {
|
||||
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
|
||||
// Enable switching between 3D and Preview with Tab
|
||||
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
|
||||
} else if (m_gizmos.get_current_type() == GLGizmosManager::SlaSupports && keyCode == WXK_SHIFT && m_gizmos.gizmo_event(SLAGizmoEventType::ShiftUp)) {
|
||||
// shift has been just released - SLA gizmo might want to close rectangular selection.
|
||||
m_dirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_gizmos.on_key(evt, *this))
|
||||
{
|
||||
if (evt.GetEventType() == wxEVT_KEY_UP) {
|
||||
if (m_tab_down && keyCode == WXK_TAB && !evt.HasAnyModifiers()) {
|
||||
// Enable switching between 3D and Preview with Tab
|
||||
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
|
||||
}
|
||||
}
|
||||
else if (evt.GetEventType() == wxEVT_KEY_DOWN) {
|
||||
m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers();
|
||||
}
|
||||
}
|
||||
} else if (evt.GetEventType() == wxEVT_KEY_DOWN) {
|
||||
m_tab_down = keyCode == WXK_TAB && !evt.HasAnyModifiers();
|
||||
}
|
||||
|
||||
if (keyCode != WXK_TAB
|
||||
|
@ -660,7 +660,6 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
||||
int keyCode = evt.GetKeyCode();
|
||||
int ctrlMask = wxMOD_CONTROL;
|
||||
|
||||
const Selection& selection = canvas.get_selection();
|
||||
bool processed = false;
|
||||
|
||||
if ((evt.GetModifiers() & ctrlMask) != 0)
|
||||
@ -732,7 +731,7 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
||||
|
||||
if (!processed)
|
||||
{
|
||||
if (handle_shortcut(keyCode, selection))
|
||||
if (handle_shortcut(keyCode, canvas.get_selection()))
|
||||
{
|
||||
canvas.update_gizmos_data();
|
||||
processed = true;
|
||||
@ -745,6 +744,24 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
|
||||
return processed;
|
||||
}
|
||||
|
||||
bool GLGizmosManager::on_key(wxKeyEvent& evt, GLCanvas3D& canvas)
|
||||
{
|
||||
const int keyCode = evt.GetKeyCode();
|
||||
bool processed = false;
|
||||
|
||||
if (evt.GetEventType() == wxEVT_KEY_UP)
|
||||
{
|
||||
if ((m_current == SlaSupports) && (keyCode == WXK_SHIFT) && gizmo_event(SLAGizmoEventType::ShiftUp))
|
||||
// shift has been just released - SLA gizmo might want to close rectangular selection.
|
||||
processed = true;
|
||||
}
|
||||
|
||||
if (processed)
|
||||
canvas.set_as_dirty();
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
void GLGizmosManager::reset()
|
||||
{
|
||||
for (GizmosMap::value_type& gizmo : m_gizmos)
|
||||
|
@ -154,6 +154,7 @@ public:
|
||||
|
||||
bool on_mouse(wxMouseEvent& evt, GLCanvas3D& canvas);
|
||||
bool on_char(wxKeyEvent& evt, GLCanvas3D& canvas);
|
||||
bool on_key(wxKeyEvent& evt, GLCanvas3D& canvas);
|
||||
|
||||
private:
|
||||
void reset();
|
||||
|
Loading…
Reference in New Issue
Block a user