mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-06 06:50:07 +00:00
Enhancement new layer below (issue #1822)
This commit is contained in:
parent
03d363d1a6
commit
93d0b94929
@ -65,6 +65,9 @@
|
||||
<key command="LayerVisibility" shortcut="Shift+X" />
|
||||
<key command="OpenGroup" shortcut="Shift+E" />
|
||||
<key command="NewLayer" shortcut="Shift+N" />
|
||||
<key command="NewLayer" shortcut="Shift+Space+N">
|
||||
<param name="before" value="true" />
|
||||
</key>
|
||||
<key command="NewLayer" shortcut="Alt+Shift+N">
|
||||
<param name="group" value="true" />
|
||||
</key>
|
||||
@ -740,7 +743,7 @@
|
||||
<item command="MergeDownLayer" text="@.layer_merge_down" />
|
||||
<item command="FlattenLayers" text="@.layer_flatten" />
|
||||
<separator />
|
||||
<item command="NewLayer" text="@.layer_add_reference_layer" >
|
||||
<item command="NewLayer" text="@.layer_add_reference_layer">
|
||||
<param name="reference" value="true" />
|
||||
<param name="from-file" value="true" />
|
||||
</item>
|
||||
@ -906,7 +909,7 @@
|
||||
<item command="LayerProperties" text="@main_menu.layer_properties" />
|
||||
<separator />
|
||||
<item command="NewLayer" text="@main_menu.layer_new_layer" />
|
||||
<item command="NewLayer" text="@main_menu.layer_new_group" >
|
||||
<item command="NewLayer" text="@main_menu.layer_new_group">
|
||||
<param name="group" value="true" />
|
||||
</item>
|
||||
<item command="RemoveLayer" text="@main_menu.layer_delete_layer" />
|
||||
|
@ -307,6 +307,9 @@ NewFrame_DuplicateCels = Duplicate Linked Cels
|
||||
NewFrame_DuplicateCelsBlock = Duplicate Cels
|
||||
NewFrameTag = New Frame Tag
|
||||
NewLayer = New Layer
|
||||
NewLayer_BeforeActiveLayer = New Layer Below
|
||||
NewLayer_Group = New Group
|
||||
NewLayer_ReferenceLayer = New Reference Layer
|
||||
NewSpriteFromSelection = New Sprite From Selection
|
||||
OpenBrowser = Open Browser
|
||||
OpenFile = Open Sprite
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_api.h"
|
||||
#include "app/find_widget.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/load_widget.h"
|
||||
#include "app/modules/gui.h"
|
||||
#include "app/tx.h"
|
||||
@ -42,7 +43,7 @@ using namespace ui;
|
||||
class NewLayerCommand : public Command {
|
||||
public:
|
||||
enum class Type { Layer, Group, ReferenceLayer };
|
||||
enum class Place { AfterActiveLayer, Top };
|
||||
enum class Place { AfterActiveLayer, BeforeActiveLayer, Top };
|
||||
|
||||
NewLayerCommand();
|
||||
Command* clone() const override { return new NewLayerCommand(*this); }
|
||||
@ -51,6 +52,7 @@ protected:
|
||||
void onLoadParams(const Params& params) override;
|
||||
bool onEnabled(Context* context) override;
|
||||
void onExecute(Context* context) override;
|
||||
std::string onGetFriendlyName() const override;
|
||||
|
||||
private:
|
||||
std::string getUniqueLayerName(const Sprite* sprite) const;
|
||||
@ -87,6 +89,8 @@ void NewLayerCommand::onLoadParams(const Params& params)
|
||||
m_place = Place::AfterActiveLayer;
|
||||
if (params.get("top") == "true")
|
||||
m_place = Place::Top;
|
||||
else if (params.get("before") == "true")
|
||||
m_place = Place::BeforeActiveLayer;
|
||||
}
|
||||
|
||||
bool NewLayerCommand::onEnabled(Context* context)
|
||||
@ -186,6 +190,8 @@ void NewLayerCommand::onExecute(Context* context)
|
||||
switch (m_type) {
|
||||
case Type::Layer:
|
||||
layer = api.newLayer(parent, name);
|
||||
if (m_place == Place::BeforeActiveLayer)
|
||||
api.restackLayerBefore(layer, parent, activeLayer);
|
||||
break;
|
||||
case Type::Group:
|
||||
layer = api.newGroup(parent, name);
|
||||
@ -324,6 +330,28 @@ void NewLayerCommand::onExecute(Context* context)
|
||||
App::instance()->mainWindow()->popTimeline();
|
||||
}
|
||||
|
||||
std::string NewLayerCommand::onGetFriendlyName() const
|
||||
{
|
||||
std::string text;
|
||||
|
||||
switch (m_type) {
|
||||
case Type::Layer:
|
||||
if (m_place == Place::BeforeActiveLayer)
|
||||
text = Strings::commands_NewLayer_BeforeActiveLayer();
|
||||
else
|
||||
text = Strings::commands_NewLayer();
|
||||
break;
|
||||
case Type::Group:
|
||||
text = Strings::commands_NewLayer_Group();
|
||||
break;
|
||||
case Type::ReferenceLayer:
|
||||
text = Strings::commands_NewLayer_ReferenceLayer();
|
||||
break;
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
std::string NewLayerCommand::getUniqueLayerName(const Sprite* sprite) const
|
||||
{
|
||||
char buf[1024];
|
||||
|
Loading…
Reference in New Issue
Block a user