Merge PR #7435 by @wavexx (Shift+Tab shortcut to collapse sidebar):
The extra commit by lukasmatena fixes toolbar tooltip updating.
This commit is contained in:
commit
482a58ccdc
4 changed files with 27 additions and 10 deletions
|
@ -3214,6 +3214,10 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
|
|||
// m_canvas->HandleAsNavigationKey(evt); // XXX: Doesn't work in some cases / on Linux
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_TAB));
|
||||
}
|
||||
else if (keyCode == WXK_TAB && evt.ShiftDown()) {
|
||||
// Collapse side-panel with Shift+Tab
|
||||
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
|
||||
}
|
||||
else if (keyCode == WXK_SHIFT)
|
||||
{
|
||||
translationProcessor.process(evt);
|
||||
|
|
|
@ -140,6 +140,8 @@ void KBShortcutsDialog::fill_shortcuts()
|
|||
// View
|
||||
{ "0-6", L("Camera view") },
|
||||
{ "E", L("Show/Hide object/instance labels") },
|
||||
{ "Tab", L("Switch between Editor/Preview") },
|
||||
{ "Shift+Tab", L("Collapse/Expand the sidebar") },
|
||||
// Configuration
|
||||
{ ctrl + "P", L("Preferences") },
|
||||
// Help
|
||||
|
|
|
@ -1295,7 +1295,7 @@ void MainFrame::init_menubar()
|
|||
append_menu_check_item(viewMenu, wxID_ANY, _L("Show &labels") + sep + "E", _L("Show object/instance labels in 3D scene"),
|
||||
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); }, this,
|
||||
[this]() { return m_plater->is_view3D_shown(); }, [this]() { return m_plater->are_view3D_labels_shown(); }, this);
|
||||
append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse sidebar"), _L("Collapse sidebar"),
|
||||
append_menu_check_item(viewMenu, wxID_ANY, _L("&Collapse sidebar") + sep + "Shift+Tab", _L("Collapse sidebar"),
|
||||
[this](wxCommandEvent&) { m_plater->collapse_sidebar(!m_plater->is_sidebar_collapsed()); }, this,
|
||||
[]() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this);
|
||||
}
|
||||
|
|
|
@ -1597,7 +1597,7 @@ struct Plater::priv
|
|||
void show_view3D_labels(bool show) { if (current_panel == view3D) view3D->get_canvas3d()->show_labels(show); }
|
||||
|
||||
bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); }
|
||||
void collapse_sidebar(bool show) { sidebar->collapse(show); }
|
||||
void collapse_sidebar(bool collapse);
|
||||
|
||||
bool is_view3D_layers_editing_enabled() const { return (current_panel == view3D) && view3D->get_canvas3d()->is_layers_editing_enabled(); }
|
||||
|
||||
|
@ -1952,6 +1952,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
|||
preview->get_wxglcanvas()->Bind(EVT_GLCANVAS_QUESTION_MARK, [this](SimpleEvent&) { wxGetApp().keyboard_shortcuts(); });
|
||||
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()); });
|
||||
#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); });
|
||||
|
@ -2127,6 +2128,20 @@ void Plater::priv::select_next_view_3D()
|
|||
set_current_panel(view3D);
|
||||
}
|
||||
|
||||
void Plater::priv::collapse_sidebar(bool collapse)
|
||||
{
|
||||
sidebar->collapse(collapse);
|
||||
|
||||
// Now update the tooltip in the toolbar.
|
||||
std::string new_tooltip = collapse
|
||||
? _utf8(L("Expand sidebar"))
|
||||
: _utf8(L("Collapse sidebar"));
|
||||
new_tooltip += " [Shift+Tab]";
|
||||
int id = collapse_toolbar.get_item_id("collapse_sidebar");
|
||||
collapse_toolbar.set_tooltip(id, new_tooltip);
|
||||
}
|
||||
|
||||
|
||||
void Plater::priv::reset_all_gizmos()
|
||||
{
|
||||
view3D->get_canvas3d()->reset_all_gizmos();
|
||||
|
@ -4076,21 +4091,17 @@ bool Plater::priv::init_collapse_toolbar()
|
|||
|
||||
item.name = "collapse_sidebar";
|
||||
item.icon_filename = "collapse.svg";
|
||||
item.tooltip = wxGetApp().plater()->is_sidebar_collapsed() ? _utf8(L("Expand right panel")) : _utf8(L("Collapse right panel"));
|
||||
item.sprite_id = 0;
|
||||
item.left.action_callback = [this, item]() {
|
||||
std::string new_tooltip = wxGetApp().plater()->is_sidebar_collapsed() ?
|
||||
_utf8(L("Collapse right panel")) : _utf8(L("Expand right panel"));
|
||||
|
||||
int id = collapse_toolbar.get_item_id("collapse_sidebar");
|
||||
collapse_toolbar.set_tooltip(id, new_tooltip);
|
||||
|
||||
item.left.action_callback = []() {
|
||||
wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed());
|
||||
};
|
||||
|
||||
if (!collapse_toolbar.add_item(item))
|
||||
return false;
|
||||
|
||||
// Now "collapse" sidebar to current state. This is done so the tooltip
|
||||
// is updated before the toolbar is first used.
|
||||
wxGetApp().plater()->collapse_sidebar(wxGetApp().plater()->is_sidebar_collapsed());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue