Use Tx instead of Transaction in commands

This commit is contained in:
David Capello 2018-08-20 16:00:59 -03:00
parent 587f697bda
commit 70629d6f89
56 changed files with 310 additions and 312 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2016-2017 David Capello
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -17,7 +17,7 @@
#include "app/context_access.h"
#include "app/i18n/strings.h"
#include "app/modules/palettes.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "app/ui/context_bar.h"
#include "app/ui/editor/editor.h"
@ -121,9 +121,9 @@ void AddColorCommand::onExecute(Context* ctx)
if (document) {
frame_t frame = writer.frame();
Transaction transaction(writer.context(), friendlyName(), ModifyDocument);
transaction.execute(new cmd::SetPalette(sprite, frame, newPalette));
transaction.commit();
Tx tx(writer.context(), friendlyName(), ModifyDocument);
tx(new cmd::SetPalette(sprite, frame, newPalette));
tx.commit();
}
set_current_palette(newPalette, true);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "doc/layer.h"
#include "doc/sprite.h"
@ -53,10 +53,10 @@ void BackgroundFromLayerCommand::onExecute(Context* context)
Doc* document(writer.document());
{
Transaction transaction(writer.context(), "Background from Layer");
document->getApi(transaction).backgroundFromLayer(
Tx tx(writer.context(), "Background from Layer");
document->getApi(tx).backgroundFromLayer(
static_cast<LayerImage*>(writer.layer()));
transaction.commit();
tx.commit();
}
update_screen_for_document(document);

View File

@ -13,7 +13,7 @@
#include "app/doc_api.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/button_set.h"
#include "app/ui/color_bar.h"
#include "app/ui/editor/editor.h"
@ -331,14 +331,14 @@ void CanvasSizeCommand::onExecute(Context* context)
ContextWriter writer(reader);
Doc* document = writer.document();
Sprite* sprite = writer.sprite();
Transaction transaction(writer.context(), "Canvas Size");
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), "Canvas Size");
DocApi api = document->getApi(tx);
api.cropSprite(sprite,
gfx::Rect(x1, y1,
MID(1, x2-x1, DOC_SPRITE_MAX_WIDTH),
MID(1, y2-y1, DOC_SPRITE_MAX_HEIGHT)));
transaction.commit();
tx.commit();
document->generateMaskBoundaries();
update_screen_for_document(document);

View File

@ -16,7 +16,7 @@
#include "app/context_access.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "doc/cel.h"
#include "doc/cels_range.h"
@ -72,7 +72,7 @@ void CelOpacityCommand::onExecute(Context* context)
return;
{
Transaction transaction(writer.context(), "Set Cel Opacity");
Tx tx(writer.context(), "Set Cel Opacity");
// TODO the range of selected cels should be in app::Site.
DocRange range = App::instance()->timeline()->range();
@ -86,12 +86,12 @@ void CelOpacityCommand::onExecute(Context* context)
if (!c->layer()->isBackground() &&
c->layer()->isEditable() &&
m_opacity != c->opacity()) {
transaction.execute(new cmd::SetCelOpacity(c, m_opacity));
tx(new cmd::SetCelOpacity(c, m_opacity));
}
}
}
transaction.commit();
tx.commit();
}
update_screen_for_document(writer.document());

View File

