Skip to content

Commit

Permalink
Merge the toggle*ManipulatorMode methods into one.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Dec 17, 2016
1 parent 0f73e83 commit 84c8510
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 48 deletions.
65 changes: 21 additions & 44 deletions radiant/selection/RadiantSelectionSystem.cpp
Expand Up @@ -1226,10 +1226,10 @@ void RadiantSelectionSystem::initialiseModule(const ApplicationContext& ctx)
sigc::mem_fun(this, &RadiantSelectionSystem::keyChanged)
);

GlobalEventManager().addToggle("ToggleClipper", std::bind(&RadiantSelectionSystem::toggleClipManipulatorMode, this, std::placeholders::_1));
GlobalEventManager().addToggle("MouseTranslate", std::bind(&RadiantSelectionSystem::toggleTranslateManipulatorMode, this, std::placeholders::_1));
GlobalEventManager().addToggle("MouseRotate", std::bind(&RadiantSelectionSystem::toggleRotateManipulatorMode, this, std::placeholders::_1));
GlobalEventManager().addToggle("MouseDrag", std::bind(&RadiantSelectionSystem::toggleDragManipulatorMode, this, std::placeholders::_1));
GlobalEventManager().addToggle("ToggleClipper", std::bind(&RadiantSelectionSystem::toggleManipulatorMode, this, Manipulator::Clip, std::placeholders::_1));
GlobalEventManager().addToggle("MouseTranslate", std::bind(&RadiantSelectionSystem::toggleManipulatorMode, this, Manipulator::Translate, std::placeholders::_1));
GlobalEventManager().addToggle("MouseRotate", std::bind(&RadiantSelectionSystem::toggleManipulatorMode, this, Manipulator::Rotate, std::placeholders::_1));
GlobalEventManager().addToggle("MouseDrag", std::bind(&RadiantSelectionSystem::toggleManipulatorMode, this, Manipulator::Drag, std::placeholders::_1));
GlobalEventManager().setToggled("MouseDrag", true);

GlobalEventManager().addToggle("DragVertices", std::bind(&RadiantSelectionSystem::toggleVertexComponentMode, this, std::placeholders::_1));
Expand Down Expand Up @@ -1345,11 +1345,11 @@ void RadiantSelectionSystem::toggleDefaultManipulatorMode(bool newState)
{
switch (_defaultManipulatorType)
{
case Manipulator::Translate: toggleTranslateManipulatorMode(true); break;
case Manipulator::Rotate: toggleRotateManipulatorMode(true); break;
case Manipulator::Translate: toggleManipulatorMode(Manipulator::Translate, true); break;
case Manipulator::Rotate: toggleManipulatorMode(Manipulator::Rotate, true); break;
case Manipulator::Scale: break;
case Manipulator::Drag: toggleDragManipulatorMode(true); break;
case Manipulator::Clip: toggleClipManipulatorMode(true); break;
case Manipulator::Drag: toggleManipulatorMode(Manipulator::Drag, true); break;
case Manipulator::Clip: toggleManipulatorMode(Manipulator::Clip, true); break;
};
}

Expand All @@ -1362,46 +1362,23 @@ void RadiantSelectionSystem::toggleManipulatorMode(Manipulator::Type type, bool
}
else // we're not in <mode> yet
{
_currentManipulatorModeSupportsComponentEditing = true;

GlobalClipper().onClipMode(false);
setActiveManipulator(type);

onManipulatorModeChanged();
}
}

void RadiantSelectionSystem::toggleDragManipulatorMode(bool newState)
{
toggleManipulatorMode(Manipulator::Drag, newState); // pass the call to the generic method
}

void RadiantSelectionSystem::toggleTranslateManipulatorMode(bool newState)
{
toggleManipulatorMode(Manipulator::Translate, newState); // pass the call to the generic method
}

void RadiantSelectionSystem::toggleRotateManipulatorMode(bool newState)
{
toggleManipulatorMode(Manipulator::Rotate, newState); // pass the call to the generic method
}
if (type == Manipulator::Clip)
{
_currentManipulatorModeSupportsComponentEditing = false;

void RadiantSelectionSystem::toggleClipManipulatorMode(bool newState)
{
if (_activeManipulator->getType() == Manipulator::Clip && _defaultManipulatorType != Manipulator::Clip)
{
toggleDefaultManipulatorMode(true);
}
else
{
_currentManipulatorModeSupportsComponentEditing = false;
activateDefaultMode();
GlobalClipper().onClipMode(true);
}
else
{
_currentManipulatorModeSupportsComponentEditing = true;

activateDefaultMode();
GlobalClipper().onClipMode(true);
setActiveManipulator(Manipulator::Clip);
GlobalClipper().onClipMode(false);
}

setActiveManipulator(type);
onManipulatorModeChanged();
onComponentModeChanged();
onComponentModeChanged();
}
}

Expand Down
4 changes: 0 additions & 4 deletions radiant/selection/RadiantSelectionSystem.h
Expand Up @@ -219,10 +219,6 @@ class RadiantSelectionSystem :

// Command targets used to connect to the event system
void toggleDefaultManipulatorMode(bool newState);
void toggleDragManipulatorMode(bool newState);
void toggleTranslateManipulatorMode(bool newState);
void toggleRotateManipulatorMode(bool newState);
void toggleClipManipulatorMode(bool newState);
void toggleManipulatorMode(Manipulator::Type type, bool newState);

void activateDefaultMode();
Expand Down

0 comments on commit 84c8510

Please sign in to comment.