mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-24 09:02:31 +00:00
Merge branch 'multiple_layer_visibility'
This commit is contained in:
commit
d0c1be871a
@ -8,9 +8,11 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "app/app.h"
|
||||||
#include "app/commands/command.h"
|
#include "app/commands/command.h"
|
||||||
#include "app/context_access.h"
|
#include "app/context_access.h"
|
||||||
#include "app/modules/gui.h"
|
#include "app/modules/gui.h"
|
||||||
|
#include "app/ui/timeline/timeline.h"
|
||||||
#include "doc/image.h"
|
#include "doc/image.h"
|
||||||
#include "doc/layer.h"
|
#include "doc/layer.h"
|
||||||
|
|
||||||
@ -45,16 +47,41 @@ bool LayerVisibilityCommand::onEnabled(Context* context)
|
|||||||
bool LayerVisibilityCommand::onChecked(Context* context)
|
bool LayerVisibilityCommand::onChecked(Context* context)
|
||||||
{
|
{
|
||||||
const ContextReader reader(context);
|
const ContextReader reader(context);
|
||||||
const Layer* layer = reader.layer();
|
SelectedLayers selLayers;
|
||||||
return (layer && layer->isVisible());
|
auto range = App::instance()->timeline()->range();
|
||||||
|
if (range.enabled()) {
|
||||||
|
selLayers = range.selectedLayers();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
selLayers.insert(const_cast<Layer*>(reader.layer()));
|
||||||
|
}
|
||||||
|
bool visible = false;
|
||||||
|
for (auto layer : selLayers) {
|
||||||
|
if (layer && layer->isVisible())
|
||||||
|
visible = true;
|
||||||
|
}
|
||||||
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayerVisibilityCommand::onExecute(Context* context)
|
void LayerVisibilityCommand::onExecute(Context* context)
|
||||||
{
|
{
|
||||||
ContextWriter writer(context);
|
ContextWriter writer(context);
|
||||||
Layer* layer = writer.layer();
|
SelectedLayers selLayers;
|
||||||
|
auto range = App::instance()->timeline()->range();
|
||||||
layer->setVisible(!layer->isVisible());
|
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());
|
update_screen_for_document(writer.document());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user