Fix Retina coordinate for stored popup menu position

This commit is contained in:
Filip Sykala 2022-02-25 11:58:15 +01:00
parent ca79932d30
commit 8022c64209
3 changed files with 15 additions and 3 deletions

View File

@ -4090,6 +4090,14 @@ bool GLCanvas3D::is_object_sinking(int object_idx) const
return false;
}
void GLCanvas3D::apply_retina_scale(Vec2d &screen_coordinate) const
{
#if ENABLE_RETINA_GL
double scale = static_cast<double>(m_retina_helper->get_scale_factor());
screen_coordinate *= scale;
#endif // ENABLE_RETINA_GL
}
bool GLCanvas3D::_is_shown_on_screen() const
{
return (m_canvas != nullptr) ? m_canvas->IsShownOnScreen() : false;

View File

@ -925,6 +925,8 @@ public:
bool is_object_sinking(int object_idx) const;
void apply_retina_scale(Vec2d &screen_coordinate) const;
private:
bool _is_shown_on_screen() const;

View File

@ -4436,7 +4436,7 @@ void Plater::priv::on_right_click(RBtnEvent& evt)
}
if (q != nullptr && menu) {
const Vec2d& mouse_position = evt.data.first;
Vec2d mouse_position = evt.data.first;
wxPoint position(static_cast<int>(mouse_position.x()),
static_cast<int>(mouse_position.y()));
#ifdef __linux__
@ -4444,9 +4444,11 @@ void Plater::priv::on_right_click(RBtnEvent& evt)
// specified (even though the position is sane).
position = wxDefaultPosition;
#endif
q->canvas3D()->set_popup_menu_position(mouse_position);
GLCanvas3D &canvas = *q->canvas3D();
canvas.apply_retina_scale(mouse_position);
canvas.set_popup_menu_position(mouse_position);
q->PopupMenu(menu, position);
q->canvas3D()->clear_popup_menu_position();
canvas.clear_popup_menu_position();
}
}