MSW specific: Implementation of the own notebook control
* MSW specific: First implementation of the Notebook control to support Dark/Light color modes * MSW specific: Set mode sizer to the Notebook control. * MSW specific: Added icons to the Notepad control + There is no need to restart application after the changing of the color mode * Fixed non-MSW build * Updated color for SavePresetDialog + Added wrapper to wxMessageBox for mom-MSW platforms
This commit is contained in:
parent
7fce368cca
commit
4652733201
25 changed files with 703 additions and 135 deletions
|
@ -181,6 +181,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/Mouse3DController.hpp
|
||||
GUI/DoubleSlider.cpp
|
||||
GUI/DoubleSlider.hpp
|
||||
GUI/Notebook.cpp
|
||||
GUI/Notebook.hpp
|
||||
GUI/ObjectDataViewModel.cpp
|
||||
GUI/ObjectDataViewModel.hpp
|
||||
GUI/InstanceCheck.cpp
|
||||
|
|
|
@ -10,7 +10,6 @@ namespace boost::filesystem { class path; }
|
|||
|
||||
class wxWindow;
|
||||
class wxMenuBar;
|
||||
class wxNotebook;
|
||||
class wxComboCtrl;
|
||||
class wxFileDialog;
|
||||
class wxTopLevelWindow;
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
#include "DesktopIntegrationDialog.hpp"
|
||||
|
||||
#include "BitmapCache.hpp"
|
||||
#include "Notebook.hpp"
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include <dbt.h>
|
||||
|
@ -929,8 +930,6 @@ bool GUI_App::on_init_inner()
|
|||
if (scrn && is_editor())
|
||||
scrn->SetText(_L("Preparing settings tabs") + dots);
|
||||
|
||||
m_tabs_as_menu = dark_mode() || app_config->get("tabs_as_menu") == "1";
|
||||
|
||||
mainframe = new MainFrame();
|
||||
// hide settings tabs after first Layout
|
||||
if (is_editor())
|
||||
|
@ -1043,6 +1042,7 @@ void GUI_App::init_label_colours()
|
|||
m_color_highlight_label_default = is_dark_mode ? wxColour(230, 230, 230): wxSystemSettings::GetColour(/*wxSYS_COLOUR_HIGHLIGHTTEXT*/wxSYS_COLOUR_WINDOWTEXT);
|
||||
m_color_highlight_default = is_dark_mode ? wxColour(78, 78, 78) : wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
|
||||
m_color_hovered_btn_label = is_dark_mode ? wxColour(253, 111, 40) : wxColour(252, 77, 1);
|
||||
m_color_selected_btn_bg = is_dark_mode ? wxColour(95, 73, 62) : wxColour(228, 220, 216);
|
||||
#else
|
||||
m_color_label_default = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
|
||||
#endif
|
||||
|
@ -1090,24 +1090,22 @@ void GUI_App::UpdateDarkUI(wxWindow* window, bool highlited/* = false*/, bool ju
|
|||
btn->Bind(wxEVT_LEAVE_WINDOW, [focus_button](wxMouseEvent& event) { focus_button(false); event.Skip(); });
|
||||
}
|
||||
}
|
||||
else if (dark_mode()) {
|
||||
if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
|
||||
if (text->GetBorder() != wxBORDER_SIMPLE)
|
||||
text->SetWindowStyle(text->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
}
|
||||
else if (wxCheckListBox* list = dynamic_cast<wxCheckListBox*>(window)) {
|
||||
list->SetWindowStyle(list->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
list->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
for (size_t i = 0; i < list->GetCount(); i++)
|
||||
if (wxOwnerDrawn* item = list->GetItem(i)) {
|
||||
item->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
item->SetTextColour(m_color_label_default);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (dynamic_cast<wxListBox*>(window))
|
||||
window->SetWindowStyle(window->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
else if (wxTextCtrl* text = dynamic_cast<wxTextCtrl*>(window)) {
|
||||
if (text->GetBorder() != wxBORDER_SIMPLE)
|
||||
text->SetWindowStyle(text->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
}
|
||||
else if (wxCheckListBox* list = dynamic_cast<wxCheckListBox*>(window)) {
|
||||
list->SetWindowStyle(list->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
list->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
for (size_t i = 0; i < list->GetCount(); i++)
|
||||
if (wxOwnerDrawn* item = list->GetItem(i)) {
|
||||
item->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
item->SetTextColour(m_color_label_default);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (dynamic_cast<wxListBox*>(window))
|
||||
window->SetWindowStyle(window->GetWindowStyle() | wxBORDER_SIMPLE);
|
||||
|
||||
if (!just_font)
|
||||
window->SetBackgroundColour(highlited ? m_color_highlight_default : m_color_window_default);
|
||||
|
@ -1138,8 +1136,6 @@ void GUI_App::UpdateDlgDarkUI(wxDialog* dlg)
|
|||
void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!dark_mode())
|
||||
return;
|
||||
UpdateDarkUI(dvc, highlited);
|
||||
wxItemAttr attr(dark_mode() ? m_color_highlight_default : m_color_label_default,
|
||||
m_color_window_default,
|
||||
|
@ -1155,8 +1151,6 @@ void GUI_App::UpdateDVCDarkUI(wxDataViewCtrl* dvc, bool highlited/* = false*/)
|
|||
void GUI_App::UpdateAllStaticTextDarkUI(wxWindow* parent)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!dark_mode())
|
||||
return;
|
||||
wxGetApp().UpdateDarkUI(parent);
|
||||
|
||||
auto children = parent->GetChildren();
|
||||
|
@ -1222,6 +1216,11 @@ void GUI_App::set_label_clr_sys(const wxColour& clr)
|
|||
app_config->save();
|
||||
}
|
||||
|
||||
bool GUI_App::tabs_as_menu() const
|
||||
{
|
||||
return app_config->get("tabs_as_menu") == "1"; // || dark_mode();
|
||||
}
|
||||
|
||||
wxSize GUI_App::get_min_size() const
|
||||
{
|
||||
return wxSize(76*m_em_unit, 49 * m_em_unit);
|
||||
|
@ -1366,6 +1365,14 @@ void fatal_error(wxWindow* parent)
|
|||
// exit 1; // #ys_FIXME
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
void GUI_App::force_colors_update()
|
||||
{
|
||||
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
|
||||
m_force_colors_update = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Called after the Preferences dialog is closed and the program settings are saved.
|
||||
// Update the UI based on the current preferences.
|
||||
void GUI_App::update_ui_from_settings()
|
||||
|
@ -1373,13 +1380,13 @@ void GUI_App::update_ui_from_settings()
|
|||
update_label_colours();
|
||||
mainframe->update_ui_from_settings();
|
||||
|
||||
#if 0 //#ifdef _WIN32 // #ysDarkMSW - Use to force dark colors for SystemLightMode
|
||||
if (m_force_sys_colors_update) {
|
||||
m_force_sys_colors_update = false;
|
||||
mainframe->force_sys_color_changed();
|
||||
mainframe->diff_dialog.force_sys_color_changed();
|
||||
#ifdef _WIN32
|
||||
if (m_force_colors_update) {
|
||||
m_force_colors_update = false;
|
||||
mainframe->force_color_changed();
|
||||
mainframe->diff_dialog.force_color_changed();
|
||||
if (m_wizard)
|
||||
m_wizard->force_sys_color_changed();
|
||||
m_wizard->force_color_changed();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -1763,6 +1770,11 @@ void GUI_App::update_mode()
|
|||
{
|
||||
sidebar().update_mode();
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(mainframe->m_tabpanel)->UpdateMode();
|
||||
#endif
|
||||
|
||||
for (auto tab : tabs_list)
|
||||
tab->update_mode();
|
||||
|
||||
|
@ -1902,13 +1914,6 @@ void GUI_App::add_config_menu(wxMenuBar *menu)
|
|||
this->plater_->refresh_print();
|
||||
|
||||
if (dlg.recreate_GUI()) {
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (dlg.color_mode_changed()) {
|
||||
NppDarkMode::SetDarkMode(app_config->get("dark_color_mode") == "1");
|
||||
init_label_colours();
|
||||
}
|
||||
#endif
|
||||
m_tabs_as_menu = dark_mode() || app_config->get("tabs_as_menu") == "1";
|
||||
recreate_GUI(_L("Restart application") + dots);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -124,11 +124,10 @@ private:
|
|||
wxColour m_color_highlight_label_default;
|
||||
wxColour m_color_hovered_btn_label;
|
||||
wxColour m_color_highlight_default;
|
||||
//bool m_force_sys_colors_update { false }; // #ysDarkMSW - Use to force dark colors for SystemLightMode
|
||||
wxColour m_color_selected_btn_bg;
|
||||
bool m_force_colors_update { false };
|
||||
#endif
|
||||
|
||||
bool m_tabs_as_menu{ false };
|
||||
|
||||
wxFont m_small_font;
|
||||
wxFont m_bold_font;
|
||||
wxFont m_normal_font;
|
||||
|
@ -202,7 +201,9 @@ public:
|
|||
#ifdef _WIN32
|
||||
const wxColour& get_label_highlight_clr() { return m_color_highlight_label_default; }
|
||||
const wxColour& get_highlight_default_clr() { return m_color_highlight_default; }
|
||||
// void force_sys_colors_update() { m_force_sys_colors_update = true; } // #ysDarkMSW - Use to force dark colors for SystemLightMode
|
||||
const wxColour& get_color_hovered_btn_label() { return m_color_hovered_btn_label; }
|
||||
const wxColour& get_color_selected_btn_bg() { return m_color_selected_btn_bg; }
|
||||
void force_colors_update();
|
||||
#endif
|
||||
|
||||
const wxFont& small_font() { return m_small_font; }
|
||||
|
@ -210,7 +211,7 @@ public:
|
|||
const wxFont& normal_font() { return m_normal_font; }
|
||||
const wxFont& code_font() { return m_code_font; }
|
||||
int em_unit() const { return m_em_unit; }
|
||||
bool tabs_as_menu() const { return m_tabs_as_menu;}
|
||||
bool tabs_as_menu() const;
|
||||
wxSize get_min_size() const;
|
||||
float toolbar_icon_scale(const bool is_limited = false) const;
|
||||
void set_auto_toolbar_icon_scale(float scale) const;
|
||||
|
|
|
@ -1115,5 +1115,20 @@ void MenuFactory::sys_color_changed()
|
|||
}
|
||||
}
|
||||
|
||||
void MenuFactory::sys_color_changed(wxMenuBar* menubar)
|
||||
{
|
||||
for (size_t id = 0; id < menubar->GetMenuCount(); id++) {
|
||||
wxMenu* menu = menubar->GetMenu(id);
|
||||
msw_rescale_menu(menu);
|
||||
#ifdef _WIN32
|
||||
// but under MSW we have to update item's bachground color
|
||||
for (wxMenuItem* item : menu->GetMenuItems())
|
||||
update_menu_item_def_colors(item);
|
||||
#endif
|
||||
}
|
||||
menubar->Refresh();
|
||||
}
|
||||
|
||||
|
||||
} //namespace GUI
|
||||
} //namespace Slic3r
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
void msw_rescale();
|
||||
void sys_color_changed();
|
||||
|
||||
static void sys_color_changed(wxMenuBar* menu_bar);
|
||||
|
||||
wxMenu* default_menu();
|
||||
wxMenu* object_menu();
|
||||
wxMenu* sla_object_menu();
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include <string>
|
||||
#include "libslic3r/GCode/GCodeProcessor.hpp"
|
||||
|
||||
class wxNotebook;
|
||||
class wxGLCanvas;
|
||||
class wxBoxSizer;
|
||||
class wxStaticText;
|
||||
|
|
|
@ -174,7 +174,7 @@ bool check_dark_mode() {
|
|||
#ifdef _WIN32
|
||||
void update_dark_ui(wxWindow* window)
|
||||
{
|
||||
bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1" ? true : check_dark_mode();
|
||||
bool is_dark = wxGetApp().app_config->get("dark_color_mode") == "1";// ? true : check_dark_mode();// #ysDarkMSW - Allow it when we deside to support the sustem colors for application
|
||||
window->SetBackgroundColour(is_dark ? wxColour(43, 43, 43) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
window->SetForegroundColour(is_dark ? wxColour(250, 250, 250) : wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
|
||||
}
|
||||
|
|
|
@ -175,8 +175,8 @@ public:
|
|||
const wxFont& normal_font() const { return m_normal_font; }
|
||||
void enable_force_rescale() { m_force_rescale = true; }
|
||||
|
||||
#if 0 //#ifdef _WIN32 // #ysDarkMSW - Use to force dark colors for SystemLightMode
|
||||
void force_sys_color_changed()
|
||||
#ifdef _WIN32
|
||||
void force_color_changed()
|
||||
{
|
||||
update_dark_ui(this);
|
||||
on_sys_color_changed();
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
#include "I18N.hpp"
|
||||
#include "libslic3r/Utils.hpp"
|
||||
#include "GUI.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include <wx/scrolwin.h>
|
||||
#include <wx/display.h>
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "MainFrame.hpp"
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/listbook.h>
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -18,8 +18,6 @@ KBShortcutsDialog::KBShortcutsDialog()
|
|||
: DPIDialog(static_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, wxString(wxGetApp().is_editor() ? SLIC3R_APP_NAME : GCODEVIEWER_APP_NAME) + " - " + _L("Keyboard Shortcuts"),
|
||||
wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
// SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
|
||||
// fonts
|
||||
const wxFont& font = wxGetApp().normal_font();
|
||||
const wxFont& bold_font = wxGetApp().bold_font();
|
||||
|
@ -31,13 +29,10 @@ KBShortcutsDialog::KBShortcutsDialog()
|
|||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
wxBookCtrlBase* book;
|
||||
if (wxGetApp().dark_mode()) {
|
||||
book = new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
|
||||
wxGetApp().UpdateDarkUI(book);
|
||||
wxGetApp().UpdateDarkUI(dynamic_cast<wxListbook*>(book)->GetListView());
|
||||
}
|
||||
else
|
||||
book = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
|
||||
// if (wxGetApp().dark_mode())
|
||||
book = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
|
||||
/* else
|
||||
book = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);*/
|
||||
#else
|
||||
wxNotebook* book = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP);
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
#include "GUI_App.hpp"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
#include "GUI_Factories.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <dbt.h>
|
||||
|
@ -427,8 +429,13 @@ void MainFrame::update_layout()
|
|||
case ESettingsLayout::Old:
|
||||
{
|
||||
m_plater->Reparent(m_tabpanel);
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater, _L("Plater"), std::string("plater"));
|
||||
else
|
||||
#endif
|
||||
m_tabpanel->InsertPage(0, m_plater, _L("Plater"));
|
||||
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);
|
||||
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 1);
|
||||
m_plater->Show();
|
||||
m_tabpanel->Show();
|
||||
// update Tabs
|
||||
|
@ -447,6 +454,11 @@ void MainFrame::update_layout()
|
|||
m_tabpanel->Hide();
|
||||
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND);
|
||||
m_plater_page = new wxPanel(m_tabpanel);
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->InsertPage(0, m_plater_page, _L("Plater"), std::string("plater"));
|
||||
else
|
||||
#endif
|
||||
m_tabpanel->InsertPage(0, m_plater_page, _L("Plater")); // empty panel just for Plater tab */
|
||||
m_plater->Show();
|
||||
break;
|
||||
|
@ -455,7 +467,7 @@ void MainFrame::update_layout()
|
|||
{
|
||||
m_main_sizer->Add(m_plater, 1, wxEXPAND);
|
||||
m_tabpanel->Reparent(&m_settings_dialog);
|
||||
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND);
|
||||
m_settings_dialog.GetSizer()->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 2);
|
||||
m_tabpanel->Show();
|
||||
m_plater->Show();
|
||||
|
||||
|
@ -476,6 +488,11 @@ void MainFrame::update_layout()
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// Sizer with buttons for mode changing
|
||||
m_plater->sidebar().show_mode_sizer(wxGetApp().tabs_as_menu() || m_layout != ESettingsLayout::Old);
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
if (update_scaling_state != State::noUpdate)
|
||||
{
|
||||
|
@ -640,7 +657,7 @@ void MainFrame::init_tabpanel()
|
|||
wxGetApp().UpdateDarkUI(m_tabpanel);
|
||||
}
|
||||
else
|
||||
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
|
||||
m_tabpanel = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME, true);
|
||||
#else
|
||||
m_tabpanel = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME);
|
||||
#endif
|
||||
|
@ -652,7 +669,7 @@ void MainFrame::init_tabpanel()
|
|||
m_settings_dialog.set_tabpanel(m_tabpanel);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
m_tabpanel->Bind(/*wxEVT_LISTBOOK_PAGE_CHANGED*/wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
|
||||
m_tabpanel->Bind(wxEVT_BOOKCTRL_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
|
||||
#else
|
||||
m_tabpanel->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, [this](wxBookCtrlEvent& e) {
|
||||
#endif
|
||||
|
@ -763,20 +780,25 @@ void MainFrame::register_win32_callbacks()
|
|||
void MainFrame::create_preset_tabs()
|
||||
{
|
||||
wxGetApp().update_label_colours_from_appconfig();
|
||||
add_created_tab(new TabPrint(m_tabpanel));
|
||||
add_created_tab(new TabFilament(m_tabpanel));
|
||||
add_created_tab(new TabSLAPrint(m_tabpanel));
|
||||
add_created_tab(new TabSLAMaterial(m_tabpanel));
|
||||
add_created_tab(new TabPrinter(m_tabpanel));
|
||||
add_created_tab(new TabPrint(m_tabpanel), "cog");
|
||||
add_created_tab(new TabFilament(m_tabpanel), "spool");
|
||||
add_created_tab(new TabSLAPrint(m_tabpanel), "cog");
|
||||
add_created_tab(new TabSLAMaterial(m_tabpanel), "resin");
|
||||
add_created_tab(new TabPrinter(m_tabpanel), wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() == ptFFF ? "printer" : "sla_printer");
|
||||
}
|
||||
|
||||
void MainFrame::add_created_tab(Tab* panel)
|
||||
void MainFrame::add_created_tab(Tab* panel, const std::string& bmp_name /*= ""*/)
|
||||
{
|
||||
panel->create_preset_tab();
|
||||
|
||||
const auto printer_tech = wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology();
|
||||
|
||||
if (panel->supports_printer_technology(printer_tech))
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->AddPage(panel, panel->title(), bmp_name);
|
||||
else
|
||||
#endif
|
||||
m_tabpanel->AddPage(panel, panel->title());
|
||||
}
|
||||
|
||||
|
@ -960,6 +982,12 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
|
|||
wxGetApp().update_fonts(this);
|
||||
this->SetFont(this->normal_font());
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// update common mode sizer
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
||||
#endif
|
||||
|
||||
// update Plater
|
||||
wxGetApp().plater()->msw_rescale();
|
||||
|
||||
|
@ -968,9 +996,8 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
|
|||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->msw_rescale();
|
||||
|
||||
wxMenuBar* menu_bar = this->GetMenuBar();
|
||||
for (size_t id = 0; id < menu_bar->GetMenuCount(); id++)
|
||||
msw_rescale_menu(menu_bar->GetMenu(id));
|
||||
for (size_t id = 0; id < m_menubar->GetMenuCount(); id++)
|
||||
msw_rescale_menu(m_menubar->GetMenu(id));
|
||||
|
||||
// Workarounds for correct Window rendering after rescale
|
||||
|
||||
|
@ -1003,6 +1030,11 @@ void MainFrame::on_sys_color_changed()
|
|||
#ifdef __WXMSW__
|
||||
wxGetApp().UpdateDarkUI(m_tabpanel);
|
||||
m_statusbar->update_dark_ui();
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// update common mode sizer
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// update Plater
|
||||
|
@ -1012,10 +1044,7 @@ void MainFrame::on_sys_color_changed()
|
|||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->sys_color_changed();
|
||||
|
||||
// msw_rescale_menu updates just icons, so use it
|
||||
wxMenuBar* menu_bar = this->GetMenuBar();
|
||||
for (size_t id = 0; id < menu_bar->GetMenuCount(); id++)
|
||||
msw_rescale_menu(menu_bar->GetMenu(id));
|
||||
MenuFactory::sys_color_changed(m_menubar);
|
||||
|
||||
this->Refresh();
|
||||
}
|
||||
|
@ -2103,8 +2132,8 @@ SettingsDialog::SettingsDialog(MainFrame* mainframe)
|
|||
this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
#else
|
||||
this->SetFont(wxGetApp().normal_font());
|
||||
#endif // __WXMSW__
|
||||
this->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
|
||||
// Load the icon either from the exe, or from the ico file.
|
||||
#if _WIN32
|
||||
|
@ -2185,6 +2214,12 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
|
|||
const int& em = em_unit();
|
||||
const wxSize& size = wxSize(85 * em, 50 * em);
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// update common mode sizer
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(m_tabpanel)->Rescale();
|
||||
#endif
|
||||
|
||||
// update Tabs
|
||||
for (auto tab : wxGetApp().tabs_list)
|
||||
tab->msw_rescale();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include "Event.hpp"
|
||||
#include "UnsavedChangesDialog.hpp"
|
||||
|
||||
class wxNotebook;
|
||||
class wxBookCtrlBase;
|
||||
class wxProgressDialog;
|
||||
|
||||
|
@ -154,7 +153,7 @@ public:
|
|||
|
||||
void init_tabpanel();
|
||||
void create_preset_tabs();
|
||||
void add_created_tab(Tab* panel);
|
||||
void add_created_tab(Tab* panel, const std::string& bmp_name = "");
|
||||
bool is_active_and_shown_tab(Tab* tab);
|
||||
// Register Win32 RawInput callbacks (3DConnexion) and removable media insert / remove callbacks.
|
||||
// Called from wxEVT_ACTIVATE, as wxEVT_CREATE was not reliable (bug in wxWidgets?).
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "I18N.hpp"
|
||||
#include "ConfigWizard.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "Mainframe.hpp"
|
||||
#include "GUI_App.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
|
@ -24,7 +25,7 @@ namespace GUI {
|
|||
|
||||
|
||||
MsgDialog::MsgDialog(wxWindow *parent, const wxString &title, const wxString &headline, wxWindowID button_id, wxBitmap bitmap)
|
||||
: wxDialog(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
: wxDialog(parent ? parent : dynamic_cast<wxWindow*>(wxGetApp().mainframe), wxID_ANY, title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
, boldfont(wxGetApp().normal_font()/*wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT)*/)
|
||||
, content_sizer(new wxBoxSizer(wxVERTICAL))
|
||||
, btn_sizer(new wxBoxSizer(wxHORIZONTAL))
|
||||
|
@ -136,6 +137,7 @@ ErrorDialog::ErrorDialog(wxWindow *parent, const wxString &msg, bool monospaced_
|
|||
|
||||
SetMaxSize(wxSize(-1, CONTENT_MAX_HEIGHT*wxGetApp().em_unit()));
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
}
|
||||
|
||||
// WarningDialog
|
||||
|
@ -157,9 +159,10 @@ WarningDialog::WarningDialog(wxWindow *parent,
|
|||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
// MessageDialog
|
||||
|
||||
MessageDialog::MessageDialog(wxWindow* parent,
|
||||
|
@ -181,7 +184,9 @@ MessageDialog::MessageDialog(wxWindow* parent,
|
|||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
Fit();
|
||||
this->CenterOnParent();
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
virtual ~WarningDialog() = default;
|
||||
};
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
// Generic message dialog, used intead of wxMessageDialog
|
||||
class MessageDialog : public MsgDialog
|
||||
{
|
||||
|
@ -98,6 +98,19 @@ public:
|
|||
MessageDialog &operator=(const MessageDialog&) = delete;
|
||||
virtual ~MessageDialog() = default;
|
||||
};
|
||||
#else
|
||||
// just a wrapper to wxMessageBox to use the same code on all platforms
|
||||
class MessageDialog : public wxMessageDialog
|
||||
{
|
||||
public:
|
||||
MessageDialog(wxWindow* parent,
|
||||
const wxString& message,
|
||||
const wxString& caption = wxEmptyString,
|
||||
long style = wxOK)
|
||||
: wxMessageDialog(parent, message, caption, style) {}
|
||||
~MessageDialog() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
|
134
src/slic3r/GUI/Notebook.cpp
Normal file
134
src/slic3r/GUI/Notebook.cpp
Normal file
|
@ -0,0 +1,134 @@
|
|||
#include "Notebook.hpp"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include "GUI_App.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
|
||||
#include <wx/button.h>
|
||||
#include <wx/sizer.h>
|
||||
|
||||
wxDEFINE_EVENT(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, wxCommandEvent);
|
||||
|
||||
ButtonsListCtrl::ButtonsListCtrl(wxWindow *parent, bool add_mode_buttons/* = false*/) :
|
||||
wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL)
|
||||
{
|
||||
#ifdef __WINDOWS__
|
||||
SetDoubleBuffered(true);
|
||||
#endif //__WINDOWS__
|
||||
|
||||
m_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
this->SetSizer(m_sizer);
|
||||
|
||||
if (add_mode_buttons) {
|
||||
m_mode_sizer = new ModeSizer(this, int(0.5 * em_unit(this)));
|
||||
m_sizer->AddStretchSpacer(20);
|
||||
m_sizer->Add(m_mode_sizer, 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
|
||||
}
|
||||
|
||||
this->Bind(wxEVT_PAINT, &ButtonsListCtrl::OnPaint, this);
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::OnPaint(wxPaintEvent&)
|
||||
{
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||
const wxSize sz = GetSize();
|
||||
wxPaintDC dc(this);
|
||||
|
||||
if (m_selection < 0 || m_selection >= (int)m_pageButtons.size())
|
||||
return;
|
||||
|
||||
// highlight selected button
|
||||
|
||||
const wxColour& selected_btn_bg = Slic3r::GUI::wxGetApp().get_color_selected_btn_bg();
|
||||
const wxColour& default_btn_bg = Slic3r::GUI::wxGetApp().get_highlight_default_clr();
|
||||
const wxColour& btn_marker_color = Slic3r::GUI::wxGetApp().get_color_hovered_btn_label();
|
||||
for (int idx = 0; idx < m_pageButtons.size(); idx++) {
|
||||
wxButton* btn = m_pageButtons[idx];
|
||||
|
||||
btn->SetBackgroundColour(idx == m_selection ? selected_btn_bg : default_btn_bg);
|
||||
|
||||
wxPoint pos = btn->GetPosition();
|
||||
wxSize size = btn->GetSize();
|
||||
const wxColour& clr = idx == m_selection ? btn_marker_color : default_btn_bg;
|
||||
dc.SetPen(clr);
|
||||
dc.SetBrush(clr);
|
||||
dc.DrawRectangle(pos.x, sz.y - 3, size.x, 3);
|
||||
}
|
||||
|
||||
dc.SetPen(btn_marker_color);
|
||||
dc.SetBrush(btn_marker_color);
|
||||
dc.DrawRectangle(1, sz.y - 1, sz.x, 1);
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::UpdateMode()
|
||||
{
|
||||
m_mode_sizer->SetMode(Slic3r::GUI::wxGetApp().get_mode());
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::Rescale()
|
||||
{
|
||||
m_mode_sizer->msw_rescale();
|
||||
for (ScalableButton* btn : m_pageButtons)
|
||||
btn->msw_rescale();
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::SetSelection(int sel)
|
||||
{
|
||||
if (m_selection == sel)
|
||||
return;
|
||||
m_selection = sel;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
bool ButtonsListCtrl::InsertPage(size_t n, const wxString& text, bool bSelect/* = false*/, const std::string& bmp_name/* = ""*/)
|
||||
{
|
||||
ScalableButton* btn = new ScalableButton(this, wxID_ANY, bmp_name, text, wxDefaultSize, wxDefaultPosition, wxBU_LEFT | wxBU_EXACTFIT);
|
||||
btn->Bind(wxEVT_BUTTON, [this, btn](wxCommandEvent& event) {
|
||||
if (auto it = std::find(m_pageButtons.begin(), m_pageButtons.end(), btn); it != m_pageButtons.end()) {
|
||||
m_selection = it - m_pageButtons.begin();
|
||||
wxCommandEvent evt = wxCommandEvent(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED);
|
||||
evt.SetId(m_selection);
|
||||
wxPostEvent(this->GetParent(), evt);
|
||||
Refresh();
|
||||
}
|
||||
});
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(btn);
|
||||
m_pageButtons.insert(m_pageButtons.begin() + n, btn);
|
||||
m_sizer->Insert(n, new wxSizerItem(btn, 0, wxEXPAND | wxRIGHT | wxBOTTOM, 3));
|
||||
m_sizer->Layout();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::RemovePage(size_t n)
|
||||
{
|
||||
ScalableButton* btn = m_pageButtons[n];
|
||||
m_pageButtons.erase(m_pageButtons.begin() + n);
|
||||
m_sizer->Remove(n);
|
||||
btn->Reparent(nullptr);
|
||||
btn->Destroy();
|
||||
m_sizer->Layout();
|
||||
}
|
||||
|
||||
bool ButtonsListCtrl::SetPageImage(size_t n, const std::string& bmp_name) const
|
||||
{
|
||||
if (n >= m_pageButtons.size())
|
||||
return false;
|
||||
return m_pageButtons[n]->SetBitmap_(bmp_name);
|
||||
}
|
||||
|
||||
void ButtonsListCtrl::SetPageText(size_t n, const wxString& strText)
|
||||
{
|
||||
ScalableButton* btn = m_pageButtons[n];
|
||||
btn->SetLabel(strText);
|
||||
}
|
||||
|
||||
wxString ButtonsListCtrl::GetPageText(size_t n) const
|
||||
{
|
||||
ScalableButton* btn = m_pageButtons[n];
|
||||
return btn->GetLabel();
|
||||
}
|
||||
|
||||
#endif // _WIN32
|
||||
|
||||
|
305
src/slic3r/GUI/Notebook.hpp
Normal file
305
src/slic3r/GUI/Notebook.hpp
Normal file
|
@ -0,0 +1,305 @@
|
|||
#ifndef slic3r_Notebook_hpp_
|
||||
#define slic3r_Notebook_hpp_
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <wx/bookctrl.h>
|
||||
|
||||
class ModeSizer;
|
||||
class ScalableButton;
|
||||
|
||||
// custom message the ButtonsListCtrl sends to its parent (Notebook) to notify a selection change:
|
||||
wxDECLARE_EVENT(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, wxCommandEvent);
|
||||
|
||||
class ButtonsListCtrl : public wxControl
|
||||
{
|
||||
public:
|
||||
ButtonsListCtrl(wxWindow* parent, bool add_mode_buttons = false);
|
||||
~ButtonsListCtrl() {}
|
||||
|
||||
void OnPaint(wxPaintEvent&);
|
||||
void SetSelection(int sel);
|
||||
void UpdateMode();
|
||||
void Rescale();
|
||||
bool InsertPage(size_t n, const wxString& text, bool bSelect = false, const std::string& bmp_name = "");
|
||||
void RemovePage(size_t n);
|
||||
bool SetPageImage(size_t n, const std::string& bmp_name) const;
|
||||
void SetPageText(size_t n, const wxString& strText);
|
||||
wxString GetPageText(size_t n) const;
|
||||
|
||||
private:
|
||||
wxWindow* m_parent;
|
||||
wxBoxSizer* m_sizer;
|
||||
std::vector<ScalableButton*> m_pageButtons;
|
||||
int m_selection {-1};
|
||||
ModeSizer* m_mode_sizer {nullptr};
|
||||
};
|
||||
|
||||
class Notebook: public wxBookCtrlBase
|
||||
{
|
||||
public:
|
||||
Notebook(wxWindow * parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0,
|
||||
bool add_mode_buttons = false)
|
||||
{
|
||||
Init();
|
||||
Create(parent, winid, pos, size, style, add_mode_buttons);
|
||||
}
|
||||
|
||||
bool Create(wxWindow * parent,
|
||||
wxWindowID winid = wxID_ANY,
|
||||
const wxPoint & pos = wxDefaultPosition,
|
||||
const wxSize & size = wxDefaultSize,
|
||||
long style = 0,
|
||||
bool add_mode_buttons = false)
|
||||
{
|
||||
if (!wxBookCtrlBase::Create(parent, winid, pos, size, style | wxBK_TOP))
|
||||
return false;
|
||||
|
||||
m_bookctrl = new ButtonsListCtrl(this, add_mode_buttons);
|
||||
|
||||
wxSizer* mainSizer = new wxBoxSizer(IsVertical() ? wxVERTICAL : wxHORIZONTAL);
|
||||
|
||||
if (style & wxBK_RIGHT || style & wxBK_BOTTOM)
|
||||
mainSizer->Add(0, 0, 1, wxEXPAND, 0);
|
||||
|
||||
m_controlSizer = new wxBoxSizer(IsVertical() ? wxHORIZONTAL : wxVERTICAL);
|
||||
m_controlSizer->Add(m_bookctrl, wxSizerFlags(1).Expand());
|
||||
wxSizerFlags flags;
|
||||
if (IsVertical())
|
||||
flags.Expand();
|
||||
else
|
||||
flags.CentreVertical();
|
||||
mainSizer->Add(m_controlSizer, flags.Border(wxALL, m_controlMargin));
|
||||
SetSizer(mainSizer);
|
||||
|
||||
this->Bind(wxCUSTOMEVT_NOTEBOOK_SEL_CHANGED, [this](wxCommandEvent& evt)
|
||||
{
|
||||
if (int page_idx = evt.GetId(); page_idx >= 0)
|
||||
SetSelection(page_idx);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// Methods specific to this class.
|
||||
|
||||
// A method allowing to add a new page without any label (which is unused
|
||||
// by this control) and show it immediately.
|
||||
bool ShowNewPage(wxWindow * page)
|
||||
{
|
||||
return AddPage(page, wxString(), ""/*true *//* select it */);
|
||||
}
|
||||
|
||||
|
||||
// Set effect to use for showing/hiding pages.
|
||||
void SetEffects(wxShowEffect showEffect, wxShowEffect hideEffect)
|
||||
{
|
||||
m_showEffect = showEffect;
|
||||
m_hideEffect = hideEffect;
|
||||
}
|
||||
|
||||
// Or the same effect for both of them.
|
||||
void SetEffect(wxShowEffect effect)
|
||||
{
|
||||
SetEffects(effect, effect);
|
||||
}
|
||||
|
||||
// And the same for time outs.
|
||||
void SetEffectsTimeouts(unsigned showTimeout, unsigned hideTimeout)
|
||||
{
|
||||
m_showTimeout = showTimeout;
|
||||
m_hideTimeout = hideTimeout;
|
||||
}
|
||||
|
||||
void SetEffectTimeout(unsigned timeout)
|
||||
{
|
||||
SetEffectsTimeouts(timeout, timeout);
|
||||
}
|
||||
|
||||
|
||||
// Implement base class pure virtual methods.
|
||||
|
||||
// adds a new page to the control
|
||||
bool AddPage(wxWindow* page,
|
||||
const wxString& text,
|
||||
const std::string& bmp_name,
|
||||
bool bSelect = false)
|
||||
{
|
||||
DoInvalidateBestSize();
|
||||
return InsertPage(GetPageCount(), page, text, bmp_name, bSelect);
|
||||
}
|
||||
|
||||
// Page management
|
||||
virtual bool InsertPage(size_t n,
|
||||
wxWindow * page,
|
||||
const wxString & text,
|
||||
bool bSelect = false,
|
||||
int imageId = NO_IMAGE) override
|
||||
{
|
||||
if (!wxBookCtrlBase::InsertPage(n, page, text, bSelect, imageId))
|
||||
return false;
|
||||
|
||||
GetBtnsListCtrl()->InsertPage(n, text, bSelect);
|
||||
|
||||
if (!DoSetSelectionAfterInsertion(n, bSelect))
|
||||
page->Hide();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool InsertPage(size_t n,
|
||||
wxWindow * page,
|
||||
const wxString & text,
|
||||
const std::string& bmp_name = "",
|
||||
bool bSelect = false)
|
||||
{
|
||||
if (!wxBookCtrlBase::InsertPage(n, page, text, bSelect))
|
||||
return false;
|
||||
|
||||
GetBtnsListCtrl()->InsertPage(n, text, bSelect, bmp_name);
|
||||
|
||||
if (!DoSetSelectionAfterInsertion(n, bSelect))
|
||||
page->Hide();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual int SetSelection(size_t n) override
|
||||
{
|
||||
GetBtnsListCtrl()->SetSelection(n);
|
||||
return DoSetSelection(n, SetSelection_SendEvent);
|
||||
}
|
||||
|
||||
virtual int ChangeSelection(size_t n) override
|
||||
{
|
||||
GetBtnsListCtrl()->SetSelection(n);
|
||||
return DoSetSelection(n);
|
||||
}
|
||||
|
||||
// Neither labels nor images are supported but we still store the labels
|
||||
// just in case the user code attaches some importance to them.
|
||||
virtual bool SetPageText(size_t n, const wxString & strText) override
|
||||
{
|
||||
wxCHECK_MSG(n < GetPageCount(), false, wxS("Invalid page"));
|
||||
|
||||
GetBtnsListCtrl()->SetPageText(n, strText);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual wxString GetPageText(size_t n) const override
|
||||
{
|
||||
wxCHECK_MSG(n < GetPageCount(), wxString(), wxS("Invalid page"));
|
||||
return GetBtnsListCtrl()->GetPageText(n);
|
||||
}
|
||||
|
||||
virtual bool SetPageImage(size_t WXUNUSED(n), int WXUNUSED(imageId)) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual int GetPageImage(size_t WXUNUSED(n)) const override
|
||||
{
|
||||
return NO_IMAGE;
|
||||
}
|
||||
|
||||
bool SetPageImage(size_t n, const std::string& bmp_name)
|
||||
{
|
||||
return GetBtnsListCtrl()->SetPageImage(n, bmp_name);
|
||||
}
|
||||
|
||||
// Override some wxWindow methods too.
|
||||
virtual void SetFocus() override
|
||||
{
|
||||
wxWindow* const page = GetCurrentPage();
|
||||
if (page)
|
||||
page->SetFocus();
|
||||
}
|
||||
|
||||
ButtonsListCtrl* GetBtnsListCtrl() const { return static_cast<ButtonsListCtrl*>(m_bookctrl); }
|
||||
|
||||
void UpdateMode()
|
||||
{
|
||||
GetBtnsListCtrl()->UpdateMode();
|
||||
}
|
||||
|
||||
void Rescale()
|
||||
{
|
||||
GetBtnsListCtrl()->Rescale();
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void UpdateSelectedPage(size_t WXUNUSED(newsel)) override
|
||||
{
|
||||
// Nothing to do here, but must be overridden to avoid the assert in
|
||||
// the base class version.
|
||||
}
|
||||
|
||||
virtual wxBookCtrlEvent * CreatePageChangingEvent() const override
|
||||
{
|
||||
return new wxBookCtrlEvent(wxEVT_BOOKCTRL_PAGE_CHANGING,
|
||||
GetId());
|
||||
}
|
||||
|
||||
virtual void MakeChangedEvent(wxBookCtrlEvent & event) override
|
||||
{
|
||||
event.SetEventType(wxEVT_BOOKCTRL_PAGE_CHANGED);
|
||||
}
|
||||
|
||||
virtual wxWindow * DoRemovePage(size_t page) override
|
||||
{
|
||||
wxWindow* const win = wxBookCtrlBase::DoRemovePage(page);
|
||||
if (win)
|
||||
{
|
||||
GetBtnsListCtrl()->RemovePage(page);
|
||||
DoSetSelectionAfterRemoval(page);
|
||||
}
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
virtual void DoSize() override
|
||||
{
|
||||
wxWindow* const page = GetCurrentPage();
|
||||
if (page)
|
||||
page->SetSize(GetPageRect());
|
||||
}
|
||||
|
||||
virtual void DoShowPage(wxWindow * page, bool show) override
|
||||
{
|
||||
if (show)
|
||||
page->ShowWithEffect(m_showEffect, m_showTimeout);
|
||||
else
|
||||
page->HideWithEffect(m_hideEffect, m_hideTimeout);
|
||||
}
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
// We don't need any border as we don't have anything to separate the
|
||||
// page contents from.
|
||||
SetInternalBorder(0);
|
||||
|
||||
// No effects by default.
|
||||
m_showEffect =
|
||||
m_hideEffect = wxSHOW_EFFECT_NONE;
|
||||
|
||||
m_showTimeout =
|
||||
m_hideTimeout = 0;
|
||||
}
|
||||
|
||||
wxShowEffect m_showEffect,
|
||||
m_hideEffect;
|
||||
|
||||
unsigned m_showTimeout,
|
||||
m_hideTimeout;
|
||||
|
||||
ButtonsListCtrl* m_ctrl{ nullptr };
|
||||
|
||||
};
|
||||
#endif // _WIN32
|
||||
#endif // slic3r_Notebook_hpp_
|
|
@ -583,7 +583,7 @@ struct Sidebar::priv
|
|||
wxScrolledWindow *scrolled;
|
||||
wxPanel* presets_panel; // Used for MSW better layouts
|
||||
|
||||
ModeSizer *mode_sizer;
|
||||
ModeSizer *mode_sizer {nullptr};
|
||||
wxFlexGridSizer *sizer_presets;
|
||||
PlaterPresetComboBox *combo_print;
|
||||
std::vector<PlaterPresetComboBox*> combos_filament;
|
||||
|
@ -754,7 +754,8 @@ Sidebar::Sidebar(Plater *parent)
|
|||
p->sliced_info = new SlicedInfo(p->scrolled);
|
||||
|
||||
// Sizer in the scrolled area
|
||||
scrolled_sizer->Add(p->mode_sizer, 0, wxALIGN_CENTER_HORIZONTAL/*RIGHT | wxBOTTOM | wxRIGHT, 5*/);
|
||||
if (p->mode_sizer)
|
||||
scrolled_sizer->Add(p->mode_sizer, 0, wxALIGN_CENTER_HORIZONTAL);
|
||||
is_msw ?
|
||||
scrolled_sizer->Add(p->presets_panel, 0, wxEXPAND | wxLEFT, margin_5) :
|
||||
scrolled_sizer->Add(p->sizer_presets, 0, wxEXPAND | wxLEFT, margin_5);
|
||||
|
@ -944,13 +945,16 @@ void Sidebar::update_presets(Preset::Type preset_type)
|
|||
|
||||
void Sidebar::update_mode_sizer() const
|
||||
{
|
||||
p->mode_sizer->SetMode(m_mode);
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->SetMode(m_mode);
|
||||
}
|
||||
|
||||
void Sidebar::change_top_border_for_mode_sizer(bool increase_border)
|
||||
{
|
||||
p->mode_sizer->set_items_flag(increase_border ? wxTOP : 0);
|
||||
p->mode_sizer->set_items_border(increase_border ? int(0.5 * wxGetApp().em_unit()) : 0);
|
||||
if (p->mode_sizer) {
|
||||
p->mode_sizer->set_items_flag(increase_border ? wxTOP : 0);
|
||||
p->mode_sizer->set_items_border(increase_border ? int(0.5 * wxGetApp().em_unit()) : 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Sidebar::update_reslice_btn_tooltip() const
|
||||
|
@ -965,7 +969,8 @@ void Sidebar::msw_rescale()
|
|||
{
|
||||
SetMinSize(wxSize(40 * wxGetApp().em_unit(), -1));
|
||||
|
||||
p->mode_sizer->msw_rescale();
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->msw_rescale();
|
||||
|
||||
for (PlaterPresetComboBox* combo : std::vector<PlaterPresetComboBox*> { p->combo_print,
|
||||
p->combo_sla_print,
|
||||
|
@ -1009,7 +1014,8 @@ void Sidebar::sys_color_changed()
|
|||
for (wxWindow* btn : std::vector<wxWindow*>{ p->btn_reslice, p->btn_export_gcode })
|
||||
wxGetApp().UpdateDarkUI(btn, true);
|
||||
|
||||
p->mode_sizer->msw_rescale();
|
||||
if (p->mode_sizer)
|
||||
p->mode_sizer->msw_rescale();
|
||||
p->frequently_changed_parameters->sys_color_changed();
|
||||
p->object_settings->sys_color_changed();
|
||||
#endif
|
||||
|
@ -1394,6 +1400,12 @@ void Sidebar::collapse(bool collapse)
|
|||
wxGetApp().app_config->set("collapsed_sidebar", collapse ? "1" : "0");
|
||||
}
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
void Sidebar::show_mode_sizer(bool show)
|
||||
{
|
||||
p->mode_sizer->Show(show);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Sidebar::update_ui_from_settings()
|
||||
{
|
||||
|
|
|
@ -112,6 +112,10 @@ public:
|
|||
void update_searcher();
|
||||
void update_ui_from_settings();
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
void show_mode_sizer(bool show);
|
||||
#endif
|
||||
|
||||
std::vector<PlaterPresetComboBox*>& combos_filament();
|
||||
Search::OptionsSearcher& get_searcher();
|
||||
std::string& get_search_line();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "I18N.hpp"
|
||||
#include "libslic3r/AppConfig.hpp"
|
||||
#include <wx/notebook.h>
|
||||
#include <wx/listbook.h>
|
||||
#include "Notebook.hpp"
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
@ -58,15 +58,12 @@ void PreferencesDialog::build()
|
|||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
wxBookCtrlBase* tabs;
|
||||
if (wxGetApp().dark_mode()) {
|
||||
tabs = new wxListbook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNO_BORDER);
|
||||
wxGetApp().UpdateDarkUI(tabs);
|
||||
wxGetApp().UpdateDarkUI(dynamic_cast<wxListbook*>(tabs)->GetListView());
|
||||
}
|
||||
else {
|
||||
// if (wxGetApp().dark_mode())
|
||||
tabs = new Notebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
|
||||
/* else {
|
||||
tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL | wxNB_NOPAGETHEME | wxNB_DEFAULT);
|
||||
tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
}
|
||||
}*/
|
||||
#else
|
||||
wxNotebook* tabs = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_TOP | wxTAB_TRAVERSAL |wxNB_NOPAGETHEME | wxNB_DEFAULT );
|
||||
tabs->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
|
@ -345,7 +342,6 @@ void PreferencesDialog::build()
|
|||
def.set_default_value(new ConfigOptionBool{ app_config->get("dark_color_mode") == "1" });
|
||||
option = Option(def, "dark_color_mode");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
#endif
|
||||
|
||||
def.label = L("Set settings tabs as menu items (experimental)");
|
||||
def.type = coBool;
|
||||
|
@ -354,6 +350,7 @@ void PreferencesDialog::build()
|
|||
def.set_default_value(new ConfigOptionBool{ app_config->get("tabs_as_menu") == "1" });
|
||||
option = Option(def, "tabs_as_menu");
|
||||
m_optgroup_gui->append_single_option_line(option);
|
||||
#endif
|
||||
|
||||
def.label = L("Use custom size for toolbar icons");
|
||||
def.type = coBool;
|
||||
|
@ -414,11 +411,7 @@ void PreferencesDialog::accept()
|
|||
// if (m_values.find("no_defaults") != m_values.end()
|
||||
// warning_catcher(this, wxString::Format(_L("You need to restart %s to make the changes effective."), SLIC3R_APP_NAME));
|
||||
|
||||
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu"
|
||||
#ifdef _MSW_DARK_MODE
|
||||
,"dark_color_mode"
|
||||
#endif
|
||||
};
|
||||
std::vector<std::string> options_to_recreate_GUI = { "no_defaults", "tabs_as_menu" };
|
||||
|
||||
for (const std::string& option : options_to_recreate_GUI) {
|
||||
if (m_values.find(option) != m_values.end()) {
|
||||
|
@ -432,9 +425,6 @@ void PreferencesDialog::accept()
|
|||
wxICON_QUESTION | wxYES | wxNO);
|
||||
if (dialog.ShowModal() == wxID_YES) {
|
||||
m_recreate_GUI = true;
|
||||
#ifdef _MSW_DARK_MODE
|
||||
m_color_mode_changed = m_values.find("dark_color_mode") != m_values.end();
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
for (const std::string& option : options_to_recreate_GUI)
|
||||
|
@ -495,6 +485,11 @@ void PreferencesDialog::accept()
|
|||
|
||||
EndModal(wxID_OK);
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (m_values.find("dark_color_mode") != m_values.end())
|
||||
wxGetApp().force_colors_update();
|
||||
#endif
|
||||
|
||||
if (m_settings_layout_changed)
|
||||
;// application will be recreated after Preference dialog will be destroyed
|
||||
else
|
||||
|
@ -585,7 +580,9 @@ void PreferencesDialog::create_icon_size_slider()
|
|||
|
||||
void PreferencesDialog::create_settings_mode_widget()
|
||||
{
|
||||
bool dark_mode = wxGetApp().dark_mode();
|
||||
#ifdef _MSW_DARK_MODE
|
||||
bool disable_new_layout = wxGetApp().tabs_as_menu();
|
||||
#endif
|
||||
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") };
|
||||
|
@ -596,7 +593,7 @@ void PreferencesDialog::create_settings_mode_widget()
|
|||
app_config->get("dlg_settings_layout_mode") == "1" ? 2 : 0;
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (dark_mode) {
|
||||
if (disable_new_layout) {
|
||||
choices = { _L("Old regular layout with the tab bar"),
|
||||
_L("Settings in non-modal window") };
|
||||
selection = app_config->get("dlg_settings_layout_mode") == "1" ? 1 : 0;
|
||||
|
@ -621,14 +618,18 @@ void PreferencesDialog::create_settings_mode_widget()
|
|||
|
||||
int dlg_id = 2;
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (dark_mode)
|
||||
if (disable_new_layout)
|
||||
dlg_id = 1;
|
||||
#endif
|
||||
|
||||
btn->Bind(wxEVT_RADIOBUTTON, [this, id, dlg_id, dark_mode](wxCommandEvent& ) {
|
||||
btn->Bind(wxEVT_RADIOBUTTON, [this, id, dlg_id
|
||||
#ifdef _MSW_DARK_MODE
|
||||
, disable_new_layout
|
||||
#endif
|
||||
](wxCommandEvent& ) {
|
||||
m_values["old_settings_layout_mode"] = (id == 0) ? "1" : "0";
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!dark_mode)
|
||||
if (!disable_new_layout)
|
||||
m_values["new_settings_layout_mode"] = (id == 1) ? "1" : "0";
|
||||
#endif
|
||||
m_values["dlg_settings_layout_mode"] = (id == dlg_id) ? "1" : "0";
|
||||
|
@ -637,7 +638,7 @@ void PreferencesDialog::create_settings_mode_widget()
|
|||
}
|
||||
|
||||
auto sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
sizer->Add(/*m_layout_mode_box*/stb_sizer, 1, wxALIGN_CENTER_VERTICAL);
|
||||
sizer->Add(stb_sizer, 1, wxALIGN_CENTER_VERTICAL);
|
||||
m_optgroup_gui->sizer->Add(sizer, 0, wxEXPAND | wxTOP, em_unit());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ class PreferencesDialog : public DPIDialog
|
|||
std::shared_ptr<ConfigOptionsGroup> m_optgroup_render;
|
||||
#endif // ENABLE_ENVIRONMENT_MAP
|
||||
wxSizer* m_icon_size_sizer;
|
||||
wxRadioBox* m_layout_mode_box;
|
||||
wxColourPickerCtrl* m_sys_colour {nullptr};
|
||||
wxColourPickerCtrl* m_mod_colour {nullptr};
|
||||
bool isOSX {false};
|
||||
|
@ -35,9 +34,7 @@ class PreferencesDialog : public DPIDialog
|
|||
bool m_seq_top_gcode_indices_changed{ false };
|
||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
bool m_recreate_GUI{false};
|
||||
#ifdef _MSW_DARK_MODE
|
||||
bool m_color_mode_changed {false};
|
||||
#endif
|
||||
|
||||
public:
|
||||
explicit PreferencesDialog(wxWindow* parent);
|
||||
~PreferencesDialog() = default;
|
||||
|
@ -48,9 +45,6 @@ public:
|
|||
bool seq_seq_top_gcode_indices_changed() const { return m_seq_top_gcode_indices_changed; }
|
||||
#endif // ENABLE_GCODE_LINES_ID_IN_H_SLIDER
|
||||
bool recreate_GUI() const { return m_recreate_GUI; }
|
||||
#ifdef _MSW_DARK_MODE
|
||||
bool color_mode_changed() const { return m_color_mode_changed; }
|
||||
#endif
|
||||
void build();
|
||||
void accept();
|
||||
|
||||
|
|
|
@ -208,12 +208,13 @@ SavePresetDialog::~SavePresetDialog()
|
|||
|
||||
void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix)
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#if defined(__WXMSW__)
|
||||
// ys_FIXME! temporary workaround for correct font scaling
|
||||
// Because of from wxWidgets 3.1.3 auto rescaling is implemented for the Fonts,
|
||||
// From the very beginning set dialog font to the wxSYS_DEFAULT_GUI_FONT
|
||||
this->SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
|
||||
#else
|
||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
|
||||
#endif // __WXMSW__
|
||||
|
||||
if (suffix.empty())
|
||||
|
@ -240,6 +241,10 @@ void SavePresetDialog::build(std::vector<Preset::Type> types, std::string suffix
|
|||
topSizer->SetSizeHints(this);
|
||||
|
||||
this->CenterOnScreen();
|
||||
|
||||
#ifdef _WIN32
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SavePresetDialog::AddItem(Preset::Type type, const std::string& suffix)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "UnsavedChangesDialog.hpp"
|
||||
#include "SavePresetDialog.hpp"
|
||||
#include "MsgDialog.hpp"
|
||||
#include "Notebook.hpp"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <commctrl.h>
|
||||
|
@ -255,8 +256,11 @@ void Tab::create_preset_tab()
|
|||
m_modified_label_clr = wxGetApp().get_label_clr_modified();
|
||||
m_default_text_clr = wxGetApp().get_label_clr_default();
|
||||
|
||||
#ifdef _MSW_DARK_MODE
|
||||
// Sizer with buttons for mode changing
|
||||
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
|
||||
if (wxGetApp().tabs_as_menu())
|
||||
#endif
|
||||
m_mode_sizer = new ModeSizer(panel, int (0.5*em_unit(this)));
|
||||
|
||||
const float scale_factor = /*wxGetApp().*/em_unit(this)*0.1;// GetContentScaleFactor();
|
||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -285,9 +289,11 @@ void Tab::create_preset_tab()
|
|||
// 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
|
||||
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
mode_sizer->Add(m_mode_sizer, 1, wxALIGN_RIGHT);
|
||||
m_hsizer->Add(mode_sizer, 1, wxALIGN_CENTER_VERTICAL | wxRIGHT, wxOSX ? 15 : 10);
|
||||
if (m_mode_sizer) {
|
||||
auto mode_sizer = new wxBoxSizer(wxVERTICAL);
|
||||
mode_sizer->Add(m_mode_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.
|
||||
m_hsizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
@ -490,7 +496,8 @@ void Tab::OnActivate()
|
|||
|
||||
// Workaroud for Menu instead of NoteBook
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (wxGetApp().tabs_as_menu()) {
|
||||
// if (wxGetApp().tabs_as_menu())
|
||||
{
|
||||
wxSize sz = m_presets_choice->GetSize();
|
||||
wxSize ok_sz = wxSize(35 * m_em_unit, m_presets_choice->GetBestSize().y+1);
|
||||
if (sz != ok_sz) {
|
||||
|
@ -943,7 +950,8 @@ void Tab::update_mode()
|
|||
m_mode = wxGetApp().get_mode();
|
||||
|
||||
// update mode for ModeSizer
|
||||
m_mode_sizer->SetMode(m_mode);
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->SetMode(m_mode);
|
||||
|
||||
update_visibility();
|
||||
|
||||
|
@ -969,7 +977,8 @@ void Tab::msw_rescale()
|
|||
{
|
||||
m_em_unit = em_unit(m_parent);
|
||||
|
||||
m_mode_sizer->msw_rescale();
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->msw_rescale();
|
||||
m_presets_choice->msw_rescale();
|
||||
|
||||
m_treectrl->SetMinSize(wxSize(20 * m_em_unit, -1));
|
||||
|
@ -1026,7 +1035,8 @@ void Tab::sys_color_changed()
|
|||
update_label_colours();
|
||||
#ifdef _WIN32
|
||||
wxWindowUpdateLocker noUpdates(this);
|
||||
m_mode_sizer->msw_rescale();
|
||||
if (m_mode_sizer)
|
||||
m_mode_sizer->msw_rescale();
|
||||
wxGetApp().UpdateDarkUI(this);
|
||||
wxGetApp().UpdateDarkUI(m_treectrl);
|
||||
#endif
|
||||
|
@ -3085,7 +3095,15 @@ void Tab::load_current_preset()
|
|||
}
|
||||
if (tab->supports_printer_technology(printer_technology))
|
||||
{
|
||||
wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title());
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu()) {
|
||||
std::string bmp_name = tab->type() == Slic3r::Preset::TYPE_FILAMENT ? "spool" :
|
||||
tab->type() == Slic3r::Preset::TYPE_SLA_MATERIAL ? "resin" : "cog";
|
||||
dynamic_cast<Notebook*>(wxGetApp().tab_panel())->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title(), bmp_name);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
wxGetApp().tab_panel()->InsertPage(wxGetApp().tab_panel()->FindPage(this), tab, tab->title());
|
||||
#ifdef __linux__ // the tabs apparently need to be explicitly shown on Linux (pull request #1563)
|
||||
int page_id = wxGetApp().tab_panel()->FindPage(tab);
|
||||
wxGetApp().tab_panel()->GetPage(page_id)->Show(true);
|
||||
|
@ -3099,6 +3117,10 @@ void Tab::load_current_preset()
|
|||
}
|
||||
static_cast<TabPrinter*>(this)->m_printer_technology = printer_technology;
|
||||
m_active_page = tmp_page;
|
||||
#ifdef _MSW_DARK_MODE
|
||||
if (!wxGetApp().tabs_as_menu())
|
||||
dynamic_cast<Notebook*>(wxGetApp().tab_panel())->SetPageImage(wxGetApp().tab_panel()->FindPage(this), printer_technology == ptFFF ? "printer" : "sla_printer");
|
||||
#endif
|
||||
}
|
||||
on_presets_changed();
|
||||
if (printer_technology == ptFFF) {
|
||||
|
|
|
@ -129,7 +129,7 @@ protected:
|
|||
wxScrolledWindow* m_page_view {nullptr};
|
||||
wxBoxSizer* m_page_sizer {nullptr};
|
||||
|
||||
ModeSizer* m_mode_sizer;
|
||||
ModeSizer* m_mode_sizer {nullptr};
|
||||
|
||||
struct PresetDependencies {
|
||||
Preset::Type type = Preset::TYPE_INVALID;
|
||||
|
|
|
@ -838,9 +838,13 @@ ScalableButton::ScalableButton( wxWindow * parent,
|
|||
Create(parent, id, label, pos, size, style);
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this);
|
||||
|
||||
SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
|
||||
if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
if (!icon_name.empty()) {
|
||||
SetBitmap(create_scaled_bitmap(icon_name, parent, m_px_cnt));
|
||||
if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
if (!label.empty())
|
||||
SetBitmapMargins(int(0.5* em_unit(parent)), 0);
|
||||
}
|
||||
|
||||
if (size != wxDefaultSize)
|
||||
{
|
||||
|
@ -873,6 +877,20 @@ void ScalableButton::SetBitmap_(const ScalableBitmap& bmp)
|
|||
m_current_icon_name = bmp.name();
|
||||
}
|
||||
|
||||
bool ScalableButton::SetBitmap_(const std::string& bmp_name)
|
||||
{
|
||||
m_current_icon_name = bmp_name;
|
||||
if (m_current_icon_name.empty())
|
||||
return false;
|
||||
|
||||
wxBitmap bmp = create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt);
|
||||
SetBitmap(bmp);
|
||||
SetBitmapCurrent(bmp);
|
||||
if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScalableButton::SetBitmapDisabled_(const ScalableBitmap& bmp)
|
||||
{
|
||||
SetBitmapDisabled(bmp.bmp());
|
||||
|
@ -898,11 +916,13 @@ void ScalableButton::msw_rescale()
|
|||
{
|
||||
Slic3r::GUI::wxGetApp().UpdateDarkUI(this, m_has_border);
|
||||
|
||||
SetBitmap(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt));
|
||||
if (!m_disabled_icon_name.empty())
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));
|
||||
else if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
if (!m_current_icon_name.empty()) {
|
||||
SetBitmap(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt));
|
||||
if (!m_disabled_icon_name.empty())
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_disabled_icon_name, m_parent, m_px_cnt));
|
||||
else if (m_use_default_disabled_bitmap)
|
||||
SetBitmapDisabled(create_scaled_bitmap(m_current_icon_name, m_parent, m_px_cnt, true));
|
||||
}
|
||||
|
||||
if (m_width > 0 || m_height>0)
|
||||
{
|
||||
|
|
|
@ -231,6 +231,7 @@ public:
|
|||
~ScalableButton() {}
|
||||
|
||||
void SetBitmap_(const ScalableBitmap& bmp);
|
||||
bool SetBitmap_(const std::string& bmp_name);
|
||||
void SetBitmapDisabled_(const ScalableBitmap &bmp);
|
||||
int GetBitmapHeight();
|
||||
void UseDefaultBitmapDisabled();
|
||||
|
|
Loading…
Reference in a new issue