Deleted unused UI-settings ("Set settings tabs as menu items" and "New layout, access via settings button in the top menu")

This commit is contained in:
YuSanka 2024-04-17 11:14:19 +02:00 committed by Lukas Matena
parent 45899c8c19
commit c95bc97435
9 changed files with 14 additions and 263 deletions

View File

@ -101,9 +101,6 @@ void AppConfig::set_defaults()
if (get("associate_stl").empty())
set("associate_stl", "0");
if (get("tabs_as_menu").empty())
set("tabs_as_menu", "0");
if (get("suppress_round_corners").empty())
set("suppress_round_corners", "1");
#endif // _WIN32

View File

@ -5145,8 +5145,7 @@ bool GLCanvas3D::_init_main_toolbar()
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ;
item.sprite_id = 10;
item.enabling_callback = GLToolbarItem::Default_Enabling_Callback;
item.visibility_callback = []() { return wxGetApp().app_config->get_bool("new_settings_layout_mode") ||
wxGetApp().app_config->get_bool("dlg_settings_layout_mode"); };
item.visibility_callback = []() { return wxGetApp().app_config->get_bool("dlg_settings_layout_mode"); };
item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); };
if (!m_main_toolbar.add_item(item))
return false;

View File

@ -1823,11 +1823,6 @@ void GUI_App::set_mode_palette(const std::vector<wxColour>& palette)
}
}
bool GUI_App::tabs_as_menu() const
{
return app_config->get_bool("tabs_as_menu"); // || dark_mode();
}
bool GUI_App::suppress_round_corners() const
{
return true;// app_config->get("suppress_round_corners") == "1";
@ -2479,8 +2474,7 @@ void GUI_App::update_mode()
{
sidebar().update_mode();
if (!wxGetApp().tabs_as_menu())
dynamic_cast<TopBar*>(mainframe->m_tabpanel)->UpdateMode();
dynamic_cast<TopBar*>(mainframe->m_tabpanel)->UpdateMode();
for (auto tab : tabs_list)
tab->update_mode();

View File

@ -265,7 +265,6 @@ public:
const wxFont& code_font() { return m_code_font; }
const wxFont& link_font() { return m_link_font; }
int em_unit() const { return m_em_unit; }
bool tabs_as_menu() const;
bool suppress_round_corners() const;
wxSize get_min_size(wxWindow* display_win) const;
int get_max_font_pt_size();

View File

@ -317,91 +317,6 @@ DPIFrame(NULL, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_S
}
}
#ifdef _MSW_DARK_MODE
static wxString pref() { return " [ "; }
static wxString suff() { return " ] "; }
static void append_tab_menu_items_to_menubar(wxMenuBar* bar, PrinterTechnology pt, bool is_mainframe_menu)
{
if (is_mainframe_menu)
bar->Append(new wxMenu(), pref() + _L("Plater") + suff());
for (const wxString& title : { is_mainframe_menu ? _L("Print Settings") : pref() + _L("Print Settings") + suff(),
pt == ptSLA ? _L("Material Settings") : _L("Filament Settings"),
_L("Printer Settings") })
bar->Append(new wxMenu(), title);
}
// update markers for selected/unselected menu items
static void update_marker_for_tabs_menu(wxMenuBar* bar, const wxString& title, bool is_mainframe_menu)
{
if (!bar)
return;
size_t items_cnt = bar->GetMenuCount();
for (size_t id = items_cnt - (is_mainframe_menu ? 4 : 3); id < items_cnt; id++) {
wxString label = bar->GetMenuLabel(id);
if (label.First(pref()) == 0) {
if (label == pref() + title + suff())
return;
label.Remove(size_t(0), pref().Len());
label.RemoveLast(suff().Len());
bar->SetMenuLabel(id, label);
break;
}
}
if (int id = bar->FindMenu(title); id != wxNOT_FOUND)
bar->SetMenuLabel(id, pref() + title + suff());
}
static void add_tabs_as_menu(wxMenuBar* bar, MainFrame* main_frame, wxWindow* bar_parent)
{
PrinterTechnology pt = main_frame->plater() ? main_frame->plater()->printer_technology() : ptFFF;
bool is_mainframe_menu = bar_parent == main_frame;
if (!is_mainframe_menu)
append_tab_menu_items_to_menubar(bar, pt, is_mainframe_menu);
bar_parent->Bind(wxEVT_MENU_OPEN, [main_frame, bar, is_mainframe_menu](wxMenuEvent& event) {
wxMenu* const menu = event.GetMenu();
if (!menu || menu->GetMenuItemCount() > 0) {
// If we are here it means that we open regular menu and not a tab used as a menu
event.Skip(); // event.Skip() is verry important to next processing of the wxEVT_UPDATE_UI by this menu items.
// If wxEVT_MENU_OPEN will not be pocessed in next event queue then MenuItems of this menu will never caught wxEVT_UPDATE_UI
// and, as a result, "check/radio value" will not be updated
return;
}
// update tab selection
const wxString& title = menu->GetTitle();
if (title == _L("Plater"))
main_frame->select_tab(size_t(0));
else if (title == _L("Print Settings"))
main_frame->select_tab(wxGetApp().get_tab(main_frame->plater()->printer_technology() == ptFFF ? Preset::TYPE_PRINT : Preset::TYPE_SLA_PRINT));
else if (title == _L("Filament Settings"))
main_frame->select_tab(wxGetApp().get_tab(Preset::TYPE_FILAMENT));
else if (title == _L("Material Settings"))
main_frame->select_tab(wxGetApp().get_tab(Preset::TYPE_SLA_MATERIAL));
else if (title == _L("Printer Settings"))
main_frame->select_tab(wxGetApp().get_tab(Preset::TYPE_PRINTER));
// update markers for selected/unselected menu items
update_marker_for_tabs_menu(bar, title, is_mainframe_menu);
});
}
void MainFrame::show_tabs_menu(bool show)
{
if (!m_menubar)
return;
if (show)
append_tab_menu_items_to_menubar(m_menubar, plater() ? plater()->printer_technology() : ptFFF, true);
else
while (m_menubar->GetMenuCount() >= 8) {
if (wxMenu* menu = m_menubar->Remove(7))
delete menu;
}
}
#endif // _MSW_DARK_MODE
void MainFrame::update_layout()
{
auto restore_to_creation = [this]() {
@ -442,7 +357,6 @@ void MainFrame::update_layout()
ESettingsLayout layout = wxGetApp().is_gcode_viewer() ? ESettingsLayout::GCodeViewer :
(wxGetApp().app_config->get_bool("old_settings_layout_mode") ? ESettingsLayout::Old :
wxGetApp().app_config->get_bool("new_settings_layout_mode") ? ( wxGetApp().tabs_as_menu() ? ESettingsLayout::Old : ESettingsLayout::New) :
wxGetApp().app_config->get_bool("dlg_settings_layout_mode") ? ESettingsLayout::Dlg : ESettingsLayout::Old);
if (m_layout == layout)
@ -484,12 +398,7 @@ void MainFrame::update_layout()
{
m_plater->Reparent(m_tabpanel);
m_plater->Layout();
#ifdef _WIN32
if (wxGetApp().tabs_as_menu())
m_tabpanel->InsertPage(0, m_plater, _L("Plater"));
else
#endif
dynamic_cast<TopBar*>(m_tabpanel)->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true);
dynamic_cast<TopBar*>(m_tabpanel)->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true);
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 1);
m_plater->Show();
@ -498,26 +407,6 @@ void MainFrame::update_layout()
if (old_layout == ESettingsLayout::Dlg)
if (int sel = m_tabpanel->GetSelection(); sel != wxNOT_FOUND)
m_tabpanel->SetSelection(sel+1);// call SetSelection to correct layout after switching from Dlg to Old mode
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu())
show_tabs_menu(true);
#endif
break;
}
case ESettingsLayout::New:
{
m_main_sizer->Add(m_plater, 1, wxEXPAND);
m_tabpanel->Hide();
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);
m_plater_page = new wxPanel(m_tabpanel);
#ifdef _WIN32
if (wxGetApp().tabs_as_menu())
m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab
else
#endif
dynamic_cast<TopBar*>(m_tabpanel)->InsertNewPage(0, m_plater_page, _L("Plater"), std::string("plater"), true);
m_plater->Show();
break;
}
case ESettingsLayout::Dlg:
@ -527,11 +416,6 @@ void MainFrame::update_layout()
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 2);
m_tabpanel->Show();
m_plater->Show();
#ifdef _WIN32
if (wxGetApp().tabs_as_menu())
show_tabs_menu(false);
#endif
break;
}
case ESettingsLayout::GCodeViewer:
@ -574,20 +458,6 @@ void MainFrame::update_layout()
}
}
#endif //__WXMSW__
//#ifdef __APPLE__
// // Using SetMinSize() on Mac messes up the window position in some cases
// // cf. https://groups.google.com/forum/#!topic/wx-users/yUKPBBfXWO0
// // So, if we haven't possibility to set MinSize() for the MainFrame,
// // set the MinSize() as a half of regular for the m_plater and m_tabpanel, when settings layout is in slNew mode
// // Otherwise, MainFrame will be maximized by height
// if (m_layout == ESettingsLayout::New) {
// wxSize size = wxGetApp().get_min_size();
// size.SetHeight(int(0.5 * size.GetHeight()));
// m_plater->SetMinSize(size);
// m_tabpanel->SetMinSize(size);
// }
//#endif
Layout();
Thaw();
@ -710,13 +580,6 @@ void MainFrame::init_tabpanel()
// wxNB_NOPAGETHEME: Disable Windows Vista theme for the Notebook background. The theme performance is terrible on Windows 10
// with multiple high resolution displays connected.
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu()) {
m_tabpanel = new wxSimplebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
// wxGetApp().UpdateDarkUI(m_tabpanel);
}
else
#endif
m_tabpanel = new TopBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
m_tabpanel->SetFont(Slic3r::GUI::wxGetApp().normal_font());
@ -748,10 +611,6 @@ void MainFrame::init_tabpanel()
// before the MainFrame is fully set up.
tab->OnActivate();
m_last_selected_tab = m_tabpanel->GetSelection();
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu())
tab->SetFocus();
#endif
}
else
select_tab(size_t(0)); // select Plater
@ -972,14 +831,8 @@ void MainFrame::add_created_tab(Tab* panel, const std::string& bmp_name /*= ""*
const auto printer_tech = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
if (panel->supports_printer_technology(printer_tech)) {
#ifdef _WIN32
if (wxGetApp().tabs_as_menu())
m_tabpanel->AddPage(panel, panel->title());
else
#endif
dynamic_cast<TopBar*>(m_tabpanel)->AddNewPage(panel, panel->title(), bmp_name);
}
if (panel->supports_printer_technology(printer_tech))
dynamic_cast<TopBar*>(m_tabpanel)->AddNewPage(panel, panel->title(), bmp_name);
}
bool MainFrame::is_active_and_shown_tab(Tab* tab)
@ -991,9 +844,6 @@ bool MainFrame::is_active_and_shown_tab(Tab* tab)
if (m_layout == ESettingsLayout::Dlg)
return m_settings_dialog.IsShown();
if (m_layout == ESettingsLayout::New)
return m_main_sizer->IsShown(m_tabpanel);
return true;
}
@ -1122,7 +972,6 @@ bool MainFrame::can_change_view() const
switch (m_layout)
{
default: { return false; }
case ESettingsLayout::New: { return m_plater->IsShown(); }
case ESettingsLayout::Dlg: { return true; }
case ESettingsLayout::Old: {
int page_id = m_tabpanel->GetSelection();
@ -1164,8 +1013,7 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
#ifdef _WIN32
// update common mode sizer
if (!wxGetApp().tabs_as_menu())
dynamic_cast<TopBar*>(m_tabpanel)->Rescale();
dynamic_cast<TopBar*>(m_tabpanel)->Rescale();
#endif
// update Plater
@ -1210,9 +1058,8 @@ void MainFrame::on_sys_color_changed()
wxGetApp().update_ui_colours_from_appconfig();
#ifdef __WXMSW__
wxGetApp().UpdateDarkUI(m_tabpanel);
if (!wxGetApp().tabs_as_menu())
#endif
dynamic_cast<TopBar*>(m_tabpanel)->OnColorsChanged();
dynamic_cast<TopBar*>(m_tabpanel)->OnColorsChanged();
// update Plater
wxGetApp().plater()->sys_color_changed();
@ -1236,8 +1083,7 @@ void MainFrame::on_sys_color_changed()
void MainFrame::update_mode_markers()
{
// update markers in common mode sizer
if (!wxGetApp().tabs_as_menu())
dynamic_cast<TopBar*>(m_tabpanel)->UpdateModeMarkers();
dynamic_cast<TopBar*>(m_tabpanel)->UpdateModeMarkers();
// update mode markers in tabs
for (auto tab : wxGetApp().tabs_list)
@ -2095,14 +1941,7 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
if (m_tabpanel->GetSelection() != (int)new_selection)
m_tabpanel->SetSelection(new_selection);
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu()) {
if (Tab* cur_tab = dynamic_cast<Tab*>(m_tabpanel->GetPage(new_selection)))
update_marker_for_tabs_menu((m_layout == ESettingsLayout::Old ? m_menubar : m_settings_dialog.menubar()), cur_tab->title(), m_layout == ESettingsLayout::Old);
else if (tab == 0 && m_layout == ESettingsLayout::Old)
m_plater->get_current_canvas3D()->render();
}
#endif
if (tab == 0 && m_layout == ESettingsLayout::Old)
m_plater->canvas3D()->render();
else if (was_hidden) {
@ -2143,26 +1982,11 @@ void MainFrame::select_tab(size_t tab/* = size_t(-1)*/)
if (m_settings_dialog.IsIconized())
m_settings_dialog.Iconize(false);
}
else if (m_layout == ESettingsLayout::New) {
m_main_sizer->Show(m_plater, tab == 0);
tabpanel_was_hidden = !m_main_sizer->IsShown(m_tabpanel);
select(tabpanel_was_hidden);
m_main_sizer->Show(m_tabpanel, tab != 0);
// plater should be focused for correct navigation inside search window
if (tab == 0)
m_plater->SetFocus();
Layout();
}
else {
select(false);
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu() && tab == 0)
m_plater->SetFocus();
#endif
}
// When we run application in ESettingsLayout::New or ESettingsLayout::Dlg mode, tabpanel is hidden from the very beginning
// When we run application in ESettingsLayout::Dlg mode, tabpanel is hidden from the very beginning
// and as a result Tab::update_changed_tree_ui() function couldn't update m_is_nonsys_values values,
// which are used for update TreeCtrl and "revert_buttons".
// So, force the call of this function for Tabs, if tab panel was hidden
@ -2333,15 +2157,6 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
//just hide the Frame on closing
this->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent& evt) { this->Hide(); });
#ifdef _MSW_DARK_MODE
if (wxGetApp().tabs_as_menu()) {
// menubar
m_menubar = new wxMenuBar();
add_tabs_as_menu(m_menubar, mainframe, this);
this->SetMenuBar(m_menubar);
}
#endif
// initialize layout
auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->SetSizeHints(this);
@ -2369,9 +2184,7 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
const wxSize& size = wxSize(85 * em, 50 * em);
#ifdef _WIN32
// update common mode sizer
if (!wxGetApp().tabs_as_menu())
dynamic_cast<TopBar*>(m_tabpanel)->Rescale();
dynamic_cast<TopBar*>(m_tabpanel)->Rescale();
#endif
// update Tabs

