diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt index 36b74efa8..a5064511e 100644 --- a/src/app/CMakeLists.txt +++ b/src/app/CMakeLists.txt @@ -496,9 +496,9 @@ add_library(app-lib console.cpp context.cpp context_flags.cpp + doc_api.cpp doc_undo.cpp document.cpp - document_api.cpp document_diff.cpp document_exporter.cpp document_range.cpp diff --git a/src/app/commands/cmd_background_from_layer.cpp b/src/app/commands/cmd_background_from_layer.cpp index 5af76ba5b..d5b0d2092 100644 --- a/src/app/commands/cmd_background_from_layer.cpp +++ b/src/app/commands/cmd_background_from_layer.cpp @@ -10,7 +10,7 @@ #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "app/ui/color_bar.h" diff --git a/src/app/commands/cmd_canvas_size.cpp b/src/app/commands/cmd_canvas_size.cpp index ee9a66c76..4169fb893 100644 --- a/src/app/commands/cmd_canvas_size.cpp +++ b/src/app/commands/cmd_canvas_size.cpp @@ -10,7 +10,7 @@ #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/editors.h" #include "app/modules/gui.h" #include "app/transaction.h" @@ -333,7 +333,7 @@ void CanvasSizeCommand::onExecute(Context* context) Document* document = writer.document(); Sprite* sprite = writer.sprite(); Transaction transaction(writer.context(), "Canvas Size"); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); api.cropSprite(sprite, gfx::Rect(x1, y1, diff --git a/src/app/commands/cmd_cel_properties.cpp b/src/app/commands/cmd_cel_properties.cpp index e1874548b..7adc5c817 100644 --- a/src/app/commands/cmd_cel_properties.cpp +++ b/src/app/commands/cmd_cel_properties.cpp @@ -15,7 +15,6 @@ #include "app/console.h" #include "app/context_access.h" #include "app/doc_event.h" -#include "app/document_api.h" #include "app/document_range.h" #include "app/modules/gui.h" #include "app/transaction.h" diff --git a/src/app/commands/cmd_clear_cel.cpp b/src/app/commands/cmd_clear_cel.cpp index 8101ab2e2..05c1cbed0 100644 --- a/src/app/commands/cmd_clear_cel.cpp +++ b/src/app/commands/cmd_clear_cel.cpp @@ -11,7 +11,7 @@ #include "app/app.h" #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "app/ui/status_bar.h" diff --git a/src/app/commands/cmd_crop.cpp b/src/app/commands/cmd_crop.cpp index 075804189..57dfe26cb 100644 --- a/src/app/commands/cmd_crop.cpp +++ b/src/app/commands/cmd_crop.cpp @@ -10,7 +10,7 @@ #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "app/ui/color_bar.h" diff --git a/src/app/commands/cmd_duplicate_layer.cpp b/src/app/commands/cmd_duplicate_layer.cpp index 27fb070fc..3598a3525 100644 --- a/src/app/commands/cmd_duplicate_layer.cpp +++ b/src/app/commands/cmd_duplicate_layer.cpp @@ -13,7 +13,7 @@ #include "app/console.h" #include "app/context_access.h" #include "app/doc_undo.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/editors.h" #include "app/modules/gui.h" #include "app/transaction.h" @@ -53,7 +53,7 @@ void DuplicateLayerCommand::onExecute(Context* context) { Transaction transaction(writer.context(), "Layer Duplication"); LayerImage* sourceLayer = static_cast(writer.layer()); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); api.duplicateLayerAfter(sourceLayer, sourceLayer->parent(), sourceLayer); diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp index 6f4fde275..88ab6cb83 100644 --- a/src/app/commands/cmd_flip.cpp +++ b/src/app/commands/cmd_flip.cpp @@ -18,7 +18,7 @@ #include "app/cmd/trim_cel.h" #include "app/commands/params.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/i18n/strings.h" #include "app/modules/gui.h" @@ -69,7 +69,7 @@ void FlipCommand::onExecute(Context* context) { Transaction transaction(writer.context(), friendlyName()); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); Timeline* timeline = App::instance()->timeline(); LockTimelineRange lockRange(timeline); diff --git a/src/app/commands/cmd_frame_properties.cpp b/src/app/commands/cmd_frame_properties.cpp index 90681b3a8..eaee1bcb7 100644 --- a/src/app/commands/cmd_frame_properties.cpp +++ b/src/app/commands/cmd_frame_properties.cpp @@ -13,7 +13,7 @@ #include "app/commands/params.h" #include "app/context.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/pref/preferences.h" #include "app/transaction.h" #include "base/convert_to.h" @@ -129,7 +129,7 @@ void FramePropertiesCommand::onExecute(Context* context) ContextWriter writer(reader); Transaction transaction(writer.context(), "Frame Duration"); - DocumentApi api = writer.document()->getApi(transaction); + DocApi api = writer.document()->getApi(transaction); for (frame_t frame : selFrames) api.setFrameDuration(writer.sprite(), frame, newMsecs); diff --git a/src/app/commands/cmd_import_sprite_sheet.cpp b/src/app/commands/cmd_import_sprite_sheet.cpp index a97d89ffa..5e0c2bcfe 100644 --- a/src/app/commands/cmd_import_sprite_sheet.cpp +++ b/src/app/commands/cmd_import_sprite_sheet.cpp @@ -15,7 +15,7 @@ #include "app/context.h" #include "app/context_access.h" #include "app/document_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/i18n/strings.h" #include "app/modules/editors.h" #include "app/modules/gui.h" @@ -386,7 +386,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context) // operations in a undo-transaction. ContextWriter writer(context); Transaction transaction(writer.context(), "Import Sprite Sheet", ModifyDocument); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); // Add the layer in the sprite. LayerImage* resultLayer = api.newLayer(sprite->root(), "Sprite Sheet"); diff --git a/src/app/commands/cmd_layer_from_background.cpp b/src/app/commands/cmd_layer_from_background.cpp index 2f81cd440..37b8d00d0 100644 --- a/src/app/commands/cmd_layer_from_background.cpp +++ b/src/app/commands/cmd_layer_from_background.cpp @@ -10,7 +10,7 @@ #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "doc/layer.h" diff --git a/src/app/commands/cmd_merge_down_layer.cpp b/src/app/commands/cmd_merge_down_layer.cpp index e4226a106..2a70031f1 100644 --- a/src/app/commands/cmd_merge_down_layer.cpp +++ b/src/app/commands/cmd_merge_down_layer.cpp @@ -15,8 +15,8 @@ #include "app/cmd/unlink_cel.h" #include "app/commands/command.h" #include "app/context_access.h" +#include "app/doc_api.h" #include "app/document.h" -#include "app/document_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "base/unique_ptr.h" diff --git a/src/app/commands/cmd_move_mask.cpp b/src/app/commands/cmd_move_mask.cpp index 63421e609..8da4a8cd2 100644 --- a/src/app/commands/cmd_move_mask.cpp +++ b/src/app/commands/cmd_move_mask.cpp @@ -14,7 +14,7 @@ #include "app/commands/command.h" #include "app/commands/params.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/i18n/strings.h" #include "app/modules/editors.h" #include "app/modules/gui.h" diff --git a/src/app/commands/cmd_new_frame.cpp b/src/app/commands/cmd_new_frame.cpp index 898d986a9..284548305 100644 --- a/src/app/commands/cmd_new_frame.cpp +++ b/src/app/commands/cmd_new_frame.cpp @@ -14,7 +14,7 @@ #include "app/commands/params.h" #include "app/console.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/i18n/strings.h" #include "app/modules/gui.h" #include "app/transaction.h" @@ -91,7 +91,7 @@ void NewFrameCommand::onExecute(Context* context) Sprite* sprite(writer.sprite()); { Transaction transaction(writer.context(), friendlyName()); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); switch (m_content) { diff --git a/src/app/commands/cmd_new_layer.cpp b/src/app/commands/cmd_new_layer.cpp index 92a4a335e..2e1f9c4fc 100644 --- a/src/app/commands/cmd_new_layer.cpp +++ b/src/app/commands/cmd_new_layer.cpp @@ -14,7 +14,7 @@ #include "app/commands/commands.h" #include "app/commands/params.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/find_widget.h" #include "app/load_widget.h" #include "app/modules/gui.h" @@ -180,7 +180,7 @@ void NewLayerCommand::onExecute(Context* context) Transaction transaction( writer.context(), std::string("New ") + layerPrefix()); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); bool afterBackground = false; switch (m_type) { diff --git a/src/app/commands/cmd_remove_frame.cpp b/src/app/commands/cmd_remove_frame.cpp index 9cbaaf580..1462aa886 100644 --- a/src/app/commands/cmd_remove_frame.cpp +++ b/src/app/commands/cmd_remove_frame.cpp @@ -11,7 +11,7 @@ #include "app/app.h" #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "doc/sprite.h" @@ -50,7 +50,7 @@ void RemoveFrameCommand::onExecute(Context* context) Sprite* sprite(writer.sprite()); { Transaction transaction(writer.context(), "Remove Frame"); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); const Site* site = writer.site(); if (site->inTimeline() && !site->selectedFrames().empty()) { diff --git a/src/app/commands/cmd_remove_layer.cpp b/src/app/commands/cmd_remove_layer.cpp index 4276cf452..c9b92cfaa 100644 --- a/src/app/commands/cmd_remove_layer.cpp +++ b/src/app/commands/cmd_remove_layer.cpp @@ -11,7 +11,7 @@ #include "app/app.h" #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/i18n/strings.h" #include "app/modules/gui.h" #include "app/transaction.h" @@ -53,7 +53,7 @@ void RemoveLayerCommand::onExecute(Context* context) Sprite* sprite(writer.sprite()); { Transaction transaction(writer.context(), "Remove Layer"); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); const Site* site = writer.site(); if (site->inTimeline() && diff --git a/src/app/commands/cmd_remove_slice.cpp b/src/app/commands/cmd_remove_slice.cpp index 18f5fbb16..455584cec 100644 --- a/src/app/commands/cmd_remove_slice.cpp +++ b/src/app/commands/cmd_remove_slice.cpp @@ -13,7 +13,6 @@ #include "app/cmd/set_slice_key.h" #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" #include "app/modules/gui.h" #include "app/ui/status_bar.h" #include "app/transaction.h" diff --git a/src/app/commands/cmd_rotate.cpp b/src/app/commands/cmd_rotate.cpp index a8906e79f..d79b5338a 100644 --- a/src/app/commands/cmd_rotate.cpp +++ b/src/app/commands/cmd_rotate.cpp @@ -13,7 +13,7 @@ #include "app/commands/cmd_rotate.h" #include "app/commands/params.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/i18n/strings.h" #include "app/modules/editors.h" @@ -79,7 +79,7 @@ protected: // [working thread] void onJob() override { - DocumentApi api = document()->getApi(transaction()); + DocApi api = document()->getApi(transaction()); // 1) Rotate cel positions for (Cel* cel : m_cels) { diff --git a/src/app/commands/cmd_set_palette.cpp b/src/app/commands/cmd_set_palette.cpp index 1679dab05..90dc4e2dc 100644 --- a/src/app/commands/cmd_set_palette.cpp +++ b/src/app/commands/cmd_set_palette.cpp @@ -10,7 +10,7 @@ #include "app/commands/cmd_set_palette.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/file_selector.h" #include "app/ini_file.h" #include "app/modules/palettes.h" diff --git a/src/app/commands/cmd_sprite_properties.cpp b/src/app/commands/cmd_sprite_properties.cpp index 95571cfe9..10fa2343e 100644 --- a/src/app/commands/cmd_sprite_properties.cpp +++ b/src/app/commands/cmd_sprite_properties.cpp @@ -12,7 +12,7 @@ #include "app/color.h" #include "app/commands/command.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/transaction.h" #include "app/ui/color_button.h" @@ -137,7 +137,7 @@ void SpritePropertiesCommand::onExecute(Context* context) if (index != sprite->transparentColor() || pixelRatio != sprite->pixelRatio()) { Transaction transaction(writer.context(), "Change Sprite Properties"); - DocumentApi api = writer.document()->getApi(transaction); + DocApi api = writer.document()->getApi(transaction); if (index != sprite->transparentColor()) api.setSpriteTransparentColor(sprite, index); diff --git a/src/app/commands/cmd_sprite_size.cpp b/src/app/commands/cmd_sprite_size.cpp index d70fb109c..55fe02e04 100644 --- a/src/app/commands/cmd_sprite_size.cpp +++ b/src/app/commands/cmd_sprite_size.cpp @@ -13,7 +13,7 @@ #include "app/commands/cmd_sprite_size.h" #include "app/commands/command.h" #include "app/commands/params.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/ini_file.h" #include "app/modules/gui.h" #include "app/modules/palettes.h" @@ -73,7 +73,7 @@ protected: // [working thread] void onJob() override { - DocumentApi api = writer().document()->getApi(transaction()); + DocApi api = writer().document()->getApi(transaction()); int cels_count = 0; for (Cel* cel : sprite()->uniqueCels()) { // TODO add size() member function to CelsRange diff --git a/src/app/document_api.cpp b/src/app/doc_api.cpp similarity index 85% rename from src/app/document_api.cpp rename to src/app/doc_api.cpp index 97e6b5b1a..f082803ff 100644 --- a/src/app/document_api.cpp +++ b/src/app/doc_api.cpp @@ -8,7 +8,7 @@ #include "config.h" #endif -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/cmd/add_cel.h" #include "app/cmd/add_frame.h" @@ -63,23 +63,23 @@ namespace app { -DocumentApi::DocumentApi(Document* document, Transaction& transaction) +DocApi::DocApi(Document* document, Transaction& transaction) : m_document(document) , m_transaction(transaction) { } -void DocumentApi::setSpriteSize(Sprite* sprite, int w, int h) +void DocApi::setSpriteSize(Sprite* sprite, int w, int h) { m_transaction.execute(new cmd::SetSpriteSize(sprite, w, h)); } -void DocumentApi::setSpriteTransparentColor(Sprite* sprite, color_t maskColor) +void DocApi::setSpriteTransparentColor(Sprite* sprite, color_t maskColor) { m_transaction.execute(new cmd::SetTransparentColor(sprite, maskColor)); } -void DocumentApi::cropSprite(Sprite* sprite, const gfx::Rect& bounds) +void DocApi::cropSprite(Sprite* sprite, const gfx::Rect& bounds) { setSpriteSize(sprite, bounds.w, bounds.h); @@ -157,7 +157,7 @@ void DocumentApi::cropSprite(Sprite* sprite, const gfx::Rect& bounds) } } -void DocumentApi::trimSprite(Sprite* sprite) +void DocApi::trimSprite(Sprite* sprite) { gfx::Rect bounds; @@ -181,14 +181,14 @@ void DocumentApi::trimSprite(Sprite* sprite) cropSprite(sprite, bounds); } -void DocumentApi::addFrame(Sprite* sprite, frame_t newFrame) +void DocApi::addFrame(Sprite* sprite, frame_t newFrame) { copyFrame(sprite, newFrame-1, newFrame, kDropBeforeFrame, kDefaultTagsAdjustment); } -void DocumentApi::addEmptyFrame(Sprite* sprite, frame_t newFrame) +void DocApi::addEmptyFrame(Sprite* sprite, frame_t newFrame) { m_transaction.execute(new cmd::AddFrame(sprite, newFrame)); adjustFrameTags(sprite, newFrame, +1, @@ -196,13 +196,13 @@ void DocumentApi::addEmptyFrame(Sprite* sprite, frame_t newFrame) kDefaultTagsAdjustment); } -void DocumentApi::addEmptyFramesTo(Sprite* sprite, frame_t newFrame) +void DocApi::addEmptyFramesTo(Sprite* sprite, frame_t newFrame) { while (sprite->totalFrames() <= newFrame) addEmptyFrame(sprite, sprite->totalFrames()); } -void DocumentApi::copyFrame(Sprite* sprite, +void DocApi::copyFrame(Sprite* sprite, const frame_t fromFrame, const frame_t newFrame, const DropFramePlace dropFramePlace, @@ -220,7 +220,7 @@ void DocumentApi::copyFrame(Sprite* sprite, tagsHandling); } -void DocumentApi::removeFrame(Sprite* sprite, frame_t frame) +void DocApi::removeFrame(Sprite* sprite, frame_t frame) { ASSERT(frame >= 0); m_transaction.execute(new cmd::RemoveFrame(sprite, frame)); @@ -229,18 +229,18 @@ void DocumentApi::removeFrame(Sprite* sprite, frame_t frame) kDefaultTagsAdjustment); } -void DocumentApi::setTotalFrames(Sprite* sprite, frame_t frames) +void DocApi::setTotalFrames(Sprite* sprite, frame_t frames) { ASSERT(frames >= 1); m_transaction.execute(new cmd::SetTotalFrames(sprite, frames)); } -void DocumentApi::setFrameDuration(Sprite* sprite, frame_t frame, int msecs) +void DocApi::setFrameDuration(Sprite* sprite, frame_t frame, int msecs) { m_transaction.execute(new cmd::SetFrameDuration(sprite, frame, msecs)); } -void DocumentApi::setFrameRangeDuration(Sprite* sprite, frame_t from, frame_t to, int msecs) +void DocApi::setFrameRangeDuration(Sprite* sprite, frame_t from, frame_t to, int msecs) { ASSERT(from >= frame_t(0)); ASSERT(from < to); @@ -250,7 +250,7 @@ void DocumentApi::setFrameRangeDuration(Sprite* sprite, frame_t from, frame_t to m_transaction.execute(new cmd::SetFrameDuration(sprite, fr, msecs)); } -void DocumentApi::moveFrame(Sprite* sprite, +void DocApi::moveFrame(Sprite* sprite, const frame_t frame, frame_t targetFrame, const DropFramePlace dropFramePlace, @@ -293,7 +293,7 @@ void DocumentApi::moveFrame(Sprite* sprite, } } -void DocumentApi::moveFrameLayer(Layer* layer, frame_t frame, frame_t beforeFrame) +void DocApi::moveFrameLayer(Layer* layer, frame_t frame, frame_t beforeFrame) { ASSERT(layer); @@ -349,7 +349,7 @@ void DocumentApi::moveFrameLayer(Layer* layer, frame_t frame, frame_t beforeFram } } -void DocumentApi::addCel(LayerImage* layer, Cel* cel) +void DocApi::addCel(LayerImage* layer, Cel* cel) { ASSERT(layer); ASSERT(cel); @@ -357,7 +357,7 @@ void DocumentApi::addCel(LayerImage* layer, Cel* cel) m_transaction.execute(new cmd::AddCel(layer, cel)); } -void DocumentApi::setCelFramePosition(Cel* cel, frame_t frame) +void DocApi::setCelFramePosition(Cel* cel, frame_t frame) { ASSERT(cel); ASSERT(frame >= 0); @@ -365,14 +365,14 @@ void DocumentApi::setCelFramePosition(Cel* cel, frame_t frame) m_transaction.execute(new cmd::SetCelFrame(cel, frame)); } -void DocumentApi::setCelPosition(Sprite* sprite, Cel* cel, int x, int y) +void DocApi::setCelPosition(Sprite* sprite, Cel* cel, int x, int y) { ASSERT(cel); m_transaction.execute(new cmd::SetCelPosition(cel, x, y)); } -void DocumentApi::setCelOpacity(Sprite* sprite, Cel* cel, int newOpacity) +void DocApi::setCelOpacity(Sprite* sprite, Cel* cel, int newOpacity) { ASSERT(cel); ASSERT(sprite->supportAlpha()); @@ -380,19 +380,19 @@ void DocumentApi::setCelOpacity(Sprite* sprite, Cel* cel, int newOpacity) m_transaction.execute(new cmd::SetCelOpacity(cel, newOpacity)); } -void DocumentApi::clearCel(LayerImage* layer, frame_t frame) +void DocApi::clearCel(LayerImage* layer, frame_t frame) { if (Cel* cel = layer->cel(frame)) clearCel(cel); } -void DocumentApi::clearCel(Cel* cel) +void DocApi::clearCel(Cel* cel) { ASSERT(cel); m_transaction.execute(new cmd::ClearCel(cel)); } -void DocumentApi::moveCel( +void DocApi::moveCel( LayerImage* srcLayer, frame_t srcFrame, LayerImage* dstLayer, frame_t dstFrame) { @@ -402,7 +402,7 @@ void DocumentApi::moveCel( dstLayer, dstFrame, dstLayer->isContinuous())); } -void DocumentApi::copyCel( +void DocApi::copyCel( LayerImage* srcLayer, frame_t srcFrame, LayerImage* dstLayer, frame_t dstFrame) { @@ -411,7 +411,7 @@ void DocumentApi::copyCel( dstLayer, dstFrame, dstLayer->isContinuous()); } -void DocumentApi::copyCel( +void DocApi::copyCel( LayerImage* srcLayer, frame_t srcFrame, LayerImage* dstLayer, frame_t dstFrame, bool continuous) { @@ -426,7 +426,7 @@ void DocumentApi::copyCel( dstLayer, dstFrame, continuous)); } -void DocumentApi::swapCel( +void DocApi::swapCel( LayerImage* layer, frame_t frame1, frame_t frame2) { ASSERT(frame1 != frame2); @@ -444,7 +444,7 @@ void DocumentApi::swapCel( if (cel2) setCelFramePosition(cel2, frame1); } -LayerImage* DocumentApi::newLayer(LayerGroup* parent, const std::string& name) +LayerImage* DocApi::newLayer(LayerGroup* parent, const std::string& name) { LayerImage* layer = new LayerImage(parent->sprite()); layer->setName(name); @@ -453,7 +453,7 @@ LayerImage* DocumentApi::newLayer(LayerGroup* parent, const std::string& name) return layer; } -LayerGroup* DocumentApi::newGroup(LayerGroup* parent, const std::string& name) +LayerGroup* DocApi::newGroup(LayerGroup* parent, const std::string& name) { LayerGroup* layer = new LayerGroup(parent->sprite()); layer->setName(name); @@ -462,19 +462,19 @@ LayerGroup* DocumentApi::newGroup(LayerGroup* parent, const std::string& name) return layer; } -void DocumentApi::addLayer(LayerGroup* parent, Layer* newLayer, Layer* afterThis) +void DocApi::addLayer(LayerGroup* parent, Layer* newLayer, Layer* afterThis) { m_transaction.execute(new cmd::AddLayer(parent, newLayer, afterThis)); } -void DocumentApi::removeLayer(Layer* layer) +void DocApi::removeLayer(Layer* layer) { ASSERT(layer); m_transaction.execute(new cmd::RemoveLayer(layer)); } -void DocumentApi::restackLayerAfter(Layer* layer, LayerGroup* parent, Layer* afterThis) +void DocApi::restackLayerAfter(Layer* layer, LayerGroup* parent, Layer* afterThis) { ASSERT(parent); @@ -484,7 +484,7 @@ void DocumentApi::restackLayerAfter(Layer* layer, LayerGroup* parent, Layer* aft m_transaction.execute(new cmd::MoveLayer(layer, parent, afterThis)); } -void DocumentApi::restackLayerBefore(Layer* layer, LayerGroup* parent, Layer* beforeThis) +void DocApi::restackLayerBefore(Layer* layer, LayerGroup* parent, Layer* beforeThis) { ASSERT(parent); @@ -500,17 +500,17 @@ void DocumentApi::restackLayerBefore(Layer* layer, LayerGroup* parent, Layer* be restackLayerAfter(layer, parent, afterThis); } -void DocumentApi::backgroundFromLayer(Layer* layer) +void DocApi::backgroundFromLayer(Layer* layer) { m_transaction.execute(new cmd::BackgroundFromLayer(layer)); } -void DocumentApi::layerFromBackground(Layer* layer) +void DocApi::layerFromBackground(Layer* layer) { m_transaction.execute(new cmd::LayerFromBackground(layer)); } -Layer* DocumentApi::duplicateLayerAfter(Layer* sourceLayer, LayerGroup* parent, Layer* afterLayer) +Layer* DocApi::duplicateLayerAfter(Layer* sourceLayer, LayerGroup* parent, Layer* afterLayer) { ASSERT(parent); base::UniquePtr newLayerPtr; @@ -532,7 +532,7 @@ Layer* DocumentApi::duplicateLayerAfter(Layer* sourceLayer, LayerGroup* parent, return newLayerPtr.release(); } -Layer* DocumentApi::duplicateLayerBefore(Layer* sourceLayer, LayerGroup* parent, Layer* beforeLayer) +Layer* DocApi::duplicateLayerBefore(Layer* sourceLayer, LayerGroup* parent, Layer* beforeLayer) { ASSERT(parent); Layer* afterThis = (beforeLayer ? beforeLayer->getPreviousBrowsable(): nullptr); @@ -542,7 +542,7 @@ Layer* DocumentApi::duplicateLayerBefore(Layer* sourceLayer, LayerGroup* parent, return newLayer; } -Cel* DocumentApi::addCel(LayerImage* layer, frame_t frameNumber, const ImageRef& image) +Cel* DocApi::addCel(LayerImage* layer, frame_t frameNumber, const ImageRef& image) { ASSERT(layer->cel(frameNumber) == NULL); @@ -552,7 +552,7 @@ Cel* DocumentApi::addCel(LayerImage* layer, frame_t frameNumber, const ImageRef& return cel.release(); } -void DocumentApi::replaceImage(Sprite* sprite, const ImageRef& oldImage, const ImageRef& newImage) +void DocApi::replaceImage(Sprite* sprite, const ImageRef& oldImage, const ImageRef& newImage) { ASSERT(oldImage); ASSERT(newImage); @@ -562,13 +562,13 @@ void DocumentApi::replaceImage(Sprite* sprite, const ImageRef& oldImage, const I sprite, oldImage, newImage)); } -void DocumentApi::flipImage(Image* image, const gfx::Rect& bounds, +void DocApi::flipImage(Image* image, const gfx::Rect& bounds, doc::algorithm::FlipType flipType) { m_transaction.execute(new cmd::FlipImage(image, bounds, flipType)); } -void DocumentApi::copyToCurrentMask(Mask* mask) +void DocApi::copyToCurrentMask(Mask* mask) { ASSERT(m_document->mask()); ASSERT(mask); @@ -576,14 +576,14 @@ void DocumentApi::copyToCurrentMask(Mask* mask) m_transaction.execute(new cmd::SetMask(m_document, mask)); } -void DocumentApi::setMaskPosition(int x, int y) +void DocApi::setMaskPosition(int x, int y) { ASSERT(m_document->mask()); m_transaction.execute(new cmd::SetMaskPosition(m_document, gfx::Point(x, y))); } -void DocumentApi::setPalette(Sprite* sprite, frame_t frame, const Palette* newPalette) +void DocApi::setPalette(Sprite* sprite, frame_t frame, const Palette* newPalette) { Palette* currentSpritePalette = sprite->palette(frame); // Sprite current pal int from, to; @@ -598,7 +598,7 @@ void DocumentApi::setPalette(Sprite* sprite, frame_t frame, const Palette* newPa } } -void DocumentApi::adjustFrameTags(Sprite* sprite, +void DocApi::adjustFrameTags(Sprite* sprite, const frame_t frame, const frame_t delta, const DropFramePlace dropFramePlace, diff --git a/src/app/document_api.h b/src/app/doc_api.h similarity index 96% rename from src/app/document_api.h rename to src/app/doc_api.h index 5d5e972e1..16519eafb 100644 --- a/src/app/document_api.h +++ b/src/app/doc_api.h @@ -4,8 +4,8 @@ // This program is distributed under the terms of // the End-User License Agreement for Aseprite. -#ifndef APP_DOCUMENT_API_H_INCLUDED -#define APP_DOCUMENT_API_H_INCLUDED +#ifndef APP_DOC_API_H_INCLUDED +#define APP_DOC_API_H_INCLUDED #pragma once #include "app/drop_frame_place.h" @@ -37,9 +37,9 @@ namespace app { // directly to the transaction. // // TODO refactor this class in several Cmd, don't make it bigger - class DocumentApi { + class DocApi { public: - DocumentApi(Document* document, Transaction& transaction); + DocApi(Document* document, Transaction& transaction); // Sprite API void setSpriteSize(Sprite* sprite, int w, int h); diff --git a/src/app/document.cpp b/src/app/document.cpp index debebecf3..abe1283dc 100644 --- a/src/app/document.cpp +++ b/src/app/document.cpp @@ -18,7 +18,7 @@ #include "app/doc_event.h" #include "app/doc_observer.h" #include "app/doc_undo.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/file/format_options.h" #include "app/flatten.h" #include "app/pref/preferences.h" @@ -76,9 +76,9 @@ void Document::setContext(Context* ctx) onContextChanged(); } -DocumentApi Document::getApi(Transaction& transaction) +DocApi Document::getApi(Transaction& transaction) { - return DocumentApi(this, transaction); + return DocApi(this, transaction); } ////////////////////////////////////////////////////////////////////// diff --git a/src/app/document.h b/src/app/document.h index ea1528c00..d1f0ddbc9 100644 --- a/src/app/document.h +++ b/src/app/document.h @@ -42,7 +42,7 @@ namespace gfx { namespace app { class Context; - class DocumentApi; + class DocApi; class DocUndo; class Transaction; @@ -71,7 +71,7 @@ namespace app { void setContext(Context* ctx); // Returns a high-level API: observable and undoable methods. - DocumentApi getApi(Transaction& transaction); + DocApi getApi(Transaction& transaction); ////////////////////////////////////////////////////////////////////// // Main properties diff --git a/src/app/document_api_tests.cpp b/src/app/document_api_tests.cpp index 708fb3eb1..1c0e8c3da 100644 --- a/src/app/document_api_tests.cpp +++ b/src/app/document_api_tests.cpp @@ -8,7 +8,7 @@ #include "app/context.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/test_context.h" #include "app/transaction.h" #include "base/unique_ptr.h" diff --git a/src/app/document_range_ops.cpp b/src/app/document_range_ops.cpp index 0796be172..5f84136b7 100644 --- a/src/app/document_range_ops.cpp +++ b/src/app/document_range_ops.cpp @@ -15,7 +15,7 @@ #include "app/app.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/transaction.h" #include "app/ui/timeline/timeline.h" @@ -33,7 +33,7 @@ namespace app { enum Op { Move, Copy }; static void move_or_copy_cels( - DocumentApi& api, Op op, + DocApi& api, Op op, const LayerList& srcLayers, const LayerList& dstLayers, const SelectedFrames& srcFrames, @@ -76,7 +76,7 @@ static void move_or_copy_cels( } static DocumentRange move_or_copy_frames( - DocumentApi& api, Op op, + DocApi& api, Op op, Sprite* sprite, const DocumentRange& srcRange, frame_t dstFrame, @@ -332,11 +332,11 @@ static DocumentRange drop_range_op( const ContextReader reader(context); ContextWriter writer(reader, 500); Transaction transaction(writer.context(), undoLabel, ModifyDocument); - DocumentApi api = doc->getApi(transaction); + DocApi api = doc->getApi(transaction); - // TODO Try to add the range with just one call to DocumentApi + // TODO Try to add the range with just one call to DocApi // methods, to avoid generating a lot of cmd::SetCelFrame (see - // DocumentApi::setCelFramePosition() function). + // DocApi::setCelFramePosition() function). switch (from.type()) { @@ -489,7 +489,7 @@ void reverse_frames(Document* doc, const DocumentRange& range) const ContextReader reader(context); ContextWriter writer(reader, 500); Transaction transaction(writer.context(), "Reverse Frames"); - DocumentApi api = doc->getApi(transaction); + DocApi api = doc->getApi(transaction); Sprite* sprite = doc->sprite(); LayerList layers; frame_t frameBegin, frameEnd; diff --git a/src/app/document_range_tests.cpp b/src/app/document_range_tests.cpp index 95fc7004e..565bef05e 100644 --- a/src/app/document_range_tests.cpp +++ b/src/app/document_range_tests.cpp @@ -9,7 +9,7 @@ #include "app/context.h" #include "app/doc_undo.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/document_range_ops.h" #include "app/test_context.h" diff --git a/src/app/script/sprite_class.cpp b/src/app/script/sprite_class.cpp index 7ef74c147..d9e9c0545 100644 --- a/src/app/script/sprite_class.cpp +++ b/src/app/script/sprite_class.cpp @@ -14,7 +14,7 @@ #include "app/commands/params.h" #include "app/context.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/file/palette_file.h" #include "app/script/app_scripting.h" #include "app/script/sprite_wrap.h" @@ -60,7 +60,7 @@ void Sprite_resize(script::ContextHandle handle) wrap->commitImages(); Document* doc = wrap->document(); - DocumentApi api(doc, wrap->transaction()); + DocApi api(doc, wrap->transaction()); api.setSpriteSize(doc->sprite(), size.w, size.h); } @@ -90,7 +90,7 @@ void Sprite_crop(script::ContextHandle handle) } if (!bounds.isEmpty()) { - DocumentApi api(doc, wrap->transaction()); + DocApi api(doc, wrap->transaction()); api.cropSprite(doc->sprite(), bounds); } } diff --git a/src/app/script/sprite_wrap.cpp b/src/app/script/sprite_wrap.cpp index 12a347e49..d96817622 100644 --- a/src/app/script/sprite_wrap.cpp +++ b/src/app/script/sprite_wrap.cpp @@ -14,7 +14,7 @@ #include "app/cmd/set_sprite_size.h" #include "app/context.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/script/image_wrap.h" #include "app/site.h" #include "app/transaction.h" diff --git a/src/app/ui/color_bar.cpp b/src/app/ui/color_bar.cpp index 236e549b3..53249260d 100644 --- a/src/app/ui/color_bar.cpp +++ b/src/app/ui/color_bar.cpp @@ -27,7 +27,7 @@ #include "app/console.h" #include "app/context_access.h" #include "app/doc_undo.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/i18n/strings.h" #include "app/ini_file.h" #include "app/modules/editors.h" @@ -648,7 +648,7 @@ void ColorBar::setTransparentIndex(int index) int(sprite->transparentColor()) != index) { // TODO merge this code with SpritePropertiesCommand Transaction transaction(writer.context(), "Set Transparent Color"); - DocumentApi api = writer.document()->getApi(transaction); + DocApi api = writer.document()->getApi(transaction); api.setSpriteTransparentColor(sprite, index); transaction.commit(); diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index a791220a5..b58a8e054 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -13,7 +13,7 @@ #include "app/app.h" #include "app/cmd/set_cel_bounds.h" #include "app/context_access.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/transaction.h" #include "app/ui/editor/editor.h" @@ -149,7 +149,7 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) { ContextWriter writer(m_reader, 1000); Transaction transaction(writer.context(), "Cel Movement", ModifyDocument); - DocumentApi api = document->getApi(transaction); + DocApi api = document->getApi(transaction); gfx::Point intOffset = intCelOffset(); // And now we move the cel (or all selected range) to the new position. @@ -178,7 +178,7 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) // m_celOffset=(0.5,0.5)) will not move the final // position of the mask (so the ref layer is moved and // the mask isn't). - + api.setMaskPosition(document->mask()->bounds().x + intOffset.x, document->mask()->bounds().y + intOffset.y); } diff --git a/src/app/ui/editor/pixels_movement.cpp b/src/app/ui/editor/pixels_movement.cpp index b8868e307..f9fec1cd7 100644 --- a/src/app/ui/editor/pixels_movement.cpp +++ b/src/app/ui/editor/pixels_movement.cpp @@ -17,7 +17,7 @@ #include "app/cmd/trim_cel.h" #include "app/console.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/modules/gui.h" #include "app/pref/preferences.h" #include "app/site.h" diff --git a/src/app/ui/timeline/timeline.cpp b/src/app/ui/timeline/timeline.cpp index a464396b7..158b47f3b 100644 --- a/src/app/ui/timeline/timeline.cpp +++ b/src/app/ui/timeline/timeline.cpp @@ -21,7 +21,7 @@ #include "app/doc_event.h" #include "app/doc_undo.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range_ops.h" #include "app/loop_tag.h" #include "app/modules/editors.h" diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp index 9f10e7afd..a9b4a5ebe 100644 --- a/src/app/util/clipboard.cpp +++ b/src/app/util/clipboard.cpp @@ -15,7 +15,7 @@ #include "app/console.h" #include "app/context_access.h" #include "app/document.h" -#include "app/document_api.h" +#include "app/doc_api.h" #include "app/document_range.h" #include "app/document_range_ops.h" #include "app/modules/editors.h" @@ -407,7 +407,7 @@ void paste() } Transaction transaction(UIContext::instance(), "Paste Cels"); - DocumentApi api = dstDoc->getApi(transaction); + DocApi api = dstDoc->getApi(transaction); // Add extra frames if needed while (dstFrameFirst+srcRange.frames() > dstSpr->totalFrames()) @@ -499,7 +499,7 @@ void paste() } Transaction transaction(UIContext::instance(), "Paste Frames"); - DocumentApi api = dstDoc->getApi(transaction); + DocApi api = dstDoc->getApi(transaction); auto srcLayers = srcSpr->allBrowsableLayers(); auto dstLayers = dstSpr->allBrowsableLayers(); @@ -542,7 +542,7 @@ void paste() throw std::runtime_error("You cannot copy layers of document with different color modes"); Transaction transaction(UIContext::instance(), "Paste Layers"); - DocumentApi api = dstDoc->getApi(transaction); + DocApi api = dstDoc->getApi(transaction); // Remove children if their parent is selected so we only // copy the parent.