Simplify DocumentApi::clearMask(): we just need the "cel" param

This commit is contained in:
David Capello 2014-09-12 02:05:32 -03:00
parent 4e6e50194e
commit 77a66c1b87
5 changed files with 8 additions and 11 deletions

View File

@ -99,8 +99,7 @@ void ClearCommand::onExecute(Context* context)
{ {
UndoTransaction undoTransaction(writer.context(), "Clear"); UndoTransaction undoTransaction(writer.context(), "Clear");
DocumentApi api = document->getApi(); DocumentApi api = document->getApi();
api.clearMask(writer.layer(), writer.cel(), api.clearMask(writer.cel());
app_get_color_to_clear_layer(writer.layer()));
if (visibleMask) if (visibleMask)
api.deselectMask(); api.deselectMask();

View File

@ -1200,16 +1200,17 @@ void DocumentApi::clearImage(Image* image, color_t bgcolor)
} }
// Clears the mask region in the current sprite with the specified background color. // Clears the mask region in the current sprite with the specified background color.
void DocumentApi::clearMask(Layer* layer, Cel* cel, color_t bgcolor) void DocumentApi::clearMask(Cel* cel)
{ {
ASSERT(cel); ASSERT(cel);
ASSERT(layer == cel->layer());
Image* image = (cel ? cel->image(): NULL); Image* image = (cel ? cel->image(): NULL);
if (!image) if (!image)
return; return;
Layer* layer = cel->layer();
Mask* mask = m_document->mask(); Mask* mask = m_document->mask();
color_t bgcolor = bgColor(layer);
// If the mask is empty or is not visible then we have to clear the // If the mask is empty or is not visible then we have to clear the
// entire image in the cel. // entire image in the cel.
@ -1222,7 +1223,7 @@ void DocumentApi::clearMask(Layer* layer, Cel* cel, color_t bgcolor)
// associated image). // associated image).
else { else {
ASSERT(layer->isImage()); ASSERT(layer->isImage());
removeCel(static_cast<LayerImage*>(layer), cel); removeCel(cel);
} }
} }
else { else {

View File

@ -115,7 +115,7 @@ namespace app {
// Image API // Image API
void clearImage(Image* image, color_t bgcolor); void clearImage(Image* image, color_t bgcolor);
void clearMask(Layer* layer, Cel* cel, color_t bgcolor); void clearMask(Cel* cel);
void flipImage(Image* image, const gfx::Rect& bounds, raster::algorithm::FlipType flipType); void flipImage(Image* image, const gfx::Rect& bounds, raster::algorithm::FlipType flipType);
void flipImageWithMask(Image* image, const Mask* mask, raster::algorithm::FlipType flipType, color_t bgcolor); void flipImageWithMask(Image* image, const Mask* mask, raster::algorithm::FlipType flipType, color_t bgcolor);
void pasteImage(Sprite* sprite, Cel* cel, const Image* src_image, int x, int y, int opacity); void pasteImage(Sprite* sprite, Cel* cel, const Image* src_image, int x, int y, int opacity);

View File

@ -22,7 +22,6 @@
#include "app/ui/editor/pixels_movement.h" #include "app/ui/editor/pixels_movement.h"
#include "app/app.h"
#include "app/document.h" #include "app/document.h"
#include "app/document_api.h" #include "app/document_api.h"
#include "app/modules/gui.h" #include "app/modules/gui.h"
@ -119,8 +118,7 @@ void PixelsMovement::cutMask()
{ {
ContextWriter writer(m_reader); ContextWriter writer(m_reader);
if (writer.cel()) if (writer.cel())
m_document->getApi().clearMask(m_layer, writer.cel(), m_document->getApi().clearMask(writer.cel());
app_get_color_to_clear_layer(m_layer));
} }
copyMask(); copyMask();

View File

@ -193,8 +193,7 @@ void clipboard::cut(ContextWriter& writer)
UndoTransaction undoTransaction(writer.context(), "Cut"); UndoTransaction undoTransaction(writer.context(), "Cut");
DocumentApi api(writer.document()->getApi()); DocumentApi api(writer.document()->getApi());
api.clearMask(writer.layer(), writer.cel(), api.clearMask(writer.cel());
app_get_color_to_clear_layer(writer.layer()));
api.deselectMask(); api.deselectMask();
undoTransaction.commit(); undoTransaction.commit();