Merge branch 'ys_spe2284'

This commit is contained in:
Lukas Matena 2024-05-14 08:06:50 +02:00
commit 5247ebe325
9 changed files with 99 additions and 56 deletions

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Written by Treer (gitlab.com/Treer) -->
<svg
version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
width="240"
height="240"
style="background-color:black">
<title>Mask for user icon</title>
<circle cx="120" cy="120" r="115"
stroke="black" stroke-width="1" fill="white" />
</svg>

After

Width:  |  Height:  |  Size: 401 B

View File

@ -5028,10 +5028,12 @@ bool GLCanvas3D::_init_main_toolbar()
GLToolbarItem::Data item; GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "add"; item.name = "add";
item.icon_filename = "add.svg"; item.icon_filename = "add.svg";
item.tooltip = _u8L("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]"; item.tooltip = _u8L("Add...") + " [" + GUI::shortkey_ctrl_prefix() + "I]";
item.sprite_id = 0; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ADD)); };
if (!m_main_toolbar.add_item(item)) if (!m_main_toolbar.add_item(item))
return false; return false;
@ -5039,7 +5041,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "delete"; item.name = "delete";
item.icon_filename = "remove.svg"; item.icon_filename = "remove.svg";
item.tooltip = _u8L("Delete") + " [Del]"; item.tooltip = _u8L("Delete") + " [Del]";
item.sprite_id = 1; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete(); };
if (!m_main_toolbar.add_item(item)) if (!m_main_toolbar.add_item(item))
@ -5048,7 +5050,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "deleteall"; item.name = "deleteall";
item.icon_filename = "delete_all.svg"; item.icon_filename = "delete_all.svg";
item.tooltip = _u8L("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]"; item.tooltip = _u8L("Delete all") + " [" + GUI::shortkey_ctrl_prefix() + "Del]";
item.sprite_id = 2; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_DELETE_ALL)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_delete_all(); };
if (!m_main_toolbar.add_item(item)) if (!m_main_toolbar.add_item(item))
@ -5057,7 +5059,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "arrange"; item.name = "arrange";
item.icon_filename = "arrange.svg"; item.icon_filename = "arrange.svg";
item.tooltip = _u8L("Arrange") + " [A]\n" + _u8L("Arrange selection") + " [Shift+A]\n" + _u8L("Click right mouse button to show arrangement options"); item.tooltip = _u8L("Arrange") + " [A]\n" + _u8L("Arrange selection") + " [Shift+A]\n" + _u8L("Click right mouse button to show arrangement options");
item.sprite_id = 3; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_ARRANGE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_arrange(); };
item.right.toggable = true; item.right.toggable = true;
@ -5077,7 +5079,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "copy"; item.name = "copy";
item.icon_filename = "copy.svg"; item.icon_filename = "copy.svg";
item.tooltip = _u8L("Copy") + " [" + GUI::shortkey_ctrl_prefix() + "C]"; item.tooltip = _u8L("Copy") + " [" + GUI::shortkey_ctrl_prefix() + "C]";
item.sprite_id = 4; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_COPY)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_copy_to_clipboard(); };
if (!m_main_toolbar.add_item(item)) if (!m_main_toolbar.add_item(item))
@ -5086,7 +5088,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "paste"; item.name = "paste";
item.icon_filename = "paste.svg"; item.icon_filename = "paste.svg";
item.tooltip = _u8L("Paste") + " [" + GUI::shortkey_ctrl_prefix() + "V]"; item.tooltip = _u8L("Paste") + " [" + GUI::shortkey_ctrl_prefix() + "V]";
item.sprite_id = 5; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_PASTE)); };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_paste_from_clipboard(); };
if (!m_main_toolbar.add_item(item)) if (!m_main_toolbar.add_item(item))
@ -5098,7 +5100,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "more"; item.name = "more";
item.icon_filename = "instance_add.svg"; item.icon_filename = "instance_add.svg";
item.tooltip = _u8L("Add instance") + " [+]"; item.tooltip = _u8L("Add instance") + " [+]";
item.sprite_id = 6; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_MORE)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_increase_instances(); };
@ -5109,7 +5111,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "fewer"; item.name = "fewer";
item.icon_filename = "instance_remove.svg"; item.icon_filename = "instance_remove.svg";
item.tooltip = _u8L("Remove instance") + " [-]"; item.tooltip = _u8L("Remove instance") + " [-]";
item.sprite_id = 7; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_FEWER)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_decrease_instances(); };
@ -5122,7 +5124,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "splitobjects"; item.name = "splitobjects";
item.icon_filename = "split_objects.svg"; item.icon_filename = "split_objects.svg";
item.tooltip = _u8L("Split to objects"); item.tooltip = _u8L("Split to objects");
item.sprite_id = 8; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_OBJECTS)); };
item.visibility_callback = GLToolbarItem::Default_Visibility_Callback; item.visibility_callback = GLToolbarItem::Default_Visibility_Callback;
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_objects(); };
@ -5132,7 +5134,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "splitvolumes"; item.name = "splitvolumes";
item.icon_filename = "split_parts.svg"; item.icon_filename = "split_parts.svg";
item.tooltip = _u8L("Split to parts"); item.tooltip = _u8L("Split to parts");
item.sprite_id = 9; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_SPLIT_VOLUMES)); };
item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; }; item.visibility_callback = []()->bool { return wxGetApp().get_mode() != comSimple; };
item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); }; item.enabling_callback = []()->bool { return wxGetApp().plater()->can_split_to_volumes(); };
@ -5147,7 +5149,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") + item.tooltip = _u8L("Switch to Settings") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "2] - " + _u8L("Print Settings Tab") +
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab") + "\n" + "[" + GUI::shortkey_ctrl_prefix() + "3] - " + (current_printer_technology() == ptFFF ? _u8L("Filament Settings Tab") : _u8L("Material Settings Tab") +
"\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ; "\n" + "[" + GUI::shortkey_ctrl_prefix() + "4] - " + _u8L("Printer Settings Tab")) ;
item.sprite_id = 10; item.sprite_id = sprite_id++;
item.enabling_callback = GLToolbarItem::Default_Enabling_Callback; item.enabling_callback = GLToolbarItem::Default_Enabling_Callback;
item.visibility_callback = []() { return 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(); }; item.left.action_callback = []() { wxGetApp().mainframe->select_tab(); };
@ -5160,7 +5162,7 @@ bool GLCanvas3D::_init_main_toolbar()
item.name = "layersediting"; item.name = "layersediting";
item.icon_filename = "layers_white.svg"; item.icon_filename = "layers_white.svg";
item.tooltip = _u8L("Variable layer height"); item.tooltip = _u8L("Variable layer height");
item.sprite_id = 12; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); }; item.left.action_callback = [this]() { if (m_canvas != nullptr) wxPostEvent(m_canvas, SimpleEvent(EVT_GLTOOLBAR_LAYERSEDITING)); };
item.visibility_callback = [this]()->bool { item.visibility_callback = [this]()->bool {
bool res = current_printer_technology() == ptFFF; bool res = current_printer_technology() == ptFFF;
@ -5210,10 +5212,12 @@ bool GLCanvas3D::_init_undoredo_toolbar()
GLToolbarItem::Data item; GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "undo"; item.name = "undo";
item.icon_filename = "undo_toolbar.svg"; item.icon_filename = "undo_toolbar.svg";
item.tooltip = _u8L("Undo") + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _u8L("Click right mouse button to open/close History"); item.tooltip = _u8L("Undo") + " [" + GUI::shortkey_ctrl_prefix() + "Z]\n" + _u8L("Click right mouse button to open/close History");
item.sprite_id = 0; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); }; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_UNDO)); };
item.right.toggable = true; item.right.toggable = true;
item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; }; item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; };
@ -5250,7 +5254,7 @@ bool GLCanvas3D::_init_undoredo_toolbar()
item.name = "redo"; item.name = "redo";
item.icon_filename = "redo_toolbar.svg"; item.icon_filename = "redo_toolbar.svg";
item.tooltip = _u8L("Redo") + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _u8L("Click right mouse button to open/close History"); item.tooltip = _u8L("Redo") + " [" + GUI::shortkey_ctrl_prefix() + "Y]\n" + _u8L("Click right mouse button to open/close History");
item.sprite_id = 1; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); }; item.left.action_callback = [this]() { post_event(SimpleEvent(EVT_GLCANVAS_REDO)); };
item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; }; item.right.action_callback = [this]() { m_imgui_undo_redo_hovered_pos = -1; };
item.right.render_callback = [this](float left, float right, float, float) { item.right.render_callback = [this](float left, float right, float, float) {

View File

@ -404,7 +404,7 @@ void MainFrame::update_layout()
{ {
m_plater->Reparent(m_tabpanel); m_plater->Reparent(m_tabpanel);
m_plater->Layout(); m_plater->Layout();
m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true); // m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), std::string("plater"), true);
m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 1); m_main_sizer->Add(m_tabpanel, 1, wxEXPAND | wxTOP, 1);
m_plater->Show(); m_plater->Show();
@ -476,6 +476,9 @@ void MainFrame::update_layout()
} }
#endif //__WXMSW__ #endif //__WXMSW__
if (m_layout == ESettingsLayout::Old)
m_tabpanel->InsertNewPage(0, m_plater, _L("Plater"), "", true);
Layout(); Layout();
Thaw(); Thaw();
} }
@ -1050,7 +1053,8 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
this->SetFont(this->normal_font()); this->SetFont(this->normal_font());
#ifdef _WIN32 #ifdef _WIN32
// update common mode sizer if (m_tmp_top_bar->IsShown())
m_tmp_top_bar->Rescale();
m_tabpanel->Rescale(); m_tabpanel->Rescale();
#endif #endif
@ -1062,6 +1066,10 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
for (auto tab : wxGetApp().tabs_list) for (auto tab : wxGetApp().tabs_list)
tab->msw_rescale(); tab->msw_rescale();
wxGetApp().searcher().dlg_msw_rescale();
return; // #ysFIXME - delete_after_testing - It looks like next code is no need any more
// Workarounds for correct Window rendering after rescale // Workarounds for correct Window rendering after rescale
/* Even if Window is maximized during moving, /* Even if Window is maximized during moving,
@ -1082,8 +1090,6 @@ void MainFrame::on_dpi_changed(const wxRect& suggested_rect)
this->SetSize(sz); this->SetSize(sz);
this->Maximize(is_maximized); this->Maximize(is_maximized);
wxGetApp().searcher().dlg_msw_rescale();
} }
void MainFrame::on_sys_color_changed() void MainFrame::on_sys_color_changed()
@ -2242,8 +2248,9 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
if (wxGetApp().is_gcode_viewer()) if (wxGetApp().is_gcode_viewer())
return; return;
const int& em = em_unit(); // #ysFIXME - delete_after_testing
const wxSize& size = wxSize(85 * em, 50 * em); // const int& em = em_unit();
// const wxSize& size = wxSize(85 * em, 50 * em);
#ifdef _WIN32 #ifdef _WIN32
m_tabpanel->Rescale(); m_tabpanel->Rescale();
@ -2253,9 +2260,10 @@ void SettingsDialog::on_dpi_changed(const wxRect& suggested_rect)
for (auto tab : wxGetApp().tabs_list) for (auto tab : wxGetApp().tabs_list)
tab->msw_rescale(); tab->msw_rescale();
SetMinSize(size); // #ysFIXME - delete_after_testing
Fit(); // SetMinSize(size);
Refresh(); // Fit();
// Refresh();
} }

View File

@ -3253,10 +3253,12 @@ bool Plater::priv::init_view_toolbar()
GLToolbarItem::Data item; GLToolbarItem::Data item;
unsigned int sprite_id = 0;
item.name = "3D"; item.name = "3D";
item.icon_filename = "editor.svg"; item.icon_filename = "editor.svg";
item.tooltip = _u8L("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]"; item.tooltip = _u8L("3D editor view") + " [" + GUI::shortkey_ctrl_prefix() + "5]";
item.sprite_id = 0; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); }; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_3D)); };
if (!view_toolbar.add_item(item)) if (!view_toolbar.add_item(item))
return false; return false;
@ -3264,7 +3266,7 @@ bool Plater::priv::init_view_toolbar()
item.name = "Preview"; item.name = "Preview";
item.icon_filename = "preview.svg"; item.icon_filename = "preview.svg";
item.tooltip = _u8L("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]"; item.tooltip = _u8L("Preview") + " [" + GUI::shortkey_ctrl_prefix() + "6]";
item.sprite_id = 1; item.sprite_id = sprite_id++;
item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); }; item.left.action_callback = [this]() { if (this->q != nullptr) wxPostEvent(this->q, SimpleEvent(EVT_GLVIEWTOOLBAR_PREVIEW)); };
if (!view_toolbar.add_item(item)) if (!view_toolbar.add_item(item))
return false; return false;

View File

@ -135,9 +135,9 @@ void TopBarItemsCtrl::Button::render()
pt.x = text.IsEmpty() ? ((rc.width - szIcon.x) / 2) : em; pt.x = text.IsEmpty() ? ((rc.width - szIcon.x) / 2) : em;
pt.y = (rc.height - szIcon.y) / 2; pt.y = (rc.height - szIcon.y) / 2;
#ifdef __WXGTK3__ #ifdef __WXGTK3__
dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt); dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt, true);
#else #else
dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt); dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt, true);
#endif #endif
pt.x += szIcon.x; pt.x += szIcon.x;
} }
@ -170,7 +170,7 @@ TopBarItemsCtrl::ButtonWithPopup::ButtonWithPopup(wxWindow* parent, const wxStri
:TopBarItemsCtrl::Button(parent, label, icon_name, 24, size) :TopBarItemsCtrl::Button(parent, label, icon_name, 24, size)
{ {
if (size != wxDefaultSize) if (size != wxDefaultSize)
m_fixed_width = size.x; m_fixed_width = size.x * 0.1;
this->SetLabel(label); this->SetLabel(label);
} }
@ -193,7 +193,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label)
const int label_width = GetTextExtent(text).GetWidth(); const int label_width = GetTextExtent(text).GetWidth();
bool resize_and_layout{ false }; bool resize_and_layout{ false };
if (m_fixed_width != wxDefaultCoord) { if (m_fixed_width != wxDefaultCoord) {
const int text_width = m_fixed_width - 2 * btn_height; const int text_width = m_fixed_width * em_unit(this) - 2 * btn_height;
if (label_width > text_width || GetMinSize().GetWidth() <= btn_height) { if (label_width > text_width || GetMinSize().GetWidth() <= btn_height) {
wxWindowDC wdc(this); wxWindowDC wdc(this);
text = wxControl::Ellipsize(text, wdc, wxELLIPSIZE_END, text_width); text = wxControl::Ellipsize(text, wdc, wxELLIPSIZE_END, text_width);
@ -215,7 +215,7 @@ void TopBarItemsCtrl::ButtonWithPopup::SetLabel(const wxString& label)
#endif #endif
ScalableButton::SetLabel(full_label); ScalableButton::SetLabel(full_label);
if (resize_and_layout) { if (resize_and_layout) {
SetMinSize(wxSize(m_fixed_width, btn_height)); SetMinSize(wxSize(m_fixed_width * em_unit(this), btn_height));
GetParent()->Layout(); GetParent()->Layout();
} }
} }
@ -225,11 +225,13 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
auto user_account = wxGetApp().plater()->get_user_account(); auto user_account = wxGetApp().plater()->get_user_account();
const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymous"); const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Anonymous");
m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name); m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name);
m_account_btn->SetToolTip(user_name);
const int icon_sz = 24;
#ifdef __linux__ #ifdef __linux__
if (avatar) { if (avatar) {
if (user_account->is_logged()) { if (user_account->is_logged()) {
boost::filesystem::path path = user_account->get_avatar_path(true); boost::filesystem::path path = user_account->get_avatar_path(true);
ScalableBitmap new_logo(this, path, m_account_btn->GetBitmapSize()); ScalableBitmap new_logo(this, path, wxSize(icon_sz, icon_sz));
if (new_logo.IsOk()) if (new_logo.IsOk())
m_account_btn->SetBitmap_(new_logo); m_account_btn->SetBitmap_(new_logo);
else else
@ -243,14 +245,14 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
if (avatar) { if (avatar) {
if (user_account->is_logged()) { if (user_account->is_logged()) {
boost::filesystem::path path = user_account->get_avatar_path(true); boost::filesystem::path path = user_account->get_avatar_path(true);
ScalableBitmap new_logo(this, path, m_account_btn->GetBitmapSize()); ScalableBitmap new_logo(this, path, wxSize(icon_sz, icon_sz));
if (new_logo.IsOk()) if (new_logo.IsOk())
m_account_btn->SetBitmapBundle(new_logo.bmp()); m_account_btn->SetBitmapBundle(new_logo.bmp());
else else
m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", 24)); m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", icon_sz));
} }
else { else {
m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", 24)); m_account_btn->SetBitmapBundle(*get_bmp_bundle("user", icon_sz));
} }
} }
#endif #endif
@ -365,7 +367,6 @@ void TopBarItemsCtrl::update_margins()
{ {
int em = em_unit(this); int em = em_unit(this);
m_btn_margin = std::lround(0.9 * em); m_btn_margin = std::lround(0.9 * em);
m_line_margin = std::lround(0.1 * em);
} }
wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos() wxPoint TopBarItemsCtrl::ButtonWithPopup::get_popup_pos()
@ -478,7 +479,7 @@ TopBarItemsCtrl::TopBarItemsCtrl(wxWindow *parent, TopBarMenus* menus/* = nullpt
m_menus->Popup(this, &m_menus->workspaces, m_workspace_btn->get_popup_pos()); m_menus->Popup(this, &m_menus->workspaces, m_workspace_btn->get_popup_pos());
}); });
m_account_btn = new ButtonWithPopup(this, _L("Anonymous"), "user", wxSize(18 * em_unit(this), -1)); m_account_btn = new ButtonWithPopup(this, _L("Anonymous"), "user", wxSize(180, -1));
right_sizer->Add(m_account_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT, m_btn_margin); right_sizer->Add(m_account_btn, 0, wxALIGN_CENTER_VERTICAL | wxALIGN_RIGHT | wxRIGHT, m_btn_margin);
m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) { m_account_btn->Bind(wxEVT_BUTTON, [this](wxCommandEvent& event) {
@ -529,6 +530,9 @@ void TopBarItemsCtrl::Rescale()
m_buttons_sizer->SetVGap(m_btn_margin); m_buttons_sizer->SetVGap(m_btn_margin);
m_buttons_sizer->SetHGap(m_btn_margin); m_buttons_sizer->SetHGap(m_btn_margin);
// call Layout before update buttons width to process recaling of the buttons
m_sizer->Layout();
update_btns_width(); update_btns_width();
UpdateSearchSizeAndPosition(); UpdateSearchSizeAndPosition();
m_sizer->Layout(); m_sizer->Layout();

View File

@ -105,7 +105,6 @@ private:
std::vector<Button*> m_pageButtons; std::vector<Button*> m_pageButtons;
int m_selection {-1}; int m_selection {-1};
int m_btn_margin; int m_btn_margin;
int m_line_margin;
void update_margins(); void update_margins();
}; };

View File

@ -59,11 +59,6 @@ void TopBarMenus::ApplyWorkspacesMenu()
void TopBarMenus::CreateAccountMenu() void TopBarMenus::CreateAccountMenu()
{ {
m_user_item = append_menu_item(&account, wxID_ANY, "", "",
[this](wxCommandEvent& e) { if (m_cb_on_user_item) m_cb_on_user_item(); }, get_bmp_bundle("user", 16));
account.AppendSeparator();
remember_me_item_id = wxWindow::NewControlId(); remember_me_item_id = wxWindow::NewControlId();
append_menu_check_item(&account, remember_me_item_id, _L("Remember me"), "" , append_menu_check_item(&account, remember_me_item_id, _L("Remember me"), "" ,
[](wxCommandEvent&) { wxGetApp().plater()->get_user_account()->toggle_remember_session(); } , nullptr); [](wxCommandEvent&) { wxGetApp().plater()->get_user_account()->toggle_remember_session(); } , nullptr);
@ -85,10 +80,6 @@ void TopBarMenus::UpdateAccountMenu(Slic3r::GUI::UserAccount* user_account)
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)); m_login_item->SetBitmap(is_logged ? *get_bmp_bundle("logout", 16) : *get_bmp_bundle("login", 16));
} }
const wxString user_name = is_logged ? from_u8(user_account->get_username()) : _L("Anonymous");
if (m_user_item)
m_user_item->SetItemLabel(user_name);
} }
void TopBarMenus::Popup(TopBarItemsCtrl* popup_ctrl, wxMenu* menu, wxPoint pos) void TopBarMenus::Popup(TopBarItemsCtrl* popup_ctrl, wxMenu* menu, wxPoint pos)

View File

@ -15,7 +15,6 @@ class UserAccount;
class TopBarMenus class TopBarMenus
{ {
// Prusa Account menu items // Prusa Account menu items
wxMenuItem* m_user_item { nullptr };
wxMenuItem* m_login_item { nullptr }; wxMenuItem* m_login_item { nullptr };
TopBarItemsCtrl* m_popup_ctrl { nullptr }; TopBarItemsCtrl* m_popup_ctrl { nullptr };

View File

@ -855,15 +855,36 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p
wxString path = Slic3r::GUI::from_u8(icon_path.string()); wxString path = Slic3r::GUI::from_u8(icon_path.string());
wxBitmap bitmap; wxBitmap bitmap;
const std::string ext = icon_path.extension().string(); const std::string ext = icon_path.extension().string();
if (ext == ".png") {
bitmap.LoadFile(path, wxBITMAP_TYPE_PNG); if (ext == ".png" || ext == ".jpg") {
wxBitmap::Rescale(bitmap, icon_size); bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
m_bmp = wxBitmapBundle(bitmap);
// set mask for circle shape
wxBitmapBundle mask_bmps = *get_bmp_bundle("user_mask", bitmap.GetSize().GetWidth());
wxMask* mask = new wxMask(mask_bmps.GetBitmap(bitmap.GetSize()), *wxBLACK);
bitmap.SetMask(mask);
// get allowed scale factors
std::set<double> scales = { 1.0 };
#ifdef __APPLE__
scales.emplace(Slic3r::GUI::mac_max_scaling_factor());
#elif _WIN32
size_t disp_cnt = wxDisplay::GetCount();
for (size_t disp = 0; disp < disp_cnt; ++disp)
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
// create bitmaps for bundle
wxVector<wxBitmap> bmps;
for (double scale : scales) {
wxBitmap bmp = bitmap;
wxBitmap::Rescale(bmp, icon_size * scale);
bmps.push_back(bmp);
} }
else if (ext == ".jpg") { m_bmp = wxBitmapBundle::FromBitmaps(bmps);
bitmap.LoadFile(path, wxBITMAP_TYPE_JPEG);
wxBitmap::Rescale(bitmap, icon_size);
m_bmp = wxBitmapBundle(bitmap);
} }
else if (ext == ".svg") { else if (ext == ".svg") {
m_bmp = wxBitmapBundle::FromSVGFile(path, icon_size); m_bmp = wxBitmapBundle::FromSVGFile(path, icon_size);