@ -17,7 +17,7 @@
#include "app/doc_event.h"
#include "app/doc_range.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "app/ui/user_data_popup.h"
#include "app/ui_context.h"
@ -167,7 +167,7 @@ private:
m_userData != m_cel->data()->userData()))) {
try {
ContextWriter writer(UIContext::instance());
Transaction transaction(writer.context(), "Set Cel Properties");
Tx tx(writer.context(), "Set Cel Properties");
DocRange range;
if (m_range.enabled())
@ -181,12 +181,12 @@ private:
for (Cel* cel : sprite->uniqueCels(range.selectedFrames())) {
if (range.contains(cel->layer())) {
if (!cel->layer()->isBackground() && newOpacity != cel->opacity()) {
transaction.execute(new cmd::SetCelOpacity(cel, newOpacity));
tx(new cmd::SetCelOpacity(cel, newOpacity));
}
if (m_newUserData &&
m_userData != cel->data()->userData()) {
transaction.execute(new cmd::SetUserData(cel->data(), m_userData));
tx(new cmd::SetUserData(cel->data(), m_userData));
// Redraw timeline because the cel's user data/color
// might have changed.
@ -195,7 +195,7 @@ private:
}
}
transaction.commit();
tx.commit();
}
catch (const std::exception& e) {
Console::showException(e);

View File

@ -472,9 +472,9 @@ void ChangePixelFormatCommand::onExecute(Context* context)
Sprite* sprite(job.sprite());
if (flatten)
job.transaction().execute(new cmd::FlattenLayers(sprite));
job.tx()(new cmd::FlattenLayers(sprite));
job.transaction().execute(
job.tx()(
new cmd::SetPixelFormat(
sprite, m_format,
m_ditheringAlgorithm,

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -13,7 +13,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/status_bar.h"
#include "doc/cel.h"
#include "doc/layer.h"
@ -47,7 +47,7 @@ void ClearCelCommand::onExecute(Context* context)
Doc* document(writer.document());
bool nonEditableLayers = false;
{
Transaction transaction(writer.context(), "Clear Cel");
Tx tx(writer.context(), "Clear Cel");
const Site* site = writer.site();
if (site->inTimeline() &&
@ -66,18 +66,18 @@ void ClearCelCommand::onExecute(Context* context)
for (frame_t frame : site->selectedFrames().reversed()) {
if (layerImage->cel(frame))
document->getApi(transaction).clearCel(layerImage, frame);
document->getApi(tx).clearCel(layerImage, frame);
}
}
}
else if (writer.cel()) {
if (writer.layer()->isEditableHierarchy())
document->getApi(transaction).clearCel(writer.cel());
document->getApi(tx).clearCel(writer.cel());
else
nonEditableLayers = true;
}
transaction.commit();
tx.commit();
}
if (nonEditableLayers)

View File

@ -140,7 +140,7 @@ void ColorQuantizationCommand::onExecute(Context* context)
}
if (*curPalette != *newPalette)
job.transaction().execute(new cmd::SetPalette(sprite, frame, newPalette.get()));
job.tx()(new cmd::SetPalette(sprite, frame, newPalette.get()));
set_current_palette(newPalette.get(), false);
ui::Manager::getDefault()->invalidate();

View File

@ -12,7 +12,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "app/util/autocrop.h"
#include "doc/image.h"
@ -71,9 +71,9 @@ void CropSpriteCommand::onExecute(Context* context)
bounds = m_bounds;
{
Transaction transaction(writer.context(), "Sprite Crop");
document->getApi(transaction).cropSprite(sprite, bounds);
transaction.commit();
Tx tx(writer.context(), "Sprite Crop");
document->getApi(tx).cropSprite(sprite, bounds);
tx.commit();
}
document->generateMaskBoundaries();
@ -109,9 +109,9 @@ void AutocropSpriteCommand::onExecute(Context* context)
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
{
Transaction transaction(writer.context(), "Trim Sprite");
document->getApi(transaction).trimSprite(sprite);
transaction.commit();
Tx tx(writer.context(), "Trim Sprite");
document->getApi(tx).trimSprite(sprite);
tx.commit();
}
document->generateMaskBoundaries();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-42017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/mask.h"
#include "doc/sprite.h"
@ -44,9 +44,9 @@ void DeselectMaskCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
{
Transaction transaction(writer.context(), "Deselect", DoesntModifyDocument);
transaction.execute(new cmd::DeselectMask(document));
transaction.commit();
Tx tx(writer.context(), "Deselect", DoesntModifyDocument);
tx(new cmd::DeselectMask(document));
tx.commit();
}
document->generateMaskBoundaries();
update_screen_for_document(document);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -16,7 +16,7 @@
#include "app/doc_api.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "doc/layer.h"
#include "doc/sprite.h"
@ -51,13 +51,13 @@ void DuplicateLayerCommand::onExecute(Context* context)
Doc* document = writer.document();
{
Transaction transaction(writer.context(), "Layer Duplication");
Tx tx(writer.context(), "Layer Duplication");
LayerImage* sourceLayer = static_cast<LayerImage*>(writer.layer());
DocApi api = document->getApi(transaction);
DocApi api = document->getApi(tx);
api.duplicateLayerAfter(sourceLayer,
sourceLayer->parent(),
sourceLayer);
transaction.commit();
tx.commit();
}
update_screen_for_document(document);

View File

@ -16,7 +16,7 @@
#include "app/context_access.h"
#include "app/modules/editors.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/util/expand_cel_canvas.h"
#include "doc/algorithm/fill_selection.h"
@ -77,11 +77,11 @@ void FillCommand::onExecute(Context* ctx)
app::Color color = pref.colorBar.fgColor();
{
Transaction transaction(writer.context(), "Fill Selection with Foreground Color");
Tx tx(writer.context(), "Fill Selection with Foreground Color");
{
ExpandCelCanvas expand(
site, layer,
TiledMode::NONE, transaction,
TiledMode::NONE, tx,
ExpandCelCanvas::None);
gfx::Region rgn(sprite->bounds() |
@ -115,9 +115,9 @@ void FillCommand::onExecute(Context* ctx)
// If the cel wasn't deleted by cmd::ClearMask, we trim it.
Cel* cel = ctx->activeSite().cel();
if (cel && layer->isTransparent())
transaction.execute(new cmd::TrimCel(cel));
tx(new cmd::TrimCel(cel));
transaction.commit();
tx.commit();
}
doc->notifyGeneralUpdate();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "doc/sprite.h"
@ -43,9 +43,9 @@ void FlattenLayersCommand::onExecute(Context* context)
ContextWriter writer(context);
Sprite* sprite = writer.sprite();
{
Transaction transaction(writer.context(), "Flatten Layers");
transaction.execute(new cmd::FlattenLayers(sprite));
transaction.commit();
Tx tx(writer.context(), "Flatten Layers");
tx(new cmd::FlattenLayers(sprite));
tx.commit();
}
update_screen_for_document(writer.document());
}

View File

@ -24,7 +24,7 @@
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/tools/tool_box.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/moving_pixels_state.h"
#include "app/ui/status_bar.h"
@ -111,8 +111,8 @@ void FlipCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document = writer.document();
Sprite* sprite = writer.sprite();
Transaction transaction(writer.context(), friendlyName());
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), friendlyName());
DocApi api = document->getApi(tx);
Mask* mask = document->mask();
if (m_flipMask && document->isMaskVisible()) {
@ -141,12 +141,12 @@ void FlipCommand::onExecute(Context* context)
continue;
if (mask->bitmap() && !mask->isRectangular())
transaction.execute(new cmd::FlipMaskedCel(cel, m_flipType));
tx(new cmd::FlipMaskedCel(cel, m_flipType));
else
api.flipImage(image, flipBounds, m_flipType);
if (cel->layer()->isTransparent())
transaction.execute(new cmd::TrimCel(cel));
tx(new cmd::TrimCel(cel));
}
// When the mask is bigger than the cel bounds, we have to
// expand the cel, make the flip, and shrink it again.
@ -157,7 +157,7 @@ void FlipCommand::onExecute(Context* context)
ExpandCelCanvas expand(
site, cel->layer(),
TiledMode::NONE, transaction,
TiledMode::NONE, tx,
ExpandCelCanvas::None);
expand.validateDestCanvas(gfx::Region(flipBounds));
@ -188,7 +188,7 @@ void FlipCommand::onExecute(Context* context)
if (m_flipType == doc::algorithm::FlipVertical)
bounds.y = sprite->height() - bounds.h - bounds.y;
transaction.execute(new cmd::SetCelBoundsF(cel, bounds));
tx(new cmd::SetCelBoundsF(cel, bounds));
}
else {
api.setCelPosition
@ -208,11 +208,11 @@ void FlipCommand::onExecute(Context* context)
// Flip the mask.
Image* maskBitmap = mask->bitmap();
if (maskBitmap) {
transaction.execute(new cmd::FlipMask(document, m_flipType));
tx(new cmd::FlipMask(document, m_flipType));
// Flip the mask position because the
if (!m_flipMask)
transaction.execute(
tx(
new cmd::SetMaskPosition(
document,
gfx::Point(
@ -226,7 +226,7 @@ void FlipCommand::onExecute(Context* context)
document->generateMaskBoundaries();
}
transaction.commit();
tx.commit();
update_screen_for_document(document);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -15,7 +15,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "base/convert_to.h"
#include "doc/sprite.h"
#include "ui/ui.h"
@ -128,13 +128,13 @@ void FramePropertiesCommand::onExecute(Context* context)
int newMsecs = window.frlen()->textInt();
ContextWriter writer(reader);
Transaction transaction(writer.context(), "Frame Duration");
DocApi api = writer.document()->getApi(transaction);
Tx tx(writer.context(), "Frame Duration");
DocApi api = writer.document()->getApi(tx);
for (frame_t frame : selFrames)
api.setFrameDuration(writer.sprite(), frame, newMsecs);
transaction.commit();
tx.commit();
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -17,7 +17,7 @@
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/loop_tag.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/frame_tag_window.h"
#include "base/convert_to.h"
#include "doc/anidir.h"
@ -87,29 +87,29 @@ void FrameTagPropertiesCommand::onExecute(Context* context)
return;
ContextWriter writer(reader);
Transaction transaction(writer.context(), "Change Frame Tag Properties");
Tx tx(writer.context(), "Change Frame Tag Properties");
FrameTag* tag = const_cast<FrameTag*>(foundTag);
std::string name = window.nameValue();
if (tag->name() != name)
transaction.execute(new cmd::SetFrameTagName(tag, name));
tx(new cmd::SetFrameTagName(tag, name));
doc::frame_t from, to;
window.rangeValue(from, to);
if (tag->fromFrame() != from ||
tag->toFrame() != to) {
transaction.execute(new cmd::SetFrameTagRange(tag, from, to));
tx(new cmd::SetFrameTagRange(tag, from, to));
}
doc::color_t docColor = window.colorValue();
if (tag->color() != docColor)
transaction.execute(new cmd::SetFrameTagColor(tag, docColor));
tx(new cmd::SetFrameTagColor(tag, docColor));
doc::AniDir anidir = window.aniDirValue();
if (tag->aniDir() != anidir)
transaction.execute(new cmd::SetFrameTagAniDir(tag, anidir));
tx(new cmd::SetFrameTagAniDir(tag, anidir));
transaction.commit();
tx.commit();
}
Command* CommandFactory::createFrameTagPropertiesCommand()

View File

@ -21,7 +21,7 @@
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/drop_down_button.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_decorator.h"
@ -385,8 +385,8 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
// The following steps modify the sprite, so we wrap all
// operations in a undo-transaction.
ContextWriter writer(context);
Transaction transaction(writer.context(), "Import Sprite Sheet", ModifyDocument);
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), "Import Sprite Sheet", ModifyDocument);
DocApi api = document->getApi(tx);
// Add the layer in the sprite.
LayerImage* resultLayer = api.newLayer(sprite->root(), "Sprite Sheet");
@ -416,7 +416,7 @@ void ImportSpriteSheetCommand::onExecute(Context* context)
// Set the size of the sprite to the tile size.
api.setSpriteSize(sprite, frameBounds.w, frameBounds.h);
transaction.commit();
tx.commit();
ASSERT(docPref);
if (docPref) {

View File

@ -13,7 +13,7 @@
#include "app/commands/commands.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/image.h"
#include "doc/mask.h"
#include "doc/primitives.h"
@ -93,9 +93,9 @@ void InvertMaskCommand::onExecute(Context* context)
mask->intersect(sprite->bounds());
// Set the new mask
Transaction transaction(writer.context(), "Mask Invert", DoesntModifyDocument);
transaction.execute(new cmd::SetMask(document, mask.get()));
transaction.commit();
Tx tx(writer.context(), "Mask Invert", DoesntModifyDocument);
tx(new cmd::SetMask(document, mask.get()));
tx.commit();
document->generateMaskBoundaries();
update_screen_for_document(document);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/layer.h"
#include "doc/sprite.h"
#include "ui/ui.h"
@ -52,9 +52,9 @@ void LayerFromBackgroundCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
{
Transaction transaction(writer.context(), "Layer from Background");
document->getApi(transaction).layerFromBackground(writer.layer());
transaction.commit();
Tx tx(writer.context(), "Layer from Background");
document->getApi(tx).layerFromBackground(writer.layer());
tx.commit();
}
update_screen_for_document(document);
}

View File

@ -16,7 +16,7 @@
#include "app/context_access.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "doc/layer.h"
#include "fmt/format.h"
@ -68,7 +68,7 @@ void LayerOpacityCommand::onExecute(Context* context)
return;
{
Transaction transaction(writer.context(), "Set Layer Opacity");
Tx tx(writer.context(), "Set Layer Opacity");
// TODO the range of selected frames should be in app::Site.
SelectedLayers selLayers;
@ -82,11 +82,10 @@ void LayerOpacityCommand::onExecute(Context* context)
for (auto layer : selLayers) {
if (layer->isImage())
transaction.execute(
new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), m_opacity));
tx(new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), m_opacity));
}
transaction.commit();
tx.commit();
}
update_screen_for_document(writer.document());

