First implementation of the separate plater from the settings tabs

+ Added collapse_toolbar
This commit is contained in:
YuSanka 2020-04-23 12:41:38 +02:00
parent b447b45a3e
commit fcb85dcdc3
9 changed files with 211 additions and 41 deletions

View File

@ -1557,6 +1557,7 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D& bed, Camera& camera, GLToolbar
#endif // !ENABLE_NON_STATIC_CANVAS_MANAGER
, m_main_toolbar(GLToolbar::Normal, "Top")
, m_undoredo_toolbar(GLToolbar::Normal, "Top")
, m_collapse_toolbar(GLToolbar::Normal, "TopRight")
, m_gizmos(*this)
, m_use_clipping_planes(false)
, m_sidebar_field("")
@ -1960,6 +1961,11 @@ void GLCanvas3D::enable_undoredo_toolbar(bool enable)
m_undoredo_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_collapse_toolbar(bool enable)
{
m_collapse_toolbar.set_enabled(enable);
}
void GLCanvas3D::enable_dynamic_background(bool enable)
{
m_dynamic_background_enabled = enable;
@ -2185,6 +2191,9 @@ void GLCanvas3D::render()
tooltip = m_undoredo_toolbar.get_tooltip();
if (tooltip.empty())
tooltip = m_collapse_toolbar.get_tooltip();
if (tooltip.empty())
#if ENABLE_NON_STATIC_CANVAS_MANAGER
tooltip = wxGetApp().plater()->get_view_toolbar().get_tooltip();
#else
@ -2223,6 +2232,9 @@ void GLCanvas3D::render()
if (tooltip.empty())
tooltip = m_undoredo_toolbar.get_tooltip();
if (tooltip.empty())
tooltip = m_collapse_toolbar.get_tooltip();
if (tooltip.empty())
tooltip = m_view_toolbar.get_tooltip();
@ -2949,6 +2961,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
m_dirty |= m_main_toolbar.update_items_state();
m_dirty |= m_undoredo_toolbar.update_items_state();
m_dirty |= m_collapse_toolbar.update_items_state();
#if ENABLE_NON_STATIC_CANVAS_MANAGER
m_dirty |= wxGetApp().plater()->get_view_toolbar().update_items_state();
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(wxGetApp().plater()->get_camera());
@ -3580,6 +3593,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
return;
}
if (m_collapse_toolbar.on_mouse(evt, *this))
{
if (evt.LeftUp() || evt.MiddleUp() || evt.RightUp())
mouse_up_cleanup();
m_mouse.set_start_position_3D_as_invalid();
return;
}
#if ENABLE_NON_STATIC_CANVAS_MANAGER
if (wxGetApp().plater()->get_view_toolbar().on_mouse(evt, *this))
#else
@ -4478,7 +4499,7 @@ bool GLCanvas3D::_render_search_list(float pos_x) const
#else
const float x = pos_x * (float)get_camera().get_zoom() + 0.5f * (float)get_canvas_size().get_width();
#endif
imgui->set_next_window_pos(x, m_undoredo_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
imgui->set_next_window_pos(x, m_main_toolbar.get_height(), ImGuiCond_Always, 0.5f, 0.0f);
std::string title = L("Search");
imgui->begin(_(title), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoCollapse);
@ -4894,6 +4915,9 @@ bool GLCanvas3D::_init_toolbars()
if (!_init_view_toolbar())
return false;
if (!_init_collapse_toolbar())
return false;
return true;
}
@ -5183,26 +5207,6 @@ bool GLCanvas3D::_init_undoredo_toolbar()
if (!m_undoredo_toolbar.add_separator())
return false;
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 = 2;
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 = m_undoredo_toolbar.get_item_id("collapse_sidebar");
m_undoredo_toolbar.set_tooltip(id, new_tooltip);
set_tooltip("");
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
};
item.enabling_callback = []()->bool { return true; };
if (!m_undoredo_toolbar.add_item(item))
return false;
return true;
}
@ -5211,6 +5215,86 @@ bool GLCanvas3D::_init_view_toolbar()
return wxGetApp().plater()->init_view_toolbar();
}
bool GLCanvas3D::_init_collapse_toolbar()
{
if (!m_collapse_toolbar.is_enabled())
return true;
BackgroundTexture::Metadata background_data;
background_data.filename = "toolbar_background.png";
background_data.left = 16;
background_data.top = 16;
background_data.right = 16;
background_data.bottom = 16;
if (!m_collapse_toolbar.init(background_data))
{
// unable to init the toolbar texture, disable it
m_collapse_toolbar.set_enabled(false);
return true;
}
m_collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
m_collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
m_collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
m_collapse_toolbar.set_border(5.0f);
m_collapse_toolbar.set_separator_size(5);
m_collapse_toolbar.set_gap_size(2);
GLToolbarItem::Data item;
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 = m_collapse_toolbar.get_item_id("collapse_sidebar");
m_collapse_toolbar.set_tooltip(id, new_tooltip);
set_tooltip("");
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
};
if (!m_collapse_toolbar.add_item(item))
return false;
if (!m_collapse_toolbar.add_separator())
return false;
item.name = "print";
item.icon_filename = "cog.svg";
item.tooltip = _utf8(L("Switch to Print Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "2]";
item.sprite_id = 1;
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(0); };
if (!m_collapse_toolbar.add_item(item))
return false;
item.name = "filament";
item.icon_filename = "spool.svg";
item.tooltip = _utf8(L("Switch to Filament Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "3]";
item.sprite_id = 2;
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(1); };
if (!m_collapse_toolbar.add_item(item))
return false;
item.name = "printer";
item.icon_filename = "printer.svg";
item.tooltip = _utf8(L("Switch to Printer Settings")) + " [" + GUI::shortkey_ctrl_prefix() + "4]";
item.sprite_id = 3;
item.left.action_callback = [this]() { wxGetApp().mainframe->select_tab(2); };
if (!m_collapse_toolbar.add_item(item))
return false;
return true;
}
bool GLCanvas3D::_set_current()
{
return m_context != nullptr && m_canvas->SetCurrent(*m_context);
@ -5588,14 +5672,17 @@ void GLCanvas3D::_render_overlays() const
const float scale = m_retina_helper->get_scale_factor() * wxGetApp().toolbar_icon_scale(true);
m_main_toolbar.set_scale(scale);
m_undoredo_toolbar.set_scale(scale);
m_collapse_toolbar.set_scale(scale);
#else
const float size = int(GLToolbar::Default_Icons_Size * wxGetApp().toolbar_icon_scale(true));
m_main_toolbar.set_icons_size(size);
m_undoredo_toolbar.set_icons_size(size);
m_collapse_toolbar.set_icons_size(size);
#endif // ENABLE_RETINA_GL
_render_main_toolbar();
_render_undoredo_toolbar();
_render_collapse_toolbar();
_render_view_toolbar();
if ((m_layers_editing.last_object_id >= 0) && (m_layers_editing.object_max_z() > 0.0f))
@ -5726,6 +5813,27 @@ void GLCanvas3D::_render_undoredo_toolbar() const
m_undoredo_toolbar.render(*this);
}
void GLCanvas3D::_render_collapse_toolbar() const
{
if (!m_collapse_toolbar.is_enabled())
return;
Size cnv_size = get_canvas_size();
#if ENABLE_NON_STATIC_CANVAS_MANAGER
float inv_zoom = (float)wxGetApp().plater()->get_camera().get_inv_zoom();
#else
float inv_zoom = (float)m_camera.get_inv_zoom();
#endif // ENABLE_NON_STATIC_CANVAS_MANAGER
float band = m_layers_editing.is_enabled() ? (wxGetApp().imgui()->get_style_scaling() * LayersEditing::THICKNESS_BAR_WIDTH) : 0.0;
float top = 0.5f * (float)cnv_size.get_height() * inv_zoom;
float left = (0.5f * (float)cnv_size.get_width() - (float)m_collapse_toolbar.get_width() - band) * inv_zoom;
m_collapse_toolbar.set_position(top, left);
m_collapse_toolbar.render(*this);
}
void GLCanvas3D::_render_view_toolbar() const
{
#if ENABLE_NON_STATIC_CANVAS_MANAGER
@ -7275,6 +7383,17 @@ bool GLCanvas3D::_activate_search_toolbar_item()
return false;
}
bool GLCanvas3D::_deactivate_collapse_toolbar_items()
{
if (m_collapse_toolbar.is_item_pressed("print"))
{
m_collapse_toolbar.force_left_action(m_collapse_toolbar.get_item_id("print"), *this);
return true;
}
return false;
}
const Print* GLCanvas3D::fff_print() const
{
return (m_process == nullptr) ? nullptr : m_process->fff_print();

View File

@ -160,8 +160,8 @@ private:
Num_States
};
private:
static const float THICKNESS_BAR_WIDTH;
private:
bool m_enabled;
Shader m_shader;
@ -456,6 +456,7 @@ private:
mutable GLGizmosManager m_gizmos;
mutable GLToolbar m_main_toolbar;
mutable GLToolbar m_undoredo_toolbar;
mutable GLToolbar m_collapse_toolbar;
ClippingPlane m_clipping_planes[2];
mutable ClippingPlane m_camera_clipping_plane;
bool m_use_clipping_planes;
@ -602,6 +603,7 @@ public:
void enable_selection(bool enable);
void enable_main_toolbar(bool enable);
void enable_undoredo_toolbar(bool enable);
void enable_collapse_toolbar(bool enable);
void enable_dynamic_background(bool enable);
void enable_labels(bool enable) { m_labels.enable(enable); }
#if ENABLE_SLOPE_RENDERING
@ -742,6 +744,7 @@ private:
bool _init_main_toolbar();
bool _init_undoredo_toolbar();
bool _init_view_toolbar();
bool _init_collapse_toolbar();
bool _set_current();
void _resize(unsigned int w, unsigned int h);
@ -770,6 +773,7 @@ private:
void _render_gizmos_overlay() const;
void _render_main_toolbar() const;
void _render_undoredo_toolbar() const;
void _render_collapse_toolbar() const;
void _render_view_toolbar() const;
#if ENABLE_SHOW_CAMERA_TARGET
void _render_camera_target() const;
@ -839,6 +843,7 @@ private:
bool _deactivate_undo_redo_toolbar_items();
bool _deactivate_search_toolbar_item();
bool _activate_search_toolbar_item();
bool _deactivate_collapse_toolbar_items();
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);

