mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Fix some commands/editor states to check parent group editable/visible state too
This commit is contained in:
parent
32faa33353
commit
ac20d1edfc
@ -60,20 +60,21 @@ void ClearCelCommand::onExecute(Context* context)
|
||||
if (!layer->isImage())
|
||||
continue;
|
||||
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
nonEditableLayers = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
LayerImage* layerImage = static_cast<LayerImage*>(layer);
|
||||
|
||||
for (frame_t frame : site->selectedFrames().reversed()) {
|
||||
if (layerImage->cel(frame)) {
|
||||
if (layerImage->isEditable())
|
||||
document->getApi(transaction).clearCel(layerImage, frame);
|
||||
else
|
||||
nonEditableLayers = true;
|
||||
}
|
||||
if (layerImage->cel(frame))
|
||||
document->getApi(transaction).clearCel(layerImage, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (writer.cel()) {
|
||||
if (writer.layer()->isEditable())
|
||||
if (writer.layer()->isEditableHierarchy())
|
||||
document->getApi(transaction).clearCel(writer.cel());
|
||||
else
|
||||
nonEditableLayers = true;
|
||||
|
@ -61,13 +61,12 @@ void LinkCelsCommand::onExecute(Context* context)
|
||||
return;
|
||||
|
||||
Transaction transaction(writer.context(), friendlyName());
|
||||
Sprite* sprite = writer.sprite();
|
||||
|
||||
for (Layer* layer : site.selectedLayers()) {
|
||||
if (!layer->isImage())
|
||||
continue;
|
||||
|
||||
if (!layer->isEditable()) {
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
nonEditableLayers = true;
|
||||
continue;
|
||||
}
|
||||
|
@ -59,23 +59,24 @@ void UnlinkCelCommand::onExecute(Context* context)
|
||||
if (!layer->isImage())
|
||||
continue;
|
||||
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
nonEditableLayers = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
LayerImage* layerImage = static_cast<LayerImage*>(layer);
|
||||
|
||||
for (frame_t frame : site->selectedFrames().reversed()) {
|
||||
Cel* cel = layerImage->cel(frame);
|
||||
if (cel && cel->links()) {
|
||||
if (layerImage->isEditable())
|
||||
transaction.execute(new cmd::UnlinkCel(cel));
|
||||
else
|
||||
nonEditableLayers = true;
|
||||
}
|
||||
if (cel && cel->links())
|
||||
transaction.execute(new cmd::UnlinkCel(cel));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
Cel* cel = writer.cel();
|
||||
if (cel && cel->links()) {
|
||||
if (cel->layer()->isEditable())
|
||||
if (cel->layer()->isEditableHierarchy())
|
||||
transaction.execute(new cmd::UnlinkCel(writer.cel()));
|
||||
else
|
||||
nonEditableLayers = true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2001-2015 David Capello
|
||||
// Copyright (C) 2001-2016 David Capello
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License version 2 as
|
||||
@ -88,10 +88,10 @@ void ContextFlags::updateFlagsFromSite(const Site& site)
|
||||
if (layer->isBackground())
|
||||
m_flags |= ActiveLayerIsBackground;
|
||||
|
||||
if (layer->isVisible())
|
||||
if (layer->isVisibleHierarchy())
|
||||
m_flags |= ActiveLayerIsVisible;
|
||||
|
||||
if (layer->isEditable())
|
||||
if (layer->isEditableHierarchy())
|
||||
m_flags |= ActiveLayerIsEditable;
|
||||
|
||||
if (layer->isImage()) {
|
||||
|
@ -1442,8 +1442,8 @@ bool Editor::canDraw()
|
||||
{
|
||||
return (m_layer != NULL &&
|
||||
m_layer->isImage() &&
|
||||
m_layer->isVisible() &&
|
||||
m_layer->isEditable());
|
||||
m_layer->isVisibleHierarchy() &&
|
||||
m_layer->isEditableHierarchy());
|
||||
}
|
||||
|
||||
bool Editor::isInsideSelection()
|
||||
|
@ -209,11 +209,11 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
StatusBar::instance()->showTip(1000,
|
||||
"The background layer cannot be moved");
|
||||
}
|
||||
else if (!layer->isVisible()) {
|
||||
else if (!layer->isVisibleHierarchy()) {
|
||||
StatusBar::instance()->showTip(1000,
|
||||
"Layer '%s' is hidden", layer->name().c_str());
|
||||
}
|
||||
else if (!layer->isMovable() || !layer->isEditable()) {
|
||||
else if (!layer->isMovable() || !layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(1000,
|
||||
"Layer '%s' is locked", layer->name().c_str());
|
||||
}
|
||||
@ -253,7 +253,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
int x, y, opacity;
|
||||
Image* image = site.image(&x, &y, &opacity);
|
||||
if (layer && image) {
|
||||
if (!layer->isEditable()) {
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(1000,
|
||||
"Layer '%s' is locked", layer->name().c_str());
|
||||
return true;
|
||||
@ -268,7 +268,7 @@ bool StandbyState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
|
||||
// Move selected pixels
|
||||
if (layer && editor->isInsideSelection() && msg->left()) {
|
||||
if (!layer->isEditable()) {
|
||||
if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(1000,
|
||||
"Layer '%s' is locked", layer->name().c_str());
|
||||
return true;
|
||||
|
@ -497,13 +497,13 @@ tools::ToolLoop* create_tool_loop(Editor* editor, Context* context)
|
||||
1000, "There is no active layer");
|
||||
return nullptr;
|
||||
}
|
||||
else if (!layer->isVisible()) {
|
||||
else if (!layer->isVisibleHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, "Layer '%s' is hidden", layer->name().c_str());
|
||||
return nullptr;
|
||||
}
|
||||
// If the active layer is read-only.
|
||||
else if (!layer->isEditable()) {
|
||||
else if (!layer->isEditableHierarchy()) {
|
||||
StatusBar::instance()->showTip(
|
||||
1000, "Layer '%s' is locked", layer->name().c_str());
|
||||
return nullptr;
|
||||
@ -615,8 +615,8 @@ tools::ToolLoop* create_tool_loop_preview(
|
||||
|
||||
Layer* layer = editor->layer();
|
||||
if (!layer ||
|
||||
!layer->isVisible() ||
|
||||
!layer->isEditable()) {
|
||||
!layer->isVisibleHierarchy() ||
|
||||
!layer->isEditableHierarchy()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,28 @@ Layer* Layer::getNextInWholeHierarchy() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Layer::isVisibleHierarchy() const
|
||||
{
|
||||
const Layer* layer = this;
|
||||
while (layer) {
|
||||
if (!layer->isVisible())
|
||||
return false;
|
||||
layer = layer->parent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Layer::isEditableHierarchy() const
|
||||
{
|
||||
const Layer* layer = this;
|
||||
while (layer) {
|
||||
if (!layer->isEditable())
|
||||
return false;
|
||||
layer = layer->parent();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Cel* Layer::cel(frame_t frame) const
|
||||
{
|
||||
return nullptr;
|
||||
|
@ -76,6 +76,9 @@ namespace doc {
|
||||
bool isCollapsed() const { return hasFlags(LayerFlags::Collapsed); }
|
||||
bool isExpanded() const { return !hasFlags(LayerFlags::Collapsed); }
|
||||
|
||||
bool isVisibleHierarchy() const;
|
||||
bool isEditableHierarchy() const;
|
||||
|
||||
void setBackground(bool state) { switchFlags(LayerFlags::Background, state); }
|
||||
void setVisible (bool state) { switchFlags(LayerFlags::Visible, state); }
|
||||
void setEditable (bool state) { switchFlags(LayerFlags::Editable, state); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user