Esempio n. 1
0
void ActionStack::undo() {
	assert(canUndo());
	if (!canUndo()) return;
	Action* action = undo_actions.back();
	action->perform(true);
	tellListeners(*action, true);
	// move to redo stack
	undo_actions.pop_back();
	redo_actions.push_back(action);
	last_was_add = false;
}
Esempio n. 2
0
void UndoStack::undo() throw (Exception)
{
    if ((!canUndo()) || (mCommandActive)) // if a command is active, undo() is not allowed
        return;

    mCommands[mCurrentIndex-1]->undo(); // throws an exception on error
    mCurrentIndex--;

    // emit signals
    emit undoTextChanged(getUndoText());
    emit redoTextChanged(getRedoText());
    emit canUndoChanged(canUndo());
    emit canRedoChanged(canRedo());
    emit cleanChanged(isClean());
}
void ShaderEditor::onGUIMenu()
{
	if(ImGui::BeginMenuBar())
	{
		if(ImGui::BeginMenu("File"))
		{
			if (ImGui::MenuItem("New")) newGraph();
			if (ImGui::MenuItem("Open")) load();
			if (ImGui::MenuItem("Save", nullptr, false, m_path.isValid())) save(m_path.c_str());
			if (ImGui::MenuItem("Save as"))
			{
				getSavePath();
				if (m_path.isValid()) save(m_path.c_str());
			}
			ImGui::EndMenu();
		}
		if (ImGui::BeginMenu("Edit"))
		{
			if (ImGui::MenuItem("Undo", nullptr, false, canUndo())) undo();
			if (ImGui::MenuItem("Redo", nullptr, false, canRedo())) redo();
			ImGui::EndMenu();
		}
		if (ImGui::MenuItem("Generate", nullptr, false, m_path.isValid()))
		{
			generate(m_path.c_str(), ShaderType::VERTEX);
			generate(m_path.c_str(), ShaderType::FRAGMENT);
			generateMain(m_path.c_str());
		}

		ImGui::EndMenuBar();
	}
}
Esempio n. 4
0
void EditorClientEfl::undo()
{
    if (canUndo()) {
        RefPtr<WebCore::UndoStep> step = undoStack.takeFirst();
        step->unapply();
    }
}
Esempio n. 5
0
//-----------------------------------------------------------------------------
// undoAction()
//-----------------------------------------------------------------------------
BOOL LLUndoBuffer::undoAction()
{
	if (!canUndo())
	{
		return FALSE;
	}

	S32 prevAction = (mNextAction + mNumActions - 1) % mNumActions;

	while(mActions[prevAction]->mClusterID == mOperationID)
	{
		// go ahead and decrement action index
		mNextAction = prevAction;

		// undo this action
		mActions[mNextAction]->undo();

		// we're at the first action, so we don't know if we've actually undid everything
		if (mNextAction == mFirstAction)
		{
			mOperationID--;
			return FALSE;
		}

		// do wrap-around of index, but avoid negative numbers for modulo operator
		prevAction = (mNextAction + mNumActions - 1) % mNumActions;
	}

	mOperationID--;

	return TRUE;
}
Esempio n. 6
0
void Task::undo()
{
  if (canUndo()) {
    (*_currentStep)->undo();
    _currentStep++;
  }
}
Esempio n. 7
0
long
GNEUndoList::p_onUpdUndo(FXObject* sender, FXSelector, void*) {
    bool enable = canUndo() && !hasCommandGroup();
    sender->handle(this, enable ? FXSEL(SEL_COMMAND, FXWindow::ID_ENABLE) : FXSEL(SEL_COMMAND, FXWindow::ID_DISABLE), 0);
    FXString caption = undoName();
    if (hasCommandGroup()) {
        caption = ("Cannot Undo in the middle of " + myCommandGroups.top()->getDescription()).c_str();
    } else if (!canUndo()) {
        caption = "Undo";
    }
    // only set caption on menu item
    if (dynamic_cast<FXMenuCommand*>(sender)) {
        sender->handle(this, FXSEL(SEL_COMMAND, FXMenuCaption::ID_SETSTRINGVALUE), (void*)&caption);
    }
    return 1;
}
Esempio n. 8
0
QString UndoStack::getUndoText() const noexcept
{
    if (canUndo())
        return QString(tr("Undo: %1")).arg(mCommands[mCurrentIndex-1]->getText());
    else
        return tr("Undo");
}
Esempio n. 9
0
void KUndo2QStack::setIndex(int idx, bool clean)
{
    bool was_clean = m_index == m_clean_index;
    if (m_lastMergedIndex <= idx) {
        m_lastMergedSetCount = idx - m_lastMergedIndex;

    } else {
        m_lastMergedSetCount = 1;
        m_lastMergedIndex = idx-1;
    }
    if(idx == 0){
        m_lastMergedSetCount = 0;
        m_lastMergedIndex = 0;
    }
    if (idx != m_index) {
        m_index = idx;
        emit indexChanged(m_index);
        emit canUndoChanged(canUndo());
        emit undoTextChanged(undoText());
        emit canRedoChanged(canRedo());
        emit redoTextChanged(redoText());
    }

    if (clean)
        m_clean_index = m_index;

    bool is_clean = m_index == m_clean_index;
    if (is_clean != was_clean)
        emit cleanChanged(is_clean);
}
Esempio n. 10
0
void Timeline::undo()
{
  if (canUndo()) {
    (*_currentTask)->undo();
    _currentTask++;
  }
}
Esempio n. 11
0
String ActionStack::undoName() const {
	if (canUndo()) {
		return _(" ") + capitalize(undo_actions.back()->getName(true));
	} else {
		return wxEmptyString;
	}
}
Esempio n. 12
0
void Board::setGravityFlag(bool b)
{
	if( gravity_flag != b ){
		if(canUndo() || canRedo())
			newGame();
		gravity_flag = b;
	}
}
Esempio n. 13
0
void GameMovesRegistry::clear()
{
    m_performedCmnds.clear();
    m_undoneCmnds.clear();

    emit countChanged(count());
    emit canRedoChanged(canRedo());
    emit canUndoChanged(canUndo());
}
Esempio n. 14
0
void GameMovesRegistry::failExecution()
{
    m_performedCmnds.clear();
    m_undoneCmnds.clear();

    emit canRedoChanged(canRedo());
    emit canUndoChanged(canUndo());
    emit executionFailed();
}
Esempio n. 15
0
void KDocumentTextBuffer::updateUndoRedoActions()
{
    emit canUndo(dynamic_cast<QInfinity::AdoptedSession*>(m_session)->canUndo(
        *dynamic_cast<QInfinity::AdoptedUser*>(m_user.data()))
    );
    emit canRedo(dynamic_cast<QInfinity::AdoptedSession*>(m_session)->canRedo(
        *dynamic_cast<QInfinity::AdoptedUser*>(m_user.data()))
    );
}
Esempio n. 16
0
void EditorClient::undo()
{
    if (canUndo()) {
        RefPtr<WebCore::EditCommand> command(*(--undoStack.end()));
        undoStack.remove(--undoStack.end());
        // unapply will call us back to push this command onto the redo stack.
        command->unapply();
    }
}
Esempio n. 17
0
void EditorClientImpl::undo()
{
    if (canUndo()) {
        UndoManagerStack::iterator back = --m_undoStack.end();
        RefPtr<UndoStep> step(*back);
        m_undoStack.remove(back);
        step->unapply();
        // unapply will call us back to push this command onto the redo stack.
    }
}
Esempio n. 18
0
void UndoStack::undo()
{
    if (canUndo()) {
        UndoStepStack::iterator back = --m_undoStack.end();
        RefPtr<UndoStep> step(back->get());
        m_undoStack.remove(back);
        step->unapply();
        // unapply will call us back to push this command onto the redo stack.
    }
}
Esempio n. 19
0
CommandAdd::~CommandAdd() {
  if (m_node_struct) {
    if (canUndo()) {
      m_node_struct->m_graphic_node = nullptr;
      m_node_struct->m_node = nullptr;
    }

    delete m_node_struct;
  }
}
void EditorClientImpl::undo()
{
    if (canUndo()) {
        EditCommandStack::iterator back = --m_undoStack.end();
        RefPtr<EditCommand> command(*back);
        m_undoStack.remove(back);
        command->unapply();
        // unapply will call us back to push this command onto the redo stack.
    }
}
void AbstractUndoableEdit::undo(void)
{
	if(canUndo())
	{
		_HasBeenDone = false;
	}
	else
	{
		throw CannotUndoException();
	}
}
Esempio n. 22
0
bool Recorder::redo()
{
    bool couldUndo = canUndo();
    bool couldRedo = canRedo();
    if(canRedo())
    {
        actions_.at(nextUndo_ + 1)->redo(model_);
        ++nextUndo_;
        if(couldUndo != canUndo())
        {
            emit undoChanged(canUndo());
        }
        if(couldRedo != canRedo())
        {
            emit redoChanged(canRedo());
        }
        return true;
    }
    return false;
}
Esempio n. 23
0
void EditorClientBlackBerry::undo()
{
    if (canUndo()) {
        EditCommandStack::iterator back = --m_undoStack.end();
        RefPtr<UndoStep> command(*back);
        m_undoStack.remove(back);

        // Unapply will call us back to push this command onto the redo stack.
        command->unapply();
    }
}
Esempio n. 24
0
QAction *KUndo2QStack::createUndoAction(QObject *parent) const
{
    KUndo2Action *result = new KUndo2Action(i18n("Undo %1"), i18nc("Default text for undo action", "Undo"), parent);
    result->setEnabled(canUndo());
    result->setPrefixedText(undoText());
    connect(this, SIGNAL(canUndoChanged(bool)),
            result, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(undoTextChanged(QString)),
            result, SLOT(setPrefixedText(QString)));
    connect(result, SIGNAL(triggered()), this, SLOT(undo()));
    return result;
}
Esempio n. 25
0
void Board::undo() {
  if(canUndo()) {
    undrawArrow();
    Move *m = _undo.take(_undo.count() - 1);
    setField(m->x1, m->y1, m->tile);
    setField(m->x2, m->y2, m->tile);
    updateField(m->x1, m->y1);
    updateField(m->x2, m->y2);
    _redo.insert(0, m);
    emit changed();
  }
}
Esempio n. 26
0
QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const
{
    QString pref = prefix.isEmpty() ? tr("Undo") : prefix;
    QUndoAction *result = new QUndoAction(pref, parent);
    result->setEnabled(canUndo());
    result->setPrefixedText(undoText());
    connect(this, SIGNAL(canUndoChanged(bool)),
            result, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(undoTextChanged(QString)),
            result, SLOT(setPrefixedText(QString)));
    connect(result, SIGNAL(triggered()), this, SLOT(undo()));
    return result;
}
Esempio n. 27
0
bool CMyPaintDoc::undo() {
  CHECKINVARIANT;
  bool done = false;
  if(canUndo()) {
    if(!canRedo()) {
      addImage();
      m_index = max(getHistorySize() - 1, 1);
    }
    setImage(m_history[--m_index]->clone(true));
    done = true;
  }
  CHECKINVARIANT;
  return done;
}
Esempio n. 28
0
void GameMovesRegistry::undo()
{
    if (!canUndo())
    {
        return;
    }

    qDebug() << "Undo";

    IMoveCommand::UPtr cmd = std::move(m_performedCmnds.back());
    m_performedCmnds.pop_back();
    m_undoneCmnds.push_back(std::move(cmd));
    if (!m_undoneCmnds.back()->undo(m_board))
    {
        failExecution();
        return;
    }

    emit newMoveDone();

    emit canRedoChanged(canRedo());
    emit canUndoChanged(canUndo());
}
Esempio n. 29
0
QAction *QUndoStack::createUndoAction(QObject *parent, const QString &prefix) const
{
    QUndoAction *result = new QUndoAction(prefix, parent);
    if (prefix.isEmpty())
        result->setTextFormat(tr("Undo %1"), tr("Undo", "Default text for undo action"));

    result->setEnabled(canUndo());
    result->setPrefixedText(undoText());
    connect(this, SIGNAL(canUndoChanged(bool)),
            result, SLOT(setEnabled(bool)));
    connect(this, SIGNAL(undoTextChanged(QString)),
            result, SLOT(setPrefixedText(QString)));
    connect(result, SIGNAL(triggered()), this, SLOT(undo()));
    return result;
}
Esempio n. 30
0
/* =============================================================================
 =============================================================================== */
void CWorld::undo()
{
	if (!canUndo())
		return;

	CEditStack	&Stack = g_Set.m_SessionPlayback ? getSessionStack() : getEditStack();
	bool		bLoop = (Stack.getCur().getGroup() == END_GROUP);
	bool		bEndLoop = false;
	do
	{
		bEndLoop = (Stack.getCur().getGroup() == START_GROUP);
		processEdit(Stack.getCur(), true);
		Stack.undo();
	} while(bLoop && !bEndLoop);
}