Minor refactor using cmds directly instead of DocApi in Layer/Background from Background/Layer

This commit is contained in:
David Capello 2020-06-08 14:44:47 -03:00
parent f2bc864fc9
commit aa1943e609
4 changed files with 8 additions and 23 deletions

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -8,12 +9,11 @@
#include "config.h"
#endif
#include "app/cmd/background_from_layer.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "doc/layer.h"
#include "doc/sprite.h"
@ -52,9 +52,8 @@ void BackgroundFromLayerCommand::onExecute(Context* context)
Doc* document(writer.document());
{
Tx tx(writer.context(), "Background from Layer");
document->getApi(tx).backgroundFromLayer(
static_cast<LayerImage*>(writer.layer()));
Tx tx(writer.context(), friendlyName());
tx(new cmd::BackgroundFromLayer(static_cast<LayerImage*>(writer.layer())));
tx.commit();
}

View File

@ -1,4 +1,5 @@
// Aseprite
// Copyright (C) 2020 Igara Studio S.A.
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
@ -8,14 +9,13 @@
#include "config.h"
#endif
#include "app/cmd/layer_from_background.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/tx.h"
#include "doc/layer.h"
#include "doc/sprite.h"
#include "ui/ui.h"
namespace app {
@ -51,8 +51,8 @@ void LayerFromBackgroundCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
{
Tx tx(writer.context(), "Layer from Background");
document->getApi(tx).layerFromBackground(writer.layer());
Tx tx(writer.context(), friendlyName());
tx(new cmd::LayerFromBackground(writer.layer()));
tx.commit();
}
#ifdef ENABLE_UI

View File

@ -14,13 +14,11 @@
#include "app/cmd/add_cel.h"
#include "app/cmd/add_frame.h"
#include "app/cmd/add_layer.h"
#include "app/cmd/background_from_layer.h"
#include "app/cmd/clear_cel.h"
#include "app/cmd/clear_image.h"
#include "app/cmd/copy_cel.h"
#include "app/cmd/copy_frame.h"
#include "app/cmd/flip_image.h"
#include "app/cmd/layer_from_background.h"
#include "app/cmd/move_cel.h"
#include "app/cmd/move_layer.h"
#include "app/cmd/remove_cel.h"
@ -677,16 +675,6 @@ void DocApi::restackLayerBefore(Layer* layer, LayerGroup* parent, Layer* beforeT
restackLayerAfter(layer, parent, afterThis);
}
void DocApi::backgroundFromLayer(Layer* layer)
{
m_transaction.execute(new cmd::BackgroundFromLayer(layer));
}
void DocApi::layerFromBackground(Layer* layer)
{
m_transaction.execute(new cmd::LayerFromBackground(layer));
}
Layer* DocApi::duplicateLayerAfter(Layer* sourceLayer, LayerGroup* parent, Layer* afterLayer)
{
ASSERT(parent);

View File

@ -97,8 +97,6 @@ namespace app {
void removeLayer(Layer* layer);
void restackLayerAfter(Layer* layer, LayerGroup* parent, Layer* afterThis);
void restackLayerBefore(Layer* layer, LayerGroup* parent, Layer* beforeThis);
void backgroundFromLayer(Layer* layer);
void layerFromBackground(Layer* layer);
Layer* duplicateLayerAfter(Layer* sourceLayer, LayerGroup* parent, Layer* afterLayer);
Layer* duplicateLayerBefore(Layer* sourceLayer, LayerGroup* parent, Layer* beforeLayer);