Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fix & improvements to collapse sidebar #3044

Merged
merged 6 commits into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions src/slic3r/GUI/GLCanvas3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3500,10 +3500,7 @@ void GLCanvas3D::on_key(wxKeyEvent& evt)
}
else if (keyCode == WXK_CONTROL)
m_dirty = true;
else if (keyCode == WXK_TAB && evt.ShiftDown() && !evt.ControlDown() && !wxGetApp().is_gcode_viewer()) {
// Collapse side-panel with Shift+Tab
post_event(SimpleEvent(EVT_GLCANVAS_COLLAPSE_SIDEBAR));
} else if (m_gizmos.is_enabled() && !m_selection.is_empty() && m_canvas_type != CanvasAssembleView) {
else if (m_gizmos.is_enabled() && !m_selection.is_empty() && m_canvas_type != CanvasAssembleView) {
auto _do_rotate = [this](double angle_z_rad) {
m_selection.setup_cache();
m_selection.rotate(Vec3d(0.0, 0.0, angle_z_rad), TransformationType(TransformationType::World_Relative_Joint));
Expand Down Expand Up @@ -7146,7 +7143,7 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
m_main_toolbar.set_scale(sc);
m_assemble_view_toolbar.set_scale(sc);
m_separator_toolbar.set_scale(sc);
collapse_toolbar.set_scale(sc);
collapse_toolbar.set_scale(sc / 2.0);
size *= m_retina_helper->get_scale_factor();

auto* m_notification = wxGetApp().plater()->get_notification_manager();
Expand All @@ -7156,17 +7153,17 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
m_main_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size * scale);
m_assemble_view_toolbar.set_icons_size(size);
m_separator_toolbar.set_icons_size(size);
collapse_toolbar.set_icons_size(size);
collapse_toolbar.set_icons_size(size / 2.0);
#endif // ENABLE_RETINA_GL

// Update collapse toolbar
collapse_toolbar.set_enabled(wxGetApp().plater()->get_sidebar_docking_state() != Sidebar::None);

//BBS: GUI refactor: GLToolbar
#if BBS_TOOLBAR_ON_TOP
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : GLToolbar::Default_Icons_Size;
float collapse_toolbar_width = collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0;

float top_tb_width = m_main_toolbar.get_width() + m_gizmos.get_scaled_total_width() + m_assemble_view_toolbar.get_width() + m_separator_toolbar.get_width() + collapse_toolbar_width;
float top_tb_width = m_main_toolbar.get_width() + m_gizmos.get_scaled_total_width() + m_assemble_view_toolbar.get_width() + m_separator_toolbar.get_width() + collapse_toolbar_width * 2;
int items_cnt = m_main_toolbar.get_visible_items_cnt() + m_gizmos.get_selectable_icons_cnt() + m_assemble_view_toolbar.get_visible_items_cnt() + m_separator_toolbar.get_visible_items_cnt() + collapse_toolbar.get_visible_items_cnt();
float noitems_width = top_tb_width - size * items_cnt; // width of separators and borders in top toolbars

Expand Down Expand Up @@ -7221,7 +7218,7 @@ void GLCanvas3D::_render_overlays()
m_main_toolbar.set_scale(scale);
m_assemble_view_toolbar.set_scale(scale);
m_separator_toolbar.set_scale(scale);
wxGetApp().plater()->get_collapse_toolbar().set_scale(scale);
wxGetApp().plater()->get_collapse_toolbar().set_scale(scale / 2.0);
m_gizmos.set_overlay_scale(scale);
#else
// BBS adjust display scale
Expand All @@ -7234,7 +7231,7 @@ void GLCanvas3D::_render_overlays()
m_main_toolbar.set_icons_size(gizmo_size);
m_assemble_view_toolbar.set_icons_size(gizmo_size);
m_separator_toolbar.set_icons_size(gizmo_size);
wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size);
wxGetApp().plater()->get_collapse_toolbar().set_icons_size(size / 2.0);
m_gizmos.set_overlay_icon_size(gizmo_size);
#endif // ENABLE_RETINA_GL

Expand Down Expand Up @@ -7442,7 +7439,7 @@ void GLCanvas3D::_render_gizmos_overlay()
float GLCanvas3D::get_main_toolbar_offset() const
{
const float cnv_width = get_canvas_size().get_width();
const float collapse_toolbar_width = get_collapse_toolbar_width();
const float collapse_toolbar_width = get_collapse_toolbar_width() * 2;
const float gizmo_width = m_gizmos.get_scaled_total_width();
const float assemble_width = m_assemble_view_toolbar.get_width();
const float separator_width = m_separator_toolbar.get_width();
Expand Down
13 changes: 12 additions & 1 deletion src/slic3r/GUI/Plater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2565,6 +2565,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
//BBS :partplatelist construction
, partplate_list(this->q, &model)
{
m_is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";

m_aui_mgr.SetManagedWindow(q);
m_aui_mgr.SetDockSizeConstraint(1, 1);
//m_aui_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 0);
Expand Down Expand Up @@ -3183,6 +3185,15 @@ void Plater::priv::collapse_sidebar(bool collapse)
return;

sidebar_layout.is_collapsed = collapse;

// Now update the tooltip in the toolbar.
std::string new_tooltip = collapse
? _u8L("Expand sidebar")
: _u8L("Collapse sidebar");
new_tooltip += " [Shift+Tab]";
int id = collapse_toolbar.get_item_id("collapse_sidebar");
collapse_toolbar.set_tooltip(id, new_tooltip);

update_sidebar();
}

Expand Down Expand Up @@ -5834,7 +5845,7 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice)

//BBS: add the collapse logic
if (panel == preview && q->only_gcode_mode()) {
this->sidebar->collapse(true);
this->enable_sidebar(false);
preview->get_canvas3d()->enable_select_plate_toolbar(false);
}
else if (panel == preview && q->using_exported_file() && (q->m_valid_plates_count <= 1)) {
Expand Down