store position of just opened menu into Canvas3d
This commit is contained in:
parent
b36a535763
commit
d4744954cb
3 changed files with 15 additions and 3 deletions
|
@ -755,6 +755,12 @@ public:
|
|||
Size get_canvas_size() const;
|
||||
Vec2d get_local_mouse_position() const;
|
||||
|
||||
// store opening position of menu
|
||||
std::optional<Vec2d> m_popup_menu_positon; // position of mouse right click
|
||||
void set_popup_menu_position(const Vec2d &position) { m_popup_menu_positon = position; }
|
||||
const std::optional<Vec2d>& get_popup_menu_position() const { return m_popup_menu_positon; }
|
||||
void clear_popup_menu_position() { m_popup_menu_positon.reset(); }
|
||||
|
||||
void set_tooltip(const std::string& tooltip);
|
||||
|
||||
// the following methods add a snapshot to the undo/redo stack, unless the given string is empty
|
||||
|
|
|
@ -484,13 +484,17 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty
|
|||
[type, item](wxCommandEvent&) { obj_list()->load_generic_subobject(item, type); }, "", menu);
|
||||
}
|
||||
|
||||
auto add_text = [type](wxCommandEvent &) {
|
||||
GLGizmosManager &mng = plater()->canvas3D()->get_gizmos_manager();
|
||||
auto add_text = [type](wxCommandEvent &evt) {
|
||||
GLCanvas3D * canvas = plater()->canvas3D();
|
||||
GLGizmosManager &mng = canvas->get_gizmos_manager();
|
||||
if ((mng.get_current_type() == GLGizmosManager::Emboss ||
|
||||
mng.open_gizmo(GLGizmosManager::Emboss)) &&
|
||||
type != ModelVolumeType::INVALID) {
|
||||
GLGizmoEmboss *emboss = dynamic_cast<GLGizmoEmboss *>(mng.get_current());
|
||||
if (emboss != nullptr) emboss->create_volume(type);
|
||||
if (emboss == nullptr) return;
|
||||
auto screen_position = canvas->get_popup_menu_position();
|
||||
assert(screen_position.has_value());
|
||||
emboss->create_volume(type, *screen_position);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -6876,7 +6876,9 @@ bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos)
|
|||
SuppressBackgroundProcessingUpdate sbpu;
|
||||
// When tracking a pop-up menu, postpone error messages from the slicing result.
|
||||
m_tracking_popup_menu = true;
|
||||
canvas3D()->set_popup_menu_position(Vec2d(pos.x, pos.y));
|
||||
bool out = this->wxPanel::PopupMenu(menu, pos);
|
||||
canvas3D()->clear_popup_menu_position();
|
||||
m_tracking_popup_menu = false;
|
||||
if (! m_tracking_popup_menu_error_message.empty()) {
|
||||
// Don't know whether the CallAfter is necessary, but it should not hurt.
|
||||
|
|
Loading…
Reference in a new issue