From 82fb304e61191f27403b5dbfaa90f24d625dee87 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 16 Mar 2015 17:15:46 -0400 Subject: Added popup menu to tree in map editor --- tools/mapedit/src/frame.cpp | 13 +++++++++++++ tools/mapedit/src/frame.h | 2 ++ 2 files changed, 15 insertions(+) (limited to 'tools') diff --git a/tools/mapedit/src/frame.cpp b/tools/mapedit/src/frame.cpp index 500f2c4..934e0f8 100644 --- a/tools/mapedit/src/frame.cpp +++ b/tools/mapedit/src/frame.cpp @@ -52,6 +52,7 @@ wxBEGIN_EVENT_TABLE(MapeditFrame, wxFrame) EVT_TREE_SEL_CHANGED(MAP_EDITOR_TREE, MapeditFrame::OnDidSelectMap) EVT_TREE_BEGIN_DRAG(MAP_EDITOR_TREE, MapeditFrame::OnWillDragMap) EVT_TREE_END_DRAG(MAP_EDITOR_TREE, MapeditFrame::OnDidDragMap) + EVT_TREE_ITEM_RIGHT_CLICK(MAP_EDITOR_TREE, MapeditFrame::OnRightClickTree) EVT_TEXT(MAP_TITLE_TEXTBOX, MapeditFrame::OnTitleChange) EVT_BUTTON(ADD_ENTITY_BUTTON, MapeditFrame::OnAddEntity) EVT_BUTTON(CANCEL_ENTITY_BUTTON, MapeditFrame::OnCancelAddEntity) @@ -84,6 +85,10 @@ MapeditFrame::MapeditFrame(std::unique_ptr world) : wxFrame(NULL, wxID_AN SetMenuBar(menuBar); + mapTreePopup = new wxMenu; + mapTreePopup->Append(MENU_MAP_ADD_ROOT, "Add Sibling Map"); + mapTreePopup->Append(MENU_MAP_ADD_CHILD, "Add Child Map"); + // Layout 1: Splitter between map tree and layout 2 // Layout 2: Non-splitter between layout 3 and notebook // Layout 3: Splitter between map editor and properties editor @@ -411,6 +416,14 @@ void MapeditFrame::OnDidDragMap(wxTreeEvent& event) mapTree->SelectItem(newChild); } +void MapeditFrame::OnRightClickTree(wxTreeEvent& event) +{ + if (event.GetItem().IsOk()) + { + PopupMenu(mapTreePopup); + } +} + void MapeditFrame::NewWorld() { LaunchWindow(std::unique_ptr(new World())); diff --git a/tools/mapedit/src/frame.h b/tools/mapedit/src/frame.h index f1e4efc..4844485 100644 --- a/tools/mapedit/src/frame.h +++ b/tools/mapedit/src/frame.h @@ -62,6 +62,7 @@ class MapeditFrame : public wxFrame { void OnWillSelectMap(wxTreeEvent& event); void OnWillDragMap(wxTreeEvent& event); void OnDidDragMap(wxTreeEvent& event); + void OnRightClickTree(wxTreeEvent& event); std::unique_ptr world; Map* currentMap; @@ -77,6 +78,7 @@ class MapeditFrame : public wxFrame { wxMenu* menuFile; wxTreeCtrl* mapTree; wxTreeItemId dragMap; + wxMenu* mapTreePopup; bool addingEntity = false; -- cgit 1.4.1