Added Esc shortcut and menu item for command deselect all

This commit is contained in:
Enrico Turri 2019-05-14 11:57:39 +02:00
parent c4c292168d
commit 14c4469cbf
10 changed files with 55 additions and 18 deletions

View file

@ -59,4 +59,12 @@
#define ENABLE_SVG_ICONS (1 && ENABLE_1_42_0_ALPHA8 && ENABLE_TEXTURES_FROM_SVG)
//====================
// 1.42.0.rc techs
//====================
#define ENABLE_1_42_0_RC 1
// Disables Edit->Deselect all item menu item
#define DISABLE_DESELECT_ALL_MENU_ITEM (1 && ENABLE_1_42_0_RC)
#endif // _technologies_h_

View file

@ -1715,6 +1715,16 @@ void GLCanvas3D::select_all()
m_dirty = true;
}
void GLCanvas3D::deselect_all()
{
m_selection.clear();
m_selection.set_mode(Selection::Instance);
wxGetApp().obj_manipul()->set_dirty();
m_gizmos.reset_all_states();
m_gizmos.update_data(*this);
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
}
void GLCanvas3D::delete_selected()
{
m_selection.erase();
@ -2359,6 +2369,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE));
break;
case WXK_ESCAPE: { deselect_all(); break; }
case '0': { select_view("iso"); break; }
case '1': { select_view("top"); break; }
case '2': { select_view("bottom"); break; }
@ -2379,11 +2390,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
case 'o': { set_camera_zoom(-1.0f); break; }
case 'Z':
case 'z': { m_selection.is_empty() ? zoom_to_volumes() : zoom_to_selection(); break; }
default:
{
evt.Skip();
break;
}
default: { evt.Skip(); break; }
}
}
}
@ -2900,14 +2907,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
{
// deselect and propagate event through callback
if (!evt.ShiftDown() && m_picking_enabled)
{
m_selection.clear();
m_selection.set_mode(Selection::Instance);
wxGetApp().obj_manipul()->set_dirty();
m_gizmos.reset_all_states();
m_gizmos.update_data(*this);
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
}
deselect_all();
}
else if (evt.LeftUp() && m_mouse.dragging)
// Flips X mouse deltas if bed is upside down

View file

@ -555,6 +555,7 @@ public:
void render();
void select_all();
void deselect_all();
void delete_selected();
void ensure_on_bed(unsigned int object_idx);

View file

@ -99,6 +99,12 @@ void View3D::select_all()
m_canvas->select_all();
}
void View3D::deselect_all()
{
if (m_canvas != nullptr)
m_canvas->deselect_all();
}
void View3D::delete_selected()
{
if (m_canvas != nullptr)

View file

@ -47,6 +47,7 @@ public:
void select_view(const std::string& direction);
void select_all();
void deselect_all();
void delete_selected();
void mirror_selection(Axis axis);

View file

@ -789,11 +789,14 @@ bool GLGizmosManager::on_char(wxKeyEvent& evt, GLCanvas3D& canvas)
{
// key ESC
case WXK_ESCAPE:
{
if (m_current != Undefined)
{
if ((m_current != SlaSupports) || !gizmo_event(SLAGizmoEventType::DiscardChanges))
reset_all_states();
processed = true;
}
break;
}
case WXK_RETURN:

View file

@ -267,6 +267,11 @@ bool MainFrame::can_select() const
return (m_plater != nullptr) && !m_plater->model().objects.empty();
}
bool MainFrame::can_deselect() const
{
return (m_plater != nullptr) && !m_plater->is_selection_empty();
}
bool MainFrame::can_delete() const
{
return (m_plater != nullptr) && !m_plater->is_selection_empty();
@ -449,6 +454,11 @@ void MainFrame::init_menubar()
append_menu_item(editMenu, wxID_ANY, _(L("&Select all")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "A",
_(L("Selects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->select_all(); },
"", nullptr, [this](){return can_select(); }, this);
#if !DISABLE_DESELECT_ALL_MENU_ITEM
append_menu_item(editMenu, wxID_ANY, _(L("D&eselect all")) + sep + GUI::shortkey_ctrl_prefix() + sep + "Esc",
_(L("Deselects all objects")), [this](wxCommandEvent&) { if (m_plater != nullptr) m_plater->deselect_all(); },
"", nullptr, [this](){return can_deselect(); }, this);
#endif // !DISABLE_DESELECT_ALL_MENU_ITEM
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("&Delete selected")) + sep + hotkey_delete,
_(L("Deletes the current selection")),[this](wxCommandEvent&) { m_plater->remove_selected(); },
@ -458,7 +468,6 @@ void MainFrame::init_menubar()
menu_icon("delete_all_menu"), nullptr, [this](){return can_delete_all(); }, this);
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("&Copy")) + sep + GUI::shortkey_ctrl_prefix() + sep_space + "C",
_(L("Copy selection to clipboard")), [this](wxCommandEvent&) { m_plater->copy_selection_to_clipboard(); },
menu_icon("copy_menu"), nullptr, [this](){return m_plater->can_copy(); }, this);

View file

@ -68,6 +68,7 @@ class MainFrame : public DPIFrame
bool can_slice() const;
bool can_change_view() const;
bool can_select() const;
bool can_deselect() const;
bool can_delete() const;
bool can_delete_all() const;

View file

@ -1261,6 +1261,7 @@ struct Plater::priv
void object_list_changed();
void select_all();
void deselect_all();
void remove(size_t obj_idx);
void delete_object_from_model(size_t obj_idx);
void reset();
@ -2032,6 +2033,11 @@ void Plater::priv::select_all()
this->sidebar->obj_list()->update_selections();
}
void Plater::priv::deselect_all()
{
view3D->deselect_all();
}
void Plater::priv::remove(size_t obj_idx)
{
// Prevent toolpaths preview from rendering while we modify the Print object
@ -3303,6 +3309,7 @@ void Plater::select_view(const std::string& direction) { p->select_view(directio
void Plater::select_view_3D(const std::string& name) { p->select_view_3D(name); }
void Plater::select_all() { p->select_all(); }
void Plater::deselect_all() { p->deselect_all(); }
void Plater::remove(size_t obj_idx) { p->remove(obj_idx); }
void Plater::reset() { p->reset(); }

View file

@ -152,6 +152,7 @@ public:
void update_ui_from_settings();
void select_all();
void deselect_all();
void remove(size_t obj_idx);
void reset();
void reset_with_confirm();