From cfd46a4ef8a2f651af3154ac6dbf6ea11d087e2b Mon Sep 17 00:00:00 2001 From: Chris Hill Date: Tue, 6 Jun 2017 08:48:27 -0700 Subject: [PATCH 1/2] Support hide/show multiple layers on Layer > Visible (Shift+X) --- src/app/commands/cmd_layer_visibility.cpp | 37 ++++++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/app/commands/cmd_layer_visibility.cpp b/src/app/commands/cmd_layer_visibility.cpp index 447367488..40891d9c1 100644 --- a/src/app/commands/cmd_layer_visibility.cpp +++ b/src/app/commands/cmd_layer_visibility.cpp @@ -8,9 +8,11 @@ #include "config.h" #endif +#include "app/app.h" #include "app/commands/command.h" #include "app/context_access.h" #include "app/modules/gui.h" +#include "app/ui/timeline/timeline.h" #include "doc/image.h" #include "doc/layer.h" @@ -45,16 +47,41 @@ bool LayerVisibilityCommand::onEnabled(Context* context) bool LayerVisibilityCommand::onChecked(Context* context) { const ContextReader reader(context); - const Layer* layer = reader.layer(); - return (layer && layer->isVisible()); + SelectedLayers selLayers; + auto range = App::instance()->timeline()->range(); + if (range.enabled()) { + selLayers = range.selectedLayers(); + } + else { + selLayers.insert(const_cast(reader.layer())); + } + bool visible = false; + for (auto layer : selLayers) { + if(layer && layer->isVisible()) + visible = true; + } + return visible; } void LayerVisibilityCommand::onExecute(Context* context) { ContextWriter writer(context); - Layer* layer = writer.layer(); - - layer->setVisible(!layer->isVisible()); + SelectedLayers selLayers; + auto range = App::instance()->timeline()->range(); + if (range.enabled()) { + selLayers = range.selectedLayers(); + } + else { + selLayers.insert(writer.layer()); + } + bool anyVisible = false; + for (auto layer : selLayers) { + if(layer->isVisible()) + anyVisible = true; + } + for(auto layer : selLayers) { + layer->setVisible(!anyVisible); + } update_screen_for_document(writer.document()); } From 4cbe5a1079e465c27acffd58c1c4837b98953c0f Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 12 Jun 2017 14:55:38 -0300 Subject: [PATCH 2/2] Minor formatting --- src/app/commands/cmd_layer_visibility.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/commands/cmd_layer_visibility.cpp b/src/app/commands/cmd_layer_visibility.cpp index 40891d9c1..a21bd65a6 100644 --- a/src/app/commands/cmd_layer_visibility.cpp +++ b/src/app/commands/cmd_layer_visibility.cpp @@ -57,7 +57,7 @@ bool LayerVisibilityCommand::onChecked(Context* context) } bool visible = false; for (auto layer : selLayers) { - if(layer && layer->isVisible()) + if (layer && layer->isVisible()) visible = true; } return visible; @@ -76,10 +76,10 @@ void LayerVisibilityCommand::onExecute(Context* context) } bool anyVisible = false; for (auto layer : selLayers) { - if(layer->isVisible()) + if (layer->isVisible()) anyVisible = true; } - for(auto layer : selLayers) { + for (auto layer : selLayers) { layer->setVisible(!anyVisible); }