View File

@ -19,7 +19,7 @@
#include "app/doc.h"
#include "app/doc_event.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/separator_in_view.h"
#include "app/ui/timeline/timeline.h"
#include "app/ui/user_data_popup.h"
@ -223,7 +223,7 @@ private:
newBlendMode != static_cast<LayerImage*>(m_layer)->blendMode()))))) {
try {
ContextWriter writer(UIContext::instance());
Transaction transaction(writer.context(), "Set Layer Properties");
Tx tx(writer.context(), "Set Layer Properties");
DocRange range;
if (m_range.enabled())
@ -240,17 +240,17 @@ private:
for (Layer* layer : range.selectedLayers()) {
if (nameChanged && newName != layer->name())
transaction.execute(new cmd::SetLayerName(layer, newName));
tx(new cmd::SetLayerName(layer, newName));
if (userDataChanged && m_userData != layer->userData())
transaction.execute(new cmd::SetUserData(layer, m_userData));
tx(new cmd::SetUserData(layer, m_userData));
if (layer->isImage()) {
if (opacityChanged && newOpacity != static_cast<LayerImage*>(layer)->opacity())
transaction.execute(new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), newOpacity));
tx(new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), newOpacity));
if (blendModeChanged && newBlendMode != static_cast<LayerImage*>(layer)->blendMode())
transaction.execute(new cmd::SetLayerBlendMode(static_cast<LayerImage*>(layer), newBlendMode));
tx(new cmd::SetLayerBlendMode(static_cast<LayerImage*>(layer), newBlendMode));
}
}
@ -258,7 +258,7 @@ private:
// might have changed.
App::instance()->timeline()->invalidate();
transaction.commit();
tx.commit();
}
catch (const std::exception& e) {
Console::showException(e);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -13,7 +13,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/status_bar.h"
#include "doc/cel.h"
#include "doc/layer.h"
@ -57,7 +57,7 @@ void LinkCelsCommand::onExecute(Context* context)
if (!site.inTimeline())
return;
Transaction transaction(writer.context(), friendlyName());
Tx tx(writer.context(), friendlyName());
for (Layer* layer : site.selectedLayers()) {
if (!layer->isImage())
@ -76,7 +76,7 @@ void LinkCelsCommand::onExecute(Context* context)
Cel* cel = layerImage->cel(frame);
if (cel) {
for (++it; it != end; ++it) {
transaction.execute(
tx(
new cmd::CopyCel(
layerImage, cel->frame(),
layerImage, *it,
@ -87,7 +87,7 @@ void LinkCelsCommand::onExecute(Context* context)
}
}
transaction.commit();
tx.commit();
}
if (nonEditableLayers)

View File

@ -15,7 +15,7 @@
#include "app/file_selector.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/util/msk_file.h"
#include "doc/mask.h"
#include "doc/sprite.h"
@ -77,9 +77,9 @@ void LoadMaskCommand::onExecute(Context* context)
{
ContextWriter writer(reader);
Doc* document = writer.document();
Transaction transaction(writer.context(), "Mask Load", DoesntModifyDocument);
transaction.execute(new cmd::SetMask(document, mask.get()));
transaction.commit();
Tx tx(writer.context(), "Mask Load", DoesntModifyDocument);
tx(new cmd::SetMask(document, mask.get()));
tx.commit();
document->generateMaskBoundaries();
update_screen_for_document(document);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/mask.h"
#include "doc/sprite.h"
#include "app/pref/preferences.h"
@ -49,9 +49,9 @@ void MaskAllCommand::onExecute(Context* context)
Mask newMask;
newMask.replace(sprite->bounds());
Transaction transaction(writer.context(), "Select All", DoesntModifyDocument);
transaction.execute(new cmd::SetMask(document, &newMask));
transaction.commit();
Tx tx(writer.context(), "Select All", DoesntModifyDocument);
tx(new cmd::SetMask(document, &newMask));
tx.commit();
document->resetTransformation();
document->generateMaskBoundaries();

View File

@ -19,7 +19,7 @@
#include "app/ini_file.h"
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "app/ui/color_button.h"
#include "base/bind.h"
@ -159,10 +159,10 @@ void MaskByColorCommand::onExecute(Context* context)
Doc* document(writer.document());
if (apply) {
Transaction transaction(writer.context(), "Mask by Color", DoesntModifyDocument);
Tx tx(writer.context(), "Mask by Color", DoesntModifyDocument);
std::unique_ptr<Mask> mask(generateMask(sprite, image, xpos, ypos));
transaction.execute(new cmd::SetMask(document, mask.get()));
transaction.commit();
tx(new cmd::SetMask(document, mask.get()));
tx.commit();
set_config_color("MaskColor", "Color", m_buttonColor->getColor());
set_config_int("MaskColor", "Tolerance", m_sliderTolerance->getValue());

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -17,7 +17,7 @@
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/tools/tool_box.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/toolbar.h"
#include "doc/algorithm/shrink_bounds.h"
@ -82,9 +82,9 @@ void MaskContentCommand::onExecute(Context* context)
newMask.replace(cel->bounds());
}
Transaction transaction(writer.context(), "Select Content", DoesntModifyDocument);
transaction.execute(new cmd::SetMask(document, &newMask));
transaction.commit();
Tx tx(writer.context(), "Select Content", DoesntModifyDocument);
tx(new cmd::SetMask(document, &newMask));
tx.commit();
document->resetTransformation();
document->generateMaskBoundaries();

View File

@ -18,7 +18,7 @@
#include "app/doc.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/blend_internals.h"
#include "doc/cel.h"
#include "doc/image.h"
@ -68,7 +68,7 @@ void MergeDownLayerCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
Transaction transaction(writer.context(), "Merge Down Layer", ModifyDocument);
Tx tx(writer.context(), "Merge Down Layer", ModifyDocument);
LayerImage* src_layer = static_cast<LayerImage*>(writer.layer());
Layer* dst_layer = src_layer->getPrevious();
@ -106,7 +106,7 @@ void MergeDownLayerCommand::onExecute(Context* context)
dst_cel->setPosition(src_cel->x(), src_cel->y());
dst_cel->setOpacity(opacity);
transaction.execute(new cmd::AddCel(dst_layer, dst_cel));
tx(new cmd::AddCel(dst_layer, dst_cel));
}
// With destination
else {
@ -138,22 +138,22 @@ void MergeDownLayerCommand::onExecute(Context* context)
opacity,
src_layer->blendMode());
transaction.execute(new cmd::SetCelPosition(dst_cel,
tx(new cmd::SetCelPosition(dst_cel,
bounds.x, bounds.y));
if (dst_cel->links())
transaction.execute(new cmd::UnlinkCel(dst_cel));
tx(new cmd::UnlinkCel(dst_cel));
transaction.execute(new cmd::ReplaceImage(sprite,
tx(new cmd::ReplaceImage(sprite,
dst_cel->imageRef(), new_image));
}
}
}
document->notifyLayerMergedDown(src_layer, dst_layer);
document->getApi(transaction).removeLayer(src_layer); // src_layer is deleted inside removeLayer()
document->getApi(tx).removeLayer(src_layer); // src_layer is deleted inside removeLayer()
transaction.commit();
tx.commit();
update_screen_for_document(document);
}

View File

@ -16,7 +16,7 @@
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "base/convert_to.h"
#include "doc/algorithm/modify_selection.h"
#include "doc/brush_type.h"
@ -138,11 +138,11 @@ void ModifySelectionCommand::onExecute(Context* context)
}
// Set the new mask
Transaction transaction(writer.context(),
friendlyName(),
DoesntModifyDocument);
transaction.execute(new cmd::SetMask(document, mask.get()));
transaction.commit();
Tx tx(writer.context(),
friendlyName(),
DoesntModifyDocument);
tx(new cmd::SetMask(document, mask.get()));
tx.commit();
document->generateMaskBoundaries();
update_screen_for_document(document);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -19,7 +19,7 @@
#include "app/modules/editors.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/doc_view.h"
#include "app/ui/editor/editor.h"
#include "app/ui_context.h"
@ -82,10 +82,10 @@ void MoveMaskCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
{
Transaction transaction(writer.context(), "Move Selection", DoesntModifyDocument);
Tx tx(writer.context(), "Move Selection", DoesntModifyDocument);
gfx::Point pt = document->mask()->bounds().origin();
document->getApi(transaction).setMaskPosition(pt.x+delta.x, pt.y+delta.y);
transaction.commit();
document->getApi(tx).setMaskPosition(pt.x+delta.x, pt.y+delta.y);
tx.commit();
}
document->generateMaskBoundaries();
@ -98,9 +98,9 @@ void MoveMaskCommand::onExecute(Context* context)
ContextWriter writer(context);
if (writer.cel()) {
// Rotate content
Transaction transaction(writer.context(), "Shift Pixels");
transaction.execute(new cmd::ShiftMaskedCel(writer.cel(), delta.x, delta.y));
transaction.commit();
Tx tx(writer.context(), "Shift Pixels");
tx(new cmd::ShiftMaskedCel(writer.cel(), delta.x, delta.y));
tx.commit();
}
update_screen_for_document(writer.document());
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -18,7 +18,7 @@
#include "app/tools/active_tool.h"
#include "app/tools/ink.h"
#include "app/tools/tool_box.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/context_bar.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/select_box_state.h"
@ -113,9 +113,9 @@ void NewBrushCommand::onQuickboxEnd(Editor* editor, const gfx::Rect& rect, ui::M
try {
ContextWriter writer(UIContext::instance(), 250);
if (writer.cel()) {
Transaction transaction(writer.context(), "Clear");
transaction.execute(new cmd::ClearRect(writer.cel(), rect));
transaction.commit();
Tx tx(writer.context(), "Clear");
tx(new cmd::ClearRect(writer.cel(), rect));
tx.commit();
}
}
catch (const std::exception& ex) {

View File

@ -17,7 +17,7 @@
#include "app/doc_api.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/doc_view.h"
#include "app/ui/editor/editor.h"
#include "app/ui/main_window.h"
@ -90,8 +90,8 @@ void NewFrameCommand::onExecute(Context* context)
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
{
Transaction transaction(writer.context(), friendlyName());
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), friendlyName());
DocApi api = document->getApi(tx);
switch (m_content) {
@ -179,7 +179,7 @@ void NewFrameCommand::onExecute(Context* context)
}
}
transaction.commit();
tx.commit();
}
update_screen_for_document(document);

View File

@ -13,7 +13,7 @@
#include "app/commands/command.h"
#include "app/context.h"
#include "app/context_access.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/frame_tag_window.h"
#include "app/ui/timeline/timeline.h"
#include "doc/frame_tag.h"
@ -73,10 +73,10 @@ void NewFrameTagCommand::onExecute(Context* context)
{
ContextWriter writer(reader);
Transaction transaction(writer.context(), "New Frames Tag");
transaction.execute(new cmd::AddFrameTag(writer.sprite(), frameTag.get()));
Tx tx(writer.context(), "New Frames Tag");
tx(new cmd::AddFrameTag(writer.sprite(), frameTag.get()));
frameTag.release();
transaction.commit();
tx.commit();
}
App::instance()->timeline()->invalidate();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -18,7 +18,7 @@
#include "app/find_widget.h"
#include "app/load_widget.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/main_window.h"
#include "app/ui/status_bar.h"
#include "app/ui_context.h"
@ -177,10 +177,10 @@ void NewLayerCommand::onExecute(Context* context)
Layer* layer = nullptr;
{
Transaction transaction(
Tx tx(
writer.context(),
std::string("New ") + layerPrefix());
DocApi api = document->getApi(transaction);
DocApi api = document->getApi(tx);
bool afterBackground = false;
switch (m_type) {
@ -236,7 +236,7 @@ void NewLayerCommand::onExecute(Context* context)
if (sameParents == selLayers.size()) {
for (Layer* newChild : selLayers.toLayerList()) {
transaction.execute(
tx(
new cmd::MoveLayer(newChild, layer,
static_cast<LayerGroup*>(layer)->lastLayer()));
}
@ -311,7 +311,7 @@ void NewLayerCommand::onExecute(Context* context)
}
}
transaction.commit();
tx.commit();
}
update_screen_for_document(document);

View File

@ -13,7 +13,7 @@
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/modules/palettes.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/palette.h"
#include "doc/sprite.h"
#include "ui/manager.h"
@ -65,9 +65,9 @@ void PaletteSizeCommand::onExecute(Context* context)
palette.resize(MID(1, ncolors, std::numeric_limits<int>::max()));
ContextWriter writer(reader);
Transaction transaction(context, "Palette Size", ModifyDocument);
transaction.execute(new cmd::SetPalette(writer.sprite(), frame, &palette));
transaction.commit();
Tx tx(context, "Palette Size", ModifyDocument);
tx(new cmd::SetPalette(writer.sprite(), frame, &palette));
tx.commit();
set_current_palette(&palette, false);
ui::Manager::getDefault()->invalidate();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -13,7 +13,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/sprite.h"
#include "ui/ui.h"
@ -49,8 +49,8 @@ void RemoveFrameCommand::onExecute(Context* context)
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
{
Transaction transaction(writer.context(), "Remove Frame");
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), "Remove Frame");
DocApi api = document->getApi(tx);
const Site* site = writer.site();
if (site->inTimeline() &&
!site->selectedFrames().empty()) {
@ -62,7 +62,7 @@ void RemoveFrameCommand::onExecute(Context* context)
api.removeFrame(sprite, writer.frame());
}
transaction.commit();
tx.commit();
}
update_screen_for_document(document);
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -15,7 +15,7 @@
#include "app/context.h"
#include "app/context_access.h"
#include "app/loop_tag.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "base/convert_to.h"
#include "doc/frame_tag.h"
@ -77,9 +77,9 @@ void RemoveFrameTagCommand::onExecute(Context* context)
if (!foundTag)
return;
Transaction transaction(writer.context(), "Remove Frame Tag");
transaction.execute(new cmd::RemoveFrameTag(sprite, foundTag));
transaction.commit();
Tx tx(writer.context(), "Remove Frame Tag");
tx(new cmd::RemoveFrameTag(sprite, foundTag));
tx.commit();
App::instance()->timeline()->invalidate();
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -14,7 +14,7 @@
#include "app/doc_api.h"
#include "app/i18n/strings.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/status_bar.h"
#include "doc/layer.h"
#include "doc/sprite.h"
@ -52,8 +52,8 @@ void RemoveLayerCommand::onExecute(Context* context)
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
{
Transaction transaction(writer.context(), "Remove Layer");
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), "Remove Layer");
DocApi api = document->getApi(tx);
const Site* site = writer.site();
if (site->inTimeline() &&
@ -87,7 +87,7 @@ void RemoveLayerCommand::onExecute(Context* context)
api.removeLayer(layer);
}
transaction.commit();
tx.commit();
}
update_screen_for_document(document);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -15,7 +15,7 @@
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/ui/status_bar.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "base/convert_to.h"
#include "doc/slice.h"
#include "doc/sprite.h"
@ -83,16 +83,16 @@ void RemoveSliceCommand::onExecute(Context* context)
ContextWriter writer(reader, 500);
Doc* document(writer.document());
Sprite* sprite(writer.sprite());
Transaction transaction(writer.context(), "Remove Slice");
Tx tx(writer.context(), "Remove Slice");
Slice* slice = const_cast<Slice*>(foundSlice);
if (slice->size() > 1) {
transaction.execute(new cmd::SetSliceKey(slice, frame, SliceKey()));
tx(new cmd::SetSliceKey(slice, frame, SliceKey()));
}
else {
transaction.execute(new cmd::RemoveSlice(sprite, slice));
tx(new cmd::RemoveSlice(sprite, slice));
}
transaction.commit();
tx.commit();
document->notifyGeneralUpdate();
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/mask.h"
#include "doc/sprite.h"
@ -49,9 +49,9 @@ void ReselectMaskCommand::onExecute(Context* context)
ContextWriter writer(context);
Doc* document(writer.document());
{
Transaction transaction(writer.context(), "Reselect", DoesntModifyDocument);
transaction.execute(new cmd::ReselectMask(document));
transaction.commit();
Tx tx(writer.context(), "Reselect", DoesntModifyDocument);
tx(new cmd::ReselectMask(document));
tx.commit();
}
document->generateMaskBoundaries();