View File

@ -424,6 +424,8 @@ bool GUI_App::on_init_inner()
update_mode(); // update view mode after fix of the object_list size
mainframe->switch_to(true); // hide settings tabs after mode updating
m_initialized = true;
return true;
}

View File

@ -97,6 +97,7 @@ bool View3D::init(wxWindow* parent, Bed3D& bed, Camera& camera, GLToolbar& view_
m_canvas->enable_selection(true);
m_canvas->enable_main_toolbar(true);
m_canvas->enable_undoredo_toolbar(true);
m_canvas->enable_collapse_toolbar(true);
m_canvas->enable_labels(true);
#if ENABLE_SLOPE_RENDERING
m_canvas->enable_slope(true);

View File

@ -89,6 +89,8 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
// initialize layout
auto sizer = new wxBoxSizer(wxVERTICAL);
if (m_plater)
sizer->Add(m_plater, 1, wxEXPAND);
if (m_tabpanel)
sizer->Add(m_tabpanel, 1, wxEXPAND);
sizer->SetSizeHints(this);
@ -306,9 +308,11 @@ void MainFrame::init_tabpanel()
}
});
m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
//! m_plater = new Slic3r::GUI::Plater(m_tabpanel, this);
m_plater = new Plater(this, this);
wxGetApp().plater_ = m_plater;
m_tabpanel->AddPage(m_plater, _(L("Plater")));
// m_tabpanel->AddPage(m_plater, _(L("Plater")));
wxGetApp().obj_list()->create_popup_menus();
@ -334,6 +338,13 @@ void MainFrame::init_tabpanel()
}
}
void MainFrame::switch_to(bool plater)
{
this->m_plater->Show(plater);
this->m_tabpanel->Show(!plater);
this->Layout();
}
void MainFrame::create_preset_tabs()
{
wxGetApp().update_label_colours_from_appconfig();
@ -735,33 +746,34 @@ void MainFrame::init_menubar()
editMenu->AppendSeparator();
append_menu_item(editMenu, wxID_ANY, _(L("Searc&h")) + "\tCtrl+F",
_(L("Find option")), [this](wxCommandEvent&) { m_plater->search(m_tabpanel->GetCurrentPage() == m_plater); },
_(L("Find option")), [this](wxCommandEvent&) { m_plater->search(/*m_tabpanel->GetCurrentPage() == */m_plater->IsShown()); },
"search", nullptr, [this]() {return true; }, this);
}
// Window menu
auto windowMenu = new wxMenu();
{
size_t tab_offset = 0;
//! size_t tab_offset = 0;
if (m_plater) {
append_menu_item(windowMenu, wxID_HIGHEST + 1, _(L("&Plater Tab")) + "\tCtrl+1", _(L("Show the plater")),
[this](wxCommandEvent&) { select_tab(0); }, "plater", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab((size_t)(-1)); }, "plater", nullptr,
[this]() {return true; }, this);
tab_offset += 1;
}
if (tab_offset > 0) {
//! tab_offset += 1;
//! }
//! if (tab_offset > 0) {
windowMenu->AppendSeparator();
}
append_menu_item(windowMenu, wxID_HIGHEST + 2, _(L("P&rint Settings Tab")) + "\tCtrl+2", _(L("Show the print settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 0); }, "cog", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */0); }, "cog", nullptr,
[this]() {return true; }, this);
wxMenuItem* item_material_tab = append_menu_item(windowMenu, wxID_HIGHEST + 3, _(L("&Filament Settings Tab")) + "\tCtrl+3", _(L("Show the filament settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 1); }, "spool", nullptr,
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */1); }, "spool", nullptr,
[this]() {return true; }, this);
m_changeable_menu_items.push_back(item_material_tab);
append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")),
[this, tab_offset](wxCommandEvent&) { select_tab(tab_offset + 2); }, "printer", nullptr,
wxMenuItem* item_printer_tab = append_menu_item(windowMenu, wxID_HIGHEST + 4, _(L("Print&er Settings Tab")) + "\tCtrl+4", _(L("Show the printer settings")),
[this/*, tab_offset*/](wxCommandEvent&) { select_tab(/*tab_offset + */2); }, "printer", nullptr,
[this]() {return true; }, this);
m_changeable_menu_items.push_back(item_printer_tab);
if (m_plater) {
windowMenu->AppendSeparator();
append_menu_item(windowMenu, wxID_HIGHEST + 5, _(L("3&D")) + "\tCtrl+5", _(L("Show the 3D editing view")),
@ -905,7 +917,9 @@ void MainFrame::update_menubar()
m_changeable_menu_items[miSend] ->SetItemLabel((is_fff ? _(L("S&end G-code")) : _(L("S&end to print"))) + dots + "\tCtrl+Shift+G");
m_changeable_menu_items[miMaterialTab] ->SetItemLabel((is_fff ? _(L("&Filament Settings Tab")) : _(L("Mate&rial Settings Tab"))) + "\tCtrl+3");
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool": "resin"));
m_changeable_menu_items[miMaterialTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "spool" : "resin"));
m_changeable_menu_items[miPrinterTab] ->SetBitmap(create_scaled_bitmap(is_fff ? "printer" : "sla_printer"));
}
// To perform the "Quck Slice", "Quick Slice and Save As", "Repeat last Quick Slice" and "Slice to SVG".
@ -1221,9 +1235,17 @@ void MainFrame::load_config(const DynamicPrintConfig& config)
#endif
}
void MainFrame::select_tab(size_t tab) const
void MainFrame::select_tab(size_t tab)
{
m_tabpanel->SetSelection(tab);
if (tab == (size_t)(-1)) {
if (m_plater && !m_plater->IsShown())
this->switch_to(true);
}
else {
if (m_plater && m_plater->IsShown())
switch_to(false);
m_tabpanel->SetSelection(tab);
}
}
// Set a camera direction, zoom to all objects.

View File

@ -86,6 +86,7 @@ class MainFrame : public DPIFrame
miExport = 0, // Export G-code Export
miSend, // Send G-code Send to print
miMaterialTab, // Filament Settings Material Settings
miPrinterTab, // Different bitmap for Printer Settings
};
// vector of a MenuBar items changeable in respect to printer technology
@ -108,6 +109,7 @@ public:
void update_title();
void init_tabpanel();
void switch_to(bool plater);
void create_preset_tabs();
void add_created_tab(Tab* panel);
void init_menubar();
@ -128,7 +130,7 @@ public:
void export_configbundle();
void load_configbundle(wxString file = wxEmptyString);
void load_config(const DynamicPrintConfig& config);
void select_tab(size_t tab) const;
void select_tab(size_t tab);
void select_view(const std::string& direction);
// Propagate changed configuration from the Tab to the Plater and save changes to the AppConfig
void on_config_changed(DynamicPrintConfig* cfg) const ;

