コード例 #1
0
        bool CreateEntityTool::handleDragDrop(InputState& inputState, const String& payload) {
            assert(m_entity != NULL);

            beginCommandGroup(wxT("Create Entity"));
            Controller::AddObjectsCommand* addObjectsCommand = Controller::AddObjectsCommand::addEntity(document(), *m_entity);
            submitCommand(addObjectsCommand);
            Controller::ChangeEditStateCommand* changeEditStateCommand = Controller::ChangeEditStateCommand::replace(document(), *m_entity);
            submitCommand(changeEditStateCommand);
            endCommandGroup();
            
            m_entity = NULL;
            deleteFigure(m_entityFigure);
            m_entityFigure = NULL;

            return true;
        }
コード例 #2
0
void RKConsole::tryNextInBatch (bool add_new_line) {
	RK_TRACE (APP);
	if (add_new_line) {
		if (RKSettingsModuleConsole::maxConsoleLines ()) {
			uint c = (uint) doc->numLines();
			setUpdatesEnabled (false);
			for (uint ui = c; ui > RKSettingsModuleConsole::maxConsoleLines (); --ui) {
				editInterface(doc)->removeText (0, 0,0, editInterface(doc)->textLine(0).length());
			}
			setUpdatesEnabled (true);
		}
		editInterface(doc)->insertText (doc->numLines ()-1, 0, prefix);		// somehow, it seems to be safer to do this after removing superfluous lines, than before
		cursorAtTheEnd ();
	}

	if (!commands_batch.isEmpty()) {
		// If we were not finished executing a batch of commands, we execute the next one.
		setCurrentCommand (currentCommand () + commands_batch.first ());
		commands_batch.pop_front ();
		if (!commands_batch.isEmpty ()){
			submitCommand ();
			return;
		}
		// We would put this here if we would want the last line to be executed. We generally don't want this, as there is an empty last item, if there is a newline at the end.
		//TODO: deal with this kind of situation better.
		//commands_batch.erase(commands_batch.begin());
	}

	current_command = 0;
	interrupt_command_action->setEnabled (isBusy ());
}
コード例 #3
0
        bool RotateObjectsTool::handleDrag(InputState& inputState) {
            int delta = 0;
            if (m_axis == Vec3f::PosZ) {
                delta = -(inputState.x() - m_startX);
            } else {
                delta = inputState.y() - m_startY;
                if (m_invert)
                    delta *= -1;
            }

            m_angle = static_cast<float>(delta) / 200.0f * Math::Pi;

            Utility::Grid& grid = document().grid();
            m_angle = grid.snapAngle(m_angle);

            m_ignoreObjectsChange = true;
            rollbackCommandGroup();

            if (m_angle != 0.0f) {
                Model::EditStateManager& editStateManager = document().editStateManager();
                const Model::EntityList& entities = editStateManager.selectedEntities();
                const Model::BrushList& brushes = editStateManager.selectedBrushes();
                RotateObjectsCommand* command = RotateObjectsCommand::rotate(document(), entities, brushes, m_axis, m_angle, false, m_center, document().textureLock());
                submitCommand(command);
            }

            m_ignoreObjectsChange = false;
            return true;
        }
コード例 #4
0
        void CreateBrushTool::handleEndPlaneDrag(InputState& inputState) {
            assert(m_brush != NULL);
            assert(m_brushFigure != NULL);
            
            Controller::AddObjectsCommand* addBrushCommand = Controller::AddObjectsCommand::addBrush(document(), *m_brush);
            Controller::ChangeEditStateCommand* selectBrushCommand = Controller::ChangeEditStateCommand::replace(document(), *m_brush);
            
            beginCommandGroup(wxT("Create Brush"));
            submitCommand(addBrushCommand);
            submitCommand(selectBrushCommand);
            endCommandGroup();
            
            m_brush = NULL;

            deleteFigure(m_brushFigure);
            m_brushFigure = NULL;
        }
コード例 #5
0
/* ----------------------------------------------------------------------
 * Author: Julian
 * Date: 27 January 2014
 * Description: Handles the text the user enters
 * ----------------------------------------------------------------------
 */
void Console::handleText(const sf::Event& windowEvent)
{
	// If you pressed return it will send the message, otherwise keep writing
	if(windowEvent.text.unicode == 13)
	{
		// You can't send an empty command!
		if(!consoleTextList[0].getString().isEmpty())
			submitCommand();
	}
	else if(windowEvent.text.unicode == 8)
	{
		// Erases a sign
		if(!consoleTextList[0].getString().isEmpty())
		{
			std::string temp = consoleTextList[0].getString().toAnsiString();
			temp.erase(temp.size() - 1, 1);
			consoleTextList[0].setString(temp);
		}
	}
	else if(windowEvent.text.unicode != 96)
		consoleTextList[0].setString(consoleTextList[0].getString() + windowEvent.text.unicode);
}
コード例 #6
0
bool RKConsole::handleKeyPress (QKeyEvent *e) {

	uint para=0; uint pos=0;
	view->cursorPosition (&para, &pos);

	if (para < doc->numLines() - 1 || pos < prefix.length ()) {	// not inside the last line?
		int t = (int) pos;					// adjust position before interpreting keystroke
		if (prefix.length()>pos) t=prefix.length ();
		view->setCursorPosition (doc->numLines () -1, t);
	}

	if (hasSelectedText () && (selectionInterfaceExt(doc)->selStartCol () < (int) prefix.length () || selectionInterfaceExt (doc)->selStartLine () < (int) doc->numLines () -1)) { // There is a selection outside the command line
		// Eat the key and beep (unless it's just a modifier key). Otherwise it might overwrite or delete the selection
		if (e->state () == e->stateAfter ()) {
			KApplication::kApplication ()->beep ();
			e->ignore ();
		}
		return true;
	}

	if (current_command) {
		e->ignore ();
		return true;
	}

	if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Return) {
		hinter->hideArgHint ();
		submitCommand ();
		return true;
	}
	else if (e->state () == Qt::ShiftButton && e->key () == Qt::Key_Home){
		if(hasSelectedText())
			pos=selectionInterfaceExt(doc)->selEndCol (); //There is already a selection, we take it into account.
		selectionInterface(doc)->setSelection(doc->numLines()-1,prefix.length (),doc->numLines()-1, pos);
		cursorAtTheBeginning ();
		return true;
	}
	else if (e->state () == Qt::ShiftButton && e->key () == Qt::Key_Left){
		if(pos<=prefix.length ()){
			return true;
		} else {
			view->shiftCursorLeft ();
			return false;
		}
	}
	else if (e->key () == Qt::Key_Up) {
		commandsListUp ();
		return true;
	}
	else if (e->key () == Qt::Key_Down) {
		commandsListDown ();
		return true;
	}
	else if (e->key () == Qt::Key_Left){
		if(pos<=prefix.length ()){
			return true;
		} else {
			view->cursorLeft();
			return true;
		}
	}
	else if (e->key () == Qt::Key_Backspace){
		if(pos<=prefix.length ()){
			return true;
		} else {
			view->backspace();
			return true;
		}
	}
	else if (e->key () == Qt::Key_Tab){
		doTabCompletion ();
		return true;
	}
	else if (e->key () == Qt::Key_Home){
		cursorAtTheBeginning ();
		return true;
	}
	else if (e->key() == Qt::Key_Delete) {
		view->keyDelete();
		return true;
	}

	return false;
}