1// Aseprite
2// Copyright (C) 2001-2016 David Capello
3//
4// This program is distributed under the terms of
5// the End-User License Agreement for Aseprite.
6
7#ifdef HAVE_CONFIG_H
8#include "config.h"
9#endif
10
11#include "app/cmd/layer_from_background.h"
12
13#include "app/cmd/set_layer_flags.h"
14#include "app/cmd/set_layer_name.h"
15#include "doc/layer.h"
16#include "doc/sprite.h"
17
18namespace app {
19namespace cmd {
20
21LayerFromBackground::LayerFromBackground(Layer* layer)
22{
23 ASSERT(layer != NULL);
24 ASSERT(layer->isVisible());
25 ASSERT(layer->isEditable());
26 ASSERT(layer->isBackground());
27 ASSERT(!layer->isReference());
28 ASSERT(layer->sprite() != NULL);
29 ASSERT(layer->sprite()->backgroundLayer() != NULL);
30
31 // Remove "Background" and "LockMove" flags
32 LayerFlags newFlags = LayerFlags(int(layer->flags())
33 & ~int(LayerFlags::BackgroundLayerFlags));
34
35 add(new cmd::SetLayerFlags(layer, newFlags));
36 add(new cmd::SetLayerName(layer, "Layer 0"));
37}
38
39} // namespace cmd
40} // namespace app
41