View File

@ -362,6 +362,9 @@ PresetBitmapComboBox(parent, wxSize(15 * wxGetApp().em_unit(), -1)),
wxGetApp().tab_panel()->ChangeSelection(page_id);
// Switch to Settings NotePad
wxGetApp().mainframe->switch_to(false);
/* In a case of a multi-material printing, for editing another Filament Preset
* it's needed to select this preset for the "Filament settings" Tab
*/
@ -773,6 +776,8 @@ Sidebar::Sidebar(Plater *parent)
p->scrolled = new wxScrolledWindow(this);
p->scrolled->SetScrollbars(0, 100, 1, 2);
SetFont(wxGetApp().normal_font());
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
// Sizer in the scrolled area
auto *scrolled_sizer = new wxBoxSizer(wxVERTICAL);
@ -1101,6 +1106,10 @@ void Sidebar::jump_to_option(size_t selected)
{
const Search::Option& opt = p->searcher.get_option(selected);
wxGetApp().get_tab(opt.type)->activate_option(opt.opt_key, opt.category);
// Switch to the Settings NotePad, if plater is shown
if (p->plater->IsShown())
wxGetApp().mainframe->switch_to(false);
}
ObjectManipulation* Sidebar::obj_manipul()

View File

@ -31,6 +31,7 @@
#include "GUI_App.hpp"
#include "GUI_ObjectList.hpp"
#include "ConfigWizard.hpp"
#include "format.hpp"
namespace Slic3r {
namespace GUI {
@ -186,7 +187,10 @@ void Tab::create_preset_tab()
"or click this button.")));
add_scaled_button(panel, &m_search_btn, "search");
m_question_btn->SetToolTip(_L("Find option"));
m_search_btn->SetToolTip(format_wxstr(_L("Click to start a search or use %1% shortcut"), "Ctrl+F"));
add_scaled_button(panel, &m_to_plater_btn, "plater");
m_to_plater_btn->SetToolTip(_L("Switch to the Plater"));
// Determine the theme color of OS (dark or light)
auto luma = wxGetApp().get_colour_approx_luma(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
@ -219,6 +223,7 @@ void Tab::create_preset_tab()
}
}));
m_search_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) { wxGetApp().plater()->search(false); });
m_to_plater_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent) { wxGetApp().mainframe->switch_to(true); });
// Colors for ui "decoration"
m_sys_label_clr = wxGetApp().get_label_clr_sys();
@ -243,13 +248,17 @@ void Tab::create_preset_tab()
m_hsizer->AddSpacer(int(32 * scale_factor));
m_hsizer->Add(m_undo_to_sys_btn, 0, wxALIGN_CENTER_VERTICAL);
m_hsizer->Add(m_undo_btn, 0, wxALIGN_CENTER_VERTICAL);
m_hsizer->AddSpacer(int(48 * scale_factor));
m_hsizer->AddSpacer(int(32 * scale_factor));
m_hsizer->Add(m_search_btn, 0, wxALIGN_CENTER_VERTICAL);
// m_hsizer->AddStretchSpacer(32);
// StretchSpacer has a strange behavior under OSX, so
// There is used just additional sizer for m_mode_sizer with right alignment
wxBoxSizer* top_right_sizer = new wxBoxSizer(wxHORIZONTAL);
top_right_sizer->Add(m_to_plater_btn, 0, wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT, wxOSX ? 15 : 10);
top_right_sizer->Add(m_mode_sizer, 0, wxALIGN_CENTER_VERTICAL);
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
// mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
mode_sizer->Add(top_right_sizer, 1, wxALIGN_RIGHT);
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 10);
//Horizontal sizer to hold the tree and the selected page.

View File

@ -127,6 +127,7 @@ protected:
ScalableButton* m_btn_save_preset;
ScalableButton* m_btn_delete_preset;
ScalableButton* m_btn_hide_incompatible_presets;
ScalableButton* m_to_plater_btn;
wxBoxSizer* m_hsizer;
wxBoxSizer* m_left_sizer;
wxTreeCtrl* m_treectrl;