View File

@ -20,7 +20,7 @@
#include "app/modules/gui.h"
#include "app/sprite_job.h"
#include "app/tools/tool_box.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
@ -79,7 +79,7 @@ protected:
// [working thread]
void onJob() override {
DocApi api = document()->getApi(transaction());
DocApi api = document()->getApi(tx());
// 1) Rotate cel positions
for (Cel* cel : m_cels) {
@ -91,7 +91,7 @@ protected:
gfx::RectF bounds = cel->boundsF();
rotate_rect(bounds);
if (cel->boundsF() != bounds)
transaction().execute(new cmd::SetCelBoundsF(cel, bounds));
tx()(new cmd::SetCelBoundsF(cel, bounds));
}
else {
gfx::Rect bounds = cel->bounds();
@ -120,7 +120,7 @@ protected:
// cancel all the operation?
if (isCanceled())
return; // Transaction destructor will undo all operations
return; // Tx destructor will undo all operations
}
// rotate mask

View File

@ -17,7 +17,7 @@
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
#include "app/snap_to_grid.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "doc/mask.h"
#include "fmt/format.h"
@ -93,11 +93,11 @@ void SelectTileCommand::onExecute(Context* ctx)
}
// Set the new mask
Transaction transaction(writer.context(),
Tx tx(writer.context(),
friendlyName(),
DoesntModifyDocument);
transaction.execute(new cmd::SetMask(doc, mask.get()));
transaction.commit();
tx(new cmd::SetMask(doc, mask.get()));
tx.commit();
doc->generateMaskBoundaries();
update_screen_for_document(doc);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -17,7 +17,7 @@
#include "app/commands/params.h"
#include "app/context_access.h"
#include "app/loop_tag.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/timeline/timeline.h"
#include "doc/frame_tag.h"
@ -108,16 +108,16 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
loopTag = create_loop_tag(begin, end);
ContextWriter writer(ctx);
Transaction transaction(writer.context(), "Add Loop");
transaction.execute(new cmd::AddFrameTag(sprite, loopTag));
transaction.commit();
Tx tx(writer.context(), "Add Loop");
tx(new cmd::AddFrameTag(sprite, loopTag));
tx.commit();
}
else if (loopTag->fromFrame() != begin ||
loopTag->toFrame() != end) {
ContextWriter writer(ctx);
Transaction transaction(writer.context(), "Set Loop Range");
transaction.execute(new cmd::SetFrameTagRange(loopTag, begin, end));
transaction.commit();
Tx tx(writer.context(), "Set Loop Range");
tx(new cmd::SetFrameTagRange(loopTag, begin, end));
tx.commit();
}
else {
Command* cmd = Commands::instance()->byId(CommandId::FrameTagProperties());
@ -127,9 +127,9 @@ void SetLoopSectionCommand::onExecute(Context* ctx)
else {
if (loopTag) {
ContextWriter writer(ctx);
Transaction transaction(writer.context(), "Remove Loop");
transaction.execute(new cmd::RemoveFrameTag(sprite, loopTag));
transaction.commit();
Tx tx(writer.context(), "Remove Loop");
tx(new cmd::RemoveFrameTag(sprite, loopTag));
tx.commit();
}
}

View File

@ -14,7 +14,7 @@
#include "app/file_selector.h"
#include "app/ini_file.h"
#include "app/modules/palettes.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "doc/palette.h"
#include "ui/alert.h"
#include "ui/manager.h"
@ -37,10 +37,10 @@ void SetPaletteCommand::onExecute(Context* context)
ContextWriter writer(context);
if (writer.document()) {
Transaction transaction(writer.context(), "Set Palette");
writer.document()->getApi(transaction)
Tx tx(writer.context(), "Set Palette");
writer.document()->getApi(tx)
.setPalette(writer.sprite(), writer.frame(), m_palette);
transaction.commit();
tx.commit();
}
set_current_palette(m_palette, false);

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -13,7 +13,7 @@
#include "app/cmd/set_user_data.h"
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/slice_window.h"
#include "base/convert_to.h"
#include "doc/slice.h"
@ -85,16 +85,16 @@ void SlicePropertiesCommand::onExecute(Context* context)
{
ContextWriter writer(reader, 500);
Transaction transaction(writer.context(), "Slice Properties");
Tx tx(writer.context(), "Slice Properties");
Slice* slice = const_cast<Slice*>(foundSlice);
std::string name = window.nameValue();
if (slice->name() != name)
transaction.execute(new cmd::SetSliceName(slice, name));
tx(new cmd::SetSliceName(slice, name));
if (slice->userData() != window.userDataValue())
transaction.execute(new cmd::SetUserData(slice, window.userDataValue()));
tx(new cmd::SetUserData(slice, window.userDataValue()));
if (key->bounds() != window.boundsValue() ||
key->center() != window.centerValue() ||
@ -103,10 +103,10 @@ void SlicePropertiesCommand::onExecute(Context* context)
newKey.setBounds(window.boundsValue());
newKey.setCenter(window.centerValue());
newKey.setPivot(window.pivotValue());
transaction.execute(new cmd::SetSliceKey(slice, frame, newKey));
tx(new cmd::SetSliceKey(slice, frame, newKey));
}
transaction.commit();
tx.commit();
writer.document()->notifyGeneralUpdate();
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -14,7 +14,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_button.h"
#include "app/util/pixel_ratio.h"
#include "base/bind.h"
@ -136,16 +136,16 @@ void SpritePropertiesCommand::onExecute(Context* context)
if (index != sprite->transparentColor() ||
pixelRatio != sprite->pixelRatio()) {
Transaction transaction(writer.context(), "Change Sprite Properties");
DocApi api = writer.document()->getApi(transaction);
Tx tx(writer.context(), "Change Sprite Properties");
DocApi api = writer.document()->getApi(tx);
if (index != sprite->transparentColor())
api.setSpriteTransparentColor(sprite, index);
if (pixelRatio != sprite->pixelRatio())
transaction.execute(new cmd::SetPixelRatio(sprite, pixelRatio));
tx(new cmd::SetPixelRatio(sprite, pixelRatio));
transaction.commit();
tx.commit();
update_screen_for_document(writer.document());
}

View File

@ -72,7 +72,7 @@ protected:
// [working thread]
void onJob() override {
DocApi api = writer().document()->getApi(transaction());
DocApi api = writer().document()->getApi(tx());
int cels_count = 0;
for (Cel* cel : sprite()->uniqueCels()) { // TODO add size() member function to CelsRange
@ -89,7 +89,7 @@ protected:
// Resize the cel bounds only if it's from a reference layer
if (cel->layer()->isReference()) {
gfx::RectF newBounds = scale_rect<double>(cel->boundsF());
transaction().execute(new cmd::SetCelBoundsF(cel, newBounds));
tx()(new cmd::SetCelBoundsF(cel, newBounds));
}
else {
// Change its location
@ -118,7 +118,7 @@ protected:
// Cancel all the operation?
if (isCanceled())
return; // Transaction destructor will undo all operations
return; // Tx destructor will undo all operations
}
// Resize mask
@ -170,8 +170,7 @@ protected:
newKey.setPivot(gfx::Point(scale_x(newKey.pivot().x),
scale_y(newKey.pivot().y)));
transaction().execute(
new cmd::SetSliceKey(slice, k.frame(), newKey));
tx()(new cmd::SetSliceKey(slice, k.frame(), newKey));
}
}

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2001-2017 David Capello
// Copyright (C) 2001-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -13,7 +13,7 @@
#include "app/commands/command.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/status_bar.h"
#include "doc/cel.h"
#include "doc/layer.h"
@ -47,7 +47,7 @@ void UnlinkCelCommand::onExecute(Context* context)
Doc* document(writer.document());
bool nonEditableLayers = false;
{
Transaction transaction(writer.context(), "Unlink Cel");
Tx tx(writer.context(), "Unlink Cel");
const Site* site = writer.site();
if (site->inTimeline() &&
@ -66,7 +66,7 @@ void UnlinkCelCommand::onExecute(Context* context)
for (frame_t frame : site->selectedFrames().reversed()) {
Cel* cel = layerImage->cel(frame);
if (cel && cel->links())
transaction.execute(new cmd::UnlinkCel(cel));
tx(new cmd::UnlinkCel(cel));
}
}
}
@ -74,13 +74,13 @@ void UnlinkCelCommand::onExecute(Context* context)
Cel* cel = writer.cel();
if (cel && cel->links()) {
if (cel->layer()->isEditableHierarchy())
transaction.execute(new cmd::UnlinkCel(writer.cel()));
tx(new cmd::UnlinkCel(writer.cel()));
else
nonEditableLayers = true;
}
}
transaction.commit();
tx.commit();
}
if (nonEditableLayers)

