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/configure_background.h"
12
13#include "app/cmd/move_layer.h"
14#include "app/cmd/set_layer_flags.h"
15#include "app/cmd/set_layer_name.h"
16#include "app/cmd/set_layer_opacity.h"
17#include "doc/sprite.h"
18
19namespace app {
20namespace cmd {
21
22ConfigureBackground::ConfigureBackground(Layer* layer)
23{
24 // Add "Background" and "LockMove" flags
25 LayerFlags newFlags = LayerFlags(int(layer->flags())
26 | int(LayerFlags::BackgroundLayerFlags));
27
28 add(new cmd::SetLayerFlags(layer, newFlags));
29 add(new cmd::SetLayerName(layer, "Background"));
30
31 if (layer->isImage() &&
32 static_cast<LayerImage*>(layer)->opacity() < 255) {
33 add(new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), 255));
34 }
35
36 add(new cmd::MoveLayer(layer, layer->sprite()->root(), nullptr));
37}
38
39} // namespace cmd
40} // namespace app
41