当前位置: 首页>>代码示例>>C++>>正文


C++ DocumentUndo类代码示例

本文整理汇总了C++中DocumentUndo的典型用法代码示例。如果您正苦于以下问题:C++ DocumentUndo类的具体用法?C++ DocumentUndo怎么用?C++ DocumentUndo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DocumentUndo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deselectMask

void DocumentApi::deselectMask()
{
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::SetMask(getObjects(),
        m_document));

  m_document->setMaskVisible(false);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:9,代码来源:document_api.cpp

示例2: ASSERT

void DocumentApi::setMaskPosition(int x, int y)
{
  ASSERT(m_document->getMask());

  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::SetMaskPosition(getObjects(), m_document));

  m_document->getMask()->setOrigin(x, y);
  m_document->resetTransformation();
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:11,代码来源:document_api.cpp

示例3: attachDocument

  void attachDocument(app::Document* document) {
    detachDocument();

    m_document = document;
    if (!document)
      return;

    DocumentUndo* history = m_document->undoHistory();
    history->addObserver(this);

    refillList(history);
  }
开发者ID:ripesunflower,项目名称:aseprite,代码行数:12,代码来源:cmd_undo_history.cpp

示例4: writer

void PaletteEntryEditor::updateCurrentSpritePalette(const char* operationName)
{
    if (UIContext::instance()->activeDocument() &&
            UIContext::instance()->activeDocument()->sprite()) {
        try {
            ContextWriter writer(UIContext::instance());
            Document* document(writer.document());
            Sprite* sprite(writer.sprite());
            Palette* newPalette = get_current_palette(); // System current pal
            frame_t frame = writer.frame();
            Palette* currentSpritePalette = sprite->palette(frame); // Sprite current pal
            int from, to;

            // Check differences between current sprite palette and current system palette
            from = to = -1;
            currentSpritePalette->countDiff(newPalette, &from, &to);

            if (from >= 0 && to >= from) {
                DocumentUndo* undo = document->undoHistory();
                Cmd* cmd = new cmd::SetPalette(sprite, frame, newPalette);

                // Add undo information to save the range of pal entries that will be modified.
                if (m_implantChange &&
                        undo->lastExecutedCmd() &&
                        undo->lastExecutedCmd()->label() == operationName) {
                    // Implant the cmd in the last CmdSequence if it's
                    // related about color palette modifications
                    ASSERT(dynamic_cast<CmdSequence*>(undo->lastExecutedCmd()));
                    static_cast<CmdSequence*>(undo->lastExecutedCmd())->add(cmd);
                    cmd->execute(UIContext::instance());
                }
                else {
                    Transaction transaction(writer.context(), operationName, ModifyDocument);
                    transaction.execute(cmd);
                    transaction.commit();
                }
            }
        }
        catch (base::Exception& e) {
            Console::showException(e);
        }
    }

    PaletteView* palette_editor = ColorBar::instance()->getPaletteView();
    palette_editor->invalidate();

    if (!m_redrawTimer.isRunning())
        m_redrawTimer.start();

    m_redrawAll = false;
    m_implantChange = true;
}
开发者ID:93i,项目名称:aseprite,代码行数:52,代码来源:cmd_palette_editor.cpp

示例5: configureLayerAsBackground

void DocumentApi::configureLayerAsBackground(LayerImage* layer)
{
  // Add undoers.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled()) {
    m_undoers->pushUndoer(new undoers::SetLayerFlags(getObjects(), layer));
    m_undoers->pushUndoer(new undoers::SetLayerName(getObjects(), layer));
    m_undoers->pushUndoer(new undoers::MoveLayer(getObjects(), layer));
  }

  // Do the action.
  layer->configureAsBackground();
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:13,代码来源:document_api.cpp

示例6: restackLayerAfter

void DocumentApi::restackLayerAfter(Layer* layer, Layer* afterThis)
{
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::MoveLayer(getObjects(), layer));

  layer->getParent()->stackLayer(layer, afterThis);

  DocumentEvent ev(m_document);
  ev.sprite(layer->getSprite());
  ev.layer(layer);
  m_document->notifyObservers<DocumentEvent&>(&DocumentObserver::onLayerRestacked, ev);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:13,代码来源:document_api.cpp

示例7: setConstantFrameRate

void DocumentApi::setConstantFrameRate(Sprite* sprite, int msecs)
{
  // Add undoers.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled()) {
    for (FrameNumber fr(0); fr<sprite->getTotalFrames(); ++fr)
      m_undoers->pushUndoer(new undoers::SetFrameDuration(
          getObjects(), sprite, fr));
  }

  // Do the action.
  sprite->setDurationForAllFrames(msecs);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:13,代码来源:document_api.cpp