View File

@ -17,14 +17,14 @@ SpriteJob::SpriteJob(const ContextReader& reader, const char* jobName)
, m_writer(reader, 500)
, m_document(m_writer.document())
, m_sprite(m_writer.sprite())
, m_transaction(m_writer.context(), jobName, ModifyDocument)
, m_tx(m_writer.context(), jobName, ModifyDocument)
{
}
SpriteJob::~SpriteJob()
{
if (!isCanceled())
m_transaction.commit();
m_tx.commit();
}
void SpriteJob::onJob()

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -11,7 +11,7 @@
#include "app/context.h"
#include "app/context_access.h"
#include "app/job.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "render/task_delegate.h"
#include <functional>
@ -27,7 +27,7 @@ public:
ContextWriter& writer() { return m_writer; }
Doc* document() const { return m_document; }
Sprite* sprite() const { return m_sprite; }
Transaction& transaction() { return m_transaction; }
Tx& tx() { return m_tx; }
template<typename T>
void startJobWithCallback(T&& callback) {
@ -47,7 +47,7 @@ private:
ContextWriter m_writer;
Doc* m_document;
Sprite* m_sprite;
Transaction m_transaction;
Tx m_tx;
// Default implementation calls the given function in
// startJob(). Anyway you can just extended the SpriteJob and

View File

@ -34,7 +34,7 @@
#include "app/modules/gui.h"
#include "app/modules/palettes.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_spectrum.h"
#include "app/ui/color_tint_shade_tone.h"
#include "app/ui/color_wheel.h"
@ -541,7 +541,7 @@ void ColorBar::onRemapButtonClick()
if (sprite) {
ASSERT(sprite->pixelFormat() == IMAGE_INDEXED);
Transaction transaction(writer.context(), "Remap Colors", ModifyDocument);
Tx tx(writer.context(), "Remap Colors", ModifyDocument);
bool remapPixels = true;
if (remap.isFor8bit()) {
@ -553,7 +553,7 @@ void ColorBar::onRemapButtonClick()
}
if (remap.isInvertible(usedEntries)) {
transaction.execute(new cmd::RemapColors(sprite, remap));
tx(new cmd::RemapColors(sprite, remap));
remapPixels = false;
}
}
@ -565,17 +565,17 @@ void ColorBar::onRemapButtonClick()
ImageRef newImage(Image::createCopy(celImage.get()));
doc::remap_image(newImage.get(), remap);
transaction.execute(new cmd::ReplaceImage(
sprite, celImage, newImage));
tx(new cmd::ReplaceImage(
sprite, celImage, newImage));
}
}
color_t oldTransparent = sprite->transparentColor();
color_t newTransparent = remap[oldTransparent];
if (oldTransparent != newTransparent)
transaction.execute(new cmd::SetTransparentColor(sprite, newTransparent));
tx(new cmd::SetTransparentColor(sprite, newTransparent));
transaction.commit();
tx.commit();
}
update_screen_for_document(writer.document());
hideRemap();
@ -625,9 +625,9 @@ void ColorBar::setPalette(const doc::Palette* newPalette, const std::string& act
frame_t frame = writer.frame();
if (sprite &&
newPalette->countDiff(sprite->palette(frame), nullptr, nullptr)) {
Transaction transaction(writer.context(), actionText, ModifyDocument);
transaction.execute(new cmd::SetPalette(sprite, frame, newPalette));
transaction.commit();
Tx tx(writer.context(), actionText, ModifyDocument);
tx(new cmd::SetPalette(sprite, frame, newPalette));
tx.commit();
}
}
catch (base::Exception& e) {
@ -647,10 +647,10 @@ void ColorBar::setTransparentIndex(int index)
sprite->pixelFormat() == IMAGE_INDEXED &&
int(sprite->transparentColor()) != index) {
// TODO merge this code with SpritePropertiesCommand
Transaction transaction(writer.context(), "Set Transparent Color");
DocApi api = writer.document()->getApi(transaction);
Tx tx(writer.context(), "Set Transparent Color");
DocApi api = writer.document()->getApi(tx);
api.setSpriteTransparentColor(sprite, index);
transaction.commit();
tx.commit();
update_screen_for_document(writer.document());
}
@ -1180,9 +1180,9 @@ void ColorBar::updateCurrentSpritePalette(const char* operationName)
cmd->execute(UIContext::instance());
}
else {
Transaction transaction(writer.context(), operationName, ModifyDocument);
transaction.execute(cmd);
transaction.commit();
Tx tx(writer.context(), operationName, ModifyDocument);
tx(cmd);
tx.commit();
}
}
}

