mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-20 19:19:11 +08:00
TopBar: Improvements and bug fixes
* Don't set a bold font on hovered items * Don't hover selected item * Fixed position of popup menu + Fix for SPE-2235 : Hard to see the numbers of printers after a change of application color mode + Fixed build warning with AddPage()
This commit is contained in:
parent
95d1d6fa14
commit
44c8770df5
@ -753,7 +753,7 @@ void MainFrame::init_tabpanel()
|
||||
if (wxGetApp().is_editor()) {
|
||||
|
||||
//m_webview = new WebViewPanel(m_tabpanel);
|
||||
//m_tabpanel->AddPage(m_webview, "web", "cog"/*, "tab_home_active"*/);
|
||||
//m_tabpanel->AddNewPage(m_webview, "web", "cog"/*, "tab_home_active"*/);
|
||||
//m_param_panel = new ParamsPanel(m_tabpanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBK_LEFT | wxTAB_TRAVERSAL);
|
||||
}
|
||||
|
||||
@ -887,7 +887,7 @@ void MainFrame::add_printer_webview_tab(const wxString& url)
|
||||
}
|
||||
m_printer_webview_added = true;
|
||||
// add as the last (rightmost) panel
|
||||
dynamic_cast<TopBar*>(m_tabpanel)->AddPage(m_printer_webview, _L("Physical Printer"), "", false);
|
||||
dynamic_cast<TopBar*>(m_tabpanel)->AddNewPage(m_printer_webview, _L("Physical Printer"), "");
|
||||
m_printer_webview->set_default_url(url);
|
||||
m_printer_webview->load_default_url_delayed();
|
||||
}
|
||||
@ -937,15 +937,14 @@ 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())
|
||||
#endif
|
||||
dynamic_cast<TopBar*>(m_tabpanel)->AddPage(panel, panel->title(), bmp_name);
|
||||
if (panel->supports_printer_technology(printer_tech)) {
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().tabs_as_menu())
|
||||
m_tabpanel->AddPage(panel, panel->title());
|
||||
else
|
||||
m_tabpanel->AddPage(panel, panel->title());
|
||||
#endif
|
||||
dynamic_cast<TopBar*>(m_tabpanel)->AddNewPage(panel, panel->title(), bmp_name);
|
||||
}
|
||||
}
|
||||
|
||||
bool MainFrame::is_active_and_shown_tab(Tab* tab)
|
||||
|
@ -1184,6 +1184,8 @@ void PlaterPresetComboBox::sys_color_changed()
|
||||
{
|
||||
PresetComboBox::sys_color_changed();
|
||||
edit_btn->sys_color_changed();
|
||||
if (connect_info)
|
||||
wxGetApp().UpdateDarkUI(connect_info);
|
||||
}
|
||||
|
||||
// ---------------------------------
|
||||
|
@ -85,15 +85,14 @@ void TopBarItemsCtrl::Button::set_selected(bool selected)
|
||||
void TopBarItemsCtrl::Button::set_hovered(bool hovered)
|
||||
{
|
||||
using namespace Slic3r::GUI;
|
||||
const wxFont& new_font = hovered ? wxGetApp().bold_font() : wxGetApp().normal_font();
|
||||
|
||||
this->SetFont(new_font);
|
||||
#ifdef _WIN32
|
||||
this->GetParent()->Refresh(); // force redraw a background of the selected mode button
|
||||
#endif /* no _WIN32 */
|
||||
|
||||
m_background_color = hovered ? wxGetApp().get_color_selected_btn_bg() :
|
||||
m_is_selected ? wxGetApp().get_label_clr_default() :
|
||||
m_background_color = m_is_selected ? wxGetApp().get_label_clr_default() :
|
||||
hovered ? wxGetApp().get_color_selected_btn_bg() :
|
||||
|
||||
#ifdef _WIN32
|
||||
wxGetApp().get_window_default_clr();
|
||||
#else
|
||||
@ -187,8 +186,8 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label)
|
||||
|
||||
static wxString get_workspace_name(Slic3r::ConfigOptionMode mode)
|
||||
{
|
||||
return mode == Slic3r::ConfigOptionMode::comSimple ? _L("Beginners") :
|
||||
mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Regulars") : _L("Experts");
|
||||
return mode == Slic3r::ConfigOptionMode::comSimple ? _L("Beginner mode") :
|
||||
mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Normal mode") : _L("Expert mode");
|
||||
}
|
||||
|
||||
void TopBarItemsCtrl::ApplyWorkspacesMenu()
|
||||
@ -307,6 +306,13 @@ void TopBarItemsCtrl::update_margins()
|
||||
m_line_margin = std::lround(0.1 * em);
|
||||
}
|
||||
|
||||
wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos()
|
||||
{
|
||||
wxPoint pos = this->GetPosition();
|
||||
pos.y = -pos.y + int(0.2 * wxGetApp().em_unit());
|
||||
return pos;
|
||||
}
|
||||
|
||||
TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
wxControl(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE | wxTAB_TRAVERSAL)
|
||||
{
|
||||
@ -331,10 +337,9 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
|
||||
m_menu_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
|
||||
m_menu_btn->set_selected(true);
|
||||
wxPoint pos = m_menu_btn->GetPosition();
|
||||
// !!! To popup main menu use native wxPanel::PopupMenu() function
|
||||
// Don't use wrap function Plater::PopupMenu(), because it's no need in this case
|
||||
wxGetApp().plater()->wxPanel::PopupMenu(&m_main_menu, pos);
|
||||
wxGetApp().plater()->wxPanel::PopupMenu(&m_main_menu, m_menu_btn->get_popup_pos());
|
||||
});
|
||||
m_main_menu.Bind(wxEVT_MENU_CLOSE, [this](wxMenuEvent&) { m_menu_btn->set_selected(false); });
|
||||
#endif
|
||||
@ -361,8 +366,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
|
||||
m_workspace_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
|
||||
m_workspace_btn->set_selected(true);
|
||||
wxPoint pos = m_workspace_btn->GetPosition();
|
||||
wxGetApp().plater()->PopupMenu(&m_workspaces_menu, pos);
|
||||
wxGetApp().plater()->wxPanel::PopupMenu(&m_workspaces_menu, m_workspace_btn->get_popup_pos());
|
||||
});
|
||||
m_workspaces_menu.Bind(wxEVT_MENU_CLOSE, [this](wxMenuEvent&) { m_workspace_btn->set_selected(false); });
|
||||
|
||||
@ -375,8 +379,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent) :
|
||||
m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
|
||||
UpdateAccountMenu();
|
||||
m_account_btn->set_selected(true);
|
||||
wxPoint pos = m_account_btn->GetPosition();
|
||||
wxGetApp().plater()->PopupMenu(&m_account_menu, pos);
|
||||
wxGetApp().plater()->wxPanel::PopupMenu(&m_account_menu, m_account_btn->get_popup_pos());
|
||||
});
|
||||
m_account_menu.Bind(wxEVT_MENU_CLOSE, [this](wxMenuEvent&) { m_account_btn->set_selected(false); });
|
||||
|
||||
|
@ -54,6 +54,7 @@ class TopBarItemsCtrl : public wxControl
|
||||
~ButtonWithPopup() {}
|
||||
|
||||
void SetLabel(const wxString& label) override;
|
||||
wxPoint get_popup_pos();
|
||||
};
|
||||
|
||||
wxMenu m_main_menu;
|
||||
@ -164,7 +165,7 @@ public:
|
||||
// by this control) and show it immediately.
|
||||
bool ShowNewPage(wxWindow * page)
|
||||
{
|
||||
return AddPage(page, wxString(), ""/*true *//* select it */);
|
||||
return AddNewPage(page, wxString(), ""/*true *//* select it */);
|
||||
}
|
||||
|
||||
|
||||
@ -197,7 +198,7 @@ public:
|
||||
// Implement base class pure virtual methods.
|
||||
|
||||
// adds a new page to the control
|
||||
bool AddPage(wxWindow* page,
|
||||
bool AddNewPage(wxWindow* page,
|
||||
const wxString& text,
|
||||
const std::string& bmp_name,
|
||||
bool bSelect = false)
|
||||
@ -206,6 +207,15 @@ public:
|
||||
return InsertPage(GetPageCount(), page, text, bmp_name, bSelect);
|
||||
}
|
||||
|
||||
// override AddPage with using of AddNewPage
|
||||
bool AddPage( wxWindow* page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = NO_IMAGE) override
|
||||
{
|
||||
return AddNewPage(page, text, "", bSelect);
|
||||
}
|
||||
|
||||
// Page management
|
||||
virtual bool InsertPage(size_t n,
|
||||
wxWindow * page,
|
||||
|
Loading…
x
Reference in New Issue
Block a user