示例8: flipImage

void DocumentApi::flipImage(Image* image,
                                const gfx::Rect& bounds,
                                raster::algorithm::FlipType flipType)
{
  // Insert the undo operation.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled()) {
    m_undoers->pushUndoer
      (new undoers::FlipImage
       (getObjects(), image, bounds, flipType));
  }

  // Flip the portion of the bitmap.
  raster::algorithm::flip_image(image, bounds, flipType);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:15,代码来源:document_api.cpp

示例9: setFrameDuration

void DocumentApi::setFrameDuration(Sprite* sprite, FrameNumber frame, int msecs)
{
  // Add undoers.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::SetFrameDuration(
        getObjects(), sprite, frame));

  // Do the action.
  sprite->setFrameDuration(frame, msecs);

  // Notify observers.
  DocumentEvent ev(m_document);
  ev.sprite(sprite);
  ev.frame(frame);
  m_document->notifyObservers<DocumentEvent&>(&DocumentObserver::onFrameDurationChanged, ev);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:17,代码来源:document_api.cpp

示例10: addLayer

void DocumentApi::addLayer(LayerFolder* folder, Layer* newLayer, Layer* afterThis)
{
  // Add undoers.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::AddLayer(getObjects(),
                                                m_document, newLayer));

  // Do the action.
  folder->addLayer(newLayer);
  folder->stackLayer(newLayer, afterThis);

  // Notify observers.
  DocumentEvent ev(m_document);
  ev.sprite(folder->getSprite());
  ev.layer(newLayer);
  m_document->notifyObservers<DocumentEvent&>(&DocumentObserver::onAddLayer, ev);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:18,代码来源:document_api.cpp

示例11: addFrameForLayer

