Add Copy, Cut, and Delete selection to right click popup

This commit is contained in:
Yousef Khadadeh 2025-12-01 17:52:58 +03:00
parent 359f20e7fd
commit 303dac19a4
2 changed files with 18 additions and 6 deletions

View file

@ -229,12 +229,24 @@ void DrawingProgram::toolbar_gui() {
bool DrawingProgram::selection_action_menu(Vector2f popupPos) {
Toolbar& t = world.main.toolbar;
// Paste objects action only works on selection allowing tools
return !t.gui.action_list_popup_menu("General popup menu", popupPos, {
{"Paste Objects", [&]() {
selection.deselect_all();
selection.paste_clipboard(popupPos);
}}
std::vector<std::pair<std::string, std::function<void()>>> actions;
actions.emplace_back("Paste Objects", [&]() {
selection.deselect_all();
selection.paste_clipboard(popupPos);
});
if(selection.is_something_selected()) {
actions.emplace_back("Copy Selection", [&]() {
selection.selection_to_clipboard();
});
actions.emplace_back("Cut Selection", [&]() {
selection.selection_to_clipboard();
selection.delete_all();
});
actions.emplace_back("Delete Selection", [&]() {
selection.delete_all();
});
}
return !t.gui.action_list_popup_menu("General popup menu", popupPos, actions);
}
bool DrawingProgram::right_click_popup_gui(Vector2f popupPos) {

View file

@ -30,11 +30,11 @@ class DrawingProgramSelection {
void selection_to_clipboard();
void paste_clipboard(Vector2f pasteScreenPos);
void delete_all();
private:
std::function<bool(const std::shared_ptr<DrawingProgramCacheBVHNode>&, std::vector<CollabListType::ObjectInfoPtr>&)> erase_select_objects_in_bvh_func(std::unordered_set<CollabListType::ObjectInfoPtr>& selectedComponents, const SCollision::ColliderCollection<float>& cC, const SCollision::ColliderCollection<WorldScalar>& cCWorld);
void fully_collided_erase_select_objects_func(std::unordered_set<CollabListType::ObjectInfoPtr>& selectedComponents, const std::shared_ptr<DrawingProgramCacheBVHNode>& bvhNode);
void delete_all();
bool mouse_collided_with_selection_aabb();
bool mouse_collided_with_scale_point();
bool mouse_collided_with_rotate_center_handle_point();