mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-03 23:41:56 +00:00
Clear background layer too in "New Empty Frame"
This commit is contained in:
parent
6b2c5cc386
commit
da1b7097c6
@ -91,7 +91,9 @@ void NewFrameCommand::onExecute(Context* context)
|
||||
document->getApi().addFrame(sprite, writer.frame().next());
|
||||
break;
|
||||
case Content::EmptyFrame:
|
||||
document->getApi().addEmptyFrame(sprite, writer.frame().next());
|
||||
document->getApi().addEmptyFrame(sprite,
|
||||
writer.frame().next(),
|
||||
app_get_color_to_clear_layer(writer.layer()));
|
||||
break;
|
||||
}
|
||||
undoTransaction.commit();
|
||||
|
@ -245,7 +245,7 @@ void DocumentApi::addFrame(Sprite* sprite, FrameNumber newFrame)
|
||||
copyFrame(sprite, newFrame.previous(), newFrame);
|
||||
}
|
||||
|
||||
void DocumentApi::addEmptyFrame(Sprite* sprite, FrameNumber newFrame)
|
||||
void DocumentApi::addEmptyFrame(Sprite* sprite, FrameNumber newFrame, color_t bgcolor)
|
||||
{
|
||||
// Add the frame in the sprite structure, it adjusts the total
|
||||
// number of frames in the sprite.
|
||||
@ -261,7 +261,9 @@ void DocumentApi::addEmptyFrame(Sprite* sprite, FrameNumber newFrame)
|
||||
Layer* bgLayer = sprite->backgroundLayer();
|
||||
if (bgLayer) {
|
||||
LayerImage* imglayer = static_cast<LayerImage*>(bgLayer);
|
||||
copyCel(imglayer, FrameNumber(0), imglayer, newFrame, 0);
|
||||
Image* bgimage = Image::create(sprite->pixelFormat(), sprite->width(), sprite->height());
|
||||
clear_image(bgimage, bgcolor);
|
||||
addImage(imglayer, newFrame, bgimage);
|
||||
}
|
||||
|
||||
// Notify observers about the new frame.
|
||||
@ -1140,6 +1142,17 @@ int DocumentApi::addImageInStock(Sprite* sprite, Image* image)
|
||||
return imageIndex;
|
||||
}
|
||||
|
||||
Cel* DocumentApi::addImage(LayerImage* layer, FrameNumber frameNumber, Image* image)
|
||||
{
|
||||
int imageIndex = addImageInStock(layer->sprite(), image);
|
||||
base::UniquePtr<Cel> cel(new Cel(frameNumber, imageIndex));
|
||||
|
||||
addCel(layer, cel);
|
||||
cel.release();
|
||||
|
||||
return cel;
|
||||
}
|
||||
|
||||
// Removes and destroys the specified image in the stock.
|
||||
void DocumentApi::removeImageFromStock(Sprite* sprite, int imageIndex)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ namespace app {
|
||||
|
||||
// Frames API
|
||||
void addFrame(Sprite* sprite, FrameNumber newFrame);
|
||||
void addEmptyFrame(Sprite* sprite, FrameNumber newFrame);
|
||||
void addEmptyFrame(Sprite* sprite, FrameNumber newFrame, color_t bgcolor);
|
||||
void copyFrame(Sprite* sprite, FrameNumber fromFrame, FrameNumber newFrame);
|
||||
void removeFrame(Sprite* sprite, FrameNumber frame);
|
||||
void setTotalFrames(Sprite* sprite, FrameNumber frames);
|
||||
@ -106,6 +106,7 @@ namespace app {
|
||||
void duplicateLayerBefore(Layer* sourceLayer, Layer* beforeLayer);
|
||||
|
||||
// Images stock API
|
||||
Cel* addImage(LayerImage* layer, FrameNumber frameNumber, Image* image);
|
||||
int addImageInStock(Sprite* sprite, Image* image);
|
||||
void removeImageFromStock(Sprite* sprite, int imageIndex);
|
||||
void replaceStockImage(Sprite* sprite, int imageIndex, Image* newImage);
|
||||
|
Loading…
Reference in New Issue
Block a user