Commit c8a6a249 authored by Dmitry Kazakov's avatar Dmitry Kazakov
Browse files

Disable Lightness and Gradient for non-pixel brush engines

This mode generates weird results with colorsmudge engine, it needs
some special handling in it.
parent 51a7b123
......@@ -41,7 +41,7 @@ KisBrushOpResources::KisBrushOpResources(const KisPaintOpSettingsSP settings, Ki
sharpnessOption->readOptionSetting(settings);
sharpnessOption->resetAllSensors();
textureOption.reset(new KisTextureProperties(painter->device()->defaultBounds()->currentLevelOfDetail()));
textureOption.reset(new KisTextureProperties(painter->device()->defaultBounds()->currentLevelOfDetail(), SupportsGradientMode | SupportsLightnessMode));
textureOption->fillProperties(settings, settings->resourcesInterface(), settings->canvasResourcesInterface());
m_d->hsvOptions.append(KisPressureHSVOption::createHueOption());
......
......@@ -45,7 +45,7 @@
KisBrushOp::KisBrushOp(const KisPaintOpSettingsSP settings, KisPainter *painter, KisNodeSP node, KisImageSP image)
: KisBrushBasedPaintOp(settings, painter)
: KisBrushBasedPaintOp(settings, painter, SupportsGradientMode | SupportsLightnessMode)
, m_opacityOption(node)
, m_avgSpacing(50)
, m_avgNumDabs(50)
......
......@@ -77,7 +77,7 @@ KisBrushOpSettingsWidget::KisBrushOpSettingsWidget(QWidget* parent)
KisPaintActionTypeOption *actionTypeOption = new KisPaintActionTypeOption();
addPaintOpOption(actionTypeOption, i18n("Painting Mode"));
addPaintOpOption(new KisTextureOption(), i18n("Pattern"));
addPaintOpOption(new KisTextureOption(SupportsLightnessMode | SupportsGradientMode), i18n("Pattern"));
addPaintOpOption(new KisCurveOptionWidget(new KisPressureTextureStrengthOption(), i18n("Weak"), i18n("Strong")), i18n("Strength"));
KisMaskingBrushOption::MasterBrushSizeAdapter sizeAdapter =
......
......@@ -63,9 +63,9 @@ void KisBrushBasedPaintOp::preinitializeOpStatically(KisPaintOpSettingsSP settin
#endif /* HAVE_THREADED_TEXT_RENDERING_WORKAROUND */
KisBrushBasedPaintOp::KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter* painter)
KisBrushBasedPaintOp::KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter* painter, KisBrushTextureFlags textureFlags)
: KisPaintOp(painter),
m_textureProperties(painter->device()->defaultBounds()->currentLevelOfDetail())
m_textureProperties(painter->device()->defaultBounds()->currentLevelOfDetail(), textureFlags)
{
Q_ASSERT(settings);
......
......@@ -52,7 +52,7 @@ class PAINTOP_EXPORT KisBrushBasedPaintOp : public KisPaintOp
public:
KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter* painter);
KisBrushBasedPaintOp(const KisPaintOpSettingsSP settings, KisPainter* painter, KisBrushTextureFlags textureFlags = None);
~KisBrushBasedPaintOp() override;
bool checkSizeTooSmall(qreal scale);
......
......@@ -9,7 +9,7 @@
#include "widgets/kis_gradient_chooser.h"
KisTextureChooser::KisTextureChooser(QWidget *parent)
KisTextureChooser::KisTextureChooser(KisBrushTextureFlags flags, QWidget *parent)
: QWidget(parent)
{
setupUi(this);
......@@ -40,9 +40,19 @@ KisTextureChooser::KisTextureChooser(QWidget *parent)
QStringList texturingModes;
texturingModes << i18n("Multiply Alpha") << i18n("Subtract Alpha") << i18n("Lightness Map") << i18n("Gradient Map");
cmbTexturingMode->addItems(texturingModes);
cmbTexturingMode->setCurrentIndex(KisTextureProperties::SUBTRACT);
cmbTexturingMode->addItem(i18n("Multiply Alpha"), KisTextureProperties::MULTIPLY);
cmbTexturingMode->addItem(i18n("Subtract Alpha"), KisTextureProperties::SUBTRACT);
if (flags & SupportsLightnessMode) {
cmbTexturingMode->addItem(i18n("Lightness Map"), KisTextureProperties::LIGHTNESS);
}
if (flags & SupportsGradientMode) {
cmbTexturingMode->addItem(i18n("Gradient Map"), KisTextureProperties::GRADIENT);
}
selectTexturingMode(KisTextureProperties::SUBTRACT);
QStringList cutOffPolicies;
cutOffPolicies << i18n("Cut Off Disabled") << i18n("Cut Off Brush") << i18n("Cut Off Pattern");
......@@ -62,3 +72,20 @@ KisTextureChooser::~KisTextureChooser()
{
}
bool KisTextureChooser::selectTexturingMode(KisTextureProperties::TexturingMode mode)
{
int i = 0;
for (; i < cmbTexturingMode->count(); i++) {
if (cmbTexturingMode->itemData(i) == mode) {
cmbTexturingMode->setCurrentIndex(i);
}
}
return i < cmbTexturingMode->count();
}
KisTextureProperties::TexturingMode KisTextureChooser::texturingMode() const
{
return KisTextureProperties::TexturingMode(cmbTexturingMode->currentData().value<int>());
}
......@@ -9,13 +9,18 @@
#include "ui_wdgtexturechooser.h"
#include "kis_texture_option.h"
class KisTextureChooser : public QWidget, public Ui::KisWdgTextureChooser
{
Q_OBJECT
public:
KisTextureChooser(QWidget *parent = 0);
KisTextureChooser(KisBrushTextureFlags flags, QWidget *parent = 0);
~KisTextureChooser();
bool selectTexturingMode(KisTextureProperties::TexturingMode mode);
KisTextureProperties::TexturingMode texturingMode() const;
};
#endif
......@@ -45,9 +45,9 @@
#include <KoCanvasResourcesInterface.h>
KisTextureOption::KisTextureOption()
KisTextureOption::KisTextureOption(KisBrushTextureFlags flags)
: KisPaintOpOption(KisPaintOpOption::TEXTURE, true)
, m_textureOptions(new KisTextureChooser())
, m_textureOptions(new KisTextureChooser(flags))
{
setObjectName("KisTextureOption");
setConfigurationPage(m_textureOptions);
......@@ -126,7 +126,7 @@ void KisTextureOption::writeOptionSetting(KisPropertiesConfigurationSP setting)
m_textureOptions->offsetSliderY ->setEnabled(true);
}
int texturingMode = m_textureOptions->cmbTexturingMode->currentIndex();
int texturingMode = m_textureOptions->texturingMode();
bool invert = (m_textureOptions->chkInvert->checkState() == Qt::Checked);
setting->setProperty("Texture/Pattern/Scale", scale);
......@@ -172,7 +172,7 @@ void KisTextureOption::readOptionSetting(const KisPropertiesConfigurationSP sett
m_textureOptions->offsetSliderY->setValue(setting->getInt("Texture/Pattern/OffsetY"));
m_textureOptions->randomOffsetX->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetX"));
m_textureOptions->randomOffsetY->setChecked(setting->getBool("Texture/Pattern/isRandomOffsetY"));
m_textureOptions->cmbTexturingMode->setCurrentIndex(setting->getInt("Texture/Pattern/TexturingMode", KisTextureProperties::MULTIPLY));
m_textureOptions->selectTexturingMode(KisTextureProperties::TexturingMode(setting->getInt("Texture/Pattern/TexturingMode", KisTextureProperties::MULTIPLY)));
m_textureOptions->cmbCutoffPolicy->setCurrentIndex(setting->getInt("Texture/Pattern/CutoffPolicy"));
m_textureOptions->cutoffSlider->slotModifyBlack(setting->getInt("Texture/Pattern/CutoffLeft", 0));
m_textureOptions->cutoffSlider->slotModifyWhite(setting->getInt("Texture/Pattern/CutoffRight", 255));
......@@ -200,9 +200,10 @@ void KisTextureOption::resetGUI(KoResourceSP res)
/**********************************************************************/
KisTextureProperties::KisTextureProperties(int levelOfDetail)
KisTextureProperties::KisTextureProperties(int levelOfDetail, KisBrushTextureFlags flags)
: m_gradient(0)
, m_levelOfDetail(levelOfDetail)
, m_flags(flags)
{
}
......@@ -214,7 +215,16 @@ void KisTextureProperties::fillProperties(const KisPropertiesConfigurationSP set
}
m_texturingMode = (TexturingMode)setting->getInt("Texture/Pattern/TexturingMode", MULTIPLY);
bool preserveAlpha = m_texturingMode == LIGHTNESS || m_texturingMode == GRADIENT;
if (!(m_flags & SupportsLightnessMode) && (m_texturingMode == LIGHTNESS)) {
m_texturingMode = SUBTRACT;
}
if (!(m_flags & SupportsGradientMode) && (m_texturingMode == GRADIENT)) {
m_texturingMode = SUBTRACT;
}
const bool preserveAlpha = m_texturingMode == LIGHTNESS || m_texturingMode == GRADIENT;
m_maskInfo = toQShared(new KisTextureMaskInfo(m_levelOfDetail, preserveAlpha));
if (!m_maskInfo->fillProperties(setting, resourcesInterface)) {
......
......@@ -27,12 +27,22 @@ class KisPropertiesConfiguration;
class KisPaintopLodLimitations;
class KisResourcesInterface;
enum KisBrushTextureFlag
{
None = 0x0,
SupportsLightnessMode = 0x1,
SupportsGradientMode = 0x2,
};
Q_DECLARE_FLAGS(KisBrushTextureFlags, KisBrushTextureFlag)
Q_DECLARE_OPERATORS_FOR_FLAGS(KisBrushTextureFlags)
class PAINTOP_EXPORT KisTextureOption : public KisPaintOpOption
{
Q_OBJECT
public:
explicit KisTextureOption();
explicit KisTextureOption(KisBrushTextureFlags flags = None);
~KisTextureOption() override;
public Q_SLOTS:
......@@ -49,13 +59,12 @@ private Q_SLOTS:
private:
/// UI Widget that stores all the texture options
KisTextureChooser* m_textureOptions;
};
class PAINTOP_EXPORT KisTextureProperties
{
public:
KisTextureProperties(int levelOfDetail);
KisTextureProperties(int levelOfDetail, KisBrushTextureFlags flags = None);
enum TexturingMode {
MULTIPLY,
......@@ -97,6 +106,7 @@ private:
private:
KisPressureTextureStrengthOption m_strengthOption;
KisTextureMaskInfoSP m_maskInfo;
KisBrushTextureFlags m_flags;
};
#endif // KIS_TEXTURE_OPTION_H
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