void DocumentApi::addFrame(Sprite* sprite, FrameNumber newFrame)
{
  // Move cels, and create copies of the cels in the given "newFrame".
  addFrameForLayer(sprite->getFolder(), newFrame);

  // Add the frame in the sprite structure, it adjusts the total
  // number of frames in the sprite.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled())
    m_undoers->pushUndoer(new undoers::AddFrame(getObjects(), m_document, sprite, newFrame));

  sprite->addFrame(newFrame);

  // Notify observers about the new frame.
  DocumentEvent ev(m_document);
  ev.sprite(sprite);
  ev.frame(newFrame);
  m_document->notifyObservers<DocumentEvent&>(&DocumentObserver::onAddFrame, ev);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:19,代码来源:document_api.cpp

示例12: flippedImage

void DocumentApi::flipImageWithMask(Image* image, const Mask* mask, raster::algorithm::FlipType flipType, int bgcolor)
{
  UniquePtr<Image> flippedImage((Image::createCopy(image)));

  // Flip the portion of the bitmap.
  raster::algorithm::flip_image_with_mask(flippedImage, mask, flipType, bgcolor);

  // Insert the undo operation.
  DocumentUndo* undo = m_document->getUndo();
  if (undo->isEnabled()) {
    UniquePtr<Dirty> dirty((new Dirty(image, flippedImage)));
    dirty->saveImagePixels(image);

    m_undoers->pushUndoer(new undoers::DirtyArea(getObjects(), image, dirty));
  }

  // Copy the flipped image into the image specified as argument.
  image_copy(image, flippedImage, 0, 0);
}
开发者ID:RobertLowe,项目名称:aseprite,代码行数:19,代码来源:document_api.cpp

示例13: writer

void UndoCommand::onExecute(Context* context)
{
    ContextWriter writer(context);
    Document* document(writer.document());
    DocumentUndo* undo = document->getUndo();
    Sprite* sprite = document->sprite();

    if (context->settings()->undoGotoModified()) {
        SpritePosition spritePosition;
        SpritePosition currentPosition(writer.location()->layerIndex(),
                                       writer.location()->frame());

        if (m_type == Undo)
            spritePosition = undo->getNextUndoSpritePosition();
        else
            spritePosition = undo->getNextRedoSpritePosition();

        if (spritePosition != currentPosition) {
            current_editor->setLayer(sprite->indexToLayer(spritePosition.layerIndex()));
            current_editor->setFrame(spritePosition.frameNumber());

            // Draw the current layer/frame (which is not undone yet) so the
            // user can see the doUndo/doRedo effect.
            current_editor->drawSpriteClipped(
                gfx::Region(gfx::Rect(0, 0, sprite->width(), sprite->height())));

            ui::dirty_display_flag = true;
            gui_feedback();

            base::this_thread::sleep_for(0.01);
        }
    }

    StatusBar::instance()
    ->showTip(1000, "%s %s",
              (m_type == Undo ? "Undid": "Redid"),
              (m_type == Undo ? undo->getNextUndoLabel():
               undo->getNextRedoLabel()));

    // Effectively undo/redo.
    if (m_type == Undo)
        undo->doUndo();
    else
        undo->doRedo();

    document->generateMaskBoundaries();
    document->destroyExtraCel(); // Regenerate extras

    update_screen_for_document(document);
    set_current_palette(writer.palette(), false);
}
开发者ID:Julien-B,项目名称:aseprite,代码行数:51,代码来源:cmd_undo.cpp

示例14: document

void UndoCommand::onExecute(Context* context)
{
  ActiveDocumentWriter document(context);
  DocumentUndo* undo = document->getUndo();
  Sprite* sprite = document->getSprite();

  if (get_config_bool("Options", "UndoGotoModified", true)) {
    SpritePosition spritePosition;

    if (m_type == Undo)
      spritePosition = undo->getNextUndoSpritePosition();
    else
      spritePosition = undo->getNextRedoSpritePosition();

    if (spritePosition != sprite->getCurrentPosition()) {
      sprite->setCurrentPosition(spritePosition);

      current_editor->drawSpriteSafe(0, 0, sprite->getWidth(), sprite->getHeight());
      update_screen_for_document(document);

      ui::dirty_display_flag = true;
      gui_feedback();

      base::this_thread::sleep_for(0.01);
    }
  }

  StatusBar::instance()
    ->showTip(1000, "%s %s",
              (m_type == Undo ? "Undid": "Redid"),
              (m_type == Undo ? undo->getNextUndoLabel():
                                undo->getNextRedoLabel()));

  if (m_type == Undo)
    undo->doUndo();
  else
    undo->doRedo();

  document->generateMaskBoundaries();
  document->destroyExtraCel(); // Regenerate extras

  update_screen_for_document(document);
}
开发者ID:eledot,项目名称:aseprite,代码行数:43,代码来源:cmd_undo.cpp

示例15: writer

void UndoCommand::onExecute(Context* context)
{
  ContextWriter writer(context);
  Document* document(writer.document());
  DocumentUndo* undo = document->undoHistory();
  Sprite* sprite = document->sprite();
  SpritePosition spritePosition;
  const bool gotoModified =
    Preferences::instance().undo.gotoModified();

  if (gotoModified) {
    SpritePosition currentPosition(writer.site()->layerIndex(),
                                   writer.site()->frame());

    if (m_type == Undo)
      spritePosition = undo->nextUndoSpritePosition();
    else
      spritePosition = undo->nextRedoSpritePosition();

    if (spritePosition != currentPosition) {
      current_editor->setLayer(sprite->indexToLayer(spritePosition.layerIndex()));
      current_editor->setFrame(spritePosition.frame());

      // Draw the current layer/frame (which is not undone yet) so the
      // user can see the doUndo/doRedo effect.
      current_editor->drawSpriteClipped(
        gfx::Region(gfx::Rect(0, 0, sprite->width(), sprite->height())));

      current_editor->manager()->flipDisplay();
      base::this_thread::sleep_for(0.01);
    }
  }

  StatusBar* statusbar = StatusBar::instance();
  if (statusbar)
    statusbar->showTip(1000, "%s %s",
      (m_type == Undo ? "Undid": "Redid"),
      (m_type == Undo ?
        undo->nextUndoLabel().c_str():
        undo->nextRedoLabel().c_str()));

  // Effectively undo/redo.
  if (m_type == Undo)
    undo->undo();
  else
    undo->redo();

  // After redo/undo, we retry to change the current SpritePosition
  // (because new frames/layers could be added, positions that we
  // weren't able to reach before the undo).
  if (gotoModified) {
    SpritePosition currentPosition(
      writer.site()->layerIndex(),
      writer.site()->frame());

    if (spritePosition != currentPosition) {
      current_editor->setLayer(sprite->indexToLayer(spritePosition.layerIndex()));
      current_editor->setFrame(spritePosition.frame());
    }
  }

  document->generateMaskBoundaries();
  document->setExtraCel(ExtraCelRef(nullptr));

  update_screen_for_document(document);
  set_current_palette(writer.palette(), false);
}
开发者ID:4144,项目名称:aseprite,代码行数:67,代码来源:cmd_undo.cpp


注:本文中的DocumentUndo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。