Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5451: LayerOrthoContextMenuItems now dispatch the operations through…
… the command system
  • Loading branch information
codereader committed Dec 24, 2020
1 parent 25fc354 commit 5ae4cfe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
25 changes: 3 additions & 22 deletions radiant/ui/layers/LayerOrthoContextMenuItem.cpp
Expand Up @@ -56,36 +56,17 @@ void LayerOrthoContextMenuItem::preShow()

void LayerOrthoContextMenuItem::AddToLayer(int layerID)
{
DoWithMapLayerManager([=](scene::ILayerManager& manager)
{
manager.addSelectionToLayer(layerID);
});
GlobalCommandSystem().executeCommand("AddSelectionToLayer", cmd::Argument(layerID));
}

void LayerOrthoContextMenuItem::MoveToLayer(int layerID)
{
DoWithMapLayerManager([=](scene::ILayerManager& manager)
{
manager.moveSelectionToLayer(layerID);
});
GlobalCommandSystem().executeCommand("MoveSelectionToLayer", cmd::Argument(layerID));
}

void LayerOrthoContextMenuItem::RemoveFromLayer(int layerID)
{
DoWithMapLayerManager([=](scene::ILayerManager& manager)
{
manager.removeSelectionFromLayer(layerID);
});
}

void LayerOrthoContextMenuItem::DoWithMapLayerManager(const std::function<void(scene::ILayerManager&)>& func)
{
if (!GlobalMapModule().getRoot())
{
return;
}

func(GlobalMapModule().getRoot()->getLayerManager());
GlobalCommandSystem().executeCommand("RemoveSelectionFromLayer", cmd::Argument(layerID));
}

} // namespace
3 changes: 0 additions & 3 deletions radiant/ui/layers/LayerOrthoContextMenuItem.h
Expand Up @@ -38,9 +38,6 @@ class LayerOrthoContextMenuItem :
static void AddToLayer(int layerID);
static void MoveToLayer(int layerID);
static void RemoveFromLayer(int layerID);

private:
static void DoWithMapLayerManager(const std::function<void(scene::ILayerManager&)>& func);
};
typedef std::shared_ptr<LayerOrthoContextMenuItem> LayerOrthoContextMenuItemPtr;

Expand Down

0 comments on commit 5ae4cfe

Please sign in to comment.