View File

@ -143,7 +143,6 @@ class MainFrame : public DPIFrame
{
Unknown,
Old,
New,
Dlg,
GCodeViewer
};
@ -181,9 +180,6 @@ public:
void update_menubar();
// Open item in menu by menu and item name (in actual language)
void open_menubar_item(const wxString& menu_name,const wxString& item_name);
#ifdef _WIN32
void show_tabs_menu(bool show);
#endif
void update_ui_from_settings();
bool is_loaded() const { return m_loaded; }
bool is_last_input_file() const { return !m_qs_last_input_file.IsEmpty(); }

View File

@ -502,15 +502,6 @@ void PreferencesDialog::build()
wxGetApp().plater()->get_current_canvas3D()->render();
return;
}
if (opt_key == "tabs_as_menu") {
bool disable_new_layout = boost::any_cast<bool>(value);
m_rb_new_settings_layout_mode->Show(!disable_new_layout);
if (disable_new_layout && m_rb_new_settings_layout_mode->GetValue()) {
m_rb_new_settings_layout_mode->SetValue(false);
m_rb_old_settings_layout_mode->SetValue(true);
}
refresh_og(m_optgroup_gui);
}
if (auto it = m_values.find(opt_key); it != m_values.end()) {
m_values.erase(it); // we shouldn't change value, if some of those parameters were selected, and then deselected
@ -564,13 +555,6 @@ void PreferencesDialog::build()
L("If enabled, related notification will be shown, when sliced object looks like a logo or a sign."),
app_config->get_bool("allow_auto_color_change"));
#ifdef _MSW_DARK_MODE
append_bool_option(m_optgroup_gui, "tabs_as_menu",
L("Set settings tabs as menu items"),
L("If enabled, Settings Tabs will be placed as menu items. If disabled, old UI will be used."),
app_config->get_bool("tabs_as_menu"));
#endif
m_optgroup_gui->append_separator();
/*
append_bool_option(m_optgroup_gui, "suppress_round_corners",
@ -766,7 +750,7 @@ void PreferencesDialog::accept(wxEvent&)
#endif //(__linux__) && defined(SLIC3R_DESKTOP_INTEGRATION)
}
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu", "sys_menu_enabled", "font_pt_size", "suppress_round_corners" };
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "sys_menu_enabled", "font_pt_size", "suppress_round_corners" };
for (const std::string& option : options_to_recreate_GUI) {
if (m_values.find(option) != m_values.end()) {
@ -797,7 +781,6 @@ void PreferencesDialog::accept(wxEvent&)
m_settings_layout_changed = false;
for (const std::string& key : { "old_settings_layout_mode",
"new_settings_layout_mode",
"dlg_settings_layout_mode" })
{
auto it = m_values.find(key);
@ -875,11 +858,6 @@ void PreferencesDialog::revert(wxEvent&)
m_settings_layout_changed = false;
continue;
}
if (key == "new_settings_layout_mode") {
m_rb_new_settings_layout_mode->SetValue(app_config->get_bool(key));
m_settings_layout_changed = false;
continue;
}
if (key == "dlg_settings_layout_mode") {
m_rb_dlg_settings_layout_mode->SetValue(app_config->get_bool(key));
m_settings_layout_changed = false;
@ -897,11 +875,6 @@ void PreferencesDialog::revert(wxEvent&)
if (opt_group->set_value(key, app_config->get_bool(key)))
break;
}
if (key == "tabs_as_menu") {
m_rb_new_settings_layout_mode->Show(!app_config->get_bool(key));
refresh_og(m_optgroup_gui);
continue;
}
}
clear_cache();
@ -1026,7 +999,6 @@ void PreferencesDialog::create_settings_mode_widget()
auto app_config = get_app_config();
std::vector<wxString> choices = { _L("Old regular layout with the tab bar"),
_L("New layout, access via settings button in the top menu"),
_L("Settings in non-modal window") };
int id = -1;
auto add_radio = [this, parent, stb_sizer, choices](wxRadioButton** rb, int id, bool select) {
@ -1035,25 +1007,13 @@ void PreferencesDialog::create_settings_mode_widget()
(*rb)->SetValue(select);
(*rb)->Bind(wxEVT_RADIOBUTTON, [this, id](wxCommandEvent&) {
m_values["old_settings_layout_mode"] = (id == 0) ? "1" : "0";
m_values["new_settings_layout_mode"] = (id == 1) ? "1" : "0";
m_values["dlg_settings_layout_mode"] = (id == 2) ? "1" : "0";
m_values["dlg_settings_layout_mode"] = (id == 1) ? "1" : "0";
});
};
add_radio(&m_rb_old_settings_layout_mode, ++id, app_config->get_bool("old_settings_layout_mode"));
add_radio(&m_rb_new_settings_layout_mode, ++id, app_config->get_bool("new_settings_layout_mode"));
add_radio(&m_rb_dlg_settings_layout_mode, ++id, app_config->get_bool("dlg_settings_layout_mode"));
#ifdef _MSW_DARK_MODE
if (app_config->get_bool("tabs_as_menu")) {
m_rb_new_settings_layout_mode->Hide();
if (m_rb_new_settings_layout_mode->GetValue()) {
m_rb_new_settings_layout_mode->SetValue(false);
m_rb_old_settings_layout_mode->SetValue(true);
}
}
#endif
std::string opt_key = "settings_layout_mode";
m_blinkers[opt_key] = new BlinkingBitmap(parent);

View File

@ -57,7 +57,6 @@ class PreferencesDialog : public DPIDialog
wxSizer* m_icon_size_sizer {nullptr};
wxSlider* m_icon_size_slider {nullptr};
wxRadioButton* m_rb_old_settings_layout_mode {nullptr};
wxRadioButton* m_rb_new_settings_layout_mode {nullptr};
wxRadioButton* m_rb_dlg_settings_layout_mode {nullptr};
wxColourPickerCtrl* m_sys_colour {nullptr};

View File

@ -3658,13 +3658,7 @@ void Tab::load_current_preset()
}
if (tab->supports_printer_technology(printer_technology))
{
#ifdef _WIN32
if (wxGetApp().tabs_as_menu())
wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title());
else
#endif
dynamic_cast<TopBar*>(wxGetApp().tab_panel())->InsertNewPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title(),"");
dynamic_cast<TopBar*>(wxGetApp().tab_panel())->InsertNewPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title(),"");
}
else {
int page_id = wxGetApp().tab_panel()->FindPage(tab);