mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-19 20:29:07 +08:00
TopBarMenus: Added sys_color_changed() to correct process a changing of the application color mode
SPE-2320
This commit is contained in:
parent
86780b5a6c
commit
fa61ea4e9e
@ -6,7 +6,7 @@
|
|||||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||||
width="600"
|
width="600"
|
||||||
height="600"
|
height="600"
|
||||||
stroke="grey"
|
stroke="#808080"
|
||||||
stroke-width="30"
|
stroke-width="30"
|
||||||
fill="none">
|
fill="none">
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 497 B After Width: | Height: | Size: 500 B |
@ -1478,14 +1478,18 @@ static void update_menu_item_def_colors(T* item)
|
|||||||
|
|
||||||
void MenuFactory::sys_color_changed()
|
void MenuFactory::sys_color_changed()
|
||||||
{
|
{
|
||||||
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu }) {
|
for (MenuWithSeparators* menu : { &m_object_menu, &m_sla_object_menu, &m_part_menu, &m_default_menu })
|
||||||
sys_color_changed_menu(dynamic_cast<wxMenu*>(menu));// msw_rescale_menu updates just icons, so use it
|
sys_color_changed(dynamic_cast<wxMenu*>(menu));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuFactory::sys_color_changed(wxMenu* menu)
|
||||||
|
{
|
||||||
|
sys_color_changed_menu(menu);// msw_rescale_menu updates just icons, so use it
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// but under MSW we have to update item's bachground color
|
// but under MSW we have to update item's bachground color
|
||||||
for (wxMenuItem* item : menu->GetMenuItems())
|
for (wxMenuItem* item : menu->GetMenuItems())
|
||||||
update_menu_item_def_colors(item);
|
update_menu_item_def_colors(item);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuFactory::sys_color_changed(wxMenuBar* menubar)
|
void MenuFactory::sys_color_changed(wxMenuBar* menubar)
|
||||||
|
@ -77,6 +77,7 @@ public:
|
|||||||
void update_default_menu();
|
void update_default_menu();
|
||||||
void sys_color_changed();
|
void sys_color_changed();
|
||||||
|
|
||||||
|
static void sys_color_changed(wxMenu* menu);
|
||||||
static void sys_color_changed(wxMenuBar* menu_bar);
|
static void sys_color_changed(wxMenuBar* menu_bar);
|
||||||
|
|
||||||
wxMenu* default_menu();
|
wxMenu* default_menu();
|
||||||
|
@ -548,6 +548,10 @@ void TopBarItemsCtrl::Rescale()
|
|||||||
void TopBarItemsCtrl::OnColorsChanged()
|
void TopBarItemsCtrl::OnColorsChanged()
|
||||||
{
|
{
|
||||||
wxGetApp().UpdateDarkUI(this);
|
wxGetApp().UpdateDarkUI(this);
|
||||||
|
|
||||||
|
if (m_menus)
|
||||||
|
m_menus->sys_color_changed();
|
||||||
|
|
||||||
if (m_menu_btn)
|
if (m_menu_btn)
|
||||||
m_menu_btn->sys_color_changed();
|
m_menu_btn->sys_color_changed();
|
||||||
if (m_settings_btn)
|
if (m_settings_btn)
|
||||||
@ -555,6 +559,8 @@ void TopBarItemsCtrl::OnColorsChanged()
|
|||||||
|
|
||||||
m_workspace_btn->sys_color_changed();
|
m_workspace_btn->sys_color_changed();
|
||||||
m_account_btn->sys_color_changed();
|
m_account_btn->sys_color_changed();
|
||||||
|
UpdateAccountButton(true);
|
||||||
|
|
||||||
m_search->SysColorsChanged();
|
m_search->SysColorsChanged();
|
||||||
|
|
||||||
UpdateSelection();
|
UpdateSelection();
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include "TopBarMenus.hpp"
|
#include "TopBarMenus.hpp"
|
||||||
#include "TopBar.hpp"
|
#include "TopBar.hpp"
|
||||||
|
|
||||||
|
#include "GUI_Factories.hpp"
|
||||||
|
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
#include "Plater.hpp"
|
#include "Plater.hpp"
|
||||||
#include "UserAccount.hpp"
|
#include "UserAccount.hpp"
|
||||||
@ -34,6 +36,13 @@ wxString TopBarMenus::get_workspace_name(const int mode)
|
|||||||
mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Normal mode") : _L("Expert mode");
|
mode == Slic3r::ConfigOptionMode::comAdvanced ? _L("Normal mode") : _L("Expert mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TopBarMenus::sys_color_changed()
|
||||||
|
{
|
||||||
|
MenuFactory::sys_color_changed(&main);
|
||||||
|
MenuFactory::sys_color_changed(&workspaces);
|
||||||
|
MenuFactory::sys_color_changed(&account);
|
||||||
|
}
|
||||||
|
|
||||||
void TopBarMenus::ApplyWorkspacesMenu()
|
void TopBarMenus::ApplyWorkspacesMenu()
|
||||||
{
|
{
|
||||||
wxMenuItemList& items = workspaces.GetMenuItems();
|
wxMenuItemList& items = workspaces.GetMenuItems();
|
||||||
@ -70,7 +79,7 @@ void TopBarMenus::CreateAccountMenu()
|
|||||||
user_account->do_logout();
|
user_account->do_logout();
|
||||||
else
|
else
|
||||||
user_account->do_login();
|
user_account->do_login();
|
||||||
}, get_bmp_bundle("login", 16));
|
}, "login");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TopBarMenus::UpdateAccountMenu(Slic3r::GUI::UserAccount* user_account)
|
void TopBarMenus::UpdateAccountMenu(Slic3r::GUI::UserAccount* user_account)
|
||||||
@ -78,7 +87,7 @@ void TopBarMenus::UpdateAccountMenu(Slic3r::GUI::UserAccount* user_account)
|
|||||||
bool is_logged = user_account && user_account->is_logged();
|
bool is_logged = user_account && user_account->is_logged();
|
||||||
if (m_login_item) {
|
if (m_login_item) {
|
||||||
m_login_item->SetItemLabel(is_logged ? _L("Prusa Account Log out") : _L("Prusa Account Log in"));
|
m_login_item->SetItemLabel(is_logged ? _L("Prusa Account Log out") : _L("Prusa Account Log in"));
|
||||||
m_login_item->SetBitmap(is_logged ? *get_bmp_bundle("logout", 16) : *get_bmp_bundle("login", 16));
|
set_menu_item_bitmap(m_login_item, is_logged ? "logout" : "login");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
|
|
||||||
wxString get_workspace_name(const /*ConfigOptionMode*/int mode);
|
wxString get_workspace_name(const /*ConfigOptionMode*/int mode);
|
||||||
void set_cb_on_user_item (std::function<void()> cb) { m_cb_on_user_item = cb; }
|
void set_cb_on_user_item (std::function<void()> cb) { m_cb_on_user_item = cb; }
|
||||||
|
void sys_color_changed();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -215,6 +215,16 @@ wxMenuItem* append_menu_check_item(wxMenu* menu, int id, const wxString& string,
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_menu_item_bitmap(wxMenuItem* item, const std::string& icon_name)
|
||||||
|
{
|
||||||
|
item->SetBitmap(*get_bmp_bundle(icon_name));
|
||||||
|
#ifndef __linux__
|
||||||
|
const auto it = msw_menuitem_bitmaps.find(item->GetId());
|
||||||
|
if (it != msw_menuitem_bitmaps.end() && it->second != icon_name)
|
||||||
|
it->second = icon_name;
|
||||||
|
#endif // !__linux__
|
||||||
|
}
|
||||||
|
|
||||||
/* Function for rescale of buttons in Dialog under MSW if dpi is changed.
|
/* Function for rescale of buttons in Dialog under MSW if dpi is changed.
|
||||||
* btn_ids - vector of buttons identifiers
|
* btn_ids - vector of buttons identifiers
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +53,8 @@ wxMenuItem* append_menu_check_item(wxMenu* menu, int id, const wxString& string,
|
|||||||
|
|
||||||
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win);
|
void enable_menu_item(wxUpdateUIEvent& evt, std::function<bool()> const cb_condition, wxMenuItem* item, wxWindow* win);
|
||||||
|
|
||||||
|
void set_menu_item_bitmap(wxMenuItem* item, const std::string& icon_name);
|
||||||
|
|
||||||
class wxDialog;
|
class wxDialog;
|
||||||
|
|
||||||
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids, double height_koef = 1.);
|
void msw_buttons_rescale(wxDialog* dlg, const int em_unit, const std::vector<int>& btn_ids, double height_koef = 1.);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user