mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Fix locked layer not completely locked (fix #2181)
This commit is contained in:
parent
0ba2a8922b
commit
9c37ea41ed
@ -13,6 +13,7 @@ sprite_without_profile = The sprite doesn't contain a color profile.
|
||||
|
||||
[statusbar_tips]
|
||||
all_layers_are_locked = All selected layers are locked
|
||||
layer_locked = Layer '{0}' is locked
|
||||
|
||||
[alerts]
|
||||
applying_filter = FX<<Applying effect...||&Cancel
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/clipboard.h"
|
||||
#include "app/util/layer_utils.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/gcd.h"
|
||||
#include "base/pi.h"
|
||||
@ -298,6 +299,9 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
getTransformation(editor));
|
||||
|
||||
if (handle != NoHandle) {
|
||||
if (layer_is_locked(editor))
|
||||
return true;
|
||||
|
||||
// Re-catch the image
|
||||
m_pixelsMovement->catchImageAgain(
|
||||
editor->screenToEditor(msg->position()), handle);
|
||||
@ -311,6 +315,9 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
// right-click can be used to deselect/subtract selection, so we
|
||||
// should drop the selection in this later case.
|
||||
if (editor->isInsideSelection() && msg->left()) {
|
||||
if (layer_is_locked(editor))
|
||||
return true;
|
||||
|
||||
// In case that the user is pressing the copy-selection keyboard shortcut.
|
||||
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
|
||||
if ((customization) &&
|
||||
@ -532,9 +539,22 @@ void MovingPixelsState::onBeforeCommandExecution(CommandExecutionEvent& ev)
|
||||
if (!isActiveEditor())
|
||||
return;
|
||||
|
||||
if (layer_is_locked(m_editor) &&
|
||||
(command->id() == CommandId::Flip() ||
|
||||
command->id() == CommandId::Cut() ||
|
||||
command->id() == CommandId::Clear() ||
|
||||
command->id() == CommandId::Rotate())) {
|
||||
ev.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
// We don't need to drop the pixels if a MoveMaskCommand of Content is executed.
|
||||
if (MoveMaskCommand* moveMaskCmd = dynamic_cast<MoveMaskCommand*>(command)) {
|
||||
if (moveMaskCmd->getTarget() == MoveMaskCommand::Content) {
|
||||
if (layer_is_locked(m_editor)) {
|
||||
ev.cancel();
|
||||
return;
|
||||
}
|
||||
gfx::Point delta = moveMaskCmd->getMoveThing().getDelta(UIContext::instance());
|
||||
// Verify Shift condition of the MoveMaskCommand (i.e. wrap = true)
|
||||
if (moveMaskCmd->isWrap()) {
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/doc_range.h"
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/ini_file.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/tools/active_tool.h"
|
||||
@ -47,6 +48,7 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui/timeline/timeline.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/layer_utils.h"
|
||||
#include "app/util/new_image_from_mask.h"
|
||||
#include "app/util/readable_time.h"
|
||||
#include "base/bind.h"
|
||||
@ -196,7 +198,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
}
|
||||
else if (!layer->isMovable() || !layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, fmt::format("Layer '{}' is locked", layer->name()));
|
||||
1000, fmt::format(Strings::statusbar_tips_layer_locked(), layer->name()));
|
||||
}
|
||||
else {
|
||||
MovingCelCollect collect(editor, layer);
|
||||
@ -299,12 +301,6 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
int x, y, opacity;
|
||||
Image* image = site.image(&x, &y, &opacity);
|
||||
if (layer && image) {
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, fmt::format("Layer '{}' is locked", layer->name()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Change to MovingPixelsState
|
||||
transformSelection(editor, msg, handle);
|
||||
}
|
||||
@ -320,12 +316,6 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
|
||||
// Move selected pixels
|
||||
if (layer && editor->canStartMovingSelectionPixels() && msg->left()) {
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, fmt::format("Layer '{}' is locked", layer->name()));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Change to MovingPixelsState
|
||||
transformSelection(editor, msg, MovePixelsHandle);
|
||||
return true;
|
||||
@ -747,6 +737,9 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
|
||||
return;
|
||||
}
|
||||
|
||||
if (layer_is_locked(editor))
|
||||
return;
|
||||
|
||||
try {
|
||||
// Clear brush preview, as the extra cel will be replaced with the
|
||||
// transformed image.
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "app/util/expand_cel_canvas.h"
|
||||
#include "app/util/layer_utils.h"
|
||||
#include "doc/cel.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/layer.h"
|
||||
@ -734,9 +735,7 @@ tools::ToolLoop* create_tool_loop(
|
||||
return nullptr;
|
||||
}
|
||||
// If the active layer is read-only.
|
||||
else if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, fmt::format("Layer '{}' is locked", layer->name()));
|
||||
else if (layer_is_locked(editor)) {
|
||||
return nullptr;
|
||||
}
|
||||
// If the active layer is reference.
|
||||
|
@ -6,8 +6,12 @@
|
||||
|
||||
#include "app/util/layer_utils.h"
|
||||
|
||||
#include "app/i18n/strings.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui/status_bar.h"
|
||||
#include "doc/layer.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
namespace app {
|
||||
|
||||
@ -38,4 +42,18 @@ Layer* candidate_if_layer_is_deleted(
|
||||
return const_cast<Layer*>(layerToSelect);
|
||||
}
|
||||
|
||||
bool layer_is_locked(Editor* editor)
|
||||
{
|
||||
Layer* layer = editor->layer();
|
||||
if (layer && !layer->isEditableHierarchy()) {
|
||||
#ifdef ENABLE_UI
|
||||
if (auto statusBar = StatusBar::instance())
|
||||
statusBar->showTip(
|
||||
1000, fmt::format(Strings::statusbar_tips_layer_locked(), layer->name()));
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -14,6 +14,8 @@ namespace doc {
|
||||
|
||||
namespace app {
|
||||
|
||||
class Editor;
|
||||
|
||||
// Calculates a possible candidate to be selected in case that we
|
||||
// have a specific "selectedLayer" and are going to delete the given
|
||||
// "layerToDelete".
|
||||
@ -21,6 +23,10 @@ namespace app {
|
||||
const doc::Layer* selectedLayer,
|
||||
const doc::Layer* layerToDelete);
|
||||
|
||||
// True if the active layer is locked (itself or its hierarchy),
|
||||
// also, it sends a tip to the user 'Layer ... is locked'
|
||||
bool layer_is_locked(Editor* editor);
|
||||
|
||||
} // namespace app
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user