File indexing completed on 2024-12-22 04:10:03
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Stuart Dickson <stuartmd@kogmbh.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "kis_set_layer_style_command.h" 0007 0008 #include "kis_selection_mask.h" 0009 #include "kis_layer.h" 0010 #include "kis_abstract_projection_plane.h" 0011 #include "kis_psd_layer_style.h" 0012 0013 0014 KisSetLayerStyleCommand::KisSetLayerStyleCommand(KisLayerSP layer, KisPSDLayerStyleSP oldStyle, KisPSDLayerStyleSP newStyle, KUndo2Command *parent) 0015 : KUndo2Command(kundo2_i18n("Change Layer Style"), parent), 0016 m_layer(layer), 0017 m_oldStyle(oldStyle), 0018 m_newStyle(newStyle) 0019 { 0020 } 0021 0022 void KisSetLayerStyleCommand::redo() 0023 { 0024 updateLayerStyle(m_layer, m_newStyle); 0025 } 0026 0027 void KisSetLayerStyleCommand::undo() 0028 { 0029 updateLayerStyle(m_layer, m_oldStyle); 0030 } 0031 0032 void KisSetLayerStyleCommand::updateLayerStyle(KisLayerSP layer, KisPSDLayerStyleSP style) 0033 { 0034 QRect oldDirtyRect = layer->projectionPlane()->changeRect(layer->extent(), KisLayer::N_FILTHY); 0035 layer->setLayerStyle(style); 0036 QRect newDirtyRect = layer->projectionPlane()->changeRect(layer->extent(), KisLayer::N_FILTHY); 0037 0038 layer->setDirty(newDirtyRect | oldDirtyRect); 0039 }