Exemplo n.º 1
0
void SelectionPlugin::onMouseButtonRelease( const MouseButtonEvent& event )
{
	if( event.button != MouseButton::Left )
		return;

	SceneDocument* sceneDocument = (SceneDocument*) editor->getDocument();
	sceneDocument->getRenderWindow()->setCursorCapture(false);

	editor->getDocument()->getWindow()->flagRedraw();

	SelectionOperation* selection = nullptr;

	if(selections->dragRectangle)
		selection = processDragSelection(event);
	else
		selection = processSelection(event);

	if( !selection ) return;

	const SelectionCollection& selected = selections->getSelections();

	// Prevent duplication of selection events.
	if( selected.isSame(selection->selections) ) 
	{
		LogDebug("Ignoring duplicated selection");
		Deallocate(selection);
		return;
	}

	selection->redo();

	UndoManager* undoManager = sceneDocument->getUndoManager();
	undoManager->registerOperation(selection);
}
Exemplo n.º 2
0
void SelectionPlugin::onUndoOperation( const UndoOperationPtr& operation )
{
	assert( operation != nullptr );

	Class* klass = operation->getType();
	
	if( !ClassInherits(klass, ReflectionGetType(SelectionOperation)) )
		return;

	SelectionOperation* selection = RefCast<SelectionOperation>(operation).get();
	selection->redo();
}