From ea5fdcd7b1e5e26e105f078ff78dfb4c18bd7743 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Wed, 4 Nov 2020 16:26:25 +0100 Subject: [PATCH] Removed cog icon from the horizontal slider. + Shortcut "Shift+G" works from the Preview canvas now (not just from the focused slider as before) --- src/slic3r/GUI/DoubleSlider.cpp | 6 ++++++ src/slic3r/GUI/GLCanvas3D.cpp | 14 ++++++++++++++ src/slic3r/GUI/GLCanvas3D.hpp | 1 + src/slic3r/GUI/GUI_Preview.cpp | 10 ++++++++++ src/slic3r/GUI/GUI_Preview.hpp | 1 + src/slic3r/GUI/Plater.cpp | 1 + 6 files changed, 33 insertions(+) diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp index 26d4f95cb..a0480c289 100644 --- a/src/slic3r/GUI/DoubleSlider.cpp +++ b/src/slic3r/GUI/DoubleSlider.cpp @@ -294,6 +294,8 @@ wxSize Control::get_size() const void Control::get_size(int* w, int* h) const { GetSize(w, h); + if (m_draw_mode == dmSequentialGCodeView) + return; // we have no more icons for drawing is_horizontal() ? *w -= m_lock_icon_dim : *h -= m_lock_icon_dim; } @@ -909,6 +911,10 @@ void Control::draw_revert_icon(wxDC& dc) void Control::draw_cog_icon(wxDC& dc) { +#if ENABLE_GCODE_VIEWER + if (m_draw_mode == dmSequentialGCodeView) + return; +#endif // ENABLE_GCODE_VIEWER int width, height; get_size(&width, &height); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 2dda6f18a..9c8da1654 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1457,6 +1457,7 @@ wxDEFINE_EVENT(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, wxKeyEvent); wxDEFINE_EVENT(EVT_GLCANVAS_MOVE_DOUBLE_SLIDER, wxKeyEvent); #endif // ENABLE_GCODE_VIEWER wxDEFINE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent); +wxDEFINE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent); wxDEFINE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_REDO, SimpleEvent); wxDEFINE_EVENT(EVT_GLCANVAS_COLLAPSE_SIDEBAR, SimpleEvent); @@ -2899,6 +2900,7 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) // see include/wx/defs.h enum wxKeyCode int keyCode = evt.GetKeyCode(); int ctrlMask = wxMOD_CONTROL; + int shiftMask = wxMOD_SHIFT; auto imgui = wxGetApp().imgui(); if (imgui->update_key_data(evt)) { @@ -2996,6 +2998,18 @@ void GLCanvas3D::on_char(wxKeyEvent& evt) post_event(SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); break; default: evt.Skip(); } + } + else if ((evt.GetModifiers() & shiftMask) != 0) { + switch (keyCode) { + case 'g': + case 'G': { + if (dynamic_cast(m_canvas->GetParent()) != nullptr) + post_event(wxKeyEvent(EVT_GLCANVAS_JUMP_TO, evt)); + break; + } + default: + evt.Skip(); + } } else if (evt.HasModifiers()) { evt.Skip(); } else { diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index d0a130e89..5351e99fa 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -114,6 +114,7 @@ wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, wxKeyEvent); wxDECLARE_EVENT(EVT_GLCANVAS_MOVE_DOUBLE_SLIDER, wxKeyEvent); #endif // ENABLE_GCODE_VIEWER wxDECLARE_EVENT(EVT_GLCANVAS_EDIT_COLOR_CHANGE, wxKeyEvent); +wxDECLARE_EVENT(EVT_GLCANVAS_JUMP_TO, wxKeyEvent); wxDECLARE_EVENT(EVT_GLCANVAS_UNDO, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_REDO, SimpleEvent); wxDECLARE_EVENT(EVT_GLCANVAS_COLLAPSE_SIDEBAR, SimpleEvent); diff --git a/src/slic3r/GUI/GUI_Preview.cpp b/src/slic3r/GUI/GUI_Preview.cpp index 2e67eb23d..5f068130b 100644 --- a/src/slic3r/GUI/GUI_Preview.cpp +++ b/src/slic3r/GUI/GUI_Preview.cpp @@ -557,6 +557,16 @@ void Preview::msw_rescale() refresh_print(); } +void Preview::jump_layers_slider(wxKeyEvent& evt) +{ +#if ENABLE_GCODE_VIEWER + if (m_layers_slider) m_layers_slider->OnChar(evt); +#else + if (m_slider) + m_slider->OnKeyDown(evt); +#endif // ENABLE_GCODE_VIEWER +} + #if ENABLE_GCODE_VIEWER void Preview::move_layers_slider(wxKeyEvent& evt) { diff --git a/src/slic3r/GUI/GUI_Preview.hpp b/src/slic3r/GUI/GUI_Preview.hpp index 3628bfd97..5ad70a1ac 100644 --- a/src/slic3r/GUI/GUI_Preview.hpp +++ b/src/slic3r/GUI/GUI_Preview.hpp @@ -179,6 +179,7 @@ Preview(wxWindow* parent, Model* model, DynamicPrintConfig* config, void refresh_print(); void msw_rescale(); + void jump_layers_slider(wxKeyEvent& evt); #if ENABLE_GCODE_VIEWER void move_layers_slider(wxKeyEvent& evt); void edit_layers_slider(wxKeyEvent& evt); diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 331f29fa0..4063b22e7 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -1978,6 +1978,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame) preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_UPDATE_BED_SHAPE, [q](SimpleEvent&) { q->set_bed_shape(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_TAB, [this](SimpleEvent&) { select_next_view_3D(); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_COLLAPSE_SIDEBAR, [this](SimpleEvent&) { this->q->collapse_sidebar(!this->q->is_sidebar_collapsed()); }); + preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_JUMP_TO, [this](wxKeyEvent& evt) { preview->jump_layers_slider(evt); }); #if ENABLE_GCODE_VIEWER preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_MOVE_LAYERS_SLIDER, [this](wxKeyEvent& evt) { preview->move_layers_slider(evt); }); preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_EDIT_COLOR_CHANGE, [this](wxKeyEvent& evt) { preview->edit_layers_slider(evt); });