mirror of
https://git.mirrors.martin98.com/https://github.com/bambulab/BambuStudio.git
synced 2025-08-05 14:20:40 +08:00
NEW:Make sidebar collapsible, resizable
jira:STUDIO-11623 Code is from OrcaSlicer,thanks for OrcaSlicer and Noisyfox commit 7cfa4f3bcd793d4c394134fc5665fa3732ee1c82 Author: Noisyfox <timemanager.rick@gmail.com> Date: Fri Dec 8 17:16:16 2023 +0800 QoL: Make sidebar collapsible, resizable, movable, floatable and dockable (#2972) Change-Id: I7f2b16f87ab1affe6719f9b348680f392cf245f0
This commit is contained in:
parent
f2314f8f57
commit
1142a4d3f6
5
resources/images/collapse.svg
Normal file
5
resources/images/collapse.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M7.4152 6.875L4.73448 9.5556C4.34394 9.94612 4.34394 10.5793 4.73447 10.9698L7.4152 13.6506" stroke="#00AE42" stroke-linecap="round"/>
|
||||
<path d="M12.5847 13.6494L15.2654 10.9688C15.6559 10.5783 15.6559 9.94512 15.2654 9.55459L12.5847 6.87385" stroke="#00AE42" stroke-linecap="round"/>
|
||||
<line x1="9.98254" y1="5.01172" x2="9.98254" y2="14.9874" stroke="#00AE42" stroke-linecap="round"/>
|
||||
</svg>
|
After Width: | Height: | Size: 496 B |
@ -176,6 +176,8 @@ void AppConfig::set_defaults()
|
||||
set_bool("enable_merge_color_by_sync_ams", false);
|
||||
if (get("ams_sync_match_full_use_color_dist").empty())
|
||||
set_bool("ams_sync_match_full_use_color_dist", false);
|
||||
if (get("enable_sidebar_resizable").empty())
|
||||
set_bool("enable_sidebar_resizable", false);
|
||||
|
||||
if (get("zoom_to_mouse").empty())
|
||||
set_bool("zoom_to_mouse", false);
|
||||
|
@ -2104,18 +2104,43 @@ void GLCanvas3D::update_volumes_colors_by_extruder()
|
||||
m_volumes.update_colors_by_extruder(m_config);
|
||||
}
|
||||
|
||||
float GLCanvas3D::get_collapse_toolbar_width()
|
||||
int GLCanvas3D::get_main_toolbar_offset() const
|
||||
{
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const float cnv_width = get_canvas_size().get_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();
|
||||
const float toolbar_total_width = m_main_toolbar.get_width() + separator_width + gizmo_width + assemble_width + collapse_toolbar_width;
|
||||
|
||||
return collapse_toolbar.is_enabled() ? collapse_toolbar.get_width() : 0;
|
||||
if (cnv_width < toolbar_total_width) {
|
||||
return is_collapse_toolbar_on_left() ? collapse_toolbar_width : 0;
|
||||
} else {
|
||||
const float offset = (cnv_width - toolbar_total_width) / 2;
|
||||
return is_collapse_toolbar_on_left() ? offset + collapse_toolbar_width : offset;
|
||||
}
|
||||
}
|
||||
|
||||
float GLCanvas3D::get_collapse_toolbar_height()
|
||||
bool GLCanvas3D::is_collapse_toolbar_on_left() const
|
||||
{
|
||||
GLToolbar& collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
auto state = wxGetApp().plater()->get_sidebar_docking_state();
|
||||
return state == Sidebar::Left;
|
||||
}
|
||||
|
||||
return collapse_toolbar.is_enabled() ? collapse_toolbar.get_height() : 0;
|
||||
float GLCanvas3D::get_collapse_toolbar_width() const
|
||||
{
|
||||
GLToolbar &collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const auto state = wxGetApp().plater()->get_sidebar_docking_state();
|
||||
|
||||
return state != Sidebar::None ? collapse_toolbar.get_width() : 0;
|
||||
}
|
||||
|
||||
float GLCanvas3D::get_collapse_toolbar_height() const
|
||||
{
|
||||
GLToolbar &collapse_toolbar = wxGetApp().plater()->get_collapse_toolbar();
|
||||
const auto state = wxGetApp().plater()->get_sidebar_docking_state();
|
||||
|
||||
return state != Sidebar::None ? collapse_toolbar.get_height() : 0;
|
||||
}
|
||||
|
||||
bool GLCanvas3D::make_current_for_postinit() {
|
||||
@ -3654,6 +3679,16 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||
case WXK_CONTROL_E:
|
||||
#endif /* __APPLE__ */
|
||||
{ m_labels.show(!m_labels.is_shown()); m_dirty = true; break; }
|
||||
#ifdef __APPLE__
|
||||
case 'W':
|
||||
case 'w':
|
||||
#else /* __APPLE__ */
|
||||
case WXK_CONTROL_W:
|
||||
#endif /* __APPLE__ */
|
||||
{
|
||||
wxGetApp().plater()->reset_window_layout();
|
||||
break;
|
||||
}
|
||||
case '0': {
|
||||
select_view("plate");
|
||||
zoom_to_bed();
|
||||
@ -5563,11 +5598,6 @@ void GLCanvas3D::update_ui_from_settings()
|
||||
_refresh_if_shown_on_screen();
|
||||
}
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
#ifdef SUPPORT_COLLAPSE_BUTTON
|
||||
if (wxGetApp().is_editor())
|
||||
wxGetApp().plater()->enable_collapse_toolbar(wxGetApp().app_config->get("show_collapse_button") == "1");
|
||||
#endif
|
||||
}
|
||||
|
||||
// BBS: add partplate logic
|
||||
@ -7592,8 +7622,10 @@ 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(wxGetApp().plater()->get_collapse_toolbar_size());
|
||||
#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
|
||||
@ -7670,7 +7702,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(wxGetApp().plater()->get_collapse_toolbar_size());
|
||||
m_gizmos.set_overlay_icon_size(gizmo_size);
|
||||
#endif // ENABLE_RETINA_GL
|
||||
|
||||
@ -7918,8 +7950,7 @@ void GLCanvas3D::_render_main_toolbar()
|
||||
#endif
|
||||
m_main_toolbar.set_position(top, left);
|
||||
m_main_toolbar.render(*this);
|
||||
if (m_toolbar_highlighter.m_render_arrow)
|
||||
{
|
||||
if (m_toolbar_highlighter.m_render_arrow){
|
||||
m_main_toolbar.render_arrow(*this, m_toolbar_highlighter.m_toolbar_item);
|
||||
}
|
||||
}
|
||||
@ -8029,7 +8060,7 @@ void GLCanvas3D::_render_imgui_select_plate_toolbar()
|
||||
float margin_size = 4.0f * f_scale;
|
||||
float button_margin = frame_padding;
|
||||
|
||||
const float y_offset = 0; // is_collapse_toolbar_on_left() ? (get_collapse_toolbar_height() + 5) : 0;
|
||||
const float y_offset = is_collapse_toolbar_on_left() ? (get_collapse_toolbar_height() + 5) : 0;
|
||||
// Make sure the window does not overlap the 3d navigator
|
||||
auto window_height_max = canvas_h - y_offset;
|
||||
if (wxGetApp().show_3d_navigator()) {
|
||||
@ -8320,7 +8351,7 @@ void GLCanvas3D::_render_return_toolbar()
|
||||
auto canvas_h = float(cnv_size.get_height());
|
||||
float window_width = real_size.x + button_icon_size.x + imgui.scaled(2.0f);
|
||||
float window_height = button_icon_size.y + imgui.scaled(2.0f);
|
||||
float window_pos_x = 30.0f;
|
||||
float window_pos_x = 30.0f + (is_collapse_toolbar_on_left() ? (get_collapse_toolbar_width() + 5.f) : 0);
|
||||
float window_pos_y = 14.0f;
|
||||
{//solve ui overlap issue
|
||||
if (m_canvas_type == ECanvasType::CanvasView3D) {
|
||||
|
@ -910,15 +910,17 @@ public:
|
||||
//BBS: add part plate related logic
|
||||
void select_plate();
|
||||
//BBS: GUI refactor: GLToolbar&&gizmo
|
||||
float get_main_toolbar_height() { return m_main_toolbar.get_height();}
|
||||
float get_main_toolbar_width() { return m_main_toolbar.get_width();}
|
||||
float get_assemble_view_toolbar_width() { return m_assemble_view_toolbar.get_width(); }
|
||||
float get_assemble_view_toolbar_height() { return m_assemble_view_toolbar.get_height(); }
|
||||
float get_assembly_paint_toolbar_width() { return m_paint_toolbar_width; }
|
||||
float get_separator_toolbar_width() { return m_separator_toolbar.get_width(); }
|
||||
float get_separator_toolbar_height() { return m_separator_toolbar.get_height(); }
|
||||
float get_collapse_toolbar_width();
|
||||
float get_collapse_toolbar_height();
|
||||
int get_main_toolbar_offset() const;
|
||||
int get_main_toolbar_height() const { return m_main_toolbar.get_height(); }
|
||||
int get_main_toolbar_width() const { return m_main_toolbar.get_width(); }
|
||||
float get_assemble_view_toolbar_width() const { return m_assemble_view_toolbar.get_width(); }
|
||||
float get_assemble_view_toolbar_height() const { return m_assemble_view_toolbar.get_height(); }
|
||||
float get_assembly_paint_toolbar_width() const { return m_paint_toolbar_width; }
|
||||
float get_separator_toolbar_width() const { return m_separator_toolbar.get_width(); }
|
||||
float get_separator_toolbar_height() const { return m_separator_toolbar.get_height(); }
|
||||
bool is_collapse_toolbar_on_left() const;
|
||||
float get_collapse_toolbar_width() const;
|
||||
float get_collapse_toolbar_height() const;
|
||||
|
||||
void update_volumes_colors_by_extruder();
|
||||
|
||||
|
@ -921,7 +921,7 @@ void MainFrame::update_layout()
|
||||
//BBS: add bed exclude area
|
||||
m_plater->set_bed_shape({ { 0.0, 0.0 }, { 200.0, 0.0 }, { 200.0, 200.0 }, { 0.0, 200.0 } }, {}, 0.0, {}, {}, {}, {}, true);
|
||||
m_plater->get_collapse_toolbar().set_enabled(false);
|
||||
m_plater->collapse_sidebar(true);
|
||||
m_plater->enable_sidebar(false);
|
||||
m_plater->Show();
|
||||
break;
|
||||
}
|
||||
@ -2897,6 +2897,11 @@ void MainFrame::init_menubar_as_editor()
|
||||
},
|
||||
this, [this]() { return m_tabpanel->GetSelection() == TabPosition::tp3DEditor || m_tabpanel->GetSelection() == TabPosition::tpPreview; },
|
||||
[this]() { return wxGetApp().show_3d_navigator(); }, this);
|
||||
append_menu_item(
|
||||
viewMenu, wxID_ANY, _L("Reset Window Layout") + "\t" + ctrl + "W", _L("Reset to default window layout"),
|
||||
[this](wxCommandEvent &) { m_plater->reset_window_layout(); }, "", this,
|
||||
[this]() { return (m_tabpanel->GetSelection() == TabPosition::tp3DEditor || m_tabpanel->GetSelection() == TabPosition::tpPreview) && m_plater->is_sidebar_enabled(); },
|
||||
this);
|
||||
viewMenu->AppendSeparator();
|
||||
append_menu_check_item(viewMenu, wxID_ANY, _L("Show Labels") + "\t" + ctrl + "E", _L("Show object labels in 3D scene"),
|
||||
[this](wxCommandEvent&) { m_plater->show_view3D_labels(!m_plater->are_view3D_labels_shown()); m_plater->get_current_canvas3D()->post_event(SimpleEvent(wxEVT_PAINT)); }, this,
|
||||
|
@ -38,6 +38,7 @@
|
||||
#endif
|
||||
#include <wx/clrpicker.h>
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/aui/aui.h>
|
||||
|
||||
#include "libslic3r/libslic3r.h"
|
||||
#include "libslic3r/Format/STL.hpp"
|
||||
@ -480,7 +481,6 @@ struct Sidebar::priv
|
||||
//ScalableButton *btn_eject_device;
|
||||
ScalableButton* btn_export_gcode_removable; //exports to removable drives (appears only if removable drive is connected)
|
||||
|
||||
bool is_collapsed {false};
|
||||
bool is_switching_diameter{false};
|
||||
Search::OptionsSearcher searcher;
|
||||
std::string ams_list_device;
|
||||
@ -3412,18 +3412,12 @@ void Sidebar::update_mode()
|
||||
Layout();
|
||||
}
|
||||
|
||||
bool Sidebar::is_collapsed() { return p->is_collapsed; }
|
||||
bool Sidebar::is_collapsed() {
|
||||
return p->plater->is_sidebar_collapsed();
|
||||
}
|
||||
|
||||
void Sidebar::collapse(bool collapse)
|
||||
{
|
||||
p->is_collapsed = collapse;
|
||||
|
||||
this->Show(!collapse);
|
||||
p->plater->Layout();
|
||||
|
||||
// save collapsing state to the AppConfig
|
||||
//if (wxGetApp().is_editor())
|
||||
// wxGetApp().app_config->set_bool("collapsed_sidebar", collapse);
|
||||
void Sidebar::collapse(bool collapse){
|
||||
p->plater->collapse_sidebar(collapse);
|
||||
}
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
@ -3705,12 +3699,37 @@ enum ExportingStatus{
|
||||
EXPORTING_TO_LOCAL
|
||||
};
|
||||
|
||||
class FloatFrame : public wxAuiFloatingFrame
|
||||
{
|
||||
public:
|
||||
FloatFrame(wxWindow *parent, wxAuiManager *ownerMgr, const wxAuiPaneInfo &pane) : wxAuiFloatingFrame(parent, ownerMgr, pane) { wxGetApp().UpdateFrameDarkUI(this); }
|
||||
};
|
||||
|
||||
class AuiMgr : public wxAuiManager
|
||||
{
|
||||
public:
|
||||
AuiMgr() : wxAuiManager() {
|
||||
}
|
||||
|
||||
virtual wxAuiFloatingFrame *CreateFloatingFrame(wxWindow *parent, const wxAuiPaneInfo &p) override {
|
||||
return new FloatFrame(parent, this, p);
|
||||
}
|
||||
};
|
||||
|
||||
// Plater / private
|
||||
struct Plater::priv
|
||||
{
|
||||
// PIMPL back pointer ("Q-Pointer")
|
||||
Plater *q;
|
||||
Sidebar * sidebar;
|
||||
AuiMgr m_aui_mgr;
|
||||
wxString m_default_window_layout;
|
||||
struct SidebarLayout
|
||||
{
|
||||
bool is_enabled{false};
|
||||
bool is_collapsed{false};
|
||||
bool show{false};
|
||||
} sidebar_layout;
|
||||
MainFrame *main_frame;
|
||||
|
||||
MenuFactory menus;
|
||||
@ -3930,8 +3949,11 @@ struct Plater::priv
|
||||
if (current_panel == view3D) view3D->get_canvas3d()->show_overhang(show);
|
||||
}
|
||||
|
||||
bool is_sidebar_collapsed() const { return sidebar->is_collapsed(); }
|
||||
void enable_sidebar(bool enabled);
|
||||
void collapse_sidebar(bool collapse);
|
||||
void update_sidebar(bool force_update = false);
|
||||
void reset_window_layout(int width);
|
||||
Sidebar::DockingState get_sidebar_docking_state();
|
||||
|
||||
bool is_view3D_layers_editing_enabled() const { return (current_panel == view3D) && view3D->get_canvas3d()->is_layers_editing_enabled(); }
|
||||
|
||||
@ -4154,6 +4176,7 @@ struct Plater::priv
|
||||
//BBS: change dark/light mode
|
||||
void on_change_color_mode(SimpleEvent& evt);
|
||||
void on_apple_change_color_mode(wxSysColourChangedEvent& evt);
|
||||
void apply_color_mode();
|
||||
void on_update_geometry(Vec3dsEvent<2>&);
|
||||
void on_3dcanvas_mouse_dragging_started(SimpleEvent&);
|
||||
void on_3dcanvas_mouse_dragging_finished(SimpleEvent&);
|
||||
@ -4163,6 +4186,7 @@ struct Plater::priv
|
||||
void update_publish_dialog_status(wxString &msg, int percent = -1);
|
||||
void on_action_print_plate_from_sdcard(SimpleEvent&);
|
||||
|
||||
void on_tab_selection_changing(wxBookCtrlEvent &);
|
||||
// Set the bed shape to a single closed 2D polygon(array of two element arrays),
|
||||
// triangulate the bed and store the triangles into m_bed.m_triangles,
|
||||
// fills the m_bed.m_grid_lines and sets m_bed.m_origin.
|
||||
@ -4322,6 +4346,14 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
//BBS :partplatelist construction
|
||||
, partplate_list(this->q, &model)
|
||||
{
|
||||
m_is_dark = wxGetApp().app_config->get_bool("dark_color_mode");
|
||||
m_aui_mgr.SetManagedWindow(q);
|
||||
m_aui_mgr.SetDockSizeConstraint(1, 1);
|
||||
// m_aui_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_PANE_BORDER_SIZE, 0);
|
||||
// m_aui_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_SASH_SIZE, 2);
|
||||
m_aui_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_CAPTION_SIZE, 8);
|
||||
m_aui_mgr.GetArtProvider()->SetMetric(wxAUI_DOCKART_GRADIENT_TYPE, wxAUI_GRADIENT_NONE);
|
||||
|
||||
this->q->SetFont(Slic3r::GUI::wxGetApp().normal_font());
|
||||
|
||||
//BBS: use the first partplate's print for background process
|
||||
@ -4367,12 +4399,15 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
this->q->Bind(EVT_ADD_FILAMENT, &priv::on_add_filament, this);
|
||||
this->q->Bind(EVT_DEL_FILAMENT, &priv::on_delete_filament, this);
|
||||
this->q->Bind(EVT_ADD_CUSTOM_FILAMENT, &priv::on_add_custom_filament, this);
|
||||
view3D = new View3D(q, bed, &model, config, &background_process);
|
||||
main_frame->m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGING, &priv::on_tab_selection_changing, this);
|
||||
|
||||
auto *panel_3d = new wxPanel(q);
|
||||
view3D = new View3D(panel_3d, bed, &model, config, &background_process);
|
||||
partplate_list.set_bed3d(&bed);
|
||||
//BBS: use partplater's gcode
|
||||
preview = new Preview(q, bed, &model, config, &background_process, partplate_list.get_current_slice_result(), [this]() { schedule_background_process(); });
|
||||
preview = new Preview(panel_3d, bed, &model, config, &background_process, partplate_list.get_current_slice_result(), [this]() { schedule_background_process(); });
|
||||
|
||||
assemble_view = new AssembleView(q, bed, &model, config, &background_process);
|
||||
assemble_view = new AssembleView(panel_3d, bed, &model, config, &background_process);
|
||||
|
||||
#ifdef __APPLE__
|
||||
// BBS
|
||||
@ -4392,24 +4427,49 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
});
|
||||
|
||||
update();
|
||||
// Orca: Make sidebar dockable
|
||||
auto look = wxGetApp().app_config->get_bool("enable_sidebar_resizable");
|
||||
m_aui_mgr.AddPane(sidebar, wxAuiPaneInfo()
|
||||
.Name("sidebar")
|
||||
.Left()
|
||||
.CloseButton(false)
|
||||
.TopDockable(false)
|
||||
.BottomDockable(false)
|
||||
.Floatable(true)
|
||||
.Resizable(wxGetApp().app_config->get_bool("enable_sidebar_resizable"))
|
||||
.MinSize(wxSize(41 * wxGetApp().em_unit(), -1))
|
||||
.BestSize(wxSize(42 * wxGetApp().em_unit(), 90 * wxGetApp().em_unit())));
|
||||
|
||||
auto* hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto* vsizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
||||
// BBS: move sidebar to left side
|
||||
hsizer->Add(sidebar, 0, wxEXPAND | wxLEFT | wxRIGHT, 0);
|
||||
auto spliter_1 = new ::StaticLine(q, true);
|
||||
spliter_1->SetLineColour("#A6A9AA");
|
||||
hsizer->Add(spliter_1, 0, wxEXPAND);
|
||||
|
||||
panel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
auto *panel_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
panel_sizer->Add(view3D, 1, wxEXPAND | wxALL, 0);
|
||||
panel_sizer->Add(preview, 1, wxEXPAND | wxALL, 0);
|
||||
panel_sizer->Add(assemble_view, 1, wxEXPAND | wxALL, 0);
|
||||
vsizer->Add(panel_sizer, 1, wxEXPAND | wxALL, 0);
|
||||
hsizer->Add(vsizer, 1, wxEXPAND | wxALL, 0);
|
||||
panel_3d->SetSizer(panel_sizer);
|
||||
m_aui_mgr.AddPane(panel_3d, wxAuiPaneInfo().Name("main").CenterPane().PaneBorder(false));
|
||||
|
||||
q->SetSizer(hsizer);
|
||||
m_default_window_layout = m_aui_mgr.SavePerspective();
|
||||
{
|
||||
auto &sidebar = m_aui_mgr.GetPane(this->sidebar);
|
||||
|
||||
// Load previous window layout
|
||||
const auto cfg = wxGetApp().app_config;
|
||||
wxString layout = wxString::FromUTF8(cfg->get("window_layout"));
|
||||
if (!layout.empty()) {
|
||||
m_aui_mgr.LoadPerspective(layout, false);
|
||||
sidebar_layout.is_collapsed = !sidebar.IsShown();
|
||||
}
|
||||
|
||||
// Keep tracking the current sidebar size, by storing it using `best_size`, which will be stored
|
||||
// in the config and re-applied when the app is opened again.
|
||||
this->sidebar->Bind(wxEVT_IDLE, [&sidebar, this](wxIdleEvent &e) {
|
||||
if (sidebar.IsShown() && sidebar.IsDocked() && sidebar.rect.GetWidth() > 0) { sidebar.BestSize(sidebar.rect.GetWidth(), sidebar.best_size.GetHeight()); }
|
||||
e.Skip();
|
||||
});
|
||||
|
||||
// Hide sidebar initially, will re-show it after initialization when we got proper window size
|
||||
sidebar.Hide();
|
||||
m_aui_mgr.Update();
|
||||
}
|
||||
|
||||
menus.init(main_frame);
|
||||
|
||||
@ -4638,6 +4698,8 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
q->SetDropTarget(new PlaterDropTarget(q)); // if my understanding is right, wxWindow takes the owenership
|
||||
q->Layout();
|
||||
|
||||
apply_color_mode();
|
||||
|
||||
set_current_panel(wxGetApp().is_editor() ? static_cast<wxPanel*>(view3D) : static_cast<wxPanel*>(preview));
|
||||
|
||||
// updates camera type from .ini file
|
||||
@ -4763,6 +4825,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
|
||||
// bool is_collapsed = wxGetApp().app_config->get("collapsed_sidebar") == "1";
|
||||
// sidebar->collapse(is_collapsed);
|
||||
//}
|
||||
update_sidebar(true);
|
||||
}
|
||||
|
||||
Plater::priv::~priv()
|
||||
@ -4771,6 +4834,7 @@ Plater::priv::~priv()
|
||||
delete config;
|
||||
// Saves the database of visited (already shown) hints into hints.ini.
|
||||
notification_manager->deactivate_loaded_hints();
|
||||
main_frame->m_tabpanel->Unbind(wxEVT_NOTEBOOK_PAGE_CHANGING, &priv::on_tab_selection_changing, this);
|
||||
}
|
||||
|
||||
void Plater::priv::update(unsigned int flags)
|
||||
@ -4809,6 +4873,7 @@ void Plater::priv::update(unsigned int flags)
|
||||
if (get_config("autocenter") == "true" && this->sidebar->obj_manipul()->IsShown())
|
||||
this->sidebar->obj_manipul()->UpdateAndShow(true);
|
||||
#endif
|
||||
update_sidebar();
|
||||
}
|
||||
|
||||
void Plater::priv::select_view(const std::string& direction)
|
||||
@ -4934,12 +4999,84 @@ void Plater::priv::select_next_view_3D()
|
||||
// set_current_panel(view3D);
|
||||
}
|
||||
|
||||
void Plater::priv::enable_sidebar(bool enabled)
|
||||
{
|
||||
if (q->m_only_gcode) enabled = false;
|
||||
|
||||
sidebar_layout.is_enabled = enabled;
|
||||
update_sidebar();
|
||||
}
|
||||
|
||||
void Plater::priv::collapse_sidebar(bool collapse)
|
||||
{
|
||||
if (q->m_only_gcode && !collapse)
|
||||
return;
|
||||
sidebar->collapse(collapse);
|
||||
notification_manager->set_sidebar_collapsed(collapse);
|
||||
if (q->m_only_gcode) 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();
|
||||
}
|
||||
|
||||
void Plater::priv::update_sidebar(bool force_update)
|
||||
{
|
||||
auto &sidebar = m_aui_mgr.GetPane(this->sidebar);
|
||||
if (!sidebar.IsOk() || this->current_panel == nullptr) { return; }
|
||||
bool needs_update = force_update;
|
||||
|
||||
if (!sidebar_layout.is_enabled) {
|
||||
if (sidebar.IsShown()) {
|
||||
sidebar.Hide();
|
||||
needs_update = true;
|
||||
}
|
||||
} else {
|
||||
// Only hide if collapsed or is floating and is not 3d view
|
||||
const bool should_hide = sidebar_layout.is_collapsed || (sidebar.IsFloating() && !sidebar_layout.show);
|
||||
const bool should_show = !should_hide;
|
||||
if (should_show != sidebar.IsShown()) {
|
||||
sidebar.Show(should_show);
|
||||
needs_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (needs_update) {
|
||||
notification_manager->set_sidebar_collapsed(sidebar.IsShown());
|
||||
m_aui_mgr.Update();
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::priv::reset_window_layout(int width)
|
||||
{
|
||||
if (width < 0) {
|
||||
m_aui_mgr.LoadPerspective(m_default_window_layout, false);
|
||||
} else {
|
||||
auto copy = m_default_window_layout;
|
||||
wxString old_num = wxString::Format("%d", 42 * wxGetApp().em_unit());
|
||||
wxString new_num = wxString::Format("%d", width);
|
||||
wxString str0("bestw="), str1("bestw=");
|
||||
str0 += old_num;
|
||||
str1 += new_num;
|
||||
copy.Replace(str0, str1, false);
|
||||
m_aui_mgr.LoadPerspective(copy, false);
|
||||
}
|
||||
sidebar_layout.is_collapsed = false;
|
||||
update_sidebar(true);
|
||||
}
|
||||
|
||||
Sidebar::DockingState Plater::priv::get_sidebar_docking_state()
|
||||
{
|
||||
if (!sidebar_layout.is_enabled) { return Sidebar::None; }
|
||||
|
||||
const auto &sidebar = m_aui_mgr.GetPane(this->sidebar);
|
||||
if (sidebar.IsFloating()) {
|
||||
return Sidebar::None;
|
||||
}
|
||||
|
||||
return sidebar.dock_direction == wxAUI_DOCK_RIGHT ? Sidebar::Right : Sidebar::Left;
|
||||
}
|
||||
|
||||
|
||||
@ -6639,6 +6776,15 @@ void Plater::priv::reset(bool apply_presets_change)
|
||||
|
||||
// BBS
|
||||
m_saved_timestamp = m_backup_timestamp = size_t(-1);
|
||||
|
||||
// Save window layout
|
||||
if (sidebar_layout.is_enabled) {
|
||||
// Reset show state
|
||||
auto &sidebar = m_aui_mgr.GetPane(this->sidebar);
|
||||
if (!sidebar_layout.is_collapsed && !sidebar.IsShown()) { sidebar.Show(); }
|
||||
auto layout = m_aui_mgr.SavePerspective();
|
||||
wxGetApp().app_config->set("window_layout", layout.utf8_string());
|
||||
}
|
||||
}
|
||||
|
||||
void Plater::priv::center_selection()
|
||||
@ -8010,7 +8156,7 @@ void Plater::priv::set_current_panel(wxPanel* panel, bool no_slice)
|
||||
p->Hide();
|
||||
}
|
||||
|
||||
panel_sizer->Layout();
|
||||
m_aui_mgr.Update();
|
||||
|
||||
if (wxGetApp().plater()) {
|
||||
Camera& cam = wxGetApp().plater()->get_camera();
|
||||
@ -8970,6 +9116,13 @@ void Plater::priv::on_action_print_plate_from_sdcard(SimpleEvent&)
|
||||
m_select_machine_dlg->ShowModal();
|
||||
}
|
||||
|
||||
void Plater::priv::on_tab_selection_changing(wxBookCtrlEvent &e)
|
||||
{
|
||||
const int new_sel = e.GetSelection();
|
||||
sidebar_layout.show = new_sel == MainFrame::tp3DEditor || new_sel == MainFrame::tpPreview;
|
||||
update_sidebar();
|
||||
}
|
||||
|
||||
int Plater::priv::update_print_required_data(Slic3r::DynamicPrintConfig config, Slic3r::Model model, Slic3r::PlateDataPtrs plate_data_list, std::string file_name, std::string file_path)
|
||||
{
|
||||
if (!m_select_machine_dlg) m_select_machine_dlg = new SelectMachineDialog(q);
|
||||
@ -9179,6 +9332,8 @@ void Plater::priv::on_apple_change_color_mode(wxSysColourChangedEvent& evt) {
|
||||
preview->get_canvas3d()->on_change_color_mode(m_is_dark);
|
||||
assemble_view->get_canvas3d()->on_change_color_mode(m_is_dark);
|
||||
}
|
||||
|
||||
apply_color_mode();
|
||||
}
|
||||
|
||||
void Plater::priv::on_change_color_mode(SimpleEvent& evt) {
|
||||
@ -9188,6 +9343,19 @@ void Plater::priv::on_change_color_mode(SimpleEvent& evt) {
|
||||
preview->get_canvas3d()->on_change_color_mode(m_is_dark);
|
||||
assemble_view->get_canvas3d()->on_change_color_mode(m_is_dark);
|
||||
if (m_send_to_sdcard_dlg) m_send_to_sdcard_dlg->on_change_color_mode();
|
||||
apply_color_mode();
|
||||
}
|
||||
|
||||
void Plater::priv::apply_color_mode()
|
||||
{
|
||||
const bool is_dark = wxGetApp().dark_mode();
|
||||
wxColour orca_color = wxColour(59, 68, 70); // wxColour(ColorRGBA::ORCA().r_uchar(), ColorRGBA::ORCA().g_uchar(), ColorRGBA::ORCA().b_uchar());
|
||||
orca_color = is_dark ? StateColor::darkModeColorFor(orca_color) : StateColor::lightModeColorFor(orca_color);
|
||||
wxColour sash_color = is_dark ? wxColour(38, 46, 48) : wxColour(206, 206, 206);
|
||||
m_aui_mgr.GetArtProvider()->SetColour(wxAUI_DOCKART_INACTIVE_CAPTION_COLOUR, sash_color);
|
||||
m_aui_mgr.GetArtProvider()->SetColour(wxAUI_DOCKART_INACTIVE_CAPTION_TEXT_COLOUR, *wxWHITE);
|
||||
m_aui_mgr.GetArtProvider()->SetColour(wxAUI_DOCKART_SASH_COLOUR, sash_color);
|
||||
m_aui_mgr.GetArtProvider()->SetColour(wxAUI_DOCKART_BORDER_COLOUR, is_dark ? *wxBLACK : wxColour(165, 165, 165));
|
||||
}
|
||||
|
||||
static void get_position(wxWindowBase *child, wxWindowBase *until_parent, int &x, int &y)
|
||||
@ -9899,10 +10067,10 @@ bool Plater::priv::init_collapse_toolbar()
|
||||
|
||||
BackgroundTexture::Metadata background_data;
|
||||
background_data.filename = m_is_dark ? "toolbar_background_dark.png" : "toolbar_background.png";
|
||||
background_data.left = 16;
|
||||
background_data.top = 16;
|
||||
background_data.right = 16;
|
||||
background_data.bottom = 16;
|
||||
background_data.left = 4;
|
||||
background_data.top = 4;
|
||||
background_data.right = 4;
|
||||
background_data.bottom = 4;
|
||||
|
||||
if (!collapse_toolbar.init(background_data))
|
||||
return false;
|
||||
@ -9910,17 +10078,16 @@ bool Plater::priv::init_collapse_toolbar()
|
||||
collapse_toolbar.set_layout_type(GLToolbar::Layout::Vertical);
|
||||
collapse_toolbar.set_horizontal_orientation(GLToolbar::Layout::HO_Right);
|
||||
collapse_toolbar.set_vertical_orientation(GLToolbar::Layout::VO_Top);
|
||||
collapse_toolbar.set_border(5.0f);
|
||||
collapse_toolbar.set_border(0.0f);
|
||||
collapse_toolbar.set_separator_size(5);
|
||||
collapse_toolbar.set_gap_size(2);
|
||||
|
||||
collapse_toolbar.del_all_item();
|
||||
|
||||
GLToolbarItem::Data item;
|
||||
|
||||
item.name = "collapse_sidebar";
|
||||
// set collapse svg name
|
||||
item.icon_filename = "*.svg";
|
||||
item.icon_filename = "collapse.svg";
|
||||
item.sprite_id = 0;
|
||||
item.left.action_callback = []() {
|
||||
wxGetApp().plater()->collapse_sidebar(!wxGetApp().plater()->is_sidebar_collapsed());
|
||||
@ -9932,6 +10099,7 @@ bool Plater::priv::init_collapse_toolbar()
|
||||
// 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());
|
||||
collapse_toolbar.set_icons_size(q->get_collapse_toolbar_size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -10925,9 +11093,6 @@ int Plater::new_project(bool skip_confirm, bool silent, const wxString &project_
|
||||
if (!skip_confirm && (result = close_with_confirm(check)) == wxID_CANCEL)
|
||||
return wxID_CANCEL;
|
||||
|
||||
//BBS: add only gcode mode
|
||||
bool previous_gcode = m_only_gcode;
|
||||
|
||||
reset_flags_when_new_or_close_project();
|
||||
get_notification_manager()->clear_all();
|
||||
|
||||
@ -10968,8 +11133,7 @@ int Plater::new_project(bool skip_confirm, bool silent, const wxString &project_
|
||||
p->select_view_3D("3D");
|
||||
p->select_view("topfront");
|
||||
p->camera.requires_zoom_to_bed = true;
|
||||
if (previous_gcode)
|
||||
collapse_sidebar(false);
|
||||
enable_sidebar(!m_only_gcode);
|
||||
|
||||
up_to_date(true, false);
|
||||
up_to_date(true, true);
|
||||
@ -13088,9 +13252,12 @@ void Plater::show_view3D_labels(bool show) { p->show_view3D_labels(show); }
|
||||
bool Plater::is_view3D_overhang_shown() const { return p->is_view3D_overhang_shown(); }
|
||||
void Plater::show_view3D_overhang(bool show) { p->show_view3D_overhang(show); }
|
||||
|
||||
bool Plater::is_sidebar_collapsed() const { return p->is_sidebar_collapsed(); }
|
||||
bool Plater::is_sidebar_enabled() const { return p->sidebar_layout.is_enabled; }
|
||||
void Plater::enable_sidebar(bool enabled) { p->enable_sidebar(enabled); }
|
||||
bool Plater::is_sidebar_collapsed() const { return p->sidebar_layout.is_collapsed; }
|
||||
void Plater::collapse_sidebar(bool show) { p->collapse_sidebar(show); }
|
||||
|
||||
Sidebar::DockingState Plater::get_sidebar_docking_state() const { return p->get_sidebar_docking_state(); }
|
||||
void Plater::reset_window_layout(int width) { p->reset_window_layout(width); }
|
||||
//BBS
|
||||
void Plater::select_curr_plate_all() { p->select_curr_plate_all(); }
|
||||
void Plater::remove_curr_plate_all() { p->remove_curr_plate_all(); }
|
||||
@ -15971,11 +16138,6 @@ bool Plater::init_collapse_toolbar()
|
||||
return p->init_collapse_toolbar();
|
||||
}
|
||||
|
||||
void Plater::enable_collapse_toolbar(bool enable)
|
||||
{
|
||||
p->collapse_toolbar.set_enabled(enable);
|
||||
}
|
||||
|
||||
const Camera& Plater::get_camera() const
|
||||
{
|
||||
return p->camera;
|
||||
@ -16942,6 +17104,10 @@ GLToolbar& Plater::get_collapse_toolbar()
|
||||
return p->collapse_toolbar;
|
||||
}
|
||||
|
||||
int Plater::get_collapse_toolbar_size() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
void Plater::update_preview_bottom_toolbar()
|
||||
{
|
||||
p->update_preview_bottom_toolbar();
|
||||
|
@ -134,6 +134,7 @@ class Sidebar : public wxPanel
|
||||
void update_sync_ams_btn_enable(wxUpdateUIEvent &e);
|
||||
|
||||
public:
|
||||
enum DockingState { None, Left, Right };
|
||||
Sidebar(Plater *parent);
|
||||
Sidebar(Sidebar &&) = delete;
|
||||
Sidebar(const Sidebar &) = delete;
|
||||
@ -386,9 +387,12 @@ public:
|
||||
bool is_view3D_overhang_shown() const;
|
||||
void show_view3D_overhang(bool show);
|
||||
|
||||
bool is_sidebar_enabled() const;
|
||||
void enable_sidebar(bool enabled);
|
||||
bool is_sidebar_collapsed() const;
|
||||
void collapse_sidebar(bool show);
|
||||
|
||||
Sidebar::DockingState get_sidebar_docking_state() const;
|
||||
void reset_window_layout(int width = -1);
|
||||
// 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();
|
||||
@ -640,7 +644,6 @@ public:
|
||||
#endif
|
||||
|
||||
bool init_collapse_toolbar();
|
||||
void enable_collapse_toolbar(bool enable);
|
||||
|
||||
const Camera& get_camera() const;
|
||||
Camera& get_camera();
|
||||
@ -693,7 +696,7 @@ public:
|
||||
|
||||
const GLToolbar& get_collapse_toolbar() const;
|
||||
GLToolbar& get_collapse_toolbar();
|
||||
|
||||
int get_collapse_toolbar_size();
|
||||
void update_preview_bottom_toolbar();
|
||||
void update_preview_moves_slider();
|
||||
void enable_preview_moves_slider(bool enable);
|
||||
|
Loading…
x
Reference in New Issue
Block a user