Change opacity to 255 for layers and cels on "Background from Layer"

This commit is contained in:
David Capello 2015-08-21 11:09:02 -03:00
parent b9af6c3b02
commit be0a944cd8
2 changed files with 12 additions and 0 deletions

View File

@ -15,6 +15,7 @@
#include "app/cmd/configure_background.h" #include "app/cmd/configure_background.h"
#include "app/cmd/copy_rect.h" #include "app/cmd/copy_rect.h"
#include "app/cmd/replace_image.h" #include "app/cmd/replace_image.h"
#include "app/cmd/set_cel_opacity.h"
#include "app/cmd/set_cel_position.h" #include "app/cmd/set_cel_position.h"
#include "app/document.h" #include "app/document.h"
#include "doc/cel.h" #include "doc/cel.h"
@ -68,6 +69,10 @@ void BackgroundFromLayer::onExecute()
// now we have to copy the new image (bg_image) to the cel... // now we have to copy the new image (bg_image) to the cel...
executeAndAdd(new cmd::SetCelPosition(cel, 0, 0)); executeAndAdd(new cmd::SetCelPosition(cel, 0, 0));
// change opacity to 255
if (cel->opacity() < 255)
executeAndAdd(new cmd::SetCelOpacity(cel, 255));
// same size of cel-image and bg-image // same size of cel-image and bg-image
if (bg_image->width() == cel_image->width() && if (bg_image->width() == cel_image->width() &&
bg_image->height() == cel_image->height()) { bg_image->height() == cel_image->height()) {

View File

@ -14,6 +14,7 @@
#include "app/cmd/move_layer.h" #include "app/cmd/move_layer.h"
#include "app/cmd/set_layer_flags.h" #include "app/cmd/set_layer_flags.h"
#include "app/cmd/set_layer_name.h" #include "app/cmd/set_layer_name.h"
#include "app/cmd/set_layer_opacity.h"
namespace app { namespace app {
namespace cmd { namespace cmd {
@ -26,6 +27,12 @@ ConfigureBackground::ConfigureBackground(Layer* layer)
add(new cmd::SetLayerFlags(layer, newFlags)); add(new cmd::SetLayerFlags(layer, newFlags));
add(new cmd::SetLayerName(layer, "Background")); add(new cmd::SetLayerName(layer, "Background"));
if (layer->isImage() &&
static_cast<LayerImage*>(layer)->opacity() < 255) {
add(new cmd::SetLayerOpacity(static_cast<LayerImage*>(layer), 255));
}
add(new cmd::MoveLayer(layer, nullptr)); add(new cmd::MoveLayer(layer, nullptr));
} }