mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-02 04:59:24 +00:00
Timeline: Add support to delete several cels at once
This commit is contained in:
parent
ca7f6a055f
commit
400a2c1993
@ -442,7 +442,7 @@
|
||||
<menu id="cel_popup">
|
||||
<item command="CelProperties" text="&Properties..." />
|
||||
<separator />
|
||||
<item command="Clear" text="&Clear" />
|
||||
<item command="RemoveCel" text="&Clear" />
|
||||
</menu>
|
||||
|
||||
<menu id="cel_movement_popup">
|
||||
|
@ -22,11 +22,14 @@
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/document_location.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "app/ui/timeline.h"
|
||||
#include "app/undo_transaction.h"
|
||||
#include "raster/layer.h"
|
||||
#include "raster/mask.h"
|
||||
@ -61,6 +64,17 @@ bool ClearCommand::onEnabled(Context* context)
|
||||
|
||||
void ClearCommand::onExecute(Context* context)
|
||||
{
|
||||
// Clear of several frames is handled with RemoveCel command.
|
||||
Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
|
||||
if (range.enabled()) {
|
||||
Command* subCommand = CommandsModule::instance()
|
||||
->getCommandByName(CommandId::RemoveCel);
|
||||
context->executeCommand(subCommand);
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO add support to clear the mask in the selected range of frames.
|
||||
|
||||
ContextWriter writer(context);
|
||||
Document* document = writer.document();
|
||||
bool visibleMask = document->isMaskVisible();
|
||||
|
@ -20,10 +20,13 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/document_api.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/ui/main_window.h"
|
||||
#include "app/ui/timeline.h"
|
||||
#include "app/undo_transaction.h"
|
||||
#include "raster/cel.h"
|
||||
#include "raster/layer.h"
|
||||
@ -61,10 +64,38 @@ void RemoveCelCommand::onExecute(Context* context)
|
||||
{
|
||||
ContextWriter writer(context);
|
||||
Document* document(writer.document());
|
||||
Cel* cel = writer.cel();
|
||||
{
|
||||
UndoTransaction undoTransaction(writer.context(), "Remove Cel");
|
||||
document->getApi().removeCel(static_cast<LayerImage*>(writer.layer()), cel);
|
||||
|
||||
// TODO the range of selected frames should be in the DocumentLocation.
|
||||
Timeline::Range range = App::instance()->getMainWindow()->getTimeline()->range();
|
||||
if (range.enabled()) {
|
||||
Sprite* sprite = writer.sprite();
|
||||
|
||||
// TODO indexes in timeline are inverted!! fix that for a future release
|
||||
for (LayerIndex layerIdx = sprite->countLayers() - LayerIndex(range.layerBegin()+1),
|
||||
end = sprite->countLayers() - LayerIndex(range.layerEnd()+2);
|
||||
layerIdx != end; --layerIdx) {
|
||||
Layer* layer = sprite->indexToLayer(layerIdx);
|
||||
if (!layer->isImage())
|
||||
continue;
|
||||
|
||||
LayerImage* layerImage = static_cast<LayerImage*>(layer);
|
||||
|
||||
for (FrameNumber frame = range.frameEnd(),
|
||||
begin = range.frameBegin().previous();
|
||||
frame != begin;
|
||||
frame = frame.previous()) {
|
||||
Cel* cel = layerImage->getCel(frame);
|
||||
if (cel)
|
||||
document->getApi().removeCel(layerImage, cel);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
document->getApi().removeCel(static_cast<LayerImage*>(writer.layer()), writer.cel());
|
||||
}
|
||||
|
||||
undoTransaction.commit();
|
||||
}
|
||||
update_screen_for_document(document);
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/app.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context_access.h"
|
||||
|
@ -359,11 +359,14 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
const DocumentReader document(const_cast<Document*>(m_document));
|
||||
const Sprite* sprite = document->getSprite();
|
||||
int old_layer = getLayerIndex(m_layer);
|
||||
bool selectCel = (mouseMsg->left()
|
||||
|| !isLayerActive(m_clk_layer)
|
||||
|| !isFrameActive(m_clk_frame));
|
||||
FrameNumber old_frame = m_frame;
|
||||
|
||||
// Select the new clicked-part.
|
||||
if (old_layer != m_clk_layer ||
|
||||
old_frame != m_clk_frame) {
|
||||
if (old_layer != m_clk_layer
|
||||
|| old_frame != m_clk_frame) {
|
||||
setLayer(m_layers[m_clk_layer]);
|
||||
setFrame(m_clk_frame);
|
||||
invalidate();
|
||||
@ -376,7 +379,8 @@ bool Timeline::onProcessMessage(Message* msg)
|
||||
m_state = STATE_MOVING_CEL;
|
||||
else {
|
||||
m_state = STATE_SELECTING_CELS;
|
||||
m_range.startRange(m_clk_layer, m_clk_frame);
|
||||
if (selectCel)
|
||||
m_range.startRange(m_clk_layer, m_clk_frame);
|
||||
invalidate();
|
||||
}
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user