View File

@ -24,7 +24,7 @@
#include "app/modules/editors.h"
#include "app/modules/palettes.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_customization_delegate.h"
#include "app/ui/editor/editor_view.h"
@ -559,19 +559,19 @@ bool DocView::onClear(Context* ctx)
return false;
{
Transaction transaction(writer.context(), "Clear");
transaction.execute(new cmd::ClearMask(writer.cel()));
Tx tx(writer.context(), "Clear");
tx(new cmd::ClearMask(writer.cel()));
// If the cel wasn't deleted by cmd::ClearMask, we trim it.
if (writer.cel() &&
writer.cel()->layer()->isTransparent())
transaction.execute(new cmd::TrimCel(writer.cel()));
tx(new cmd::TrimCel(writer.cel()));
if (visibleMask &&
!Preferences::instance().selection.keepSelectionAfterClear())
transaction.execute(new cmd::DeselectMask(document));
tx(new cmd::DeselectMask(document));
transaction.commit();
tx.commit();
}
if (visibleMask)

View File

@ -15,7 +15,7 @@
#include "app/context_access.h"
#include "app/doc_api.h"
#include "app/doc_range.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/editor/editor_customization_delegate.h"
#include "app/ui/main_window.h"
@ -148,8 +148,8 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg)
if (modified) {
{
ContextWriter writer(m_reader, 1000);
Transaction transaction(writer.context(), "Cel Movement", ModifyDocument);
DocApi api = document->getApi(transaction);
Tx tx(writer.context(), "Cel Movement", ModifyDocument);
DocApi api = document->getApi(tx);
gfx::Point intOffset = intCelOffset();
// And now we move the cel (or all selected range) to the new position.
@ -163,7 +163,7 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg)
celBounds.w *= m_celScale.w;
celBounds.h *= m_celScale.h;
}
transaction.execute(new cmd::SetCelBoundsF(cel, celBounds));
tx(new cmd::SetCelBoundsF(cel, celBounds));
}
else {
api.setCelPosition(writer.sprite(), cel,
@ -183,7 +183,7 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg)
document->mask()->bounds().y + intOffset.y);
}
transaction.commit();
tx.commit();
}
// Redraw all editors. We've to notify all views about this

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/cmd/set_mask_position.h"
#include "app/context_access.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/skin/skin_theme.h"
#include "app/ui/status_bar.h"
@ -55,9 +55,9 @@ EditorState::LeaveAction MovingSelectionState::onLeaveState(Editor* editor, Edit
{
ContextWriter writer(UIContext::instance(), 1000);
Transaction transaction(writer.context(), "Move Selection Edges", DoesntModifyDocument);
transaction.execute(new cmd::SetMaskPosition(doc, newOrigin));
transaction.commit();
Tx tx(writer.context(), "Move Selection Edges", DoesntModifyDocument);
tx(new cmd::SetMaskPosition(doc, newOrigin));
tx.commit();
}
doc->resetTransformation();

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2017 David Capello
// Copyright (C) 2017-2018 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@ -12,7 +12,7 @@
#include "app/cmd/set_slice_key.h"
#include "app/context_access.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/editor/editor.h"
#include "app/ui/status_bar.h"
#include "app/ui_context.h"
@ -43,15 +43,15 @@ bool MovingSliceState::onMouseUp(Editor* editor, MouseMessage* msg)
{
{
ContextWriter writer(UIContext::instance(), 1000);
Transaction transaction(writer.context(), "Slice Movement", ModifyDocument);
Tx tx(writer.context(), "Slice Movement", ModifyDocument);
doc::SliceKey newKey = m_key;
m_hit.slice()->insert(editor->frame(), m_keyStart);
transaction.execute(new cmd::SetSliceKey(m_hit.slice(),
editor->frame(),
newKey));
transaction.commit();
tx(new cmd::SetSliceKey(m_hit.slice(),
editor->frame(),
newKey));
tx.commit();
}
editor->backToPreviousState();

View File

@ -22,7 +22,7 @@
#include "app/modules/gfx.h"
#include "app/modules/gui.h"
#include "app/pref/preferences.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui/color_bar.h"
#include "app/ui/editor/editor.h"
#include "app/ui/skin/skin_theme.h"
@ -251,16 +251,16 @@ void cut(ContextWriter& writer)
}
else {
{
Transaction transaction(writer.context(), "Cut");
transaction.execute(new cmd::ClearMask(writer.cel()));
Tx tx(writer.context(), "Cut");
tx(new cmd::ClearMask(writer.cel()));
ASSERT(writer.cel());
if (writer.cel() &&
writer.cel()->layer()->isTransparent())
transaction.execute(new cmd::TrimCel(writer.cel()));
tx(new cmd::TrimCel(writer.cel()));
transaction.execute(new cmd::DeselectMask(writer.document()));
transaction.commit();
tx(new cmd::DeselectMask(writer.document()));
tx.commit();
}
writer.document()->generateMaskBoundaries();
update_screen_for_document(writer.document());
@ -406,8 +406,8 @@ void paste()
return;
}
Transaction transaction(UIContext::instance(), "Paste Cels");
DocApi api = dstDoc->getApi(transaction);
Tx tx(UIContext::instance(), "Paste Cels");
DocApi api = dstDoc->getApi(tx);
// Add extra frames if needed
while (dstFrameFirst+srcRange.frames() > dstSpr->totalFrames())
@ -480,7 +480,7 @@ void paste()
}
}
transaction.commit();
tx.commit();
editor->invalidate();
break;
}
@ -498,8 +498,8 @@ void paste()
break;
}
Transaction transaction(UIContext::instance(), "Paste Frames");
DocApi api = dstDoc->getApi(transaction);
Tx tx(UIContext::instance(), "Paste Frames");
DocApi api = dstDoc->getApi(tx);
auto srcLayers = srcSpr->allBrowsableLayers();
auto dstLayers = dstSpr->allBrowsableLayers();
@ -532,7 +532,7 @@ void paste()
++dstFrame;
}
transaction.commit();
tx.commit();
editor->invalidate();
break;
}
@ -541,8 +541,8 @@ void paste()
if (srcDoc->colorMode() != dstDoc->colorMode())
throw std::runtime_error("You cannot copy layers of document with different color modes");
Transaction transaction(UIContext::instance(), "Paste Layers");
DocApi api = dstDoc->getApi(transaction);
Tx tx(UIContext::instance(), "Paste Layers");
DocApi api = dstDoc->getApi(tx);
// Remove children if their parent is selected so we only
// copy the parent.
@ -583,7 +583,7 @@ void paste()
srcDoc->copyLayerContent(srcLayer, dstDoc, newLayer);
}
transaction.commit();
tx.commit();
editor->invalidate();
break;
}

View File

@ -14,7 +14,7 @@
#include "app/console.h"
#include "app/context_access.h"
#include "app/modules/gui.h"
#include "app/transaction.h"
#include "app/tx.h"
#include "app/ui_context.h"
#include "doc/cel.h"
#include "doc/document.h"
@ -120,9 +120,9 @@ void select_layer_boundaries(Layer* layer,
}
}
Transaction transaction(writer.context(), "Select Layer Boundaries", DoesntModifyDocument);
transaction.execute(new cmd::SetMask(doc, &newMask));
transaction.commit();
Tx tx(writer.context(), "Select Layer Boundaries", DoesntModifyDocument);
tx(new cmd::SetMask(doc, &newMask));
tx.commit();
doc->resetTransformation();
doc->generateMaskBoundaries();