Commit 06803bed authored by Boudewijn Rempt's avatar Boudewijn Rempt

Pass the layerstyle object from the layer to the dialog

Now all we need to do is fill in the dialog from the settings and save
the settings on closing the dialog. Then we can load and save the ASL
files in the .kra file and import/export to PSD -- and finally we _just_
need to apply the effects to the layer during recomposition!

Easy-peasy!
parent e4b2bdaf
......@@ -44,6 +44,7 @@
#include "kis_clone_layer.h"
#include "kis_psd_layer_style.h"
class KisSafeProjection {
public:
......@@ -114,6 +115,7 @@ public:
KisMetaData::Store* metaDataStore;
KisSafeProjection safeProjection;
KisCloneLayersList clonesList;
KisPSDLayerStyle* layerStyle;
};
......@@ -125,6 +127,7 @@ KisLayer::KisLayer(KisImageWSP image, const QString &name, quint8 opacity)
setOpacity(opacity);
m_d->image = image;
m_d->metaDataStore = new KisMetaData::Store();
m_d->layerStyle = 0;
}
KisLayer::KisLayer(const KisLayer& rhs)
......@@ -134,12 +137,14 @@ KisLayer::KisLayer(const KisLayer& rhs)
if (this != &rhs) {
m_d->image = rhs.m_d->image;
m_d->metaDataStore = new KisMetaData::Store(*rhs.m_d->metaDataStore);
m_d->layerStyle = new KisPSDLayerStyle(*rhs.m_d->layerStyle);
setName(rhs.name());
}
}
KisLayer::~KisLayer()
{
delete m_d->layerStyle;
delete m_d->metaDataStore;
delete m_d;
}
......@@ -168,6 +173,17 @@ const KoCompositeOp * KisLayer::compositeOp() const
return op ? op : parentNode->colorSpace()->compositeOp(COMPOSITE_OVER);
}
KisPSDLayerStyle *KisLayer::layerStyle() const
{
return m_d->layerStyle;
}
void KisLayer::setLayerStyle(KisPSDLayerStyle *layerStyle)
{
delete layerStyle;
m_d->layerStyle = layerStyle;
}
KoDocumentSectionModel::PropertyList KisLayer::sectionModelProperties() const
{
KoDocumentSectionModel::PropertyList l = KisBaseNode::sectionModelProperties();
......
......@@ -40,6 +40,7 @@ class QIcon;
class QBitArray;
class KisCloneLayer;
class KisNodeVisitor;
class KisPSDLayerStyle;
namespace KisMetaData
{
......@@ -79,6 +80,9 @@ public:
/// returns the layer's composite op for the colorspace of the layer's parent.
const KoCompositeOp * compositeOp() const;
KisPSDLayerStyle *layerStyle() const;
void setLayerStyle(KisPSDLayerStyle *layerStyle);
/**
* Ask the layer to assemble its data & apply all the effect masks
* to it.
......
......@@ -57,12 +57,27 @@ struct KisPSDLayerStyle::Private
};
KisPSDLayerStyle::KisPSDLayerStyle(QObject *parent)
: QObject(parent)
, d(new Private())
KisPSDLayerStyle::KisPSDLayerStyle()
: d(new Private())
{
}
KisPSDLayerStyle::~KisPSDLayerStyle()
{
delete d;
}
KisPSDLayerStyle::KisPSDLayerStyle(const KisPSDLayerStyle &rhs)
: d(new Private())
{
// XXX: copy all the contents of KisPSDLayerStyle::Private
}
void KisPSDLayerStyle::operator=(const KisPSDLayerStyle &rhs)
{
// XXX copy all the contents of KisPSDLayerStyle::Private
}
bool KisPSDLayerStyle::writeASL(QIODevice *io) const
{
return false;
......
......@@ -18,8 +18,6 @@
#ifndef KIS_PSD_LAYER_STYLE_H
#define KIS_PSD_LAYER_STYLE_H
#include <QObject>
class QIODevice;
#include <krita_export.h>
......@@ -29,11 +27,15 @@ class QIODevice;
* the PSD layer effects.
*
*/
class KRITAIMAGE_EXPORT KisPSDLayerStyle : public QObject
class KRITAIMAGE_EXPORT KisPSDLayerStyle
{
Q_OBJECT
public:
explicit KisPSDLayerStyle(QObject *parent = 0);
explicit KisPSDLayerStyle();
virtual ~KisPSDLayerStyle();
KisPSDLayerStyle(const KisPSDLayerStyle& rhs);
void operator=(const KisPSDLayerStyle& rhs);
/// Save the ASL style format. See http://www.tonton-pixel.com/Photoshop%20Additional%20File%20Formats/styles-file-format.html
bool writeASL(QIODevice *io) const;
......@@ -44,10 +46,6 @@ public:
bool write(QIODevice *io) const;
bool read(QIODevice *io);
signals:
public slots:
private:
struct Private;
Private * const d;
......
......@@ -28,7 +28,7 @@
void KisPSDLayerStyleTest::testRoundTrip()
{
KisPSDLayerStyle layerStyle(0);
KisPSDLayerStyle layerStyle;
QFile f(FILES_DATA_DIR + QDir::separator() + "teststyles.asl");
bool res = f.open(QIODevice::ReadOnly);
Q_ASSERT(res);
......
......@@ -199,7 +199,7 @@ bool psd_read_pattern(QIODevice *io)
}
QByteArray ba = io->read(len);
channelData << Compression::uncompress(length, ba, compression_mode);
channelData << Compression::uncompress(length, ba, (Compression::CompressionType)compression_mode);
}
}
......
......@@ -23,8 +23,9 @@
#include "kis_config.h"
KisDlgLayerStyle::KisDlgLayerStyle(QWidget *parent) :
KDialog(parent)
KisDlgLayerStyle::KisDlgLayerStyle(KisPSDLayerStyle *layerStyle, QWidget *parent)
: KDialog(parent)
, m_layerStyle(layerStyle)
{
setCaption(i18n("Layer Styles"));
setButtons(Ok | Cancel);
......@@ -34,34 +35,34 @@ KisDlgLayerStyle::KisDlgLayerStyle(QWidget *parent) :
wdgLayerStyles.setupUi(page);
setMainWidget(page);
stylesSelector = new StylesSelector(this);
wdgLayerStyles.stylesStack->addWidget(stylesSelector);
blendingOptions = new BlendingOptions(this);
wdgLayerStyles.stylesStack->addWidget(blendingOptions);
dropShadow = new DropShadow(this);
wdgLayerStyles.stylesStack->addWidget(dropShadow);
innerShadow = new InnerShadow(this);
wdgLayerStyles.stylesStack->addWidget(innerShadow);
outerGlow = new OuterGlow(this);
wdgLayerStyles.stylesStack->addWidget(outerGlow);
innerGlow = new InnerGlow(this);
wdgLayerStyles.stylesStack->addWidget(innerGlow);
bevelAndEmboss = new BevelAndEmboss(this);
wdgLayerStyles.stylesStack->addWidget(bevelAndEmboss);
contour = new Contour(this);
wdgLayerStyles.stylesStack->addWidget(contour);
texture = new Texture(this);
wdgLayerStyles.stylesStack->addWidget(texture);
satin = new Satin(this);
wdgLayerStyles.stylesStack->addWidget(satin);
colorOverlay = new ColorOverlay(this);
wdgLayerStyles.stylesStack->addWidget(colorOverlay);
gradientOverlay = new GradientOverlay(this);
wdgLayerStyles.stylesStack->addWidget(gradientOverlay);
patternOverlay = new PatternOverlay(this);
wdgLayerStyles.stylesStack->addWidget(patternOverlay);
stroke = new Stroke(this);
wdgLayerStyles.stylesStack->addWidget(stroke);
m_stylesSelector = new StylesSelector(this);
wdgLayerStyles.stylesStack->addWidget(m_stylesSelector);
m_blendingOptions = new BlendingOptions(this);
wdgLayerStyles.stylesStack->addWidget(m_blendingOptions);
m_dropShadow = new DropShadow(this);
wdgLayerStyles.stylesStack->addWidget(m_dropShadow);
m_innerShadow = new InnerShadow(this);
wdgLayerStyles.stylesStack->addWidget(m_innerShadow);
m_outerGlow = new OuterGlow(this);
wdgLayerStyles.stylesStack->addWidget(m_outerGlow);
m_innerGlow = new InnerGlow(this);
wdgLayerStyles.stylesStack->addWidget(m_innerGlow);
m_bevelAndEmboss = new BevelAndEmboss(this);
wdgLayerStyles.stylesStack->addWidget(m_bevelAndEmboss);
m_contour = new Contour(this);
wdgLayerStyles.stylesStack->addWidget(m_contour);
m_texture = new Texture(this);
wdgLayerStyles.stylesStack->addWidget(m_texture);
m_satin = new Satin(this);
wdgLayerStyles.stylesStack->addWidget(m_satin);
m_colorOverlay = new ColorOverlay(this);
wdgLayerStyles.stylesStack->addWidget(m_colorOverlay);
m_gradientOverlay = new GradientOverlay(this);
wdgLayerStyles.stylesStack->addWidget(m_gradientOverlay);
m_patternOverlay = new PatternOverlay(this);
wdgLayerStyles.stylesStack->addWidget(m_patternOverlay);
m_stroke = new Stroke(this);
wdgLayerStyles.stylesStack->addWidget(m_stroke);
KisConfig cfg;
wdgLayerStyles.stylesStack->setCurrentIndex(cfg.readEntry("KisDlgLayerStyle::current", 1));
......
/*
/*
* Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
......@@ -37,6 +37,7 @@
#include "ui_wdgTexture.h"
class QListWidgetItem;
class KisPSDLayerStyle;
class BevelAndEmboss : public QWidget {
public:
......@@ -143,7 +144,7 @@ class KisDlgLayerStyle : public KDialog
{
Q_OBJECT
public:
explicit KisDlgLayerStyle(QWidget *parent = 0);
explicit KisDlgLayerStyle(KisPSDLayerStyle *layerStyle, QWidget *parent = 0);
signals:
......@@ -151,22 +152,25 @@ public slots:
void changePage(QListWidgetItem *, QListWidgetItem*);
private:
KisPSDLayerStyle *m_layerStyle;
Ui::WdgStylesDialog wdgLayerStyles;
BevelAndEmboss *bevelAndEmboss;
BlendingOptions *blendingOptions;
ColorOverlay *colorOverlay;
Contour *contour;
DropShadow *dropShadow;
GradientOverlay *gradientOverlay;
InnerGlow *innerGlow;
InnerShadow *innerShadow;
OuterGlow *outerGlow;
PatternOverlay *patternOverlay;
Satin *satin;
Stroke *stroke;
StylesSelector *stylesSelector;
Texture *texture;
BevelAndEmboss *m_bevelAndEmboss;
BlendingOptions *m_blendingOptions;
ColorOverlay *m_colorOverlay;
Contour *m_contour;
DropShadow *m_dropShadow;
GradientOverlay *m_gradientOverlay;
InnerGlow *m_innerGlow;
InnerShadow *m_innerShadow;
OuterGlow *m_outerGlow;
PatternOverlay *m_patternOverlay;
Satin *m_satin;
Stroke *m_stroke;
StylesSelector *m_stylesSelector;
Texture *m_texture;
};
......
......@@ -63,6 +63,7 @@
#include <kis_painter.h>
#include <metadata/kis_meta_data_store.h>
#include <metadata/kis_meta_data_merge_strategy_registry.h>
#include <kis_psd_layer_style.h>
#include "kis_config.h"
#include "kis_cursor.h"
......@@ -94,6 +95,7 @@
#include "kis_action_manager.h"
class KisSaveGroupVisitor : public KisNodeVisitor
{
public:
......@@ -892,9 +894,10 @@ void KisLayerManager::layerStyle()
KisLayerSP layer = activeLayer();
if (!layer) return;
KisDlgLayerStyle dlg;
KisPSDLayerStyle *style = new KisPSDLayerStyle(*layer->layerStyle());
KisDlgLayerStyle dlg(style);
if (dlg.exec() == QDialog::Accepted) {
// Do stuff...
layer->setLayerStyle(style);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment