Merge remote-tracking branch 'origin/ys_collapse_sidebar' into ys_search

This commit is contained in:
YuSanka 2020-03-28 22:07:56 +01:00
commit 7236abe473
3 changed files with 32 additions and 0 deletions

View file

@ -758,6 +758,9 @@ 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")),
[this](wxCommandEvent&) { m_plater->collapse_sidebur(!m_plater->is_sidebar_collapsed()); }, this,
[this]() { return true; }, [this]() { return m_plater->is_sidebar_collapsed(); }, this);
}
// Help menu

View file

@ -714,6 +714,7 @@ struct Sidebar::priv
ScalableButton *btn_remove_device;
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
bool is_collapsed {false};
SearchOptions search_list;
std::string search_line;
@ -1395,6 +1396,20 @@ void Sidebar::update_mode()
Layout();
}
bool Sidebar::is_collapsed() { return p->is_collapsed; }
void Sidebar::collapse(bool collapse)
{
p->is_collapsed = collapse;
this->Show(!collapse);
p->plater->Layout();
// save collapsing state to the AppConfig
wxGetApp().app_config->set("collapsed_sidebar", collapse ? "1" : "0");
}
std::vector<PresetComboBox*>& Sidebar::combos_filament()
{
return p->combos_filament;
@ -1868,6 +1883,9 @@ struct Plater::priv
bool are_view3D_labels_shown() const { return (current_panel == view3D) && view3D->get_canvas3d()->are_labels_shown(); }
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_sidebur(bool show) { sidebar->collapse(show); }
void set_current_canvas_as_dirty();
GLCanvas3D* get_current_canvas3D();
@ -2242,6 +2260,9 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
// Initialize the Undo / Redo stack with a first snapshot.
this->take_snapshot(_(L("New Project")));
// collapse sidebar according to saved value
sidebar->collapse(wxGetApp().app_config->get("collapsed_sidebar") == "1");
}
Plater::priv::~priv()
@ -4697,6 +4718,9 @@ bool Plater::is_view3D_shown() const { return p->is_view3D_shown(); }
bool Plater::are_view3D_labels_shown() const { return p->are_view3D_labels_shown(); }
void Plater::show_view3D_labels(bool show) { p->show_view3D_labels(show); }
bool Plater::is_sidebar_collapsed() const { return p->is_sidebar_collapsed(); }
void Plater::collapse_sidebur(bool show) { p->collapse_sidebur(show); }
void Plater::select_all() { p->select_all(); }
void Plater::deselect_all() { p->deselect_all(); }

View file

@ -126,6 +126,8 @@ public:
bool show_export_removable(bool show) const;
bool is_multifilament();
void update_mode();
bool is_collapsed();
void collapse(bool collapse);
void update_search_list();
std::vector<PresetComboBox*>& combos_filament();
@ -178,6 +180,9 @@ public:
bool are_view3D_labels_shown() const;
void show_view3D_labels(bool show);
bool is_sidebar_collapsed() const;
void collapse_sidebur(bool show);
// Called after the Preferences dialog is closed and the program settings are saved.
// Update the UI based on the current preferences.
void update_ui_from_settings();