mirror of https://github.com/aseprite/aseprite.git
Add possibility to duplicate the current cel only (Alt+M)
This commit is contained in:
parent
5ef4cb1460
commit
f475378d38
|
@ -68,6 +68,9 @@
|
||||||
<key command="NewFrame" shortcut="Alt+B">
|
<key command="NewFrame" shortcut="Alt+B">
|
||||||
<param name="content" value="empty" />
|
<param name="content" value="empty" />
|
||||||
</key>
|
</key>
|
||||||
|
<key command="NewFrame" shortcut="Alt+M">
|
||||||
|
<param name="content" value="cel" />
|
||||||
|
</key>
|
||||||
<key command="RemoveFrame" shortcut="Alt+C" />
|
<key command="RemoveFrame" shortcut="Alt+C" />
|
||||||
<key command="FrameProperties" shortcut="P">
|
<key command="FrameProperties" shortcut="P">
|
||||||
<param name="frame" value="current" />
|
<param name="frame" value="current" />
|
||||||
|
@ -520,6 +523,9 @@
|
||||||
<item command="NewFrame" text="New &Empty Frame">
|
<item command="NewFrame" text="New &Empty Frame">
|
||||||
<param name="content" value="empty" />
|
<param name="content" value="empty" />
|
||||||
</item>
|
</item>
|
||||||
|
<item command="NewFrame" text="Copy &Cel in Next Frame">
|
||||||
|
<param name="content" value="cel" />
|
||||||
|
</item>
|
||||||
<item command="RemoveFrame" text="&Remove Frame" />
|
<item command="RemoveFrame" text="&Remove Frame" />
|
||||||
<separator />
|
<separator />
|
||||||
<menu text="&Tags">
|
<menu text="&Tags">
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
#include "app/context_access.h"
|
#include "app/context_access.h"
|
||||||
#include "app/document_api.h"
|
#include "app/document_api.h"
|
||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
|
#include "app/transaction.h"
|
||||||
|
#include "app/ui/document_view.h"
|
||||||
|
#include "app/ui/editor/editor.h"
|
||||||
#include "app/ui/main_window.h"
|
#include "app/ui/main_window.h"
|
||||||
#include "app/ui/status_bar.h"
|
#include "app/ui/status_bar.h"
|
||||||
#include "app/transaction.h"
|
#include "app/ui_context.h"
|
||||||
#include "doc/cel.h"
|
#include "doc/cel.h"
|
||||||
#include "doc/image.h"
|
#include "doc/image.h"
|
||||||
#include "doc/layer.h"
|
#include "doc/layer.h"
|
||||||
|
@ -32,7 +35,11 @@ namespace app {
|
||||||
|
|
||||||
class NewFrameCommand : public Command {
|
class NewFrameCommand : public Command {
|
||||||
public:
|
public:
|
||||||
enum class Content { CurrentFrame, EmptyFrame };
|
enum class Content {
|
||||||
|
DUPLICATE_FRAME,
|
||||||
|
NEW_EMPTY_FRAME,
|
||||||
|
DUPLICATE_CEL
|
||||||
|
};
|
||||||
|
|
||||||
NewFrameCommand();
|
NewFrameCommand();
|
||||||
Command* clone() const override { return new NewFrameCommand(*this); }
|
Command* clone() const override { return new NewFrameCommand(*this); }
|
||||||
|
@ -56,11 +63,16 @@ NewFrameCommand::NewFrameCommand()
|
||||||
|
|
||||||
void NewFrameCommand::onLoadParams(const Params& params)
|
void NewFrameCommand::onLoadParams(const Params& params)
|
||||||
{
|
{
|
||||||
m_content = Content::CurrentFrame;
|
m_content = Content::DUPLICATE_FRAME;
|
||||||
|
|
||||||
std::string content = params.get("content");
|
std::string content = params.get("content");
|
||||||
if (content == "current") m_content = Content::CurrentFrame;
|
if (content == "current" ||
|
||||||
else if (content == "empty") m_content = Content::EmptyFrame;
|
content == "frame")
|
||||||
|
m_content = Content::DUPLICATE_FRAME;
|
||||||
|
else if (content == "empty")
|
||||||
|
m_content = Content::NEW_EMPTY_FRAME;
|
||||||
|
else if (content == "cel")
|
||||||
|
m_content = Content::DUPLICATE_CEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewFrameCommand::onEnabled(Context* context)
|
bool NewFrameCommand::onEnabled(Context* context)
|
||||||
|
@ -79,12 +91,23 @@ void NewFrameCommand::onExecute(Context* context)
|
||||||
DocumentApi api = document->getApi(transaction);
|
DocumentApi api = document->getApi(transaction);
|
||||||
|
|
||||||
switch (m_content) {
|
switch (m_content) {
|
||||||
case Content::CurrentFrame:
|
case Content::DUPLICATE_FRAME:
|
||||||
api.addFrame(sprite, writer.frame()+1);
|
api.addFrame(sprite, writer.frame()+1);
|
||||||
break;
|
break;
|
||||||
case Content::EmptyFrame:
|
case Content::NEW_EMPTY_FRAME:
|
||||||
api.addEmptyFrame(sprite, writer.frame()+1);
|
api.addEmptyFrame(sprite, writer.frame()+1);
|
||||||
break;
|
break;
|
||||||
|
case Content::DUPLICATE_CEL:
|
||||||
|
api.copyCel(
|
||||||
|
static_cast<LayerImage*>(writer.layer()), writer.frame(),
|
||||||
|
static_cast<LayerImage*>(writer.layer()), writer.frame()+1);
|
||||||
|
|
||||||
|
// TODO should we use DocumentObserver?
|
||||||
|
if (UIContext::instance() == context) {
|
||||||
|
if (DocumentView* view = UIContext::instance()->activeView())
|
||||||
|
view->getEditor()->setFrame(writer.frame()+1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
@ -104,11 +127,14 @@ std::string NewFrameCommand::onGetFriendlyName() const
|
||||||
std::string text = "New Frame";
|
std::string text = "New Frame";
|
||||||
|
|
||||||
switch (m_content) {
|
switch (m_content) {
|
||||||
case Content::CurrentFrame:
|
case Content::DUPLICATE_FRAME:
|
||||||
text = "New Frame (duplicated)";
|
text = "New Frame";
|
||||||
break;
|
break;
|
||||||
case Content::EmptyFrame:
|
case Content::NEW_EMPTY_FRAME:
|
||||||
text = "New Frame (empty)";
|
text = "New Empty Frame";
|
||||||
|
break;
|
||||||
|
case Content::DUPLICATE_CEL:
|
||||||
|
text = "Copy Cel into Next Frame";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue