Fix for for SPE-2338 - [LINUX] "Menu" / "Log in" has wrong label layout (is bottom placed)

(set icon size for 20px instead of 24)
+ Sidebar: nonMSW specific : Added right margin for bottom buttons
+ Gizmos toolbar: Code cleaning
This commit is contained in:
YuSanka 2024-06-06 15:53:37 +02:00 committed by Lukas Matena
parent 8590e34aaf
commit 986b0e1cdb
5 changed files with 25 additions and 29 deletions

View File

@ -1291,7 +1291,7 @@ void GLToolbar::render_vertical(const GLCanvas3D& parent)
render_background(left, top, right, bottom, border_w, border_h); render_background(left, top, right, bottom, border_w, border_h);
left += border_w + gap_size_y; left += border_w + gap_size_x;
top -= border_h + gap_size_y; top -= border_h + gap_size_y;
// renders icons // renders icons

View File

@ -62,8 +62,6 @@ std::vector<size_t> GLGizmosManager::get_selectable_idxs() const
return out; return out;
} }
#define rect_sel 1 // square_sel, if 0
GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_pos) const GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_pos) const
{ {
if (!m_enabled) return Undefined; if (!m_enabled) return Undefined;
@ -74,7 +72,6 @@ GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_
float border = m_layout.scaled_border(); float border = m_layout.scaled_border();
float stride_y = m_layout.scaled_stride_y(); float stride_y = m_layout.scaled_stride_y();
float gap_x = m_layout.scaled_gap_x(); float gap_x = m_layout.scaled_gap_x();
float gap_y = m_layout.scaled_gap_x();
float top_y = 0.5f * (cnv_h - height) + border; float top_y = 0.5f * (cnv_h - height) + border;
// is mouse horizontally in the area? // is mouse horizontally in the area?
@ -83,11 +80,7 @@ GLGizmosManager::EType GLGizmosManager::get_gizmo_from_mouse(const Vec2d &mouse_
// which icon is it on? // which icon is it on?
size_t from_top = (size_t) ((float) mouse_pos(1) - top_y) / stride_y; size_t from_top = (size_t) ((float) mouse_pos(1) - top_y) / stride_y;
// is it really on the icon or already past the border? // is it really on the icon or already past the border?
#if rect_sel
if ((float) mouse_pos(1) <= top_y + from_top * stride_y + icons_size) { if ((float) mouse_pos(1) <= top_y + from_top * stride_y + icons_size) {
#else
if ((float) mouse_pos(1) <= top_y + gap_y + from_top * stride_y + icons_size) {
#endif
std::vector<size_t> selectable = get_selectable_idxs(); std::vector<size_t> selectable = get_selectable_idxs();
if (from_top < selectable.size()) if (from_top < selectable.size())
return static_cast<EType>(selectable[from_top]); return static_cast<EType>(selectable[from_top]);
@ -817,14 +810,9 @@ void GLGizmosManager::do_render_overlay() const
render_background(top_x, top_y, top_x + width, top_y - height, border_w, border_h); render_background(top_x, top_y, top_x + width, top_y - height, border_w, border_h);
const float margin_w = border_w + m_layout.scaled_gap_x() * inv_cnv_w; const float margin_w = border_w + m_layout.scaled_gap_x() * inv_cnv_w;
const float margin_h = border_h + m_layout.scaled_gap_y() * inv_cnv_h;
top_x += margin_w; top_x += margin_w;
#if rect_sel
top_y -= border_h; top_y -= border_h;
#else
top_y -= margin_h;
#endif
const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w; const float icons_size_x = 2.0f * m_layout.scaled_icons_size() * inv_cnv_w;
const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h; const float icons_size_y = 2.0f * m_layout.scaled_icons_size() * inv_cnv_h;
@ -849,11 +837,7 @@ void GLGizmosManager::do_render_overlay() const
GLGizmoBase* gizmo = m_gizmos[idx].get(); GLGizmoBase* gizmo = m_gizmos[idx].get();
if (m_current == idx) if (m_current == idx)
#if rect_sel
render_background(top_x - margin_w, top_y + border_h, top_x + icons_size_x + margin_w, top_y - icons_size_y - border_h, border_w, border_h); render_background(top_x - margin_w, top_y + border_h, top_x + icons_size_x + margin_w, top_y - icons_size_y - border_h, border_w, border_h);
#else
render_background(top_x - margin_w, top_y + margin_h, top_x + icons_size_x + margin_w, top_y - icons_size_y - margin_h, border_w, border_h);
#endif
const unsigned int sprite_id = gizmo->get_sprite_id(); const unsigned int sprite_id = gizmo->get_sprite_id();
// higlighted state needs to be decided first so its highlighting in every other state // higlighted state needs to be decided first so its highlighting in every other state
@ -879,11 +863,7 @@ void GLGizmosManager::do_render_overlay() const
float GLGizmosManager::get_scaled_total_height() const float GLGizmosManager::get_scaled_total_height() const
{ {
#if rect_sel
return 2.0f * m_layout.scaled_border() + (float)get_selectable_idxs().size() * m_layout.scaled_stride_y() - m_layout.scaled_gap_y(); return 2.0f * m_layout.scaled_border() + (float)get_selectable_idxs().size() * m_layout.scaled_stride_y() - m_layout.scaled_gap_y();
#else
return 2.0f * m_layout.scaled_border() + (float)get_selectable_idxs().size() * m_layout.scaled_stride_y();
#endif
} }
float GLGizmosManager::get_scaled_total_width() const float GLGizmosManager::get_scaled_total_width() const

View File

@ -513,7 +513,11 @@ Sidebar::Sidebar(Plater *parent)
auto *sizer = new wxBoxSizer(wxVERTICAL); auto *sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(m_scrolled_panel, 1, wxEXPAND); sizer->Add(m_scrolled_panel, 1, wxEXPAND);
sizer->Add(btns_sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM, margin_5); sizer->Add(btns_sizer, 0, wxEXPAND | wxLEFT | wxBOTTOM
#ifndef _WIN32
| wxRIGHT
#endif // __linux__
, margin_5);
SetSizer(sizer); SetSizer(sizer);
// Events // Events

View File

@ -166,8 +166,14 @@ void TopBarItemsCtrl::Button::sys_color_changed()
m_foreground_color = wxGetApp().get_label_clr_default(); m_foreground_color = wxGetApp().get_label_clr_default();
} }
#ifdef __linux__
const int icon_sz = 20;
#else
const int icon_sz = 24;
#endif
TopBarItemsCtrl::ButtonWithPopup::ButtonWithPopup(wxWindow* parent, const wxString& label, const std::string& icon_name, wxSize size) TopBarItemsCtrl::ButtonWithPopup::ButtonWithPopup(wxWindow* parent, const wxString& label, const std::string& icon_name, wxSize size)
:TopBarItemsCtrl::Button(parent, label, icon_name, 24, size) :TopBarItemsCtrl::Button(parent, label, icon_name, icon_sz, size)
{ {
if (size != wxDefaultSize) if (size != wxDefaultSize)
m_fixed_width = size.x * 0.1; m_fixed_width = size.x * 0.1;
@ -224,9 +230,7 @@ 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("Log in"); const wxString user_name = user_account->is_logged() ? from_u8(user_account->get_username()) : _L("Log in");
m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name);
m_account_btn->SetToolTip(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()) {
@ -256,7 +260,10 @@ void TopBarItemsCtrl::UpdateAccountButton(bool avatar/* = false*/)
} }
} }
#endif #endif
m_account_btn->Refresh();
m_account_btn->SetLabel(m_collapsed_btns ? "" : user_name);
this->Layout();
// m_account_btn->Refresh();
} }
void TopBarItemsCtrl::UnselectPopupButtons() void TopBarItemsCtrl::UnselectPopupButtons()

View File

@ -566,10 +566,15 @@ ScalableButton::ScalableButton( wxWindow * parent,
SetBitmap(bitmap.bmp()); SetBitmap(bitmap.bmp());
} }
void ScalableButton::SetBitmap_(const ScalableBitmap& bmp) void ScalableButton::SetBitmap_(const ScalableBitmap& bitmap)
{ {
SetBitmap(bmp.bmp()); const wxBitmapBundle& bmp = bitmap.bmp();
m_current_icon_name = bmp.name(); SetBitmap(bmp);
SetBitmapCurrent(bmp);
SetBitmapPressed(bmp);
SetBitmapFocus(bmp);
SetBitmapDisabled(bmp);
m_current_icon_name = bitmap.name();
} }
bool ScalableButton::SetBitmap_(const std::string& bmp_name) bool ScalableButton::SetBitmap_(const std::string& bmp_name)