TopBarMenus: Deleted account menu item and set tooltip with user name on Account button

+ Make circle icon for logo
This commit is contained in:
YuSanka 2024-04-26 16:59:43 +02:00 committed by Lukas Matena
parent 26d52595a8
commit dc78fc5a77
5 changed files with 28 additions and 12 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

@ -135,9 +135,9 @@ void TopBarItemsCtrl::Button::render()
pt.x = text.IsEmpty() ? ((rc.width - szIcon.x) / 2) : em;
pt.y = (rc.height - szIcon.y) / 2;
#ifdef __WXGTK3__
dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt);
dc.DrawBitmap(m_bmp_bundle.GetBitmap(szIcon), pt, true);
#else
dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt);
dc.DrawBitmap(m_bmp_bundle.GetBitmapFor(this), pt, true);
#endif
pt.x += szIcon.x;
}
@ -225,6 +225,7 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
auto user_account = wxGetApp().plater()->get_user_account();
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->SetToolTip(user_name);
const int icon_sz = 24;
#ifdef __linux__
if (avatar) {

View File

@ -59,11 +59,6 @@ void TopBarMenus::ApplyWorkspacesMenu()
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();
append_menu_check_item(&account, remember_me_item_id, _L("Remember me"), "" ,
[](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->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)

View File

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

View File

@ -859,6 +859,14 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p
if (ext == ".png" || ext == ".jpg") {
bitmap.LoadFile(path, ext == ".png" ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_JPEG);
// 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());
@ -868,6 +876,8 @@ ScalableBitmap::ScalableBitmap(wxWindow* parent, boost::filesystem::path& icon_p
scales.emplace(wxDisplay(disp).GetScaleFactor());
#endif
// create bitmaps for bundle
wxVector<wxBitmap> bmps;
for (double scale : scales) {
wxBitmap bmp = bitmap;